/* 5 in 30
   Flat silkscreen blocks, hard offset shadows, no gradients. During a turn the
   whole screen carries the playing team's colour so the phone reads as a
   scoreboard from across the room, and the timer drains as a bar so the
   describer never has to stop and read a number. */

:root {
  --ink: #17132B;
  --ink-raised: #221C3D;
  --paper: #F6F4F0;

  --t1: #E5564B;
  --t2: #00BFA0;
  --t3: #FFC42E;
  --t4: #8A6BFF;
  --t5: #38A1FF;

  /* Overwritten per team as play moves around the table. */
  --team: var(--t3);

  --display: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
             "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --gap: clamp(0.75rem, 3vw, 1.25rem);
  --pad: clamp(1.1rem, 5vw, 2rem);
}

* { box-sizing: border-box; }

/* The browser's own [hidden] rule loses to any author rule that sets display,
   so anything given `display` below would ignore the hidden attribute. */
[hidden] { display: none !important; }

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

body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--display);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* Handoff and turn take the team colour full bleed. */
body[data-screen="handoff"],
body[data-screen="turn"] {
  background: var(--team);
  color: var(--ink);
}

.screen { display: none; }
body[data-screen="setup"]   #screen-setup,
body[data-screen="boards"]  #screen-boards,
body[data-screen="lobby"]   #screen-lobby,
body[data-screen="handoff"] #screen-handoff,
body[data-screen="turn"]    #screen-turn,
body[data-screen="result"]  #screen-result,
body[data-screen="over"]    #screen-over {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.wrap {
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  padding: calc(var(--pad) + env(safe-area-inset-top)) var(--pad)
           calc(var(--pad) + env(safe-area-inset-bottom));
  flex: 1;
}

.wrap-centred {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

/* ---------- Setup ---------- */

.wordmark {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.35em;
  margin: 0.2em 0 0;
  font-size: clamp(3.2rem, 17vw, 5.5rem);
  line-height: 0.85;
  font-weight: 900;
  letter-spacing: -0.05em;
}

.wordmark-num { color: var(--paper); }
.wordmark-num:last-child { color: var(--t3); }

.wordmark-in {
  font-family: var(--mono);
  font-size: 0.24em;
  font-weight: 400;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--t2);
}

.tagline {
  margin: 0.9rem 0 2.2rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  color: rgba(246, 244, 240, 0.6);
}

.field { margin-bottom: 1.9rem; }

.label {
  display: block;
  margin-bottom: 0.6rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(246, 244, 240, 0.5);
}

.chips { display: flex; gap: 0.5rem; }

.chip {
  flex: 1;
  padding: 0.85rem 0;
  border: 2px solid rgba(246, 244, 240, 0.18);
  border-radius: 6px;
  background: transparent;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 1.15rem;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--paper);
  border-color: var(--paper);
  color: var(--ink);
}

.team-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}

.team-swatch {
  width: 0.7rem;
  align-self: stretch;
  min-height: 2.9rem;
  border-radius: 3px;
  background: var(--row-colour);
  flex: none;
}

.team-fields {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.team-fields input:first-child { grid-column: 1 / -1; }

input[type="text"], .target {
  width: 100%;
  padding: 0.7rem 0.75rem;
  border: 2px solid rgba(246, 244, 240, 0.16);
  border-radius: 5px;
  background: var(--ink-raised);
  color: var(--paper);
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
  min-width: 0;
}

input::placeholder { color: rgba(246, 244, 240, 0.32); font-weight: 400; }
input:focus-visible, .chip:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 3px solid var(--t3);
  outline-offset: 2px;
}

.target-row { display: flex; align-items: center; gap: 0.5rem; }

.target {
  width: 5.5rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 1.5rem;
  -moz-appearance: textfield;
}

.target::-webkit-outer-spin-button,
.target::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.stepper {
  width: 3rem;
  height: 3rem;
  border: 2px solid rgba(246, 244, 240, 0.18);
  border-radius: 5px;
  background: transparent;
  color: var(--paper);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.target-unit {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(246, 244, 240, 0.45);
}

.hint {
  margin: 0.7rem 0 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: rgba(246, 244, 240, 0.5);
}

.error {
  margin: 0 0 0.9rem;
  padding: 0.7rem 0.85rem;
  border-left: 4px solid var(--t1);
  background: rgba(255, 75, 62, 0.12);
  font-size: 0.92rem;
}

/* ---------- Buttons ---------- */

.action {
  display: block;
  width: 100%;
  margin-top: 0.7rem;
  padding: 1.15rem 1rem;
  border: 0;
  border-radius: 7px;
  background: var(--t3);
  color: var(--ink);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.35);
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  cursor: pointer;
}

.action:active { transform: translate(3px, 3px); box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.35); }

.action:disabled {
  opacity: 0.35;
  box-shadow: none;
  cursor: not-allowed;
}

.action:disabled:active { transform: none; }

.action-invert {
  background: var(--ink);
  color: var(--paper);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.22);
}

.action-quiet {
  background: transparent;
  color: rgba(246, 244, 240, 0.6);
  box-shadow: none;
  font-size: 0.95rem;
  font-weight: 600;
}

