/* =====================================================================
   The Platform: layout and components.
   Every colour, font and size comes from css/theme.css (loaded first).
   To change the look, edit theme.css, not this file.
   ===================================================================== */

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--fw-normal) var(--fs-body)/var(--line-height) var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
[hidden] { display: none !important; }
img { max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; margin: 0; text-wrap: balance; color: var(--ink); }
h1 { font-size: var(--fs-h1); font-weight: var(--fw-bold); }
h2 { font-size: var(--fs-h2); font-weight: var(--fw-bold); }
h3 { font-size: var(--fs-h3); font-weight: 600; }
p { margin: 0; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-small); }
.tiny { font-size: var(--fs-tiny); }
.lead { font-size: var(--fs-lead); color: var(--ink-2); max-width: 62ch; }
.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.stage-sec { display: grid; gap: clamp(12px, 2.4vh, 24px); align-content: start; }
.center { text-align: center; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
code, .kbd { font-family: var(--font-mono); font-size: .88em; background: var(--surface-2); padding: .1em .4em; border-radius: 6px; }

/* ------------------------------------------------------------------ layout */
.page { max-width: var(--page-width); margin: 0 auto; padding-inline: var(--gutter); padding-block: 28px 64px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.page.narrow { max-width: 880px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.page-head .stack { gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.stack.loose { gap: 20px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row.tight { gap: 6px; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.grid-3 { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.split { display: grid; gap: 24px; grid-template-columns: 290px minmax(0, 1fr); align-items: start; }
.split > aside { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; }
@media (max-width: 900px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split > aside { position: static; max-height: none; }
}

/* ------------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 10px var(--gutter);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 9px; font: 700 1.25rem/1 var(--font-display); color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand .logo {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--logo-bg); color: var(--logo-ink); font-size: 1.1rem;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2);
}
.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.topbar nav a { padding: 8px 11px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .92rem; }
.topbar nav a:hover { background: var(--surface-2); color: var(--ink); }
.topbar nav a.active { background: var(--brand-soft); color: var(--brand); }
.mode-badge { font-size: .78rem; font-weight: 700; padding: 5px 10px; border-radius: var(--radius-pill); white-space: nowrap; cursor: help; }
.mode-badge.demo { background: var(--warn-soft); color: var(--warn); }
.mode-badge.live { background: var(--ok-soft); color: var(--ok); }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 10px; font-size: 1.2rem; width: 42px; height: 40px; cursor: pointer; }
@media (max-width: 1080px) {
  .topbar { flex-wrap: wrap; }
  .nav-toggle { display: block; order: 2; }
  .brand { margin-right: auto; }
  .mode-badge { order: 1; }
  .topbar nav { display: none; order: 3; flex-basis: 100%; flex-direction: column; padding-bottom: 6px; }
  .topbar.open nav { display: flex; }
  .topbar nav a { padding: 12px; font-size: 1rem; }
}

/* ------------------------------------------------------------------ cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card.flat { box-shadow: none; }
.card.tight { padding: 14px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius); display: grid; gap: 10px; justify-items: center; }
.empty strong { color: var(--ink); font-family: var(--font-display); font-size: 1.15rem; }
.notice { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--ink); font-size: .92rem; display: flex; gap: 10px; align-items: flex-start; }
.notice.warn { background: var(--warn-soft); }
.notice.bad { background: var(--bad-soft); }
.notice.ok { background: var(--ok-soft); }

/* ------------------------------------------------------------------ buttons */
.btn {
  --bg: var(--surface); --fg: var(--ink); --bd: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 16px; border-radius: 12px;
  border: 1px solid var(--bd); background: var(--bg); color: var(--fg);
  font: 700 .95rem/1.1 var(--font-body); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .12s ease, background-color .15s ease, box-shadow .15s ease, filter .15s;
  user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.primary { --bg: var(--brand); --fg: var(--brand-ink); --bd: transparent; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); }
.btn.primary:hover { background: var(--brand-hover); }
.btn.accent { --bg: var(--accent); --fg: var(--accent-ink); --bd: transparent; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15); }
.btn.accent:hover { background: var(--accent-hover); }
.btn.success { --bg: var(--ok); --fg: var(--on-color); --bd: transparent; }
.btn.success:hover { filter: brightness(1.08); background: var(--ok); }
.btn.danger { --bg: transparent; --fg: var(--bad); --bd: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { --bg: transparent; --bd: transparent; }
.btn.lg { min-height: 54px; padding: 12px 24px; font-size: 1.08rem; border-radius: 14px; }
.btn.xl { min-height: 64px; padding: 14px 34px; font: 700 1.3rem/1 var(--font-display); border-radius: 16px; }
.btn.sm { min-height: 34px; padding: 6px 11px; font-size: .85rem; border-radius: 9px; }
.btn.icon { width: 42px; padding: 0; }
.btn.icon.sm { width: 34px; }
.btn.block { width: 100%; }
@media (max-width: 600px) { .btn { white-space: normal; max-width: 100%; text-align: center; } }

/* ------------------------------------------------------------------ forms */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 700; font-size: .88rem; color: var(--ink-2); }
.hint { font-size: .82rem; color: var(--muted); }
input[type="text"], input[type="number"], input[type="email"], input[type="password"], input[type="search"], input[type="tel"], input[type="datetime-local"], input:not([type]), select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--ink);
  font: 500 .96rem/1.4 var(--font-body);
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
input.invalid, select.invalid, textarea.invalid { border-color: var(--bad); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: .95rem; line-height: 1.35; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.form-grid > .field { align-content: start; } /* a message under one field must not stretch the inputs beside it */
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 7px 13px; border-radius: 9px; font-weight: 700; font-size: .88rem; color: var(--ink-2); }
.seg input:checked + span { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); }

/* ------------------------------------------------------------------ chips & pills */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font: 700 .84rem/1 var(--font-body); cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--radius-pill); font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.easy { background: var(--ok-soft); color: var(--ok); }
.pill.medium { background: var(--warn-soft); color: var(--warn); }
.pill.hard { background: var(--bad-soft); color: var(--bad); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill.st-submitted { background: var(--brand-soft); color: var(--brand); }
.pill.st-changes_requested { background: var(--warn-soft); color: var(--warn); }
.pill.st-approved { background: var(--ok-soft); color: var(--ok); }
.pill.st-rejected { background: var(--bad-soft); color: var(--bad); }
.count-badge { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 7px; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--muted); font-size: .75rem; font-weight: 700; }

/* ------------------------------------------------------------------ tables & tabs */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
.heat td.h { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--heat-5-ink); min-width: 58px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; padding: 10px 14px; font: 700 .95rem var(--font-body); color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ------------------------------------------------------------------ avatars */
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  font: 800 1rem/1 var(--font-display);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .14), 0 2px 0 rgba(0, 0, 0, .15);
}
.avatar.lg { width: 64px; height: 64px; font-size: 1.8rem; }
.avatar.xl { width: 104px; height: 104px; font-size: 3rem; }
.name-chip { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; }
.name-chip > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ question cards (bank, review) */
.qcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 10px; }
.qcard-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.qcard-head .id { font: 700 var(--fs-tiny) var(--font-mono); color: var(--muted); margin-right: auto; }
.qcard .qtext { font-weight: 600; font-size: 1.02rem; }
.qopts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.qopts li { display: flex; gap: 8px; align-items: flex-start; padding: 7px 10px; border-radius: 10px; background: var(--surface-2); font-size: .92rem; }
.qopts li .shape { flex: none; width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; color: var(--tile-ink, var(--on-color)); font-size: .72rem; }
.show-answers .qopts li.correct { background: var(--ok-soft); box-shadow: inset 0 0 0 2px var(--ok); }
.qcard .accepted, .qcard .expl { display: none; font-size: .9rem; }
.show-answers .qcard .accepted, .show-answers .qcard .expl { display: block; }
.qcard .expl { color: var(--ink-2); padding-left: 12px; border-left: 3px solid var(--line); }
/* a tile colour; --tile-ink is the text / symbol colour that goes with it */
.bg-a { background: var(--a) !important; --tile-ink: var(--a-ink); } .bg-b { background: var(--b) !important; --tile-ink: var(--b-ink); }
.bg-c { background: var(--c) !important; --tile-ink: var(--c-ink); } .bg-d { background: var(--d) !important; --tile-ink: var(--d-ink); }
.bg-e { background: var(--e) !important; --tile-ink: var(--e-ink); } .bg-f { background: var(--f) !important; --tile-ink: var(--f-ink); }

