/* MMT Quiz — brand styling.
   Palette taken from the MMT wordmark: cyan #11b1c3 on ink #303030 / #1a1a1a. */

:root {
  --mmt-cyan: #11b1c3;
  --mmt-cyan-bright: #2fd0e2;
  --mmt-cyan-dim: #0d8a99;
  --mmt-ink: #303030;
  --mmt-night: #1a1a1a;
  --mmt-gold: #ffe05e;

  --bg: #14191c;
  --bg-deep: #0e1214;
  --surface: #1e2529;
  --surface-2: #262f34;
  --surface-3: #303b41;
  --line: #38454c;
  --line-soft: #2a343a;

  --text: #f4f7f8;
  --text-dim: #a8b7bf;
  --text-faint: #74858e;

  --good: #35c07a;
  --bad: #e2564a;
  --warn: #f0a742;

  --r-sm: 8px;
  --r: 14px;
  --r-lg: 22px;
  --r-pill: 999px;

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 18px 44px rgba(0, 0, 0, 0.45);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --page: min(760px, 100%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
  overscroll-behavior-y: contain;
}

/* A soft cyan wash so the brand colour is present even on empty screens. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1100px 620px at 12% -12%, rgba(17, 177, 195, 0.16), transparent 62%),
    radial-gradient(900px 520px at 108% 6%, rgba(17, 177, 195, 0.09), transparent 60%);
}

.shell {
  position: relative;
  z-index: 1;
  width: var(--page);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 0 18px;
}

.brandmark { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brandmark img { height: 26px; width: auto; display: block; flex: none; }
.brandmark .divider { width: 1px; height: 22px; background: var(--line); flex: none; }
.brandmark .label {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* -------------------------------------------------------------- typography */

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.018em; }
h1 { font-size: clamp(26px, 6vw, 38px); }
h2 { font-size: clamp(19px, 4vw, 24px); }
h3 { font-size: 16px; }

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--mmt-cyan);
  margin: 0 0 8px;
}

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.tiny  { font-size: 12.5px; }
.small { font-size: 14px; }
.center { text-align: center; }
.mono { font-family: var(--mono); }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.accent { border-color: rgba(17, 177, 195, 0.42); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}

.card-body { padding: 20px; }

/* ----------------------------------------------------------------- buttons */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--r);
  padding: 14px 20px;
  font: inherit;
  font-weight: 650;
  font-size: 16px;
  color: var(--mmt-night);
  background: var(--mmt-cyan);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  line-height: 1.2;
  min-height: 50px;
  touch-action: manipulation;
}
.btn:hover:not(:disabled) { background: var(--mmt-cyan-bright); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--mmt-cyan-bright); outline-offset: 2px; }

.btn.block { width: 100%; }
.btn.big { padding: 19px 26px; font-size: 18px; min-height: 62px; }

.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--mmt-cyan); }

.btn.subtle {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line-soft);
}
.btn.subtle:hover:not(:disabled) { background: var(--surface-3); }

.btn.danger { background: transparent; color: var(--bad); border-color: rgba(226, 86, 74, 0.5); }
.btn.danger:hover:not(:disabled) { background: rgba(226, 86, 74, 0.14); }

.btn.tiny-btn { padding: 8px 13px; font-size: 13.5px; min-height: 36px; border-radius: 10px; }

/* ------------------------------------------------------------------ inputs */

label.field { display: block; }
label.field > span.label-text {
  display: block;
  font-size: 13px;
  font-weight: 650;
  color: var(--text-dim);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
}

input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming on focus */
  color: var(--text);
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--mmt-cyan);
  box-shadow: 0 0 0 3px rgba(17, 177, 195, 0.2);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { resize: vertical; min-height: 120px; font-family: var(--mono); font-size: 13.5px; line-height: 1.55; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 19px) center, calc(100% - 13px) center;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

.input-code {
  font-family: var(--mono);
  font-size: clamp(26px, 8vw, 36px);
  font-weight: 700;
  letter-spacing: 0.34em;
  text-align: center;
  text-transform: uppercase;
  padding: 18px 10px 18px 20px;
}

/* ------------------------------------------------------------- join / code */

.joincode {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--mmt-cyan);
  font-size: clamp(30px, 9vw, 52px);
  line-height: 1;
}

.qr-frame {
  background: #fff;
  border-radius: var(--r);
  padding: 14px;
  display: inline-flex;
  line-height: 0;
  box-shadow: var(--shadow);
}
.qr-frame svg { display: block; width: 100%; height: auto; }

/* ---------------------------------------------------------------- question */

.qmeta {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-dim);
}
.chip.cyan { background: rgba(17, 177, 195, 0.15); border-color: rgba(17, 177, 195, 0.4); color: var(--mmt-cyan-bright); }
.chip.gold { background: rgba(255, 224, 94, 0.14); border-color: rgba(255, 224, 94, 0.4); color: var(--mmt-gold); }
.chip.good { background: rgba(53, 192, 122, 0.14); border-color: rgba(53, 192, 122, 0.4); color: var(--good); }
.chip.bad  { background: rgba(226, 86, 74, 0.14); border-color: rgba(226, 86, 74, 0.4); color: var(--bad); }

