/* Consensus — one stylesheet for phones and the big screen.
 *
 * The big screen is the same pages at a much larger size (body.is-viewer),
 * rather than a separate design. Fewer things to keep in step that way.
 */

:root {
  --bg: #07080f;
  --bg-soft: #101321;
  --line: #232842;
  --ink: #f2f4ff;
  --ink-dim: #8b93b8;
  --a: #ff2e88;
  --b: #22e0ff;
  --win: #5bf0a5;
  --warn: #ffc24b;
  --radius: 14px;
  --pad: clamp(1rem, 4vw, 2rem);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  padding: var(--pad);
  padding-bottom: max(var(--pad), env(safe-area-inset-bottom));
  max-width: 34rem;
  margin: 0 auto;
  width: 100%;
}

/* --- screens ------------------------------------------------------------ */

.screen { display: none; }
.screen.active {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: rise 0.25s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .screen.active { animation: none; }
}

/* --- type --------------------------------------------------------------- */

.wordmark {
  font-size: clamp(2.5rem, 12vw, 4rem);
  margin: 2rem 0 0;
  letter-spacing: -0.03em;
  line-height: 1;
}

.tagline { color: var(--ink-dim); margin: 0 0 1.5rem; font-size: 1.05rem; }
.eyebrow { color: var(--ink-dim); font-size: 0.85rem; margin: 0; text-transform: uppercase; letter-spacing: 0.08em; }
.section-head { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); margin: 0.5rem 0 0; }
.hint { color: var(--ink-dim); font-size: 0.9rem; margin: 0; }
.err { color: var(--warn); font-size: 0.95rem; margin: 0; }
h2 { margin: 0; font-size: 1.6rem; }

.code { font-variant-numeric: tabular-nums; letter-spacing: 0.25em; font-weight: 700; }
.code-big { font-size: clamp(3rem, 18vw, 6rem); margin: 0; line-height: 1; }

/* The way into the room: code above, camera target here, address as backup. */
.joinblock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
}

/* White quiet zone and white paper, whatever the theme is doing. A neon-tinted
   QR code is how you discover which guest has the fussy phone. */
.qr-code {
  background: #fff;
  border-radius: 8px;
  padding: 0;
  display: block;
  image-rendering: pixelated;
}

.qr {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-dim);
  word-break: break-all;
  text-align: center;
}

/* --- controls ----------------------------------------------------------- */

.stack { display: flex; flex-direction: column; gap: 0.8rem; }
.row { display: flex; gap: 0.6rem; align-items: center; }
.row-center { justify-content: center; flex-wrap: wrap; }

.btn {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1.2rem;
  cursor: pointer;
  min-height: 48px;
  transition: transform 0.06s ease, background 0.15s ease;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-quiet { background: transparent; color: var(--ink-dim); }
.btn-wide { width: 100%; }

.text-input, .code-input {
  font: inherit;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  padding: 0.9rem 1rem;
  min-height: 48px;
  width: 100%;
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 0.35em;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
}

.joinbox { display: flex; flex-direction: column; gap: 0.5rem; }
.joinbox label { color: var(--ink-dim); font-size: 0.9rem; }

.settings { display: grid; gap: 0.8rem; }
.settings fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin: 0;
}
.settings legend { color: var(--ink-dim); font-size: 0.8rem; padding: 0 0.3rem; }
.settings label { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0; cursor: pointer; }
.settings input { accent-color: var(--a); width: 1.1rem; height: 1.1rem; }

/* --- players ------------------------------------------------------------ */

.players { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.players li {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.95rem;
}
.players li.away { opacity: 0.4; }

/* --- voting ------------------------------------------------------------- */

.reader-call { text-align: center; }
.reader-badge {
  display: inline-block;
  background: var(--a);
  color: var(--bg);
  font-weight: 700;
  border-radius: 999px;
  padding: 0.4rem 1rem;
}

.prompt { font-size: 1.35rem; font-weight: 600; margin: 0; line-height: 1.3; }
.prompt-small { font-size: 1.05rem; color: var(--ink-dim); font-weight: 500; }

.options { display: grid; gap: 0.8rem; }

.option {
  font: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--bg-soft);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  padding: 1.1rem;
  min-height: 88px;
  cursor: pointer;
  transition: transform 0.06s ease, border-color 0.15s ease;
}

.option:active { transform: scale(0.99); }
.option-key {
  font-weight: 800;
  font-size: 1.3rem;
  width: 2.2rem; height: 2.2rem;
  flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
}
.option-a .option-key { background: var(--a); color: var(--bg); }
.option-b .option-key { background: var(--b); color: var(--bg); }
.option-text { font-size: 1.1rem; line-height: 1.3; }
.option-a.chosen { border-color: var(--a); }
.option-b.chosen { border-color: var(--b); }