/* ------------------------------------------------------------------ bank tree */
.tree { display: grid; gap: 4px; font-size: .93rem; min-width: 0; overflow-wrap: anywhere; }
.tree details { border-radius: 10px; }
.tree summary { cursor: pointer; padding: 7px 8px; border-radius: 9px; font-weight: 700; list-style: none; display: flex; gap: 6px; align-items: center; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: "▸"; color: var(--muted); transition: transform .15s; width: 12px; }
.tree details[open] > summary::before { transform: rotate(90deg); }
.tree summary:hover { background: var(--surface-2); }
.tree .indent { padding-left: 14px; display: grid; gap: 2px; }
.tree a { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 9px; color: var(--ink-2); text-decoration: none; }
.tree a:hover { background: var(--surface-2); color: var(--ink); }
.tree a.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }

/* coverage bars */
.cov { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-2); min-width: 80px; }
.cov i { display: block; height: 100%; }
.cov .e { background: var(--ok); } .cov .m { background: var(--c); } .cov .h { background: var(--bad); }
td.gap { background: var(--bad-soft) !important; color: var(--bad); font-weight: 700; }

/* ------------------------------------------------------------------ toasts & errors */
#toasts { position: fixed; z-index: 200; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
.toast { background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toast-in .25s ease; transition: opacity .35s, transform .35s; }
.toast.ok { background: var(--ok); color: var(--on-color); }
.toast.bad { background: var(--bad); color: var(--on-color); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.fatal { background: var(--bad); color: var(--on-color); padding: 12px var(--gutter); font-weight: 600; position: relative; z-index: 300; }

/* =====================================================================
   HOME
   ===================================================================== */
.hero {
  position: relative; overflow: hidden; border-radius: 24px; color: var(--stage-ink);
  background:
    radial-gradient(1200px 400px at 85% -10%, var(--stage-glow), transparent 60%),
    linear-gradient(var(--stage-grid) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(90deg, var(--stage-grid) 1px, transparent 1px) 0 0 / 34px 34px,
    var(--stage);
  padding: clamp(26px, 5vw, 56px); box-shadow: inset 0 0 0 1px var(--stage-edge);
  display: grid; gap: 28px; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: center;
}
.hero h1 { color: var(--stage-ink); font-size: var(--fs-hero); font-weight: var(--fw-heavy); line-height: 1.02; }
.hero h1 em { font-style: normal; color: var(--stage-accent); }
.hero p { color: var(--stage-soft); font-size: 1.08rem; max-width: 50ch; }
.hero canvas.shapes { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: .55; }
.hero > * { position: relative; }
.join-box { background: var(--card); color: var(--card-ink); border-radius: 20px; padding: 22px; display: grid; gap: 12px; box-shadow: var(--shadow-lg); }
.join-box h2 { color: var(--card-ink); }
.join-box input { font: 800 1.9rem/1 var(--font-display); text-align: center; letter-spacing: .18em; min-height: 62px; color: var(--card-ink); background: var(--card); border-color: var(--card-line); }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; } }
.tile-link { display: grid; gap: 8px; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; transition: transform .15s, box-shadow .15s, border-color .15s; }
.tile-link:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--brand); }
.tile-link .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--tile-ink, var(--on-color)); font-size: 1.2rem; }
.tile-link h3 { font-size: 1.2rem; }
.tile-link p { color: var(--muted); font-size: .93rem; }
.stat-row { display: flex; flex-wrap: wrap; gap: 10px 28px; }
.stat-row div { display: grid; }
.stat-row b { font: 800 1.7rem/1 var(--font-display); color: var(--stage-accent); }
.stat-row span { color: var(--stage-muted); font-size: .85rem; }

/* =====================================================================
   HOST SETUP
   ===================================================================== */
.setup { display: grid; gap: 20px; grid-template-columns: 280px minmax(0, 1fr) 320px; align-items: start; }
.setup > .card { position: sticky; top: 84px; }
.setup > .picker { position: static; }
@media (max-width: 1180px) { .setup { grid-template-columns: 260px minmax(0, 1fr); } .setup > .settings { grid-column: 1 / -1; position: static; } }
@media (max-width: 820px) { .setup { grid-template-columns: 1fr; } .setup > .card { position: static; } }
.pick-list { display: grid; gap: 8px; }
.pick { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.pick:hover { border-color: var(--brand); }
.pick.on { border-color: var(--brand); background: var(--brand-soft); }
.pick input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); }
.pick .t { font-weight: 600; }
.pick .m { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.dock {
  position: sticky; bottom: 0; z-index: 30; margin-inline: calc(-1 * var(--gutter));
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
}
.dock .sel-count { font: 800 1.4rem/1 var(--font-display); color: var(--brand); }

/* =====================================================================
   GAME STAGE (host projector + student phone)
   ===================================================================== */
.stage, .play, .ad-slide {
  color: var(--stage-ink);
  background:
    radial-gradient(900px 480px at 50% -12%, var(--stage-glow), transparent 65%),
    linear-gradient(var(--stage-grid) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, var(--stage-grid) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(180deg, var(--stage), var(--stage-deep));
}
.stage { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; overflow: hidden; }
.stage h1, .stage h2, .stage h3, .play h1, .play h2, .play h3 { color: var(--stage-ink); }
.stage-bg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 120; }
.stage-bar {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: calc(12px + env(safe-area-inset-top, 0px)) clamp(12px, 2.5vw, 28px) 12px;
}
.stage-bar .pin-mini { font: 700 1rem/1 var(--font-display); background: var(--stage-chip); padding: 8px 14px; border-radius: var(--radius-pill); }
.stage-bar .pin-mini b { color: var(--stage-accent); letter-spacing: .08em; font-size: 1.15rem; }
.stage-bar .counter { font: 700 1.05rem/1 var(--font-display); padding: 8px 14px; border-radius: var(--radius-pill); background: var(--stage-chip); }
.sbtn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--stage-chip); color: var(--stage-ink); transition: background .15s, transform .12s;
}
.sbtn:hover { background: color-mix(in srgb, var(--stage-ink) 22%, transparent); }
.sbtn:active { transform: scale(.95); }
.sbtn svg { width: 20px; height: 20px; }
.sbtn.off { opacity: .55; }
.stage-main { position: relative; z-index: 1; flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; padding: 8px clamp(12px, 3vw, 40px) 24px; gap: clamp(12px, 2.4vh, 24px); }
.stage-main > * { width: min(100%, 1280px); }
.stage .btn.accent { font-family: var(--font-display); }

