:root {
    --bg: #121211;
    --fg: #f5f5f0;
    --mut: rgba(245, 245, 240, .56);
    --dim: #74746d;
    --ink: 255, 255, 255;
    --bgc: 18, 18, 17;
    --line: rgba(var(--ink), .09);
    --glass: rgba(var(--ink), .055);
    --hi: rgba(255, 255, 255, .16);
    --shadow: rgba(0, 0, 0, .35);
    --ex: #3a3a36;
    --hot: #ffd08a;
    --ease: cubic-bezier(.22, 1, .36, 1);
    --pad: clamp(20px, 5vw, 72px);
}

html[data-theme="light"] {
    color-scheme: light;
    --bg: #f5f5f0;
    --fg: #121211;
    --mut: rgba(18, 18, 17, .6);
    --dim: #9a9a92;
    --ink: 18, 18, 17;
    --bgc: 245, 245, 240;
    --glass: rgba(255, 255, 255, .65);
    --hi: rgba(255, 255, 255, .9);
    --shadow: rgba(18, 18, 17, .1);
    --ex: #c4c4bb;
    --hot: #b86e00;
}

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

html {
    background: var(--bg);
    color-scheme: dark light;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth
}

body {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    line-height: 1.5
}

body.in-game {
    overflow: hidden
}

a {
    color: inherit;
    text-decoration: none
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent
}

[hidden] {
    display: none !important
}

.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap
}

::selection {
    background: var(--fg);
    color: var(--bg)
}

.glass {
    background: var(--glass);
    backdrop-filter: blur(22px) saturate(1.5);
    -webkit-backdrop-filter: blur(22px) saturate(1.5);
    border: 1px solid var(--line);
    box-shadow: inset 0 1px 0 var(--hi), 0 10px 40px var(--shadow)
}

/* ---------- loader ---------- */
#loader {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--bg);
    display: grid;
    place-items: center;
    transition: opacity .7s var(--ease), visibility .7s
}

#loader.done {
    opacity: 0;
    visibility: hidden;
    pointer-events: none
}

.ld-blocks,
.iris-mark {
    display: grid;
    grid-template-columns: repeat(2, 18px);
    gap: 6px
}

.ld-blocks i,
.iris-mark i {
    display: block;
    border-radius: 5px;
    background: var(--fg)
}

.ld-blocks i {
    width: 18px;
    height: 18px;
    animation: ld 1.1s var(--ease) infinite
}

.ld-blocks i:nth-child(2) {
    animation-delay: .12s;
    opacity: .55
}

.ld-blocks i:nth-child(3) {
    animation-delay: .36s;
    opacity: .55
}

.ld-blocks i:nth-child(4) {
    animation-delay: .24s
}

@keyframes ld {

    0%,
    100% {
        transform: scale(1)
    }

    50% {
        transform: scale(.55);
        border-radius: 9px
    }
}

/* ---------- nav ---------- */
.nav {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    width: min(92vw, 660px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 8px 8px 18px;
    border-radius: 999px;
    transition: background .4s, transform .5s var(--ease)
}

.nav.scrolled {
    background: rgba(var(--bgc), .6)
}

body.in-game .nav {
    transform: translate(-50%, -140%)
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    letter-spacing: -.01em
}

.logo-mark {
    display: block;
    transition: transform .6s var(--ease)
}

.brand:hover .logo-mark {
    transform: rotate(90deg)
}

.nav nav {
    display: flex;
    gap: 22px;
    font-size: 13.5px;
    color: var(--mut)
}

.nav nav a {
    transition: color .25s
}

.nav nav a:hover {
    color: var(--fg)
}

.nav-cta {
    background: var(--fg);
    color: var(--bg);
    font-weight: 600;
    font-size: 13.5px;
    padding: 9px 18px;
    border-radius: 999px;
    transition: transform .3s var(--ease)
}

.nav-cta:hover {
    transform: scale(1.05)
}

@media(max-width:560px) {
    .nav nav {
        display: none
    }
}

/* ---------- buttons ---------- */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 15px 28px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -.01em;
    overflow: hidden;
    transition: transform .35s var(--ease), background .3s
}

.btn.primary {
    background: var(--fg);
    color: var(--bg)
}

.btn.ghost {
    color: var(--mut)
}

.btn.ghost:hover {
    color: var(--fg)
}

.btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%);
    transform: translateX(-120%);
    transition: transform .8s var(--ease);
    pointer-events: none
}

.btn:hover::after {
    transform: translateX(120%)
}

.btn:active {
    transform: scale(.97) !important
}

.btn.glass:hover {
    background: rgba(var(--ink), .1)
}

.btn span {
    position: relative;
    z-index: 1
}

/* ---------- hero ---------- */
.hero {
    height: 175vh;
    position: relative
}

.hero-pin {
    position: sticky;
    top: 0;
    height: 100svh;
    overflow: hidden;
    transform-origin: 50% 100%;
    will-change: transform;
    background: var(--bg)
}

