/* Shared tokens and the board, plus everything the phone needs.
   display.css layers the television-scale overrides on top. */

:root {
  /* Signal. #0f1720 is the anchor and it is the field itself: a deep ink blue
     the page recedes into, panels a shade above it, and everything that has to
     be read drawn in near-white or one of three signal colours on top.

     Dark because of what display.css assumes on its first line — the nearest
     viewer three metres away, the room dim and full of people. A light ground
     at that size is a lamp pointed at the party. It also buys the board back:
     the twelve marker colours become the only saturated things on screen.
     Text tones are all >= 7:1 on the ground. */
  --bg: #0f1720;
  --panel: #18232f;
  --panel-2: #223041;
  --line: #41566b;
  --line-soft: #2c3b4b;
  --text: #e9eff5;
  --muted: #a2b4c6;
  --accent: #3fc3ea;
  --accent-ink: #04202c;
  --good: #4fd39b;
  --warn: #f0c257;
  --bad: #ff7a72;
  /* Bars that are a block of colour rather than text on the page. A status bar
     has to shout across a dark screen, so these stay bright and take dark ink. */
  --warn-fill: #f5cd6e;
  --warn-ink: #2e2102;
  --bad-fill: #ff8f88;
  --bad-ink: #330906;
  --good-ink: #04291b;
  /* Below here: tints of the ground rather than colours in their own right.
     They were written out at each use site while the theme was one fixed pink,
     which is what made a retheme a search-and-replace instead of an edit here.
     Shadows are true black, not a tinted dark — on a dark ground a tinted
     shadow greys the panel it is meant to seat. */
  --shadow: rgba(0, 0, 0, 0.55);
  --shadow-soft: rgba(0, 0, 0, 0.32);
  --wash-lift: rgba(63, 195, 234, 0.1); /* accent, thrown from the top left */
  --wash-deep: rgba(0, 0, 0, 0.38); /* and the far corner falling away */
  --marker-ring: rgba(0, 0, 0, 0.55); /* seats a bright dot against the board */
  --marker-name-bg: rgba(24, 35, 47, 0.94);
  --halo: rgba(233, 239, 245, 0.5); /* lifts the crosshair off whatever is under it */
  --target-ring: #0f1720;
  --notice-bg: rgba(240, 194, 87, 0.12);
  --notice-line: rgba(240, 194, 87, 0.34);
  --radius: 14px;
  --tap: 48px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  /* Two washes over the ink so the flat background reads as a lit room rather
     than as a black rectangle: the accent thrown in from one corner, the other
     falling away. */
  background:
    radial-gradient(120% 80% at 8% -10%, var(--wash-lift), transparent 62%),
    radial-gradient(110% 70% at 100% 105%, var(--wash-deep), transparent 64%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none; /* no pull-to-refresh mid-drag */
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--muted);
}
.center {
  text-align: center;
}
[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ board */

.board-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  color: var(--muted);
}

.board-middle {
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}

.axis-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.axis-label span {
  display: block;
}

/* The side labels read bottom-to-top so long descriptors still fit. */
.axis-x {
  flex: 0 0 1.35rem;
  writing-mode: vertical-rl;
}
.axis-left span {
  transform: rotate(180deg);
}
.axis-right {
  writing-mode: vertical-rl;
}
.axis-y {
  min-height: 1.35rem;
}

.axis-x-unknown .axis-x,
.axis-y-unknown .axis-y {
  color: var(--warn);
  opacity: 0.85;
}

.board-surface {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  aspect-ratio: 1;
  background: radial-gradient(130% 130% at 50% 0%, var(--wash-lift), transparent 72%), var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  touch-action: none; /* the board owns every gesture on it */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.board-grid {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image:
    repeating-linear-gradient(to right, var(--line-soft) 0 1px, transparent 1px 10%),
    repeating-linear-gradient(to top, var(--line-soft) 0 1px, transparent 1px 10%);
  background-position: left top;
}

/* The centre lines, a little stronger than the rest of the grid. */
.board-grid::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, transparent calc(50% - 1px), var(--line) 50%, transparent calc(50% + 1px)),
    linear-gradient(to top, transparent calc(50% - 1px), var(--line) 50%, transparent calc(50% + 1px));
}

.board-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.guide {
  stroke: var(--accent);
  stroke-width: 1;
  opacity: 0.4;
  stroke-dasharray: 4 4;
}

.tether {
  stroke-width: 2;
  opacity: 0.55;
}

.board-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.marker {
  position: absolute;
  transform: translate(-50%, 50%);
  --marker-color: var(--accent);
  transition:
    left 260ms cubic-bezier(0.2, 0.8, 0.2, 1),
    bottom 260ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 200ms ease;
}

.marker-dot {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--marker-color);
  border: 2px solid var(--marker-ring);
  box-shadow: 0 1px 4px var(--shadow-soft);
}

.marker-name {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--marker-name-bg);
  color: var(--text);
  box-shadow: 0 1px 4px var(--shadow-soft);
  font-size: 0.72rem;
  font-weight: 650;
  white-space: nowrap;
}

.marker.label-below .marker-name {
  bottom: auto;
  top: calc(100% + 4px);
}

.marker-crosshair {
  transition: none; /* the crosshair must track the thumb exactly, with no easing */
}
.marker-crosshair .marker-dot {
  width: 26px;
  height: 26px;
  background: transparent;
  border: 3px solid var(--accent);
  box-shadow:
    0 0 0 2px var(--halo),
    0 0 14px var(--accent);
}
.marker-crosshair .marker-dot::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
}