/* lobby */
.lobby-top { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
.join-card { background: var(--card); color: var(--card-ink); border-radius: var(--radius-lg); padding: clamp(16px, 2.5vw, 26px) clamp(18px, 3vw, 34px); box-shadow: var(--shadow-lg); display: flex; flex-wrap: wrap; align-items: center; gap: 12px 36px; }
.join-card .lbl { font: 700 .95rem/1.2 var(--font-body); color: var(--card-muted); }
.join-card .url { font: 700 clamp(1rem, 1.8vw, 1.35rem)/1.2 var(--font-display); color: var(--card-ink); word-break: break-all; }
.join-card .pin { font: 800 var(--fs-game-pin)/.9 var(--font-display); letter-spacing: .06em; color: var(--card-ink); font-variant-numeric: tabular-nums; }
.join-card .link-btn { align-self: flex-start; margin-top: 4px; --bg: var(--card-soft); --fg: var(--card-ink); --bd: var(--card-line); }
.join-card .link-btn:hover { background: var(--card-soft-hover); }
.qr-card { background: var(--card); border-radius: var(--radius-lg); padding: 14px 14px 10px; display: grid; place-items: center; align-content: center; gap: 6px; box-shadow: var(--shadow-lg); }
.qr-card canvas, .qr-card img { width: clamp(140px, 17vw, 240px) !important; height: auto !important; image-rendering: pixelated; }
.qr-cap { font: 700 .9rem/1 var(--font-body); color: var(--card-muted); }
/* optional auto-advance: seconds left + a bar filling along the bottom of the main button */
.stage-foot .btn.accent { position: relative; overflow: hidden; }
.stage-foot .btn.accent::after { content: ''; position: absolute; left: 0; bottom: 0; width: 100%; height: 4px; background: currentColor; opacity: .35; transform-origin: left; transform: scaleX(var(--auto-p, 0)); transition: transform 1s linear; }
.auto-tag { min-width: 1.9em; padding: 3px 7px; border-radius: var(--radius-pill); background: rgba(0, 0, 0, .14); font-size: .85em; font-variant-numeric: tabular-nums; text-align: center; }
@media (max-width: 720px) { .lobby-top { grid-template-columns: 1fr; } .qr-card { display: none; } }
.lobby-mid { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; justify-content: space-between; }
.player-count { display: flex; align-items: center; gap: 10px; font: 800 1.6rem/1 var(--font-display); }
.player-count span { display: grid; place-items: center; min-width: 58px; height: 58px; padding: 0 12px; border-radius: 16px; background: color-mix(in srgb, var(--stage-ink) 14%, transparent); font-size: 2rem; }
.players-cloud { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-content: flex-start; min-height: 120px; padding: 6px; }
.player-pop {
  display: inline-flex; align-items: center; gap: 9px; padding: 7px 16px 7px 7px; border-radius: var(--radius-pill);
  background: var(--card); color: var(--card-ink); font: 700 1.05rem/1 var(--font-display);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .18); cursor: pointer; animation: pop-in .45s cubic-bezier(.2, 1.6, .4, 1) both;
  border: 0;
}
.player-pop:hover { background: var(--kick-hover); text-decoration: line-through; }
.player-pop.offline { opacity: .5; }
@keyframes pop-in { from { transform: scale(.2) rotate(-8deg); opacity: 0; } }
.waiting-hint { text-align: center; color: var(--stage-muted); font-size: 1.1rem; }
.dots::after { content: ""; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* question */
.q-top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: clamp(10px, 2vw, 24px); align-items: center; }
.q-card { background: var(--card); color: var(--card-ink); border-radius: var(--radius-lg); padding: clamp(16px, 2.6vw, 30px); box-shadow: var(--shadow-lg); text-align: center; display: grid; gap: 12px; animation: drop-in .5s cubic-bezier(.2, 1.3, .4, 1) both; }
.q-card .q-meta { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.q-card .q-meta .pill { background: var(--card-soft); color: var(--card-ink-2); }
.q-text { font: 700 var(--fs-game-question)/1.18 var(--font-display); color: var(--card-ink); text-wrap: balance; }
.q-img { max-height: 30vh; justify-self: center; border-radius: 12px; }
@keyframes drop-in { from { transform: translateY(-24px) scale(.96); opacity: 0; } }
.timer {
  position: relative; width: clamp(74px, 9vw, 112px); aspect-ratio: 1; max-width: 100%;
  display: grid; place-items: center; font: 800 clamp(1.8rem, 3.6vw, 2.9rem)/1 var(--font-display); font-variant-numeric: tabular-nums;
}
.timer svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 9; }
.timer .track { stroke: color-mix(in srgb, var(--stage-ink) 16%, transparent); }
.timer .prog { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .25s linear, stroke .3s; }
.timer.urgent .prog { stroke: var(--a); }
.timer.urgent span { animation: pulse .5s ease-in-out infinite alternate; color: var(--urgent-ink); }
@keyframes pulse { to { transform: scale(1.14); } }
.answered-box { display: grid; justify-items: center; gap: 2px; min-width: 88px; }
.answered-box b { font: 800 clamp(1.8rem, 3.6vw, 2.9rem)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.answered-box span { font-size: .85rem; color: var(--stage-muted); font-weight: 700; }

.answers-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(8px, 1.4vw, 16px); }
.ans {
  position: relative; display: flex; align-items: center; gap: 14px; min-height: clamp(64px, 11vh, 120px);
  padding: 12px 18px; border-radius: 16px; border: 0; color: var(--tile-ink, var(--on-color)); text-align: left;
  font: 700 var(--fs-game-answer)/1.2 var(--font-display);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .2); transition: transform .15s, opacity .3s, filter .3s;
  animation: tile-in .45s cubic-bezier(.2, 1.3, .4, 1) both;
}
.ans:nth-child(2) { animation-delay: .06s; } .ans:nth-child(3) { animation-delay: .12s; } .ans:nth-child(4) { animation-delay: .18s; }
.ans:nth-child(5) { animation-delay: .24s; } .ans:nth-child(6) { animation-delay: .3s; }
@keyframes tile-in { from { transform: translateY(18px) scale(.94); opacity: 0; } }
.ans .shape { flex: none; font-size: 2.1em; width: 1.25em; text-align: center; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .2)); }
.ans .txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ans .mark { flex: none; width: 36px; height: 36px; border-radius: 50%; display: none; place-items: center; background: var(--card); }
.ans .mark svg { width: 22px; height: 22px; }
.ans.correct .mark { display: grid; color: var(--card-ok); }
.ans.dim { opacity: .28; filter: saturate(.4); }
.ans.correct { transform: scale(1.02); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .2), 0 0 0 4px var(--card); }
.ans-a { background: var(--a); --tile-ink: var(--a-ink); } .ans-b { background: var(--b); --tile-ink: var(--b-ink); } .ans-c { background: var(--c); --tile-ink: var(--c-ink); }
.ans-d { background: var(--d); --tile-ink: var(--d-ink); } .ans-e { background: var(--e); --tile-ink: var(--e-ink); } .ans-f { background: var(--f); --tile-ink: var(--f-ink); }
.type-answer-card { background: color-mix(in srgb, var(--stage-ink) 10%, transparent); border: 2px dashed color-mix(in srgb, var(--stage-ink) 30%, transparent); border-radius: 18px; padding: 22px; text-align: center; font: 700 1.3rem var(--font-display); }
.type-answer-card.revealed { background: var(--d); color: var(--d-ink); border: 0; }

/* result bars */
.bars { display: flex; justify-content: center; align-items: flex-end; gap: clamp(10px, 2.2vw, 28px); height: clamp(120px, 24vh, 230px); }
.bar { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; align-items: end; gap: 6px; width: clamp(56px, 9vw, 110px); height: 100%; }
.bar .cnt { font: 800 1.5rem/1 var(--font-display); }
.bar .fill { width: 100%; border-radius: 10px 10px 4px 4px; height: 0%; transition: height .9s cubic-bezier(.2, 1, .3, 1); box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .18); min-height: 6px; }
.bar .lab { font-size: 1.3rem; display: flex; align-items: center; gap: 4px; }
.bar.correct .lab::after { content: "✓"; font-weight: 800; color: var(--correct-glow); }
.bar.dim .fill { opacity: .35; }
.expl-box { background: color-mix(in srgb, var(--stage-ink) 10%, transparent); border-radius: 16px; padding: 14px 18px; color: var(--stage-soft); font-size: clamp(.95rem, 1.5vw, 1.15rem); display: flex; gap: 12px; align-items: flex-start; }
.expl-box b { color: var(--stage-accent); }
.expl-box svg, .notice svg { width: 24px; height: 24px; flex: none; }
.expl-box svg { color: var(--accent); }
.revealed .q-top { grid-template-columns: minmax(0, 1fr) auto; }
.stage-main { overflow-x: hidden; }
.shape svg { display: block; width: 1em; height: 1em; fill: currentColor; }
.bar .lab svg { width: 1.1em; height: 1.1em; fill: currentColor; }

/* leaderboard rows */
.lb-title { text-align: center; font: 800 var(--fs-game-title)/1 var(--font-display); }
.lb-list { display: grid; gap: 10px; width: min(100%, 860px) !important; justify-self: center; }
.lb-row {
  display: grid; grid-template-columns: 44px auto minmax(0, 1fr) auto auto; align-items: center; gap: 14px;
  background: var(--card); color: var(--card-ink); border-radius: 16px; padding: 10px 18px; box-shadow: 0 5px 0 rgba(0, 0, 0, .2);
  font: 700 clamp(1.05rem, 2vw, 1.5rem)/1.1 var(--font-display);
}
.lb-row .rk { font-size: 1.3em; color: var(--card-muted); text-align: center; }
.lb-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .sc { font-variant-numeric: tabular-nums; }
.lb-row .delta { font-size: .72em; color: var(--card-ok); min-width: 64px; text-align: right; }
.lb-row .streak { display: inline-flex; align-items: center; gap: 2px; font-size: .7em; color: var(--streak); }
.lb-row .streak svg { width: 18px; height: 18px; }
.lb-row.top1 { background: linear-gradient(90deg, var(--leader-row), var(--card)); }

