/* Brain Games Arena: calm, premium, console-like. Deep night blue, soft aurora light, glass panels, one warm
   accent per category. Every size comes from the viewport so phone, tablet, desktop and TV share one layout. */
@font-face { font-family: 'Rubik'; src: url('../assets/fonts/Rubik-latin.woff2') format('woff2'); font-weight: 300 900; font-display: swap; }

:root {
  --bg: #0c1022; --bg2: #141838; --ink: #eef1ff; --muted: #9aa3c7; --faint: #5f678f;
  --glass: rgba(255, 255, 255, .055); --glass2: rgba(255, 255, 255, .09); --line: rgba(255, 255, 255, .1);
  --accent: #ffd64a; --violet: #a98bff; --teal: #3fd3c0; --coral: #ff7a8a; --amber: #ffc43d; --good: #3ed69a; --bad: #ff6b6b;
  --p0: #5b9dff; --p1: #ff6fae; --p2: #3ed69a; --p3: #ffc43d;
  --r: 18px; --r2: 26px;
  --ease: cubic-bezier(.2, .8, .2, 1); --spring: cubic-bezier(.34, 1.56, .64, 1);
  --u: clamp(14px, 1.05vw + .55vh, 22px);
  font-family: 'Rubik', system-ui, sans-serif; font-size: var(--u); color: var(--ink); background: var(--bg);
  -webkit-tap-highlight-color: transparent; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: radial-gradient(120vmax 90vmax at 15% -10%, #262b66 0%, var(--bg2) 45%, var(--bg) 75%); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
input { font: inherit; color: inherit; user-select: text; -webkit-user-select: text; }
h1, h2, h3, p { margin: 0; }
svg { display: block; width: 100%; height: 100%; }
.noscript { padding: 2rem; }

/* focus rings: only for keys and gamepads, big and clear (TV distance) */
:focus { outline: none; }
html:is([data-input="keys"], [data-input="pad"]) :focus-visible,
html:is([data-input="keys"], [data-input="pad"]) button:focus { outline: 3px solid var(--accent); outline-offset: 3px; box-shadow: 0 0 0 7px rgba(255, 214, 74, .18); }

/* ---------------------------------------------------------------- screens and transitions */
#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; overflow: auto; padding: max(1.1rem, env(safe-area-inset-top)) max(1.2rem, env(safe-area-inset-right)) max(3.2rem, env(safe-area-inset-bottom)) max(1.2rem, env(safe-area-inset-left));
  transition: opacity .32s var(--ease), transform .42s var(--ease), filter .32s; }
.screen.enter { opacity: 0; transform: translateX(4vw) scale(.985); filter: blur(4px); }
.screen.enter.from-left { transform: translateX(-4vw) scale(.985); }
.screen.leave { opacity: 0; transform: translateX(-4vw) scale(.985); pointer-events: none; }
.screen.leave.to-right { transform: translateX(4vw) scale(.985); }
html.calm .screen { transition: opacity .2s; transform: none !important; filter: none !important; }

.aurora { position: fixed; inset: -20%; pointer-events: none; z-index: -1; background:
  radial-gradient(40% 30% at 20% 20%, rgba(169, 139, 255, .22), transparent 70%),
  radial-gradient(35% 30% at 80% 30%, rgba(63, 211, 192, .16), transparent 70%),
  radial-gradient(40% 30% at 60% 85%, rgba(255, 122, 138, .12), transparent 70%);
  animation: drift 28s ease-in-out infinite alternate; }
.aurora.dim { opacity: .55; }
@keyframes drift { to { transform: translate3d(3%, -2%, 0) rotate(4deg) scale(1.05); } }
html.calm .aurora { animation: none; }

/* ---------------------------------------------------------------- shared pieces */
.page { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; min-height: 100%; }
.bar { display: flex; align-items: center; gap: .9rem; }
.bar h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.01em; flex: 1; }
.spacer { flex: 1; }
.back-btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem .5rem .6rem; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); color: var(--muted); transition: background .2s, color .2s; }
.back-btn svg { width: 1.1rem; height: 1.1rem; }
.back-btn:hover, .back-btn:focus { background: var(--glass2); color: var(--ink); }
.panel { background: linear-gradient(180deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .035)); border: 1px solid var(--line); border-radius: var(--r2); padding: 1.1rem 1.2rem; box-shadow: 0 20px 50px -30px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .06); backdrop-filter: blur(14px); }
.panel h2 { font-size: 1.05rem; color: var(--muted); font-weight: 600; margin-bottom: .7rem; letter-spacing: .02em; text-transform: uppercase; }
.lead { color: var(--muted); max-width: 52ch; }
.note, .status { color: var(--muted); font-size: .9rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.actions { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; margin-top: .4rem; }
.actions.col { flex-direction: column; align-items: stretch; }
.i { display: inline-block; width: 1.1em; height: 1.1em; vertical-align: -.15em; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .72rem 1.3rem; border-radius: 14px; background: var(--glass2); border: 1px solid var(--line); font-weight: 600; transition: transform .18s var(--spring), background .2s, box-shadow .2s; }
.btn:hover { background: rgba(255, 255, 255, .14); }
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(180deg, #ffe07a, #ffc43d); color: #241a00; border-color: transparent; box-shadow: 0 10px 30px -12px rgba(255, 196, 61, .7), inset 0 1px 0 #fff8; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: rgba(255, 107, 107, .2); border-color: rgba(255, 107, 107, .4); }
.btn.big { font-size: 1.2rem; padding: .95rem 2.6rem; border-radius: 18px; }
.btn:disabled { opacity: .45; cursor: default; }
.chip { display: inline-flex; align-items: center; gap: .45rem; padding: .48rem .9rem; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); font-weight: 500; font-size: .92rem; transition: background .2s, border-color .2s, transform .18s var(--spring); }
.chip:hover { background: var(--glass2); }
.chip.on { background: rgba(255, 214, 74, .16); border-color: rgba(255, 214, 74, .55); color: #fff3c4; }
.chip.small { padding: .2rem .55rem; }
.chip:disabled { opacity: .55; cursor: default; }
.chip .av, .player-chip .av { width: 1.6rem; height: 1.6rem; }
.text { background: rgba(0, 0, 0, .25); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; outline: none; min-width: 0; }
.text:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255, 214, 74, .15); }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .65rem; border-radius: 999px; background: var(--glass2); font-size: .8rem; font-weight: 600; color: var(--muted); }
.badge svg { width: 1em; height: 1em; }

