:root {
  --bg: #0b0b10;
  --surface: #17171f;
  --surface-2: #22222d;
  --line: #2e2e3a;
  --text: #ffffff;
  --muted: #a3a3b2;
  --cyan: #25f4ee;
  --pink: #fe2c55;
  --good: #25f4ee;
  --bad: #fe2c55;
  --opt-a: #fe2c55;
  --opt-b: #25a8f4;
  --opt-c: #f4b625;
  --opt-d: #3fd47a;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  -webkit-tap-highlight-color: transparent;
}

.brand {
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* The two-tone "glitch" heading. */
.glitch {
  text-shadow: -2px -1px 0 var(--cyan), 2px 1px 0 var(--pink);
}

.muted {
  color: var(--muted);
}

/* ── Options (shared by phone and booth) ─────────────────────────────── */

.opts {
  display: grid;
  gap: 12px;
}

.opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--line);
  text-align: left;
  font-weight: 600;
  line-height: 1.25;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s ease;
}

.opt .letter {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-weight: 800;
  color: #0b0b10;
  background: var(--c);
}

.opt:nth-child(1) {
  --c: var(--opt-a);
}
.opt:nth-child(2) {
  --c: var(--opt-b);
}
.opt:nth-child(3) {
  --c: var(--opt-c);
}
.opt:nth-child(4) {
  --c: var(--opt-d);
}

.opt.picked {
  box-shadow: inset 0 0 0 3px var(--c);
  background: color-mix(in srgb, var(--c) 18%, var(--surface));
}

.opt.right {
  box-shadow: inset 0 0 0 3px var(--good);
  background: color-mix(in srgb, var(--good) 22%, var(--surface));
}

.opt.wrong {
  box-shadow: inset 0 0 0 3px var(--bad);
  background: color-mix(in srgb, var(--bad) 18%, var(--surface));
}

.opt.dim {
  opacity: 0.4;
}

.opt .mark {
  margin-left: auto;
  font-size: 1.3em;
}

/* ── Phone ────────────────────────────────────────────────────────────── */

.phone {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.phone header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.phone header .brand {
  font-size: 18px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.card {
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  box-shadow: inset 0 0 0 1px var(--line);
}

.center {
  text-align: center;
}

.phone h1 {
  font-size: 30px;
  line-height: 1.1;
  margin: 8px 0 6px;
}

.phone h2 {
  font-size: 22px;
  line-height: 1.25;
  margin: 0;
}

.phone p {
  margin: 8px 0;
  line-height: 1.45;
}

.field {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  border: 0;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 2px var(--line);
  font-size: 18px;
  outline: none;
}

.field:focus {
  box-shadow: inset 0 0 0 2px var(--cyan);
}

.go {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  background: var(--pink);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  transition: transform 0.12s ease, opacity 0.2s ease;
}

.go:active,
.opt:active {
  transform: scale(0.97);
}

.go:disabled {
  opacity: 0.45;
}

.error {
  color: var(--pink);
  font-weight: 600;
  min-height: 1.4em;
}

.progress {
  display: flex;
  gap: 6px;
}

.progress span {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: var(--surface-2);
}

.progress .ok {
  background: var(--good);
}

.progress .no {
  background: var(--bad);
}

.progress .now {
  background: color-mix(in srgb, var(--text) 45%, var(--surface-2));
}

.big-emoji {
  font-size: 64px;
  line-height: 1;
}

.fact {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface-2);
  line-height: 1.45;
}

.prize {
  text-align: center;
  padding: 28px 20px;
  border-radius: 24px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--cyan) 30%, var(--surface)), color-mix(in srgb, var(--pink) 30%, var(--surface)));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--text) 25%, transparent);
}

.prize .code {
  margin: 14px auto 6px;
  font-size: 46px;
  font-weight: 900;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
}