/* podium */
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: clamp(8px, 2vw, 22px); width: min(100%, 900px) !important; justify-self: center; min-height: 52vh; }
.pod { display: grid; justify-items: center; gap: 10px; text-align: center; }
.pod .who { display: grid; justify-items: center; gap: 6px; opacity: 0; transform: translateY(20px); transition: all .6s cubic-bezier(.2, 1.4, .4, 1); }
.pod .who .nm { font: 800 clamp(1rem, 2.2vw, 1.6rem)/1.1 var(--font-display); }
.pod .who .sc { color: var(--stage-soft); font-weight: 700; font-variant-numeric: tabular-nums; }
.pod .step { width: 100%; border-radius: 16px 16px 0 0; display: grid; place-items: start center; padding-top: 14px; font: 800 clamp(2rem, 5vw, 4rem)/1 var(--font-display); color: rgba(0, 0, 0, .35); height: 0; transition: height .9s cubic-bezier(.2, 1, .3, 1); box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .12); }
.pod.p1 .step { background: linear-gradient(var(--gold-1), var(--gold-2)); }
.pod.p2 .step { background: linear-gradient(var(--silver-1), var(--silver-2)); }
.pod.p3 .step { background: linear-gradient(var(--bronze-1), var(--bronze-2)); }
.podium.go .pod .who { opacity: 1; transform: none; }
.podium.go .p1 .step { height: 34vh; } .podium.go .p2 .step { height: 25vh; } .podium.go .p3 .step { height: 18vh; }
.podium.go .p3 .who { transition-delay: .4s; } .podium.go .p2 .who { transition-delay: 1.1s; } .podium.go .p1 .who { transition-delay: 2.2s; }
.podium.go .p3 .step { transition-delay: .1s; } .podium.go .p2 .step { transition-delay: .8s; } .podium.go .p1 .step { transition-delay: 1.8s; }
.crown { width: 44px; height: 44px; color: var(--accent); filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .25)); }

/* countdown overlay */
.countdown { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; align-content: center; gap: 18px; text-align: center; background: var(--stage-overlay); backdrop-filter: blur(6px); }
.countdown .cd-q { font: 700 clamp(1.1rem, 2.4vw, 1.6rem) var(--font-display); color: var(--stage-soft); }
.countdown .cd-type { display: inline-flex; gap: 8px; align-items: center; font: 800 clamp(1.6rem, 4vw, 2.8rem) var(--font-display); }
.countdown .cd-num { display: grid; place-items: center; width: clamp(120px, 20vw, 190px); aspect-ratio: 1; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font: 800 clamp(4rem, 10vw, 7rem)/1 var(--font-display); box-shadow: 0 10px 0 rgba(0, 0, 0, .25); animation: cd-pop .9s ease both; }
@keyframes cd-pop { 0% { transform: scale(.3); opacity: 0; } 25% { transform: scale(1.12); opacity: 1; } 45% { transform: scale(1); } 100% { transform: scale(1); } }

.stage-foot { position: relative; z-index: 2; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: center; padding: 10px clamp(12px, 2.5vw, 28px) calc(14px + env(safe-area-inset-bottom, 0px)); }
.stage-foot .note { margin-right: auto; color: var(--stage-muted); font-weight: 600; }

/* =====================================================================
   STUDENT PLAY (phone first)
   ===================================================================== */
body.play-body { background: var(--stage-deep); }
.play { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.play-top { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; background: var(--stage-shade); }
.play-top .name-chip { color: var(--stage-ink); }
.play-top .score { margin-left: auto; font: 800 1.2rem/1 var(--font-display); background: color-mix(in srgb, var(--stage-ink) 14%, transparent); padding: 8px 14px; border-radius: var(--radius-pill); font-variant-numeric: tabular-nums; }
.play-main { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 18px; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); text-align: center; }
.play-main > * { width: min(100%, 520px); }
.play-card { background: var(--card); color: var(--card-ink); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-lg); display: grid; gap: 14px; text-align: left; animation: drop-in .45s cubic-bezier(.2, 1.3, .4, 1) both; }
.play-card h2 { color: var(--card-ink); }
.play-card label { color: var(--card-ink-2); }
.play-card select, .play-card input, .join-box select { background-color: var(--card); color: var(--card-ink); border-color: var(--card-line); color-scheme: light; }
.play-card .btn:not(.accent), .join-box .btn:not(.accent) { --bg: var(--card-soft); --fg: var(--card-ink); --bd: var(--card-line); }
.play-card .btn:not(.accent):hover { background: var(--card-soft-hover); }
.play-logo { display: inline-flex; align-items: center; gap: 10px; font: 800 1.7rem/1 var(--font-display); justify-content: center; }
.play-logo .logo { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); }
.pin-input { font: 800 2.2rem/1 var(--font-display) !important; text-align: center; letter-spacing: .2em; min-height: 70px !important; }
.name-preview { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 16px; background: var(--card-soft); }
.name-preview .nm { font: 800 1.45rem/1.1 var(--font-display); color: var(--card-ink); }
.name-selects { display: grid; grid-template-columns: 1fr 1fr 90px; gap: 10px; }
@media (max-width: 380px) { .name-selects { grid-template-columns: 1fr 1fr; } .name-selects .field:last-child { grid-column: 1 / -1; } }
.big-msg { display: grid; gap: 10px; justify-items: center; }
.big-msg h1 { font-size: var(--fs-phone-title); font-weight: var(--fw-heavy); }
.big-msg p { color: var(--stage-soft); font-size: 1.1rem; }
.bounce { animation: bounce 1.2s ease-in-out infinite; }
@keyframes bounce { 50% { transform: translateY(-10px); } }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 6px solid color-mix(in srgb, var(--stage-ink) 20%, transparent); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.play-main > section.answer-sec { flex: 1; display: flex; flex-direction: column; gap: 12px; width: min(100%, 900px); }
.answer-body { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.answer-body .pad { flex: 1; }
.type-form { display: grid; gap: 12px; }
.type-form input { font: 700 1.5rem/1.2 var(--font-display) !important; min-height: 68px !important; text-align: center; background: var(--card) !important; color: var(--card-ink) !important; border-radius: 16px !important; }
/* Answer pad on students' devices.
   Phones: one wide row per answer (shape, then text). Rows share the free height but never grow past a cap,
   so tiles stay wide instead of tall and narrow. True/False: two taller rows. Shapes only: 2 x 2 near-square tiles.
   Tablets and landscape: 2 columns. */
.pad { flex: 1; width: 100% !important; max-width: 900px !important; display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(68px, 132px); gap: 10px; align-content: center; }
.pad .ans { min-height: 0; gap: 14px; padding: 10px 16px; text-align: left; font-size: var(--fs-phone-answer); cursor: pointer; }
.pad .ans .shape { font-size: clamp(2.8rem, 14vw, 4rem); width: 1.15em; }
.pad .ans .txt { flex: 1; }
.pad.two { grid-auto-rows: minmax(96px, 190px); }
.pad.two .ans { font-size: clamp(1.3rem, 6vw, 1.75rem); }
.pad.two .ans .shape { font-size: clamp(3.2rem, 16vw, 4.4rem); }
.pad.no-text { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(110px, 200px); }
.pad.no-text .ans { justify-content: center; }
.pad.no-text .ans .shape { font-size: clamp(4rem, 22vw, 6rem); width: auto; }
.pad.no-text .ans .txt { display: none; }
@media (min-width: 600px) {
  .pad { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(96px, 200px); }
}
.pad .ans:active { transform: scale(.97); }
.pad .ans.sel { box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .2), 0 0 0 5px var(--card); transform: scale(.97); }
.pad .ans.sel .mark { display: grid; color: var(--card-ink); width: 30px; height: 30px; }
.pad.no-text .ans.sel .mark { position: absolute; top: 8px; right: 8px; }
.play-q { background: var(--card); color: var(--card-ink); border-radius: 16px; padding: 12px 16px; font: 700 var(--fs-phone-question)/1.25 var(--font-display); text-align: center; }
.play-timerbar { height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--stage-ink) 15%, transparent); overflow: hidden; }
.play-timerbar i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; transition: transform .25s linear; }
.play-timerbar.urgent i { background: var(--a); }

.result { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; align-content: center; gap: 14px; padding: 24px; text-align: center; color: var(--result-ink); animation: fade-in .3s ease both; }
.result.good { background: radial-gradient(circle at 50% 30%, var(--result-good-1), var(--result-good-2)); }
.result.bad { background: radial-gradient(circle at 50% 30%, var(--result-bad-1), var(--result-bad-2)); }
.result.none { background: radial-gradient(circle at 50% 30%, var(--result-none-1), var(--result-none-2)); }
.result .icon-big { width: 110px; height: 110px; border-radius: 50%; background: var(--card); display: grid; place-items: center; animation: pop-in .55s cubic-bezier(.2, 1.6, .4, 1) both; }
.result .icon-big svg { width: 64px; height: 64px; }
.result.good .icon-big { color: var(--result-good-2); } .result.bad .icon-big { color: var(--result-bad-2); } .result.none .icon-big { color: var(--result-none-2); }
.result h1 { font-size: clamp(2.4rem, 11vw, 3.6rem); font-weight: var(--fw-heavy); color: var(--result-ink); }
.result .pts { font: 800 1.6rem/1 var(--font-display); background: rgba(0, 0, 0, .18); padding: 10px 20px; border-radius: var(--radius-pill); font-variant-numeric: tabular-nums; }
.result .streak-tag { display: inline-flex; align-items: center; gap: 6px; font: 700 1.1rem var(--font-display); background: rgba(255, 255, 255, .18); padding: 8px 14px; border-radius: var(--radius-pill); }
.result .streak-tag svg { width: 22px; height: 22px; color: var(--streak-flame); }
.result .answer-was { max-width: 420px; color: rgba(255, 255, 255, .92); font-size: 1rem; }
.result .rank-line { font: 700 1.2rem var(--font-display); color: rgba(255, 255, 255, .95); }
@keyframes fade-in { from { opacity: 0; } }
.medal { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; font: 800 3.4rem/1 var(--font-display); color: var(--medal-ink); box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .15), 0 8px 0 rgba(0, 0, 0, .25); animation: pop-in .6s cubic-bezier(.2, 1.6, .4, 1) both; }
.medal.m1 { background: linear-gradient(var(--gold-1), var(--gold-2)); } .medal.m2 { background: linear-gradient(var(--silver-1), var(--silver-2)); } .medal.m3 { background: linear-gradient(var(--bronze-1), var(--bronze-2)); }
.medal.mx { background: linear-gradient(var(--medal-other-1), var(--medal-other-2)); color: var(--on-color); }
.conn-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 150; background: var(--a); color: var(--a-ink); text-align: center; padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 6px; font-weight: 700; }

