@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@600;800;900&family=Rajdhani:wght@500;600;700&display=swap');

:root {
    /* ---- Color tokens ---- */
    --bg-deep: #05060a;
    --bg-surface: #10131c;
    --bg-surface-2: #161a26;
    --line: rgba(255, 255, 255, 0.08);

    --neon-magenta: #ff2d6d;
    --neon-magenta-dim: #6b0f30;
    --neon-magenta-glow: rgba(255, 45, 109, 0.55);

    --neon-cyan: #05e5ff;
    --neon-cyan-dim: #05505c;
    --neon-cyan-glow: rgba(5, 229, 255, 0.55);

    --neon-violet: #b06bff;
    --neon-violet-glow: rgba(176, 107, 255, 0.45);

    --text-hi: #f3f6fb;
    --text-mid: #a9b4c9;
    --text-low: #62708a;

    --font-display: 'Orbitron', 'Segoe UI', sans-serif;
    --font-body: 'Rajdhani', 'Segoe UI', sans-serif;
}

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

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-deep);
    font-family: var(--font-body);
}

body {
    background:
        linear-gradient(rgba(8, 10, 20, 0.65), rgba(8, 10, 20, 0.75)),
        url("./bg.jpg") center center / cover no-repeat;
    background-attachment: fixed;

    display: flex;
    align-items: center;
    justify-content: center;
}

:root {
    --pl-cyan: #05e5ff;
    --pl-magenta: #ff2d6d;
    --pl-violet: #b06bff;
    --pl-bg: #05060a;
    --pl-glow-cyan: 0 0 18px rgba(5, 229, 255, 0.65), 0 0 40px rgba(5, 229, 255, 0.22);
    --pl-glow-magenta: 0 0 18px rgba(255, 45, 109, 0.65), 0 0 40px rgba(255, 45, 109, 0.22);
}

#preloader-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: radial-gradient(ellipse at 50% 40%, #0d0f1a 0%, var(--pl-bg) 70%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Rajdhani', 'Segoe UI', sans-serif;
}

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

#preloader-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(5, 229, 255, 0.02) 2px, rgba(5, 229, 255, 0.02) 4px);
    pointer-events: none;
}

.preloader-content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
}

.preloader-title {
    font-family: 'Orbitron', 'Courier New', monospace;
    font-size: clamp(24px, 6vw, 38px);
    font-weight: 900;
    letter-spacing: 5px;
    text-transform: uppercase;
    color: #fff;
    text-shadow: 0 0 10px var(--pl-cyan), 0 0 32px rgba(5, 229, 255, 0.4);
}

.preloader-title .accent {
    color: var(--pl-magenta);
    text-shadow: 0 0 10px var(--pl-magenta), 0 0 32px rgba(255, 45, 109, 0.4);
}

.spinner-ring-container {
    position: relative;
    width: 64px;
    height: 64px;
}

.spinner-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
    animation: spin-ring 1.3s cubic-bezier(0.68, -0.15, 0.27, 1.15) infinite;
}

.spinner-ring.ring-cyan {
    border-top-color: var(--pl-cyan);
    border-right-color: rgba(5, 229, 255, 0.3);
    box-shadow: var(--pl-glow-cyan);
}

.spinner-ring.ring-magenta {
    width: 44px;
    height: 44px;
    top: 10px;
    left: 10px;
    border-bottom-color: var(--pl-magenta);
    border-left-color: rgba(255, 45, 109, 0.3);
    box-shadow: var(--pl-glow-magenta);
    animation-delay: 0.6s;
    animation-direction: reverse;
}

@keyframes spin-ring {
    to {
        transform: rotate(360deg);
    }
}

.preloader-status {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 3px;
    color: #7c8aa5;
    text-transform: uppercase;
    min-height: 16px;
}

.progress-track {
    width: 180px;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--pl-cyan), var(--pl-violet), var(--pl-magenta));
    box-shadow: 0 0 10px var(--pl-cyan);
    transition: width 0.1s linear;
}