.pulse {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

/* ── Booth screen ─────────────────────────────────────────────────────── */

.booth {
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(280px, 28vw, 440px);
  gap: clamp(16px, 2vw, 32px);
  padding: clamp(16px, 2.4vw, 40px);
  overflow: hidden;
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: clamp(14px, 2vh, 28px);
}

.stage .title {
  font-size: clamp(28px, 3.2vw, 56px);
  margin: 0;
}

.stage .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stage .meta .chip {
  font-size: clamp(14px, 1.2vw, 20px);
  padding: 8px 16px;
}

.question {
  font-size: clamp(26px, 3vw, 54px);
  font-weight: 800;
  line-height: 1.15;
  margin: 0;
}

.stage .opts {
  grid-template-columns: 1fr 1fr;
  gap: clamp(10px, 1.4vw, 20px);
}

.stage .opt {
  min-height: clamp(70px, 11vh, 130px);
  font-size: clamp(18px, 1.8vw, 32px);
  padding: clamp(12px, 1.4vw, 24px);
}

.stage .opt .letter {
  width: clamp(36px, 3vw, 54px);
  height: clamp(36px, 3vw, 54px);
  font-size: clamp(18px, 1.6vw, 28px);
}

.stage .opt .count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.stage .fact {
  font-size: clamp(16px, 1.5vw, 26px);
}

.stage .hint {
  font-size: clamp(16px, 1.4vw, 24px);
}

.idle {
  flex: 1;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 12px;
}

.idle .headline {
  font-size: clamp(36px, 5vw, 88px);
  font-weight: 900;
  line-height: 1.05;
  margin: 0;
}

.idle .sub {
  font-size: clamp(18px, 1.8vw, 32px);
  color: var(--muted);
  margin: 0;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.qr {
  background: #fff;
  border-radius: 24px;
  padding: clamp(12px, 1.2vw, 20px);
}

.qr img {
  display: block;
  width: 100%;
  height: auto;
}

/* Smaller on shorter screens, to leave room for who's playing. */
.qr {
  align-self: center;
  width: min(100%, 34vh);
}

.side .scan {
  text-align: center;
  font-size: clamp(20px, 1.8vw, 32px);
  font-weight: 800;
  margin: 0;
}

.side .url {
  text-align: center;
  font-size: clamp(12px, 0.95vw, 16px);
  color: var(--muted);
  word-break: break-all;
  margin: 0;
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: clamp(16px, 1.3vw, 22px);
}

.stat b {
  font-size: 1.4em;
}

/* Host controls: small, out of the way, for the person running it. */
.controls {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ctl {
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 700;
  font-size: 15px;
}

.ctl.main {
  flex: 1 1 100%;
  padding: 14px;
  background: var(--pink);
  box-shadow: none;
  font-size: 18px;
}

.ctl:disabled {
  opacity: 0.4;
  cursor: default;
}

.ctl kbd {
  font: inherit;
  font-size: 0.8em;
  opacity: 0.7;
}

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(560px, 100vw);
  background: var(--bg);
  box-shadow: -1px 0 0 var(--line), -20px 0 60px rgb(0 0 0 / 0.5);
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 10;
}

.drawer[hidden] {
  display: none;
}

.drawer h3 {
  margin: 0;
  font-size: 20px;
}

.drawer label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.drawer input[type="number"] {
  width: 110px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 0;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}

.winners {
  display: grid;
  gap: 8px;
}

.winner {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.winner.claimed {
  opacity: 0.55;
}

.winner code {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.small {
  font-size: 13px;
}

/* The PIN, on the public booth screen. */
.lock {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg);
}

.lock[hidden] {
  display: none;
}

/* Who's playing, on the booth screen. */
.roster {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.roster h3 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0;
  font-size: clamp(16px, 1.3vw, 22px);
}

.roster h3 b {
  font-size: 1.3em;
}

.roster-list {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 6px;
  /* Fades the last row out when there's more than fits. */
  mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
  padding-bottom: 12px;
}

.player {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "who pts" "dots tick";
  align-items: center;
  gap: 4px 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: clamp(15px, 1.15vw, 20px);
}

.player .who {
  grid-area: who;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player .pts {
  grid-area: pts;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.player .pts small {
  font-weight: 600;
  color: var(--muted);
}

.player .dots {
  grid-area: dots;
  display: flex;
  gap: 4px;
}

.player .dots i {
  flex: 1;
  max-width: 28px;
  height: 6px;
  border-radius: 99px;
  background: var(--surface-2);
}

.player .dots .ok {
  background: var(--good);
}

.player .dots .no {
  background: var(--bad);
}

.player .tick {
  grid-area: tick;
  justify-self: end;
  font-size: 0.85em;
  font-weight: 800;
  color: var(--muted);
}

.player .tick.in {
  color: var(--good);
}

/* The question's clock: a draining bar with the seconds on it. */
.timer {
  position: relative;
  height: 34px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}

.timer span {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--cyan), color-mix(in srgb, var(--cyan) 60%, var(--pink)));
  transition: width 0.1s linear;
}

.timer b {
  position: relative;
  display: grid;
  place-items: center;
  height: 100%;
  font-variant-numeric: tabular-nums;
  color: #fff;
  font-weight: 800;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.7);
}

.timer.low span {
  background: var(--pink);
}

.stage .timer {
  height: clamp(36px, 5vh, 56px);
  font-size: clamp(18px, 1.8vw, 30px);
}

.player .tick.away {
  color: var(--bad);
}

/* The question bank, in the host panel. */
.bank h3 {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.bank-filters {
  display: grid;
  gap: 8px;
}

.bank-filters .field {
  padding: 10px 12px;
  font-size: 15px;
}

.bank-tiers {
  display: flex;
  gap: 6px;
}

.bank-tiers .ctl {
  flex: 1;
  padding: 8px;
  font-size: 14px;
}

.bank-tiers .ctl.on {
  background: var(--text);
  color: var(--bg);
}

.bank-list {
  display: grid;
  gap: 6px;
}

.bank-q {
  border-radius: 12px;
  background: var(--surface-2);
  padding: 10px 12px;
}

.bank-q summary {
  display: flex;
  gap: 10px;
  align-items: baseline;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  line-height: 1.3;
}

.bank-q summary::-webkit-details-marker {
  display: none;
}

.bank-q ul {
  margin: 10px 0 6px;
  padding-left: 18px;
  line-height: 1.5;
}

.bank-q li.right {
  color: var(--good);
  font-weight: 700;
}

.bank-q p {
  margin: 4px 0 0;
}

.tier {
  flex: none;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 800;
  color: #0b0b10;
}

.tier.t1 {
  background: var(--opt-d);
}

.tier.t2 {
  background: var(--opt-c);
}

.tier.t3 {
  background: var(--pink);
}