/* =====================================================================
   LEADERBOARD PAGE
   ===================================================================== */
.board-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; }
.board-podium .bp { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 12px; display: grid; justify-items: center; gap: 6px; text-align: center; }
.board-podium .bp.first { padding-block: 26px; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.board-podium .bp .medal { width: 54px; height: 54px; font-size: 1.5rem; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .15); animation: none; }
.board-podium .bp .nm { font: 800 1.1rem/1.1 var(--font-display); }
.board-podium .bp .sc { font: 800 1.6rem/1 var(--font-display); color: var(--brand); }
@media (max-width: 560px) { .board-podium { grid-template-columns: 1fr; } .board-podium .bp.first { order: -1; } }
.rank-cell { font: 800 1.1rem var(--font-display); color: var(--muted); }

/* =====================================================================
   REVIEW / ADMIN
   ===================================================================== */
.queue { display: grid; gap: 8px; }
.queue-item { display: grid; gap: 6px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; color: var(--ink); font: inherit; }
.queue-item:hover { border-color: var(--brand); }
.queue-item.active { border-color: var(--brand); background: var(--brand-soft); }
.queue-item .t { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.checklist { display: grid; gap: 8px; }
.history { display: grid; gap: 8px; font-size: .9rem; }
.history div { padding-left: 12px; border-left: 3px solid var(--line); }
.opt-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.opt-row .shape { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--tile-ink, var(--on-color)); font-weight: 800; }
.opt-row .check { font-size: .85rem; white-space: nowrap; }
.preview-phone { background: var(--stage); border-radius: 22px; padding: 14px; display: grid; gap: 10px; }
.preview-phone .play-q { font-size: 1rem; }
.preview-phone .pad { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; gap: 8px; }
.preview-phone .ans { min-height: 54px; padding: 8px 12px; font-size: .95rem; animation: none; }
.preview-phone .ans .shape { font-size: 2rem; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 30px 18px; text-align: center; display: grid; gap: 10px; justify-items: center; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.map-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.row-err td { background: var(--bad-soft) !important; }
.row-warn td { background: var(--warn-soft) !important; }
.sum-tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.sum-tiles div { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; display: grid; gap: 2px; }
.sum-tiles b { font: 800 1.6rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.sum-tiles span { font-size: .82rem; color: var(--muted); font-weight: 600; }

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

/* two-column work pages (suggest, review) */
.two-col { display: grid; gap: 24px; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
.sticky-side { position: sticky; top: 84px; }
@media (max-width: 960px) { .two-col { grid-template-columns: 1fr; } .sticky-side { position: static; } }
.sim { display: grid; gap: 4px; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); font-size: .92rem; }
.sim b { color: var(--warn); font-size: .8rem; }
.mine-item { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.mine-item .t { font-weight: 600; font-size: .93rem; }

/* icon sizing inside components */
.tile-link .ico svg { width: 24px; height: 24px; }
.qopts li .shape svg { width: 19px; height: 19px; }
.opt-row .shape svg { width: 26px; height: 26px; }
.drop > span:first-child svg { width: 100%; height: 100%; }
td.gap { white-space: nowrap; }
td.gap a { color: inherit; text-decoration: none; display: block; }
td.gap a:hover { text-decoration: underline; }
.icon-inline svg, .notice > svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }

/* =====================================================================
   INSIGHTS
   ===================================================================== */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filter-bar .field { flex: 1 1 150px; max-width: 220px; }
.findings { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.findings li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; align-items: start; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); line-height: 1.45; }
.findings li svg { width: 22px; height: 22px; margin-top: 1px; }
.findings li.crit svg { color: var(--status-critical); }
.findings li.warn svg { color: var(--status-warning); }
.findings li.info svg { color: var(--brand); }
.findings li.good svg { color: var(--status-good); }
.barlist { display: grid; gap: 2px; }
.bl-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(80px, 1fr) 46px; gap: 12px; align-items: center; padding: 7px 8px; border-radius: 10px; }
.bl-row:hover { background: var(--surface-2); }
.bl-row.head { margin-top: 6px; }
.bl-row.head .t { font-weight: 700; }
.bl-row.low { opacity: .55; }
.bl-label { min-width: 0; display: grid; gap: 2px; font-size: .9rem; }
.bl-label .t { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bl-label .s { font-size: .76rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.bl-track { position: relative; height: 12px; background: var(--viz-track); border-radius: 0 4px 4px 0; }
.bl-track i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--viz-bar); border-radius: 0 4px 4px 0; transition: width .6s cubic-bezier(.2, 1, .3, 1); }
.bl-track .target { position: absolute; top: -4px; bottom: -4px; border-left: 2px dashed var(--viz-target); }
.bl-val { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.barlist.compact .bl-row { grid-template-columns: minmax(0, 1fr) 44px; row-gap: 6px; }
.barlist.compact .bl-label { grid-column: 1 / -1; }
.status { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.status svg { width: 14px; height: 14px; }
.status.crit svg { color: var(--status-critical); }
.status.warn svg { color: var(--status-warning); }
.heat-legend { display: flex; flex-wrap: wrap; gap: 2px; font-size: .7rem; font-weight: 700; }
.heat-legend span { padding: 3px 6px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.heat-pill { display: inline-block; min-width: 48px; padding: 3px 8px; border-radius: 6px; font-weight: 800; text-align: center; }
.table tr.avg-row td { border-top: 2px solid var(--line); }
td.h.muted { color: var(--muted) !important; }
@media (max-width: 560px) {
  .bl-row, .barlist.compact .bl-row { grid-template-columns: minmax(0, 1fr) 44px; }
  .bl-row .bl-label { grid-column: 1 / -1; }
}
.btn.on-stage { --bg: var(--stage-chip); --fg: var(--stage-ink); --bd: color-mix(in srgb, var(--stage-ink) 25%, transparent); }
.btn.on-stage:hover { background: color-mix(in srgb, var(--stage-ink) 20%, transparent); }
.announce { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 10px var(--gutter); background: var(--accent); color: var(--accent-ink); font-weight: 700; text-align: center; }
.announce svg { width: 18px; height: 18px; flex: none; }
.play-body .announce { position: relative; z-index: 5; }

/* =====================================================================
   ADMIN PORTAL
   ===================================================================== */
.admin-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 24px; align-items: start; }
.admin-nav { position: sticky; top: 84px; display: grid; gap: 2px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.admin-nav button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink-2); font: 700 .93rem var(--font-body); text-align: left; cursor: pointer; }
.admin-nav button svg { width: 18px; height: 18px; flex: none; }
.admin-nav button .count-badge { margin-left: auto; }
.admin-nav button .count-badge:empty { display: none; }
.admin-nav button:hover { background: var(--surface-2); color: var(--ink); }
.admin-nav button.active { background: var(--brand-soft); color: var(--brand); }
.admin-main { min-width: 0; }
@media (max-width: 960px) {
  .admin-layout { grid-template-columns: minmax(0, 1fr); }
  .admin-nav { position: static; display: flex; overflow-x: auto; }
  .admin-nav button { white-space: nowrap; }
}
.kpis { grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
.todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.todo li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: .92rem; }
.todo li svg { width: 20px; height: 20px; }
.todo li.crit svg { color: var(--status-critical); }
.todo li.warn svg { color: var(--status-warning); }
.todo li.info svg { color: var(--brand); }
.todo li.ok svg { color: var(--status-good); }
.qline { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 520px; }
.table tr.retired td { opacity: .6; }
.code-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px auto; gap: 8px; align-items: center; max-width: 520px; }
.drawer { position: fixed; inset: 0; z-index: 90; display: flex; justify-content: flex-end; background: rgba(8, 14, 45, .5); }
.drawer-panel { width: min(100%, 760px); height: 100%; overflow: auto; background: var(--paper); padding: 20px var(--gutter) 40px; box-shadow: var(--shadow-lg); display: grid; gap: 16px; align-content: start; animation: slide-in .25s ease; }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }

