/* ============================================================================
   课堂答题 · HOST — teacher big-screen ("Chalk & Neon", dark / projector)
   ----------------------------------------------------------------------------
   Built for the back row: huge type, high contrast on warm ink, jewel-tone
   answer bars that grow on reveal, a game-show lobby with a giant QR. Shares
   the design system + tokens defined in common.css. Distribution stays HIDDEN
   while answering and only blooms in on .bars.revealed.
   ========================================================================== */

html, body { height: 100%; }

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--fg-inv);
  background:
    radial-gradient(130% 90% at 50% -20%, #211d2e 0%, var(--ink) 60%, #110f17 100%);
  overflow: hidden;            /* big screen = no page scroll; views scroll internally */
}

/* Riso grain over the whole stage */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ---------------------------------------------------------------------------
   Top bar — brand + the three mode tabs (题库 / PPT / 答题)
   ------------------------------------------------------------------------- */
#topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: clamp(10px, 1.6vh, 16px) clamp(16px, 3vw, 32px);
  background: linear-gradient(180deg, var(--ink-2), rgba(32,29,43,.86));
  border-bottom: 1px solid var(--ink-line);
  box-shadow: 0 10px 30px -18px #000;
  z-index: 20;
}
/* Brand lockup with a coral double-print echo */
#topbar::before {
  content: "课堂答题";
  position: relative;
  margin-right: auto;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.1rem, 2.2vw, 1.5rem);
  letter-spacing: -.01em;
  color: var(--fg-inv);
  text-shadow: 2px 2px 0 var(--coral);
}

#topbar [data-tab] {
  padding: 10px clamp(16px, 2.4vw, 26px);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(.95rem, 1.8vw, 1.2rem);
  letter-spacing: .02em;
  color: var(--fg-inv-soft);
  background: var(--ink-3);
  border-radius: var(--r-pill);
  box-shadow: 0 3px 0 rgba(0,0,0,.4);
  transition: transform .08s var(--ease-out), box-shadow .1s var(--ease-out),
              color .15s, background .15s;
}
#topbar [data-tab]:hover { color: var(--fg-inv); filter: brightness(1.1); }
#topbar [data-tab]:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.4); }
#topbar [data-tab].active {
  color: #fff;
  background: var(--coral);
  box-shadow: 0 4px 0 var(--coral-deep);
}
/* The "答题" tab is the live one — give it an aqua identity when active */
#topbar [data-tab="quiz"].active {
  background: var(--aqua);
  color: #04302f;
  box-shadow: 0 4px 0 var(--aqua-deep);
}

/* ---------------------------------------------------------------------------
   View shell — one visible [data-hostview] fills the rest of the screen
   ------------------------------------------------------------------------- */
[data-hostview] {
  flex: 1 1 auto;
  min-height: 0;
  animation: hostViewIn .4s var(--ease-out) both;
}
[data-hostview][hidden] { display: none; }
@keyframes hostViewIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===========================================================================
   TAB 1 · 题库  (authoring — a tidy dark working surface, scrolls internally)
   ========================================================================= */
[data-hostview="bank"] { overflow-y: auto; padding: clamp(20px, 3vw, 40px); }

#bank-root { max-width: 1100px; margin-inline: auto; }

.bank-bar {
  position: sticky;
  top: calc(-1 * clamp(20px, 3vw, 40px));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) 0 var(--s-5);
  margin-bottom: var(--s-4);
  background: linear-gradient(180deg, var(--ink) 70%, transparent);
  z-index: 5;
}
.bank-bar button, .import-label {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 12px 20px;
  font-family: var(--font-display); font-weight: 700;
  color: var(--fg-inv);
  background: var(--ink-3);
  border-radius: var(--r-pill);
  box-shadow: 0 3px 0 rgba(0,0,0,.4);
  transition: transform .08s var(--ease-out), filter .15s;
}
.bank-bar button:hover, .import-label:hover { filter: brightness(1.12); }
.bank-bar button:active { transform: translateY(2px); }
#add-single { background: var(--o1); box-shadow: 0 3px 0 var(--o1-deep); color: #fff; }
#add-tf     { background: var(--o3); box-shadow: 0 3px 0 var(--o3-deep); color: #fff; }
#export-bank { background: var(--ink-2); }
.import-label { cursor: pointer; background: var(--ink-2); }
.bank-count {
  margin-left: auto;
  font-family: var(--font-num); font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--fg-inv-soft);
}

