:root {
    --neon-pink: #ff00ff;
    --neon-blue: #00f2ff;
    --dark-space: #05011a;
    --terminal-bg: #0a0a2a;
    scroll-behavior: smooth;
    scroll-padding-top: 100px;
    /* Offset for sticky nav */
}

body {
    background-color: var(--dark-space);
    color: #fff;
    font-family: 'Exo 2', sans-serif;
    margin: 0;
    overflow-x: hidden;
    user-select: none;
}

#countdown {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Match chat scrollbars to arcade palette */
#chat-window {
    scrollbar-width: thin;
    scrollbar-color: var(--neon-blue) #0a0a2a;
}

#chat-window::-webkit-scrollbar {
    width: 10px;
}

#chat-window::-webkit-scrollbar-track {
    background: #0a0a2a;
    border-left: 1px solid rgba(0, 242, 255, 0.2);
}

#chat-window::-webkit-scrollbar-thumb {
    background: var(--neon-blue);
    border: 2px solid #0a0a2a;
}

.font-retro {
    font-family: 'Press Start 2P', cursive;
}

.font-cyber {
    font-family: 'Orbitron', sans-serif;
}

/* Background Grid */
.grid-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    perspective: 500px;
    z-index: -1;
    background: linear-gradient(to bottom, #05011a 0%, #1a0b3c 100%);
    overflow: hidden;
}

.grid-lines {
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background-image:
        linear-gradient(to right, rgba(0, 242, 255, 0.1) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 0, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    transform: rotateX(60deg);
    animation: moveGridLines 5s linear infinite;
}

@keyframes moveGridLines {
    0% {
        transform: rotateX(60deg) translateY(0);
    }

    100% {
        transform: rotateX(60deg) translateY(50px);
    }
}

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 100;
}

.neon-card {
    background: rgba(10, 10, 42, 0.95);
    border: 2px solid var(--neon-blue);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.3), inset 0 0 10px rgba(0, 242, 255, 0.1);
    position: relative;
    transform: translateZ(0);
    outline: 1px solid var(--neon-pink);
    outline-offset: 4px;
}

/* Pink outline without changing background/glow */
.neon-outline {
    position: relative;
}

.neon-outline::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 1px solid var(--neon-pink);
    pointer-events: none;
    opacity: 0.5;
    border-radius: inherit;
}

.btn-neon {
    background: transparent;
    border: 2px solid var(--neon-blue);
    color: var(--neon-blue);
    text-transform: uppercase;
    transition: all 0.2s ease-out;
    cursor: pointer;
}

.btn-neon:hover {
    background: var(--neon-blue);
    color: var(--dark-space);
    box-shadow: 0 0 30px var(--neon-blue);
}

/* Ticker */
.ticker-track {
    display: flex;
    gap: 32px;
    width: max-content;
    animation: tickerMove 20s linear infinite;
}

.ticker-content {
    white-space: nowrap;
    display: inline-block;
}

@keyframes tickerMove {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* Highscore dropdown without layout shift */
.highscore-details {
    position: relative;
}

.highscore-details .highscore-panel {
    display: none;
}

.highscore-details[open] .highscore-panel {
    display: block;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    z-index: 40;
    border-top: 1px solid rgba(0, 242, 255, 0.2);
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1/2;
    margin: 10px auto;
    border: 4px solid #333;
    background: #000;
    overflow: hidden;
    touch-action: none;
}

#game-wrapper {
    border: 2px solid rgba(0, 242, 255, 0.6);
    box-shadow: 0 0 18px rgba(0, 242, 255, 0.35);
    background: #000;
    overflow: hidden;
}

#game-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(closest-side at 0% 50%, rgba(0, 242, 255, 0.7), rgba(0, 242, 255, 0) 85%),
        radial-gradient(closest-side at 100% 50%, rgba(0, 242, 255, 0.7), rgba(0, 242, 255, 0) 85%);
    pointer-events: none;
    z-index: 0;
}

#game-wrapper > canvas {
    position: relative;
    z-index: 1;
}

/* Hide header stats during game over to avoid overlap */
.game-over .arcade-header {
    opacity: 0;
    pointer-events: none;
}

/* Game over overlay should fit on small screens */
.gameover-overlay {
    overflow-y: auto;
    max-height: 100%;
}

/* Compact game over content on small screens */
.gameover-overlay h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.gameover-overlay .font-cyber.text-3xl,
.gameover-overlay .font-cyber.text-4xl {
    font-size: 22px !important;
    margin-bottom: 10px !important;
}

.gameover-overlay #quest-result {
    padding: 10px !important;
    margin-bottom: 10px !important;
}

.gameover-overlay #quest-result p {
    font-size: 11px !important;
}

.gameover-overlay #inp-initials {
    font-size: 18px !important;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}

.gameover-overlay button {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}

canvas {
    width: auto;
    height: auto;
    display: block;
    border: 2px solid rgba(255, 255, 255, 0.8);
}

/* Secret Quest Overlay */
#special-quest {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(255, 0, 255, 0.95);
    color: white;
    z-index: 150;
    padding: 25px;
    text-align: center;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Form Controls */
.input-slot {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(0, 242, 255, 0.3);
    border-left: 4px solid var(--neon-pink);
    padding: 14px;
    color: white;
    width: 100%;
    outline: none;
    display: block;
    position: relative;
    z-index: 10;
}

.input-slot:focus {
    border-color: var(--neon-blue);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
}

#gatekeeper {
    /* Previously fixed, now inline handled by HTML structure/Tailwind classes, 
       but keeping this rule to ensure specificity if needed, or resetting it. */
    display: flex;
    justify-content: center;
    margin: 40px 0;
    z-index: 50;
}

/* Game Navigation / Controls */
.controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 15px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.ctrl-btn {
    background: rgba(0, 242, 255, 0.1);
    border: 2px solid var(--neon-blue);
    padding: 15px;
    text-align: center;
    border-radius: 8px;
    color: var(--neon-blue);
    font-size: 10px;
    font-family: 'Press Start 2P', cursive;
    cursor: pointer;
    touch-action: none;
}

.ctrl-btn:active {
    background: var(--neon-blue);
    color: black;
}

.pulse-text {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        color: var(--neon-blue);
    }

    50% {
        opacity: 0.6;
        color: var(--neon-pink);
    }
}

/* Highscore Terminal Style */
.highscore-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed rgba(0, 242, 255, 0.2);
    padding: 8px 0;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
}

@media (min-width: 768px) {
    .controls {
        display: none;
    }
}

/* Matrix Scrollbar for Chat */
#chat-window::-webkit-scrollbar {
    width: 8px;
}

#chat-window::-webkit-scrollbar-track {
    background: #000;
}

#chat-window::-webkit-scrollbar-thumb {
    background: #22c55e;
    border: 2px solid #000;
}