.hero-pin canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: pan-y
}

#scene {
    display: none
}

.hero-top {
    position: absolute;
    top: calc(14% + 20px);
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 0 16px;
    z-index: 2
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    border-radius: 999px;
    font-size: clamp(12.5px, 3.4vw, 15px);
    font-weight: 600;
    animation: rise 1s .5s var(--ease) both;
    transition: transform .35s var(--ease)
}

.pill:hover {
    transform: translateY(-2px)
}

.pill .tag {
    background: var(--fg);
    color: var(--bg);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: .92em;
    font-weight: 700
}

.hero-bottom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(7% + 10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
    padding: 0 20px;
    text-align: center;
    z-index: 2;
    pointer-events: none
}

.hero-bottom>* {
    pointer-events: auto
}

.sub {
    max-width: 520px;
    color: var(--mut);
    font-size: clamp(15px, 2.2vw, 18px);
    animation: rise 1s .9s var(--ease) both
}

.cta-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    animation: rise 1s 1.05s var(--ease) both
}

.scroll-cue {
    position: absolute;
    left: 50%;
    bottom: 18px;
    width: 22px;
    height: 34px;
    border: 1.5px solid rgba(var(--ink), .3);
    border-radius: 12px;
    transform: translateX(-50%);
    z-index: 2
}

.scroll-cue i {
    position: absolute;
    left: 50%;
    top: 7px;
    width: 3px;
    height: 7px;
    margin-left: -1.5px;
    background: var(--fg);
    border-radius: 2px;
    animation: cue 1.8s var(--ease) infinite
}

@keyframes cue {
    0% {
        transform: translateY(0);
        opacity: 1
    }

    80%,
    100% {
        transform: translateY(12px);
        opacity: 0
    }
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(24px)
    }

    to {
        opacity: 1;
        transform: none
    }
}

@media(max-height:640px) {
    .scroll-cue {
        display: none
    }

    .hero-bottom {
        gap: 16px
    }
}

/* ---------- marquee ---------- */
.marquee {
    overflow: hidden;
    border-block: 1px solid var(--line);
    padding: 26px 0;
    background: var(--bg);
    position: relative;
    z-index: 2
}

.track {
    display: flex;
    gap: 56px;
    width: max-content;
    animation: mq 38s linear infinite
}

.track span {
    font-size: clamp(28px, 5vw, 52px);
    font-weight: 800;
    letter-spacing: -.04em;
    color: transparent;
    -webkit-text-stroke: 1px rgba(var(--ink), .28);
    white-space: nowrap
}

.track span::after {
    content: "✦";
    margin-left: 56px;
    -webkit-text-stroke: 0;
    color: rgba(var(--ink), .25);
    font-size: .5em;
    vertical-align: middle
}

@keyframes mq {
    to {
        transform: translateX(calc(-50% - 28px))
    }
}

/* ---------- manifesto ---------- */
.manifesto {
    padding: clamp(100px, 22vh, 220px) var(--pad);
    max-width: 1200px;
    margin: 0 auto
}

.manifesto p {
    font-size: clamp(30px, 5.6vw, 72px);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -.04em
}

.manifesto .w {
    opacity: .14;
    transition: opacity .25s linear
}

/* ---------- shared ---------- */
.eyebrow {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--mut);
    margin-bottom: 14px
}

h2 {
    font-size: clamp(38px, 7vw, 88px);
    font-weight: 800;
    letter-spacing: -.045em;
    line-height: 1
}

.dim {
    color: var(--dim)
}

.section-head {
    margin-bottom: clamp(36px, 6vw, 64px)
}

.rv {
    opacity: 0;
    transform: translateY(34px);
    transition: opacity .9s var(--ease), transform .9s var(--ease)
}

.rv.in {
    opacity: 1;
    transform: none
}

/* ---------- bento ---------- */
.bento,
.about,
.modes {
    padding: clamp(70px, 12vh, 130px) var(--pad);
    max-width: 1280px;
    margin: 0 auto
}

.grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px
}

.card,
.mode {
    position: relative;
    overflow: hidden;
    border-radius: 28px;
    background: rgba(var(--ink), .035);
    border: 1px solid var(--line);
    padding: clamp(22px, 3vw, 34px)
}

.card::before,
.mode::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity .4s;
    background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(var(--ink), .1), transparent 60%)
}

.card:hover::before,
.mode:hover::before {
    opacity: 1
}

.c3 {
    grid-column: span 3
}

.c2 {
    grid-column: span 2
}

.card h3 {
    font-size: clamp(20px, 2.4vw, 26px);
    letter-spacing: -.03em;
    line-height: 1.15;
    margin: 20px 0 8px
}

.card p {
    color: var(--mut);
    font-size: 15px;
    max-width: 34ch
}

.stat {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-height: 92px
}

.stat span {
    font-size: clamp(64px, 8vw, 104px);
    font-weight: 800;
    letter-spacing: -.06em;
    line-height: 1
}

