/*
 * Phone-first, one hand, across a dark room.
 *
 * Everything is sized for a thumb and for being read at arm's length by
 * somebody who is also holding a drink and shouting. That is the actual design
 * constraint, and it is why the type is enormous and the palette is only four
 * colours: the room's black, a bookmaker's acid yellow, and the two sides of
 * every bet.
 */

:root {
  --bg: #0b0d0e;
  --panel: #16191c;
  --line: #262b30;
  --ink: #f2f4f5;
  --dim: #8b959d;
  --accent: #e8ff3a;
  --over: #22c98a;
  --under: #ff4d5e;
  --gold: #ffc94d;
  /*
   * The small-type scale.
   *
   * Everything here shares a screen with display type up to 140px, and at
   * 10-12px the labels stopped reading as text and started reading as texture.
   * Nothing goes below --t-xs.
   */
  --t-xs: 12px;
  --t-sm: 13.5px;
  --t-md: 15px;
  --radius: 16px;
  --pad: clamp(14px, 4vw, 22px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 ui-sans-serif, -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

/* ── Status bar ─────────────────────────────────────────────────────────── */

#bar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px var(--pad);
  border-bottom: 1px solid var(--line);
  font-size: var(--t-sm);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  flex: none;
}

#bar-points {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/*
 * The room code is also the exit, and it is the only one that exists mid-game.
 * It takes two taps — the first arms it — because a stray thumb on the header
 * should never drop somebody out of a round.
 */
#bar-code {
  width: auto;
  min-height: 0;
  padding: 2px 8px;
  margin: -2px -8px;
  font: inherit;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  background: none;
  border: 1px solid transparent;
  border-radius: 999px;
}

#bar-code.arm {
  color: var(--under);
  border-color: var(--under);
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: var(--pad);
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.spacer {
  flex: 1;
  min-height: 4px;
}

.eyebrow {
  font-size: var(--t-sm);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0;
}

