/* One stylesheet for both screens: the players' phones and the big board view. */
:root {
  --ink: #f4f1ea;
  --page: #14121a;
  --panel: #1e1b27;
  --raised: #282433;
  --line: #3a3447;
  --muted: #a39db4;
  --accent: #ffc14d;
  --good: #67d98b;
  --bad: #ff7a7a;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
}

h1 { font-size: 30px; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 19px; margin: 0 0 12px; }
p { margin: 0 0 14px; }
.note { color: var(--muted); font-size: 15px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }

label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
input, select {
  font: inherit; width: 100%; padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--raised); color: var(--ink);
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

button {
  font: inherit; font-weight: 600; cursor: pointer; min-height: 48px;
  padding: 13px 20px; border-radius: 12px; border: 1px solid transparent;
  background: var(--accent); color: #241c05;
}
button.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
button[disabled] { opacity: .5; cursor: not-allowed; }

/* The board: four by four, square, as big as the screen allows */
.board { display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: clamp(3px, calc(32px / var(--cols, 4)), 8px); margin: 12px 0; }
.tile {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 12px;
  background: linear-gradient(#f6f2e8, #e2dbcb); color: #221d14;
  font-weight: 800; letter-spacing: -0.02em;
  /* Sized off the number of columns, so an 8x8 board still reads */
  font-size: clamp(11px, calc(36vw / var(--cols, 4)), 44px);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18);
}
.board.big .tile { font-size: min(calc(44vw / var(--cols, 4)), calc(44vh / var(--cols, 4)), 120px); border-radius: 18px; }

/* Drawing a word: the board must not scroll under the finger, and a chosen tile has to be obvious at a glance */
.board { touch-action: none; user-select: none; -webkit-user-select: none; }
.tile { -webkit-touch-callout: none; }
.tile.on { background: linear-gradient(var(--accent), #f0a81f); color: #241c05; transform: scale(.94); box-shadow: inset 0 -3px 0 rgba(0,0,0,.2); }
.trace { min-height: 34px; font-size: 24px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; display: flex; align-items: center; }

/* The clock, and the bar that drains with it */
.clock { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 34px; letter-spacing: -0.02em; }
.clock.low { color: var(--bad); }
.bar { height: 8px; border-radius: 999px; background: var(--raised); overflow: hidden; margin-top: 10px; }
.bar > span { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }

.words { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.words li { background: var(--raised); border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; font-weight: 600; }
.words li.dup { text-decoration: line-through; color: var(--muted); }
.words li.bad { color: var(--bad); border-color: var(--bad); }
.words li .pts { color: var(--muted); font-weight: 500; margin-left: 6px; font-size: 13px; }

.players { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.players li { display: flex; align-items: center; gap: 10px; background: var(--raised); border-radius: 12px; padding: 11px 14px; }
.players .seat { width: 26px; height: 26px; border-radius: 999px; background: var(--accent); color: #241c05; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.players .count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.players li.you { outline: 2px solid var(--accent); }

.code { font-size: 42px; font-weight: 800; letter-spacing: .18em; margin: 6px 0 2px; }
.flash { border-radius: 12px; padding: 11px 14px; margin-bottom: 12px; font-weight: 600; }
.flash.bad { background: rgba(255, 122, 122, .14); color: var(--bad); }
.flash.good { background: rgba(103, 217, 139, .14); color: var(--good); }

.scores { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.scores > li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.scores .total { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.scores li.won { border-color: var(--accent); }

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