/* =====================================================================
   Accounts: top-bar account menu, notification bell, sign-in pages, dashboards
   ===================================================================== */
.user-box { display: flex; align-items: center; gap: 8px; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 700; font-size: .9rem; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { border-color: var(--brand); }
.menu[open] > summary { border-color: var(--brand); background: var(--brand-soft); }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: min(88vw, 300px); max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px); overflow-y: auto; display: grid; gap: 4px; padding: 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-lg); }
.menu-panel a, .menu-panel button { display: block; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font: 600 .92rem var(--font-body); text-align: left; background: none; border: 0; cursor: pointer; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); }
.menu-panel hr { margin: 6px 0; }
.role-pill { justify-self: start; }
.me-av { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font: 800 .78rem/1 var(--font-display); flex: none; }
.me-av.lg { width: 52px; height: 52px; font-size: 1.1rem; }
.me-name { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bell > summary { padding: 7px; position: relative; }
.bell > summary svg { width: 18px; height: 18px; }
.bell-n { position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--bad); color: var(--on-color); font: 800 .7rem/19px var(--font-body); text-align: center; }
.bell-panel { width: min(92vw, 380px); gap: 8px; }
.bell-list { display: grid; gap: 2px; max-height: 60vh; overflow: auto; }
.notice-item { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; align-items: start; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-size: .9rem; line-height: 1.35; }
.notice-item:hover { background: var(--surface-2); }
.notice-item.unread { background: var(--brand-soft); }
.notice-item.unread .stack > span:first-child { font-weight: 700; }
.ni-ico { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); color: var(--brand); }
.ni-ico svg { width: 16px; height: 16px; }
.ni-ico.st-approved { background: var(--ok-soft); color: var(--ok); }
.ni-ico.st-rejected { background: var(--bad-soft); color: var(--bad); }
.ni-ico.st-changes_requested { background: var(--warn-soft); color: var(--warn); }
@media (max-width: 1080px) {
  .user-box { order: 1; }
  .me-name { display: none; }
  .menu > summary { padding: 4px; }
}
@media (max-width: 600px) {
  /* the top bar (sticky, so it holds them) anchors the menus: full width under it, whatever the button's position */
  .user-box .menu { position: static; }
  .user-box .menu-panel, .user-box .bell-panel { left: 10px; right: 10px; top: calc(100% + 4px); width: auto; }
}
@media (max-width: 520px) {
  .mode-badge, .user-box .signup-link { display: none; } /* keeps the top bar on one row (sign-up is on the home and sign-in pages) */
}

/* sign-in and registration */
.auth-page { max-width: 1060px; }
.auth-layout { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr) minmax(0, 460px); align-items: start; }
.auth-intro { padding-top: 12px; }
.auth-intro h1 { font-size: var(--fs-h1); }
.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.auth-points li { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: start; }
.auth-points li > span > svg { display: block; width: 40px; height: 40px; padding: 9px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); }
.auth-points b { display: block; font-family: var(--font-display); }
.auth-points span { color: var(--muted); font-size: .93rem; }
.auth-card { padding: clamp(18px, 3vw, 28px); }
.auth-ico svg, .gate-ico svg { width: 52px; height: 52px; padding: 12px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); }
.auth-ico.bad svg { background: var(--bad-soft); color: var(--bad); }
.field-msg { display: flex; align-items: flex-start; gap: 6px; font-size: .84rem; color: var(--muted); }
.field-msg svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.field-msg.ok { color: var(--ok); }
.field-msg.bad { color: var(--bad); font-weight: 600; }
.field-msg.warn { color: var(--warn); font-weight: 600; }
/* Admin portal > Users & access > Create an account */
.pass-row { flex-wrap: nowrap; }
.pass-row input { flex: 1 1 auto; min-width: 0; font-family: var(--font-mono, ui-monospace, Consolas, monospace); letter-spacing: .04em; }
.check-row { display: flex; align-items: flex-start; gap: 8px; font-size: .9rem; color: var(--ink-2); cursor: pointer; }
.check-row input { margin-top: 3px; flex: none; }
.cred-table code.cred-pass { font-size: .95rem; letter-spacing: .04em; user-select: all; white-space: nowrap; }
.cred-table .cred-err { color: var(--bad); font-weight: 600; font-size: .86rem; }
#caBulk { width: 100%; min-height: 120px; font: inherit; }
.form-err { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bad-soft); color: var(--ink); font-size: .9rem; }
.me-card { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: var(--radius); background: var(--surface-2); }
.gate-card { max-width: 640px; }
@media (max-width: 820px) { .auth-layout { grid-template-columns: 1fr; } .auth-intro { order: 2; } }

/* dashboards */
.admin-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--ink-2); font: 700 .93rem var(--font-body); text-decoration: none; }
.admin-nav a svg { width: 18px; height: 18px; flex: none; }
.admin-nav a:hover { background: var(--surface-2); color: var(--ink); }
.admin-nav a .count-badge { margin-left: auto; }
.admin-nav a .count-badge:empty { display: none; }
.admin-nav .nav-sep { padding: 12px 12px 4px; font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.count-badge.hot:not(:empty) { background: var(--bad); color: var(--on-color); }
.role-card { display: grid; gap: 10px; border-top: 4px solid var(--brand); }
.role-card .row svg { width: 22px; height: 22px; color: var(--brand); }
.big-n { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.big-n b { font: 800 2.4rem/1 var(--font-display); }
.big-n span { color: var(--ink-2); font-weight: 600; }
.mini-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.mini-tiles div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; display: grid; }
.mini-tiles b { font: 800 1.35rem/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.mini-tiles span { font-size: .75rem; color: var(--muted); font-weight: 600; }
@media (max-width: 480px) { .mini-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.first-steps { display: grid; gap: 12px; border: 2px dashed var(--brand); box-shadow: none; }
.first-steps ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.first-steps .btn { justify-self: start; }
.lo-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.lo-row:last-child { border-bottom: 0; }
.lo-row .heat-pill { text-align: center; }
.act-cell { text-align: right; }
.act-cell .btn { margin-left: 4px; }
.act-cell .btn svg { width: 15px; height: 15px; }
.users-table select { min-height: 34px; padding: 4px 8px; }
.loc-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
@media (max-width: 520px) { .topbar { gap: 10px; } .mode-badge.live { display: none; } }

/* ================================================================== CHARTS (js/charts.js) */
.chart { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font-body); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--viz-bar); transition: opacity .15s; }
.chart .bar:focus { outline: none; stroke: var(--focus); stroke-width: 2; }
.chart .hit { fill: transparent; }
.chart:has(.hit:hover) .bar { opacity: .55; }
.chart .hit:hover + .bar, .chart .bar:has(+ .hit:hover) { opacity: 1; }
.chart .target { stroke: var(--viz-target); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .target-lab { fill: var(--viz-target); font-size: 11px; font-weight: 700; }
.chart .trend-line { fill: none; stroke: var(--viz-bar); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--viz-bar); stroke: var(--surface); stroke-width: 2; cursor: default; }
.chart .dot:hover, .chart .dot:focus { r: 6.5; outline: none; }
.chart .whisker { stroke: var(--ink-2); stroke-width: 1.5; }
.chart .boxfill { fill: color-mix(in srgb, var(--viz-bar) 22%, var(--surface)); stroke: var(--viz-bar); stroke-width: 1.5; }
.chart .boxfill:focus { outline: none; stroke-width: 2.5; }
.chart .median { stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.chart .mean { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.chart-tip { position: fixed; z-index: 90; pointer-events: none; max-width: 280px; padding: 8px 10px; border-radius: 10px; background: var(--ink); color: var(--surface); font-size: .8rem; line-height: 1.35; box-shadow: var(--shadow-lg); }
.chart-tip b { font-weight: 800; }
.box-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.box-legend span { display: inline-flex; align-items: center; gap: 6px; }
.box-legend i { display: inline-block; width: 14px; height: 10px; }
.box-legend .lg-box { background: color-mix(in srgb, var(--viz-bar) 22%, var(--surface)); border: 1.5px solid var(--viz-bar); border-radius: 3px; }
.box-legend .lg-med { width: 3px; height: 14px; background: var(--ink); border-radius: 2px; }
.box-legend .lg-mean { width: 9px; height: 9px; border: 1.5px solid var(--ink); transform: rotate(45deg); }
.box-legend .lg-wh { height: 0; border-top: 1.5px solid var(--ink-2); }

.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(90px, 38%) 44px; gap: 10px; align-items: center; border-radius: 8px; padding: 2px 4px; }
.hbar:hover, .hbar:focus-visible { background: var(--surface-2); outline: none; }
.hb-label { font-size: .86rem; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.hb-label small { display: block; color: var(--muted); font-size: .75rem; }
.hb-track { position: relative; height: 12px; background: var(--viz-track); border-radius: 0 4px 4px 0; }
.hb-track i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; transition: width .5s cubic-bezier(.2, 1, .3, 1); }
.hb-target { position: absolute; top: -4px; bottom: -4px; border-left: 2px dashed var(--viz-target); }
.hb-val { text-align: right; font-weight: 800; font-size: .88rem; }
@media (max-width: 480px) { .hbar { grid-template-columns: minmax(0, 1fr) 44px; } .hb-track { grid-column: 1 / -1; grid-row: 2; } }

.stat-tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1180px) { .stat-tiles b { font-size: 1.3rem; } }
@media (max-width: 760px) { .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sum-tiles .hl { background: var(--brand-soft); }
.sum-tiles .hl b { color: var(--brand); }

/* ================================================================== SELF-PACED: status, monitor, player progress */
.state-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: var(--radius-pill); font-size: .78rem; font-weight: 800; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.state-pill:empty { display: none; }
.state-pill.st-scheduled { background: var(--brand-soft); color: var(--brand); }
.state-pill.st-open { background: var(--ok-soft); color: var(--ok); }
.state-pill.st-open::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse-dot 1.6s ease-in-out infinite; }
.state-pill.st-closed { background: var(--warn-soft); color: var(--warn); }
.state-pill.st-ended { background: var(--surface-2); color: var(--ink-2); }
@keyframes pulse-dot { 50% { opacity: .35; } }
.mon-state { align-items: flex-end; text-align: right; }
@media (max-width: 600px) { .mon-state { align-items: flex-start; text-align: left; } } /* under the title on a phone */
.mon-join { display: flex; flex-wrap: wrap; gap: 16px 28px; align-items: center; justify-content: space-between; }
.mj-url { font: 800 clamp(1.05rem, 2.6vw, 1.5rem)/1.2 var(--font-display); color: var(--brand); overflow-wrap: anywhere; }
.mon-qr { display: grid; }
.mon-qr[hidden] { display: none; }
.mon-grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 960px) { .mon-grid { grid-template-columns: minmax(0, 1fr); } }
.mon-actions { align-items: flex-end; }
.mon-actions .field { min-width: min(100%, 230px); }
.mon-table td { vertical-align: middle; }
.mon-table .rank-cell { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
div.prog { height: 10px; border-radius: 0 4px 4px 0; background: var(--viz-track); overflow: hidden; }
div.prog i { display: block; height: 100%; background: var(--viz-bar); border-radius: 0 4px 4px 0; transition: width .5s cubic-bezier(.2, 1, .3, 1); }
div.prog i.done { background: var(--ok); }

.sp-prog { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; font-size: .82rem; font-weight: 700; color: color-mix(in srgb, var(--stage-ink) 85%, transparent); }
.sp-dots { display: flex; flex-wrap: wrap; gap: 4px; }
.sp-dots i { width: 8px; height: 8px; border-radius: 50%; background: color-mix(in srgb, var(--stage-ink) 22%, transparent); }
.sp-dots i.done { background: color-mix(in srgb, var(--stage-ink) 75%, transparent); }
.sp-dots i.now { background: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--stage-ink) 35%, transparent); }

