/* Base Styles */
:root {
    --neon-blue: #00f3ff;
    --neon-purple: #bc13fe;
    --neon-green: #0aff0a;
    --neon-red: #ff003c;
    --bg-dark: #050510;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Roboto', sans-serif;
}

body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at center, #1a1a2e 0%, #000000 100%);
    color: #fff;
    font-family: var(--font-body);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
}

/* Background Grid Effect - REMOVED for performance/resize stability */

/* Game Container */
#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    box-shadow: none;
    border: none;
    border-radius: 0;
    backdrop-filter: none;
    padding: 0;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Canvas Styling */
#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* HUD Styling */
#hud {
    position: absolute;
    top: 20px;
    left: 25px;
    font-family: var(--font-display);
    font-size: 16px;
    letter-spacing: 1px;
    background: rgba(0, 0, 0, 0.6);
    padding: 12px 25px;
    border-radius: 30px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(15px);
    display: flex;
    gap: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    transform: skewX(-10deg);
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 8px;
    transform: skewX(10deg);
    /* Counter-skew text */
}

.hud-item span:first-child {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 700;
}

#score {
    color: var(--neon-blue);
    text-shadow: 0 0 10px var(--neon-blue);
    font-size: 20px;
}

#multiplier {
    color: var(--neon-green);
    text-shadow: 0 0 10px var(--neon-green);
    font-size: 20px;
}

#health {
    color: var(--neon-red);
    text-shadow: 0 0 10px var(--neon-red);
    font-size: 20px;
}

/* Screen Overlays */
.screen-overlay {
    display: none;
    /* Hidden by default, toggled by JS */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: rgba(10, 10, 25, 0.95);
    padding: 40px 60px;
    border-radius: 20px;
    border: 1px solid var(--neon-purple);
    box-shadow:
        0 0 50px rgba(188, 19, 254, 0.3),
        inset 0 0 20px rgba(188, 19, 254, 0.1);
    backdrop-filter: blur(20px);
    min-width: 400px;
    z-index: 100;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* Show flex when active */
.screen-overlay.active {
    display: flex;
}

/* Specific override for start screen to be visible initially if needed, 
   but we will handle visibility via JS classes/style */
#start-screen {
    display: flex;
}

.game-title {
    font-size: 64px;
    margin: 0;
    color: var(--neon-blue);
    font-family: var(--font-display);
    letter-spacing: 6px;
    text-shadow: 0 0 20px var(--neon-blue);
}

.instructions {
    margin: 20px 0;
    text-align: left;
    width: 100%;
}

.instructions h3 {
    color: var(--neon-green);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.control-group p {
    margin: 10px 0;
    font-size: 16px;
    color: #ddd;
    display: flex;
    align-items: center;
    gap: 10px;
}

.key {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--neon-blue);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--neon-blue);
    font-family: var(--font-display);
    font-size: 12px;
    box-shadow: 0 0 5px rgba(0, 243, 255, 0.2);
}

.objective {
    margin-top: 20px;
    font-style: italic;
    color: #aaa;
    font-size: 14px;
    text-align: center;
}

#game-over h2 {
    margin: 0 0 20px 0;
    color: var(--neon-red);
    font-family: var(--font-display);
    font-size: 48px;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-shadow:
        0 0 10px var(--neon-red),
        0 0 20px var(--neon-red);
    animation: glitch 2s infinite;
}

#game-over p {
    font-size: 18px;
    margin: 15px 0;
    color: #ccc;
    font-family: var(--font-display);
}

#final-score {
    color: var(--neon-blue);
    font-weight: bold;
    font-size: 36px;
    text-shadow: 0 0 15px var(--neon-blue);
    display: block;
    margin-top: 10px;
}

/* Button Styling */
.neon-btn {
    background: transparent;
    border: 2px solid var(--neon-blue);
    color: var(--neon-blue);
    padding: 15px 40px;
    font-family: var(--font-display);
    font-size: 18px;
    margin-top: 10px;
    cursor: pointer;
    border-radius: 5px;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.1);
}

.neon-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 243, 255, 0.2), transparent);
    transition: 0.5s;
}

.neon-btn:hover {
    background: var(--neon-blue);
    color: #000;
    box-shadow: 0 0 30px var(--neon-blue);
    transform: scale(1.05);
}

.neon-btn:hover::before {
    left: 100%;
}

.neon-btn:active {
    transform: scale(0.95);
}

/* Animations */
@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.02);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes glitch {
    0% {
        text-shadow: 2px 2px var(--neon-blue), -2px -2px var(--neon-red);
    }

    25% {
        text-shadow: -2px 2px var(--neon-blue), 2px -2px var(--neon-red);
    }

    50% {
        text-shadow: 2px -2px var(--neon-blue), -2px 2px var(--neon-red);
    }

    75% {
        text-shadow: -2px -2px var(--neon-blue), 2px 2px var(--neon-red);
    }

    100% {
        text-shadow: 2px 2px var(--neon-blue), -2px -2px var(--neon-red);
    }
}

/* Responsive Design */
@media (max-width: 850px) {
    #hud {
        width: 90%;
        left: 50%;
        transform: translateX(-50%) skewX(0);
        justify-content: center;
        top: 10px;
        padding: 8px 15px;
        flex-wrap: wrap;
        padding: 5px 15px;
    }

    .screen-overlay {
        padding: 10px 20px;
        gap: 10px;
    }

}

/* Mobile Landscape specific adjustments (800x450 target) */
@media (max-height: 500px) {
    #hud {
        top: 5px;
        padding: 5px 15px;
    }

    .screen-overlay {
        padding: 10px 20px;
        gap: 10px;
    }

    .game-title {
        font-size: 32px;
        margin-bottom: 5px;
    }

    .instructions {
        margin: 5px 0;
    }

    .control-group p {
        margin: 5px 0;
        font-size: 14px;
    }

    .neon-btn {
        padding: 8px 25px;
        margin-top: 5px;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #000;
}

::-webkit-scrollbar-thumb {
    background: var(--neon-purple);
    border-radius: 3px;
}

/* On-Screen Controls */
#controls-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to canvas/game */
    z-index: 10;
}

.control-btn {
    position: absolute;
    pointer-events: auto;
    /* Re-enable clicks for buttons */
    background: rgba(0, 243, 255, 0.1);
    border: 2px solid rgba(0, 243, 255, 0.5);
    color: #00f3ff;
    font-family: 'Orbitron', sans-serif;
    border-radius: 50%;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.control-btn:active {
    background: rgba(0, 243, 255, 0.3);
    transform: scale(0.95);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.5);
}

#pause-btn-hud {
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    font-size: 14px;
    font-weight: bold;
}

#dash-btn-hud {
    bottom: 40px;
    right: 40px;
    width: 80px;
    height: 80px;
    font-size: 16px;
    font-weight: bold;
    border-color: rgba(255, 0, 60, 0.5);
    color: #ff003c;
    background: rgba(255, 0, 60, 0.1);
}

#dash-btn-hud:active {
    background: rgba(255, 0, 60, 0.3);
    box-shadow: 0 0 20px rgba(255, 0, 60, 0.6);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    #dash-btn-hud {
        bottom: 30px;
        right: 30px;
        width: 90px;
        height: 90px;
    }
}