.bank-list { display: grid; gap: var(--s-4); padding-bottom: var(--s-8); }

.q-card {
  padding: var(--s-4) var(--s-5);
  background: var(--ink-2);
  border: 2px solid var(--ink-line);
  border-radius: var(--r-lg);
  box-shadow: var(--float-dark);
  transition: border-color .18s var(--ease-out), transform .12s var(--ease-out);
}
.q-card.selected {
  border-color: var(--aqua);
  box-shadow: 0 0 0 4px rgba(22,200,200,.18), var(--float-dark);
}
.q-card-head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
.q-type {
  flex: 0 0 auto;
  padding: 6px 14px;
  font-family: var(--font-display); font-weight: 800; font-size: .85rem;
  letter-spacing: .08em;
  color: #04302f; background: var(--aqua);
  border-radius: var(--r-pill);
}
.q-text {
  flex: 1 1 auto; min-width: 0;
  padding: 12px 16px;
  font-size: 1.15rem; font-weight: 700;
  color: var(--fg-inv);
  background: var(--ink-3);
  border: 2px solid var(--ink-line);
  border-radius: var(--r-md);
}
.q-text::placeholder { color: var(--fg-inv-soft); opacity: .7; }
.q-text:focus { outline: none; border-color: var(--aqua); }
.q-del {
  flex: 0 0 auto;
  padding: 8px 14px; font-weight: 700;
  color: #fff; background: rgba(240,75,86,.16);
  border: 1.5px solid rgba(240,75,86,.5);
  border-radius: var(--r-pill);
  transition: background .15s;
}
.q-del:hover { background: var(--no); }

.q-opts { display: grid; gap: var(--s-2); margin-bottom: var(--s-3); }
.opt-row { display: flex; align-items: center; gap: var(--s-3); }
.opt-row input[type=radio] {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  accent-color: var(--correct);
  cursor: pointer;
}
.opt-text {
  flex: 1 1 auto; min-width: 0;
  padding: 10px 14px;
  color: var(--fg-inv);
  background: var(--ink-3);
  border: 1.5px solid var(--ink-line);
  border-radius: var(--r-sm);
}
.opt-text:focus { outline: none; border-color: var(--aqua); }
.opt-text:disabled { opacity: .8; }
.opt-del {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  font-size: 1.2rem; font-weight: 800; line-height: 1;
  color: var(--fg-inv-soft);
  background: var(--ink-3);
  border-radius: var(--r-sm);
  transition: color .15s, background .15s;
}
.opt-del:hover { color: #fff; background: var(--no); }
.opt-add {
  justify-self: start;
  padding: 8px 16px; font-weight: 700;
  color: var(--aqua);
  border: 1.5px dashed var(--aqua-deep);
  border-radius: var(--r-pill);
}
.opt-add:hover { color: #04302f; background: var(--aqua); }

.q-meta { display: flex; align-items: center; gap: var(--s-4); }
.q-meta label {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-weight: 600; color: var(--fg-inv-soft);
}
.q-time {
  width: 92px; padding: 9px 12px;
  font-family: var(--font-num); font-weight: 700; text-align: center;
  color: var(--fg-inv);
  background: var(--ink-3);
  border: 1.5px solid var(--ink-line);
  border-radius: var(--r-sm);
}
.q-select {
  margin-left: auto;
  padding: 11px 22px;
  font-family: var(--font-display); font-weight: 800;
  color: #fff; background: var(--coral);
  border-radius: var(--r-pill);
  box-shadow: 0 3px 0 var(--coral-deep);
  transition: transform .08s var(--ease-out), filter .15s;
}
.q-select:hover { filter: brightness(1.06); }
.q-select:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--coral-deep); }
.q-card.selected .q-select { background: var(--aqua); color: #04302f; box-shadow: 0 3px 0 var(--aqua-deep); }

/* ===========================================================================
   TAB 2 · PPT  (upload bar + full-bleed render stage)
   ========================================================================= */
[data-hostview="ppt"] { display: flex; flex-direction: column; }

#ppt-toolbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-3) clamp(16px, 3vw, 32px);
  background: var(--ink-2);
  border-bottom: 1px solid var(--ink-line);
}
#ppt-file {
  color: var(--fg-inv-soft);
  font-weight: 600;
}
#ppt-file::file-selector-button {
  margin-right: var(--s-3);
  padding: 10px 18px;
  font-family: var(--font-display); font-weight: 700;
  color: #fff; background: var(--coral);
  border: 0; border-radius: var(--r-pill);
  box-shadow: 0 3px 0 var(--coral-deep);
  cursor: pointer;
}
#ppt-status {
  font-weight: 600; color: var(--gold);
}
#ppt-toolbar button {
  padding: 8px 14px; font-family: var(--font-display); font-weight: 700;
  color: var(--fg-inv); background: var(--ink-3);
  border-radius: var(--r-pill); box-shadow: 0 3px 0 rgba(0,0,0,.4);
}
#ppt-toolbar button:hover:not(:disabled) { filter: brightness(1.12); }
#ppt-toolbar button:disabled { opacity: .35; pointer-events: none; box-shadow: none; }
#ppt-full:not(:disabled) { background: var(--aqua); color: #04302f; box-shadow: 0 3px 0 var(--aqua-deep); }
#ppt-page {
  font-family: var(--font-num); font-weight: 800; color: var(--fg-inv);
  min-width: 5ch; text-align: center; font-variant-numeric: tabular-nums;
}