.prompt {
  font-size: clamp(21px, 5.2vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0 0 6px;
}

.hint { color: var(--text-dim); font-size: 15px; margin: 10px 0 0; }

/* --------------------------------------------------------------- MC option */

.options { display: grid; gap: 11px; margin-top: 20px; }

.option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 17px 18px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 2px solid var(--line-soft);
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.08s ease;
  touch-action: manipulation;
  min-height: 62px;
}
.option:hover:not(:disabled) { border-color: var(--mmt-cyan); background: var(--surface-3); }
.option:active:not(:disabled) { transform: scale(0.99); }
.option:disabled { cursor: default; }

.option .key {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
}

.option.selected { border-color: var(--mmt-cyan); background: rgba(17, 177, 195, 0.16); }
.option.selected .key { background: var(--mmt-cyan); border-color: var(--mmt-cyan); color: var(--mmt-night); }

.option.correct { border-color: var(--good); background: rgba(53, 192, 122, 0.16); }
.option.correct .key { background: var(--good); border-color: var(--good); color: #06251a; }

.option.wrong { border-color: var(--bad); background: rgba(226, 86, 74, 0.14); }
.option.wrong .key { background: var(--bad); border-color: var(--bad); color: #2b0705; }

.option.dim { opacity: 0.5; }

/* ------------------------------------------------------------------ timer */

.timer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 18px;
}
.timer-track {
  position: relative;
  flex: 1;
  height: 9px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  overflow: hidden;
}
.timer-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--mmt-cyan-dim), var(--mmt-cyan-bright));
  transition: width 0.25s linear, background 0.4s ease;
}
.timer.urgent .timer-fill { background: linear-gradient(90deg, #c9432f, var(--warn)); }
.timer-count {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 3.2ch;
  text-align: right;
  color: var(--text);
}
.timer.urgent .timer-count { color: var(--warn); }

/* ------------------------------------------------------------ leaderboard */

.board { display: flex; flex-direction: column; }

.board-row {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.board-row:last-child { border-bottom: none; }
.board-row.me { background: rgba(17, 177, 195, 0.1); }

.board-rank {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-faint);
  text-align: center;
}
.board-row.top1 .board-rank { color: var(--mmt-gold); }
.board-row.top2 .board-rank,
.board-row.top3 .board-rank { color: var(--text-dim); }

.board-name { font-weight: 650; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-sub { font-size: 12.5px; color: var(--text-faint); }
.board-points {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--mmt-cyan);
}
.board-delta { font-size: 12.5px; color: var(--good); font-family: var(--mono); text-align: right; }

/* -------------------------------------------------------------- name chips */

.namechips { display: flex; flex-wrap: wrap; gap: 8px; }
.namechip {
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  font-weight: 600;
  font-size: 14.5px;
  animation: pop 0.32s cubic-bezier(0.2, 1.3, 0.5, 1);
}
.namechip.answered { border-color: rgba(53, 192, 122, 0.55); background: rgba(53, 192, 122, 0.13); }

@keyframes pop {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------------------------------------------------------------- feedback */

.verdict {
  border-radius: var(--r-lg);
  padding: 24px;
  text-align: center;
  border: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.verdict.good { border-color: rgba(53, 192, 122, 0.5); background: rgba(53, 192, 122, 0.12); }
.verdict.bad  { border-color: rgba(226, 86, 74, 0.45); background: rgba(226, 86, 74, 0.1); }
.verdict.gold { border-color: rgba(255, 224, 94, 0.5); background: rgba(255, 224, 94, 0.11); }
.verdict-title { font-size: clamp(21px, 5vw, 27px); font-weight: 750; letter-spacing: -0.02em; }
.verdict-points {
  font-family: var(--mono);
  font-size: clamp(34px, 10vw, 50px);
  font-weight: 700;
  color: var(--mmt-cyan);
  line-height: 1.05;
  margin: 8px 0 2px;
}
.verdict.gold .verdict-points { color: var(--mmt-gold); }

.banner {
  padding: 13px 16px;
  border-radius: var(--r);
  font-size: 14.5px;
  font-weight: 600;
  border: 1px solid;
}
.banner.err  { background: rgba(226, 86, 74, 0.13); border-color: rgba(226, 86, 74, 0.45); color: #ffb3ab; }
.banner.ok   { background: rgba(53, 192, 122, 0.13); border-color: rgba(53, 192, 122, 0.45); color: #9ce8c1; }
.banner.warn { background: rgba(240, 167, 66, 0.13); border-color: rgba(240, 167, 66, 0.45); color: #f6cd8e; }
.banner.info { background: rgba(17, 177, 195, 0.12); border-color: rgba(17, 177, 195, 0.4); color: #a5e6ee; }

/* -------------------------------------------------------------- connection */

.conn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.conn.live .dot { background: var(--good); box-shadow: 0 0 0 4px rgba(53, 192, 122, 0.18); }
.conn.down .dot { background: var(--bad); }

/* ------------------------------------------------------------------ podium */

.podium { text-align: center; padding: 34px 22px; }
.podium .crown { font-size: 52px; line-height: 1; }
.podium .winner-name {
  font-size: clamp(30px, 8vw, 52px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 10px 0 4px;
  background: linear-gradient(92deg, var(--mmt-gold), #fff2b8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.podium .winner-points { font-family: var(--mono); font-size: 21px; color: var(--text-dim); }

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

.divider-line { height: 1px; background: var(--line-soft); margin: 20px 0; }

.list-reset { list-style: none; margin: 0; padding: 0; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; font-family: var(--mono); word-break: break-all; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in { animation: fadeIn 0.28s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
