:root {
    --bg-0: #06080f;
    --bg-1: #0b0f20;
    --bg-2: #0e1430;
    --cyan: #3df3ff;
    --cyan-dim: #1fb8c7;
    --violet: #8b6bff;
    --pink: #ff5fb0;
    --amber: #ffb648;
    --green: #37e29b;
    --red: #ff3b6f;
    --glass: rgba(12, 18, 40, 0.60);
    --glass-brd: rgba(80, 160, 255, 0.18);
    --text: #f0f4ff;
    --text-dim: #8a9fc8;
    --radius: 20px;
    --ff-head: 'Orbitron', sans-serif;
    --ff-body: 'Outfit', sans-serif;
    --shadow-glow: 0 8px 40px rgba(61, 243, 255, 0.15);
    --shadow-glow-strong: 0 8px 48px rgba(61, 243, 255, 0.30);
}

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

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-0);
    font-family: var(--ff-body);
    color: var(--text);
    -webkit-font-smoothing: antialiased;

   
}

#app {
    position: fixed;
    inset: 0;
    overflow: hidden;
}

/* ─── CANVAS ─── */
#bgCanvas,
#gameCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;

        background:
    linear-gradient(rgba(28, 19, 82, 0.10), rgba(28, 19, 82, 0.10)),
    url('bg.png') center center / cover no-repeat;
}

#bgCanvas {
    z-index: 0;
}

#gameCanvas {
    z-index: 1;
}

/* ─── CYBER BG ─── */
.cyber-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(1400px 900px at 10% -20%, rgba(139, 107, 255, 0.22), transparent 60%),
        radial-gradient(1200px 800px at 110% 10%, rgba(61, 243, 255, 0.16), transparent 55%),
        radial-gradient(1000px 1000px at 50% 130%, rgba(255, 95, 176, 0.10), transparent 55%),
        linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 40%, var(--bg-2) 100%);
}

.cyber-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 70% 20%, rgba(61, 243, 255, 0.04) 0%, transparent 50%),
        radial-gradient(circle at 20% 80%, rgba(139, 107, 255, 0.06) 0%, transparent 50%);
    pointer-events: none;
}

.grid-overlay {
    position: fixed;
    inset: 0;
    z-index: 0;
    opacity: 0.30;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(100, 180, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(100, 180, 255, 0.05) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(circle at 50% 40%, black, transparent 72%);
    -webkit-mask-image: radial-gradient(circle at 50% 40%, black, transparent 72%);
}

/* ─── GLASS / BUTTONS ─── */
.glass {
    background: var(--glass);
    border: 1px solid var(--glass-brd);
    border-radius: var(--radius);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.40), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.glass-strong {
    background: rgba(8, 14, 34, 0.95);
    border: 1px solid rgba(80, 160, 255, 0.20);
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);
    border-radius: 30px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.50), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.btn {
    font-family: var(--ff-body);
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.03em;
    color: var(--text);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.01));
    border: 1px solid var(--glass-brd);
    border-radius: 30px;
    padding: 12px 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
}

.btn svg {
    width: 18px;
    height: 18px;
    flex: none;
}

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

.btn:hover:not(:disabled) {
    border-color: rgba(61, 243, 255, 0.50);
    box-shadow: 0 0 0 1px rgba(61, 243, 255, 0.12), 0 0 28px rgba(61, 243, 255, 0.12);
}

.btn.primary {
    background: linear-gradient(135deg, var(--cyan) 0%, var(--violet) 100%);
    color: #050712;
    border: none;
    font-weight: 700;
    box-shadow: 0 6px 28px rgba(61, 243, 255, 0.30), 0 2px 10px rgba(139, 107, 255, 0.25);


}

.btn.primary:hover:not(:disabled) {
    box-shadow: 0 8px 40px rgba(61, 243, 255, 0.45), 0 2px 14px rgba(139, 107, 255, 0.35);
    transform: translateY(-1px);
}

.btn.primary:active {
    transform: scale(0.94);
}

.btn.ghost {
    background: transparent;
}

.btn.icon {
    padding: 10px;
    border-radius: 12px;
    min-width: 42px;
    min-height: 42px;
}

