/* Student (player) screens — mobile first */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 18px 10px;
}
.tb-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line); min-width: 0; }
.tb-name { font-weight: 600; font-size: 14px; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-xs { width: 30px; height: 30px; border-radius: 8px; }
.avatar-sm { width: 34px; height: 34px; border-radius: 9px; }
.avatar-xl { width: 112px; height: 112px; border-radius: 28px; border-color: rgba(74,188,93,.4); }

.stage { flex: 1; width: 100%; max-width: 620px; margin: 0 auto; padding: 8px 18px max(28px, env(safe-area-inset-bottom)); outline: none; display: flex; flex-direction: column; }

/* ---------- join / PIN ---------- */
.join { display: grid; gap: 18px; padding-top: 6vh; }
.join-title { font-size: clamp(36px, 10vw, 56px); }
.join-title-sm { font-size: clamp(28px, 8vw, 40px); word-break: break-word; }
.join-sub { font-size: 17px; max-width: 34ch; }
.pin-form, .name-form { display: grid; gap: 14px; margin-top: 8px; }
.pin-wrap { position: relative; }
.pin-prompt { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); font-family: var(--font-mono); color: var(--green); font-weight: 700; font-size: 20px; }
.pin-input {
  width: 100%; height: 84px; padding: 0 18px 0 58px;
  background: #050806; border: 1.5px solid var(--line-2); border-radius: 18px;
  font-size: clamp(34px, 11vw, 46px); font-weight: 700; letter-spacing: 0.32em; color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.pin-input::placeholder { color: #26302a; }
.pin-input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 4px rgba(74,188,93,.2), 0 0 40px rgba(74,188,93,.15) inset; }
.pin-input[aria-invalid="true"] { border-color: var(--danger); animation: shake 300ms; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
.join-term { padding: 16px 18px; border: 1px dashed rgba(74,188,93,.25); border-radius: 16px; background: rgba(0,0,0,.5); font-size: 13px; }
.join-foot { margin-top: auto; padding-top: 32px; text-align: center; font-size: 14px; }
.join-foot a { color: var(--muted); }
.join-foot a:hover { color: var(--green-hi); }
.link-back { justify-self: start; display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--muted); padding: 8px 0; min-height: 44px; font-family: var(--font-mono); font-size: 13px; }
.link-back .ico svg { width: 16px; height: 16px; }
.link-back:hover { color: var(--text); }
.ico { display: inline-flex; }
.ico svg { width: 18px; height: 18px; }
.name-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.input-lg { min-height: 58px; font-size: 19px; font-weight: 600; }
.av-head { display: flex; align-items: center; justify-content: space-between; }
.av-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.av-opt { aspect-ratio: 1; border-radius: 16px; border: 1.5px solid var(--line); background: #0b120d; padding: 0; overflow: hidden; transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast), box-shadow var(--t-fast); }
.av-opt svg { width: 100%; height: 100%; }
.av-opt:hover { border-color: var(--line-2); }
.av-opt[aria-checked="true"] { border-color: var(--green); box-shadow: 0 0 0 3px rgba(74,188,93,.25), 0 10px 30px rgba(74,188,93,.25); transform: translateY(-2px); }

/* ---------- lobby ---------- */
.lobby { display: grid; justify-items: center; text-align: center; gap: 14px; padding-top: 5vh; }
.lobby-av { position: relative; margin-bottom: 6px; }
.lobby-ring { position: absolute; inset: -10px; border-radius: 36px; border: 1.5px solid rgba(74,188,93,.5); animation: ring 2.4s var(--ease-out) infinite; }
@keyframes ring { 0% { transform: scale(.92); opacity: 1; } 100% { transform: scale(1.25); opacity: 0; } }
.lobby-name { font-size: clamp(30px, 9vw, 44px); word-break: break-word; }
.lobby-sub { max-width: 32ch; }
.lobby-term { text-align: left; width: 100%; padding: 16px 18px; margin: 6px 0; }
.lobby-count { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- HUD + timer ---------- */
.hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 10px; }
.hud-l { display: flex; gap: 14px; align-items: center; }
.hud-q, .hud-score { display: grid; gap: 0; }
.hud-score { text-align: right; }
.hud-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: .18em; color: var(--muted-2); }
.hud .num { font-size: 22px; font-weight: 700; }
.hud .num.low { color: var(--danger); }
.tbar { position: relative; height: 10px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; margin-bottom: 16px; }
.tbar-fill { position: absolute; inset: 0; background: linear-gradient(90deg, var(--green), var(--green-hi)); transform-origin: left; transform: scaleX(var(--k, 1)); box-shadow: 0 0 18px var(--green-glow); }
.tbar-fill.low { background: linear-gradient(90deg, var(--danger), #ff9aa5); }
.hud-timer { display: grid; justify-items: center; }
.hud-timer .num { font-size: 26px; color: var(--green-hi); min-width: 2ch; text-align: center; }

/* ---------- intro ---------- */
.intro { display: grid; justify-items: center; text-align: center; gap: 14px; padding-top: 18vh; }
.intro-num { font-size: clamp(80px, 30vw, 150px); letter-spacing: -0.05em; }
.intro-of { color: var(--muted-2); font-size: .4em; }
.intro .tbar { width: min(320px, 80vw); }

/* ---------- question ---------- */
.qscreen { display: flex; flex-direction: column; gap: 14px; }
.qcard { padding: 20px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }
.qtext { font-family: var(--font-head); font-size: clamp(20px, 5.4vw, 26px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; word-break: break-word; }
.answers { display: grid; gap: 10px; }
@media (min-width: 560px) { .answers.n4, .answers.n2 { grid-template-columns: 1fr 1fr; } }
.ans {
  display: flex; align-items: center; gap: 14px; text-align: left;
  min-height: 74px; padding: 14px 16px; border-radius: 18px;
  background: color-mix(in srgb, var(--c) 9%, #070a08);
  border: 1.5px solid color-mix(in srgb, var(--c) 50%, transparent);
  color: var(--text); font-size: 17px; font-weight: 500; line-height: 1.3;
  transition: transform var(--t-fast) var(--ease-out), background-color var(--t-fast), opacity var(--t), border-color var(--t-fast), box-shadow var(--t);
}
.ans:hover:not(:disabled) { background: color-mix(in srgb, var(--c) 17%, #070a08); }
.ans:active:not(:disabled) { transform: scale(.98); }
.ans .ans-key { width: 46px; height: 46px; }
.ans-text { flex: 1; min-width: 0; word-break: break-word; }
.ans:disabled { cursor: default; }
.ans.picked { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent), 0 12px 34px color-mix(in srgb, var(--c) 28%, transparent); }
.ans.pending .ans-key { animation: pulse 900ms ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.ans.dim { opacity: .32; }
.locked { display: flex; gap: 14px; align-items: center; padding: 16px 18px; border-radius: 16px; background: var(--green-tint); border: 1px solid rgba(74,188,93,.35); }
.locked-ic { color: var(--green); }
.locked-ic svg { width: 26px; height: 26px; }

/* ---------- reveal ---------- */
.reveal { display: flex; flex-direction: column; gap: 16px; }
.verdict { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 30px 18px 26px; border-radius: 22px; border: 1px solid; }
.verdict.ok { border-color: rgba(74,188,93,.5); background: radial-gradient(80% 80% at 50% 0%, rgba(74,188,93,.25), rgba(74,188,93,.04)); }
.verdict.bad { border-color: rgba(255,93,108,.5); background: radial-gradient(80% 80% at 50% 0%, rgba(255,93,108,.22), rgba(255,93,108,.03)); }
.verdict.none { border-color: rgba(245,185,65,.45); background: radial-gradient(80% 80% at 50% 0%, rgba(245,185,65,.18), rgba(245,185,65,.03)); }
.v-ic { display: grid; place-items: center; width: 74px; height: 74px; border-radius: 50%; margin-bottom: 6px; }
.v-ic svg { width: 38px; height: 38px; stroke-width: 2.6; }
.ok .v-ic { background: var(--green); color: var(--green-ink); box-shadow: 0 0 40px var(--green-glow); }
.bad .v-ic { background: var(--danger); color: #1a0306; box-shadow: 0 0 40px rgba(255,93,108,.35); }
.none .v-ic { background: var(--amber); color: #1d1300; }
.v-title { font-family: var(--font-mono); font-weight: 700; font-size: clamp(24px, 7vw, 32px); letter-spacing: .06em; }
.ok .v-title { color: var(--green-hi); }
.bad .v-title { color: #ff9aa5; }
.none .v-title { color: #ffd98a; }
.v-sub { color: var(--text-2); }
.v-points { font-size: 34px; font-weight: 700; color: var(--green-hi); }
.verdict.compact { padding: 22px 16px 20px; }
.verdict.compact .v-ic { width: 60px; height: 60px; }
.correct-box { display: grid; gap: 8px; }
.correct-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid color-mix(in srgb, var(--c) 55%, transparent); background: color-mix(in srgb, var(--c) 10%, #070a08); font-weight: 500; word-break: break-word; }
.rankline { display: flex; align-items: center; gap: 18px; padding: 16px 18px; }
.rank-big { font-size: 34px; font-weight: 700; color: var(--green-hi); }
.rank-gap { display: grid; gap: 6px; min-width: 0; word-break: break-word; }
.rank-gap .ico svg { width: 16px; height: 16px; vertical-align: -2px; }
.streak { color: var(--amber); font-family: var(--font-mono); font-size: 14px; display: flex; align-items: center; gap: 6px; }
.wait-note { text-align: center; font-size: 14px; }

/* ---------- podium ---------- */
.podium-me { display: grid; justify-items: center; text-align: center; gap: 16px; padding-top: 3vh; }
.place { position: relative; display: grid; justify-items: center; gap: 4px; }
.place-rank { font-size: 64px; font-weight: 700; letter-spacing: -0.04em; }
.place.top .avatar-xl { box-shadow: 0 0 60px var(--green-glow); border-color: var(--green); }
.place.top1 .place-rank { color: var(--green-hi); text-shadow: 0 0 30px var(--green-glow); }
.podium-title { font-size: clamp(26px, 7vw, 36px); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.stat { display: grid; gap: 4px; padding: 14px 8px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.stat .num { font-size: 22px; font-weight: 700; }
.top-list { width: 100%; padding: 14px; display: grid; gap: 8px; text-align: left; }
.top-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; }
.top-row.me { background: var(--green-tint); border: 1px solid rgba(74,188,93,.35); }
.top-n { width: 22px; color: var(--muted); }
.top-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Root Race ---------- */
.race-top { display: grid; gap: 10px; margin-bottom: 4px; }
.chain { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); position: relative; }
.chain::before { content: ""; position: absolute; left: 10%; right: 10%; top: 9px; height: 2px; background: var(--line-2); }
.chain li { position: relative; display: grid; justify-items: center; gap: 6px; }
.chain-node { width: 20px; height: 20px; border-radius: 6px; background: #0b100c; border: 2px solid var(--line-2); transform: rotate(45deg); position: relative; z-index: 1; }
.chain li.done .chain-node { background: var(--green); border-color: var(--green); }
.chain li.cur .chain-node { border-color: var(--green-hi); background: #0b100c; box-shadow: 0 0 0 4px rgba(74,188,93,.2), 0 0 18px var(--green-glow); }
.chain-label { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .08em; color: var(--muted-2); }
.chain li.done .chain-label, .chain li.cur .chain-label { color: var(--green-hi); }
.race-prog { display: flex; align-items: center; gap: 12px; }
.race-prog-bar { flex: 1; height: 8px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; }
.race-prog-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--green-hi)); transform-origin: left; transform: scaleX(var(--k, 0)); transition: transform 500ms var(--ease-out); }
.lockbar { position: relative; width: min(260px, 70vw); height: 8px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 8px; }
.lockbar .tbar-fill { background: linear-gradient(90deg, var(--danger), #ff9aa5); box-shadow: none; }
.rooted { display: flex; flex-direction: column; gap: 16px; }

.msg { text-align: left; }

@media (min-width: 720px) {
  .stage { padding-top: 24px; }
  .qscreen, .reveal { max-width: 860px; }
  .stage:has(.qscreen) { max-width: 900px; }
}