.stat em {
    font-style: normal;
    color: var(--mut);
    font-weight: 600
}

.mini-pair {
    display: flex;
    gap: 18px;
    min-height: 92px;
    align-items: flex-end
}

.mini-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center
}

.mini-wrap small {
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--mut)
}

.mini {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    width: 86px;
    height: 86px
}

.mini i {
    border-radius: 2px;
    background: rgba(var(--ink), .07);
    transition: background .5s, transform .5s var(--ease)
}

.mini i.on {
    background: rgba(var(--ink), .85)
}

.card:hover .mini i.on {
    transform: scale(.8)
}

@media(max-width:820px) {

    .c3,
    .c2 {
        grid-column: span 6
    }
}

@media(min-width:821px) and (max-width:1000px) {
    .c2 {
        grid-column: span 3
    }
}

/* ---------- about ---------- */
.about {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: clamp(30px, 6vw, 90px);
    align-items: center
}

.portrait-wrap {
    position: relative;
    perspective: 900px
}

.portrait {
    position: relative;
    aspect-ratio: 4/5;
    border-radius: 34px;
    overflow: hidden;
    transition: transform .5s var(--ease);
    transform-style: preserve-3d
}

.portrait img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(1) contrast(1.05)
}

.portrait .ph {
    position: absolute;
    inset: 14px;
    border: 1.5px dashed rgba(var(--ink), .22);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--mut);
    text-align: center
}

.portrait img+.ph {
    display: none
}

.portrait .ph small {
    opacity: .7
}

.float-chip {
    position: absolute;
    right: -12px;
    bottom: 28px;
    padding: 11px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    animation: bob 5s ease-in-out infinite
}

@keyframes bob {
    50% {
        transform: translateY(-8px)
    }
}

.about-text p {
    color: var(--mut);
    font-size: clamp(16px, 1.8vw, 19px);
    margin-top: 20px;
    max-width: 48ch
}

.chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 28px
}

.chips span {
    padding: 8px 15px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500
}

.links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 28px
}

.links .btn {
    padding: 12px 22px;
    font-size: 14px
}

@media(max-width:820px) {
    .about {
        grid-template-columns: 1fr
    }

    .portrait-wrap {
        max-width: 380px
    }

    .float-chip {
        right: 8px
    }
}

/* ---------- modes ---------- */
.challenge {
    display: inline-block;
    margin-top: 22px;
    padding: 12px 18px;
    border-radius: 16px;
    font-size: 14px;
    color: var(--mut)
}

.challenge b {
    color: var(--fg)
}

.mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px
}

.mode {
    text-align: left;
    display: flex;
    flex-direction: column;
    min-height: clamp(260px, 34vw, 380px);
    transition: transform .5s var(--ease), border-color .4s, opacity .9s var(--ease)
}

.mode:hover {
    transform: translateY(-6px);
    border-color: rgba(var(--ink), .22)
}

.mode.vs {
    background: rgba(var(--ink), .075)
}

.mode.pulse {
    animation: pulse 2s ease-in-out infinite
}

@keyframes pulse {
    50% {
        box-shadow: 0 0 0 8px rgba(var(--ink), .07)
    }
}

.m-ico {
    width: 56px;
    height: 56px;
    color: var(--fg)
}

.mode h3 {
    font-size: clamp(30px, 4vw, 46px);
    font-weight: 800;
    letter-spacing: -.04em;
    margin-top: auto
}

.mode p {
    color: var(--mut);
    margin-top: 6px;
    max-width: 30ch
}

.go {
    margin-top: 22px;
    font-weight: 600;
    display: inline-flex;
    gap: 8px;
    align-items: center
}

.go i {
    font-style: normal;
    transition: transform .4s var(--ease)
}

.mode:hover .go i {
    transform: translateX(8px)
}

.badge {
    position: absolute;
    top: 22px;
    right: 22px;
    background: var(--fg);
    color: var(--bg);
    font-weight: 800;
    font-size: 12px;
    padding: 5px 11px;
    border-radius: 999px;
    letter-spacing: .06em
}

@media(max-width:700px) {
    .mode-grid {
        grid-template-columns: 1fr
    }
}

.foot {
    padding: clamp(50px, 9vw, 110px) var(--pad) 40px;
    border-top: 1px solid var(--line);
    color: var(--mut);
    font-size: 14px;
    overflow: hidden
}

.wm {
    position: relative;
    display: block;
    width: fit-content;
    margin: 0 auto clamp(30px, 6vw, 70px);
    font-size: clamp(54px, 15.5vw, 230px);
    font-weight: 800;
    letter-spacing: -.055em;
    line-height: 1;
    white-space: nowrap;
    user-select: none;
    transform-style: preserve-3d;
    transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    transition: transform .45s var(--ease)
}

.wm span {
    display: block
}

