@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Rajdhani:wght@600;700&display=swap');

:root {
    --neon-pink: #ff0055;
    --neon-cyan: #00ffcc;
    --neon-yellow: #ffcc00;
    --neon-purple: #9900ff;
    --bg-dark: #0a0512;
    --panel-bg: rgba(18, 10, 36, 0.85);
    --border-glow: 2px solid var(--neon-pink);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-dark);
    color: #ffffff;
    font-family: 'Rajdhani', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: hidden;
    background-image: 
        radial-gradient(ellipse at 50% 50%, rgba(255, 0, 127, 0.18) 0%, transparent 80%),
        linear-gradient(to bottom, #0d041c 0%, #20083e 100%);
}

/* Cyber Grid Background effect */
.grid-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: 40px 40px;
    background-image: 
        linear-gradient(to right, rgba(255, 0, 85, 0.08) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 0, 85, 0.08) 1px, transparent 1px);
    z-index: 1;
    pointer-events: none;
}

/* Game Title */
.title-container {
    display: none;
}

h1.game-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 2.2rem;
    color: #fff;
    text-shadow: 
        0 0 5px #fff,
        0 0 10px var(--neon-pink),
        0 0 20px var(--neon-pink),
        0 0 40px var(--neon-purple);
    animation: titleGlow 2.5s infinite alternate;
    letter-spacing: 2px;
}

.game-subtitle {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.1rem;
    color: var(--neon-cyan);
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-top: 8px;
    text-shadow: 0 0 8px rgba(0, 255, 204, 0.5);
}

/* Main Arcade Cabinet / Screen Wrapper */
.arcade-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: #000;
    z-index: 2;
}

/* Game Canvas */
#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
}

/* CRT Screen Scanline/Glare Effects */
.crt-screen::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.05), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.05));
    background-size: 100% 4px, 3px 100%;
    z-index: 9;
    pointer-events: none;
    opacity: 0.85;
}

.crt-screen::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: radial-gradient(circle at 50% 50%, transparent 50%, rgba(0, 0, 0, 0.4) 100%);
    z-index: 9;
    pointer-events: none;
}

/* Screen Flicker Animation (subtle) */
.crt-flicker {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(18, 10, 36, 0.02);
    opacity: 0;
    z-index: 8;
    pointer-events: none;
    animation: flicker 0.15s infinite;
}

/* Overlay Screen Panels (Start, Game Over, Pause) */
.screen-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--panel-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 5;
    transition: opacity 0.4s ease, visibility 0.4s;
    backdrop-filter: blur(4px);
}

.screen-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Title on Overlay screens */
.overlay-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 2rem;
    margin-bottom: 20px;
    text-shadow: 0 0 10px var(--neon-cyan);
    color: var(--neon-cyan);
    text-align: center;
}

.overlay-title.game-over-title {
    color: var(--neon-pink);
    text-shadow: 0 0 10px var(--neon-pink);
    animation: textPulse 1s infinite alternate;
}

/* High Score & Distance display in Game Over */
.stats-summary {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
    font-size: 1.2rem;
    font-weight: bold;
    letter-spacing: 2px;
    color: #e2d9f3;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    width: 280px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
    padding-bottom: 6px;
}

.stat-value {
    color: var(--neon-yellow);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.9rem;
}

.stat-value.new-record {
    color: var(--neon-cyan);
    animation: flash 0.5s infinite alternate;
}

/* Interactive Buttons */
.arcade-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.9rem;
    padding: 12px 28px;
    background: transparent;
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    box-shadow: 0 0 12px rgba(0, 255, 204, 0.2);
    outline: none;
    letter-spacing: 1px;
}

.arcade-btn:hover {
    background-color: var(--neon-cyan);
    color: #000;
    box-shadow: 0 0 25px var(--neon-cyan);
    transform: scale(1.05);
}

.arcade-btn.restart-btn {
    border-color: var(--neon-pink);
    color: var(--neon-pink);
    box-shadow: 0 0 12px rgba(255, 0, 85, 0.2);
}

.arcade-btn.restart-btn:hover {
    background-color: var(--neon-pink);
    color: #000;
    box-shadow: 0 0 25px var(--neon-pink);
}

/* Controls Guide */
.controls-guide {
    display: flex;
    gap: 30px;
    margin-top: 30px;
    color: #8c82a6;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.key-cap {
    background: #1f143d;
    border: 1px solid #473280;
    border-radius: 4px;
    padding: 2px 6px;
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.65rem;
    margin-right: 4px;
    box-shadow: 0 2px 0 #0d081b;
}

/* Sound and Back Buttons */
.utility-bar {
    display: flex;
    justify-content: space-between;
    width: 800px;
    margin-top: 15px;
    z-index: 2;
}

@media (max-width: 850px) {
    .utility-bar {
        width: 95vw;
    }
}

.back-link {
    display: flex;
    align-items: center;
    color: #8c82a6;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: bold;
    letter-spacing: 1px;
    transition: color 0.2s;
    cursor: pointer;
}

.back-link:hover {
    color: var(--neon-cyan);
    text-shadow: 0 0 8px rgba(0, 255, 204, 0.4);
}

.back-link svg {
    margin-right: 6px;
    fill: currentColor;
    transition: transform 0.2s;
}

.back-link:hover svg {
    transform: translateX(-4px);
}

.sound-toggle {
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
    color: #8c82a6;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.95rem;
    font-weight: bold;
    letter-spacing: 1px;
    cursor: pointer;
    transition: color 0.2s;
}

.sound-toggle:hover {
    color: var(--neon-yellow);
}

.sound-toggle svg {
    margin-right: 6px;
    fill: currentColor;
}

/* Mobile Controls Layer (Visible on Mobile/Tablet only) */
.mobile-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    right: 20px;
    flex-direction: column;
    gap: 12px;
    z-index: 4;
}

.mobile-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(18, 10, 36, 0.7);
    border: 2px solid rgba(0, 255, 204, 0.4);
    color: var(--neon-cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    transition: background 0.1s, transform 0.1s;
    touch-action: manipulation;
}

.mobile-btn:active {
    background: var(--neon-cyan);
    color: #000;
    border-color: var(--neon-cyan);
    transform: scale(0.9);
}

/* Show mobile controls on touch devices */
@media (max-width: 1024px) {
    .mobile-controls {
        display: flex;
    }
}

/* Animations */
@keyframes titleGlow {
    from {
        text-shadow: 
            0 0 5px #fff,
            0 0 10px var(--neon-pink),
            0 0 15px var(--neon-pink),
            0 0 30px var(--neon-purple);
    }
    to {
        text-shadow: 
            0 0 5px #fff,
            0 0 15px var(--neon-pink),
            0 0 25px var(--neon-pink),
            0 0 45px var(--neon-purple),
            0 0 60px var(--neon-pink);
    }
}

@keyframes textPulse {
    from {
        transform: scale(1);
        text-shadow: 0 0 8px var(--neon-pink);
    }
    to {
        transform: scale(1.03);
        text-shadow: 0 0 18px var(--neon-pink), 0 0 30px var(--neon-pink);
    }
}

@keyframes flicker {
    0% { opacity: 0.15; }
    50% { opacity: 0.19; }
    100% { opacity: 0.14; }
}

@keyframes flash {
    from { opacity: 1; }
    to { opacity: 0.3; }
}