h1 {
  font-size: clamp(34px, 11vw, 54px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin: 0;
  font-weight: 800;
}

h2 {
  font-size: clamp(22px, 6.5vw, 30px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0;
  font-weight: 750;
}

p {
  margin: 0;
  color: var(--dim);
}

.wordmark {
  font-weight: 800;
  letter-spacing: -0.04em;
  font-size: clamp(46px, 16vw, 76px);
  line-height: 0.85;
}

.wordmark span {
  color: var(--accent);
}

/* ── Cards & panels ─────────────────────────────────────────────────────── */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
}

.challenge {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: var(--pad);
}

/* A challenge somebody at this table wrote, rather than one that was dealt. */
.challenge.called {
  border-left-color: var(--gold);
}

.challenge.called .cat {
  color: var(--gold);
}

.challenge .cat {
  font-size: var(--t-sm);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.challenge .prompt {
  font-size: clamp(20px, 5.6vw, 26px);
  font-weight: 700;
  line-height: 1.18;
  margin: 6px 0 8px;
  color: var(--ink);
}

.challenge .limit {
  font-size: var(--t-md);
  color: var(--dim);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

button {
  font: inherit;
  font-weight: 750;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #20252a;
  color: var(--ink);
  padding: 18px 20px;
  min-height: 60px;
  width: 100%;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.12s ease;
}

button:active {
  transform: scale(0.98);
  filter: brightness(1.25);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #101200;
  font-size: 19px;
}

button.over {
  background: var(--over);
  border-color: var(--over);
  color: #00251a;
}

button.under {
  background: var(--under);
  border-color: var(--under);
  color: #2a0006;
}

button.ghost {
  background: transparent;
}

button.small {
  min-height: 46px;
  padding: 10px 14px;
  font-size: var(--t-md);
  width: auto;
}

.row {
  display: flex;
  gap: 10px;
}

.row > * {
  flex: 1;
}

.bet-choice {
  display: grid;
  gap: 12px;
}

.bet-choice button {
  min-height: 92px;
  font-size: 26px;
  letter-spacing: -0.01em;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  justify-content: center;
}

.bet-choice small {
  font-size: var(--t-sm);
  font-weight: 600;
  opacity: 0.75;
  letter-spacing: 0.04em;
}

/* ── Inputs ─────────────────────────────────────────────────────────────── */

input[type="text"] {
  font: inherit;
  font-size: 18px;
  width: 100%;
  padding: 16px;
  min-height: 58px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #101315;
  color: var(--ink);
}

/* On its own step the code field can be the size a shouted-across-a-room code
   deserves. Indented to keep the glyphs optically centred despite the tracking. */
input#code-input {
  text-transform: uppercase;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  font-weight: 800;
  text-align: center;
  font-size: clamp(30px, 9vw, 40px);
  min-height: 82px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 44px;
}

.chip-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-toggle button {
  width: auto;
  flex: 1 1 auto;
  min-height: 48px;
  padding: 10px 14px;
  font-size: var(--t-md);
  text-transform: capitalize;
}

.chip-toggle button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #101200;
}

/* ── The big number ─────────────────────────────────────────────────────── */

.bignum {
  font-size: clamp(76px, 26vw, 140px);
  font-weight: 800;
  line-height: 0.85;
  letter-spacing: -0.05em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.bignum.accent {
  color: var(--accent);
}

.bignum.warn {
  color: var(--under);
}

.bignum.good {
  color: var(--over);
}

.unit {
  text-align: center;
  font-size: 16px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

.claim {
  text-align: center;
}

/* Lifetime form. Quiet, but it's the line people will actually bet on. */
.record {
  text-align: center;
  font-size: var(--t-md);
  letter-spacing: 0.04em;
  color: var(--gold);
  margin: 6px 0 0;
}

.claim .who {
  font-size: 15px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

/* ── The odds reveal ────────────────────────────────────────────────────── */

.odds {
  text-align: center;
  animation: slam 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes slam {
  0% {
    transform: scale(1.5);
    opacity: 0;
  }
  60% {
    transform: scale(0.96);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

/* A word needs far less room than "100%" does. */
.odds .pct.word {
  font-size: clamp(42px, 15vw, 76px);
  letter-spacing: -0.02em;
}

.odds .pct {
  font-size: clamp(80px, 28vw, 150px);
  font-weight: 800;
  line-height: 0.85;
  letter-spacing: -0.05em;
  color: var(--under);
  font-variant-numeric: tabular-nums;
}

.oddsbar {
  display: flex;
  height: 22px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #101315;
}

.oddsbar i {
  display: block;
  height: 100%;
}

.oddsbar .u {
  background: var(--under);
}

.oddsbar .o {
  background: var(--over);
}

.legend {
  display: flex;
  justify-content: space-between;
  font-size: var(--t-sm);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.legend .u {
  color: var(--under);
}

.legend .o {
  color: var(--over);
}

/* ── The clock ──────────────────────────────────────────────────────────── */

/*
 * On a counting card the clock plays second fiddle to the tally, so it sits on
 * one line at half the weight. On a holding card the clock *is* the score, and
 * `.big` promotes it back to hero size.
 */
.clockrow {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}

.clock {
  font-size: clamp(30px, 9vw, 44px);
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--dim);
}

.clocklabel {
  font-size: var(--t-sm);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.clock.big {
  font-size: clamp(76px, 26vw, 140px);
  color: var(--ink);
  letter-spacing: -0.05em;
}

.clock.done {
  color: var(--over);
}

.clock.hot {
  color: var(--under);
  animation: pulse 0.6s ease-in-out infinite;
}

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

.tallybox {
  text-align: center;
}

.tally-btns {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
}

.tally-btns .plus {
  min-height: 108px;
  font-size: 34px;
  background: var(--accent);
  border-color: var(--accent);
  color: #101200;
}

.tally-btns .minus {
  min-height: 108px;
  font-size: 28px;
}

/* ── People ─────────────────────────────────────────────────────────────── */

.people {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--panel);
}

.person .nm {
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person.off .nm {
  color: var(--dim);
  text-decoration: line-through;
}

.person .chips {
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  font-weight: 700;
}

.person .form {
  font-size: var(--t-sm);
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.tag {
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--dim);
  white-space: nowrap;
}

.tag.brag {
  border-color: var(--accent);
  color: var(--accent);
}

.tag.ref {
  border-color: var(--gold);
  color: var(--gold);
}

.tag.locked {
  border-color: var(--over);
  color: var(--over);
}

.tag.u {
  border-color: var(--under);
  color: var(--under);
}

.tag.o {
  border-color: var(--over);
  color: var(--over);
}

.delta {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.delta.up {
  color: var(--over);
}

.delta.down {
  color: var(--under);
}

.delta.flat {
  color: var(--dim);
}

/* ── Verdict ────────────────────────────────────────────────────────────── */

.verdict {
  text-align: center;
  font-size: clamp(38px, 12vw, 60px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.verdict.hit {
  color: var(--over);
}

.verdict.miss {
  color: var(--under);
}

.lastcall {
  text-align: center;
  border: 1px dashed var(--gold);
  color: var(--gold);
  border-radius: 999px;
  padding: 8px;
  font-size: var(--t-sm);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 700;
}

/* ── The nudge ──────────────────────────────────────────────────────────── */

/*
 * Set on every screen in the room once a wait has gone on too long. On the
 * phone that owes the tap it breathes the button; on everyone else's it turns
 * the polite grey waiting line into something that reads as "we are all sat
 * here looking at you".
 */
body.overdue button.primary,
body.overdue .bet-choice button {
  animation: breathe 1.1s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    filter: brightness(1.3);
    transform: scale(1.015);
  }
}

.waiting-note {
  transition: color 0.4s ease;
}

body.overdue .waiting-note {
  color: var(--accent);
}

/* ── Toast ──────────────────────────────────────────────────────────────── */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--under);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: var(--t-md);
  max-width: 90vw;
  text-align: center;
  z-index: 10;
}

.center {
  text-align: center;
}

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

.tiny {
  font-size: var(--t-md);
}

/* Player codes get read aloud and typed in. */
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.1em;
  color: var(--gold);
}

input#restore-input {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  text-align: center;
  font-weight: 700;
  font-size: 22px;
  min-height: 70px;
}

/* The toast is red by default because it usually means something went wrong. */
#toast.good {
  background: var(--over);
  color: #00251a;
}

/* An armed destructive action, matching the room-code exit. */
button.arm {
  border-color: var(--under);
  color: var(--under);
}

/* A heads-up rather than an error — gold, not red. */
.caution {
  color: var(--gold);
}

/*
 * The ref line.
 *
 * Sits under the header on every screen of a live round. Deliberately quiet
 * when it's somebody else's job and loud when it's yours — the ref counting out
 * loud is what keeps a ref who also has a bet on it honest, so they need to
 * know it's them without reading the scoreboard.
 */
#roles {
  padding: 7px var(--pad);
  border-bottom: 1px solid var(--line);
  font-size: var(--t-sm);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  color: var(--dim);
  flex: none;
}

#roles b {
  color: var(--ink);
  font-weight: 700;
}

#roles.you {
  color: var(--accent);
}

#roles.you b {
  color: var(--accent);
}