#ppt-stage {
  flex: 1 1 auto; min-height: 0;
  position: relative;
  overflow: hidden;
  background: #0c0b11;
}
#ppt-stage:empty::before {
  content: "上传 .pptx 后在这里放映 · 方向键翻页 · 点「全屏」投影";
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--fg-inv-soft); font-size: clamp(1rem, 2.4vw, 1.4rem); font-weight: 600;
}
#ppt-stage:fullscreen { background: #000; }
#pptx-result { position: absolute; inset: 0; }
/* current slide is centered and JS-scaled to fill the stage / projector */
.ppt-slide {
  position: absolute; top: 50%; left: 50%;
  transform-origin: center center;
  box-shadow: 0 24px 64px -22px #000;
}
.ppt-error { color: var(--wrong); font-weight: 700; font-size: 1.3rem; text-align: center; margin-top: 18vh; }

/* In-stage presenter controls (auto-hide; reachable even in fullscreen) */
.ppt-controls {
  position: absolute; left: 50%; bottom: clamp(16px, 4vh, 36px);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--s-2);
  padding: 8px 12px;
  background: rgba(20, 18, 28, .82);
  border: 1px solid var(--ink-line);
  border-radius: var(--r-pill);
  box-shadow: var(--float-dark);
  opacity: 0; pointer-events: none;
  transition: opacity .25s var(--ease-out);
  z-index: 30;
}
#ppt-stage.controls-visible .ppt-controls { opacity: 1; pointer-events: auto; }
.ppt-controls button {
  padding: 8px 14px; font-family: var(--font-display); font-weight: 700;
  color: var(--fg-inv); background: var(--ink-3); border-radius: var(--r-pill);
}
.ppt-controls button:hover:not(:disabled) { filter: brightness(1.15); }
.ppt-controls button:disabled { opacity: .35; pointer-events: none; }
#pc-full { background: var(--coral); color: #fff; }
#pc-quiz { background: var(--aqua); color: #04302f; }
#pc-page {
  font-family: var(--font-num); font-weight: 800; color: var(--fg-inv);
  min-width: 5ch; text-align: center; font-variant-numeric: tabular-nums;
}

/* ===========================================================================
   TAB 3 · 答题  (the show)
   ========================================================================= */
[data-hostview="quiz"] { display: flex; flex-direction: column; min-height: 0; }

/* ---- Control bar ---- */
.quiz-controls {
  flex: 0 0 auto;
  display: flex; align-items: center; flex-wrap: wrap;
  gap: var(--s-3);
  padding: var(--s-3) clamp(16px, 3vw, 32px);
  background: var(--ink-2);
  border-bottom: 1px solid var(--ink-line);
}
.quiz-controls button {
  padding: 12px 24px;
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(.95rem, 1.7vw, 1.15rem);
  color: #fff;
  border-radius: var(--r-pill);
  box-shadow: 0 4px 0 rgba(0,0,0,.4);
  transition: transform .08s var(--ease-out), filter .15s;
}
.quiz-controls button:hover { filter: brightness(1.08); }
.quiz-controls button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.4); }
#btn-send   { background: var(--coral); box-shadow: 0 4px 0 var(--coral-deep); }
#btn-reveal { background: var(--aqua); color: #04302f; box-shadow: 0 4px 0 var(--aqua-deep); }
#btn-next   { background: var(--ink-3); }
#btn-reset.danger {
  margin-left: var(--s-2);
  background: transparent; color: var(--wrong);
  border: 1.5px solid rgba(239,85,96,.5);
  box-shadow: none;
}
#btn-reset.danger:hover { background: var(--no); color: #fff; }