.wm .back {
    position: absolute;
    inset: 0;
    color: var(--ex);
    transform: translateZ(-34px);
    text-shadow:
        1px 1px 0 var(--ex), 2px 2px 0 var(--ex), 3px 3px 0 var(--ex),
        4px 4px 0 var(--ex), 5px 5px 0 var(--ex), 6px 6px 0 var(--ex),
        7px 7px 0 var(--ex), 8px 8px 0 var(--ex), 9px 9px 0 var(--ex),
        10px 10px 0 var(--ex), 18px 22px 40px rgba(var(--ink), .12)
}

.wm .front {
    position: relative;
    color: var(--fg);
    transform: translateZ(34px)
}

.foot-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap
}

.theme-switch {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 999px
}

.theme-switch button {
    width: 38px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    color: var(--mut);
    transition: background .3s, color .3s
}

.theme-switch button.on {
    background: var(--fg);
    color: var(--bg)
}

/* ---------- iris transition ---------- */
#iris {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: var(--fg);
    display: grid;
    place-items: center;
    pointer-events: none;
    clip-path: circle(0px at var(--x, 50%) var(--y, 50%));
    transition: clip-path .85s cubic-bezier(.76, 0, .24, 1), opacity .65s ease
}

#iris.on {
    clip-path: circle(160vmax at var(--x, 50%) var(--y, 50%));
    pointer-events: all
}

#iris.out {
    opacity: 0
}

.iris-mark {
    opacity: 0;
    transition: opacity .3s .5s
}

#iris.on .iris-mark {
    opacity: 1
}

.iris-mark i {
    width: 18px;
    height: 18px;
    background: var(--bg);
    animation: ld 1.1s var(--ease) infinite
}

.iris-mark i:nth-child(2) {
    animation-delay: .12s;
    opacity: .5
}

.iris-mark i:nth-child(3) {
    animation-delay: .36s;
    opacity: .5
}

.iris-mark i:nth-child(4) {
    animation-delay: .24s
}

/* ---------- game ---------- */
#game {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-image: radial-gradient(900px 500px at 50% -10%, rgba(var(--ink), .06), transparent 70%)
}

.g-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: max(14px, env(safe-area-inset-top)) 16px 10px;
    position: relative;
    z-index: 3
}

.icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    transition: transform .3s var(--ease)
}

.icon:hover {
    transform: scale(1.08)
}

.g-title {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 13px
}

.g-title i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--mut)
}

.g-title span {
    color: var(--mut);
    font-variant-numeric: tabular-nums
}

.arena {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(16px, 3vw, 48px);
    padding: 0 16px max(16px, env(safe-area-inset-bottom))
}

.panel {
    width: min(46vw, calc((100svh - 170px)*.774));
    display: flex;
    flex-direction: column;
    gap: 8px
}

.arena.solo .panel {
    width: min(92vw, calc((100svh - 170px)*.774))
}

.panel canvas {
    width: 100%;
    display: block;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none
}

.p-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 8px
}

.p-head small {
    display: block;
    font-size: 11px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--mut);
    font-weight: 600
}

.p-head .score {
    font-size: clamp(30px, 5vw, 44px);
    font-weight: 800;
    letter-spacing: -.04em;
    line-height: 1;
    font-variant-numeric: tabular-nums
}

.p-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px
}

.combo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
    color: var(--mut)
}

.combo.hot {
    color: var(--hot)
}

.dots {
    display: flex;
    gap: 4px
}

.dots i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: 1.5px solid var(--mut)
}

.combo.hot .dots i.on {
    background: var(--hot);
    border-color: var(--hot)
}

.status {
    font-size: 12px;
    color: var(--mut);
    min-height: 16px
}

.status.think::after {
    content: "";
    display: inline-block;
    width: 1.4em;
    text-align: left;
    animation: dots 1.2s steps(4) infinite
}

@keyframes dots {
    0% {
        content: ""
    }

    25% {
        content: "."
    }

    50% {
        content: ".."
    }

    75%,
    100% {
        content: "..."
    }
}

.vs-mid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    align-self: stretch;
    justify-content: center
}

.vs-mid span {
    font-weight: 800;
    letter-spacing: .1em;
    font-size: 13px;
    color: var(--mut)
}

.lead {
    width: 5px;
    flex: 1;
    max-height: 50%;
    border-radius: 4px;
    background: rgba(var(--ink), .1);
    position: relative;
    overflow: hidden
}

.lead i {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--fg);
    height: calc(var(--lead, .5)*100%);
    transition: height .5s var(--ease)
}

.g-note {
    position: absolute;
    left: 0;
    right: 0;
    bottom: max(10px, env(safe-area-inset-bottom));
    text-align: center;
    font-size: 12.5px;
    color: var(--mut);
    pointer-events: none;
    opacity: 0;
    transition: opacity .4s
}

.g-note.show {
    opacity: 1
}

.arena.enter .panel {
    animation: rise .9s var(--ease) both
}

.arena.enter .panel.ai {
    animation-delay: .12s
}

