/* IB Practice — visual system */

:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --bg-tint: #eaeef3;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --ink: #0f1419;
  --ink-2: #3d4854;
  --muted: #6b7784;
  --line: #e2e7ed;
  --line-2: #cfd7e0;
  --accent: #2f6bd8;
  --accent-ink: #ffffff;
  --ok: #0e7a52;
  --ok-bg: #e6f5ee;
  --ok-line: #a8dcc4;
  --bad: #c0392b;
  --bad-bg: #fdecea;
  --bad-line: #f2b8b1;
  --warn: #a9700c;
  --shadow-sm: 0 1px 2px rgba(15, 20, 25, .06);
  --shadow: 0 4px 16px rgba(15, 20, 25, .07);
  --shadow-lg: 0 18px 48px rgba(15, 20, 25, .12);
  --r: 14px;
  --r-sm: 9px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --bg-tint: #11161d;
    --surface: #161b23;
    --surface-2: #1c222b;
    --ink: #e8eef6;
    --ink-2: #c2ccd8;
    --muted: #8b96a3;
    --line: #262d38;
    --line-2: #333c49;
    --accent: #5b93f5;
    --accent-ink: #07101f;
    --ok: #4ed19b;
    --ok-bg: #0f2b21;
    --ok-line: #1f5c45;
    --bad: #f08a80;
    --bad-bg: #2e1613;
    --bad-line: #6b2d26;
    --warn: #e0b155;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 4px 16px rgba(0, 0, 0, .4);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }

html { min-width: 1000px; background: var(--bg); }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip { position: fixed; left: 10px; top: -60px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; z-index: 99; }
.skip:focus { top: 10px; }

/* ---------------- header ---------------- */

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  height: 60px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-inner { width: min(1000px, 100%); margin: 0 auto; display: flex; align-items: center; gap: 14px; }

.mark {
  display: flex; align-items: center; gap: 9px;
  border: 0; background: none; cursor: pointer; padding: 6px 8px 6px 0;
  font-weight: 700; letter-spacing: -.01em; color: var(--ink);
}
.mark i {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  background: var(--ink); color: var(--bg); font-style: normal; font-size: 12px; font-weight: 800;
}
.top .spacer { flex: 1; }

.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumb .sep { color: var(--line-2); }
.crumb .now { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tally { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.tally .pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13px; font-weight: 650; box-shadow: var(--shadow-sm);
}
.tally .pill b { font-weight: 800; }
.tally .pill.streak { color: var(--warn); }

/* ---------------- layout ---------------- */

main { width: min(1000px, 100%); margin: 0 auto; padding: 30px 20px 120px; }
.narrow { max-width: 760px; margin-inline: auto; }

/* ---------------- home ---------------- */

.hero { margin-bottom: 30px; }
.hero h1 { font-size: clamp(28px, 4.4vw, 40px); letter-spacing: -.032em; line-height: 1.08; margin-bottom: 10px; }
.hero p { color: var(--muted); font-size: 16px; max-width: 54ch; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 22px 0 30px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px 14px; box-shadow: var(--shadow-sm);
}
.kpi b { display: block; font-size: 22px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; color: var(--muted); }

.topics { display: grid; gap: 10px; }
.topic {
  display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 15px;
  width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 17px; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.topic:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--line-2); }
.topic .ic {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px;
  font-size: 19px; color: #fff; background: var(--tone);
}
.topic h2 { font-size: 16px; font-weight: 700; letter-spacing: -.015em; }
.topic p { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.topic .go { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.topic .go em { font-style: normal; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.bar { width: 92px; height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--tone); border-radius: 99px; }

.play-online {
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 17px;
  width: 100%; min-height: 94px; margin-top: 14px; padding: 19px 22px;
  border: 1px solid var(--accent); border-radius: var(--r); cursor: pointer;
  text-align: left; color: var(--accent-ink); background: var(--accent);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 24%, transparent);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.play-online:hover { transform: translateY(-1px); filter: brightness(1.04); box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 30%, transparent); }
.online-icon {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px;
  background: color-mix(in srgb, var(--accent-ink) 16%, transparent);
  font-size: 13px; font-weight: 850; letter-spacing: -.02em;
}
.online-copy { display: flex; flex-direction: column; gap: 2px; }
.online-copy strong { font-size: 21px; line-height: 1.2; letter-spacing: -.02em; }
.online-copy span { font-size: 13.5px; opacity: .78; }
.online-go { font-size: 14px; font-weight: 750; white-space: nowrap; }

.footnote { margin-top: 20px; font-size: 12.5px; color: var(--muted); display: flex; gap: 14px; align-items: center; }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linkish:hover { color: var(--ink); }

/* ---------------- problem card ---------------- */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow); overflow: hidden;
}