#quiz-progress {
  margin-left: auto;
  font-family: var(--font-num); font-weight: 800;
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  font-variant-numeric: tabular-nums;
  color: var(--fg-inv);
}
#quiz-countdown {
  min-width: 4ch; text-align: right;
  font-family: var(--font-num); font-weight: 900;
  font-size: clamp(1.2rem, 2.8vw, 1.9rem);
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}
#quiz-countdown:not(:empty) { animation: cdPulse 1s var(--ease-soft) infinite; }
@keyframes cdPulse { 0%,100% { opacity: .8; } 50% { opacity: 1; } }

/* ---- Stage fills the rest ---- */
#quiz-stage {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  padding: clamp(20px, 3.5vw, 48px);
  overflow-y: auto; overflow-x: hidden;   /* never hard-clip the leaderboard */
}

/* ---- LOBBY — join URL + giant QR + names wall ---- */
.lobby {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) 1.1fr;
  gap: clamp(24px, 4vw, 56px);
  align-items: center;
  min-height: 0;
}
@media (max-width: 900px) { .lobby { grid-template-columns: 1fr; } }

.join-info { text-align: center; }
.join-hint {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  letter-spacing: .04em;
  color: var(--fg-inv-soft);
  margin-bottom: var(--s-3);
}
.join-url {
  display: inline-block;
  font-family: var(--font-num); font-weight: 900;
  font-size: clamp(1.4rem, 3.4vw, 2.6rem);
  letter-spacing: -.01em;
  color: #fff;
  padding: var(--s-3) var(--s-5);
  background: var(--ink-2);
  border: 2px solid var(--aqua);
  border-radius: var(--r-md);
  box-shadow: 6px 6px 0 var(--aqua-deep);
  word-break: break-all;
}
#qrcode {
  display: inline-grid; place-items: center;
  margin-top: var(--s-5);
  padding: clamp(12px, 1.6vw, 18px);
  background: #fff;
  border-radius: var(--r-md);
  box-shadow: var(--float-dark);
}
#qrcode img, #qrcode canvas { display: block; width: clamp(180px, 22vw, 240px); height: auto; }