.preloader-bracket {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(5, 229, 255, 0.3);
}

.preloader-bracket.top-left {
    top: 20px;
    left: 20px;
    border-right: none;
    border-bottom: none;
}

.preloader-bracket.top-right {
    top: 20px;
    right: 20px;
    border-left: none;
    border-bottom: none;
}

.preloader-bracket.bottom-left {
    bottom: 20px;
    left: 20px;
    border-right: none;
    border-top: none;
}

.preloader-bracket.bottom-right {
    bottom: 20px;
    right: 20px;
    border-left: none;
    border-top: none;
}


/* ==================== GAME CONTAINER + SIGNATURE CIRCUIT FRAME ==================== */
#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 450px;
    max-height: 850px;
    margin: auto;
    overflow: hidden;
    background: var(--bg-surface);
    border: 1px solid var(--line);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.02),
        0 40px 90px rgba(0, 0, 0, 0.6),
        0 0 60px rgba(5, 229, 255, 0.08);
    transition: box-shadow 0.4s ease;
}

#game-container.pulse-magenta {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.02),
        0 40px 90px rgba(0, 0, 0, 0.6),
        0 0 55px 6px var(--neon-magenta-glow);
}

#game-container.pulse-cyan {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.02),
        0 40px 90px rgba(0, 0, 0, 0.6),
        0 0 55px 6px var(--neon-cyan-glow);
}

/* Corner brackets — the recurring signature motif */
.frame-bracket {
    position: absolute;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(5, 229, 255, 0.35);
    z-index: 6;
    pointer-events: none;
}

.frame-bracket.tl {
    top: 14px;
    left: 14px;
    border-right: none;
    border-bottom: none;
}

.frame-bracket.tr {
    top: 14px;
    right: 14px;
    border-left: none;
    border-bottom: none;
}

.frame-bracket.bl {
    bottom: 14px;
    left: 14px;
    border-right: none;
    border-top: none;
}

.frame-bracket.br {
    bottom: 14px;
    right: 14px;
    border-left: none;
    border-top: none;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
}

/* ==================== HUD ==================== */
.hud {
    position: absolute;
    top: 26px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 26px;
    align-items: center;
    z-index: 5;
    pointer-events: none;
}

.score-wrap {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.score-label {
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--text-low);
    margin-bottom: 4px;
}

.score-box {
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 800;
    color: var(--text-hi);
    letter-spacing: 1px;
    text-shadow: 0 0 16px rgba(255, 255, 255, 0.25);
    transition: text-shadow 0.15s ease;
}

.score-box.bump {
    animation: score-bump 0.28s ease;
}

@keyframes score-bump {
    0% {
        transform: scale(1);
    }

    35% {
        transform: scale(1.28);
        text-shadow: 0 0 24px var(--neon-cyan-glow);
    }

    100% {
        transform: scale(1);
    }
}

.lives {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.life-pip {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--neon-magenta);
    box-shadow: 0 0 8px var(--neon-magenta-glow);
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.life-pip.lost {
    background: rgba(255, 255, 255, 0.08);
    box-shadow: none;
    transform: scale(0.75);
}

#game-container.flash-miss {
    animation: miss-flash 0.35s ease;
}

@keyframes miss-flash {
    0% {
        box-shadow: inset 0 0 0 0 rgba(255, 45, 109, 0);
    }

    25% {
        box-shadow: inset 0 0 60px 10px rgba(255, 45, 109, 0.55);
    }

    100% {
        box-shadow: inset 0 0 0 0 rgba(255, 45, 109, 0);
    }
}

.audio-toggle {
    background: rgba(16, 19, 28, 0.85);
    border: 1px solid var(--line);
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    pointer-events: auto;
    color: var(--text-hi);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    transition: border-color 0.2s ease, transform 0.15s ease;
}

.audio-toggle:hover {
    border-color: rgba(5, 229, 255, 0.5);
}