.btn.small {
    padding: 8px 14px;
    font-size: 12px;
}

.btn.danger:hover:not(:disabled) {
    border-color: rgba(255, 80, 140, 0.55);
    box-shadow: 0 0 0 1px rgba(255, 80, 140, 0.12), 0 0 28px rgba(255, 80, 140, 0.12);
}

.btn.glow {
    animation: btnPulse 2.4s ease-in-out infinite;
}

@keyframes btnPulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(61, 243, 255, 0.10);
    }

    50% {
        box-shadow: 0 0 40px rgba(61, 243, 255, 0.25), 0 0 80px rgba(61, 243, 255, 0.06);
    }
}

.btn:disabled {
    opacity: 0.30;
    pointer-events: none;
    filter: grayscale(0.4);
}

.btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--pink);
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 0 16px rgba(255, 95, 176, 0.5);
}

h1,
h2,
h3,
.headf {
    font-family: var(--ff-head);
}

.neon-text {
    color: var(--cyan);
    text-shadow: 0 0 12px rgba(61, 243, 255, 0.5), 0 0 40px rgba(61, 243, 255, 0.15);
}

.neon-text-violet {
    color: var(--violet);
    text-shadow: 0 0 12px rgba(139, 107, 255, 0.5), 0 0 40px rgba(139, 107, 255, 0.15);
}

.gradient-text {
    background: linear-gradient(135deg, #fff 10%, var(--cyan) 50%, var(--violet) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ─── SCREENS ─── */
.screen {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transform: scale(1.02);
    transition: opacity 0.55s cubic-bezier(0.22, 0.8, 0.2, 1), transform 0.55s cubic-bezier(0.22, 0.8, 0.2, 1);
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.screen-inner {
    width: 100%;
    max-width: 560px;
    padding: 28px 24px;
    margin: 0 18px;
    max-height: 92vh;
    overflow-y: auto;
    scrollbar-width: none;
}

.screen-inner::-webkit-scrollbar {
    display: none;
}

/* ─── PRELOADER ─── */
#preloader {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: var(--bg-0);
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

#preloader.hide {
    opacity: 0;
    visibility: hidden;
}

.pl-cube-wrap {
    width: 120px;
    height: 120px;
    perspective: 600px;
    margin-bottom: 30px;
}

.pl-cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    animation: plspin 3.6s linear infinite;
}

.pl-face {
    position: absolute;
    width: 120px;
    height: 120px;
    border: 2px solid rgba(61, 243, 255, 0.45);
    background: repeating-linear-gradient(45deg, rgba(61, 243, 255, 0.08) 0 10px, rgba(139, 107, 255, 0.06) 10px 20px);
    box-shadow: inset 0 0 40px rgba(61, 243, 255, 0.20), 0 0 30px rgba(139, 107, 255, 0.15);
    backdrop-filter: blur(2px);
    border-radius: 8px;
}

.pl-face.f {
    transform: translateZ(60px);
}

.pl-face.b {
    transform: translateZ(-60px) rotateY(180deg);
}

.pl-face.r {
    transform: rotateY(90deg) translateZ(60px);
}

.pl-face.l {
    transform: rotateY(-90deg) translateZ(60px);
}

.pl-face.t {
    transform: rotateX(90deg) translateZ(60px);
}

.pl-face.d {
    transform: rotateX(-90deg) translateZ(60px);
}

@keyframes plspin {
    0% {
        transform: rotateX(-20deg) rotateY(0deg);
    }

    100% {
        transform: rotateX(-20deg) rotateY(360deg);
    }
}

.pl-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.pl-p {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 12px 3px rgba(61, 243, 255, 0.6);
    opacity: 0;
    animation: plfloat 4.5s ease-in-out infinite;
}

@keyframes plfloat {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.4);
    }

    20% {
        opacity: 0.9;
    }

    80% {
        opacity: 0.5;
    }

    100% {
        opacity: 0;
        transform: translateY(-180px) scale(1.3);
    }
}

