:root {
  color-scheme: dark;
  --bg: #101017;
  --surface: #191924;
  --raised: #22222f;
  --line: #333344;
  --text: #f9f6fa;
  --muted: #afadc1;
  --accent: #ffad8e;
  --green: #a9ebc8;
  --ink: #1b1721;
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
h1, h2, p, ul { margin: 0; }
h1, h2 { line-height: 1.04; overflow-wrap: anywhere; }
h1 { font-size: clamp(2.2rem, 5vw, 4.8rem); letter-spacing: -.065em; }
h1 span { color: var(--accent); }
h2 { font-size: 1.3rem; letter-spacing: -.035em; }
input:not([type="checkbox"]), textarea {
  width: 100%; min-width: 0; color: var(--text); background: #13131e;
  border: 1px solid var(--line); border-radius: 10px; padding: .8rem .9rem;
}
input::placeholder, textarea::placeholder { color: #9593a8; }
textarea { resize: vertical; }
label, legend { font-size: .9rem; font-weight: 700; }
label small { color: var(--muted); font-size: .85rem; font-weight: 400; }
fieldset { border: 0; margin: 1.45rem 0; padding: 0; min-inline-size: 0; }
legend { padding: 0; }
fieldset p { color: var(--muted); margin: .35rem 0 .75rem; font-size: .9rem; }

.topbar { border-bottom: 1px solid #2d2b3a; background: #101017; }
.topbar-inner {
  min-height: 68px; margin: auto; width: min(100% - 2.5rem, 1220px);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.wordmark { flex: 0 0 auto; text-decoration: none; display: flex; align-items: center; color: var(--text); font-size: 1.6rem; font-weight: 800; letter-spacing: -.085em; line-height: 1; }
.brand-mark { display: grid; place-items: center; width: 33px; height: 33px; margin-right: .52rem; border-radius: 9px; background: var(--accent); color: var(--ink); font-size: 1.35rem; letter-spacing: 0; }
.brand-dot { color: var(--accent); }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em; border: 1px solid transparent;
  min-height: 44px; padding: .62rem 1rem; border-radius: 10px; text-decoration: none;
  font-size: .92rem; font-weight: 750; line-height: 1.2; text-align: center;
  transition: background .16s ease, transform .16s ease, border-color .16s ease;
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { opacity: .48; }
.primary { color: var(--ink); background: var(--accent); }
.primary:hover:not(:disabled) { background: #ffc4ad; }
.quiet { color: var(--text); background: #22212d; border-color: #373648; }
.quiet:hover:not(:disabled) { background: #302e40; border-color: #59566e; }
.text-button { color: #ffc1bf; background: transparent; padding-inline: 0; }
.full { width: 100%; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.eyebrow { color: var(--accent); font-size: .88rem; font-weight: 800; letter-spacing: .115em; line-height: 1.35; overflow-wrap: anywhere; }
.eyebrow > span { display: inline-block; background: currentColor; width: 7px; height: 7px; border-radius: 50%; margin-right: .32rem; vertical-align: .13em; }
.lede { color: var(--muted); font-size: clamp(1rem, 2vw, 1.24rem); line-height: 1.55; }
.form-error { color: #ffc1bf; font-size: .91rem; line-height: 1.4; }
.form-error:empty { display: none; }
.notice {
  position: fixed; z-index: 10; bottom: max(1rem, env(safe-area-inset-bottom)); left: 50%; max-width: calc(100% - 2rem);
  width: max-content; transform: translate(-50%, 10px); border-radius: 10px; border: 1px solid #585369;
  padding: .75rem 1rem; color: var(--text); background: #292538; opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s; box-shadow: 0 8px 20px #0a081b66;
}
.notice.visible { opacity: 1; transform: translate(-50%, 0); }
.tone-0 { --tone: #ffad8e; }
.tone-1 { --tone: #b5a3fa; }
.tone-2 { --tone: #a9ebc8; }
.tone-3 { --tone: #a6c8ff; }
.game-art {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; width: min(100%, 370px);
  rotate: -10deg; justify-self: center; user-select: none;
}
.art-tile {
  aspect-ratio: 1; border-radius: 23%; background: var(--tone);
  box-shadow: inset 0 -7px 0 #17132526, 0 15px 28px #0a081b55;
}
.art-tile:first-child { translate: -6px -6px; }
.art-tile:last-child { translate: 6px 6px; }

.landing { width: min(100% - 2.5rem, 1220px); margin: clamp(1.1rem, 5vw, 4rem) auto; }
.hero {
  display: grid; grid-template-columns: 1.1fr 1fr; align-items: center; gap: 3.2rem; min-height: 580px;
  padding: clamp(1.4rem, 6vw, 5rem); overflow: hidden; border: 1px solid #383449; border-radius: 28px;
  background: radial-gradient(ellipse at 84% 50%, #372e4c 0%, transparent 54%), #181722;
}
.hero h1 { font-size: clamp(4rem, 10vw, 8rem); letter-spacing: -.095em; line-height: .86; margin: 1.2rem 0 1.35rem; }
.hero h1 em { color: var(--accent); font-style: normal; }
.hero .lede { max-width: 25ch; }
.find-room { margin-top: 2rem; display: grid; gap: .55rem; max-width: 420px; }
.find-actions { display: flex; gap: .55rem; }
.find-actions input { text-transform: uppercase; font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: .15em; }
.find-actions .button { flex-shrink: 0; }
.narrow { width: min(100% - 2rem, 500px); margin: clamp(1.5rem, 8vw, 5rem) auto; }
.entry { padding: clamp(1.3rem, 4vw, 2.35rem); }
.entry h1 { margin: .8rem 0 1rem; font-size: clamp(2rem, 6vw, 3.4rem); }
.entry .lede + .button { margin-top: 1.25rem; }
.stack { display: grid; gap: .7rem; margin-top: 1.65rem; }
.stack input + label { margin-top: .3rem; }
.stack .button { margin-top: .35rem; }

.workspace { width: min(100% - 2.5rem, 1160px); margin: clamp(1.15rem, 4vw, 3.2rem) auto 3rem; }
.studio-banner {
  min-height: 300px; padding: clamp(1.4rem, 5vw, 3.4rem); border-radius: 24px; border: 1px solid #383449;
  display: grid; grid-template-columns: 1fr .65fr; align-items: center; overflow: hidden; gap: 2rem;
  background: radial-gradient(ellipse at 83% 60%, #372e4c, transparent 57%), #1c1a28;
}
.studio-banner h1 { margin: .65rem 0 .45rem; }
.studio-banner .button { margin-top: 1.35rem; }
.studio-banner .game-art { width: min(100%, 210px); gap: 9px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 2.1rem 0 .85rem; }
.section-title > span, .row-copy > span, .empty p { color: var(--muted); line-height: 1.4; }
.empty, .quiz-row { display: flex; gap: 1rem; align-items: center; padding: 1rem 1.15rem; }
.empty > .button, .row-actions, .quiz-row > .button { margin-left: auto; }
.quiz-icon { background: #352638; color: var(--accent); border-radius: 11px; height: 44px; width: 44px; display: grid; place-items: center; font-size: 1.4rem; flex: 0 0 auto; }
.quiz-list { list-style: none; padding: 0; }
.quiz-row + .quiz-row { border-top: 1px solid var(--line); }
.row-copy { display: grid; gap: .22rem; min-width: 0; overflow-wrap: anywhere; }
.row-actions { display: flex; flex-shrink: 0; gap: .55rem; }
.room-tag { display: inline-block; padding: .34rem .58rem; border-radius: 7px; background: #34283b; color: #ffd1bf; font: 750 .95rem ui-monospace, monospace; letter-spacing: .1em; flex: 0 0 auto; }
.dot-separator { margin-inline: .1rem; }

.editor-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.45rem; }
.editor-heading h1 { margin-top: .55rem; }
.title-field { padding: 1rem 1.2rem; display: grid; gap: .46rem; margin-bottom: 1rem; }
.editor-grid { display: grid; align-items: start; grid-template-columns: minmax(218px, .43fr) minmax(0, 1fr); gap: 1rem; }
.editor-sidebar { padding: 1rem; }
.editor-sidebar h2 { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; }
.editor-sidebar h2 span, .waiting-list h2 span { color: var(--muted); font-size: .9rem; border-radius: 20px; padding: .22rem .54rem; background: #282737; }
.question-tabs { display: grid; gap: .35rem; margin-bottom: .85rem; max-height: 36vh; overflow: auto; padding: 4px; margin-inline: -4px; }
.question-tab { border: 1px solid transparent; background: transparent; color: var(--muted); border-radius: 9px; text-align: left; display: flex; align-items: center; gap: .6rem; min-height: 44px; padding: .52rem .56rem; min-width: 0; }
.question-tab span:first-child { font: 700 .84rem ui-monospace, monospace; color: var(--accent); }
.question-tab span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.question-tab.selected { background: #342737; border-color: #674653; color: var(--text); }
.question-tab:hover { border-color: #674653; }
.question-edit { padding: clamp(1rem, 3vw, 1.65rem); }
.question-edit > textarea { margin-top: .4rem; }
.question-edit-heading { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: 1.35rem; }
.time-field { display: flex; align-items: center; gap: .4rem; color: var(--muted); }
.time-field input { width: 4.45rem; padding: .55rem .35rem .55rem .55rem; appearance: textfield; }
.time-field input::-webkit-inner-spin-button, .time-field input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.answer-edit { display: flex; align-items: center; gap: .55rem; margin: .47rem 0; }
.answer-edit input:not([type="checkbox"]) { border-inline-start: 5px solid var(--tone); }
.correct-label { position: relative; width: 37px; height: 37px; flex: 0 0 auto; display: grid; place-items: center; cursor: pointer; }
.correct-label input { position: absolute; inset: 0; margin: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.correct-label span { width: 100%; height: 100%; display: grid; place-items: center; border: 1px solid #4b485e; border-radius: 10px; color: var(--muted); }
.correct-label input:checked + span { background: var(--green); color: var(--ink); border-color: var(--green); }
.correct-label input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.editor form > .form-error { margin-top: .65rem; }

.stage { width: min(100% - 2.5rem, 1220px); margin: clamp(1.15rem, 4vw, 3.4rem) auto 2.2rem; }
.stage-intro { margin-bottom: 1.45rem; }
.stage-intro h1 { margin-top: .6rem; }
.stage-meta { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin-bottom: .85rem; }
.phase-label { background: #252435; color: var(--muted); padding: .38rem .64rem; border-radius: 7px; font-size: .9rem; font-weight: 700; }
.lobby-grid { display: grid; grid-template-columns: 1.02fr 1fr; gap: 1rem; }
.invite { background: radial-gradient(ellipse at 50% 30%, #37283d 0%, #1a1725 65%); text-align: center; padding: clamp(1.1rem, 4vw, 2.4rem); }
.big-code { display: block; color: var(--accent); font: 800 clamp(2.8rem, 8vw, 6rem)/1.15 ui-monospace, monospace; letter-spacing: .07em; margin: .65rem 0; }
.join-url { color: var(--muted); overflow-wrap: anywhere; margin-bottom: .95rem; user-select: all; }
.waiting-list { padding: 1.25rem; }
.waiting-list h2 { display: flex; align-items: center; gap: .5rem; }
.waiting-list ul { margin-top: .9rem; list-style: none; padding: 0; display: flex; gap: .42rem; flex-wrap: wrap; max-height: 215px; overflow: auto; }
.waiting-list li { background: #2b293a; border-radius: 20px; padding: .4rem .65rem; max-width: 100%; overflow-wrap: anywhere; }
.waiting-list .no-player { background: none; color: var(--muted); padding-left: 0; }
.stage-actions { margin-top: 1rem; display: flex; justify-content: end; }
.stage-actions .button { min-height: 48px; padding-inline: 1.35rem; }
.question-title { font-size: clamp(1.9rem, 5vw, 4.65rem); margin-bottom: 1rem; line-height: 1.1; }
.clock { display: flex; align-items: center; gap: .7rem; font-variant-numeric: tabular-nums; }
.clock-track { flex: 1; height: 7px; overflow: hidden; border-radius: 20px; background: #322e42; }
.clock-track i { display: block; height: 100%; background: var(--accent); border-radius: 20px; transform: scaleX(var(--remaining, 1)); transform-origin: left; transition: transform .12s linear; }
.clock strong { min-width: 3.2rem; text-align: right; }
.host-answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin-top: 1.05rem; }
.host-answer { display: flex; flex-wrap: wrap; position: relative; align-items: center; gap: .7rem; background: var(--tone); color: var(--ink); min-height: 88px; border-radius: 13px; padding: .85rem; isolation: isolate; overflow: hidden; }
.host-answer.is-correct { outline: 2px solid var(--text); outline-offset: -4px; }
.answer-text { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: clamp(1rem, 2.4vw, 1.65rem); font-weight: 800; line-height: 1.15; }
.answer-score { display: grid; gap: .14rem; text-align: right; }
.answer-score strong { font-size: 1.2rem; }
.answer-score small { font-size: .82rem; }
.correct-badge { width: fit-content; background: var(--ink); color: var(--text); padding: .22rem .5rem; border-radius: 6px; font-size: .8rem; font-weight: 700; }
.vote-bar { position: absolute; z-index: -1; inset: auto auto 0 0; width: var(--share); height: 7px; background: #21152b5e; transform-origin: left; animation: bar-in .45s ease both; }
.stats-summary { display: flex; flex-wrap: wrap; gap: .38rem .65rem; color: var(--muted); }
.stats-summary span { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .42rem .58rem; font-size: .9rem; }
.stats-summary strong { color: var(--text); }
.reveal-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(255px, .43fr); gap: 1rem; align-items: start; }
.live-podium { padding: 1.2rem; }
.live-podium ol { display: grid; gap: .7rem; list-style: none; padding: 0; margin-top: 1rem; }
.live-podium li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .65rem; align-items: center; }
.live-podium li strong { overflow-wrap: anywhere; }
.live-rank { width: 1.9rem; height: 1.9rem; display: grid; place-items: center; background: var(--tone); color: var(--ink); border-radius: 7px; font-weight: 800; }
.rank-points { color: var(--accent); font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }

.player-live { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; position: relative; }
.player-live:has(.player-game) { height: 100vh; height: 100dvh; }
.player-live .topbar-inner { min-height: 54px; }
.player-live .brand-mark { width: 28px; height: 28px; font-size: 1.1rem; }
.rename { display: block; min-height: 36px; max-width: min(58vw, 255px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: .45rem .65rem; }
.rename::after { content: " ✎"; color: var(--accent); }
.name-form { position: absolute; top: 61px; right: max(1rem, calc((100% - 1220px) / 2)); width: min(100% - 2rem, 280px); padding: 1rem; display: grid; gap: .52rem; z-index: 5; box-shadow: 0 10px 40px #0a081bc0; }
.player-center { flex: 1; display: grid; place-items: center; text-align: center; isolation: isolate; position: relative; overflow: hidden; }
.player-center .entry { max-width: 560px; }
.player-center .game-art { margin: 0 auto 2.6rem; width: 108px; gap: 5px; }
.player-center .art-tile:first-child, .player-center .art-tile:last-child { translate: 0; }
.player-game { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 max(.45rem, env(safe-area-inset-right)) max(.45rem, env(safe-area-inset-bottom)) max(.45rem, env(safe-area-inset-left)); }
.player-status { display: flex; align-items: center; gap: .7rem; padding: .44rem .45rem; }
.player-status .clock { flex: 1; min-width: 0; }
.player-status .eyebrow { letter-spacing: .06em; white-space: nowrap; }
.answer-grid { flex: 1; min-height: 0; display: grid; grid-template: repeat(2, minmax(0, 1fr)) / repeat(2, minmax(0, 1fr)); gap: .45rem; }
.player-answer {
  position: relative; border: 2px solid transparent; border-radius: 13px; width: 100%; min-width: 0; min-height: 0;
  display: flex; justify-content: center; align-items: center; flex-direction: column; gap: clamp(.4rem, 2vmin, 1rem);
  color: var(--ink); background: var(--tone); padding: clamp(.35rem, 2vmin, 1.2rem); touch-action: manipulation;
  box-shadow: inset 0 -6px 0 #17132527; transition: filter .15s, opacity .2s, transform .15s;
}
.player-answer .answer-text { flex: 0 1 auto; max-width: 100%; font-size: clamp(.98rem, 3.6vmin, 2.45rem); }
.long-answer .answer-text { font-size: clamp(.88rem, 3.2vmin, 1.9rem); }
.player-answer:hover:not(:disabled) { filter: brightness(1.07); }
.player-answer:active:not(:disabled) { transform: scale(.99); }
.player-answer:focus-visible { outline-color: white; outline-offset: -5px; }
.player-answer.chosen { border-color: var(--ink); box-shadow: inset 0 0 0 3px #fff; }
.choice-mark { position: absolute; display: none; top: .35rem; right: .55rem; background: var(--ink); color: white; border-radius: 50%; width: 1.55rem; height: 1.55rem; line-height: 1.55rem; font-weight: 800; }
.chosen .choice-mark { display: block; }
.result { background: radial-gradient(ellipse at center, #342638, transparent 65%); }
.result.success { background: radial-gradient(ellipse at center, #234035, transparent 65%); }
.result h1 { font-size: clamp(2.7rem, 9vw, 6rem); }
.result-icon { display: grid; place-items: center; width: 92px; height: 92px; margin: 0 auto 1.35rem; border-radius: 28px; color: var(--ink); background: var(--accent); font-size: 3rem; font-weight: 800; animation: pop .42s cubic-bezier(.2,.9,.3,1.3) both; }
.success .result-icon { background: var(--green); }
.earned-points { margin: -.35rem 0 1rem; color: var(--green); font-size: clamp(1.65rem, 5vw, 2.6rem); font-weight: 850; animation: arrive .38s ease .15s both; }

.podium-stage { position: relative; text-align: center; isolation: isolate; }
.podium-stage h1 { margin: .65rem 0 1.55rem; }
.podium-grid { display: flex; justify-content: center; align-items: end; gap: clamp(.35rem, 2vw, .85rem); margin: 0 auto 1.3rem; max-width: 640px; padding-top: .6rem; }
.podium-place { display: grid; flex: 0 1 31%; min-width: 0; gap: .35rem; animation: arrive .49s ease both; }
.podium-place strong { overflow-wrap: anywhere; font-size: clamp(.95rem, 3vw, 1.3rem); }
.podium-place small { color: var(--muted); font-size: .9rem; }
.pedestal { display: grid; place-items: start center; padding-top: .75rem; color: var(--ink); border-radius: 12px 12px 5px 5px; font-size: clamp(1.5rem, 5vw, 3rem); font-weight: 900; }
.rank-1 .pedestal { min-height: clamp(108px, 21vw, 220px); background: var(--accent); }
.rank-2 .pedestal { min-height: clamp(83px, 15vw, 155px); background: #b5a3fa; }
.rank-3 .pedestal { min-height: clamp(60px, 11vw, 115px); background: var(--green); }
.rank-1 { animation-delay: .18s; }
.rank-3 { animation-delay: .09s; }
.confetti { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: 0; left: var(--x); width: 8px; height: 12px; border-radius: 2px; background: var(--tone); opacity: 0; animation: scatter 1.4s var(--delay) ease-out both; }
@keyframes pop { from { transform: scale(.35) rotate(-14deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes arrive { from { opacity: 0; transform: translateY(1rem); } to { opacity: 1; transform: translateY(0); } }
@keyframes scatter { 0% { transform: translateY(-12px) rotate(var(--tilt)); } 20% { opacity: .85; } 100% { transform: translateY(340px) rotate(calc(var(--tilt) + 220deg)); opacity: 0; } }
@keyframes bar-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (max-width: 690px) {
  .topbar-inner { width: calc(100% - 1.5rem); min-height: 60px; }
  .topbar .quiet { font-size: .84rem; padding-inline: .7rem; }
  .landing, .workspace, .stage { width: calc(100% - 1.5rem); }
  .hero { grid-template-columns: 1fr; min-height: auto; gap: 2.2rem; padding: 1.5rem 1.2rem 2rem; }
  .hero h1 { font-size: clamp(3.7rem, 15vw, 6rem); margin: .8rem 0 1rem; }
  .hero .game-art { width: min(55%, 220px); gap: 7px; }
  .find-room { margin-top: 1.2rem; }
  .studio-banner { grid-template-columns: 1fr .33fr; gap: .55rem; min-height: 220px; }
  .studio-banner .game-art { gap: 4px; }
  .empty, .quiz-row { padding: .75rem; gap: .65rem; flex-wrap: wrap; }
  .row-copy { flex: 1; }
  .row-actions, .empty > .button { flex: 0 0 100%; justify-content: end; }
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .editor-heading { align-items: start; flex-direction: column; }
  .question-tabs { max-height: 145px; }
  .lobby-grid { grid-template-columns: minmax(0, 1fr); }
  .reveal-layout { grid-template-columns: minmax(0, 1fr); }
  .host-answer { min-height: 77px; padding: .55rem; gap: .42rem; }
  .answer-score strong { font-size: 1rem; }
  .correct-badge { flex-basis: auto; }
}

@media (max-width: 360px) {
  .find-actions { flex-direction: column; }
  .empty > .button { margin-left: 0; }
  .host-answer .answer-score { font-size: .85rem; }
  .correct-badge { font-size: .72rem; }
}

@media (max-height: 450px) and (orientation: landscape) {
  .player-live .topbar-inner { min-height: 43px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .confetti { display: none; }
}