.audio-toggle:active {
    transform: scale(0.92);
}

/* ==================== MODALS ==================== */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 6, 10, 0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 25px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-card {
    position: relative;
    background: linear-gradient(180deg, rgba(22, 26, 38, 0.96), rgba(16, 19, 28, 0.96));
    width: 100%;
    max-width: 360px;
    border-radius: 18px;
    padding: 34px 26px 26px;
    border: 1px solid var(--line);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    text-align: center;
    transform: translateY(24px);
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 85%;
    display: flex;
    flex-direction: column;
}

.modal-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 18px;
    right: 18px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--neon-cyan), var(--neon-violet), var(--neon-magenta), transparent);
    opacity: 0.85;
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

.modal-scroll-body {
    overflow-y: auto;
    padding: 6px 4px;
    margin-bottom: 24px;
    flex: 1;
    text-align: left;
}

.modal-scroll-body::-webkit-scrollbar {
    width: 4px;
}

.modal-scroll-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.modal-eyebrow {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--neon-cyan);
    text-align: center;
    margin-bottom: 10px;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 800;
    color: var(--text-hi);
    margin-bottom: 22px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
}

.instruction-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 18px;
    font-family: var(--font-body);
    font-size: 18px;
    font-weight: 500;
    line-height: 1.5;
    color: var(--text-mid);
}

.instruction-item strong {
    color: var(--text-hi);
    font-weight: 700;
}

.instruction-badge {
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-cyan-dim));
    color: #ffffff;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 11px;
    flex-shrink: 0;
    box-shadow: 0 0 10px var(--neon-cyan-glow);
}

.btn {
    position: relative;
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-cyan-dim));
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 15px 32px;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    width: 100%;
    text-transform: uppercase;
    letter-spacing: 2px;
    /* 3D Effect */
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.35),
        /* top highlight */
        inset 0 -2px 0 rgba(0, 0, 0, 0.25),
        /* bottom shading */
        0 4px 0 #0092a8,
        /* solid bottom edge */
        0 8px 18px rgba(0, 255, 255, 0.35),
        /* glow */
        0 12px 24px rgba(0, 0, 0, 0.45);
    /* drop shadow */
    overflow: hidden;
}

#game-canvas {
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.35),
        /* top highlight */
        inset 0 -2px 0 rgba(0, 0, 0, 0.25),
        /* bottom shading */
        0 4px 0 #0092a8,
        /* solid bottom edge */
        0 8px 18px rgba(0, 255, 255, 0.35),
        /* glow */
        0 12px 24px rgba(0, 0, 0, 0.45);
    /* drop shadow */
    overflow: hidden;
}

.btn:hover {
    box-shadow: 0 8px 30px var(--neon-cyan-glow), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.btn:active {
    transform: scale(0.97);
}

.btn-pink {
    background: linear-gradient(135deg, var(--neon-magenta), var(--neon-magenta-dim));
    color: #ffffff;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.35),
        /* top highlight */
        inset 0 -2px 0 rgba(0, 0, 0, 0.25),
        /* bottom shade */
        0 4px 0 var(--neon-magenta-dim),
        /* 3D bottom edge */
        0 8px 20px var(--neon-magenta-glow),
        /* neon glow */
        0 12px 28px rgba(0, 0, 0, 0.45);
    /* drop shadow */

    transition: all 0.18s ease;
}

.btn-pink:hover {
    box-shadow: 0 8px 30px var(--neon-magenta-glow), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.stat-line {
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-mid);
    margin: 10px 0;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

.gameover-note {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-low);
    margin-top: 15px;
    line-height: 1.5;
    text-align: center;
}

/* Combo / streak toast */
#combo-toast {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 3px;
    color: var(--neon-violet);
    text-shadow: 0 0 18px var(--neon-violet-glow);
    text-transform: uppercase;
    opacity: 0;
    pointer-events: none;
    z-index: 4;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#combo-toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}