.names-wall {
  align-self: stretch;
  display: flex; flex-wrap: wrap; align-content: flex-start;
  gap: var(--s-3);
  padding: var(--s-4);
  max-height: 100%;
  overflow: auto;
  background: rgba(0,0,0,.18);
  border: 1px solid var(--ink-line);
  border-radius: var(--r-lg);
}
.names-wall:empty::before {
  content: "等同学加入…";
  margin: auto;
  color: var(--fg-inv-soft); font-weight: 600; font-size: 1.2rem;
}
.name-chip {
  padding: 10px 18px;
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1rem, 1.8vw, 1.3rem);
  color: var(--ink);
  background: var(--gold);
  border-radius: var(--r-pill);
  box-shadow: 0 3px 0 rgba(0,0,0,.3);
  animation: chipIn .5s var(--ease-back) both;
}
/* alternate chip hues so the wall feels alive */
.name-chip:nth-child(4n+1) { background: var(--o0); color: #fff; }
.name-chip:nth-child(4n+2) { background: var(--o1); color: #fff; }
.name-chip:nth-child(4n+3) { background: var(--gold); color: var(--ink); }
.name-chip:nth-child(4n)   { background: var(--o3); color: #fff; }
@keyframes chipIn {
  0%   { opacity: 0; transform: scale(.4) rotate(-6deg); }
  70%  { transform: scale(1.12) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

/* ---- BIG QUESTION + distribution bars ---- */
.big-question {
  flex: 1 1 auto;
  display: flex; flex-direction: column; gap: clamp(16px, 2.4vh, 28px);
  min-height: 0;
}
.big-q-image {
  align-self: center;
  max-height: 28vh; width: auto;
  border-radius: var(--r-md);
  border: 3px solid var(--ink-line);
  box-shadow: var(--float-dark);
}
.big-q-text {
  font-size: clamp(1.8rem, 4.4vw, 3.4rem);
  font-weight: 800; line-height: 1.12;
  color: #fff;
  text-align: center;
  text-wrap: balance;
}

.bars {
  display: flex; flex-direction: column;
  gap: clamp(10px, 1.6vh, 18px);
  margin-top: auto;
}
.bar-row {
  --c: var(--ink-3); --c-deep: rgba(0,0,0,.4); --glyph: "";
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
}
.bar-row.opt-0 { --c: var(--o0); --c-deep: var(--o0-deep); --glyph: "\25B2"; }
.bar-row.opt-1 { --c: var(--o1); --c-deep: var(--o1-deep); --glyph: "\25C6"; }
.bar-row.opt-2 { --c: var(--o2); --c-deep: var(--o2-deep); --glyph: "\25CF"; }
.bar-row.opt-3 { --c: var(--o3); --c-deep: var(--o3-deep); --glyph: "\25A0"; }
.bar-row.opt-4 { --c: var(--o4); --c-deep: var(--o4-deep); --glyph: "\2726"; }
.bar-row.opt-5 { --c: var(--o5); --c-deep: var(--o5-deep); --glyph: "\271A"; }

.bar-label {
  display: flex; align-items: center; gap: var(--s-3);
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.1rem, 2.4vw, 1.7rem);
  color: var(--fg-inv);
  min-width: 0;
}
/* color + shape chip in front of each option label */
.bar-label::before {
  content: var(--glyph);
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: clamp(36px, 3.4vw, 48px); height: clamp(36px, 3.4vw, 48px);
  font-size: clamp(1rem, 2vw, 1.4rem);
  color: #fff; background: var(--c);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--c-deep);
}
.bar-count {
  font-family: var(--font-num); font-weight: 900;
  font-size: clamp(1.1rem, 2.4vw, 1.7rem);
  font-variant-numeric: tabular-nums;
  color: var(--fg-inv-soft);
  white-space: nowrap;
}

/* the growing track sits across BOTH columns on the row below the label */
.bar-track {
  grid-column: 1 / -1;
  height: clamp(14px, 1.8vh, 22px);
  background: rgba(255,255,255,.07);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 70%, #fff));
  border-radius: var(--r-pill);
  /* JS sets width 0% -> data-pct%; this is the "动态" growth */
  transition: width .85s var(--ease-out);
}

/* ANSWERING: hide the distribution entirely — show only the option recap. */
.bars.hidden-dist .bar-track,
.bars.hidden-dist .bar-count { display: none; }
.bars.hidden-dist .bar-row {
  padding: clamp(8px, 1.2vh, 14px) var(--s-4);
  background: var(--ink-2);
  border: 1px solid var(--ink-line);
  border-radius: var(--r-md);
}

/* REVEALED: correct row glows + pulses, others dim back */
.bars.revealed .bar-row:not(.correct) { opacity: .62; }
.bars.revealed .bar-row.correct .bar-label { color: #fff; }
.bars.revealed .bar-row.correct .bar-label::after {
  content: "\2713 正确";
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(.85rem, 1.6vw, 1.1rem);
  color: var(--correct);
  white-space: nowrap;
}
.bars.revealed .bar-row.correct .bar-track {
  box-shadow: 0 0 0 3px var(--correct), 0 0 24px -2px var(--correct);
  animation: correctPulse 1.4s var(--ease-soft) infinite;
}
@keyframes correctPulse {
  0%,100% { box-shadow: 0 0 0 3px var(--correct), 0 0 18px -4px var(--correct); }
  50%     { box-shadow: 0 0 0 4px var(--correct), 0 0 34px 0 var(--correct); }
}

.answering-hint {
  margin-top: var(--s-5);
  text-align: center;
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  color: var(--fg-inv-soft);
  animation: pulseWait 1.8s var(--ease-soft) infinite;
}
@keyframes pulseWait { 0%,100% { opacity: .5; } 50% { opacity: 1; } }

/* ---- LEADERBOARD ---- */
.leaderboard {
  margin-top: clamp(16px, 2.4vh, 28px);
  background: rgba(0,0,0,.2);
  border: 1px solid var(--ink-line);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5);
}
.leaderboard h3 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.1rem, 2.2vw, 1.5rem);
  color: var(--gold);
  margin-bottom: var(--s-3);
  letter-spacing: .04em;
}
.leaderboard ol { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.leaderboard li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-3);
  padding: 10px 16px;
  background: var(--ink-2);
  border-radius: var(--r-md);
  animation: lbIn .45s var(--ease-out) both;
}
.leaderboard li:nth-child(1) { box-shadow: inset 4px 0 0 var(--gold); }
.leaderboard li:nth-child(2) { box-shadow: inset 4px 0 0 var(--fg-inv-soft); }
.leaderboard li:nth-child(3) { box-shadow: inset 4px 0 0 var(--o5); }
@keyframes lbIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }

