body {
    margin: 0;
    overflow: hidden;
}

#game-container {
    width: 100vw;
    height: 100vh;
}

#score {
    position: fixed;
    top: 20px;
    left: 20px;
    color: white;
    font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
    font-size: 24px;
    text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
} 

#timer {
    position: fixed;
    top: 60px;
    left: 20px;
    color: white;
    font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
    font-size: 24px;
    text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
}

#home-button {
    position: fixed;
    top: 20px;
    right: 20px;
    color: white;
    font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
    font-size: 24px;
    text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
    background-color: #000;
    padding: 10px;
    border-radius: 5px;
}

#home-button a {
    color: white;
    text-decoration: none;
}

/* Countdown overlay */
#countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#countdown {
    font-size: 150px;
    color: white;
    font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
    font-weight: bold;
    text-shadow: 3px 3px 5px rgba(0, 0, 0, 0.7);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* End game overlay */
#end-game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

#end-game-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

#end-game-message {
    padding: 40px;
    text-align: center;
    transform: translateY(20px);
    transition: transform 0.5s ease;
    max-width: 80%;
}

#end-game-message h1 {
    font-size: 48px;
    margin-bottom: 20px;
    color: #ffd700;
    text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
}

#end-game-message p {
    font-size: 32px;
    margin-bottom: 30px;
    color: #ffd700;
    font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
    text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
}

#new-game-button {
    background-color: #ffd700;
    color: #000;
    border: none;
    padding: 15px 30px;
    font-size: 24px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
    margin-top: 20px;
    display: block;
    width: 80%;
    margin-left: auto;
    margin-right: auto;
}

#new-game-button:hover {
    background-color: #ffef00;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 215, 0, 1);
}

/* Optimize for mobile devices */
@media (max-width: 768px) {
    #game-container {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
    
    #score {
        font-size: 16px;
        padding: 8px 12px;
        top: 10px;
        left: 10px;
    }
    
    #timer {
        font-size: 16px;
        padding: 8px 12px;
        top: 40px;
        left: 10px;
    }
    
    #home-button {
        font-size: 14px;
        padding: 6px 10px;
        top: 10px;
        right: 10px;
    }
    
    #countdown {
        font-size: 100px;
    }
    
    #end-game-message {
        padding: 20px;
        width: 80%;
    }
    
    #end-game-message h1 {
        font-size: 32px;
    }
    
    #end-game-message p {
        font-size: 18px;
    }
    
    #new-game-button {
        padding: 10px 20px;
        font-size: 16px;
    }
}

/* Add hardware acceleration for smoother rendering */
canvas {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Prevent selection and improve touch handling */
body, #game-container, canvas {
    -webkit-touch-callout: none; /* Prevent callout to copy image, etc when tap to hold */
    -webkit-user-select: none;   /* Prevent text selection when tapping */
    -khtml-user-select: none;    /* Same for Konqueror */
    -moz-user-select: none;      /* Firefox */
    -ms-user-select: none;       /* Internet Explorer/Edge */
    user-select: none;           /* Non-prefixed version */
    touch-action: none;          /* Disable browser handling of all touch gestures */
    -webkit-tap-highlight-color: rgba(0,0,0,0); /* Remove tap highlight on mobile */
    overscroll-behavior: none;   /* Prevent pull-to-refresh and overscroll effects */
}

/* Lock the viewport to prevent scrolling */
html, body {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior-y: none; /* Prevent pull-to-refresh */
}

/* Scoreboard styles */
#name-input-container {
    margin: 20px 0;
}

#player-name {
    padding: 10px;
    font-size: 18px;
    border: 2px solid #ffd700;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.9);
    width: 70%;
    margin-bottom: 10px;
}

#submit-score {
    background-color: #ffd700;
    color: #000;
    border: none;
    padding: 10px 20px;
    font-size: 18px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    margin-top: 10px;
}

#submit-score:hover {
    background-color: #ffef00;
    transform: scale(1.05);
}

#scoreboard-container {
    margin: 20px 0;
    width: 100%;
}

#scoreboard-container h2 {
    color: #ffd700;
    font-size: 28px;
    margin-bottom: 15px;
    text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
}

#scoreboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    border: 2px solid #ffd700;
    overflow: hidden;
}

.score-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
    color: white;
}

.score-item:last-child {
    border-bottom: none;
}

.score-rank {
    font-weight: bold;
    color: #ffd700;
    width: 10%;
}

.score-name {
    font-weight: bold;
    width: 40%;
    text-align: left;
}

.score-value {
    color: #ffd700;
    width: 30%;
    text-align: right;
}

.score-date {
    color: #aaa;
    font-size: 0.8em;
    width: 20%;
    text-align: right;
}

.empty-score {
    padding: 15px;
    text-align: center;
    color: #aaa;
    font-style: italic;
}

/* Mobile adjustments for scoreboard */
@media (max-width: 768px) {
    #player-name {
        width: 90%;
        font-size: 16px;
        padding: 8px;
    }
    
    #submit-score {
        font-size: 16px;
        padding: 8px 15px;
    }
    
    #scoreboard-container h2 {
        font-size: 22px;
    }
    
    .score-item {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    .score-date {
        display: none; /* Hide date on mobile to save space */
    }
    
    .score-name {
        width: 50%;
    }
    
    .score-value {
        width: 40%;
    }
}
