/* Layout: one centred stage column; host stage scales type up for screen share.
   Deliberately single-theme (dark game-show set), so no light variant. */
:root {
  color-scheme: dark;
  --bg: #0c2430;
  --bg-deep: #081a23;
  --panel: #12323f;
  --panel-2: #184252;
  --line: #24576b;
  --fg: #f4efe4;
  --muted: #9dbac2;
  --accent: #ff8a3d;
  --good: #3ddc97;
  --bad: #ff6b6b;
  --opt-0: #ff6b6b;
  --opt-1: #ffc145;
  --opt-2: #3ddc97;
  --opt-3: #5aa9ff;
  --opt-4: #b48cff;
  --on-opt: #10202a;
  --display: "Bricolage Grotesque", "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, var(--panel-2), transparent 70%), var(--bg);
  background-color: var(--bg);
  color: var(--fg);
  font: 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding-block: 20px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.logo { font-family: var(--display); font-weight: 800; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--on-opt); display: grid; place-items: center; font-size: 18px; transform: rotate(-6deg); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.code { font-family: var(--mono); font-weight: 700; letter-spacing: 0.12em; color: var(--fg); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; font-weight: 700; color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 14px; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
label .hint { font-weight: 400; color: var(--muted); }
input[type="text"], textarea {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
}
textarea { resize: vertical; min-height: 84px; }
input.code-input { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.3em; font-size: 24px; text-align: center; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  background: var(--accent);
  color: var(--on-opt);
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.btn.big { padding: 16px 26px; font-size: 18px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }

/* Answer options */
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px; }
.opt {
  --c: var(--opt-0);
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 0;
  border-radius: var(--radius);
  padding: 16px;
  min-height: 72px;
  background: var(--c);
  color: var(--on-opt);
  font-weight: 700;
  font-size: 17px;
  cursor: pointer;
  overflow: hidden;
}
.opt .letter { flex: none; width: 34px; height: 34px; border-radius: 9px; background: rgb(0 0 0 / 0.16); display: grid; place-items: center; font-family: var(--display); font-size: 18px; }
.opt .label { position: relative; z-index: 1; min-width: 0; overflow-wrap: anywhere; }
.opt .count { margin-left: auto; position: relative; z-index: 1; font-family: var(--mono); font-size: 15px; }
.opt .bar { position: absolute; inset: 0 auto 0 0; background: rgb(255 255 255 / 0.28); width: 0; transition: width 0.6s ease; }
.opt:nth-child(5n + 2) { --c: var(--opt-1); }
.opt:nth-child(5n + 3) { --c: var(--opt-2); }
.opt:nth-child(5n + 4) { --c: var(--opt-3); }
.opt:nth-child(5n + 5) { --c: var(--opt-4); }
.opt[disabled] { cursor: default; }
.opt.dim { opacity: 0.28; }
.opt.picked { outline: 4px solid var(--fg); outline-offset: 3px; }
.opt.right { opacity: 1; box-shadow: 0 0 0 4px var(--fg), 0 10px 30px rgb(0 0 0 / 0.35); }

/* Timer */
.timer { height: 10px; border-radius: 999px; background: var(--bg-deep); overflow: hidden; }
.timer > i { display: block; height: 100%; background: var(--accent); width: 100%; transform-origin: left; }
.timer.low > i { background: var(--bad); }
.secs { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Leaderboard */
.board { display: flex; flex-direction: column; gap: 6px; }
.board .r { display: grid; grid-template-columns: 2.2em 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--bg-deep); }
.board .r.me { outline: 2px solid var(--accent); }
.board .pos { font-family: var(--display); font-weight: 800; color: var(--muted); }
.board .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.board .nm small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.board .pts { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 700; }

.status { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--panel-2); font-weight: 600; }
.status.err { background: color-mix(in srgb, var(--bad) 22%, var(--panel)); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.result { font-family: var(--display); font-size: 34px; font-weight: 800; }
.result.good { color: var(--good); }
.result.bad { color: var(--bad); }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 700; z-index: 20; max-width: calc(100% - 32px); }

.pop { animation: pop 0.35s ease-out; }
@keyframes pop { from { transform: scale(0.97); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .pop, .spinner { animation: none; }
  .opt .bar { transition: none; }
}
