* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Press Start 2P', monospace;
    overflow: hidden;
    background: linear-gradient(180deg, #4169E1 0%, #87CEEB 100%);
    min-height: 100vh;
}

#scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.screen.active {
    display: flex;
}

/* Title Screen */
#title-screen {
    background: rgba(0, 0, 0, 0.7);
    padding: 20px;
}

.game-title {
    font-family: 'Bangers', cursive;
    font-size: clamp(2rem, 8vw, 5rem);
    color: #FFD700;
    text-shadow: 
        4px 4px 0 #FF6B00,
        8px 8px 0 #8B4513,
        0 0 30px rgba(255, 215, 0, 0.5);
    letter-spacing: 4px;
    margin-bottom: 20px;
    animation: titleFloat 2s ease-in-out infinite;
}

@keyframes titleFloat {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    50% { transform: translateY(-10px) rotate(1deg); }
}

.high-score-display {
    font-size: clamp(0.6rem, 2vw, 1rem);
    color: #00FF00;
    margin-bottom: 30px;
    text-shadow: 2px 2px 0 #006400;
}

.menu-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.setting-row span {
    color: #87CEEB;
    font-size: clamp(0.5rem, 1.5vw, 0.8rem);
    min-width: 60px;
}

.setting-buttons {
    display: flex;
    gap: 8px;
}

.setting-buttons button {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.4rem, 1.2vw, 0.6rem);
    padding: 8px 12px;
    background: #333;
    color: #888;
    border: 2px solid #555;
    cursor: pointer;
    transition: all 0.2s;
}

.setting-buttons button.selected {
    background: #4169E1;
    color: #FFD700;
    border-color: #FFD700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.setting-buttons button:hover {
    background: #555;
}

.start-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.8rem, 2.5vw, 1.2rem);
    padding: 15px 30px;
    background: linear-gradient(180deg, #32CD32 0%, #228B22 100%);
    color: #fff;
    border: 4px solid #FFD700;
    cursor: pointer;
    box-shadow: 
        0 4px 0 #006400,
        0 0 20px rgba(50, 205, 50, 0.5);
    transition: all 0.1s;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 0 #006400,
        0 0 30px rgba(50, 205, 50, 0.7);
}

.start-btn:active {
    transform: translateY(2px);
    box-shadow: 
        0 2px 0 #006400,
        0 0 15px rgba(50, 205, 50, 0.5);
}

.pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

/* Game HUD */
#game-hud {
    pointer-events: none;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 15px;
    background: transparent;
}

.hud-score, .hud-length {
    font-size: clamp(0.6rem, 2vw, 1rem);
    color: #FFD700;
    text-shadow: 2px 2px 0 #000;
    margin-bottom: 10px;
}

/* Game Over Screen */
#game-over-screen {
    background: rgba(0, 0, 0, 0.85);
}

.game-over-title {
    font-family: 'Bangers', cursive;
    font-size: clamp(2rem, 7vw, 4rem);
    color: #FF4444;
    text-shadow: 
        4px 4px 0 #8B0000,
        0 0 30px rgba(255, 0, 0, 0.5);
    margin-bottom: 20px;
    animation: gameOverShake 0.5s ease-out;
}

@keyframes gameOverShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px) rotate(-2deg); }
    40% { transform: translateX(10px) rotate(2deg); }
    60% { transform: translateX(-5px) rotate(-1deg); }
    80% { transform: translateX(5px) rotate(1deg); }
}

#new-high-score {
    font-size: clamp(0.6rem, 2vw, 1rem);
    color: #FFD700;
    margin-bottom: 20px;
    animation: newHighScore 0.5s ease-out infinite alternate;
}

#new-high-score.hidden {
    display: none;
}

@keyframes newHighScore {
    from { transform: scale(1); text-shadow: 0 0 10px #FFD700; }
    to { transform: scale(1.1); text-shadow: 0 0 20px #FFD700, 0 0 30px #FF6B00; }
}

.final-stats {
    font-size: clamp(0.5rem, 1.5vw, 0.8rem);
    color: #87CEEB;
    margin-bottom: 30px;
    text-align: center;
    line-height: 2;
}

.game-over-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.game-over-buttons button {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.5rem, 1.5vw, 0.8rem);
    padding: 12px 20px;
    background: linear-gradient(180deg, #4169E1 0%, #2E4A8E 100%);
    color: #fff;
    border: 3px solid #FFD700;
    cursor: pointer;
    box-shadow: 0 3px 0 #1a2a5e;
    transition: all 0.1s;
}

.game-over-buttons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 #1a2a5e;
}

.game-over-buttons button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 #1a2a5e;
}

/* Mobile Controls */
#mobile-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: grid;
    grid-template-areas: 
        ". up ."
        "left . right"
        ". down .";
    gap: 5px;
    pointer-events: auto;
    z-index: 20;
}

#mobile-controls.hidden {
    display: none;
}

.dpad-btn {
    width: 50px;
    height: 50px;
    font-size: 20px;
    background: rgba(65, 105, 225, 0.8);
    color: #FFD700;
    border: 3px solid #FFD700;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 0 #1a2a5e;
    transition: all 0.1s;
}

.dpad-btn:active {
    transform: scale(0.95);
    background: rgba(65, 105, 225, 1);
}

.dpad-btn[data-dir="up"] { grid-area: up; }
.dpad-btn[data-dir="down"] { grid-area: down; }
.dpad-btn[data-dir="left"] { grid-area: left; }
.dpad-btn[data-dir="right"] { grid-area: right; }

/* CRT Overlay */
#crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    background: 
        repeating-linear-gradient(
            0deg,
            rgba(0, 0, 0, 0.15),
            rgba(0, 0, 0, 0.15) 1px,
            transparent 1px,
            transparent 2px
        );
    animation: crtFlicker 0.1s infinite;
}

#crt-overlay.hidden {
    display: none;
}

@keyframes crtFlicker {
    0% { opacity: 0.95; }
    50% { opacity: 1; }
    100% { opacity: 0.95; }
}

/* Footer */
footer {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
}

footer a {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.5rem;
    color: #FFD700;
    text-decoration: none;
    background: rgba(0, 0, 0, 0.6);
    padding: 5px 10px;
    border: 2px solid #FFD700;
    transition: all 0.2s;
}

footer a:hover {
    background: #FFD700;
    color: #000;
}

/* Desktop adjustments */
@media (min-width: 768px) {
    #mobile-controls {
        display: none !important;
    }
}

@media (max-width: 767px) {
    #mobile-controls:not(.hidden) {
        display: grid !important;
    }
    
    .dpad-btn {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
}