/* Game-table felt, marigold values, chalk text.
   Big Shoulders Display: scoreboard signage for values, categories, scores.
   Atkinson Hyperlegible: clue text, built for reading at a distance. */
:root {
  --felt: #0d3836;
  --felt-deep: #082624;
  --tile: #145350;
  --tile-hi: #1b6a66;
  --marigold: #f4b43a;
  --chalk: #f2eee3;
  --chalk-dim: #a9c2bd;
  --berry: #e5574b;
  --mint: #79d59c;
  --display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --text: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --r: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--felt);
  color: var(--chalk);
  font: 17px/1.45 var(--text);
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
[hidden] { display: none !important; }
.money { font-family: var(--display); font-weight: 800; letter-spacing: 0.01em; }

.btn {
  border: 0; border-radius: var(--r); padding: 0.7em 1.1em;
  background: var(--tile); color: var(--chalk); font-weight: 700;
  min-height: 48px; touch-action: manipulation;
}
.btn:hover { background: var(--tile-hi); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--marigold); color: #2a1d02; }
.btn.primary:hover { background: #ffc657; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--tile-hi); }
.btn.good { background: var(--mint); color: #062615; }
.btn.bad { background: var(--berry); color: #2b0603; }
.btn:disabled { opacity: 0.4; cursor: default; }

/* ===================================================================== TV */
.tv { overflow: hidden; cursor: none; height: 100dvh; display: grid; grid-template-rows: 1fr auto; }
.tv.pointer { cursor: default; }
.tv-stage { position: relative; min-height: 0; padding: 1.6vmin; }
.board {
  height: 100%; display: grid; gap: 0.9vmin;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: minmax(0, 1.15fr) repeat(var(--rows), minmax(0, 1fr));
}
.cat, .tile {
  border-radius: 0.8vmin; display: grid; place-items: center; text-align: center; min-width: 0;
}
.cat {
  background: var(--felt-deep); padding: 0.6vmin 0.8vmin;
  font: 800 clamp(14px, 2.9vmin, 40px)/1.02 var(--display); text-transform: none;
  color: var(--chalk); overflow-wrap: anywhere;
  border-bottom: 0.5vmin solid var(--marigold);
}
.tile {
  background: linear-gradient(180deg, var(--tile-hi), var(--tile));
  box-shadow: inset 0 -0.5vmin 0 rgba(0,0,0,.25);
  font: 900 clamp(20px, 7vmin, 110px)/1 var(--display); color: var(--marigold);
  text-shadow: 0 0.35vmin 0 rgba(0,0,0,.35);
}
.tile.used { background: var(--felt-deep); box-shadow: none; color: transparent; text-shadow: none; }

.clue-card {
  position: absolute; inset: 1.6vmin; border-radius: 1.2vmin;
  background: linear-gradient(180deg, var(--tile-hi), var(--tile) 60%, var(--felt-deep));
  display: grid; grid-template-rows: auto 1fr auto; padding: 3vmin 5vmin 0;
  transform-origin: 0 0;
}
.clue-head { display: flex; justify-content: space-between; align-items: baseline; gap: 2vmin; }
.clue-cat { font: 800 clamp(16px, 4vmin, 54px)/1 var(--display); color: var(--chalk-dim); }
.clue-val { font: 900 clamp(22px, 7vmin, 96px)/1 var(--display); color: var(--marigold); }
.clue-body { display: grid; align-content: center; justify-items: center; gap: 4vmin; min-height: 0; text-align: center; }
.clue-text {
  margin: 0; max-width: 34ch; white-space: pre-line; font-weight: 700;
  font-size: var(--fs, 6vmin); line-height: 1.22; text-wrap: balance;
}
.clue-answer {
  margin: 0; font: 900 var(--afs, 8vmin)/1.05 var(--display); color: var(--marigold);
  max-width: 24ch; text-wrap: balance;
}
.clue-answer.show { animation: pop 380ms cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

.timer { height: 9vmin; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2vmin; }
.timer-track { height: 1.6vmin; background: rgba(0,0,0,.35); border-radius: 99px; overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--marigold); transform-origin: left; border-radius: inherit; }
.timer-num { font: 900 clamp(20px, 6vmin, 80px)/1 var(--display); min-width: 2.2ch; text-align: right; color: var(--marigold); }
.timer.low .timer-fill { background: var(--berry); }
.timer.low .timer-num { color: var(--berry); }
.timer.done .timer-num { color: var(--berry); }
.timer.paused { opacity: 0.55; }
.timer.idle { visibility: hidden; }

.scores {
  display: flex; gap: 1vmin; padding: 0 1.6vmin 1.6vmin; justify-content: center; flex-wrap: wrap;
}
.score {
  flex: 1 1 0; max-width: 28vw; min-width: 0; background: var(--felt-deep); border-radius: 0.8vmin;
  padding: 0.8vmin 1.6vmin; display: flex; justify-content: space-between; align-items: baseline; gap: 1.2vmin;
}
.score-name { font-weight: 700; font-size: clamp(13px, 2.6vmin, 34px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-pts { font: 900 clamp(16px, 4.2vmin, 56px)/1 var(--display); color: var(--marigold); }
.score-pts.neg { color: var(--berry); }
.score.bump .score-pts { animation: bump 500ms ease-out; }
@keyframes bump { 30% { transform: scale(1.25); } }

.standings {
  position: absolute; inset: 1.6vmin; display: grid; align-content: center; justify-items: center; gap: 2.5vmin;
  background: var(--felt);
}
.standings h1 { margin: 0 0 1vmin; font: 900 clamp(28px, 9vmin, 130px)/1 var(--display); color: var(--marigold); }
.standings ol { list-style: none; margin: 0; padding: 0; width: min(80vw, 120vmin); display: grid; gap: 1.4vmin; }
.standings li {
  display: grid; grid-template-columns: 6vmin 1fr auto; align-items: baseline; gap: 2vmin;
  background: var(--felt-deep); border-radius: 1vmin; padding: 1.6vmin 3vmin;
  font-size: clamp(18px, 4.6vmin, 64px); font-weight: 700;
}
.standings li .rank { font-family: var(--display); color: var(--chalk-dim); font-weight: 800; }
.standings li:first-child { box-shadow: inset 0 0 0 0.5vmin var(--marigold); }

.tv-overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; text-align: center;
  background: rgba(8,38,36,.94); cursor: default; padding: 24px;
}
.tv-overlay h1 { font: 900 clamp(32px, 9vmin, 120px)/1 var(--display); color: var(--marigold); margin: 0 0 0.3em; }
.tv-overlay p { font-size: clamp(16px, 3vmin, 34px); color: var(--chalk-dim); margin: 0.3em 0; }
.code-form { display: flex; gap: 12px; justify-content: center; margin-top: 1em; flex-wrap: wrap; }
.code-input {
  width: 6.2ch; text-align: center; text-transform: uppercase; letter-spacing: 0.15em;
  font: 900 clamp(36px, 9vmin, 110px)/1 var(--display); background: var(--felt-deep);
  border: 3px solid var(--tile-hi); border-radius: var(--r); padding: 0.1em 0.2em; color: var(--marigold);
}
.code-input:focus { border-color: var(--marigold); outline: none; }
.status-pill {
  position: fixed; top: 1.2vmin; right: 1.2vmin; z-index: 5; padding: 0.4em 0.9em; border-radius: 99px;
  background: var(--berry); color: #2b0603; font-weight: 700; font-size: clamp(12px, 2vmin, 22px);
}
.room-tag { position: fixed; left: 1.6vmin; bottom: 0.3vmin; font: 700 clamp(10px, 1.6vmin, 18px) var(--display); color: var(--chalk-dim); opacity: .6; }

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

/* =================================================================== HOST */
.host { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.host-bar {
  position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--felt-deep);
}
.host-bar .room { font: 900 28px/1 var(--display); color: var(--marigold); letter-spacing: 0.08em; }
.host-bar .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--chalk-dim); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--berry); flex: none; }
.dot.online, .dot.local { background: var(--mint); }
.host-main {
  display: grid; gap: 16px; padding: 16px; align-content: start;
  grid-template-columns: minmax(0, 1fr);
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
@media (min-width: 900px) {
  .host-main { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); }
  .host-main .side { grid-column: 2; grid-row: 1 / span 3; }
}
.panel { background: var(--felt-deep); border-radius: 14px; padding: 16px; }
.panel h2 { margin: 0 0 10px; font: 800 22px/1.1 var(--display); color: var(--chalk-dim); }

.mini-board { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 6px; }
.mini-cat { font: 800 14px/1.05 var(--display); text-align: center; padding: 4px 2px; color: var(--chalk-dim); hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; align-self: end; }
.mini-tile {
  border: 0; border-radius: 8px; min-height: 52px; background: var(--tile); color: var(--marigold);
  font: 900 22px/1 var(--display);
}
.mini-tile:hover { background: var(--tile-hi); }
.mini-tile.used { background: transparent; color: var(--chalk-dim); box-shadow: inset 0 0 0 2px var(--tile); font-size: 15px; opacity: .55; }
.board-tools { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; color: var(--chalk-dim); font-size: 15px; }
.board-tools .btn { min-height: 40px; padding: 0.4em 0.9em; }
.edit-used .mini-tile.used { opacity: 1; box-shadow: inset 0 0 0 2px var(--marigold); }

.now-cat { color: var(--chalk-dim); font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.now-cat .money { color: var(--marigold); font-size: 26px; }
.now-clue { font-size: 21px; font-weight: 700; margin: 8px 0 14px; white-space: pre-line; }
.now-answer {
  border-radius: 10px; padding: 12px 14px; background: rgba(244,180,58,.12);
  box-shadow: inset 4px 0 0 var(--marigold); margin-bottom: 14px;
}
.now-answer .lbl { font-size: 14px; color: var(--chalk-dim); }
.now-answer .ans { font: 800 28px/1.1 var(--display); color: var(--marigold); }
.now-answer .note { margin-top: 6px; color: var(--chalk-dim); font-size: 15px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 140px; }
.on-tv { font-size: 14px; color: var(--chalk-dim); margin-top: 10px; }

.timer-panel { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.big-time { font: 900 56px/1 var(--display); color: var(--marigold); min-width: 2.2ch; text-align: center; }
.big-time.low, .big-time.done { color: var(--berry); }
.timer-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.timer-btns .btn { flex: 1 1 90px; }

.team-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 12px;
  padding: 10px 0; border-top: 1px solid rgba(255,255,255,.07);
}
.team-row:first-of-type { border-top: 0; }
.team-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-score { font: 900 30px/1 var(--display); color: var(--marigold); background: none; border: 0; padding: 4px 6px; border-radius: 6px; }
.team-score.neg { color: var(--berry); }
.team-btns { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.team-btns .btn { min-height: 54px; font-size: 18px; }
.team-adjust { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.team-adjust input { width: 7em; background: var(--felt); border: 2px solid var(--tile-hi); border-radius: 8px; padding: 8px; }
.team-tools { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.team-tools .btn { min-height: 40px; padding: 0.4em 0.9em; flex: 1 1 auto; }

.menu { display: grid; gap: 8px; }
.menu .btn { text-align: left; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20;
  background: var(--chalk); color: var(--felt-deep); padding: 10px 16px; border-radius: 10px; font-weight: 700;
  max-width: calc(100vw - 32px);
}
.toast.err { background: var(--berry); color: #2b0603; }
.hint { color: var(--chalk-dim); font-size: 15px; }
.hint code, .linkbox code { background: var(--felt); padding: 2px 6px; border-radius: 5px; }
.linkbox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }

/* ================================================================== SETUP */
.setup { max-width: 1040px; margin: 0 auto; padding: 28px 18px 80px; }
.setup-hero { display: grid; gap: 6px; margin-bottom: 22px; }
.setup-hero h1 { margin: 0; font: 900 clamp(44px, 9vw, 92px)/0.92 var(--display); color: var(--marigold); }
.setup-hero p { margin: 0; color: var(--chalk-dim); max-width: 60ch; }
.step { background: var(--felt-deep); border-radius: 16px; padding: 18px; margin-bottom: 16px; }
.step h2 { margin: 0 0 4px; font: 800 28px/1.1 var(--display); }
.step > p { margin: 0 0 14px; color: var(--chalk-dim); }
.sources { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.source {
  text-align: left; border: 0; border-radius: 12px; padding: 14px; background: var(--tile); min-height: 86px;
  display: grid; align-content: start; gap: 4px;
}
.source:hover { background: var(--tile-hi); }
.source b { font-size: 18px; }
.source span { color: var(--chalk-dim); font-size: 14px; }
.paste { width: 100%; min-height: 160px; margin-top: 10px; background: var(--felt); border: 2px solid var(--tile-hi); border-radius: 10px; padding: 10px; }
.saved-list { display: grid; gap: 8px; margin-top: 12px; }
.saved-item { display: flex; gap: 8px; align-items: center; }
.saved-item .btn { min-height: 40px; padding: 0.4em 0.9em; }
.saved-item .name { flex: 1; }

.warnings { margin: 0 0 14px; padding: 12px 14px 12px 34px; border-radius: 10px; background: rgba(229,87,75,.14); color: #ffd2cd; }
.warnings li { margin: 2px 0; }
.field { display: grid; gap: 4px; }
.field label, .lbl-sm { font-size: 14px; color: var(--chalk-dim); }
.inp {
  width: 100%; background: var(--felt); border: 2px solid var(--tile); border-radius: 8px; padding: 8px 10px;
}
.inp:focus { border-color: var(--marigold); outline: none; }
textarea.inp { resize: vertical; min-height: 2.6em; }
.title-inp { font: 800 26px/1.1 var(--display); }
.cat-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 10px; }
.cat-tab { border: 0; border-radius: 8px; padding: 8px 12px; background: var(--tile); font-weight: 700; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-tab[aria-selected="true"] { background: var(--marigold); color: #2a1d02; }
.cat-tab.warn::after { content: " •"; color: var(--berry); }
.clue-edit { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 12px 0; border-top: 1px solid rgba(255,255,255,.07); }
.clue-edit .money { color: var(--marigold); font-size: 26px; padding-top: 22px; }
.clue-edit .fields { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.clue-edit .fields .field:first-child { grid-column: 1 / -1; }
@media (max-width: 600px) { .clue-edit .fields { grid-template-columns: 1fr; } }
.teams-edit { display: grid; gap: 8px; }
.team-edit { display: flex; gap: 8px; }
.team-edit .btn { min-height: 44px; }
.settings-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-top: 14px; }
.check { display: flex; gap: 10px; align-items: center; }
.check input { width: 22px; height: 22px; accent-color: var(--marigold); }
.start-row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.start-row .btn { min-height: 64px; font-size: 19px; }
.start-row .sub { display: block; font-weight: 400; font-size: 14px; opacity: .8; }
.file-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.file-actions .btn { min-height: 40px; padding: 0.4em 0.9em; }