.voted-line { margin: 0; color: var(--ink-dim); text-align: center; }

.pips { list-style: none; display: flex; gap: 0.4rem; justify-content: center; padding: 0; margin: 0; flex-wrap: wrap; }
.pip { width: 0.7rem; height: 0.7rem; border-radius: 50%; border: 1px solid var(--line); background: transparent; }
.pip.in { background: var(--win); border-color: var(--win); }
.pip.away { opacity: 0.3; }

/* --- reveal ------------------------------------------------------------- */

.tally { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.tally-side {
  background: var(--bg-soft);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  display: grid;
  gap: 0.3rem;
}
.tally-key { font-weight: 800; color: var(--ink-dim); }
.tally-count { font-size: clamp(2.5rem, 12vw, 4rem); font-weight: 800; line-height: 1; }
.tally-text { font-size: 0.95rem; color: var(--ink-dim); }
.tally-a.won { border-color: var(--a); }
.tally-b.won { border-color: var(--b); }

.verdict { text-align: center; font-size: 1.15rem; font-weight: 600; margin: 0; }

.names { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; }
.names-head { width: 100%; text-align: center; color: var(--ink-dim); margin: 0 0 0.2rem; font-size: 0.9rem; }
.chip { border-radius: 999px; padding: 0.35rem 0.8rem; font-size: 0.95rem; border: 1px solid var(--line); }
.chip-a { border-color: var(--a); }
.chip-b { border-color: var(--b); }

/* --- standings ---------------------------------------------------------- */

.winner-head { font-size: clamp(1.8rem, 9vw, 3rem); margin: 1rem 0 0; line-height: 1.1; }
.standings { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; counter-reset: place; }
.standings li {
  display: flex; justify-content: space-between; gap: 1rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
}
.pts { font-weight: 800; font-variant-numeric: tabular-nums; }

/* --- offline banner ----------------------------------------------------- */

.offline {
  position: fixed; inset: 0 0 auto 0;
  z-index: 10;
  background: var(--warn);
  color: var(--bg);
  text-align: center;
  padding: 0.5rem;
  font-weight: 700;
}

/* --- score rail (big screen only) --------------------------------------- */

.scorerail { display: none; }

/* --- the big screen ----------------------------------------------------- */

body.is-viewer #app { max-width: 90rem; padding: 3vmin 4vmin; }
body.is-viewer .prompt { font-size: clamp(2rem, 5vw, 4rem); }
body.is-viewer .option { min-height: auto; padding: 1.5rem; }
body.is-viewer .option-text { font-size: clamp(1.4rem, 3vw, 2.6rem); }
body.is-viewer .option-key { width: 3.5rem; height: 3.5rem; font-size: 2rem; }
body.is-viewer .options { grid-template-columns: 1fr 1fr; }
body.is-viewer .tally-count { font-size: clamp(4rem, 12vw, 9rem); }
body.is-viewer .tally-text { font-size: clamp(1.1rem, 2vw, 1.8rem); }
body.is-viewer .verdict { font-size: clamp(1.4rem, 3vw, 2.4rem); }
body.is-viewer .chip { font-size: clamp(1rem, 2vw, 1.6rem); }
body.is-viewer .code-big { font-size: clamp(5rem, 22vw, 14rem); }
body.is-viewer .qr { font-size: clamp(1rem, 2.5vw, 2rem); }
body.is-viewer .players li { font-size: clamp(1rem, 2vw, 1.6rem); }
body.is-viewer .eyebrow { font-size: clamp(0.9rem, 1.5vw, 1.3rem); }
body.is-viewer .voted-line { font-size: clamp(1.1rem, 2vw, 1.7rem); }
body.is-viewer .pip { width: 1.1rem; height: 1.1rem; }
body.is-viewer .winner-head { font-size: clamp(3rem, 9vw, 7rem); }
body.is-viewer .standings li { font-size: clamp(1.2rem, 2.5vw, 2rem); }
/* Buttons are meaningless on a screen nobody can tap. */
body.is-viewer .btn,
body.is-viewer .reader-call,
body.is-viewer .settings { display: none; }

body.is-viewer .scorerail {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  padding: 1.5vmin 4vmin;
  border-top: 1px solid var(--line);
  font-size: clamp(1rem, 2vw, 1.6rem);
}
body.is-viewer .rail-row { display: flex; gap: 0.5rem; }
body.is-viewer .rail-row.away { opacity: 0.4; }
