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

body {
    font-family: 'Press Start 2P', cursive;
    background: #0a0a1a;
    overflow: hidden;
    color: #fff;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

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

#scene-container {
    width: 100%;
    height: 100%;
}

#scene-container canvas {
    display: block;
}

/* CRT Scanline overlay */
#scene-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1) 0px,
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 3px
    );
    z-index: 100;
}

/* HUD */
#hud {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    padding: 0 20px;
    z-index: 10;
    pointer-events: none;
}

#score-display, #high-score-display, #balls-display {
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px 25px;
    border: 2px solid #ff00ff;
    border-radius: 5px;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.3);
}

.score-label {
    font-size: 10px;
    color: #ff00ff;
    margin-bottom: 5px;
}

#current-score {
    font-size: 24px;
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff;
}

#current-score.score-flash {
    animation: scoreFlash 0.2s ease-out;
}

@keyframes scoreFlash {
    0% { transform: scale(1.3); color: #ffff00; }
    100% { transform: scale(1); color: #00ffff; }
}

#high-score {
    font-size: 18px;
    color: #ffcc00;
    text-shadow: 0 0 10px #ffcc00;
}

#balls-remaining {
    font-size: 20px;
}

/* Tilt Warning */
#tilt-warning {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    color: #ff0000;
    text-shadow: 0 0 30px #ff0000;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 50;
    animation: tiltPulse 0.3s infinite;
}

#tilt-warning.show {
    opacity: 1;
}

@keyframes tiltPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
}

/* Start Screen */
#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 30, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    cursor: pointer;
}

#start-screen.hidden {
    display: none;
}

.arcade-frame {
    text-align: center;
    padding: 40px;
    background: linear-gradient(180deg, #1a0a2e 0%, #0d0620 100%);
    border: 4px solid #ff00ff;
    border-radius: 10px;
    box-shadow: 
        0 0 50px rgba(255, 0, 255, 0.4),
        inset 0 0 30px rgba(0, 255, 255, 0.1);
    max-width: 90%;
}

.arcade-frame h1 {
    font-size: 36px;
    color: #00ffff;
    text-shadow: 
        0 0 20px #00ffff,
        4px 4px 0 #ff00ff;
    margin-bottom: 30px;
    line-height: 1.3;
}

.insert-coin {
    font-size: 16px;
    color: #ffff00;
    animation: blink 1s infinite;
    margin-bottom: 20px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.start-prompt {
    font-size: 12px;
    color: #ffffff;
    margin-bottom: 30px;
}

.controls-info {
    font-size: 8px;
    color: #aaaaaa;
    line-height: 2;
    margin-bottom: 20px;
}

.controls-info p {
    margin: 5px 0;
}

.mobile-controls-info {
    display: none;
    font-size: 8px;
    color: #00ffff;
    line-height: 2;
    margin-bottom: 20px;
    padding: 10px;
    border: 1px solid #00ffff;
    border-radius: 5px;
    background: rgba(0, 255, 255, 0.1);
}

.mobile-controls-info p {
    margin: 5px 0;
}

#leaderboard {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #00ffff;
    border-radius: 5px;
}

.leaderboard-title {
    font-size: 12px;
    color: #00ffff;
    margin-bottom: 10px;
}

.leaderboard-entry {
    font-size: 10px;
    color: #ffcc00;
    margin: 5px 0;
}

.no-scores {
    font-size: 8px;
    color: #666;
}

/* Game Over Screen */
#game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 30, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    cursor: pointer;
}

#game-over-screen.hidden {
    display: none;
}

.game-over-content {
    text-align: center;
    padding: 40px;
    background: linear-gradient(180deg, #2e0a1a 0%, #200610 100%);
    border: 4px solid #ff0044;
    border-radius: 10px;
    box-shadow: 0 0 50px rgba(255, 0, 68, 0.4);
}

.game-over-content h2 {
    font-size: 32px;
    color: #ff0044;
    text-shadow: 0 0 20px #ff0044;
    margin-bottom: 20px;
}

#final-score-label {
    font-size: 12px;
    color: #aaaaaa;
    margin-bottom: 10px;
}

#final-score {
    font-size: 36px;
    color: #00ffff;
    text-shadow: 0 0 20px #00ffff;
    margin-bottom: 20px;
}

#new-high-score {
    font-size: 14px;
    color: #ffff00;
    animation: newHighScore 0.5s infinite;
    margin-bottom: 20px;
}

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

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

.play-again {
    font-size: 12px;
    color: #ffffff;
    animation: blink 1s infinite;
}

/* Mobile Controls */
#mobile-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    justify-content: space-around;
    padding: 0 20px;
    z-index: 150;
}

.flipper-btn, .launch-btn {
    width: 80px;
    height: 80px;
    background: rgba(255, 0, 255, 0.3);
    border: 3px solid #ff00ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #ff00ff;
    text-shadow: 0 0 10px #ff00ff;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    cursor: pointer;
    transition: transform 0.1s, background 0.1s;
}

.flipper-btn:active, .flipper-btn.active {
    background: rgba(255, 0, 255, 0.6);
    transform: scale(0.95);
}

.launch-btn {
    background: rgba(0, 255, 255, 0.3);
    border-color: #00ffff;
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff;
}

.launch-btn:active, .launch-btn.active {
    background: rgba(0, 255, 255, 0.6);
    transform: scale(0.95);
}

/* Footer */
footer {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 8px;
    color: #444;
    z-index: 50;
    pointer-events: auto;
}

footer a {
    color: #ff00ff;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Mobile */
@media (max-width: 768px) {
    #mobile-controls {
        display: flex;
    }
    
    .controls-info {
        display: none;
    }
    
    .mobile-controls-info {
        display: block;
    }
    
    #hud {
        top: 10px;
        padding: 0 10px;
    }
    
    #score-display, #high-score-display, #balls-display {
        padding: 8px 12px;
    }
    
    .score-label {
        font-size: 6px;
    }
    
    #current-score {
        font-size: 14px;
    }
    
    #high-score {
        font-size: 12px;
    }
    
    #balls-remaining {
        font-size: 14px;
    }
    
    .arcade-frame h1 {
        font-size: 24px;
    }
    
    .insert-coin {
        font-size: 12px;
    }
    
    footer {
        bottom: 110px;
    }
}

@media (max-width: 480px) {
    .arcade-frame {
        padding: 20px;
    }
    
    .arcade-frame h1 {
        font-size: 20px;
    }
    
    .flipper-btn, .launch-btn {
        width: 70px;
        height: 70px;
        font-size: 20px;
    }
}

/* Landscape mobile optimization */
@media (max-height: 500px) and (orientation: landscape) {
    #mobile-controls {
        bottom: 10px;
    }
    
    .flipper-btn, .launch-btn {
        width: 60px;
        height: 60px;
        font-size: 18px;
    }
    
    footer {
        bottom: 80px;
    }
}