@media(max-width:760px) {
    .arena.vs {
        flex-direction: column;
        gap: 4px;
        justify-content: flex-start
    }

    .arena.vs .panel.you {
        width: min(94vw, calc((100svh - 330px)*.774))
    }

    .arena.vs .panel.ai {
        order: -1;
        width: min(36vw, 22svh)
    }

    .arena.vs .panel.ai .p-head .score {
        font-size: 24px
    }

    .vs-mid {
        display: none
    }
}

.countdown {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
    font-size: clamp(100px, 26vw, 240px);
    font-weight: 800;
    letter-spacing: -.06em;
    z-index: 5
}

.countdown.pop {
    animation: cd .7s var(--ease)
}

@keyframes cd {
    0% {
        transform: scale(.4);
        opacity: 0
    }

    30% {
        opacity: 1
    }

    100% {
        transform: scale(1.25);
        opacity: 0
    }
}

.result {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(var(--bgc), .62);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: fade .5s both
}

@keyframes fade {
    from {
        opacity: 0
    }
}

.r-card {
    width: min(94vw, 520px);
    border-radius: 32px;
    padding: clamp(26px, 5vw, 44px);
    text-align: center;
    animation: rise .8s var(--ease) both
}

.r-card h2 {
    font-size: clamp(46px, 10vw, 76px)
}

.r-scores {
    display: flex;
    justify-content: center;
    gap: clamp(24px, 6vw, 48px);
    margin: 26px 0 8px
}

.r-scores div {
    display: flex;
    flex-direction: column;
    gap: 2px
}

.r-scores small {
    font-size: 11px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--mut)
}

.r-scores b {
    font-size: clamp(30px, 6vw, 44px);
    font-weight: 800;
    letter-spacing: -.04em;
    font-variant-numeric: tabular-nums
}

.r-scores .win b {
    color: var(--fg)
}

.r-scores .lose b {
    color: var(--dim)
}

.best {
    font-style: normal;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(var(--ink), .08);
    letter-spacing: .06em;
    font-size: 10px;
    transition: background .4s, color .4s
}

.best.beat {
    background: var(--hot);
    color: var(--bg)
}

.r-stats {
    display: flex;
    justify-content: center;
    gap: clamp(20px, 5vw, 40px);
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line)
}

.r-stats div {
    display: flex;
    flex-direction: column;
    gap: 2px
}

.r-stats b {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums
}

.r-stats small {
    font-size: 10px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--mut)
}

.record {
    padding: clamp(70px, 12vh, 130px) var(--pad) clamp(40px, 8vh, 80px);
    max-width: 1280px;
    margin: 0 auto
}

.rec-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 14px
}

.rec {
    border-radius: 28px;
    border: 1px solid var(--line);
    background: rgba(var(--ink), .035);
    padding: clamp(20px, 3vw, 30px);
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: flex-end;
    min-height: 150px
}

.rec b {
    font-size: clamp(34px, 5vw, 58px);
    font-weight: 800;
    letter-spacing: -.05em;
    line-height: 1;
    font-variant-numeric: tabular-nums
}

.rec.big b {
    font-size: clamp(54px, 9vw, 110px)
}

.rec small,
.rec-recent small {
    font-size: 11px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--mut)
}

.rec-recent {
    margin-top: 14px;
    padding: 18px 22px;
    border-radius: 28px;
    border: 1px solid var(--line);
    background: rgba(var(--ink), .035);
    flex-wrap: wrap;
    justify-content: space-between
}

#recRecent {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    flex: 1 1 100%
}

.rec-recent > small {
    display: block;
    margin: 0 0 12px 4px
}

.match {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 18px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(var(--ink), .035)
}

.match .m-res {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--mut)
}

.match .m-res::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 3px;
    background: rgba(var(--ink), .25)
}

.match.win .m-res {
    color: var(--fg)
}

.match.win .m-res::before {
    background: var(--fg)
}

.match.lose .m-res::before {
    background: transparent;
    border: 1.5px solid var(--mut)
}

.match b {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums
}

.match.lose b {
    color: var(--dim)
}

.rec-recent .match small {
    font-size: 12px;
    letter-spacing: 0;
    text-transform: none;
    color: var(--dim)
}

.match-empty {
    grid-column: 1 / -1;
    color: var(--mut);
    font-size: 14px
}

@media (max-width: 760px) {
    .rec-grid {
        grid-template-columns: 1fr 1fr
    }

    .rec.big {
        grid-column: 1 / -1
    }
}

.r-card p {
    color: var(--mut);
    font-size: 15px;
    min-height: 22px
}

.r-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 26px
}

.r-btns .btn {
    padding: 14px 16px;
    font-size: 14.5px
}

.r-btns .primary {
    grid-column: 1/-1
}

#toast {
    position: fixed;
    left: 50%;
    bottom: 30px;
    transform: translate(-50%, 30px);
    z-index: 300;
    padding: 12px 20px;
    border-radius: 999px;
    background: var(--fg);
    color: var(--bg);
    font-weight: 600;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: all .5s var(--ease);
    max-width: 90vw;
    text-align: center
}