.pl-title {
    font-family: var(--ff-head);
    font-weight: 900;
    font-size: 26px;
    letter-spacing: 0.16em;
    color: var(--text);
    margin-bottom: 4px;
}

.pl-sub {
    font-size: 12px;
    color: var(--text-dim);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    margin-bottom: 20px;
    font-weight: 300;
}

.pl-bar-wrap {
    width: 240px;
    height: 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.pl-bar {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--cyan), var(--violet), var(--pink));
    box-shadow: 0 0 20px rgba(61, 243, 255, 0.5);
    transition: width 0.15s ease;
}

.pl-pct {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.10em;
    font-weight: 300;
}

/* ─── HUD ─── */
#hud {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    display: none;
}

#hud.active {
    display: block;
}

.hud-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: calc(14px + env(safe-area-inset-top)) 16px 0;
    pointer-events: none;
    gap: 10px;
}

.hud-panel {
    pointer-events: auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 18px;
    background: rgba(8, 14, 34, 0.90);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid #2c68b7;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 48px;
}

.stat .lbl {
    font-size: 8px;
    letter-spacing: 0.18em;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 500;
}

.stat .val {
    font-family: var(--ff-head);
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.stat .val.cyan {
    color: var(--cyan);
}

.stat .val.amber {
    color: var(--amber);
}

.hud-actions {
    display: flex;
    gap: 8px;
    pointer-events: auto;
}

.hud-actions .btn {
    background: rgba(8, 14, 34, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-color: #2c68b7;
}

.hud-actions .btn:hover {
    border-color: rgba(61, 243, 255, 0.35);
}

.hud-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 0 14px calc(14px + env(safe-area-inset-bottom));
    pointer-events: none;
}

.hud-bottom-inner {
    pointer-events: auto;
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    background: rgba(8, 14, 34, 0.90);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid #2c68b7;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    flex-wrap: wrap;
    justify-content: center;
}

.hud-bottom-inner .btn {
    background: rgba(255, 255, 255, 0.04);
    border-color: #6b30af;
    min-width: 38px;
    min-height: 38px;
    padding: 6px;
    border-radius: 10px;
}

.hud-bottom-inner .btn:hover {
    border-color: rgba(61, 243, 255, 0.30);
    background: rgba(61, 243, 255, 0.06);
}

.hud-bottom-inner .btn svg {
    width: 16px;
    height: 16px;
}

.notation-row {
    position: absolute;
    bottom: calc(78px + env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
    pointer-events: none;
    flex-wrap: wrap;
    padding: 0 10px;
}

.note-chip {
    pointer-events: none;
    font-family: var(--ff-head);
    font-size: 12px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 8px;
    opacity: 0.90;
    background: rgba(61, 243, 255, 0.12);
    border: 1px solid rgba(61, 243, 255, 0.25);
    color: var(--cyan);
    text-shadow: 0 0 12px rgba(61, 243, 255, 0.3);
    transition: opacity 0.3s, transform 0.3s;
    animation: notePop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes notePop {
    0% {
        transform: scale(0.6) translateY(8px);
        opacity: 0;
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 0.90;
    }
}

/* ─── HOME ─── */
.logo-cube {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    position: relative;
    perspective: 450px;
}

.logo-cube .face {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.08);
}

.home-title {
    text-align: center;
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 0.04em;
    margin: 0 0 2px;
    line-height: 1.2;
}

.home-sub {
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    letter-spacing: 0.18em;
    margin-bottom: 28px;
    text-transform: uppercase;
    font-weight: 400;
}

.menu-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.menu-list .btn {
    width: 100%;
    justify-content: flex-start;
    padding: 16px 20px;
    font-size: 15px;
    font-weight: 600;
}

.menu-list .btn .icon-left {
    width: 24px;
    text-align: center;
    flex: none;
    opacity: 0.7;
}

.best-strip {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.best-card {
    flex: 1;
    padding: 12px 8px;
    border-radius: 14px;
    text-align: center;
    background: rgba(8, 14, 34, 0.50);
    border: 1px solid rgba(80, 160, 255, 0.08);
    backdrop-filter: blur(8px);
}

.best-card .lbl {
    font-size: 9px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 500;
}

.best-card .val {
    font-family: var(--ff-head);
    font-size: 18px;
    font-weight: 700;
    color: var(--cyan);
    margin-top: 2px;
    text-shadow: 0 0 20px rgba(61, 243, 255, 0.15);
}

/* ─── DIFFICULTY PILLS ─── */
.pill-row {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}

.pill {
    flex: 1;
    text-align: center;
    padding: 10px 6px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--glass-brd);
    color: var(--text-dim);
    transition: all 0.18s ease;
    background: rgba(255, 255, 255, 0.02);
}

.pill:hover {
    border-color: rgba(61, 243, 255, 0.30);
    color: var(--text);
}

.pill.active {
    color: #050712;
    background: linear-gradient(135deg, var(--cyan), var(--violet));
    border-color: transparent;
    font-weight: 700;
    box-shadow: 0 4px 24px rgba(61, 243, 255, 0.25);
}

/* ─── TUTORIAL ─── */
.tut-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.tut-dots {
    display: flex;
    gap: 6px;
}

.tut-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transition: all 0.25s ease;
}

.tut-dot.active {
    background: var(--cyan);
    width: 20px;
    border-radius: 3px;
    box-shadow: 0 0 12px rgba(61, 243, 255, 0.5);
}

.tut-card {
    text-align: center;
    padding: 6px 4px 2px;
}

.tut-letter {
    width: 68px;
    height: 68px;
    border-radius: 18px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--ff-head);
    font-size: 30px;
    font-weight: 900;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.tut-letter:hover {
    transform: scale(1.04);
}

.tut-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.tut-desc {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 16px;
    min-height: 40px;
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
}

.tut-anim {
    width: 100%;
    height: 150px;
    border-radius: 14px;
    margin-bottom: 16px;
    overflow: hidden;
    position: relative;
    background: rgba(0, 0, 0, 0.30);
    border: 1px solid rgba(80, 160, 255, 0.08);
}

.tut-anim canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* ─── SETTINGS ─── */
.set-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.set-row:last-child {
    border-bottom: none;
}

.set-label {
    font-size: 14px;
    font-weight: 500;
}

.set-label .sub {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
    font-weight: 400;
}

.toggle {
    width: 46px;
    height: 26px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.10);
    position: relative;
    cursor: pointer;
    transition: background 0.25s ease;
    flex: none;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle.on {
    background: linear-gradient(135deg, var(--cyan), var(--violet));
    box-shadow: 0 0 20px rgba(61, 243, 255, 0.20);
}

.toggle .knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: left 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.toggle.on .knob {
    left: 23px;
    background: #fff;
}

/* ─── RESULTS ─── */
.res-badge {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(61, 243, 255, 0.20), transparent 70%);
    border: 2px solid var(--cyan);
    box-shadow: 0 0 48px rgba(61, 243, 255, 0.25), inset 0 0 48px rgba(61, 243, 255, 0.05);
    animation: resPulse 1.8s ease-in-out infinite;
}

