:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #060912;
    color: #f7f9ff;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    min-width: 0;
    min-height: 0;
    background:
        radial-gradient(circle at 10% 5%, rgba(101, 88, 255, .18), transparent 34%),
        radial-gradient(circle at 92% 10%, rgba(43, 220, 173, .10), transparent 28%),
        linear-gradient(160deg, #080b15 0%, #05070d 100%);
}

button,
canvas,
a {
    -webkit-tap-highlight-color: transparent;
}

.game-shell {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    padding: clamp(8px, 2.2vmin, 20px);
}

.game-layout {
    width: min(100%, 790px);
    height: min(100%, 670px);
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(150px, 230px);
    align-items: stretch;
    justify-content: center;
    gap: clamp(10px, 2.4vmin, 22px);
}

.board-panel {
    position: relative;
    height: 100%;
    width: auto;
    max-width: 100%;
    aspect-ratio: 1 / 2;
    justify-self: end;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: clamp(14px, 2.4vmin, 22px);
    background: #080c16;
    box-shadow:
        0 28px 74px rgba(0, 0, 0, .46),
        inset 0 1px 0 rgba(255, 255, 255, .045);
}

.board-panel::before {
    content: "";
    position: absolute;
    z-index: 2;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(255,255,255,.025), transparent 16%),
        repeating-linear-gradient(180deg, transparent 0, transparent 3px, rgba(255,255,255,.012) 4px);
    mix-blend-mode: screen;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
    touch-action: none;
}

.hud {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(8px, 1.7vmin, 13px);
}

.hud-brand,
.stat-card,
.next-card,
.controls-card {
    border: 1px solid rgba(255, 255, 255, .09);
    background: rgba(16, 22, 37, .83);
    box-shadow: 0 14px 38px rgba(0, 0, 0, .21);
    backdrop-filter: blur(12px);
}

.hud-brand {
    padding: clamp(12px, 2vmin, 17px);
    border-radius: 16px;
}

.eyebrow,
.section-label,
.stat-card > span {
    color: #9ba7bc;
    font-size: clamp(7px, 1.25vmin, 10px);
    font-weight: 850;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.eyebrow {
    color: #36d7a6;
    letter-spacing: .15em;
}

.hud-brand strong {
    display: block;
    margin-top: 4px;
    font-size: clamp(1.25rem, 4vmin, 2rem);
    line-height: .95;
    letter-spacing: -.055em;
}

.hud-subtitle {
    display: block;
    margin-top: 8px;
    color: #7e8ba3;
    font-size: clamp(7px, 1.2vmin, 10px);
}

.stat-card {
    min-width: 0;
    padding: clamp(9px, 1.7vmin, 14px);
    border-radius: 14px;
}

.stat-card strong {
    display: block;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: clamp(1.1rem, 3.1vmin, 1.65rem);
    line-height: 1;
    letter-spacing: -.04em;
}

.stat-card--wide strong {
    color: #ffffff;
    font-variant-numeric: tabular-nums;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.next-card {
    padding: clamp(9px, 1.7vmin, 14px);
    border-radius: 14px;
}

#nextCanvas {
    display: block;
    width: min(100%, 112px);
    height: auto;
    aspect-ratio: 1;
    margin: 4px auto 0;
}

.controls-card {
    padding: clamp(9px, 1.7vmin, 14px);
    border-radius: 14px;
}

.controls-card dl,
.controls-card div,
.controls-card dt,
.controls-card dd {
    margin: 0;
}

.controls-card dl {
    display: grid;
    gap: clamp(4px, .8vmin, 7px);
    margin-top: 8px;
}

.controls-card div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: clamp(7px, 1.25vmin, 10px);
}

.controls-card dt {
    color: #f6f8ff;
    font-weight: 850;
}

.controls-card dd {
    color: #8996ad;
    text-align: right;
}

.game-footer {
    padding: 0 4px;
    text-align: center;
}