/* Full-screen result */
.result {
    padding: 0;
    background: rgba(var(--bgc), .92);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px)
}

.r-card {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: max(24px, env(safe-area-inset-top)) var(--pad) max(24px, env(safe-area-inset-bottom));
    overflow-y: auto
}

.r-card .eyebrow {
    font-size: 12px;
    margin-bottom: 10px
}

.r-card h2 {
    font-size: clamp(34px, 6vw, 72px)
}

.r-scores {
    width: 100%;
    max-width: 1200px;
    margin: clamp(18px, 4vh, 44px) 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0
}

.r-scores div {
    align-items: center;
    gap: 6px;
    padding: 0 12px
}

.r-scores div + div {
    border-left: 1px solid var(--line)
}

.r-scores div:only-child {
    grid-column: 1 / -1
}

.r-scores small {
    font-size: clamp(11px, 1.4vw, 14px);
    letter-spacing: .2em
}

.r-scores b {
    font-size: clamp(56px, 15vw, 260px);
    line-height: .95;
    letter-spacing: -.06em
}

.r-scores .lose b {
    color: var(--dim)
}

.r-scores .win:not(:only-child) small::after {
    content: " · winner";
    color: var(--hot)
}

.r-card p {
    font-size: clamp(14px, 1.6vw, 18px);
    max-width: 44ch;
    margin: 0 auto;
    min-height: 0
}

.r-stats {
    gap: clamp(24px, 6vw, 64px);
    margin-top: clamp(16px, 3vh, 32px);
    padding-top: clamp(14px, 2.5vh, 24px);
    border-top: 1px solid var(--line);
    width: min(92vw, 560px)
}

.r-stats b {
    font-size: clamp(20px, 2.4vw, 28px)
}

.r-btns {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: clamp(20px, 4vh, 36px);
    width: min(92vw, 720px)
}

.r-btns .btn {
    padding: 14px 24px;
    font-size: 14.5px;
    flex: 0 1 auto
}

.r-btns .primary {
    flex: 1 1 100%;
    max-width: 360px
}

.r-btns .ghost {
    padding: 14px 18px
}

@media (max-width: 600px) {
    .r-scores {
        grid-template-columns: 1fr;
        gap: 6px
    }

    .r-scores div + div {
        border-left: 0;
        border-top: 1px solid var(--line);
        padding-top: 10px
    }

    .r-scores b {
        font-size: clamp(56px, 22vw, 120px)
    }

    .r-btns .btn {
        flex: 1 1 40%
    }
}

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

@media(prefers-reduced-motion:reduce) {
    * {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important
    }

    html {
        scroll-behavior: auto
    }

    .track {
        animation: none
    }
}

/* Full-screen result: fit + no scrollbar */
.r-card {
    justify-content: safe center;
    gap: 0;
    scrollbar-width: none;
    -ms-overflow-style: none
}

.r-card::-webkit-scrollbar {
    display: none
}

.r-card > * {
    flex-shrink: 0
}

.r-scores {
    margin: clamp(10px, 2.5vh, 28px) 0
}

.r-scores b {
    font-size: clamp(56px, min(15vw, 24vh), 240px);
    line-height: .9
}

.r-scores div {
    gap: 2px
}

.r-card h2 {
    font-size: clamp(34px, min(6vw, 9vh), 72px)
}

.r-card p {
    margin: 0 auto
}

.r-stats {
    margin-top: clamp(14px, 2.5vh, 26px)
}

.r-btns {
    margin-top: clamp(16px, 3vh, 28px)
}

@media (max-width: 600px) {
    .r-scores b {
        font-size: clamp(48px, min(20vw, 14vh), 110px)
    }
}

/* Result: breathing room under the scores */
.r-scores {
    margin: clamp(10px, 2.5vh, 28px) 0 clamp(26px, 5vh, 52px)
}

.r-scores b {
    padding-bottom: .08em
}

.r-card p {
    margin: 0 auto clamp(18px, 3vh, 30px)
}

.r-stats {
    margin-top: 0
}

/* Mobile result screen: one centered group */
@media (max-width: 600px) {
    .result .r-card {
        justify-content: safe center;
        padding: max(28px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom))
    }

    .result .r-card .eyebrow {
        font-size: 11px;
        margin-bottom: 10px
    }

    .result .r-card h2 {
        font-size: clamp(48px, 16vw, 68px)
    }

    .result .r-scores {
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: none;
        margin: 28px 0 0;
        gap: 0;
        border-top: 1px solid var(--line)
    }

    .result .r-scores div,
    .result .r-scores div + div {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 18px 2px;
        border: 0;
        border-bottom: 1px solid var(--line)
    }

    .result .r-scores div:only-child {
        grid-column: auto
    }

    .result .r-scores small {
        font-size: 12px;
        letter-spacing: .18em
    }

    .result .r-scores b {
        font-size: clamp(64px, 22vw, 108px);
        line-height: 1;
        padding-bottom: 0;
        letter-spacing: -.055em
    }

    .result .r-card p {
        font-size: 14px;
        max-width: 30ch;
        margin: 22px auto 0;
        text-align: center
    }

    .result .r-stats {
        width: 100%;
        justify-content: space-around;
        gap: 12px;
        margin-top: 22px;
        padding-top: 20px
    }

    .result .r-stats b {
        font-size: 20px
    }

    .result .r-btns {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
        gap: 10px;
        margin-top: 28px;
        padding-top: 0
    }

    .result .r-btns .btn {
        padding: 15px 10px;
        font-size: 14.5px
    }

    .result .r-btns .primary {
        grid-column: 1 / -1;
        max-width: none;
        padding: 18px;
        font-size: 16px
    }

    .result .r-btns .ghost {
        grid-column: 1 / -1;
        padding: 10px;
        font-size: 14px
    }
}