.mode-seg span { padding: 8px 16px; }

/* ================================================================== Arabic and English side by side
   Each paragraph, cell and text field takes its direction from its own first letter (Arabic → right to left,
   aligned right; English → left to right), like dir="auto", without changing the page layout. */
p, li, td, th, h1, h2, h3, summary, label, .t, .txt, .q-text, .play-q, .nm, .name-chip, .hb-label, .expl, .expl-box,
.answer-was, .notice-item, .qopts li, .empty strong, .empty span,
input[type="text"], input[type="search"], input:not([type]), textarea { unicode-bidi: plaintext; text-align: start; }
.play-q, .q-text, .empty strong, .empty span, .big-msg p, .big-msg h1, .big-msg h2, .result p, .result h2 { text-align: center; }

/* ================================================================== account: optional "about me" fields */
.about-opt { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.about-opt[open] { padding-bottom: 16px; }
.about-opt > summary { cursor: pointer; font-weight: 700; }
.about-opt > summary .muted { font-weight: 500; font-size: .86rem; }
.about-opt[open] > summary { margin-bottom: 12px; }
.about-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px 16px; margin: 0; min-width: 0; }
.about-box > legend { font-weight: 700; padding: 0 6px; }
.subj-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.subj-chip { position: relative; }
.subj-chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.subj-chip span {
  display: inline-flex; align-items: center; padding: 6px 12px; border-radius: var(--radius-pill); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font: 700 .84rem/1.2 var(--font-body); transition: all .15s;
}
.subj-chip:hover span { border-color: var(--brand); }
.subj-chip input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.subj-chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.subj-add { margin-top: 4px; }
.subj-add input { flex: 1 1 200px; min-width: 0; }

/* ================================================================== in-page yes / no box (TP.ask, used where confirm() is blocked) */
.ask { position: fixed; inset: 0; z-index: 140; display: grid; place-items: center; padding: 16px; background: var(--stage-overlay); backdrop-filter: blur(4px); }
.ask-card { width: min(100%, 460px); display: grid; gap: 18px; padding: 22px 24px; border-radius: var(--radius-lg); background: var(--card); color: var(--card-ink); box-shadow: var(--shadow-lg); animation: drop-in .3s cubic-bezier(.2, 1.3, .4, 1) both; }
.ask-card p { margin: 0; font: 700 1.15rem/1.35 var(--font-display); }
.ask-card .row { justify-content: flex-end; }
.ask-card .btn:not(.primary) { --bg: var(--card-soft); --fg: var(--card-ink); --bd: var(--card-line); }

/* ================================================================== PowerPoint add-in (addin.html): a live quiz on a slide
   The page is exactly as big as the add-in's box on the slide, so sizes on the slide use vw (a share of the slide's width). */
body.addin-body { overflow: hidden; }
.addin { position: fixed; inset: 0; display: flex; flex-direction: column; }
.ad-view { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 14px; padding: clamp(12px, 3vw, 28px); }
.ad-center { align-items: center; justify-content: center; }
.ad-center h1 { margin: 0; }
.ad-center p { margin: 0; text-align: center; }
.ad-logo { font-size: 2.4rem; line-height: 1; color: var(--brand); }
.ad-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ad-head h1 { margin: 0; font-size: clamp(1.15rem, 3vw, 1.6rem); }
.ad-head p { margin: 0; }
.ad-list { display: grid; gap: 8px; }
.ad-quiz { display: grid; gap: 2px; text-align: start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; transition: border-color .15s, background .15s; }
.ad-quiz:hover, .ad-quiz:focus-visible { border-color: var(--brand); background: var(--brand-soft); }
.ad-quiz.on { border-color: var(--brand); box-shadow: inset 4px 0 0 var(--brand); }
.ad-quiz b { font: 700 1.05rem/1.25 var(--font-display); }
.ad-quiz span { color: var(--muted); font-size: .86rem; }

.ad-slide { position: relative; overflow: hidden; padding: 0; gap: 0; }
.ad-slide-in { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.2vh; padding: 6vh 7vw; }
.ad-eyebrow { display: inline-flex; align-items: center; gap: .45em; font: 800 max(12px, 2vw)/1 var(--font-display); letter-spacing: .12em; text-transform: uppercase; color: var(--stage-accent); }
.ad-eyebrow svg { width: 1.1em; height: 1.1em; }
.ad-slide h1 { margin: 0; max-width: 20ch; font: 800 max(22px, 5.6vw)/1.05 var(--font-display); color: var(--stage-ink); text-align: center; text-wrap: balance; }
.ad-meta { margin: 0; font: 600 max(12px, 2vw)/1.3 var(--font-body); color: var(--stage-soft); text-align: center; }
.ad-actions { justify-content: center; gap: 1.4vw; margin-top: 1vh; }
.ad-slide .btn.xl { min-height: 0; padding: max(10px, 1.3vw) max(22px, 3.4vw); font-size: max(16px, 2.5vw); border-radius: max(12px, 1.4vw); }
.ad-slide .btn.xl svg { width: 1em; height: 1em; }
.ad-hint { margin: 0; max-width: 62ch; font-size: max(11px, 1.45vw); color: var(--stage-muted); text-align: center; }
.ad-slide .notice { max-width: 60ch; }
.ad-edit { position: absolute; z-index: 2; top: max(8px, 1.6vw); right: max(8px, 1.6vw); }