/* ---------- Rules ---------- */

.rules {
  margin-top: 2.4rem;
  border-top: 1px solid rgba(246, 244, 240, 0.14);
  padding-top: 1rem;
}

.rules summary {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(246, 244, 240, 0.5);
  cursor: pointer;
}

.rules ol { margin: 1rem 0 0; padding-left: 1.1rem; }
.rules li { margin-bottom: 0.5rem; font-size: 0.94rem; line-height: 1.45; }
.rules-note { font-size: 0.85rem; line-height: 1.5; color: rgba(246, 244, 240, 0.55); }

/* ---------- Handoff ---------- */

.eyebrow {
  margin: 0 0 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  opacity: 0.6;
}

.team-name {
  margin: 0;
  font-size: clamp(2.4rem, 12vw, 4rem);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: -0.045em;
  text-transform: uppercase;
}

/* The one thing that has to be readable at a glance: who is describing to whom.
   The team name and the round sit around it, quietly. */
.handoff-pass {
  margin: 0.4rem 0 0;
  font-size: clamp(1.9rem, 8.5vw, 3.1rem);
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.handoff-team {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.75;
}

.handoff-roles {
  margin: 1rem 0 2.2rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  opacity: 0.7;
}

.mini-scores {
  margin: 1.6rem 0 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  opacity: 0.65;
}

/* ---------- Turn ---------- */

.timer {
  height: 14px;
  margin-top: env(safe-area-inset-top);
  background: rgba(23, 19, 43, 0.18);
  flex: none;
}

.timer-fill {
  height: 100%;
  width: 100%;
  background: var(--ink);
  transform-origin: left center;
}

body[data-screen="turn"].hurry .timer-fill { background: var(--t1); }

.turn-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.7rem var(--pad) 0.2rem;
  flex: none;
}