@keyframes resPulse {

    0%,
    100% {
        box-shadow: 0 0 48px rgba(61, 243, 255, 0.20);
    }

    50% {
        box-shadow: 0 0 72px rgba(61, 243, 255, 0.35), 0 0 120px rgba(61, 243, 255, 0.08);
    }
}

.res-title {
    text-align: center;
    font-size: 24px;
    font-weight: 900;
    margin-bottom: 2px;
    color: var(--cyan);
    text-shadow: 0 0 30px rgba(61, 243, 255, 0.2);
}

.res-sub {
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.res-stats {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.res-stat {
    flex: 1;
    padding: 14px 8px;
    border-radius: 14px;
    text-align: center;
    background: rgba(8, 14, 34, 0.50);
    border: 1px solid rgba(80, 160, 255, 0.06);
}

.res-stat .lbl {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.10em;
    font-weight: 500;
}

.res-stat .val {
    font-family: var(--ff-head);
    font-size: 22px;
    font-weight: 800;
    margin-top: 2px;
}

.res-stat.new .val {
    color: var(--amber);
    text-shadow: 0 0 24px rgba(255, 182, 72, 0.25);
}

.res-stat.new .lbl::after {
    content: ' ★';
    color: var(--amber);
}

.res-actions {
    display: flex;
    gap: 10px;
}

.res-actions .btn {
    flex: 1;
}

/* ─── MODAL ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(3, 4, 12, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-sheet {
    width: 100%;
    max-width: 520px;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
    border-radius: 28px 28px 0 0;
    transform: translateY(30px);
    transition: transform 0.35s cubic-bezier(0.22, 0.8, 0.2, 1);
    max-height: 82vh;
    overflow-y: auto;
    scrollbar-width: none;
    background: rgba(8, 14, 34, 0.88);
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);
    border: 1px solid rgba(80, 160, 255, 0.10);
    border-bottom: none;
}

.modal-sheet::-webkit-scrollbar {
    display: none;
}

.modal-overlay.show .modal-sheet {
    transform: translateY(0);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.modal-head h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

/* ─── TOAST ─── */
#toast {
    position: fixed;
    top: calc(22px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%) translateY(-16px);
    z-index: 60;
    padding: 12px 24px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.22, 0.8, 0.2, 1);
    pointer-events: none;
    white-space: nowrap;
    background: rgba(8, 14, 34, 0.90);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(80, 160, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    color: var(--text);
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#toast.success {
    border-color: rgba(61, 243, 255, 0.35);
    box-shadow: 0 8px 40px rgba(61, 243, 255, 0.10);
}

/* ─── CONFETTI ─── */
#confettiCanvas {
    position: fixed;
    inset: 0;
    z-index: 55;
    pointer-events: none;
}

