/* The shared look of every game (the design standard, .claude/skills/new-game/DESIGN.md): colours for light and dark
   mode, the page, title, buttons, fields, cards, the join form, segmented options, the player bar, status and hint
   lines, the lobby, the title row (back and profile icon) and the 44 px rule. A game links it first,
     <link rel="stylesheet" href="../shared/base.css">
   then adds only its own board and pieces in its <style> (which may also override a colour token). Kit games link
   ../shared/kit.css after it. Player colours are --p0..--p9 (seat % 10). */
:root {
  --bg: #f7f6f3;
  --text: #1d1d1f;
  --muted: #5e5e63;
  --panel: #ffffff;
  --line: #d9d2c6;
  --soft: #ece7df;
  --accent: #b04d14; --on-accent: #fff;
  --danger: #b3261e;
  --good: #2e9d5b;
  --p0: #d9a514; --p1: #2f9e55; --p2: #2f6fd6; --p3: #d6458c;
  --p4: #8e4ec6; --p5: #e5484d; --p6: #0f9b8e; --p7: #ef6c1a; --p8: #5b5bd6; --p9: #8d5a3b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618;
    --text: #ececef;
    --muted: #9a9aa2;
    --panel: #1f1f22;
    --line: #3a3a40;
    --soft: #2a2a2e;
    --accent: #f08a4b; --on-accent: #1d1d1f;
    --danger: #ff8a80;
    --good: #48c774;
    --p0: #f2c23a; --p1: #48c774; --p2: #5f97ff; --p3: #ff7fbf;
    --p4: #b98cf0; --p5: #ff7b7f; --p6: #3fd3c2; --p7: #ff9a52; --p8: #8f8fff; --p9: #c99a76;
    color-scheme: dark;
  }
}

/* Page */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
main {
  width: 100%;
  max-width: 480px;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
h1 { margin: 0; font-size: 1.45rem; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; }
h2 { margin: 0; font-size: 1.05rem; }
p { margin: 0; }
.muted { color: var(--muted); }
#home, #game { display: flex; flex-direction: column; gap: 12px; }

/* The title row (.title-bar): back (‹, an icon-only link with an aria-label: to the games page from a game, home
   from the games page) before the title, and the profile icon (.me-link: your avatar, or 👤) at the right. Both are
   hidden once in a room or game (use Leave there). */
.title-bar { display: flex; align-items: center; gap: 6px; }
.title-bar h1 { flex: 1; min-width: 0; }
.title-bar .code { flex: none; white-space: nowrap; }
.home-link {
  flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; margin-left: -10px;
  color: var(--text); font-size: 2.1rem; line-height: 1; text-decoration: none; border-radius: 12px;
}
.me-link {
  flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--soft); font-size: 1.35rem; line-height: 1; text-decoration: none;
}
:is(.home-link, .me-link):active { opacity: 0.6; }
:is(.home-link, .me-link):focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
main:has(#home[hidden]) :is(.home-link, .me-link) { display: none; }

/* Controls: one primary (accent) button per card or row, the rest .secondary. */
button {
  font: inherit; font-weight: 650; border: 0; border-radius: 12px; padding: 12px 16px;
  background: var(--accent); color: var(--on-accent); cursor: pointer; touch-action: manipulation; white-space: nowrap;
}
button:disabled { opacity: 0.5; cursor: default; }
button.secondary { background: var(--soft); color: var(--text); }
input, select { font: inherit; touch-action: manipulation; }
/* Design standard (checked by tests/ui-audit.cjs): every control is at least 44 px each way. Game boards and racks
   ([data-small-ok]) size their own pieces. */
:is(button, input, select):not([data-small-ok] *) { min-height: 44px; min-width: 44px; }

/* Cards and rows */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.error { color: var(--danger); min-height: 1.4em; font-size: 0.95rem; }
.rules { font-size: 0.9rem; color: var(--muted); }
.rules li { margin: 2px 0; }
.rules summary { cursor: pointer; font-weight: 600; color: var(--text); }

/* Home: name, join form, segmented options */
.join, .save { display: flex; gap: 10px; }
.join input, .save input, .name-row input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.join input { font-size: 1.3rem; letter-spacing: 0.3em; text-transform: uppercase; text-align: center; }
.name-row { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.name-row span { white-space: nowrap; }
.name-row input { font-weight: 500; }
.name-row:has(.seg) { flex-wrap: wrap; }
.seg { display: flex; background: var(--soft); border-radius: 12px; padding: 4px; gap: 4px; flex: 1; }
.seg button { flex: 1; background: transparent; color: var(--text); padding: 9px 6px; font-size: 0.95rem; white-space: normal; }
.seg button[aria-pressed="true"] { background: var(--panel); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* Lobby */
.lobby-qr { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 0.9rem; }
.lobby-qr svg { width: 148px; height: 148px; border-radius: 10px; border: 1px solid var(--line); }
.bigcode { font-size: 2.6rem; font-weight: 800; letter-spacing: 0.25em; text-align: center; margin: 0; }
.seated { display: flex; flex-direction: column; gap: 6px; }
.seated div { display: flex; align-items: center; gap: 8px; }

/* Game: player bar, status line, hint */
.bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.players { display: flex; gap: 6px; flex-wrap: wrap; }
/* Five players or more: one row that scrolls sideways (fading at the edge) instead of rows pushing the board down. */
.players:has(> :nth-child(5)) {
  flex: 1 1 0; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  padding-right: 24px;
}
.players:has(> :nth-child(5))::-webkit-scrollbar { display: none; }
.players:has(> :nth-child(5)) > * { flex: none; scroll-snap-align: start; }
.bar:has(.players > :nth-child(5)) { flex-wrap: nowrap; }
.bar:has(.players > :nth-child(5)) > :not(.players) { flex: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  background: var(--soft); font-size: 0.85rem; font-weight: 600; border: 2px solid transparent;
}
.chip.turn { border-color: var(--pc, var(--accent)); }
.chip.out { opacity: 0.5; }
.chip .disc { width: 12px; height: 12px; border-radius: 3px; background: var(--pc); }
/* rooms.face(): the player's avatar (an emoji from their profile) before their name, in chips and the lobby list. */
.face { font-size: 1.05em; line-height: 1; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); opacity: 0.4; }
.dot.on { background: var(--good); opacity: 1; }
.code { font-size: 0.85rem; color: var(--muted); }
/* rooms.codeInTitle(): the room code at the right of the title line. */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.title-row h1 { min-width: 0; }
.title-row .code { flex: none; white-space: nowrap; }
/* (On the home screen there's no room: an old code from before Leave stays hidden.) */
main:has(#home:not([hidden])) :is(.title-row, .kit-title, .title-bar) .code { display: none; }
.code b { font-size: 1.05rem; letter-spacing: 0.15em; color: var(--text); }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.clock.low { color: var(--danger); }
/* rooms.timeBar(): the turn timer, a bar under the status line that empties as the seconds go */
.timebar { display: block; height: 6px; max-width: 240px; margin: 6px auto 0; border-radius: 3px; background: var(--soft); overflow: hidden; }
.timebar i { display: block; height: 100%; width: calc(var(--from) * 100%); background: var(--accent); animation: timebar linear forwards; }
.timebar.low i { background: var(--danger); }
@keyframes timebar { to { width: 0; } }
@media (prefers-reduced-motion: reduce) { .timebar i { animation: none; } }
.status { text-align: center; font-size: 1.15rem; font-weight: 700; min-height: 1.5em; margin: 0; }
.hint { text-align: center; font-size: 0.9rem; color: var(--muted); min-height: 1.3em; margin: 0; }