/* ---------------------------------------------------------------- title */
.title-screen { display: grid; grid-template-rows: auto 1fr auto; gap: 1.2rem; max-width: 1280px; margin: 0 auto; min-height: 100%; }
.brand { display: flex; align-items: center; gap: 1rem; padding-top: 1vh; }
.brand .logo { width: clamp(3.6rem, 9vmin, 6rem); height: clamp(3.6rem, 9vmin, 6rem); filter: drop-shadow(0 10px 24px rgba(169, 139, 255, .45)); animation: float 6s ease-in-out infinite; }
.brand h1 { font-size: clamp(1.9rem, 2.4rem + 1vw, 3.4rem); font-weight: 900; letter-spacing: -.025em; background: linear-gradient(90deg, #fff, #d8ccff 50%, #a5f3e8); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1.05; }
.tagline { color: var(--muted); margin-top: .2rem; }
@keyframes float { 50% { transform: translateY(-6px) rotate(-2deg); } }
html.calm .brand .logo { animation: none; }
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-content: center; max-width: 900px; width: 100%; }
.tile { position: relative; display: flex; align-items: center; gap: 1rem; text-align: left; padding: 1.3rem 1.4rem; min-height: 7.2rem; border-radius: var(--r2); border: 1px solid var(--line); overflow: hidden;
  background: linear-gradient(135deg, color-mix(in srgb, var(--tc) 28%, transparent), rgba(255, 255, 255, .03) 60%); box-shadow: 0 24px 50px -32px var(--tc), inset 0 1px 0 rgba(255, 255, 255, .08);
  transition: transform .28s var(--spring), box-shadow .28s, border-color .28s; }
.tile::after { content: ''; position: absolute; inset: 0; background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, .12) 50%, transparent 70%); transform: translateX(-100%); transition: transform .7s var(--ease); }
.tile:hover, .tile:focus { transform: translateY(-3px) scale(1.015); border-color: color-mix(in srgb, var(--tc) 70%, white); box-shadow: 0 30px 60px -28px var(--tc); }
.tile:hover::after, .tile:focus::after { transform: translateX(100%); }
.tile-icon { flex: none; width: 3.6rem; height: 3.6rem; padding: .7rem; border-radius: 18px; background: color-mix(in srgb, var(--tc) 60%, #000 10%); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25); }
.tile-text { display: flex; flex-direction: column; gap: .25rem; }
.tile strong { font-size: 1.45rem; font-weight: 800; }
.tile small { color: var(--muted); font-size: .9rem; }
.t-solo { --tc: #5b9dff; } .t-party { --tc: #ff6fae; } .t-online { --tc: #3fd3c0; } .t-training { --tc: #ffc43d; }
.menu-foot { display: flex; gap: .7rem; flex-wrap: wrap; }
.pip-corner { position: fixed; right: max(1.2rem, 2vw); bottom: max(2.8rem, 6vh); display: flex; align-items: flex-end; gap: .4rem; pointer-events: none; }
.pip-wrap { width: clamp(5rem, 13vmin, 9rem); height: clamp(5rem, 13vmin, 9rem); animation: bob 3.4s ease-in-out infinite; filter: drop-shadow(0 0 30px rgba(255, 214, 74, .35)); }
.pip-wrap.small { width: 3.6rem; height: 3.6rem; flex: none; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(3deg); } }
html.calm .pip-wrap { animation: none; }
.bubble { position: relative; background: #fff; color: #1b1d2e; font-weight: 600; font-size: .92rem; padding: .6rem .9rem; border-radius: 16px 16px 16px 4px; max-width: 16rem; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .5); animation: pop .5s var(--spring) both .3s; }
.pip-corner .bubble { order: -1; border-radius: 16px 16px 4px 16px; margin-bottom: 4.5rem; }
@keyframes pop { from { opacity: 0; transform: scale(.6) translateY(10px); } }

/* ---------------------------------------------------------------- settings, setup */
.form { display: flex; flex-direction: column; gap: 1rem; max-width: 720px; }
.field { display: flex; flex-direction: column; gap: .45rem; }
.field > label { color: var(--muted); font-size: .85rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.seg { display: inline-flex; flex-wrap: wrap; gap: .3rem; padding: .3rem; background: rgba(0, 0, 0, .25); border-radius: 14px; border: 1px solid var(--line); align-self: flex-start; }
.seg-btn { padding: .5rem .95rem; border-radius: 10px; color: var(--muted); font-weight: 600; transition: background .2s, color .2s; }
.seg-btn.on { background: var(--glass2); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(255, 214, 74, .5); }
.seg-btn:disabled { cursor: default; }
.settings-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1.1rem 1.6rem; }
.settings-panel .wide { grid-column: 1 / -1; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chips.games { margin-top: .2rem; }
.chip.game { --gc: #fff; padding-left: .4rem; }
.chip.game .gi { width: 1.7rem; height: 1.7rem; padding: .28rem; border-radius: 9px; background: var(--gc); color: var(--gc); }
.chip.game.on { background: color-mix(in srgb, var(--gc) 22%, transparent); border-color: color-mix(in srgb, var(--gc) 70%, transparent); color: #fff; }
.chip.cat { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.c-memory { --cc: var(--violet); } .c-maths { --cc: var(--amber); } .c-perception { --cc: var(--teal); } .c-logic { --cc: var(--coral); }
.chip.cat.on { background: color-mix(in srgb, var(--cc) 20%, transparent); border-color: var(--cc); color: #fff; }
.stepper { display: inline-flex; align-items: center; gap: .3rem; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); border-radius: 14px; padding: .3rem; align-self: flex-start; }
.stepper output { min-width: 2.4rem; text-align: center; font-size: 1.2rem; font-weight: 700; }
.step { width: 2.4rem; height: 2.4rem; border-radius: 10px; background: var(--glass2); font-size: 1.3rem; font-weight: 700; }
.step:disabled { opacity: .3; }
.estimate { grid-column: 1 / -1; color: var(--muted); font-size: .9rem; }
.name-form { display: flex; flex-direction: column; gap: 1rem; min-width: min(26rem, 80vw); }
.name-row { display: flex; align-items: center; gap: .5rem; }
.name-row .text { flex: 1; font-size: 1.2rem; }
.tag { color: var(--muted); font-weight: 700; }

/* ---------------------------------------------------------------- training */
.train-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(17rem, 100%), 1fr)); gap: 1rem; }
.game-card { --gc: #fff; position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; text-align: left; padding: 1.2rem; border-radius: var(--r2); border: 1px solid var(--line); background: linear-gradient(160deg, color-mix(in srgb, var(--gc) 24%, transparent), rgba(255, 255, 255, .03) 65%); transition: transform .28s var(--spring), border-color .2s; min-height: 11rem; }
.game-card:hover, .game-card:focus { transform: translateY(-3px); border-color: var(--gc); }
.gc-icon { width: 3.2rem; height: 3.2rem; padding: .6rem; border-radius: 16px; background: var(--gc); color: var(--gc); margin-bottom: .3rem; box-shadow: 0 10px 24px -10px var(--gc); }
.game-card strong { font-size: 1.25rem; }
.game-card small { color: var(--muted); font-size: .88rem; }
.gc-cat { position: absolute; top: 1rem; right: 1rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.best { margin-top: auto; font-size: .85rem; color: var(--accent); font-weight: 600; }

/* ---------------------------------------------------------------- party */
.seats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); gap: 1rem; }
.seat { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .45rem; min-height: 12rem; border-radius: var(--r2); border: 2px dashed var(--line); padding: 1rem; position: relative; }
.seat.empty { color: var(--muted); transition: border-color .2s, background .2s; }
.seat.empty:hover, .seat.empty:focus { border-color: var(--accent); background: var(--glass); }
.seat .plus { font-size: 2.6rem; font-weight: 300; line-height: 1; }
.seat.on { border: 2px solid var(--pc); background: color-mix(in srgb, var(--pc) 14%, transparent); animation: pop .45s var(--spring); }
.seat .av { width: 4.4rem; height: 4.4rem; }
.seat strong { font-size: 1.2rem; }
.seat small { color: var(--muted); display: inline-flex; align-items: center; gap: .35rem; }
.seat .chip.small { position: absolute; top: .6rem; right: .6rem; }

/* ---------------------------------------------------------------- online */
.online-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr)); gap: 1rem; align-items: stretch; }
.online-grid .tile { min-height: 12rem; }
.join { display: flex; flex-direction: column; gap: .6rem; }
.join label { color: var(--muted); font-size: .85rem; }
.code-input { font-size: 1.6rem; letter-spacing: .2em; text-transform: uppercase; text-align: center; font-weight: 700; }
.page.busy { cursor: progress; }
.lobby-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 1rem; align-items: start; }
.lobby-grid .col { display: flex; flex-direction: column; gap: 1rem; }
.big-code { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 900; letter-spacing: .18em; margin: .2rem 0 .7rem; background: linear-gradient(90deg, #fff, #a5f3e8); -webkit-background-clip: text; background-clip: text; color: transparent; user-select: text; }
.invite label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.code-chip { font-weight: 800; letter-spacing: .12em; }
.members { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.members li { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border-radius: 14px; background: rgba(0, 0, 0, .18); border-left: 4px solid var(--pc, var(--faint)); animation: pop .35s var(--spring); }
.members li.me { background: rgba(255, 255, 255, .07); }
.members li.away { opacity: .5; }
.members li.cpu { opacity: .75; border-left-style: dashed; }
.members .av { width: 2.1rem; height: 2.1rem; flex: none; }
.members .nm { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.members small { color: var(--muted); }
.ready-dot { width: 1.6rem; height: 1.6rem; padding: .25rem; border-radius: 50%; background: var(--glass); opacity: .35; }
.ready-dot.on { background: var(--good); opacity: 1; }
.badge.host { color: #fff3c4; background: rgba(255, 214, 74, .15); }
.chat { display: flex; flex-direction: column; gap: .5rem; }
.chat-list { list-style: none; margin: 0; padding: 0; max-height: 10rem; min-height: 4rem; overflow: auto; font-size: .9rem; display: flex; flex-direction: column; gap: .25rem; user-select: text; }
.chat-list strong { color: var(--muted); }
.chat .row .text { flex: 1; }
.ready-btn.on { background: linear-gradient(180deg, #6ff0b8, #3ed69a); color: #00271a; }

/* ---------------------------------------------------------------- modal, toasts, hints */
.modal-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(6, 8, 20, .55); backdrop-filter: blur(8px); opacity: 0; transition: opacity .25s; padding: 1rem; }
.modal-wrap.open { opacity: 1; }
.modal { background: linear-gradient(180deg, #232859, #181c40); border: 1px solid var(--line); border-radius: var(--r2); padding: 1.5rem; box-shadow: 0 40px 80px -30px #000; transform: scale(.92) translateY(10px); transition: transform .35s var(--spring); max-width: 92vw; }
.modal-wrap.open .modal { transform: none; }
.modal h2 { font-size: 1.4rem; margin-bottom: 1rem; text-align: center; }
.pause { min-width: min(20rem, 80vw); }
#toasts { position: fixed; left: 50%; bottom: 3.4rem; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 60; pointer-events: none; }
.toast { background: rgba(20, 24, 56, .95); border: 1px solid var(--line); padding: .7rem 1.1rem; border-radius: 14px; box-shadow: 0 20px 40px -20px #000; animation: pop .35s var(--spring); max-width: 90vw; word-break: break-all; }
.toast.out { opacity: 0; transition: opacity .4s; }
.hints { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 1.4rem; padding: .55rem 1rem calc(.55rem + env(safe-area-inset-bottom)); font-size: .82rem; color: var(--muted); background: linear-gradient(0deg, rgba(8, 10, 24, .85), transparent); z-index: 40; pointer-events: none; transition: opacity .3s; }
.hints.hidden { opacity: 0; }
.hint { display: inline-flex; align-items: center; gap: .4rem; }
.hint .k { min-width: 1.6rem; padding: .1rem .45rem; border-radius: 7px; background: var(--glass2); border: 1px solid var(--line); color: var(--ink); font-weight: 700; font-size: .78rem; text-align: center; }
.hint .k.pad { border-radius: 999px; }
.update-bar { position: fixed; top: max(.8rem, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 70; display: flex; gap: .8rem; align-items: center; background: #232859; border: 1px solid rgba(255, 214, 74, .5); padding: .5rem .6rem .5rem 1rem; border-radius: 999px; box-shadow: 0 20px 40px -20px #000; animation: pop .4s var(--spring); }
.update-bar .btn { padding: .4rem .9rem; }

/* ---------------------------------------------------------------- match */
.match-screen { display: flex; flex-direction: column; gap: .7rem; padding-bottom: max(1rem, env(safe-area-inset-bottom)); overflow: hidden; }
.match-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .8rem; }
.top-left { display: flex; flex-direction: column; }
.game-label { --gc: var(--accent); font-weight: 800; font-size: 1.2rem; color: color-mix(in srgb, var(--gc) 70%, white); }
.round-label { color: var(--muted); font-size: .85rem; }
.top-right { display: flex; justify-content: flex-end; gap: .5rem; align-items: center; }
.icon-only { padding: .5rem .75rem; font-size: .8rem; letter-spacing: -.1em; }
.timer { position: relative; width: 3.6rem; height: 3.6rem; }
.timer svg { transform: rotate(-90deg); }
.timer .track { fill: rgba(0, 0, 0, .3); stroke: var(--line); stroke-width: 4; }
.timer .ring { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 100; transition: stroke-dashoffset .25s linear, stroke .3s; }
.timer-text { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.timer.hurry .ring { stroke: var(--bad); }
.timer.hurry .timer-text { color: var(--bad); animation: beat .5s ease-in-out infinite; }
@keyframes beat { 50% { transform: scale(1.12); } }
.emotes { display: flex; gap: .25rem; }
.emote-btn { width: 2.1rem; height: 2.1rem; padding: .3rem; border-radius: 10px; background: var(--glass); transition: transform .2s var(--spring), background .2s; }
.emote-btn:hover, .emote-btn:focus { background: var(--glass2); transform: scale(1.1); }
.match-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .9rem; }
.stage { min-height: 0; display: grid; gap: .8rem; }
.stage.n2 { grid-template-columns: 1fr 1fr; }
.stage.n3, .stage.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.pboard { --pc: #fff; position: relative; min-height: 0; display: flex; flex-direction: column; border-radius: var(--r2); background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .025)); border: 1px solid var(--line); box-shadow: inset 0 3px 0 var(--pc); padding: .7rem; overflow: hidden; }
.pboard.flip { transform: rotate(180deg); }
.pboard.done::after { content: '✓'; position: absolute; top: .6rem; right: .8rem; width: 2rem; height: 2rem; border-radius: 50%; background: var(--good); color: #002a1a; display: grid; place-items: center; font-weight: 900; animation: pop .4s var(--spring); }
.panel-head { display: flex; align-items: center; gap: .55rem; padding: 0 .2rem .5rem; }
.panel-head .av { width: 2rem; height: 2rem; }
.panel-head .pname { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pscore { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.prank { color: var(--muted); font-weight: 700; min-width: 2rem; text-align: right; }
.board-host { flex: 1; min-height: 0; position: relative; display: flex; }
.rail { width: clamp(12rem, 22vw, 17rem); display: flex; flex-direction: column; gap: .5rem; overflow: auto; }
.rail.empty { display: none; }
.opp { --pc: #fff; position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .55rem; padding: .55rem .65rem; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); border-left: 4px solid var(--pc); transition: opacity .3s, transform .3s var(--spring); }
.opp .av { width: 2.2rem; height: 2.2rem; }
.opp-main { min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.opp-main strong { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp .bar { height: .4rem; border-radius: 99px; background: rgba(0, 0, 0, .35); overflow: hidden; }
.opp .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--pc), color-mix(in srgb, var(--pc) 60%, white)); border-radius: 99px; transition: width .5s var(--ease); }
.opp .detail { color: var(--muted); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opp-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.opp.done { border-color: color-mix(in srgb, var(--good) 60%, transparent); }
.opp.done .opp-score::after { content: ' ✓'; color: var(--good); }
.opp.gone { opacity: .4; }
.opp.ping { animation: ping .6s var(--spring); }
@keyframes ping { 40% { transform: scale(1.06); box-shadow: 0 0 0 6px color-mix(in srgb, var(--pc) 30%, transparent); } }
.opp-fx { position: absolute; right: -.4rem; top: -.6rem; }
.emote-pop { display: block; width: 2.2rem; height: 2.2rem; animation: emote 1.8s var(--ease) forwards; }
@keyframes emote { 0% { opacity: 0; transform: scale(.3); } 15% { opacity: 1; transform: scale(1.2); } 80% { opacity: 1; transform: translateY(-10px); } 100% { opacity: 0; transform: translateY(-24px); } }
.conn-banner { position: fixed; top: 4.5rem; left: 50%; transform: translate(-50%, -20px); background: rgba(255, 196, 61, .15); border: 1px solid rgba(255, 196, 61, .5); padding: .45rem 1rem; border-radius: 999px; opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; z-index: 20; }
.conn-banner.show { opacity: 1; transform: translate(-50%, 0); }

/* overlays: intro, results, ceremony */
.overlay { position: absolute; inset: 0; z-index: 10; display: none; place-items: center; padding: 1rem; background: rgba(8, 10, 26, .5); backdrop-filter: blur(10px); }
.overlay.show { display: grid; animation: fade .35s var(--ease); }
@keyframes fade { from { opacity: 0; } }
.intro-card, .result-card, .final-card { --gc: var(--accent); position: relative; width: min(34rem, 94vw); max-height: 92vh; overflow: auto; text-align: center; padding: 1.8rem 1.6rem 1.4rem; border-radius: 30px; background: linear-gradient(180deg, #252a5e, #171b3f); border: 1px solid var(--line); box-shadow: 0 50px 100px -40px #000, inset 0 1px 0 rgba(255, 255, 255, .1); animation: card .55s var(--spring); }
@keyframes card { from { opacity: 0; transform: translateY(30px) scale(.9); } }
.intro-icon { width: 5.2rem; height: 5.2rem; margin: -.2rem auto .8rem; padding: 1rem; border-radius: 26px; background: var(--gc); color: var(--gc); box-shadow: 0 18px 40px -14px var(--gc); animation: spin-in .7s var(--spring); }
@keyframes spin-in { from { transform: rotate(-25deg) scale(.4); opacity: 0; } }
.intro-round { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.intro-card h2 { font-size: 2.3rem; font-weight: 900; margin: .2rem 0 .4rem; }
.intro-rule { color: #d5daf5; margin-bottom: .7rem; }
.count { font-size: 4.2rem; font-weight: 900; line-height: 1.2; margin: .6rem 0 .2rem; color: var(--accent); text-shadow: 0 0 40px rgba(255, 214, 74, .5); min-height: 5rem; }
.count.pulse { animation: count .9s var(--spring); }
@keyframes count { from { transform: scale(1.8); opacity: 0; } }
.intro-pip { display: flex; align-items: center; justify-content: center; gap: .6rem; margin-top: .8rem; }
.intro-pip .bubble { font-size: .85rem; border-radius: 16px 16px 16px 4px; animation-delay: .5s; }
.result-card h2, .final-card h2 { font-size: 1.7rem; font-weight: 900; margin-bottom: .8rem; }
.best-line { color: var(--accent); font-weight: 700; margin: -.3rem 0 .8rem; }
.result-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; text-align: left; }
.result-list li { display: grid; grid-template-columns: 1.8rem 2.2rem 1fr auto auto; align-items: center; gap: .6rem; padding: .5rem .7rem; border-radius: 14px; background: rgba(0, 0, 0, .2); border-left: 4px solid var(--pc); animation: slide-in .5s var(--spring) both; animation-delay: var(--d); }
.result-list li.me { background: rgba(255, 255, 255, .08); }
@keyframes slide-in { from { opacity: 0; transform: translateX(-30px); } }
.result-list .rk { font-weight: 900; color: var(--muted); }
.result-list .av { width: 2.2rem; height: 2.2rem; }
.result-list .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-list .raw { font-variant-numeric: tabular-nums; color: var(--muted); }
.result-list .pts { font-weight: 900; color: var(--accent); }
.standings { margin-top: 1rem; text-align: left; display: flex; flex-direction: column; gap: .35rem; }
.standings h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.st-row { display: grid; grid-template-columns: 7rem 1fr 2.5rem; align-items: center; gap: .5rem; font-size: .9rem; }
.st-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-bar { height: .7rem; border-radius: 99px; background: rgba(0, 0, 0, .3); overflow: hidden; }
.st-bar i { display: block; height: 100%; background: var(--pc); border-radius: 99px; transition: width 1s var(--ease) .4s; }
.st-row .tot { font-weight: 800; text-align: right; }
.final-card { width: min(40rem, 96vw); }
.final-kicker { color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-size: .85rem; font-weight: 700; }
.winner { font-size: 2.6rem !important; background: linear-gradient(90deg, #ffe07a, #fff, #ffe07a); -webkit-background-clip: text; background-clip: text; color: transparent; animation: card .7s var(--spring) .3s both; }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: .6rem; margin: .6rem 0 1rem; }
.place { --pc: #fff; display: flex; flex-direction: column; align-items: center; gap: .25rem; animation: rise .9s var(--spring) both; }
.place.p1 { animation-delay: 1.1s; } .place.p2 { animation-delay: .6s; } .place.p3 { animation-delay: .2s; }
@keyframes rise { from { opacity: 0; transform: translateY(60px); } }
.place .av.big { width: 4.2rem; height: 4.2rem; filter: drop-shadow(0 10px 20px rgba(0, 0, 0, .4)); }
.place.p1 .av.big { width: 5.4rem; height: 5.4rem; }
.place .crown { width: 2.4rem; height: 2.4rem; margin-bottom: -.6rem; animation: bob 2s ease-in-out infinite; }
.place strong { font-size: .95rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place .tot { color: var(--muted); font-size: .8rem; }
.place .block { width: 100%; border-radius: 14px 14px 6px 6px; background: linear-gradient(180deg, color-mix(in srgb, var(--pc) 60%, transparent), color-mix(in srgb, var(--pc) 15%, transparent)); display: grid; place-items: center; font-size: 1.8rem; font-weight: 900; color: #fff; }
.place.p1 .block { height: 6.4rem; } .place.p2 .block { height: 4.6rem; } .place.p3 .block { height: 3.4rem; }
.rest { list-style: none; padding: 0; margin: 0 0 .8rem; display: flex; flex-direction: column; gap: .3rem; }
.rest li { display: grid; grid-template-columns: 2rem 1fr auto; gap: .5rem; padding: .35rem .7rem; border-radius: 12px; background: rgba(0, 0, 0, .2); text-align: left; }
.awards { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .5rem; margin-bottom: .6rem; }
.award { --pc: #fff; padding: .55rem .7rem; border-radius: 14px; background: color-mix(in srgb, var(--pc) 14%, transparent); border: 1px solid color-mix(in srgb, var(--pc) 45%, transparent); display: flex; flex-direction: column; animation: pop .5s var(--spring) both 1.8s; }
.award small { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ---------------------------------------------------------------- boards */
.board { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; container-type: size; }
.board.appear { animation: card .5s var(--spring); }
.board .grid { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: clamp(4px, 1.4cqmin, 12px); width: min(100cqw, calc(100cqh * var(--cols) / var(--rows, var(--cols)))); max-width: 100%; }
.float { position: absolute; left: 50%; top: 40%; transform: translate(-50%, 0); font-weight: 900; font-size: 1.6rem; pointer-events: none; animation: rise-fade 1.1s var(--ease) forwards; z-index: 3; text-shadow: 0 4px 16px rgba(0, 0, 0, .5); }
.float.good { color: var(--good); } .float.bad { color: var(--bad); }
@keyframes rise-fade { from { opacity: 0; transform: translate(-50%, 20px) scale(.8); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } to { opacity: 0; transform: translate(-50%, -50px); } }
.cur { outline: 3px solid var(--pc, var(--accent)) !important; outline-offset: 2px; z-index: 2; }
html[data-input="pointer"] .stage.n1 .cur, html[data-input="touch"] .stage.n1 .cur { outline: none !important; }

/* memory */
.memory .grid { perspective: 900px; width: min(100cqw, calc(96cqh * var(--cols) * .75 / var(--rows))); }
.card { aspect-ratio: 3 / 4; position: relative; border-radius: clamp(8px, 2cqmin, 16px); }
.card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .45s var(--spring); border-radius: inherit; }
.card.up .card-inner { transform: rotateY(180deg); }
.card-back, .card-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: inherit; }
.card-back { background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .18), transparent 40%), repeating-linear-gradient(45deg, #4a3fa8 0 8px, #3f3594 8px 16px); border: 2px solid rgba(255, 255, 255, .15); box-shadow: 0 8px 18px -8px rgba(0, 0, 0, .6); }
.card-back::after { content: ''; position: absolute; inset: 26%; border-radius: 50%; background: radial-gradient(circle, #ffd64a 0 30%, transparent 32%), rgba(255, 255, 255, .08); }
.card-face { transform: rotateY(180deg); background: linear-gradient(180deg, #fbfbff, #e4e7f6); padding: 14%; box-shadow: 0 8px 18px -8px rgba(0, 0, 0, .6); }
.card:hover .card-back { filter: brightness(1.15); }
.card.wait .card-face::after { content: ''; position: absolute; inset: 35%; border-radius: 50%; border: 3px solid #c9cde0; border-top-color: #6f62d8; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.card.matched .card-face { box-shadow: 0 0 0 3px var(--good), 0 0 24px rgba(62, 214, 154, .45); }
.card.matched .card-inner { animation: matched .6s var(--spring); }
@keyframes matched { 50% { transform: rotateY(180deg) scale(1.08); } }
.card.miss .card-inner { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: rotateY(180deg) translateX(-5px); } 40%, 80% { transform: rotateY(180deg) translateX(5px); } }

/* quiz boards */
.quiz-body { display: flex; flex-direction: column; align-items: center; gap: clamp(.6rem, 3cqh, 1.6rem); width: 100%; height: 100%; justify-content: center; }
.quiz-body.enter { animation: card .4s var(--spring); }
.task { display: flex; align-items: baseline; gap: .6rem; font-weight: 900; font-size: clamp(1.8rem, 11cqmin, 5rem); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.task .eq { color: var(--muted); }
.options { display: grid; gap: clamp(.4rem, 2cqmin, 1rem); width: min(100%, 32rem); }
.options.two { grid-template-columns: 1fr 1fr; }
.option { position: relative; padding: clamp(.6rem, 3.5cqh, 1.2rem) .8rem; border-radius: 18px; background: var(--glass2); border: 1px solid var(--line); font-size: clamp(1.1rem, 6cqmin, 2rem); font-weight: 800; transition: transform .15s var(--spring), background .2s; }
.option:hover { background: rgba(255, 255, 255, .15); }
.option:active { transform: scale(.96); }
.option .key { position: absolute; left: .55rem; top: .45rem; font-size: .7rem; color: var(--faint); font-weight: 700; }
html[data-input="touch"] .option .key { display: none; }
.option.right, .cell.right { background: rgba(62, 214, 154, .35); border-color: var(--good); animation: pop .3s var(--spring); }
.option.wrong, .cell.wrong { background: rgba(255, 107, 107, .3); border-color: var(--bad); animation: wiggle .4s; }
.option.was, .cell.was { box-shadow: 0 0 0 3px var(--good); }
@keyframes wiggle { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.lockbar { position: absolute; left: 10%; right: 10%; bottom: 0; height: 4px; border-radius: 99px; background: var(--bad); transform: scaleX(0); transform-origin: left; opacity: 0; }
.lockbar.run { animation: lock 1.2s linear; }
@keyframes lock { from { transform: scaleX(1); opacity: 1; } to { transform: scaleX(0); opacity: 1; } }
.oddone .grid { width: min(100cqw, 90cqh); }
.cell { aspect-ratio: 1; border-radius: clamp(6px, 1.6cqmin, 14px); background: rgba(255, 255, 255, .07); border: 1px solid var(--line); padding: 16%; transition: background .2s, transform .15s var(--spring); }
.cell:hover { background: rgba(255, 255, 255, .13); }
.cell:active { transform: scale(.94); }
.cell .sym { display: block; width: 100%; height: 100%; }
.frame { position: relative; width: min(70cqw, 52cqh); aspect-ratio: 1; border-radius: 26px; overflow: hidden; background: radial-gradient(circle at 50% 40%, #2b3170, #161a3d); border: 1px solid var(--line); box-shadow: inset 0 0 40px rgba(0, 0, 0, .5); }
.pic { position: absolute; inset: 10%; }
.revealbar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: linear-gradient(90deg, var(--teal), var(--accent)); transform-origin: left; }

/* flashback */
.flash-info { display: flex; gap: 1rem; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.flash-info .phase { color: var(--ink); min-width: 9rem; text-align: center; }
.lives { display: inline-flex; gap: .3rem; }
.life { width: .8rem; height: .8rem; border-radius: 50%; background: rgba(255, 255, 255, .15); }
.life.on { background: var(--coral); box-shadow: 0 0 10px var(--coral); }
.flash .grid { width: min(100cqw, 82cqh); }
.flash .cell { padding: 0; }
.flash .cell.lit { background: radial-gradient(circle, #fff7c2, var(--accent)); box-shadow: 0 0 24px rgba(255, 214, 74, .7); transform: scale(1.04); }
.flash .cell.picked { background: color-mix(in srgb, var(--pc) 55%, transparent); border-color: var(--pc); }
.flash .cell.good { background: rgba(62, 214, 154, .55); }
.flash .cell.true { box-shadow: inset 0 0 0 3px var(--good); }
.flash .cell.bad { background: rgba(255, 107, 107, .55); }

/* slide */
.tiles { position: relative; width: min(100cqw, 92cqh); aspect-ratio: 1; }
.stile { position: absolute; width: calc(100% / var(--cols)); height: calc(100% / var(--cols)); left: 0; top: 0; padding: clamp(3px, .9cqmin, 7px); transform: translate(calc(var(--x) * 100%), calc(var(--y) * 100%)); transition: transform .16s var(--ease); }
.stile span { display: grid; place-items: center; width: 100%; height: 100%; border-radius: clamp(8px, 2cqmin, 16px); background: linear-gradient(180deg, #ff98a5, #ff6f82); font-weight: 900; font-size: clamp(1.2rem, 9cqmin, 3.2rem); color: #fff; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .18), 0 8px 16px -10px #000; text-shadow: 0 2px 0 rgba(0, 0, 0, .15); transition: background .3s; }
.stile:hover span { filter: brightness(1.08); }
.stile.home span { background: linear-gradient(180deg, #8ef0c8, #3ed69a); }
.stile.nudge span { animation: wiggle .2s; }
.slide.solved .stile span { animation: pop .5s var(--spring); }
/* ---------------------------------------------------------------- responsive */
@media (max-width: 700px), (orientation: portrait) {
  .match-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .rail { order: -1; width: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; padding-bottom: .2rem; }
  .opp { min-width: 9.5rem; grid-template-columns: auto 1fr; }
  .opp-score { position: absolute; right: .6rem; top: .4rem; font-size: .85rem; }
  .lobby-grid { grid-template-columns: 1fr; }
}
@media (orientation: portrait) {
  .stage.n2 { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}
@media (max-width: 640px) {
  .menu-grid { grid-template-columns: 1fr; gap: .7rem; }
  .tile { min-height: 5.6rem; padding: 1rem; }
  .tile-icon { width: 3rem; height: 3rem; padding: .55rem; }
  .tile strong { font-size: 1.2rem; }
  .pip-corner { display: none; }
  .match-top { grid-template-columns: 1fr auto auto; }
  .emotes { display: none; }
  .intro-card h2 { font-size: 1.8rem; }
  .bar h1 { font-size: 1.25rem; }
  .podium { gap: .3rem; }
}
@media (max-height: 520px) {
  .match-screen { gap: .3rem; padding-top: .4rem; }
  .match-top { gap: .4rem; }
  .timer { width: 2.6rem; height: 2.6rem; }
  .timer-text { font-size: .9rem; }
  .game-label { font-size: 1rem; }
  .pboard { padding: .4rem; }
  .panel-head { padding-bottom: .2rem; }
  .panel-head .av { width: 1.5rem; height: 1.5rem; }
  .rail { width: 11rem; }
  .opp { padding: .35rem .5rem; }
  .opp .av { width: 1.7rem; height: 1.7rem; }
  .intro-card, .result-card, .final-card { padding: 1rem; }
  .intro-icon { width: 3.4rem; height: 3.4rem; padding: .6rem; }
  .count { font-size: 2.6rem; min-height: 3rem; margin: .2rem 0; }
  .intro-pip { display: none; }
  .hints { display: none; }
}
@media (min-width: 1800px) { :root { --u: clamp(18px, .95vw + .5vh, 30px); } }
html.calm *, html.calm *::before, html.calm *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .05s !important; }
