:root {
    --bg-color: #0b0c10;
    --grid-color: #1f2833;
    --neon-cyan: #0ff;
    --neon-magenta: #f0f;
    --neon-yellow: #ff0;
    --glass-bg: rgba(11, 12, 16, 0.6);
    --glass-border: rgba(0, 255, 255, 0.2);
}

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

body {
    background-color: var(--bg-color);
    color: #fff;
    font-family: 'Outfit', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    /* Cyber grid background */
    background-image: 
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 30px 30px;
}

.game-container {
    position: relative;
    width: 600px;
    height: 600px;
    box-shadow: 0 0 20px var(--neon-cyan), 0 0 40px inset var(--neon-cyan);
    border: 2px solid var(--neon-cyan);
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.5); /* Slight dark overlay to make grid readable inside canvas area if wanted */
}

canvas {
    display: block;
    width: 600px;
    height: 600px;
}

/* Glassmorphism UI Panels */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    z-index: 10;
}

.overlay.hidden {
    display: none;
}

/* HUD (Heads Up Display) */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 5;
}

#hud.hidden {
    display: none;
}

.score-board, .level-board {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.label {
    font-size: 0.8rem;
    letter-spacing: 2px;
    color: #aaa;
}

.value {
    font-size: 2rem;
    font-weight: 900;
}

/* Typography and Glow */
.neon-text {
    color: #fff;
    text-shadow: 0 0 5px #fff, 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan);
}

.instructions {
    margin-top: 30px;
    font-size: 1rem;
    color: #aaa;
    letter-spacing: 1.5px;
}

/* Glitch Effect Animation */
.glitch {
    font-size: 3rem;
    font-weight: 900;
    text-transform: uppercase;
    position: relative;
    color: white;
    text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75), -0.025em -0.05em 0 rgba(0, 255, 0, 0.75), 0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
    animation: glitch 500ms infinite;
    margin-bottom: 40px;
    letter-spacing: 5px;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}

.glitch::before {
    left: 2px;
    text-shadow: -2px 0 red;
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim-2 3s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -2px 0 blue;
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim 2.5s infinite linear alternate-reverse;
}

@keyframes glitch {
    0% { text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75), -0.05em -0.025em 0 rgba(0, 255, 0, 0.75), -0.025em 0.05em 0 rgba(0, 0, 255, 0.75); }
    14% { text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75), -0.05em -0.025em 0 rgba(0, 255, 0, 0.75), -0.025em 0.05em 0 rgba(0, 0, 255, 0.75); }
    15% { text-shadow: -0.05em -0.025em 0 rgba(255, 0, 0, 0.75), 0.025em 0.025em 0 rgba(0, 255, 0, 0.75), -0.05em -0.05em 0 rgba(0, 0, 255, 0.75); }
    49% { text-shadow: -0.05em -0.025em 0 rgba(255, 0, 0, 0.75), 0.025em 0.025em 0 rgba(0, 255, 0, 0.75), -0.05em -0.05em 0 rgba(0, 0, 255, 0.75); }
    50% { text-shadow: 0.025em 0.05em 0 rgba(255, 0, 0, 0.75), 0.05em 0 0 rgba(0, 255, 0, 0.75), 0 -0.05em 0 rgba(0, 0, 255, 0.75); }
    99% { text-shadow: 0.025em 0.05em 0 rgba(255, 0, 0, 0.75), 0.05em 0 0 rgba(0, 255, 0, 0.75), 0 -0.05em 0 rgba(0, 0, 255, 0.75); }
    100% { text-shadow: -0.025em 0 0 rgba(255, 0, 0, 0.75), -0.025em -0.025em 0 rgba(0, 255, 0, 0.75), -0.025em -0.05em 0 rgba(0, 0, 255, 0.75); }
}

/* Buttons */
.cyber-button {
    background: rgba(0, 255, 255, 0.05);
    color: var(--neon-cyan);
    border: 2px solid var(--neon-cyan);
    padding: 15px 40px;
    font-size: 1.2rem;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.3s ease;
    margin: 10px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 10px inset transparent, 0 0 10px transparent;
}

.cyber-button:hover {
    background: var(--neon-cyan);
    color: #000;
    box-shadow: 0 0 15px inset rgba(0,255,255,0.8), 0 0 30px var(--neon-cyan);
    text-shadow: none;
}

.cyber-button.secondary {
    border-color: var(--neon-magenta);
    color: var(--neon-magenta);
    background: rgba(255, 0, 255, 0.05);
}

.cyber-button.secondary:hover {
    background: var(--neon-magenta);
    color: #000;
    box-shadow: 0 0 15px inset rgba(255,0,255,0.8), 0 0 30px var(--neon-magenta);
}

/* Game Over Form */
.final-stats {
    font-size: 1.5rem;
    margin-bottom: 30px;
    font-weight: 700;
    letter-spacing: 2px;
}

.input-group {
    display: flex;
    margin-bottom: 30px;
}

input[type="text"] {
    background: rgba(0,0,0,0.7);
    border: 2px solid var(--neon-yellow);
    color: var(--neon-yellow);
    padding: 10px 15px;
    font-family: inherit;
    font-size: 1.2rem;
    outline: none;
    text-transform: uppercase;
    width: 250px;
    box-shadow: 0 0 5px inset rgba(255, 255, 0, 0.2);
}

input[type="text"]::placeholder {
    color: rgba(255, 255, 0, 0.4);
}

#saveScoreBtn {
    border-color: var(--neon-yellow);
    color: var(--neon-yellow);
    margin: 0 0 0 10px;
    padding: 10px 20px;
    background: rgba(255, 255, 0, 0.05);
}

#saveScoreBtn:hover {
    background: var(--neon-yellow);
    color: #000;
    box-shadow: 0 0 10px inset rgba(255,255,0,0.5), 0 0 20px var(--neon-yellow);
}

/* Leaderboard Specifics */
.leaderboard-list {
    list-style: none;
    margin: 30px 0;
    width: 80%;
    max-width: 400px;
}

.leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(0,255,255,0.2);
    font-size: 1.2rem;
    letter-spacing: 2px;
}

.leaderboard-list li span:first-child {
    color: #fff;
}

.leaderboard-list li span:last-child {
    color: var(--neon-cyan);
    font-weight: 700;
}