.marker-target .marker-dot {
  width: 26px;
  height: 26px;
  background: var(--text);
  border: 4px solid var(--target-ring);
  box-shadow:
    0 0 0 3px var(--text),
    0 0 26px var(--shadow);
}

/* The target falls in after the guesses are already committed. */
.marker-target {
  animation: drop 620ms cubic-bezier(0.16, 1.2, 0.3, 1) both;
}

@keyframes drop {
  from {
    transform: translate(-50%, calc(50% - 60px)) scale(1.8);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 50%) scale(1);
    opacity: 1;
  }
}

/* A dimmed marker on the ink board still has to read as present rather than
   gone, and opacity against a dark ground eats a dot faster than against a
   pale one, so the resting state sits high. */
.marker.is-dim {
  opacity: 0.55;
}
.marker.is-active .marker-dot {
  box-shadow:
    0 0 0 3px var(--marker-ring),
    0 0 22px var(--marker-color);
}
.marker.is-active {
  z-index: 3;
}

@media (prefers-reduced-motion: reduce) {
  .marker,
  .marker-target {
    animation: none;
    transition: none;
  }
}

/* ------------------------------------------------------------------ phone */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

#hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.82rem;
  color: var(--muted);
  min-height: 42px;
}

#hud-name {
  font-weight: 700;
  color: var(--text);
}

#hud-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

#hud-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

#hud-timer.urgent {
  color: var(--bad);
  font-weight: 700;
}

#screen {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 14px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1 1 auto;
}

.card {
  position: relative;
  background: linear-gradient(160deg, var(--wash-lift), transparent 58%), var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 2px 10px var(--shadow-soft);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.big {
  font-size: 1.6rem;
  font-weight: 700;
}

.clue {
  font-size: 2rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  word-break: break-word;
}

/* --- controls --- */

button,
input {
  font: inherit;
  font-family: var(--font);
}

.btn {
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 650;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-ready {
  background: var(--good);
  border-color: var(--good);
  color: var(--good-ink);
}

.btn-locked {
  background: var(--panel-2);
  border-color: var(--good);
  color: var(--good);
}

.btn-ghost {
  background: transparent;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 10px;
}

.btn-row > * {
  flex: 1 1 0;
}

input[type='text'] {
  width: 100%;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
}

input[type='text']:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* The reveal board on a phone that is the only screen in the game. The board
   sizes itself; this is only the line under it that names the winner. */
.reveal-winner {
  margin: 0;
  min-height: 1.4em;
  text-align: center;
  font-weight: 700;
  color: var(--accent);
}

#reveal-waiting {
  margin: 0;
  text-align: center;
  font-size: 0.9rem;
}

.field-error {
  color: var(--bad);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.seg {
  display: flex;
  gap: 6px;
}

.seg button {
  flex: 1 1 0;
  min-height: var(--tap);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 10px;
  font-weight: 650;
  cursor: pointer;
}

.seg button[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.seg-hint {
  font-size: 0.82rem;
  color: var(--muted);
  min-height: 2.4em;
}

/* --- player lists --- */

.players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.players li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 9px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
}

.players li.away {
  opacity: 0.45;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
}

.tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.tag-ready {
  color: var(--good);
}

/* --- results --- */

.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel-2);
  border-radius: 10px;
  border: 1px solid var(--line-soft);
}

.result-list .name {
  flex: 1 1 auto;
  font-weight: 650;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-list .dist {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.result-list .pts {
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  min-width: 2.2em;
  text-align: right;
}

.result-list .delta {
  color: var(--good);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.result-list li.is-you {
  border-color: var(--accent);
}

/* The clue-giver's own line: scored on how close the whole room landed, so it
   is in the list but it is not a guess. */
.result-list li.is-chooser {
  border-style: dashed;
}

.result-list li.is-chooser .name {
  font-style: italic;
}

.rank {
  width: 1.6em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* --- status bar --- */

#status {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  background: var(--warn-fill);
  color: var(--warn-ink);
  font-weight: 700;
  font-size: 0.88rem;
  text-align: center;
  z-index: 20;
}

#status.offline {
  background: var(--warn-fill);
}
#status.superseded {
  background: var(--bad-fill);
  color: var(--bad-ink);
}

.countdown-number {
  font-size: 6rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  color: var(--accent);
}

.notice {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--notice-bg);
  border: 1px solid var(--notice-line);
  color: var(--warn);
  font-size: 0.9rem;
}

.host-tools {
  border-top: 1px dashed var(--line);
  padding-top: 12px;
  margin-top: 4px;
}

/* Chips that are buttons in all but name get a real tap target. Both the host
   tools and the lobby's locked-chooser picker are made of them. */
.host-tools .players li,
.players.pickable li {
  min-height: 44px;
  padding-left: 12px;
  cursor: pointer;
}

/* The one chip in a picker that is currently chosen. A border alone is too
   quiet to read at a glance on a phone in a dim room. */
.players li.is-picked {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Ending the game throws every score away, so the button says so before it is
   armed and shouts once it is. Two taps, five seconds apart at most. */
.btn-danger {
  color: var(--bad);
  border-color: var(--bad);
}

.btn-danger.is-armed {
  background: var(--bad-fill);
  color: var(--bad-ink);
  border-color: var(--bad);
  font-weight: 750;
}

.host-tools summary {
  min-height: 44px;
  display: flex;
  align-items: center;
}


/* --------------------------------------------------------------- headline */

/* The join screen is the first thing anybody sees, and the only one they read
   standing still, so its headline is a size larger than the rest. */
#panel-join h1 {
  font-size: 2.1rem;
  letter-spacing: -0.02em;
}