.challenge {
    padding: 18px 22px;
    border-radius: 22px
}

.ch-scores {
    display: flex;
    gap: clamp(24px, 6vw, 44px);
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line)
}

.ch-scores div {
    display: flex;
    flex-direction: column;
    gap: 4px
}

.ch-scores small {
    font-size: 11px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--mut)
}

.ch-scores b {
    font-size: clamp(34px, 6vw, 52px);
    font-weight: 800;
    letter-spacing: -.045em;
    line-height: 1;
    font-variant-numeric: tabular-nums
}

.ch-scores div:first-child b {
    color: var(--hot)
}

/* Liquid-glass share sheet */
#share {
    position: fixed;
    inset: 0;
    z-index: 250;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 14px max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    overscroll-behavior: contain
}

@media (min-width: 700px) {
    #share {
        align-items: center
    }
}

.sh-back {
    position: absolute;
    inset: 0;
    opacity: 0;
    background: rgba(0, 0, 0, .38);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity .45s var(--ease)
}

#share.on .sh-back {
    opacity: 1
}

.sh-sheet {
    position: relative;
    width: min(100%, 460px);
    max-height: calc(100svh - 28px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 12px 22px 24px;
    border-radius: 38px;
    background:
        radial-gradient(420px 220px at 12% -8%, rgba(255, 255, 255, .22), transparent 60%),
        radial-gradient(360px 200px at 100% 110%, rgba(var(--ink), .08), transparent 60%),
        linear-gradient(160deg, rgba(var(--ink), .12), rgba(var(--ink), .03)),
        rgba(var(--bgc), .55);
    backdrop-filter: blur(36px) saturate(1.9);
    -webkit-backdrop-filter: blur(36px) saturate(1.9);
    border: 1px solid rgba(var(--ink), .16);
    box-shadow: inset 0 1.5px 0 var(--hi), inset 0 -1px 0 rgba(var(--ink), .08), inset 0 0 40px rgba(var(--ink), .03), 0 40px 90px var(--shadow);
    opacity: 0;
    transform: translateY(60px) scale(.94);
    transition: transform .6s var(--ease), opacity .4s
}

#share.on .sh-sheet {
    opacity: 1;
    transform: none
}

.sh-sheet::-webkit-scrollbar {
    display: none
}

.sh-sheet {
    scrollbar-width: none;
    -ms-overflow-style: none
}

.sh-grab {
    display: block;
    width: 40px;
    height: 5px;
    border-radius: 3px;
    margin: 0 auto 14px;
    background: rgba(var(--ink), .22)
}

.sh-x {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--mut);
    background: rgba(var(--ink), .08);
    border: 1px solid var(--line);
    transition: transform .3s var(--ease), color .2s
}

.sh-x:hover {
    transform: rotate(90deg);
    color: var(--fg)
}

.sh-x svg {
    width: 16px;
    height: 16px
}

.sh-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: 8px;
    padding: 18px 18px 30px;
    border-radius: 26px;
    background: rgba(var(--ink), .06);
    border: 1px solid var(--line);
    box-shadow: inset 0 1px 0 var(--hi)
}

.sh-board.mini {
    width: 84px;
    height: 84px;
    flex: none;
    gap: 2px
}

.sh-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0
}

.sh-info small {
    font-size: 11px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--mut)
}

.sh-info b {
    font-size: clamp(38px, 10vw, 50px);
    font-weight: 800;
    letter-spacing: -.05em;
    line-height: 1;
    font-variant-numeric: tabular-nums
}

.sh-info span {
    font-size: 13px;
    color: var(--mut)
}

.sh-wm {
    position: absolute;
    right: 16px;
    bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(var(--ink), .38);
    pointer-events: none
}

.sh-apps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px 8px;
    margin: 24px 0 22px
}

.sh-app {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0;
    animation: rise .7s var(--ease) both;
    animation-delay: calc(.12s + var(--i) * 50ms)
}

.sh-app small {
    font-size: 12px;
    color: var(--mut);
    transition: color .25s
}

