/* --- GLOBAL VARIABLES & RESET --- */
:root {
    --cyan: #00f2ff;
    --cyan-glow: rgba(0, 242, 255, 0.6);
    --spotify: #1DB954;
    --spotify-glow: rgba(29, 185, 84, 0.6);
    --red: #ff3300;
    --bg-dark: #050505;
    --magenta: #ff00ea;
}

body { 
    margin: 0; 
    background: var(--bg-dark); 
    color: white; 
    font-family: 'Orbitron', sans-serif; 
    overflow: hidden; 
    user-select: none; 
    touch-action: none; 
    -webkit-tap-highlight-color: transparent;
}

/* --- GLOBAL CRT SCANLINES & SCREEN CURVE --- */
body::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.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 999; 
    background-size: 100% 3px, 3px 100%;
    pointer-events: none; 
    box-shadow: inset 0 0 100px rgba(0,0,0,0.9); 
}

/* --- BASE LAYERS --- */
canvas { 
    display: block; 
    width: 100vw; 
    height: 100vh; 
    position: fixed; 
    top: 0; 
    left: 0;
    z-index: 1;
}

/* --- OPTIMIZATION: Hardware Acceleration for Overlays --- */
.overlay {
    will-change: opacity, transform; /* Hardware Acceleration */
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(5, 5, 5, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    text-align: center;
    backdrop-filter: blur(5px);
}

/* The Hyper-Jump Class */
.overlay.hyper-jump {
    transform: scale(1.8);
    opacity: 0;
    pointer-events: none;
}

#menu-version { 
    position: absolute; 
    top: 20px; 
    right: 20px; 
    color: var(--cyan); 
    font-size: 14px; 
    opacity: 0.5;
    letter-spacing: 2px;
}

/* --- TYPOGRAPHY --- */
#start-screen h1 { 
    font-size: clamp(50px, 8vw, 100px); 
    color: #fff; 
    margin: 10px 0 5px 0; 
    font-weight: 900;
    text-transform: uppercase; 
    letter-spacing: 8px; 
    text-align: center;
    animation: title-glow 3s ease-in-out infinite alternate;
    transition: color 0.2s;
}

#start-screen h1:hover {
    animation: glitch-skew 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both infinite;
    color: #fff;
    text-shadow: -3px 0 #0ff, 3px 0 #f00;
}

@keyframes title-glow {
    from { text-shadow: 0 0 10px #fff, -4px 0 15px var(--cyan), 4px 0 15px var(--magenta), 0 0 20px var(--cyan-glow); }
    to { text-shadow: 0 0 20px #fff, -6px 0 30px var(--cyan), 6px 0 30px var(--magenta), 0 0 40px var(--cyan-glow), 0 0 60px var(--cyan-glow); }
}

@keyframes glitch-skew {
    0% { transform: skew(0deg); }
    20% { transform: skew(-10deg); }
    40% { transform: skew(10deg); }
    60% { transform: skew(-5deg); }
    80% { transform: skew(5deg); }
    100% { transform: skew(0deg); }
}

.subtitle {
    color: var(--cyan); 
    margin: 0 0 30px 0; 
    letter-spacing: 6px; 
    font-size: 18px;
    font-weight: 700;
    text-shadow: 0 0 10px var(--cyan-glow);
}

.level-selector { margin-bottom: 30px; }
#start-btn { margin-bottom: 30px; }

/* --- BUTTONS & SPARK EFFECT --- */
.lvl-btn, #start-btn {
    position: relative;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.8);
    border: none;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    color: var(--cyan);
}

.lvl-btn:hover:not(.locked), #start-btn:hover {
    transform: scale(1.05);
    color: white;
    text-shadow: 0 0 8px var(--cyan);
}

.lvl-btn {
    padding: 10px 20px;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

#start-btn {
    padding: 18px 60px;
    font-size: 22px;
    clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
}

.lvl-btn::before, #start-btn::before {
    content: '';
    position: absolute;
    width: 200%; height: 200%;
    background: conic-gradient(from 0deg, transparent 0%, transparent 80%, var(--cyan) 95%, #ffffff 100%);
    animation: borderSpark 3s linear infinite;
    z-index: -2;
}