.game-footer a {
    color: #6f7c92;
    font-size: clamp(7px, 1.15vmin, 9px);
    text-decoration: none;
}

.game-footer a:hover,
.game-footer a:focus-visible {
    color: #b6c0d2;
}

.game-overlay {
    position: absolute;
    z-index: 8;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 26px;
    text-align: center;
    background: rgba(4, 7, 14, .71);
    backdrop-filter: blur(8px);
}

.game-overlay[hidden] {
    display: none;
}

.overlay-card {
    width: min(100%, 255px);
    padding: 24px 18px;
    border: 1px solid rgba(255, 255, 255, .10);
    border-radius: 18px;
    background: rgba(11, 16, 28, .84);
    box-shadow: 0 22px 60px rgba(0, 0, 0, .35);
}

.overlay-kicker {
    display: block;
    margin-bottom: 8px;
    color: #36d7a6;
    font-size: .66rem;
    font-weight: 900;
    letter-spacing: .14em;
}

.overlay-card strong {
    display: block;
    font-size: clamp(2rem, 7vmin, 3.7rem);
    line-height: .9;
    letter-spacing: -.065em;
}

.overlay-card > span:last-child {
    display: block;
    margin-top: 12px;
    color: #9aa6bb;
    font-size: clamp(.72rem, 1.8vmin, .9rem);
    line-height: 1.5;
}


.music-card {
    display: grid;
    gap: 8px;
}

.music-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 12px;
    color: #dce5f5;
    background: rgba(255, 255, 255, .045);
    font: inherit;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .02em;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.music-toggle:hover,
.music-toggle:focus-visible {
    border-color: rgba(54, 215, 166, .45);
    background: rgba(54, 215, 166, .09);
    outline: none;
}

.music-toggle:active {
    transform: translateY(1px);
}

.music-toggle[aria-pressed="false"] {
    color: #8b97aa;
}

.music-toggle__icon {
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 7px;
    color: #08110f;
    background: #36d7a6;
    font-size: .9rem;
    font-weight: 900;
}

.music-toggle[aria-pressed="false"] .music-toggle__icon {
    color: #8b97aa;
    background: rgba(255, 255, 255, .07);
}

@media (max-width: 430px) {
    .game-shell {
        padding: 6px;
    }

    .game-layout {
        position: relative;
        display: grid;
        grid-template-columns: 1fr;
        place-items: center;
        gap: 0;
    }

    .board-panel {
        height: 100%;
        justify-self: center;
    }

    .hud {
        position: absolute;
        z-index: 5;
        top: 9px;
        left: 50%;
        width: min(calc(100% - 30px), 230px);
        transform: translateX(-50%);
        display: grid;
        grid-template-columns: 1.4fr .8fr .8fr;
        gap: 5px;
        pointer-events: none;
    }

    .hud-brand,
    .next-card,
    .controls-card,
    .music-card,
    .game-footer,
    .stats-grid {
        display: contents;
    }

    .hud-brand,
    .next-card,
    .controls-card,
    .game-footer {
        display: none;
    }

    .score-card,
    .stats-grid .stat-card {
        padding: 7px 8px;
        border-radius: 11px;
        background: rgba(8, 12, 22, .77);
        backdrop-filter: blur(8px);
    }

    .score-card strong,
    .stats-grid .stat-card strong {
        font-size: .95rem;
    }

    .score-card > span,
    .stats-grid .stat-card > span {
        font-size: 6px;
    }
}

@media (max-height: 430px) {
    .game-shell {
        padding: 6px;
    }

    .game-layout {
        gap: 8px;
        grid-template-columns: minmax(0, auto) minmax(126px, 180px);
    }

    .controls-card,
    .music-card,
    .game-footer,
    .hud-subtitle {
        display: none;
    }

    .hud-brand,
    .stat-card,
    .next-card {
        padding: 7px 9px;
    }

    #nextCanvas {
        width: min(100%, 76px);
    }
}