.card-head { padding: 18px 22px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tag {
  font-size: 11px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line);
}
.tag.tone { color: #fff; background: var(--tone); border-color: transparent; }
.tag.plain { text-transform: none; letter-spacing: .02em; font-variant-numeric: tabular-nums; }

.scenario { padding: 14px 22px 0; font-size: 16.5px; line-height: 1.55; letter-spacing: -.008em; }

.givens {
  margin: 16px 22px 0; padding: 11px 0 12px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
/* Scale caption. One line, quiet, so "$320" is never ambiguous. */
.givens .scale { display: block; font-size: 11px; color: var(--muted); letter-spacing: .02em; margin: 0 0 9px; }
/* Two columns, not three: generators list related items adjacently (entry/exit,
   before/after), so a two-wide row-major grid stacks each pair in one row and
   leaves the labels room to breathe. */
.givens .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 9px 30px; }
.given { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.given .k { color: var(--muted); font-size: 12.5px; letter-spacing: -.005em; }
.given .v {
  font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums; letter-spacing: -.01em; text-align: right; white-space: nowrap;
}
/* Unit glyphs sit back so the digits carry. */
.given .v u { text-decoration: none; color: var(--muted); font-weight: 500; }
/* A given the walkthrough is currently talking about. */
.given.cited .v { color: var(--accent); }
.given.cited .k { color: var(--ink-2); }
.given.wide { grid-column: 1 / -1; }
.given.prose { justify-content: flex-start; gap: 10px; }
.given.prose .v {
  font-family: var(--sans); font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  white-space: normal; text-align: left; letter-spacing: 0;
}

.parts { padding: 6px 22px 22px; }
.part { padding-top: 18px; }
.part + .part { margin-top: 4px; }
.part-label { font-size: 13px; font-weight: 650; color: var(--ink-2); margin-bottom: 9px; }

/* numeric rows */
.answers { display: grid; gap: 8px; }
.arow {
  display: grid; grid-template-columns: 1fr 236px; align-items: center; gap: 14px;
  padding: 9px 12px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid transparent;
}
.arow > label { font-size: 14px; }
.field { display: flex; align-items: center; gap: 0; }
.field .fx {
  display: grid; place-items: center; min-width: 26px; height: 34px; padding: 0 7px;
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
  background: var(--bg-tint); border: 1px solid var(--line-2); border-right: 0;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}
.field input {
  width: 100%; height: 34px; padding: 0 10px; text-align: right;
  font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.field.bare input { border-radius: var(--r-sm); }
.field.suffix { flex-direction: row; }
.field.suffix input { border-radius: var(--r-sm) 0 0 var(--r-sm); border-right: 0; }
.field.suffix .fx { border: 1px solid var(--line-2); border-left: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.field input:disabled { background: var(--surface-2); color: var(--ink-2); }
.arow.ok { background: var(--ok-bg); border-color: var(--ok-line); }
.arow.bad { background: var(--bad-bg); border-color: var(--bad-line); }
.verdict { grid-column: 1 / -1; font-size: 12.5px; font-family: var(--mono); }
.arow.ok .verdict { color: var(--ok); }
.arow.bad .verdict { color: var(--bad); }

/* choice */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  cursor: pointer; padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); font-size: 14px; font-weight: 550;
  transition: background .12s, border-color .12s, color .12s;
}
.choice:hover:not(:disabled) { border-color: var(--ink-2); }
.choice[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.choice.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.choice.bad { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.choice.missed { border-style: dashed; border-color: var(--ok); color: var(--ok); }
.choice:disabled { cursor: default; }

/* fill in the blank */
.sentence {
  font-size: 16px; line-height: 2.15; padding: 14px 16px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line);
}
.slot {
  display: inline-block; min-width: 116px; padding: 4px 10px; margin: 0 2px;
  border: 1px dashed var(--line-2); border-radius: 7px; background: var(--surface);
  font-family: var(--mono); font-size: 13.5px; text-align: center; cursor: pointer; color: var(--muted);
}
.slot.full { border-style: solid; color: var(--ink); border-color: var(--ink-2); }
.slot.ok { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.slot.bad { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.wordbank { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.word {
  cursor: pointer; padding: 7px 12px; border-radius: 999px; font-size: 13.5px;
  border: 1px solid var(--line-2); background: var(--surface);
}
.word:hover:not(:disabled) { border-color: var(--ink-2); }
.word:disabled { opacity: .32; cursor: default; }

/* buckets & bridge */
.pool {
  display: flex; flex-wrap: wrap; gap: 7px; min-height: 44px;
  padding: 9px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px dashed var(--line-2);
}
.pool:empty::after { content: "All placed"; color: var(--muted); font-size: 13px; padding: 3px 4px; }
.chip {
  cursor: pointer; padding: 7px 12px; border-radius: 8px; font-size: 13.5px; text-align: left;
  border: 1px solid var(--line-2); background: var(--surface); box-shadow: var(--shadow-sm);
}
.chip:hover:not(:disabled) { border-color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.chip.bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.chip:disabled { cursor: default; }

.zones {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 9px; margin-top: 9px; align-items: start;
}
.zone {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2);
  text-align: left; cursor: pointer; width: 100%; overflow: hidden;
}
.zone:hover { border-color: var(--line-2); }
.zone.armed { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.zone.locked { cursor: default; }
.zone > h4 {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0; padding: 9px 11px; font-size: 12px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); background: var(--bg-tint);
  border-bottom: 1px solid var(--line);
}
.zone > h4 .count {
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  display: grid; place-items: center; background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--line-2);
}
/* placed answers stack in a column inside the section, on the card surface so they
   never read as part of the section label above them */
.zone .items {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  padding: 9px; min-height: 62px; background: var(--surface);
}
.zone .items .chip { width: 100%; }
.zone .items .ph {
  color: var(--muted); font-size: 12.5px; padding: 4px 3px;
  border: 1px dashed var(--line-2); border-radius: 7px; text-align: center;
}
.hintline { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

/* grid builder */
.gwrap { display: grid; gap: 14px; }
.gsec { border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.gsec > h4 {
  margin: 0; padding: 10px 13px; font-size: 12px; font-weight: 750; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.grow {
  display: grid; grid-template-columns: minmax(112px, 1fr) 218px auto; align-items: center; gap: 12px;
  padding: 6px 13px; border-bottom: 1px solid var(--line);
}
.grow:last-child { border-bottom: 0; }
.grow.sub { background: var(--surface-2); font-weight: 650; }
.grow label { font-size: 13.5px; }
.grow .mk { width: 18px; text-align: center; font-size: 13px; font-family: var(--mono); }
.grow.ok .mk { color: var(--ok); }
.grow.bad .mk { color: var(--bad); }
.grow.bad label::after { content: attr(data-truth); display: block; font-family: var(--mono); font-size: 12px; color: var(--bad); }
.balance {
  display: flex; align-items: center; gap: 8px; padding: 10px 13px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line);
}
.balance.yes { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.balance.no { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }

/* ---------------- solution ---------------- */

.solution {
  margin: 0 22px 22px; padding: 16px 18px; border-radius: var(--r-sm);
  background: var(--bg-tint); border: 1px solid var(--line);
}
.solution h3 {
  font-size: 11px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}
.solution ol { margin: 0; padding-left: 19px; display: grid; gap: 9px; }
.solution li { font-size: 14.2px; line-height: 1.58; color: var(--ink-2); }

/* progressive hints — same shape as the walkthrough, but visibly provisional */
.solution.hints {
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
  border-left: 3px solid var(--accent);
}
.solution.hints h3 { color: var(--accent); }
.solution.hints .more {
  margin: 11px 0 0; padding-top: 9px; border-top: 1px dashed var(--line-2);
  font-size: 12.5px; color: var(--muted);
}

.banner {
  margin: 0 22px; padding: 12px 16px; border-radius: var(--r-sm); font-size: 14px; font-weight: 650;
  display: flex; align-items: center; gap: 9px;
}
.banner.ok { background: var(--ok-bg); border: 1px solid var(--ok-line); color: var(--ok); }
.banner.bad { background: var(--bad-bg); border: 1px solid var(--bad-line); color: var(--bad); }
.banner.note {
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  color: color-mix(in srgb, var(--accent) 78%, var(--ink));
}

/* ---------------- action bar ---------------- */

.actions {
  position: sticky; bottom: 0; z-index: 15;
  margin-top: 16px; padding: 12px 0 16px;
  background: linear-gradient(to top, var(--bg) 62%, transparent);
  display: flex; gap: 9px; align-items: center;
}
.btn {
  cursor: pointer; border-radius: 10px; padding: 11px 18px; font-size: 14.5px; font-weight: 650;
  border: 1px solid var(--line-2); background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform .1s ease, box-shadow .12s ease;
}
.btn:hover:not(:disabled) { box-shadow: var(--shadow); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.wide { flex: 1; }
.kbd {
  font-family: var(--mono); font-size: 11px; padding: 2px 5px; border-radius: 4px;
  border: 1px solid currentColor; opacity: .55; margin-left: 7px;
}
.actions .grow-space { flex: 1; }
.actions { flex-wrap: wrap; }

/* ---------------- misc ---------------- */

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ================= profile, leaderboard, back button ================= */

.back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px 6px 9px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface);
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-sm);
}
.back:hover { border-color: var(--ink-2); }
.back span { font-size: 15px; line-height: 1; }

.pill.who {
  cursor: pointer; border: 1px solid var(--line); background: var(--surface);
  padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 650;
  box-shadow: var(--shadow-sm); max-width: 190px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.pill.who:hover { border-color: var(--line-2); }

.welcome { padding-top: 26px; }
.namecard {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 22px; box-shadow: var(--shadow); max-width: 460px;
}
.namecard label { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.namecard input {
  height: 44px; padding: 0 14px; font-size: 17px;
  background: var(--bg-tint); border: 1px solid var(--line-2); border-radius: var(--r-sm);
}
.namebtns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.hintline.bad { color: var(--bad); }
.hintline.good { color: var(--ok); }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 20px 22px; box-shadow: var(--shadow-sm); margin-bottom: 14px;
}
.ph2 { font-size: 15px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 4px; }
.pmuted { font-size: 13.5px; color: var(--muted); margin-bottom: 12px; }

.coderow { display: flex; gap: 8px; align-items: stretch; }
.codebox {
  flex: 1; min-width: 0; height: 42px; padding: 0 12px;
  font-family: var(--mono); font-size: 13px;
  background: var(--bg-tint); border: 1px solid var(--line-2); border-radius: var(--r-sm);
}
.codearea {
  width: 100%; padding: 11px 12px; resize: vertical;
  font-family: var(--mono); font-size: 13px; line-height: 1.5;
  background: var(--bg-tint); border: 1px solid var(--line-2); border-radius: var(--r-sm);
}

.tablewrap { overflow-x: auto; margin: 0 -4px; }
table.board { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.board th {
  text-align: left; padding: 0 10px 9px; font-size: 11px; font-weight: 750;
  letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.board td { padding: 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.board tr:last-child td { border-bottom: 0; }
table.board .n, table.board th.n { text-align: right; }
table.board .r, table.board th.r { width: 42px; text-align: center; color: var(--muted); }
table.board .nm { font-weight: 600; }
table.board .sub { color: var(--muted); font-size: 12.5px; }
table.board tr.me td { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
table.board tr.me td:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
table.board tr.me td:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.youtag {
  margin-left: 7px; padding: 1px 6px; border-radius: 999px; font-size: 10.5px;
  font-weight: 750; letter-spacing: .05em; text-transform: uppercase;
  background: var(--accent); color: var(--accent-ink);
}
.medal {
  display: inline-grid; place-items: center; width: 22px; height: 22px;
  border-radius: 999px; font-size: 12px; font-weight: 750; color: #3a2c05;
}
.medal.m1 { background: #f2c14e; }
.medal.m2 { background: #d3d8de; }
.medal.m3 { background: #e0a674; }

/* ================= wide screens (Chrome full screen) ================= */

@media (min-width: 1080px) {
  main, .top-inner { width: min(1280px, 100%); }
  .topics { grid-template-columns: repeat(2, 1fr); }
  .narrow { max-width: 880px; }
}

@media (min-width: 1000px) {
  /* long answer stacks become two columns; a lone field still spans the row */
  .answers { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 8px 14px; }
}

/* A statement build carries a sign toggle on every row, so it needs a wider card
   than a normal problem and more room before the columns split. */
@media (min-width: 1250px) {
  .narrow.wide { max-width: 1180px; }
  .gwrap { grid-template-columns: repeat(2, 1fr); align-items: start; }
  .gwrap .balance { grid-column: 1 / -1; }
}
@media (min-width: 1560px) {
  .narrow.wide { max-width: 1460px; }
  .gwrap { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1400px) {
  main, .top-inner { width: min(1360px, 100%); }
  .narrow { max-width: 940px; }
}

/* ---- live board status ---- */
.livebar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  padding: 11px 15px; border-radius: var(--r-sm); font-size: 13.5px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
}
.livebar .dot { width: 8px; height: 8px; border-radius: 999px; background: var(--muted); flex: none; }
.livebar.on { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.livebar.on .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
details.panel > summary { cursor: pointer; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: "▸ "; color: var(--muted); }
details.panel[open] > summary::before { content: "▾ "; }
details.panel > summary + p { margin-top: 10px; }
.ph3 { font-size: 13px; font-weight: 700; margin: 20px 0 8px; color: var(--ink-2); }

/* ---- +/− sign toggle ---- */
.entry { display: flex; align-items: center; gap: 7px; justify-content: flex-end; }
.sign {
  display: inline-flex; flex: none; border: 1px solid var(--line-2);
  border-radius: var(--r-sm); overflow: hidden; background: var(--bg-tint);
}
.sgn {
  width: 30px; height: 34px; padding: 0; cursor: pointer; border: 0; background: transparent;
  font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--muted); line-height: 1;
}
.sgn + .sgn { border-left: 1px solid var(--line-2); }
.sgn:hover:not(:disabled) { background: var(--surface); color: var(--ink); }
.sgn.on { background: var(--bg-tint); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.sgn[data-sign="-"].on { background: var(--bad-bg); color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad-line); }
.sgn:disabled { cursor: default; opacity: .55; }
.sign.locked { opacity: .8; }
.entry .field { flex: 1; min-width: 0; }
.arow .entry { min-width: 0; }
.grow .entry { justify-content: flex-end; }

/* ---- leaderboard call-to-action + banter ---- */
.btn.lockin {
  padding: 7px 13px; font-size: 12.5px; font-weight: 700; letter-spacing: -.01em;
  background: var(--ink); color: var(--bg); border-color: var(--ink); white-space: nowrap;
}
.btn.lockin:hover { opacity: .88; }
.btn.lockin.sm { font-size: 12px; padding: 6px 11px; }

.roast {
  margin: 0 0 14px; padding: 13px 16px; border-radius: var(--r-sm);
  background: var(--ink); color: var(--bg);
  font-size: 15px; font-weight: 650; letter-spacing: -.01em;
}
.boardhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.boardhead .pmuted { margin: 0; }
.goattag, .bumtag {
  margin-left: 7px; padding: 1px 6px; border-radius: 999px; font-size: 10.5px;
  font-weight: 750; letter-spacing: .05em; text-transform: uppercase;
}
.goattag { background: #f2c14e; color: #3a2c05; }
.bumtag { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad-line); }
.livebar .linkish { margin-left: auto; }

.lockline {
  font-size: 17px; font-weight: 700; letter-spacing: -.015em;
  color: var(--ink); margin-bottom: 8px;
}

/* ---- hero action buttons ---- */
.hero.herosplit { display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: start; }
.heroacts { display: grid; gap: 10px; width: min(340px, 40vw); }
.bigact {
  display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto;
  gap: 2px 12px; align-items: center; text-align: left; cursor: pointer;
  padding: 14px 16px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.bigact:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--line-2); }
.bigact .ba-k {
  grid-row: 1 / 3; display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 10px; background: var(--bg-tint); color: var(--ink-2);
  font-size: 12px; font-weight: 800; letter-spacing: -.02em;
}
.bigact .ba-t { font-size: 15px; font-weight: 700; letter-spacing: -.015em; }
.bigact .ba-s { font-size: 12.5px; color: var(--muted); }
.bigact.vs { background: var(--ink); border-color: var(--ink); }
.bigact.vs .ba-t { color: var(--bg); }
.bigact.vs .ba-s { color: color-mix(in srgb, var(--bg) 70%, var(--ink)); }
.bigact.vs .ba-k { background: color-mix(in srgb, var(--bg) 22%, var(--ink)); color: var(--bg); }

/* ---- lobby ---- */
.lobbyrow {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.lobbyrow:last-child { border-bottom: 0; }
.lobbyrow strong { display: block; font-size: 15px; }
.lobbyrow .sub { font-size: 12.5px; color: var(--muted); }
.lobbyrow.waiting {
  border: 1px dashed var(--line-2); border-radius: var(--r-sm);
  padding: 13px 15px; background: var(--bg-tint);
}
.lobbyempty { padding: 14px 0; color: var(--muted); font-size: 13.5px; }

/* ---- race ---- */
.racebar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 14px; padding: 12px 16px; border-radius: var(--r-sm);
  background: var(--ink); color: var(--bg);
}
.pips { display: flex; gap: 5px; }
.pip { width: 22px; height: 5px; border-radius: 99px; background: color-mix(in srgb, var(--bg) 28%, var(--ink)); }
.pip.done { background: var(--ok); }
.pip.now { background: var(--bg); }
.racemeta { font-size: 13px; font-weight: 600; opacity: .85; }
.bigclock {
  margin-left: auto; font-family: var(--mono); font-size: 20px; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.pill.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.racescore { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; }
.racescore .side {
  display: grid; gap: 3px; padding: 16px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line); text-align: center;
}
.racescore .side.win { background: var(--ok-bg); border-color: var(--ok-line); }
.racescore .who { font-size: 13.5px; font-weight: 650; }
.racescore .time {
  font-family: var(--mono); font-size: 26px; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.racescore .side.win .time { color: var(--ok); }
.racescore .sub { font-size: 12px; color: var(--muted); }
.racescore .vs { font-size: 12px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.boardhead .btn.sm { margin-left: auto; }
.pip.ok { background: var(--ok); }
.pip.miss { background: var(--bad); }
.racescore .score {
  font-family: var(--mono); font-size: 34px; font-weight: 700; line-height: 1;
  letter-spacing: -.03em; font-variant-numeric: tabular-nums;
}
.racescore .score i { font-style: normal; font-size: 16px; color: var(--muted); font-weight: 600; }
.racescore .side.win .score { color: var(--ok); }
.racescore .time { font-size: 17px; color: var(--ink-2); }

/* ---- floating calculator ---- */
.calculator {
  position: fixed; z-index: 80; top: 112px; right: 34px; width: 244px;
  padding: 0 14px 14px; border: 1px solid var(--line-2); border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow-lg); user-select: none;
}
.calculator[hidden] { display: none; }
.calculator-head { display: flex; height: 45px; align-items: center; justify-content: space-between; cursor: grab; touch-action: none; }
.calculator-head:active { cursor: grabbing; }
.calculator-head strong { font-size: 13px; }
.calculator-head button { width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; font-size: 20px; cursor: pointer; }
.calculator-head button:hover { background: var(--surface-2); }
#calculator-display { width: 100%; height: 42px; margin-bottom: 10px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg-tint); color: var(--ink); font-family: var(--mono); font-size: 17px; text-align: right; }
.calculator-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calculator-keys button { height: 37px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); cursor: pointer; font-weight: 650; }
.calculator-keys button:hover { border-color: var(--line-2); background: var(--bg-tint); }
.calculator-keys button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---- draggable scratch paper ---- */
.scratch-note {
  position: fixed; z-index: 79; top: 112px; right: 296px; width: 286px;
  padding: 0 14px 14px; border: 1px solid color-mix(in srgb, #d6a700 45%, var(--line)); border-radius: 14px;
  background: color-mix(in srgb, #ffd84f 20%, var(--surface)); box-shadow: var(--shadow-lg);
}
.scratch-note[hidden] { display: none; }
.scratch-note-head { display: flex; height: 45px; align-items: center; justify-content: space-between; cursor: grab; touch-action: none; user-select: none; }
.scratch-note-head:active { cursor: grabbing; }
.scratch-note-head strong { font-size: 13px; }
.scratch-note-head button { width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); font-size: 20px; cursor: pointer; }
.scratch-note-head button:hover { background: color-mix(in srgb, #d6a700 16%, transparent); }
#scratch-note-text {
  display: block; width: 100%; min-height: 220px; max-height: 65vh; padding: 10px 11px; resize: vertical;
  border: 1px solid color-mix(in srgb, #d6a700 40%, var(--line)); border-radius: 8px;
  background: color-mix(in srgb, #fff2a6 42%, var(--bg-tint)); color: var(--ink);
  font: 14px/1.55 var(--sans); outline: none;
}
#scratch-note-text:focus { border-color: #c69c00; box-shadow: 0 0 0 3px color-mix(in srgb, #d6a700 18%, transparent); }

/* ---- solo Blitz Mix ---- */
.blitz-solo { padding-top: 8px; }
.blitz-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.blitz-choices .choice { border-radius: var(--r-sm); text-align: left; }
.blitz-result { display: grid; place-items: center; min-height: 180px; text-align: center; }
.blitz-result b { display: block; font-family: var(--mono); font-size: 52px; line-height: 1; letter-spacing: -.05em; color: var(--accent); }
.blitz-result span { color: var(--muted); font-weight: 650; }

/* ================= mobile layout =================
   Desktop remains the default. These overrides remove the desktop minimum canvas
   and reshape the same interface for phones and small tablets. */
@media (max-width: 820px) {
  html { min-width: 0; overflow-x: hidden; }
  body { font-size: 14px; overflow-x: hidden; }
  button, input, select, textarea { touch-action: manipulation; }
  input, select, textarea { font-size: 16px; }

  .top {
    height: 56px; gap: 8px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  .top-inner { gap: 7px; }
  .mark { padding: 5px 2px 5px 0; }
  .mark span { display: none; }
  .mark i { width: 28px; height: 28px; }
  .crumb { gap: 5px; }
  .crumb .sep, .crumb .now { display: none; }
  .back { min-height: 38px; padding: 6px 9px; }
  .tally { gap: 5px; }
  .tally .pill { padding: 5px 8px; font-size: 12px; }
  .tally .who, .tally .hide-sm { display: none; }
  .btn.lockin, .btn.lockin.sm { min-height: 38px; padding: 7px 10px; font-size: 12px; }

  main {
    width: 100%; padding: 22px 12px calc(96px + env(safe-area-inset-bottom));
  }
  .narrow, .narrow.wide { width: 100%; max-width: none; }
  .hero { margin-bottom: 22px; }
  .hero h1 { font-size: clamp(28px, 8.5vw, 36px); }
  .hero p { font-size: 15px; }
  .hero.herosplit { grid-template-columns: 1fr; gap: 16px; }
  .heroacts { width: 100%; }

  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 18px 0 22px; }
  .kpi { padding: 11px 12px; }
  .kpi b { font-size: 20px; }
  .topics { grid-template-columns: 1fr; gap: 9px; }
  .topic { grid-template-columns: 42px minmax(0, 1fr); gap: 12px; padding: 14px; }
  .topic p { line-height: 1.4; }
  .topic .go { grid-column: 2; align-items: flex-start; gap: 4px; }
  .topic .go .bar { width: min(150px, 48vw); }
  .play-online { grid-template-columns: 46px minmax(0, 1fr); min-height: 0; padding: 17px; gap: 12px; }
  .online-icon { width: 46px; height: 46px; border-radius: 12px; }
  .online-copy strong { font-size: 19px; }
  .online-copy span { line-height: 1.4; }
  .online-go { grid-column: 2; font-size: 13px; }
  .footnote { align-items: flex-start; flex-wrap: wrap; margin-top: 16px; }

  .card { border-radius: 14px; }
  .card-head { padding: 15px 15px 0; gap: 6px; }
  .scenario { padding: 12px 15px 0; font-size: 15.5px; line-height: 1.5; }
  .givens { margin: 14px 15px 0; }
  .givens .grid { grid-template-columns: 1fr; gap: 8px; }
  .given { gap: 10px; }
  .given .k { min-width: 0; }
  .parts { padding: 4px 15px 17px; }
  .part { padding-top: 15px; }

  .arow { grid-template-columns: 1fr; gap: 7px; padding: 10px; }
  .arow > label { font-weight: 600; }
  .entry, .field { width: 100%; }
  .field input { min-height: 40px; }
  .sign .sgn { width: 38px; min-height: 40px; }
  .choice { min-height: 44px; padding: 10px 13px; }
  .blitz-choices { grid-template-columns: 1fr; }
  .blitz-result { min-height: 150px; }
  .blitz-result b { font-size: 44px; }
  .sentence { padding: 12px; font-size: 15px; line-height: 2.25; overflow-wrap: anywhere; }
  .slot { min-width: 96px; max-width: 100%; }
  .word, .chip { min-height: 42px; }
  .zones { grid-template-columns: 1fr; }

  .grow { grid-template-columns: minmax(0, 1fr) auto; gap: 7px; padding: 9px 10px; }
  .grow label { grid-column: 1; grid-row: 1; }
  .grow .mk { grid-column: 2; grid-row: 1; }
  .grow .entry { grid-column: 1 / -1; grid-row: 2; }
  .gsec > h4 { padding: 9px 10px; }
  .balance { align-items: flex-start; }

  .solution { margin: 0 15px 17px; padding: 14px; }
  .solution li { font-size: 13.8px; }
  .banner { margin: 0 15px; padding: 11px 12px; }

  .actions {
    gap: 7px; margin-top: 12px;
    padding: 10px 0 calc(12px + env(safe-area-inset-bottom));
  }
  .actions .grow-space { display: none; }
  .actions .btn { min-height: 44px; padding: 10px 12px; flex: 1 1 auto; }
  .actions .btn.primary.wide, .actions #check, .actions #racecheck, .actions #next { flex: 1 0 100%; }
  .kbd { display: none; }

  .welcome { padding-top: 8px; }
  .namecard, .panel { max-width: none; padding: 17px 15px; border-radius: 14px; }
  .namecard input { min-height: 48px; }
  .namebtns .btn { min-height: 44px; }
  .coderow { flex-wrap: wrap; }
  .coderow .codebox { flex-basis: 100%; min-height: 46px; }
  .coderow .btn { flex: 1; min-height: 44px; }
  .tablewrap { -webkit-overflow-scrolling: touch; }
  table.board { min-width: 620px; }
  .livebar { align-items: flex-start; flex-wrap: wrap; padding: 11px 12px; }
  .livebar > span:nth-child(2) { flex: 1; min-width: 0; }
  .livebar .linkish { margin-left: 18px; }
  .boardhead { align-items: center; gap: 8px; }
  .lobbyrow { align-items: stretch; flex-wrap: wrap; gap: 8px; }
  .lobbyrow > div { flex: 1 1 100%; }
  .lobbyrow > .btn { flex: 1; min-height: 44px; }
  .ph3 { margin-top: 17px; }

  .racebar { gap: 8px 12px; padding: 10px 12px; }
  .pips { order: 1; }
  .bigclock { order: 2; }
  .racemeta { order: 3; flex-basis: 100%; }
  .racescore { grid-template-columns: 1fr; }
  .racescore .vs { padding: 2px 0; }

  .calculator, .scratch-note {
    top: 68px; right: 12px; left: auto; width: calc(100vw - 24px); max-height: calc(100dvh - 82px);
  }
  .calculator { padding: 0 12px 12px; overflow-y: auto; }
  .calculator-head, .scratch-note-head { height: 44px; }
  #calculator-display { height: 46px; font-size: 18px; }
  .calculator-keys button { min-height: 43px; }
  .scratch-note { padding: 0 12px 12px; }
  #scratch-note-text { min-height: min(300px, 45dvh); max-height: 55dvh; resize: none; }
}