.lvl-btn::after {
    content: '';
    position: absolute;
    inset: 2px;
    background: rgba(10, 10, 10, 0.95);
    z-index: -1;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

#start-btn::after {
    content: '';
    position: absolute;
    inset: 2px;
    background: rgba(10, 10, 10, 0.95);
    z-index: -1;
    clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
}

@keyframes borderSpark {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.lvl-btn.active::after { background: rgba(0, 40, 60, 0.9); }
.lvl-btn.locked { cursor: not-allowed; opacity: 0.3; }

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

/* --- IMPROVED LEADERBOARD UI --- */
#leaderboard {
    background: linear-gradient(180deg, rgba(0, 20, 40, 0.9) 0%, rgba(0, 10, 20, 0.95) 100%);
    border: 2px solid var(--cyan);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.2), inset 0 0 20px rgba(0, 0, 0, 0.8);
    border-radius: 6px;
    padding: 15px 20px;
    margin: 0 auto 15px auto;
    width: 100%;
    max-width: 420px; 
    height: 360px; 
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

#leaderboard::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 255, 255, 0.03) 2px, rgba(0, 255, 255, 0.03) 4px);
    pointer-events: none;
    z-index: 0;
}

#leaderboard-content {
    transition: opacity 0.4s ease, transform 0.4s ease;
    opacity: 1;
    transform: scale(1);
    flex-grow: 1;
    position: relative;
    z-index: 1; 
}

#leaderboard-content.fade-out {
    opacity: 0;
    transform: scale(0.98);
}

.lb-header {
    text-align: center;
    color: #fff;
    font-weight: 900;
    margin-bottom: 15px;
    letter-spacing: 4px;
    font-size: 16px;
    text-shadow: 0 0 8px var(--cyan);
    background: rgba(0, 242, 255, 0.15);
    border-bottom: 2px solid var(--cyan);
    padding: 8px 0;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

#score-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 16px; 
    font-weight: 700;
    letter-spacing: 2px;
}

#score-list li {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    margin-bottom: 4px;
    background: rgba(0, 0, 0, 0.4); 
    border-left: 3px solid transparent;
    transition: background 0.2s, border-color 0.2s;
}

#score-list li:nth-child(even) {
    background: rgba(0, 242, 255, 0.05);
}

#score-list li:first-child {
    border-left: 3px solid var(--cyan);
    background: rgba(0, 242, 255, 0.1);
    text-shadow: 0 0 5px var(--cyan);
}

/* --- GROWING SPOTIFY PROMO --- */
#spotify-promo {
    margin-bottom: 15px;
    background: rgba(0, 40, 20, 0.4);
    border: 2px solid var(--cyan);
    padding: 18px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    clip-path: polygon(5% 0%, 100% 0%, 95% 100%, 0% 100%); 
    animation: smoothPulse 2s infinite ease-in-out;
    transition: background 0.3s ease;
    background-image: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.4) 50%);
    background-size: 100% 4px;
}

@keyframes smoothPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 10px rgba(0, 255, 128, 0.2); }
    50% { transform: scale(1.04); box-shadow: 0 0 20px rgba(0, 255, 128, 0.5); }
}

#spotify-promo p { color: #ccc; font-size: 12px; margin: 0 0 5px 0; letter-spacing: 2px; }
#spotify-promo a { color: #00ff80; text-decoration: none; font-weight: 900; font-size: 18px; text-shadow: 0 0 5px var(--spotify-glow); }

/* --- WARNING TEXT --- */
#epilepsy-warning {
    text-align: center;
    font-size: 11px;
    color: #ff3366;
    max-width: 450px;
    margin: 0 auto;
    line-height: 1.4;
}
#epilepsy-warning p { margin: 4px 0; }

/* --- CYBERDECK NAME INPUT --- */
#new-high-score { margin: 20px 0; }

#player-name {
    position: relative;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-family: 'Orbitron', monospace;
    font-size: 32px;
    text-align: center;
    letter-spacing: 4px;
    width: 350px;
    height: 70px;
    z-index: 1;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
}