.turn-team {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turn-clock {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hurry .turn-clock { animation: pulse 1s steps(2, end) infinite; }

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

.words {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0;
  padding: 0.5rem var(--pad);
  list-style: none;
}

/* The list items are the flex children, so they carry the growth and the
   buttons stretch to fill them. Five words always fill the screen. */
.words > li {
  flex: 1;
  display: flex;
}

.word {
  flex: 1;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 3.4rem;
  padding: 0.5rem 0.9rem;
  border: 2px solid transparent;
  border-radius: 7px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.22);
  font-family: var(--display);
  font-size: clamp(1.35rem, 6vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

/* A guessed word recedes into the team colour instead of piling up visual noise. */
.word.got {
  background: transparent;
  border-color: rgba(23, 19, 43, 0.3);
  border-style: dashed;
  color: rgba(23, 19, 43, 0.5);
  box-shadow: none;
  text-decoration: line-through;
  text-decoration-thickness: 0.12em;
}

.turn-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 0.3rem var(--pad) calc(0.9rem + env(safe-area-inset-bottom));
  flex: none;
}

.turn-tally {
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.give-up {
  padding: 0.6rem 1rem;
  border: 2px solid rgba(23, 19, 43, 0.3);
  border-radius: 5px;
  background: transparent;
  color: rgba(23, 19, 43, 0.75);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
}

/* ---------- Result ---------- */

.result-score {
  margin: 0;
  font-size: clamp(5rem, 30vw, 9rem);
  line-height: 0.8;
  font-weight: 900;
  letter-spacing: -0.06em;
  color: var(--team);
  font-variant-numeric: tabular-nums;
}

.result-caption {
  margin: 0.8rem 0 1.6rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.recap {
  margin: 0 0 1.6rem;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

.recap li {
  padding: 0.35rem 0.65rem;
  border-radius: 4px;
  background: var(--ink-raised);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.recap li.got { background: var(--team); color: var(--ink); font-weight: 700; }
.recap li.missed { color: rgba(246, 244, 240, 0.45); text-decoration: line-through; }

.run-total {
  margin: 0 0 1.6rem;
  padding: 0.7rem 0;
  border-top: 1px solid rgba(246, 244, 240, 0.12);
  border-bottom: 1px solid rgba(246, 244, 240, 0.12);
  font-family: var(--mono);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Scoreboard ---------- */

.scoreboard {
  width: 100%;
  margin: 0 0 1.8rem;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.scoreboard td {
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid rgba(246, 244, 240, 0.12);
  text-align: left;
}

.scoreboard td:first-child { width: 0.6rem; padding-right: 0; }
.scoreboard td:last-child { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.scoreboard .bar { display: block; width: 0.35rem; height: 1.1rem; border-radius: 2px; }
.scoreboard tr.out td { opacity: 0.35; }
.scoreboard .tag {
  margin-left: 0.5rem;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.7;
}

/* ---------- Saved runs ---------- */

.label-centred { text-align: center; margin-bottom: 0.4rem; }

.board-tabs { margin-bottom: 1.2rem; }

.board-tabs .chip {
  padding: 0.6rem 0;
  font-family: var(--display);
  font-size: 0.85rem;
  font-weight: 700;
}

.highscores td:first-child {
  width: 1.4rem;
  padding-right: 0.4rem;
  opacity: 0.45;
  font-variant-numeric: tabular-nums;
}

.run-meta {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  opacity: 0.45;
}

/* The run just finished, so it can be picked out of the table at a glance. */
.highscores tr.is-new td { color: var(--team); opacity: 1; }
.highscores tr.is-new .run-meta { opacity: 0.7; }

.board-status {
  margin: 0.7rem 0 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.5;
  letter-spacing: 0.06em;
  color: rgba(246, 244, 240, 0.5);
  min-height: 1.2em;
}

.empty-scores {
  margin: 0.8rem 0 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  color: rgba(246, 244, 240, 0.45);
}

/* ---------- Game over ---------- */

#winner-name { color: var(--team); }

.winner-caption {
  margin: 0.9rem 0 2rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  opacity: 0.7;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Lobby ---------- */

.room-code {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(3rem, 18vw, 5rem);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-indent: 0.18em;      /* the tracking would otherwise push it off centre */
  text-align: center;
  color: var(--t3);
}

#room-share { text-align: center; }
#room-status { text-align: center; }

.together { border-top: 1px solid rgba(246, 244, 240, 0.14); padding-top: 1.4rem; }

.join-row { display: flex; gap: 0.5rem; margin-top: 0.6rem; }

.join-row input {
  flex: 1;
  font-family: var(--mono);
  font-size: 1.2rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-align: center;
}

.join-row .chip { flex: none; padding-left: 1.4rem; padding-right: 1.4rem; }

.seat-row {
  display: flex;
  align-items: stretch;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}

.seats { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; }

.seat {
  padding: 0.85rem 0.6rem;
  border: 2px solid rgba(246, 244, 240, 0.16);
  border-radius: 5px;
  background: var(--ink-raised);
  color: var(--paper);
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.seat-empty {
  background: transparent;
  border-style: dashed;
  color: rgba(246, 244, 240, 0.45);
  font-weight: 400;
}

.seat-mine { border-color: var(--t3); }

/* Still in their seat, just not on the end of a connection at the moment. */
.seat-away { opacity: 0.45; font-style: italic; }

#lobby-blocked { text-align: center; margin-top: 0.6rem; }
#lobby-host-controls .label { margin-top: 1.1rem; }
#lobby-host-controls > .label:first-child { margin-top: 0; }

/* ---------- Roles during a remote turn ---------- */

/* What the guesser gets instead of the words, because their device is never
   sent them in the first place. */
.listening {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--pad);
  text-align: center;
}

.listening-lead {
  margin: 0;
  font-size: clamp(2.6rem, 14vw, 4.5rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  text-transform: uppercase;
}

.listening-sub {
  margin: 0.8rem 0 0;
  max-width: 18rem;
  font-size: 1rem;
  line-height: 1.5;
  opacity: 0.75;
}

/* A word nobody is allowed to tap should not look tappable. */
.word[disabled] { cursor: default; }

.waiting {
  margin: 1.1rem 0 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-align: center;
  opacity: 0.7;
}

/* ---------- Creating a room is the front door ---------- */

.action-hero {
  margin-top: 0;
  padding: 1.5rem 1rem;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.hero-hint { margin-bottom: 1.6rem; }

.label-spaced { margin-top: 1.4rem; }

/* One phone is still supported, just not the thing being offered first. */
.one-phone {
  margin-top: 0.6rem;
  border-top: 1px solid rgba(246, 244, 240, 0.14);
  padding-top: 1.1rem;
}

.one-phone summary {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(246, 244, 240, 0.62);
  cursor: pointer;
  padding: 0.3rem 0;
}

.one-phone[open] summary { margin-bottom: 0.6rem; }
.one-phone > .hint:first-of-type { margin-bottom: 1.4rem; }

#open-boards { margin-top: 1.4rem; }

/* ---------- Leaderboard screen ---------- */

.boards-heading {
  margin: 0 0 1.2rem;
  font-size: clamp(1.9rem, 9vw, 2.8rem);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.035em;
  color: var(--t3);
}

#boards-status { text-align: left; }
#boards-back { margin-top: 1.6rem; }

/* ---------- Team names ---------- */

.team-block { flex: 1; min-width: 0; }

.team-name-field {
  width: 100%;
  margin-bottom: 0.35rem;
  padding: 0.55rem 0.7rem;
  border: 2px solid rgba(246, 244, 240, 0.16);
  border-radius: 5px;
  background: var(--ink-raised);
  color: var(--paper);
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 800;
}

/* A team you are not in, and are not hosting: readable, plainly not yours. */
.team-name-field:disabled {
  background: transparent;
  border-color: rgba(246, 244, 240, 0.1);
  color: rgba(246, 244, 240, 0.6);
  -webkit-text-fill-color: rgba(246, 244, 240, 0.6);
  opacity: 1;
}

.run-players {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--display);
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.75;
}

.highscores tr.is-new .run-players { opacity: 1; }

/* Each game length is ranked on its own, so the board carries its own picker. */
.length-chips { margin-bottom: 1rem; }

.length-chips .chip {
  padding: 0.55rem 0;
  font-size: 0.95rem;
}