/* ─── ORIENTATION ─── */
#orientNotice {
    position: fixed;
    inset: 0;
    z-index: 120;
    background: var(--bg-0);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    padding: 30px;
}

#orientNotice.show {
    display: flex;
}

#orientNotice svg {
    margin-bottom: 14px;
    filter: drop-shadow(0 0 20px rgba(61, 243, 255, 0.2));
}

#orientNotice div:first-of-type {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 16px;
}

#orientNotice div:last-of-type {
    font-size: 13px;
    color: var(--text-dim);
    max-width: 280px;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 480px) {
    .screen-inner {
        padding: 18px 14px;
    }

    .home-title {
        font-size: 26px;
    }

    .hud-panel {
        padding: 8px 12px;
        gap: 12px;
    }

    .stat .val {
        font-size: 14px;
    }

    .hud-bottom-inner {
        padding: 8px 8px;
        gap: 4px;
    }

    .hud-bottom-inner .btn {
        min-width: 34px;
        min-height: 34px;
        padding: 4px;
    }

    .hud-bottom-inner .btn svg {
        width: 14px;
        height: 14px;
    }

    .best-strip {
        flex-wrap: wrap;
    }

    .best-card {
        flex: 1 1 30%;
        min-width: 60px;
    }

    .modal-sheet {
        padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
    }

    .res-badge {
        width: 68px;
        height: 68px;
    }

    .res-title {
        font-size: 20px;
    }

    .res-stat .val {
        font-size: 18px;
    }
}

@media (max-width: 380px) {
    .home-title {
        font-size: 22px;
    }

    .hud-top {
        padding: 8px 8px 0;
    }

    .hud-panel {
        padding: 6px 10px;
        gap: 8px;
    }

    .stat .val {
        font-size: 12px;
    }

    .stat .lbl {
        font-size: 7px;
    }

    .btn {
        font-size: 12px;
        padding: 8px 12px;
    }
}

@media (min-width: 768px) {
    .hud-top {
        padding: calc(20px + env(safe-area-inset-top)) 28px 0;
    }

    .hud-bottom {
        padding: 0 28px calc(20px + env(safe-area-inset-bottom));
    }

    .hud-panel {
        padding: 14px 24px;
        gap: 28px;
        border-radius: 20px;
    }

    .stat .val {
        font-size: 20px;
    }

    .screen-inner {
        padding: 36px 32px;
    }
}
.logo{border-radius: 30px;margin-top: 10px;margin-bottom: 10px;}