#new-high-score {
    position: relative;
    display: inline-block;
    padding: 3px; 
    background: conic-gradient(from 0deg, transparent 0%, transparent 80%, var(--cyan) 95%, #ffffff 100%);
    animation: borderSpark 4s linear infinite;
    clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
}

#new-high-score::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: rgba(5, 5, 5, 0.95);
    z-index: 0;
    clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
}

#new-high-score p { position: relative; z-index: 1; }
#score-container { display: none !important; }

/* --- GAME OVER --- */
#game-over-screen { 
    display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    flex-direction: column; align-items: center; justify-content: center;
    background: rgba(5,5,5,0.95); backdrop-filter: blur(10px); z-index: 200;
}

#end-title { color: var(--red); font-size: 60px; text-shadow: 0 0 20px rgba(255, 51, 0, 0.5); }
.blink-text { animation: blinkPulse 1.5s infinite; }
@keyframes blinkPulse { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }

        /* --- VOLUME SLIDER --- */
        #volume-control {
            position: absolute;
            top: 20px;
            left: 20px;
            z-index: 250;
            display: flex;
            align-items: center;
            gap: 10px;
            opacity: 0.6;
            transition: opacity 0.3s ease;
        }

        #volume-control:hover {
            opacity: 1;
        }

        #volume-control label {
            color: var(--cyan);
            font-size: 10px;
            font-weight: 700;
            letter-spacing: 2px;
            text-shadow: 0 0 5px var(--cyan);
        }

        input[type=range] {
            -webkit-appearance: none;
            width: 80px;
            background: transparent;
        }

        input[type=range]:focus { outline: none; }

        input[type=range]::-webkit-slider-runnable-track {
            width: 100%;
            height: 4px;
            cursor: pointer;
            background: rgba(0, 242, 255, 0.2);
            border: 1px solid var(--cyan);
        }

        input[type=range]::-webkit-slider-thumb {
            height: 12px;
            width: 6px;
            border-radius: 0;
            background: #fff;
            cursor: pointer;
            -webkit-appearance: none;
            margin-top: -5px;
            box-shadow: 0 0 8px var(--cyan);
            transition: transform 0.1s;
        }

        input[type=range]::-webkit-slider-thumb:hover {
            transform: scale(1.5);
            background: var(--cyan);
        }

        /* --- OPTIMIZATION: Hardware Acceleration for Floating Button --- */
        #floating-transmission-btn {
            will-change: transform, box-shadow; /* Hardware Acceleration */
            position: absolute;
            bottom: 30px;
            right: 30px;
            background: rgba(0, 20, 30, 0.9);
            border: 2px solid var(--cyan);
            border-radius: 50%;
            width: 70px;
            height: 70px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            z-index: 250;
            transition: all 0.3s ease;
            animation: pulse-glow 2s infinite;
        }

        #floating-transmission-btn:hover {
            transform: scale(1.1);
            box-shadow: 0 0 30px var(--cyan);
            background: rgba(0, 40, 60, 1);
        }

        #floating-transmission-btn img {
            width: 45px;
            height: 45px;
            border-radius: 50%;
            opacity: 0.9;
        }

        @keyframes pulse-glow {
            0%, 100% { box-shadow: 0 0 10px rgba(0, 242, 255, 0.4); }
            50% { box-shadow: 0 0 25px rgba(0, 242, 255, 0.9); }
        }

        /* --- CLOSE MODAL BUTTON --- */
        #close-transmission-btn {
            margin-top: 25px; 
            padding: 10px 30px; 
            background: transparent; 
            border: 2px solid var(--red); 
            color: var(--red); 
            font-family: 'Orbitron', sans-serif; 
            font-weight: bold; 
            letter-spacing: 2px; 
            cursor: pointer; 
            transition: 0.3s; 
            box-shadow: inset 0 0 10px rgba(255, 51, 0, 0.2);
        }

        #close-transmission-btn:hover {
            background: var(--red);
            color: white;
            box-shadow: 0 0 20px var(--red);
        }