.sh-ico {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--fg);
    overflow: hidden;
    background: linear-gradient(160deg, rgba(var(--ink), .16), rgba(var(--ink), .05));
    border: 1px solid rgba(var(--ink), .16);
    box-shadow: inset 0 1.5px 0 var(--hi), inset 0 -6px 12px rgba(var(--ink), .05), 0 8px 20px var(--shadow);
    transition: transform .45s var(--ease), background .35s, color .35s, box-shadow .35s
}

.sh-ico::after {
    content: "";
    position: absolute;
    left: 12%;
    right: 12%;
    top: 5%;
    height: 42%;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, .28), transparent);
    pointer-events: none
}

.sh-app:hover .sh-ico,
.sh-app:focus-visible .sh-ico {
    transform: translateY(-5px) scale(1.08);
    color: var(--c);
    background: linear-gradient(160deg, color-mix(in srgb, var(--c) 30%, transparent), color-mix(in srgb, var(--c) 8%, transparent));
    box-shadow: inset 0 1.5px 0 var(--hi), 0 14px 30px color-mix(in srgb, var(--c) 30%, transparent)
}

.sh-app:hover small {
    color: var(--fg)
}

.sh-app:active .sh-ico {
    transform: scale(.94)
}

.sh-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 6px 6px 18px;
    border-radius: 999px;
    background: rgba(var(--ink), .06);
    border: 1px solid var(--line);
    box-shadow: inset 0 1px 0 var(--hi)
}

.sh-link > span {
    font-size: 13px;
    color: var(--mut);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0
}

.sh-copy {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 11px 18px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 14px;
    background: var(--fg);
    color: var(--bg);
    transition: transform .3s var(--ease), background .3s
}

.sh-copy svg {
    width: 16px;
    height: 16px
}

.sh-copy em,
.sh-save em {
    font-style: normal
}

.sh-copy:hover {
    transform: scale(1.04)
}

.sh-copy.done {
    background: var(--hot);
    color: #121211
}

.sh-save {
    width: 100%;
    margin-top: 10px;
    padding: 15px 18px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    font-weight: 600;
    font-size: 14.5px;
    color: var(--fg);
    background: linear-gradient(160deg, rgba(var(--ink), .14), rgba(var(--ink), .05));
    border: 1px solid rgba(var(--ink), .16);
    box-shadow: inset 0 1.5px 0 var(--hi), 0 8px 20px var(--shadow);
    transition: transform .35s var(--ease), background .3s, color .3s
}

.sh-save svg {
    width: 18px;
    height: 18px
}

.sh-save:hover {
    transform: translateY(-2px)
}

.sh-save:active {
    transform: scale(.97)
}

.sh-save:disabled {
    opacity: .7;
    pointer-events: none
}

.sh-save.done {
    background: var(--hot);
    color: #121211;
    border-color: transparent
}

@media (max-width: 380px) {
    .sh-apps {
        grid-template-columns: repeat(3, 1fr)
    }
}

/* Spectator mode */
#spec {
    position: absolute;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 7px 7px 7px 20px;
    border-radius: 999px;
    max-width: calc(100vw - 24px);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 26px) scale(.96);
    transition: opacity .5s var(--ease), transform .6s var(--ease)
}

#spec.show {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0)
}

.sp-live {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap
}

.sp-live i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--hot);
    animation: spLive 1.4s ease-in-out infinite
}

@keyframes spLive {
    50% {
        opacity: .3;
        transform: scale(.65)
    }
}

.sp-msg {
    font-size: 13px;
    color: var(--mut);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    transition: color .4s
}

#spec.lead .sp-msg {
    color: var(--hot)
}

.sp-speed {
    display: flex;
    gap: 3px;
    padding: 3px;
    border-radius: 999px;
    background: rgba(var(--ink), .08)
}

.sp-speed button {
    min-width: 44px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    color: var(--mut);
    transition: background .3s, color .3s
}

.sp-speed button.on {
    background: var(--fg);
    color: var(--bg)
}

.arena.vs .panel {
    transition: width .7s var(--ease), opacity .6s, filter .6s
}

.arena.spectate .panel.you {
    opacity: .5;
    filter: saturate(.55)
}

.arena.spectate .panel {
    width: min(46vw, calc((100svh - 260px) * .774))
}

@media (max-width: 760px) {
    .arena.vs.spectate {
        justify-content: flex-start;
        padding-bottom: 96px
    }

    .arena.vs.spectate .panel.ai {
        width: min(86vw, calc(100svh - 440px))
    }

    .arena.vs.spectate .panel.ai .p-head .score {
        font-size: 34px
    }

    .arena.vs.spectate .panel.you {
        width: min(38vw, 20svh)
    }
}

@media (max-width: 560px) {
    #spec {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px 14px;
        padding: 12px 12px 8px;
        border-radius: 26px;
        width: calc(100vw - 24px)
    }

    .sp-msg {
        order: 3;
        width: 100%;
        text-align: center;
        font-size: 12.5px;
        margin-bottom: 2px
    }
}