.lb-rank {
  font-family: var(--font-num); font-weight: 900;
  font-size: clamp(1.1rem, 2.2vw, 1.5rem);
  font-variant-numeric: tabular-nums;
  color: var(--fg-inv-soft);
  min-width: 1.6em; text-align: center;
}
.leaderboard li:nth-child(1) .lb-rank { color: var(--gold); }
.lb-name {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.05rem, 2.2vw, 1.5rem);
  color: var(--fg-inv);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lb-score {
  font-family: var(--font-num); font-weight: 900;
  font-size: clamp(1.1rem, 2.2vw, 1.5rem);
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

/* ===========================================================================
   Quiz nav (prev/next + indicator), reveal 2-col fit, bank reorder, login
   ========================================================================= */
#btn-prev, #btn-next { background: var(--ink-3); box-shadow: 0 4px 0 rgba(0,0,0,.4); }
.quiz-controls button:disabled { opacity: .38; pointer-events: none; box-shadow: none; transform: none; }
.quiz-indicator {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1rem, 2vw, 1.35rem);
  color: var(--fg-inv);
  padding: 0 var(--s-2);
  min-width: 9ch; text-align: center; white-space: nowrap;
}

/* REVEAL: bars + leaderboard side-by-side so both fit one projector screen */
.big-question:has(.bars.revealed) {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  grid-template-rows: auto auto 1fr;
  grid-template-areas: "img lb" "title lb" "bars lb";
  gap: clamp(14px, 2vw, 30px);
  height: 100%; min-height: 0;
}
.big-question:has(.bars.revealed) .big-q-image { grid-area: img; max-height: 20vh; }
.big-question:has(.bars.revealed) .big-q-text  { grid-area: title; text-align: left; font-size: clamp(1.4rem, 3vw, 2.4rem); }
.big-question:has(.bars.revealed) .bars        { grid-area: bars; margin-top: 0; align-content: start; min-height: 0; overflow-y: auto; }
.big-question:has(.bars.revealed) .leaderboard { grid-area: lb; margin-top: 0; align-self: stretch; max-height: 100%; overflow-y: auto; }
@media (max-width: 1000px) {
  .big-question:has(.bars.revealed) {
    grid-template-columns: 1fr; grid-template-rows: none;
    grid-template-areas: "img" "title" "bars" "lb";
  }
}

/* bank: reorder ↑ ↓ */
.q-move { display: inline-flex; gap: 4px; flex: 0 0 auto; }
.q-move button {
  width: 30px; height: 30px; font-size: 1rem; font-weight: 800; line-height: 1;
  color: var(--fg-inv-soft); background: var(--ink-3); border-radius: var(--r-sm);
}
.q-move button:hover { color: #fff; background: var(--aqua); }

/* teacher login page */
.login-body { justify-content: center; align-items: center; }
.login-card {
  width: min(92vw, 380px);
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: clamp(28px, 5vw, 44px);
  background: var(--ink-2);
  border: 1px solid var(--ink-line);
  border-radius: var(--r-xl);
  box-shadow: var(--float-dark);
  text-align: center;
}
.login-card h1 { font-size: clamp(1.6rem, 5vw, 2rem); color: #fff; text-shadow: 2px 2px 0 var(--coral); }
.login-sub { color: var(--fg-inv-soft); margin-bottom: var(--s-2); }
.login-card input {
  padding: 16px 18px; font-size: 1.2rem; text-align: center;
  color: var(--fg-inv); background: var(--ink-3);
  border: 2px solid var(--ink-line); border-radius: var(--r-md);
}
.login-card input:focus { outline: none; border-color: var(--aqua); }
.login-card button {
  padding: 16px; font-family: var(--font-display); font-weight: 800; font-size: 1.2rem;
  color: #fff; background: var(--coral); border-radius: var(--r-md);
  box-shadow: 0 5px 0 var(--coral-deep);
}
.login-card button:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--coral-deep); }
.login-error { color: var(--wrong); font-weight: 700; }
.login-foot { margin-top: var(--s-3); color: var(--fg-inv-soft); font-size: .95rem; }
.login-foot a { color: var(--aqua); font-weight: 700; }