/* the live game: host.html inside, drawn at least 1280 × 640 px and scaled to the slide (js/addin.js) */
.ad-game { position: absolute; inset: 0; overflow: hidden; background: var(--stage-deep); }
.ad-game iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; background: var(--stage-deep); }
.ad-loading { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 14px; color: var(--stage-soft); font: 700 max(13px, 1.8vw) var(--font-display); }

/* ================================================================== "Suggested by" under a teacher's question */
.q-credit { font-size: .85rem; color: var(--muted); }
.q-credit b { font-weight: 700; color: var(--ink-2); }
.qcard .q-credit { padding-top: 8px; border-top: 1px dashed var(--line); }
.q-card .q-credit { color: var(--card-ink-2); font-size: clamp(.85rem, 1.3vw, 1.1rem); }
.q-card .q-credit b { color: var(--card-ink); }
#pqBy .q-credit, .preview-phone .q-credit { color: var(--stage-muted); text-align: center; font-size: .8rem; }
#pqBy .q-credit b, .preview-phone .q-credit b { color: var(--stage-soft); }

/* ================================================================== teachers' leaderboard (question contributors) */
.board-tabs { margin-bottom: 4px; }
.tl-row.me td { background: var(--brand-soft); }
.tl-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.tl-subjects { display: flex; flex-wrap: wrap; gap: 4px; }
.board-podium .bp.me { border-color: var(--brand); }

/* ================================================================== theme choosers (account menu › Theme, Admin portal › Settings)
   Each option shows a small live preview of its theme (data-theme-preview in css/theme.css): the page with a card,
   a button and the highlight colour, and underneath the game stage with the four answer colours. */
.theme-menu > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--ink); font: 600 .92rem var(--font-body); cursor: pointer; }
.theme-menu > summary::-webkit-details-marker { display: none; }
.theme-menu > summary:hover { background: var(--surface-2); }
.theme-menu > summary svg { width: 17px; height: 17px; flex: none; color: var(--muted); }
.theme-menu > summary::after { content: "▸"; color: var(--muted); transition: transform .15s; }
.theme-menu[open] > summary::after { transform: rotate(90deg); }
.theme-now { margin-left: auto; font-size: .8rem; font-weight: 700; color: var(--muted); }
.theme-menu .theme-list { padding: 2px 0 6px; }
.theme-menu > p { padding: 0 10px 6px; }
.theme-list { display: grid; gap: 4px; }
.theme-opt { position: relative; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer; transition: background .15s, border-color .15s; }
.theme-opt:hover { background: var(--surface-2); }
.theme-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.theme-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.theme-opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 1px; }
.theme-opt:has(input:disabled) { cursor: default; opacity: .75; }
.theme-txt { display: grid; gap: 1px; min-width: 0; line-height: 1.25; }
.theme-txt b { color: var(--ink); font-weight: 700; font-size: .9rem; }
.theme-txt span { color: var(--muted); font-size: .78rem; }
.theme-sw { flex: none; display: grid; grid-template-rows: 1fr 13px; width: 54px; height: 38px; border-radius: 8px; overflow: hidden; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); }
.theme-sw .sw-top { display: flex; align-items: center; gap: 4px; margin: 4px 5px; padding: 0 5px; border-radius: 4px; background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.theme-sw .sw-top i { display: block; height: 6px; border-radius: 3px; background: var(--brand); flex: 1; }
.theme-sw .sw-top i:last-child { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.theme-sw .sw-stage { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; padding: 2px 3px 3px; background: var(--stage); }
.theme-sw .sw-stage b { border-radius: 2px; }
.theme-sw .sw-stage b:nth-child(1) { background: var(--a); } .theme-sw .sw-stage b:nth-child(2) { background: var(--b); }
.theme-sw .sw-stage b:nth-child(3) { background: var(--c); } .theme-sw .sw-stage b:nth-child(4) { background: var(--d); }
/* larger cards (Admin portal › Settings › Look) */
.theme-list.lg { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 12px; }
.theme-list.lg .theme-opt { flex-direction: column; align-items: stretch; gap: 10px; padding: 10px; border-color: var(--line); }
.theme-list.lg .theme-opt:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.theme-list.lg .theme-sw { width: 100%; height: auto; aspect-ratio: 16 / 9; grid-template-rows: 1fr 36%; border-radius: 10px; }
.theme-list.lg .theme-sw .sw-top { gap: 10px; margin: 10% 9% 7%; padding: 0 9%; border-radius: 7px; }
.theme-list.lg .theme-sw .sw-top i { height: 12px; border-radius: 6px; }
.theme-list.lg .theme-sw .sw-top i:last-child { width: 16px; height: 16px; }
.theme-list.lg .theme-sw .sw-stage { gap: 6px; padding: 7px 9px 9px; }
.theme-list.lg .theme-sw .sw-stage b { border-radius: 5px; }
.theme-list.lg .theme-txt b { font: 700 1.05rem/1.2 var(--font-display); }
.theme-list.lg .theme-txt span { font-size: .82rem; }
/* the slide's own theme (PowerPoint add-in, while editing the slides) */
.ad-look { width: auto; min-height: 34px; padding: 6px 30px 6px 11px; border-radius: 9px; font: 700 .85rem/1.1 var(--font-body); background-color: var(--stage-chip); color: var(--stage-ink); border: 1px solid color-mix(in srgb, var(--stage-ink) 25%, transparent); }

/* ================================================================== phones and touch screens */
@media (min-width: 901px) { .split.split-300 { grid-template-columns: 300px minmax(0, 1fr); } }
@media (pointer: coarse) {
  .chip { min-height: 36px; }
  .bell > summary { padding: 10px; }
  summary { padding-block: 6px; }
}

/* the game screen when a teacher hosts from a phone: the question card gets the full width (timer and answer count
   above it), the controls sit on their own row on the right, and answer tiles stack */
@media (max-width: 600px) {
  .stage-bar { gap: 8px; }
  .stage-bar .spacer { display: none; }
  .stage-bar #soundCtl { margin-left: auto; }
  .sbtn { width: 38px; height: 38px; }
  .q-top { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "timer . count" "card card card"; }
  .q-top .timer { grid-area: timer; }
  .q-top .q-card { grid-area: card; }
  .q-top .answered-box { grid-area: count; }
  .revealed .q-top { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: ". count" "card card"; }
}
@media (max-width: 480px) { .answers-grid { grid-template-columns: minmax(0, 1fr); } }

/* students' answer screen: exactly one screen high, so the question and the Submit button of a multiple-select question
   always stay on screen and the tiles share the height that is left (each at least as tall as its own text). When they
   do not all fit (a phone held sideways, six long options), the tiles scroll inside their area; nothing overlaps. Browsers without :has() keep the old
   behaviour (the page scrolls). */
.play:has(.answer-sec:not([hidden])) { height: 100vh; height: 100dvh; }
.play:has(.answer-sec:not([hidden])) .play-main { min-height: 0; overflow-y: auto; justify-content: center; justify-content: safe center; }
.answer-sec, .answer-body { min-height: 0; }
.answer-body .pad { min-height: 120px; overflow-y: auto; padding-block: 6px; grid-auto-rows: minmax(min-content, 132px); align-content: center; align-content: safe center; }
.answer-body .pad.two { grid-auto-rows: minmax(min-content, 190px); }
.answer-body .pad.no-text { grid-auto-rows: minmax(min-content, 200px); }
.answer-body .pad.more { -webkit-mask-image: linear-gradient(#000 calc(100% - 40px), transparent); mask-image: linear-gradient(#000 calc(100% - 40px), transparent); } /* more answers below (js/play.js) */
@media (min-width: 600px) { .answer-body .pad:not(.two):not(.no-text) { grid-auto-rows: minmax(min-content, 200px); } }
/* phones held sideways (very little height): tighter spacing so the question and the tiles fit */
@media (max-height: 450px) {
  .play-top { padding-block: 6px; }
  .play-main { padding-block: 8px; gap: 10px; }
  .play-main > section.answer-sec, .answer-body { gap: 8px; }
  .answer-body .pad:not(.two):not(.no-text) { grid-auto-rows: minmax(min-content, 132px); }
  .play-q { padding: 8px 12px; font-size: 1.05rem; }
  .answer-body .btn.xl { min-height: 48px; padding-block: 10px; }
  .pad .ans .shape, .pad.two .ans .shape { font-size: 2.4rem; } /* the symbol fits a short tile */
}
/* Admin portal › Users & access: teachers waiting for email confirmation */
.waiting-box { border-left: 4px solid var(--warn); }
