:root {
  --bg: #f4efe6;
  --surface: #fffaf2;
  --surface-2: #efe6d6;
  --ink: #2a2118;
  --muted: #64533f;
  --line: #ddd0bb;
  --accent: #b5502c;
  --accent-ink: #fff;
  --good: #2f7d4f;
  --bad: #b03a2e;
  --card: #fffdf8;
  --card-edge: #e3d5bd;
  --shadow: 0 1px 2px rgba(60, 35, 10, .12), 0 10px 24px rgba(60, 35, 10, .16);
  --radius: 12px;
  /* The cozy room: a lamp-lit wooden table, with green felt for the card games. */
  --wood: #e2cba6;
  --seam: rgba(110, 70, 30, .16);
  --lamp: rgba(255, 244, 222, .85);
  --vignette: rgba(80, 45, 15, .3);
  --felt: #34774f;
  --felt-deep: #1c4a2f;
  --felt-ink: #f6ecd8;
  --felt-muted: rgba(246, 236, 216, .78);
  --rail: #8a5a2e;
  --gold: #f3d27a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1713;
    --surface: #25201a;
    --surface-2: #2f2820;
    --ink: #f1e8da;
    --muted: #a99883;
    --line: #3d342a;
    --accent: #e0774d;
    --accent-ink: #1b1713;
    --good: #5cbf85;
    --bad: #e46a5c;
    --card: #2d261e;
    --card-edge: #4a3f32;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 24px rgba(0, 0, 0, .35);
    --wood: #2b1f15;
    --seam: rgba(0, 0, 0, .3);
    --lamp: rgba(255, 186, 100, .17);
    --vignette: rgba(0, 0, 0, .55);
    --felt: #24573a;
    --felt-deep: #10291b;
    --felt-ink: #efe4cf;
    --felt-muted: rgba(239, 228, 207, .72);
    --rail: #4e321b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--wood);
  color: var(--ink);
  font: 16px/1.5 Inter, system-ui, sans-serif;
  min-height: 100vh;
}
/* Wooden planks under a warm lamp, fixed behind everything like a tabletop. */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 90% 65% at 50% -8%, var(--lamp), transparent 72%),
    radial-gradient(ellipse 120% 100% at 50% 35%, transparent 50%, var(--vignette)),
    repeating-linear-gradient(180deg, transparent 0 178px, var(--seam) 178px 180px),
    url(/art/wood.svg) 0 0 / 480px 480px,
    var(--wood);
}
h1, h2, h3, .brand, .big-code, .event-title { font-family: Fraunces, Georgia, serif; }
h1 { font-size: clamp(28px, 5vw, 44px); line-height: 1.1; margin: 0 0 8px; }
h3 { margin: 20px 0 8px; font-size: 18px; }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; max-width: 1100px; margin: 0 auto;
}
.brand { font-size: 22px; font-weight: 700; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.brand-mark { width: 22px; height: 22px; color: var(--accent); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 45%, transparent)); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.host-wrap { position: relative; }
.host-btn {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); padding: 4px 12px;
}
.host-btn.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.host-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: min(300px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; display: grid; gap: 4px;
}
.host-panel .host-row { display: flex; gap: 8px; align-items: center; font-weight: 600; margin-bottom: 8px; }
.host-panel .host-row input { width: auto; }
.host-panel input[type=range] { padding: 0; accent-color: var(--accent); }
.host-panel em { font-style: normal; color: var(--muted); font-weight: 500; }
.host-panel p { margin: 6px 0 0; }
.room-badge {
  font-weight: 600; letter-spacing: .12em; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}

main { max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }
.hero { margin: 24px 0 20px; }
.hero h1 { text-shadow: 0 1px 0 color-mix(in srgb, var(--lamp) 60%, transparent); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.eyebrow { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }

.panel {
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 94%, #fff 6%), var(--surface) 140px);
  border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 640px) { .split { grid-template-columns: 1fr; } }

.field { display: block; margin: 0 0 12px; }
.field span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
input, select {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.code-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 600; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  padding: 10px 16px; border-radius: 8px;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.error { color: var(--bad); font-weight: 500; }

.game-picker { display: grid; gap: 10px; margin-bottom: 14px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.game-option {
  display: flex; flex-direction: column; text-align: left; border: 1px solid var(--card-edge); background: var(--card);
  border-radius: 12px; padding: 0; overflow: hidden; cursor: pointer; color: var(--ink); font: inherit;
  box-shadow: var(--shadow); transition: opacity .2s, filter .2s, transform .2s, box-shadow .2s;
}
.game-option .game-art { display: block; width: 100%; aspect-ratio: 12 / 7; object-fit: cover; background: var(--surface-2); }
.game-option strong { display: block; padding: 8px 10px 0; font-family: Fraunces, Georgia, serif; line-height: 1.25; }
.game-option span {
  font-size: 13px; line-height: 1.4; color: var(--muted); margin: 2px 10px 10px;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
.game-option:hover { transform: translateY(-2px); }
.game-option:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.game-option.selected {
  border-color: var(--accent); transform: translateY(-2px);
  box-shadow: 0 0 0 2px var(--accent), 0 10px 28px color-mix(in srgb, var(--accent) 35%, transparent);
}
.game-option.selected span { -webkit-line-clamp: unset; line-clamp: none; }
/* Once a game is picked, the rest fade back (hover or focus brings one forward to switch). */
.game-picker.has-pick .game-option:not(.selected) { opacity: .3; filter: grayscale(.85); box-shadow: none; }
.game-picker.has-pick .game-option:not(.selected):hover,
.game-picker.has-pick .game-option:not(.selected):focus-visible { opacity: .8; filter: none; }
@media (prefers-reduced-motion: reduce) { .game-option, .game-option:hover, .game-option.selected { transition: none; transform: none; } }

.lobby-game { display: flex; gap: 14px; align-items: center; margin: 18px 0 4px; }
.lobby-game h3 { margin: 0 0 4px; font-size: 22px; }
.lobby-game p { margin: 0; }
.lobby-art {
  flex: none; width: 150px; aspect-ratio: 12 / 7; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--card-edge); box-shadow: var(--shadow);
}
@media (max-width: 480px) { .lobby-art { width: 104px; } }

.lobby-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.big-code { font-size: 44px; font-weight: 700; letter-spacing: .15em; margin: 0; }
.player-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.player-list li {
  box-shadow: 0 1px 2px rgba(60, 35, 10, .1);
  padding: 6px 12px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line); font-weight: 500;
}
.player-list li.offline { opacity: .5; }
#addBotBtn { margin-top: 8px; }
.player-list .chip-btn {
  margin-left: 4px; border: none; background: none; color: var(--muted); cursor: pointer;
  font: inherit; font-size: 15px; line-height: 1; padding: 0 2px;
}
.player-list .chip-btn:hover { color: var(--accent); }
.player-list .chip-btn.kick:hover { color: var(--bad); }

/* Players panel in the top bar: who's here, who's away, rename and remove. */
.host-btn.has-away { border-color: var(--bad); color: var(--bad); }
.host-btn { white-space: nowrap; }
@media (max-width: 520px) {
  .host-panel { position: fixed; left: 16px; right: 16px; top: 64px; width: auto; }
  .brand { font-size: 19px; white-space: nowrap; }
}
.players-panel { gap: 0; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.people li { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.people .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); flex: none; }
.people li.away .dot { background: var(--bad); }
.people .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.people .who small { font-weight: 500; color: var(--muted); margin-left: 4px; }
.people li.away .who small { color: var(--bad); }
.people .btn { padding: 4px 8px; }

.ask {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow); padding: 18px; width: min(360px, calc(100vw - 32px));
}
.ask::backdrop { background: rgba(30, 18, 8, .45); }
.ask h3 { margin: 0 0 6px; }
.ask p { margin: 0 0 12px; }
.ask input { width: 100%; box-sizing: border-box; }
.ask .row { margin-top: 14px; }
.player-list .tag { font-size: 12px; color: var(--muted); margin-left: 6px; }
.options { display: grid; gap: 10px; margin: 8px 0; }
.options label { display: flex; align-items: center; gap: 10px; }
.options input[type=number] { width: 90px; }
.options input[type=checkbox] { width: auto; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px;
  box-shadow: var(--shadow); z-index: 10; max-width: calc(100vw - 32px);
}

/* ---------- Chronology ---------- */
.chrono { display: grid; gap: 16px; }
.chrono-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.chrono-bar .stats { display: flex; gap: 16px; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.chrono-bar .stats b { color: var(--ink); }

.stage {
  display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
@media (max-width: 640px) { .stage { grid-template-columns: 1fr; justify-items: center; text-align: center; } }
.stage .prompt h2 { margin: 0 0 4px; font-size: 22px; }
.stage .prompt p { margin: 0 0 8px; }

.event {
  position: relative; background: var(--card); border: 1px solid var(--card-edge);
  border-radius: 10px; box-shadow: var(--shadow);
  width: 150px; min-height: 170px; padding: 12px 12px 10px;
  display: flex; flex-direction: column; gap: 8px; flex: none;
  border-top: 5px solid var(--accent);
}
.event .event-title { font-size: 15px; line-height: 1.25; flex: 1; }
.event .year {
  font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 22px;
  border-top: 1px dashed var(--card-edge); padding-top: 6px; text-align: center;
}
.event.mystery .year { color: var(--muted); letter-spacing: .2em; }
.event.big { width: 200px; min-height: 230px; }
.event.big .event-title { font-size: 18px; }
.event.big .year { font-size: 28px; }
.event.pending { outline: 3px dashed var(--accent); outline-offset: 3px; }
.event.fresh { animation: pop .5s ease; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }

.timeline-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.timeline-wrap h3 { margin: 0 0 12px; }
.timeline {
  display: flex; flex-wrap: wrap; align-items: stretch; row-gap: 12px; padding: 6px 2px 4px;
}
.slot {
  flex: none; width: 10px; margin: 0 2px; border-radius: 8px; border: 2px dashed transparent;
  background: none; cursor: default; padding: 0;
}
.timeline.placing .slot {
  width: 36px; border-color: var(--line); cursor: pointer; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 20px;
}
.timeline.placing .slot:hover { border-color: var(--accent); color: var(--accent); }
.timeline.placing .slot.chosen { border-color: var(--accent); color: var(--accent); }
.timeline.placing .slot::after { content: '+'; }
/* Cards shrink as the timeline grows so the whole thing stays on screen. */
.timeline[data-size="m"] .event { width: 122px; min-height: 140px; padding: 10px 10px 8px; gap: 6px; }
.timeline[data-size="m"] .event-title { font-size: 13.5px; }
.timeline[data-size="m"] .year { font-size: 19px; }
.timeline[data-size="s"] .event { width: 100px; min-height: 118px; padding: 8px 8px 6px; gap: 4px; border-top-width: 4px; }
.timeline[data-size="s"] .event-title { font-size: 12.5px; line-height: 1.2; }
.timeline[data-size="s"] .year { font-size: 17px; padding-top: 4px; }
.timeline[data-size="s"].placing .slot { width: 28px; }
/* On phones the timeline becomes a compact vertical list, earliest at the top. */
@media (max-width: 640px) {
  .timeline { flex-direction: column; flex-wrap: nowrap; row-gap: 0; }
  .timeline .event, .timeline[data-size] .event {
    width: 100%; min-height: 0; padding: 6px 10px; gap: 10px;
    flex-direction: row; align-items: center;
    border-top: 1px solid var(--card-edge); border-left: 5px solid var(--accent);
  }
  .timeline .event .event-title, .timeline[data-size] .event-title { font-size: 14px; line-height: 1.25; order: 2; }
  .timeline .event .year, .timeline[data-size] .year {
    order: 1; flex: none; width: 90px; font-size: 16px; white-space: nowrap; text-align: left;
    border-top: none; padding-top: 0;
  }
  .timeline .slot { width: 100%; height: 6px; margin: 0; }
  .timeline.placing .slot, .timeline[data-size].placing .slot { width: 100%; height: 28px; margin: 3px 0; font-size: 18px; }
}
.timeline-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

.result {
  border-radius: 10px; padding: 10px 14px; font-weight: 500;
  background: var(--surface-2); border-left: 5px solid var(--muted);
}
.result.good { border-left-color: var(--good); }
.result.bad { border-left-color: var(--bad); }
.result b { font-family: Fraunces, Georgia, serif; }
.result-head { margin-bottom: 10px; }
.result .mark { font-weight: 700; }
.result.good .mark { color: var(--good); }
.result.bad .mark { color: var(--bad); }
.guess-strip { display: flex; gap: 8px; align-items: stretch; }
.guess-strip .event { width: 120px; min-height: 120px; padding: 8px 9px 6px; gap: 4px; }
.guess-strip .event-title { font-size: 13px; line-height: 1.2; }
.guess-strip .year { font-size: 17px; padding-top: 4px; }
.guess-strip .event:not(.right):not(.wrong):not(.pending) { opacity: .7; }
.guess-strip .event.right { outline: 3px solid var(--good); outline-offset: 2px; }
.guess-strip .event.wrong { outline: 3px solid var(--bad); outline-offset: 2px; }
.guess-strip .event.wrong .year { color: var(--bad); }
.guess-strip .event.right .year { color: var(--good); }
.guess-edge {
  flex: none; width: 56px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  border: 1px dashed var(--line); border-radius: 10px;
}
.stage .prompt .guess-strip { margin-top: 8px; }
.ruled-out {
  margin-top: 12px; font-size: 14px; color: var(--bad); display: grid; gap: 2px;
  background: var(--surface-2); border-radius: 8px; padding: 8px 12px;
}
.ruled-out strong { color: var(--ink); }
@media (max-width: 640px) {
  .guess-strip { justify-content: center; }
  .guess-strip .event { width: calc((100% - 16px) / 3); min-width: 0; }
  .guess-strip .event-title { font-size: 12px; }
  .guess-strip .year { font-size: 15px; }
}

.others { display: grid; gap: 12px; }
.other {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px;
}
.other.active { border-color: var(--accent); }
.other-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 8px; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 4px; }
.chip {
  flex: none; font-size: 13px; padding: 4px 8px; border-radius: 6px; background: var(--card);
  border: 1px solid var(--card-edge); max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: 3px solid var(--accent);
}
.chip b { margin-right: 4px; }

.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; width: 120px; }
.progress > i { display: block; height: 100%; background: var(--accent); }

.log { font-size: 14px; color: var(--muted); display: grid; gap: 4px; }
.log .ok { color: var(--good); font-weight: 600; }
.log .no { color: var(--bad); font-weight: 600; }

.winner {
  text-align: center; background: var(--surface); border: 2px solid var(--accent);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.winner h2 { margin: 0 0 8px; font-size: 30px; }

/* Let scrolling rows shrink inside grid/flex parents instead of widening the page. */
.chrono > *, .stage > *, .others > *, .timeline-wrap { min-width: 0; }

/* ---------- Wits & Wagers ---------- */
.ww { display: grid; gap: 16px; }
.ww > * { min-width: 0; }
.ww-question, .ww-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.ww-question { border-top: 5px solid var(--accent); }
.ww-question h2 { margin: 4px 0 0; font-size: clamp(22px, 3.4vw, 30px); line-height: 1.2; }
.ww-answer { margin-top: 14px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ww-answer strong { font-family: Fraunces, Georgia, serif; font-size: 32px; color: var(--good); }
.ww-panel h3 { margin: 0 0 6px; }
.ww-panel > p { margin: 0 0 12px; }
.ww-guess { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0 10px; }
.ww-guess input { width: 220px; max-width: 100%; font-size: 20px; font-weight: 600; }

.ww-board { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; }
.ww-slot {
  flex: 1 0 104px; min-width: 104px; display: flex; flex-direction: column; gap: 4px; text-align: center;
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--card-edge);
  border-radius: 10px; padding: 10px 8px; box-shadow: var(--shadow);
}
button.ww-slot { cursor: pointer; }
button.ww-slot:hover { border-color: var(--accent); }
.ww-slot.low { background: var(--surface-2); }
.ww-slot.win { outline: 3px solid var(--good); outline-offset: 2px; }
.ww-slot.lose { opacity: .55; }
.ww-odds { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.ww-value { font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 20px; line-height: 1.15; overflow-wrap: anywhere; }
.ww-slot.low .ww-value { font-size: 15px; }
.ww-who { font-size: 12px; color: var(--muted); min-height: 1.2em; }
.ww-markers { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: auto; padding-top: 4px; }
.ww-marker {
  font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.ww-marker.mine { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ww-marker.draft { background: transparent; color: var(--accent); border-style: dashed; }

.ww-mybets { display: grid; gap: 8px; margin-top: 8px; }
.ww-betrow {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--surface-2); border-radius: 8px; padding: 8px 12px;
}
.ww-step { display: inline-flex; gap: 6px; align-items: center; }
.ww-step .btn { width: 32px; padding: 4px 0; }

.ww-gains { display: grid; gap: 2px; margin-top: 10px; font-size: 15px; }
.ww-gains .up b { color: var(--good); }
.ww-gains .down b { color: var(--bad); }
.ww-gains b { display: inline-block; min-width: 44px; }

.ww-scores {
  display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 16px;
}
.ww-score { display: flex; gap: 10px; align-items: center; }
.ww-score.me .ww-name { font-weight: 700; }
.ww-status { width: 22px; color: var(--muted); text-align: center; flex: none; }
.ww-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) {
  .ww-board { flex-direction: column; overflow: visible; }
  .ww-slot { flex: none; min-width: 0; display: grid; grid-template-columns: 64px 1fr; text-align: left; align-items: center; column-gap: 10px; }
  .ww-slot .ww-odds { grid-row: span 2; }
  .ww-markers { grid-column: 2; justify-content: flex-start; padding-top: 0; }
}

/* Host's start-of-game walkthrough */
.guide {
  margin: 12px 0; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--accent); box-shadow: var(--shadow);
}
.guide-head strong { font-family: Fraunces, Georgia, serif; font-size: 17px; }
.guide ul { margin: 6px 0 12px; padding-left: 20px; }
.guide li + li { margin-top: 4px; }
.guide-foot { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Criss-Cross Cribbage ---------- */
.crib { display: grid; gap: 16px; }
.crib > * { min-width: 0; }
.crib-total { font-weight: 600; }
.crib-total.mine { color: var(--accent); }
.crib-turn {
  display: flex; gap: 16px; align-items: center; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow);
}
.crib-turn.mine { border-color: var(--accent); }
.crib-turn h2 { margin: 0; font-size: 22px; }
.crib-turn p { margin: 2px 0 8px; }

.pc {
  position: relative; container-type: inline-size; width: 56px; aspect-ratio: 5 / 7; flex: none;
  display: flex; align-items: center; justify-content: center; line-height: 1; overflow: hidden;
  background: linear-gradient(160deg, #fff 0%, var(--card) 60%, #f3ead9 100%);
  border: 1px solid var(--card-edge); border-radius: 8px; color: #1f1a14;
  font-family: Fraunces, Georgia, serif; font-weight: 700; box-shadow: var(--shadow); user-select: none;
}
.pc.red { color: #c0392b; }
@media (prefers-color-scheme: dark) {
  .pc { background: linear-gradient(160deg, #fbf7ef 0%, #efe6d6 100%); border-color: #bfae92; }
}
.pc-corner {
  position: absolute; display: flex; flex-direction: column; align-items: center; gap: 1cqw;
  min-width: 20cqw; font-size: 22cqw; letter-spacing: -.04em;
}
.pc-corner b { font-weight: 700; }
.pc-corner i { font-style: normal; font-size: 1.05em; }
.pc-corner.tl { left: 5cqw; top: 6cqw; }
.pc-corner.br { right: 5cqw; bottom: 6cqw; transform: rotate(180deg); }
.pc-mid { font-size: 56cqw; }
.pc-mid.ace { font-size: 70cqw; }
.pc-mid.court {
  display: flex; align-items: center; justify-content: center; font-size: 44cqw;
  position: absolute; inset: 18% 22%; border: 1.5cqw solid currentColor; border-radius: 6cqw;
  background: color-mix(in srgb, currentColor 8%, transparent);
}
.pc.big { width: 72px; height: 100px; font-size: 26px; flex: none; }

/* A hand of cards fanned out, shared by the card games (public/cards.js). */
.fan { container-type: inline-size; padding: 0 6%; min-width: 0; }
.fan-row {
  --cw: clamp(50px, 19cqw, 92px);
  /* Overlap just enough to fit the row: never more spread than a card's left strip. */
  --gap: min(var(--cw) * .6, (100cqw - var(--cw)) / var(--n1));
  display: flex; justify-content: center; align-items: flex-end;
  padding: 34px 0 calc(var(--gap) * var(--arc) + 6px);
}
.fan-card {
  --lift: 0px;
  all: unset; box-sizing: border-box; display: block; position: relative; flex: none; width: var(--cw);
  border-radius: 8px; cursor: default; transform-origin: 50% 100%;
  transform: translateY(calc(var(--gap) * var(--drop))) rotate(var(--rot)) translateY(var(--lift));
  transition: transform .18s cubic-bezier(.3, .7, .4, 1.2), filter .18s;
}
.fan-card + .fan-card { margin-left: calc(var(--gap) - var(--cw)); }
.fan-card .pc { width: 100%; height: auto; box-shadow: -2px 1px 4px rgba(40, 25, 10, .22); }
.fan-card.live { cursor: pointer; }
.fan-card.up { --lift: calc(var(--cw) * -.32); }
.fan-card.up .pc { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 8px 16px rgba(40, 25, 10, .3); }
.fan-card.dim .pc::after { content: ''; position: absolute; inset: 0; background: rgba(40, 30, 20, .32); }
.fan-card.mark .pc { outline: 2px dashed var(--accent); outline-offset: -5px; }
.fan-card:focus-visible .pc { outline: 3px solid var(--accent); outline-offset: 1px; }
@media (hover: hover) {
  .fan-card.live:not(.up):not(.dim):hover { --lift: calc(var(--cw) * -.12); }
}
@media (prefers-reduced-motion: reduce) { .fan-card { transition: none; } }

.crib-board-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); justify-self: center; width: min(100%, 500px);
}
.crib-board {
  display: grid; gap: 6px;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr)) minmax(34px, .7fr);
  grid-template-rows: repeat(var(--n), auto) auto;
}
.crib-board .pc.cell, .crib-empty { aspect-ratio: 5 / 7; width: 100%; font-size: clamp(14px, 4.2vw, 24px); }
.crib-board .pc.starter { outline: 2px dashed var(--muted); outline-offset: 2px; }
.crib-board .pc.last { outline: 3px solid var(--accent); outline-offset: 1px; }
.crib-board .pc.fresh { animation: pop .35s ease-out; }
.crib-empty {
  border: 2px dashed var(--line); border-radius: 8px; background: var(--surface-2); padding: 0;
  cursor: default; display: flex; align-items: stretch; justify-content: stretch;
}
.crib-board.placing .crib-empty { cursor: pointer; border-color: var(--muted); }
.crib-board.placing .crib-empty:hover { border-color: var(--accent); }
.crib-empty.chosen { border-color: var(--accent); }
.crib-empty .pc.ghost { width: 100%; opacity: .7; box-shadow: none; border-style: dashed; font-size: inherit; }
.crib-margin {
  display: flex; align-items: center; justify-content: center; border-radius: 8px;
  font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: clamp(15px, 3.6vw, 20px);
}
.crib-margin.mine { background: var(--accent); color: var(--accent-ink); }
.crib-margin.theirs { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); padding: 4px 0; }
.crib-key { margin-top: 10px; display: grid; gap: 2px; }
.crib-key > div { display: flex; align-items: center; gap: 6px; }
.crib-swatch { flex: none; width: 12px; height: 12px; border-radius: 3px; }
.crib-swatch.mine { background: var(--accent); }
.crib-swatch.theirs { background: var(--surface-2); border: 1px solid var(--line); }
.crib-teams { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.crib-teams > p { grid-column: 1 / -1; margin: 0; }
.crib-breakdown { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.crib-hand { display: grid; grid-template-columns: auto 2.2em 1fr; gap: 10px; align-items: baseline; padding: 3px 0; }
.crib-hand-cards { display: inline-flex; gap: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.crib-hand-cards span { min-width: 2.1em; }
.crib-hand-cards .red { color: #c0392b; }
@media (prefers-color-scheme: dark) { .crib-hand-cards .red { color: #ff7b6b; } }
.crib-hand b { text-align: right; font-family: Fraunces, Georgia, serif; }
@media (max-width: 640px) {
  .crib-board-wrap { padding: 10px; }
  .crib-board { gap: 4px; }
  .crib-hand { grid-template-columns: 1fr auto; }
  .crib-hand > .small { grid-column: 1 / -1; }
}

/* Spades */
.spades { display: grid; gap: 16px; }
.spades > * { min-width: 0; }
.sp-score.mine b { color: var(--accent); }
.sp-broken { font-weight: 600; color: var(--accent); }
.sp-table {
  display: grid; gap: 8px; justify-self: center; width: min(100%, 560px);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) minmax(0, 1fr);
  grid-template-areas: ". top ." "left mid right" ". bottom .";
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow);
}
.sp-seat {
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; text-align: center;
  background: var(--bg); align-self: center; min-width: 0;
}
.sp-seat.top { grid-area: top; } .sp-seat.bottom { grid-area: bottom; }
.sp-seat.left { grid-area: left; } .sp-seat.right { grid-area: right; }
.sp-seat.ours { background: color-mix(in srgb, var(--accent) 10%, var(--bg)); }
.sp-seat.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.sp-seat.nil .sp-bid { color: var(--accent); font-weight: 600; }
.sp-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-bid { color: var(--muted); }
.sp-backs { display: flex; justify-content: center; margin-top: 4px; }
.sp-backs span {
  width: 8px; height: 14px; border-radius: 2px; margin-left: -2px;
  background: var(--accent); border: 1px solid var(--surface); opacity: .75;
}
.sp-trick {
  grid-area: mid; position: relative; min-height: 190px;
  display: grid; grid-template-columns: 1fr auto 1fr; grid-template-rows: 1fr auto 1fr;
  place-items: center; gap: 2px;
}
.sp-trick .pc { width: 48px; height: 68px; font-size: 18px; }
.sp-played.top { grid-area: 1 / 2; } .sp-played.bottom { grid-area: 3 / 2; }
.sp-played.left { grid-area: 2 / 1; justify-self: end; } .sp-played.right { grid-area: 2 / 3; justify-self: start; }
.sp-played { animation: pop .3s ease-out; }
.sp-played.won { outline: 3px solid var(--accent); outline-offset: 1px; }
.sp-played.dim { opacity: .55; }
.sp-note { grid-area: 2 / 2; font-weight: 600; text-align: center; max-width: 9em; }
.sp-bidpanel, .sp-summary, .sp-hand-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.sp-bidpanel { border-color: var(--accent); }
.sp-bidpanel h2, .sp-summary h2 { margin: 0; font-size: 22px; }
.sp-bidpanel p { margin: 2px 0 10px; }
.sp-bids { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-bids .btn { min-width: 44px; padding: 8px 10px; }
.sp-hand-wrap.mine { border-color: var(--accent); }
.sp-hand-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; min-height: 32px; }
.sp-sumtable { width: 100%; border-collapse: collapse; margin: 10px 0 12px; font-variant-numeric: tabular-nums; }
.sp-sumtable th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 4px 6px; }
.sp-sumtable td { padding: 6px; border-top: 1px solid var(--line); vertical-align: top; }
.sp-sumtable .good { color: var(--good); font-weight: 600; }
.sp-sumtable .bad { color: var(--bad); font-weight: 600; }
@media (max-width: 480px) {
  .sp-trick { min-height: 160px; }
  .sp-trick .pc { width: 40px; height: 56px; font-size: 15px; }
  .sp-seat { padding: 4px; font-size: 14px; }
}
/* ---------- Euchre ---------- */
.euchre { display: grid; gap: 16px; }
.euchre > * { min-width: 0; }
.eu-score.mine { color: var(--accent); font-weight: 600; }
.eu-trump { font-weight: 600; color: var(--ink); }
.eu-trump.red { color: #c0392b; }
@media (prefers-color-scheme: dark) { .eu-trump.red { color: #ff7b6b; } }
.eu-table {
  position: relative; display: grid; gap: 8px; padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  grid-template-columns: 1fr minmax(170px, 1.4fr) 1fr; grid-template-rows: auto minmax(170px, auto) auto;
  grid-template-areas: ". top ." "left mid right" ". bottom .";
}
.eu-seat {
  display: grid; justify-items: center; align-content: center; gap: 4px; padding: 8px; border-radius: 10px;
  border: 1px solid transparent; text-align: center; min-width: 0;
}
.eu-seat.top { grid-area: top; } .eu-seat.left { grid-area: left; }
.eu-seat.right { grid-area: right; } .eu-seat.bottom { grid-area: bottom; }
.eu-seat.active { border-color: var(--accent); background: var(--surface-2); }
.eu-seat.out { opacity: .5; }
.eu-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.eu-tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.eu-tag { font-size: 12px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.eu-tag.maker { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.eu-tag.partner { border-color: var(--accent); }
.eu-backs { display: flex; }
.eu-back {
  width: 16px; height: 23px; margin-left: -6px; border-radius: 3px; border: 1px solid var(--card-edge);
  background: repeating-linear-gradient(45deg, var(--accent), var(--accent) 3px, var(--surface-2) 3px, var(--surface-2) 6px);
}
.eu-back:first-child { margin-left: 0; }
.eu-mid {
  grid-area: mid; position: relative; min-height: 170px; border-radius: 50%;
  background: radial-gradient(ellipse at center, var(--surface-2), transparent 70%);
}
.eu-kitty { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 6px; text-align: center; }
.eu-mid .pc { width: 50px; height: 70px; font-size: 18px; }
.eu-down {
  background: repeating-linear-gradient(45deg, var(--accent), var(--accent) 4px, var(--surface-2) 4px, var(--surface-2) 8px);
}
.eu-played { position: absolute; left: 50%; top: 50%; }
.eu-played.bottom { transform: translate(-50%, 0); }
.eu-played.top { transform: translate(-50%, -100%); }
.eu-played.left { transform: translate(-125%, -50%); }
.eu-played.right { transform: translate(25%, -50%); }
.eu-played.won { outline: 3px solid var(--accent); outline-offset: 1px; }
.eu-played.fresh { animation: pop .35s ease-out; }
.eu-took { position: absolute; left: 0; right: 0; bottom: -4px; text-align: center; font-weight: 600; color: var(--accent); }
.eu-prompt h2 { margin: 0; font-size: 22px; }
.eu-prompt p { margin: 2px 0 8px; }
.eu-prompt.mine { background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); }
.eu-prompt .row { margin: 0; flex-wrap: wrap; align-items: center; }
.eu-suit.red { color: #c0392b; }
@media (prefers-color-scheme: dark) { .eu-suit.red { color: #ff7b6b; } }
.eu-alone { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.eu-hand { display: grid; justify-items: center; }
.eu-hand .pc.trump { box-shadow: 0 0 0 3px var(--accent) inset, -2px 1px 4px rgba(40, 25, 10, .22); }
.eu-hand .fan { width: 100%; box-sizing: border-box; }
.eu-result {
  text-align: center; background: var(--surface); border: 2px solid var(--accent);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.eu-result h2 { margin: 0 0 4px; font-size: 24px; }
@media (max-width: 520px) {
  .eu-table { padding: 8px; grid-template-columns: 1fr 1.6fr 1fr; gap: 4px; }
  .eu-mid { min-height: 150px; }
  .eu-mid .pc { width: 40px; height: 56px; font-size: 15px; }
  .eu-tag { font-size: 11px; }
}

/* ---------- Hearts ---------- */
.hearts { display: grid; gap: 16px; }
.hearts > * { min-width: 0; }
.hearts-table {
  display: grid; gap: 10px; align-items: center; justify-items: center;
  grid-template-columns: 1fr minmax(180px, 260px) 1fr;
  grid-template-areas: ". top ." "left mid right" ". bottom .";
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.hearts-seat {
  text-align: center; padding: 8px 10px; border: 2px solid transparent; border-radius: 10px;
  background: var(--surface-2); min-width: 0; max-width: 100%;
}
.hearts-seat.top { grid-area: top; }
.hearts-seat.left { grid-area: left; }
.hearts-seat.right { grid-area: right; }
.hearts-seat.bottom { grid-area: bottom; }
.hearts-seat.active { border-color: var(--accent); }
.hearts-seat.winner-seat { background: var(--accent); color: var(--accent-ink); }
.hearts-seat.winner-seat .muted { color: inherit; }
.hearts-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hearts-score { font-family: Fraunces, Georgia, serif; font-size: 24px; font-weight: 700; line-height: 1.1; }
.hearts-trick {
  grid-area: mid; position: relative; width: 100%; aspect-ratio: 1; max-width: 240px;
}
.hearts-trick .pc.trick-card { position: absolute; width: 27%; aspect-ratio: 5 / 7; font-size: clamp(14px, 4vw, 22px); }
.hearts-trick .trick-card.bottom { left: 36.5%; bottom: 2%; }
.hearts-trick .trick-card.top { left: 36.5%; top: 2%; }
.hearts-trick .trick-card.left { left: 4%; top: 31%; }
.hearts-trick .trick-card.right { right: 4%; top: 31%; }
.hearts-trick .trick-card.won { outline: 3px solid var(--accent); outline-offset: 1px; }
.hearts-trick .trick-card.fresh, .hearts-took.fresh { animation: pop .35s ease-out; }
.hearts-took { margin-top: 4px; font-weight: 600; color: var(--accent); }
.hearts-caption {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  text-align: center; font-weight: 600; pointer-events: none;
}
.hearts-hand-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; box-shadow: var(--shadow); display: grid; gap: 12px;
}
.hearts-prompt h2 { margin: 0; font-size: 22px; }
.hearts-prompt p { margin: 2px 0 8px; }
.hearts-result { border-collapse: collapse; margin: 8px auto 14px; font-variant-numeric: tabular-nums; }
.hearts-result th, .hearts-result td { padding: 4px 10px; text-align: right; }
.hearts-result th:first-child, .hearts-result td:first-child { text-align: left; }
.hearts-result tr.me, .hearts-result .me { font-weight: 600; color: var(--accent); }
.hearts-sheet { overflow-x: auto; }
.hearts-sheet .hearts-result { margin: 0; }
@media (max-width: 560px) {
  .hearts-table { grid-template-columns: 1fr 150px 1fr; padding: 10px; gap: 6px; }
  .hearts-seat { padding: 6px; font-size: 13px; }
  .hearts-score { font-size: 19px; }
}
/* ---------- Farkle ---------- */
.farkle { display: grid; gap: 16px; }
.farkle > * { min-width: 0; }
.fk-final { color: var(--accent); font-weight: 700; }
.fk-table {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); display: grid; gap: 12px;
}
.fk-table.mine { border-color: var(--accent); }
.fk-table p { margin: 0; }
.fk-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.fk-head h2 { margin: 0; font-size: 22px; }
.fk-points { display: grid; justify-items: end; line-height: 1.1; }
.fk-points b { font-family: Fraunces, Georgia, serif; font-size: 28px; color: var(--accent); }
.fk-kept { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.fk-group { display: inline-flex; align-items: center; gap: 4px; }
.fk-group .small { margin-left: 2px; font-weight: 600; }
.fk-dice { display: flex; flex-wrap: wrap; gap: 12px; }
.fk-dice.small { gap: 4px; }
.fk-die {
  --s: 60px; width: var(--s); height: var(--s); padding: calc(var(--s) * .14);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); place-items: center;
  background: var(--card); border: 2px solid var(--card-edge); border-radius: calc(var(--s) * .2);
  box-shadow: var(--shadow); user-select: none; flex: none;
}
.fk-die .pip { width: 70%; height: 70%; border-radius: 50%; background: var(--ink); }
.fk-die.small { --s: 30px; border-width: 1px; box-shadow: none; }
.fk-die.tiny { --s: 22px; border-width: 1px; box-shadow: none; }
.fk-die[role="button"] { cursor: pointer; }
.fk-die[role="button"]:hover { border-color: var(--muted); }
.fk-die.chosen { border-color: var(--accent); background: var(--surface-2); transform: translateY(-6px); }
.fk-die.chosen .pip { background: var(--accent); }
.fk-die.tumble { animation: fk-tumble .45s ease-out both; }
@keyframes fk-tumble {
  0% { transform: rotate(-200deg) scale(.4); opacity: 0; }
  70% { transform: rotate(12deg) scale(1.05); opacity: 1; }
  100% { transform: none; }
}
@media (prefers-reduced-motion: reduce) { .fk-die.tumble { animation: none; } }
.fk-status { font-weight: 600; min-height: 1.4em; }
.fk-status.bad { color: var(--bad); }
.fk-btns { margin: 0; }
.fk-roll { justify-self: start; }
.fk-last {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 14px;
  border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line);
}
.fk-last.is-farkle { border-color: var(--bad); }
.fk-last.is-farkle .fk-last-text { color: var(--bad); font-weight: 600; }
.fk-last.fresh { animation: pop .35s ease-out; }
.fk-scores {
  display: grid; gap: 8px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.fk-score { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: baseline; padding: 4px 6px; border-radius: 8px; }
.fk-score.active { background: var(--surface-2); }
.fk-score.won .fk-name { color: var(--accent); font-weight: 700; }
.fk-score b { font-family: Fraunces, Georgia, serif; font-variant-numeric: tabular-nums; }
.fk-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.fk-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }
.fk-chart summary { cursor: pointer; font-weight: 600; }
.fk-chart table { border-collapse: collapse; margin-top: 8px; font-size: 14px; }
.fk-chart td { padding: 3px 16px 3px 0; border-bottom: 1px solid var(--line); }
.fk-chart td:last-child { font-weight: 600; }
.fk-chart p { margin: 8px 0 0; }
@media (max-width: 640px) {
  .fk-die { --s: 44px; }
  .fk-dice { gap: 8px; }
}
.fk-name .tag { font-size: 12px; color: var(--muted); margin-left: 4px; }
.fk-score.active .fk-bar { background: var(--line); }
.fk-die.tiny { --s: 26px; }

/* ---------- Crazy Eights ---------- */
.c8 { display: grid; gap: 16px; }
.c8 > * { min-width: 0; }
.c8-table {
  display: grid; gap: 14px; justify-items: center; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.c8-seats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; }
.c8-seat {
  text-align: center; padding: 8px 10px; border: 2px solid transparent; border-radius: 10px;
  background: var(--surface-2); min-width: 92px; max-width: 160px; flex: 1 1 92px;
}
.c8-seat.active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.c8-seat.winner-seat { background: var(--accent); color: var(--accent-ink); }
.c8-seat.winner-seat .c8-sub { color: inherit; }
.c8-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c8-score { font-family: Fraunces, Georgia, serif; font-size: 22px; font-weight: 700; line-height: 1.1; }
.c8-sub { color: var(--muted); }
.c8-sub.last { color: var(--bad); font-weight: 700; animation: pop .35s ease-out; }
.c8-backs { display: flex; justify-content: center; align-items: center; min-height: 25px; margin: 4px 0 2px; }
.c8-back, .c8-stock, .c8-under {
  border: 1px solid var(--card-edge); border-radius: 3px;
  background: repeating-linear-gradient(45deg, var(--accent), var(--accent) 3px, #f6ecd8 3px, #f6ecd8 6px);
}
.c8-back { width: 16px; height: 23px; margin-left: -8px; }
.c8-back:first-child { margin-left: 0; }
.c8-more { margin-left: 4px; color: var(--muted); }
.c8-mid { display: flex; gap: clamp(20px, 7vw, 48px); align-items: flex-start; justify-content: center; }
.c8-pilebox { display: grid; justify-items: center; gap: 6px; }
.c8-stock, .c8-pile { width: clamp(64px, 18vw, 92px); aspect-ratio: 5 / 7; }
.c8-stock {
  all: unset; box-sizing: border-box; width: clamp(64px, 18vw, 92px); aspect-ratio: 5 / 7; border-radius: 8px;
  border: 3px solid #f6ecd8; display: grid; place-items: center; cursor: default;
  background: repeating-linear-gradient(45deg, var(--accent), var(--accent) 5px, #f6ecd8 5px, #f6ecd8 10px);
  box-shadow: 2px 2px 0 #e9dcc3, 4px 4px 0 var(--card-edge), var(--shadow);
}
.c8-stock.live { cursor: pointer; animation: c8-nudge 1.6s ease-in-out infinite; }
.c8-stock.live:hover { transform: translateY(-3px); }
.c8-stock:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
@keyframes c8-nudge { 50% { box-shadow: 2px 2px 0 #e9dcc3, 4px 4px 0 var(--card-edge), 0 0 0 4px var(--gold); } }
@media (prefers-reduced-motion: reduce) { .c8-stock.live { animation: none; box-shadow: 0 0 0 4px var(--gold); } }
.c8-stock-count {
  font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 18px; color: #1f1a14;
  background: #f6ecd8; border-radius: 999px; padding: 2px 9px;
}
.c8-pile { position: relative; }
.c8-under { position: absolute; inset: 0; border-radius: 8px; transform: rotate(-7deg); background: var(--card); }
.c8-pile .pc.c8-top { position: relative; width: 100%; font-size: clamp(16px, 4vw, 24px); }
.c8-top.fresh { animation: pop .35s ease-out; }
.c8-suit {
  font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px;
  background: #f6ecd8; color: #1f1a14; border: 1px solid var(--card-edge);
}
.c8-suit.red { color: #c0392b; }
.c8-suit.called { background: var(--gold); border-color: var(--gold); animation: pop .35s ease-out; }
.c8-label { font-weight: 600; }
.c8-caption { font-weight: 600; text-align: center; min-height: 1.3em; }
.c8-hand-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; box-shadow: var(--shadow); display: grid; gap: 12px;
}
.c8-hand-box.mine { border-color: var(--accent); }
.c8-prompt h2 { margin: 0; font-size: 22px; }
.c8-prompt p { margin: 2px 0 8px; }
.c8-actions { margin: 0; }
.c8-suits { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.c8-suit-btn { font-size: 16px; }
.c8-suit-btn.red { color: #c0392b; }
.c8-result { border-collapse: collapse; margin: 8px auto 14px; font-variant-numeric: tabular-nums; }
.c8-result th, .c8-result td { padding: 4px 10px; text-align: right; vertical-align: middle; }
.c8-result th:first-child, .c8-result td:first-child { text-align: left; }
.c8-result tr.me, .c8-result .me { font-weight: 600; color: var(--accent); }
.c8-mini { display: inline-flex; flex-wrap: wrap; gap: 2px; justify-content: flex-end; max-width: 220px; }
.c8-chip {
  font-size: 12px; font-weight: 700; padding: 0 4px; border-radius: 3px; color: #1f1a14;
  background: var(--card); border: 1px solid var(--card-edge);
}
.c8-chip.red { color: #c0392b; }
.c8-out { color: var(--good); font-weight: 700; }
.c8-sheet { overflow-x: auto; }
.c8-sheet .c8-result { margin: 0; }
@media (max-width: 560px) {
  .c8-table { padding: 10px; }
  .c8-seat { padding: 6px; font-size: 13px; min-width: 78px; }
  .c8-score { font-size: 18px; }
}
@media (prefers-color-scheme: dark) { .c8-suit-btn.red { color: #ff7b6b; } }

/* ---------- Felt card tables ---------- */
/* The card games' tables are green felt in a wooden rail. Text sitting right on
   the felt switches to a light ink; seats keep their own background and ink. */
.sp-table, .eu-table, .hearts-table, .c8-table, .crib-board-wrap {
  background:
    url(/art/felt.svg) 0 0 / 160px 160px,
    radial-gradient(ellipse 80% 70% at 50% 40%, var(--felt), var(--felt-deep));
  border: 6px solid var(--rail); color: var(--felt-ink);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25), inset 0 0 28px rgba(0, 0, 0, .35), var(--shadow);
}
.sp-seat, .hearts-seat, .eu-seat, .c8-seat { color: var(--ink); }
.c8-table .c8-label, .c8-table .c8-caption { color: var(--felt-ink); }
.eu-seat { background: color-mix(in srgb, var(--surface) 92%, transparent); border-color: var(--line); }
.sp-trick .muted, .eu-mid .muted, .crib-key.muted { color: var(--felt-muted); }
.eu-mid { background: radial-gradient(ellipse at center, rgba(255, 255, 255, .09), transparent 70%); }
.eu-took { color: var(--gold); }
.crib-board .crib-empty { background: rgba(0, 0, 0, .14); border-color: rgba(246, 236, 216, .35); }
.crib-board.placing .crib-empty { border-color: rgba(246, 236, 216, .6); }
.crib-board.placing .crib-empty:hover, .crib-board .crib-empty.chosen { border-color: var(--gold); }
.crib-board .pc.starter { outline-color: var(--felt-muted); }
/* Farkle rolls onto a felt dice tray. */
.fk-table > .fk-dice {
  padding: 16px; min-height: 92px; border-radius: 10px; border: 4px solid var(--rail);
  background:
    url(/art/felt.svg) 0 0 / 160px 160px,
    radial-gradient(ellipse at 50% 40%, #8e3524, #4e170e);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, .45);
}
@media (max-width: 640px) {
  .sp-table, .eu-table, .hearts-table, .c8-table, .crib-board-wrap { border-width: 4px; }
  .fk-table > .fk-dice { padding: 10px; min-height: 70px; }
}

/* ---------- Letter Shake ---------- */
.ls { display: grid; gap: 16px; }
.ls > * { min-width: 0; }
.ls-table {
  display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 16px 22px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.ls-clockrow { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; }
.ls-clock { font-family: Fraunces, Georgia, serif; font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 84px; }
.ls-clock.low { color: var(--bad); animation: ls-pulse .5s ease-in-out infinite alternate; }
@keyframes ls-pulse { to { transform: scale(1.12); } }
.ls-track { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.ls-track > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .25s linear; }
/* The dice sit in a wooden tray. */
.ls-tray {
  --n: 4; --s: clamp(54px, 15vw, 76px);
  display: grid; grid-template-columns: repeat(var(--n), var(--s)); gap: 8px; padding: 14px;
  border-radius: 14px; border: 6px solid var(--rail);
  background:
    url(/art/felt.svg) 0 0 / 160px 160px,
    radial-gradient(ellipse at 50% 40%, #2f5d86, #16304a);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, .45), var(--shadow);
  touch-action: none; user-select: none; -webkit-user-select: none; justify-self: center;
}
.ls-tray.size-5 { --s: clamp(46px, 12.5vw, 64px); gap: 6px; }
.ls-die {
  width: var(--s); height: var(--s); display: grid; place-items: center; cursor: pointer;
  font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: calc(var(--s) * .5); line-height: 1;
  color: #2a2118; background: linear-gradient(145deg, #fffdf7, #eadcc2); border-radius: calc(var(--s) * .2);
  box-shadow: inset 0 -3px 0 rgba(110, 80, 40, .25), 0 3px 6px rgba(0, 0, 0, .35);
  transition: transform .08s ease, background .08s ease;
}
.ls-die.qu { font-size: calc(var(--s) * .4); }
.ls-die.mark { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.ls-die.on { background: linear-gradient(145deg, var(--gold), #e2a94a); transform: scale(.94); }
.ls-die.on.last { box-shadow: 0 0 0 3px var(--accent), 0 3px 6px rgba(0, 0, 0, .35); }
.ls-die.on.bad { background: linear-gradient(145deg, #f2b8ad, #d98674); }
.ls-die.shake { animation: ls-shake .5s ease-out both; }
@keyframes ls-shake {
  0% { transform: translate(-6px, 4px) rotate(-90deg) scale(.6); opacity: 0; }
  60% { transform: translate(2px, -2px) rotate(8deg) scale(1.04); opacity: 1; }
  100% { transform: none; }
}
@media (prefers-reduced-motion: reduce) { .ls-die.shake, .ls-clock.low { animation: none; } }
.ls-side { display: grid; gap: 10px; align-content: start; min-width: 0; }
.ls-entry { display: flex; gap: 8px; }
.ls-entry input {
  flex: 1; min-width: 0; font: 600 20px/1.2 Inter, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.ls-entry.nope { animation: ls-nope .3s ease; }
@keyframes ls-nope { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.ls-status { font-weight: 600; min-height: 1.5em; }
.ls-status.good { color: var(--good); }
.ls-status.bad { color: var(--bad); }
.ls-myhead { margin: 4px 0 0; font-size: 16px; }
.ls-mywords, .ls-words { display: flex; flex-wrap: wrap; gap: 6px; }
.ls-word {
  font-size: 14px; font-weight: 600; letter-spacing: .04em; padding: 3px 8px; border-radius: 6px;
  background: var(--card); border: 1px solid var(--card-edge);
}
.ls-word sup { font-size: 10px; color: var(--accent); margin-left: 3px; }
.ls-word.shared { text-decoration: line-through; color: var(--muted); background: transparent; }
.ls-counts, .ls-scores {
  display: grid; gap: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow);
}
.ls-count, .ls-score { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: baseline; padding: 2px 6px; border-radius: 8px; }
.ls-score { grid-template-columns: auto 1fr auto; }
.ls-count.me, .ls-score.me { background: var(--surface-2); }
.ls-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ls-review {
  display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.ls-review-head { display: flex; gap: 18px; align-items: center; }
.ls-review-head h2 { margin: 0 0 4px; }
.ls-review-head p { margin: 0; }
.ls-tray.mini { --s: 30px; gap: 3px; padding: 6px; border-width: 4px; flex: none; }
.ls-tray.mini.size-5 { --s: 25px; }
.ls-tray.mini .ls-die { cursor: default; box-shadow: none; border-radius: 5px; }
.ls-lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.ls-list { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; align-content: start; }
.ls-list.me { border-color: var(--accent); }
.ls-list-head { display: flex; justify-content: space-between; gap: 8px; }
.ls-list-head b { color: var(--accent); font-family: Fraunces, Georgia, serif; font-size: 18px; }
.ls-missed { font-size: 14px; color: var(--muted); }
@media (max-width: 640px) {
  .ls-table { grid-template-columns: 1fr; padding: 12px; }
  .ls-tray { border-width: 4px; padding: 10px; }
  .ls-review-head { flex-direction: column; align-items: flex-start; }
}
/* ---------- Snowman ---------- */
/* The snowman stands outside a frosty window in the wooden rail, with the word
   on paper tiles beside it. */
.snowman { display: grid; gap: 16px; }
.snowman > * { min-width: 0; }
.sm-stage {
  display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 18px; align-items: center;
  padding: 16px 20px; border-radius: var(--radius); border: 6px solid var(--rail); color: #eef4fb;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, .8) 0 1.5px, transparent 2.5px) 0 0 / 70px 60px,
    radial-gradient(circle at 60% 70%, rgba(255, 255, 255, .55) 0 1.2px, transparent 2px) 0 0 / 46px 52px,
    linear-gradient(180deg, #1f3a5c, #36597f 70%, #4d7096);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25), inset 0 0 30px rgba(0, 0, 0, .35), var(--shadow);
}
.sm-stage.mine { border-color: var(--accent); }
.sm-scene { display: grid; justify-items: center; gap: 4px; }
.sm-snowman { width: 100%; max-width: 200px; height: auto; overflow: visible; }
.sm-snow { fill: #fbfdff; stroke: #c9d8e8; stroke-width: 1.5; }
.sm-ground { fill: #e8f0f8; }
.sm-puddle { fill: rgba(170, 205, 235, .7); transition: rx .4s ease; }
.sm-coal { fill: #2a2118; }
.sm-smile { fill: none; stroke: #2a2118; stroke-width: 2.4; stroke-linecap: round; }
.sm-carrot { fill: #e8792f; }
.sm-stick { fill: none; stroke: #7a4d26; stroke-width: 4; stroke-linecap: round; }
.sm-scarf { fill: #c0392b; }
.sm-hat { fill: #2a2118; }
.sm-band { fill: #b5502c; }
.sm-melting { animation: sm-melt 1.1s ease-in forwards; transform-box: fill-box; transform-origin: center; }
@keyframes sm-melt {
  to { transform: translateY(40px) scaleY(.4); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .sm-melting { animation: none; opacity: 0; } }
.sm-meter { font-size: 13px; font-weight: 600; color: #dbe7f3; letter-spacing: .02em; }
.sm-side { display: grid; gap: 12px; align-content: center; min-width: 0; }
.sm-category {
  justify-self: start; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: #1f3a5c; background: #dbe7f3; border-radius: 999px; padding: 3px 12px;
}
.sm-word { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.sm-chunk { display: inline-flex; gap: 5px; flex-wrap: nowrap; }
.sm-tile {
  --s: 38px; width: var(--s); height: calc(var(--s) * 1.18); display: grid; place-items: center;
  font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: calc(var(--s) * .62); color: var(--ink);
  background: rgba(255, 255, 255, .14); border-bottom: 3px solid #dbe7f3; border-radius: 6px 6px 2px 2px;
}
.sm-tile.shown { background: linear-gradient(160deg, #fffdf7, #efe4cf); border-bottom-color: #cbb894; box-shadow: 0 2px 4px rgba(0, 0, 0, .3); color: #2a2118; }
.sm-tile.revealed { color: var(--bad); }
.sm-tile.fresh { animation: pop .35s ease-out both; }
.sm-punct { align-self: end; font-size: 26px; font-weight: 700; }
.sm-misses { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sm-misses .muted { color: #c6d6e6; }
.sm-miss {
  min-width: 26px; text-align: center; padding: 1px 6px; border-radius: 6px; font-weight: 700;
  background: rgba(0, 0, 0, .25); color: #ffd0c8; text-decoration: line-through;
}
.sm-miss.wide { font-weight: 600; font-size: 13px; }
.sm-turn { display: grid; gap: 4px; }
.sm-turn h2 { margin: 0; font-size: 21px; color: #fff; }
.sm-turn p { margin: 0; }
.sm-turn.fresh .sm-last { animation: pop .35s ease-out; }
.sm-last { color: #dbe7f3; }
.sm-last.is-miss, .sm-last.is-wrong { color: #ffc2b8; font-weight: 600; }
.sm-last.is-hit { color: #b9f0cd; font-weight: 600; }
.sm-result { display: grid; gap: 8px; justify-items: start; }
.sm-result h2 { margin: 0; font-size: 24px; color: #fff; }
.sm-result .muted { color: #c6d6e6; margin: 0; }
.sm-keys {
  display: grid; gap: 6px; justify-items: center; padding: 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.sm-row { display: flex; gap: 6px; justify-content: center; }
.sm-key {
  width: 40px; height: 46px; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: 700 18px Inter, system-ui, sans-serif; cursor: pointer; box-shadow: 0 2px 0 var(--line);
}
.sm-key:hover:not(:disabled) { border-color: var(--accent); }
.sm-key:disabled { cursor: default; }
.sm-keys:not(.active) .sm-key:not(.hit):not(.miss) { opacity: .7; }
.sm-key.hit { background: var(--good); border-color: var(--good); color: #fff; box-shadow: none; }
.sm-key.miss { background: var(--surface-2); color: var(--muted); text-decoration: line-through; box-shadow: none; opacity: .6; }
.sm-solve { display: flex; gap: 8px; width: 100%; max-width: 440px; margin-top: 6px; }
.sm-solve input { flex: 1; min-width: 0; }
.sm-hint { margin: 4px 0 0; }
.sm-scores { display: flex; flex-wrap: wrap; gap: 8px; }
.sm-score {
  display: flex; align-items: baseline; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
}
.sm-score.active { border-color: var(--accent); background: var(--surface-2); }
.sm-score.won .sm-name { color: var(--accent); font-weight: 700; }
.sm-score b { font-family: Fraunces, Georgia, serif; font-variant-numeric: tabular-nums; }
.sm-lead { font-size: 12px; color: var(--muted); }
.sm-history { font-size: 14px; color: var(--muted); display: grid; gap: 4px; }
.sm-history b { color: var(--ink); letter-spacing: .04em; }
@media (max-width: 640px) {
  .sm-stage { grid-template-columns: 1fr; padding: 12px; border-width: 4px; }
  .sm-snowman { max-width: 130px; }
  .sm-tile { --s: 28px; }
  .sm-word { gap: 8px 14px; }
  .sm-chunk { gap: 3px; }
  .sm-keys { padding: 8px 4px; }
  .sm-row { gap: 4px; }
  .sm-key { width: calc((100vw - 80px) / 10); max-width: 36px; height: 44px; font-size: 16px; }
}

/* ---------- Backgammon ---------- */
.bg { display: grid; gap: 14px; }
.bg > * { min-width: 0; }
.bg-crawford { color: var(--accent); font-weight: 600; }
.bg-players { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bg-player {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px; display: grid; gap: 2px;
}
.bg-player.active { border-color: var(--accent); background: var(--surface-2); }
.bg-player.won .bg-pname { color: var(--accent); font-weight: 700; }
.bg-player-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bg-pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bg-pscore { font-family: Fraunces, Georgia, serif; font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
.bg-chip { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.bg-status {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px;
}
.bg-status.mine { border-color: var(--accent); }
.bg-status-text { margin: 0; font-weight: 600; }
.bg-btns { margin: 0; }
.bg-hint { margin: 6px 2px 0; }
.bg-log-win { font-weight: 600; }

/* The board: green felt in a wooden rail, two rows of points, a bar down the
   middle and a bear-off tray on the right. */
.bg-board-wrap { container-type: inline-size; max-width: 760px; width: 100%; justify-self: center; }
.bg-board {
  --bar: clamp(20px, 6cqw, 40px); --tray: clamp(24px, 6.5cqw, 44px);
  display: grid; grid-template-columns: 1fr var(--bar) 1fr var(--tray);
  border: 6px solid var(--rail); border-radius: 10px; overflow: hidden;
  background:
    url(/art/felt.svg) 0 0 / 160px 160px,
    radial-gradient(ellipse 80% 70% at 50% 45%, var(--felt), var(--felt-deep));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25), inset 0 0 28px rgba(0, 0, 0, .35), var(--shadow);
  user-select: none;
}
.bg-quad { display: grid; grid-template-columns: repeat(6, 1fr); padding: 0 2px; }
.bg-quad.tl, .bg-quad.tr { padding-top: 4px; }
.bg-quad.bl, .bg-quad.br { padding-bottom: 4px; }
.bg-pt { position: relative; aspect-ratio: 1 / 4.6; display: flex; flex-direction: column; align-items: center; outline: none; }
.bg-pt::before {
  content: ''; position: absolute; left: 4%; right: 4%; height: 84%;
  background: #e5d1a8; clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.bg-pt.odd::before { background: #a5412b; }
.bg-pt.top::before { top: 0; }
.bg-pt.bottom { flex-direction: column-reverse; }
.bg-pt.bottom::before { bottom: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.bg-stack { position: relative; display: flex; flex-direction: inherit; align-items: center; width: 100%; }
.bg-num {
  position: absolute; left: 0; right: 0; text-align: center; font-size: clamp(8px, 1.7cqw, 11px);
  color: var(--felt-muted); opacity: .7; pointer-events: none;
}
.bg-pt.top .bg-num { bottom: 0; }
.bg-pt.bottom .bg-num { top: 0; }
.bg-checker {
  width: 88%; aspect-ratio: 1; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: clamp(9px, 2.2cqw, 15px); box-shadow: 0 1px 2px rgba(0, 0, 0, .5), inset 0 -2px 3px rgba(0, 0, 0, .25);
}
.bg-checker.white, .bg-chip.white, .bg-slab.white {
  background: radial-gradient(circle at 40% 35%, #fffaf0, #e9dcc2 60%, #cdbb98);
  color: #4a3a28; border: 1px solid #b8a37f;
}
.bg-checker.black, .bg-chip.black, .bg-slab.black {
  background: radial-gradient(circle at 40% 35%, #6e4a33, #3b2416 60%, #24150c);
  color: #f3dfbd; border: 1px solid #1a0e07;
}
.bg-checker.white { box-shadow: 0 1px 2px rgba(0, 0, 0, .5), inset 0 0 0 3px rgba(184, 163, 127, .35); }
.bg-checker.black { box-shadow: 0 1px 2px rgba(0, 0, 0, .5), inset 0 0 0 3px rgba(243, 223, 189, .12); }
/* Checkers you can move glow a little; the picked one and the places it can go glow gold. */
.bg-pt.can, .bg-bar.can { cursor: pointer; }
.bg-pt.can.top .bg-stack > :last-child, .bg-pt.can.bottom .bg-stack > :last-child, .bg-bar.can .bg-stack > :last-child {
  box-shadow: 0 0 0 2px rgba(243, 210, 122, .55), 0 1px 2px rgba(0, 0, 0, .5);
}
.bg-pt.sel .bg-stack > :last-child, .bg-bar.sel .bg-stack > :last-child {
  box-shadow: 0 0 0 3px var(--gold), 0 0 12px var(--gold); transform: scale(1.06);
}
.bg-pt.goal { cursor: pointer; }
.bg-pt.goal::after {
  content: ''; position: absolute; left: 50%; width: 80%; aspect-ratio: 1; translate: -50% 0; border-radius: 50%;
  border: 2px dashed var(--gold); background: rgba(243, 210, 122, .18); animation: bg-glow 1.2s ease-in-out infinite alternate;
}
.bg-pt.goal.top::after { top: calc(var(--n, 0) * 19% + 1%); }
.bg-pt.goal.bottom::after { bottom: calc(var(--n, 0) * 19% + 1%); }
.bg-pt.goal::before { filter: brightness(1.18) saturate(1.1); }
.bg-pt.last .bg-stack > :last-child { box-shadow: 0 0 0 2px rgba(246, 236, 216, .7), 0 1px 2px rgba(0, 0, 0, .5); }
@keyframes bg-glow { from { opacity: .55; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .bg-pt.goal::after { animation: none; } }
.bg-pt:focus-visible, .bg-bar:focus-visible, .bg-tray:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.bg-bar {
  background: linear-gradient(90deg, rgba(0, 0, 0, .25), transparent 30%, transparent 70%, rgba(0, 0, 0, .25)), var(--rail);
  display: flex; flex-direction: column; align-items: center; padding: 6px 0;
}
.bg-bar.bottom { flex-direction: column-reverse; }
.bg-bar.bottom .bg-stack { flex-direction: column-reverse; }
.bg-bar .bg-checker { width: 82%; }
.bg-tray {
  background: linear-gradient(180deg, rgba(0, 0, 0, .2), rgba(0, 0, 0, .05)), var(--rail);
  border-left: 3px solid rgba(0, 0, 0, .25); position: relative; display: flex; flex-direction: column; align-items: center; padding: 6px 3px;
}
.bg-tray.bottom { flex-direction: column-reverse; }
.bg-tray.goal { cursor: pointer; background: linear-gradient(0deg, rgba(243, 210, 122, .35), rgba(243, 210, 122, .08)), var(--rail); box-shadow: inset 0 0 0 2px var(--gold); }
.bg-off { display: flex; flex-direction: inherit; gap: 1px; width: 100%; }
.bg-slab { display: block; width: 100%; height: clamp(4px, 1.1cqw, 7px); border-radius: 2px; }
.bg-off-n { font-size: 12px; font-weight: 700; color: var(--felt-ink); margin: 2px 0; }
.bg-mid {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: clamp(40px, 9cqw, 64px);
  border-top: 1px solid rgba(0, 0, 0, .12); border-bottom: 1px solid rgba(0, 0, 0, .12);
}
.bg-dice { display: flex; gap: clamp(4px, 1.4cqw, 10px); }
.bg-die { --s: clamp(24px, 6.4cqw, 44px); background: #fffdf7; border-color: #cbb894; }
.bg-die .pip { background: #2a2118; }
.bg-die.used { opacity: .35; box-shadow: none; }
.bg-dice.theirs .bg-die { --s: clamp(22px, 5.4cqw, 38px); }
.bg-cube {
  width: clamp(26px, 6cqw, 40px); aspect-ratio: 1; display: grid; place-items: center; border-radius: 6px;
  background: linear-gradient(145deg, #fffaf0, #e2d2b2); color: #3b2416; border: 1px solid #b8a37f;
  font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: clamp(12px, 2.6cqw, 18px); box-shadow: 0 2px 4px rgba(0, 0, 0, .4);
}
.bg-cube.mine { transform: translateY(6px); }
.bg-cube.theirs { transform: translateY(-6px); }
.bg-cube.off { opacity: .45; }
.bg-cube-label { font-size: 12px; color: var(--felt-muted); }
@media (max-width: 640px) {
  .bg-board { border-width: 4px; }
  .bg-players { gap: 6px; }
  .bg-player { padding: 6px 10px; }
  .bg-pscore { font-size: 20px; }
  .bg-cube-label { display: none; }
}
/* ---------- Dots and Boxes ---------- */
/* The board is a sheet of graph paper on the table, framed in the wooden
   rail, with each player's lines in their own pencil colour. */
.dotsboxes { display: grid; gap: 14px; }
.dotsboxes > * { min-width: 0; }
.db-paper {
  justify-self: center; width: 100%; max-width: 560px; padding: 10px; border-radius: var(--radius);
  border: 6px solid var(--rail); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2), var(--shadow);
  background:
    linear-gradient(rgba(70, 120, 180, .13) 1px, transparent 1px) 0 0 / 15px 15px,
    linear-gradient(90deg, rgba(70, 120, 180, .13) 1px, transparent 1px) 0 0 / 15px 15px,
    linear-gradient(160deg, #fffdf7, #f3ead8);
}
.db-paper.mine { border-color: var(--accent); }
.db-board { display: block; width: 100%; height: auto; touch-action: manipulation; user-select: none; }
.db-dots circle { fill: #2a2118; }
.db-line { stroke-width: 6; stroke-linecap: round; }
.db-line.last { stroke-width: 7.5; }
.db-line.fresh { animation: db-draw .45s ease-out; }
@keyframes db-draw { from { opacity: .2; stroke-width: 14; } }
.db-fill { opacity: .22; }
.db-initial { font: 700 26px Fraunces, Georgia, serif; text-anchor: middle; }
.db-box.fresh { animation: pop .4s ease-out both; transform-box: fill-box; transform-origin: center; }
.db-hit { cursor: pointer; }
.db-zone { fill: transparent; }
.db-ghost { stroke: var(--mine, #b5502c); stroke-width: 6; stroke-linecap: round; opacity: 0; stroke-dasharray: 2 8; pointer-events: none; }
.db-board.active .db-ghost { opacity: .18; }
.db-hit:hover .db-ghost, .db-hit:focus .db-ghost { opacity: .75; stroke-dasharray: none; }
.db-board.waiting .db-hits { pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .db-line.fresh, .db-box.fresh { animation: none; } }
.db-turn { display: grid; gap: 2px; justify-items: center; text-align: center; }
.db-turn h2 { margin: 0; font-size: 21px; display: inline-flex; align-items: center; gap: 8px; }
.db-turn p { margin: 0; }
.db-turn.fresh .db-last { animation: pop .35s ease-out; }
.db-last { color: var(--good); font-weight: 600; }
.db-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; margin-right: 6px; vertical-align: -1px; }
.db-scores { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.db-score {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
}
.db-score .db-swatch { margin: 0; }
.db-score.active { border-color: var(--seat); box-shadow: 0 0 0 2px var(--seat); }
.db-score.won .db-name { color: var(--accent); font-weight: 700; }
.db-score b { font-family: Fraunces, Georgia, serif; font-variant-numeric: tabular-nums; }
.db-lead { font-size: 12px; color: var(--muted); }
@media (max-width: 640px) {
  .db-paper { padding: 4px; border-width: 4px; }
  .db-turn h2 { font-size: 18px; }
}

/* ---------- Othello ---------- */
.othello { display: grid; gap: 16px; }
.othello > * { min-width: 0; }
.ot-count { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; }
.ot-count.up { background: var(--surface-2); outline: 2px solid var(--accent); }
.ot-turn {
  display: flex; gap: 16px; align-items: center; background: var(--surface);
  border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 18px;
}
.ot-turn.mine { border-color: var(--accent); }
.ot-turn h2 { margin: 0; font-size: 22px; }
.ot-turn p { margin: 2px 0 0; }
.ot-pass { color: var(--accent); font-weight: 600; }
.ot-head { display: inline-flex; align-items: center; gap: 8px; }
.ot-log-row { display: flex; align-items: center; gap: 8px; }
.ot-board-wrap {
  justify-self: center; width: min(100%, 560px); padding: 12px 14px 14px 8px; border-radius: 16px;
  background:
    url(/art/felt.svg) 0 0 / 160px 160px,
    radial-gradient(ellipse 80% 70% at 50% 40%, var(--felt), var(--felt-deep));
  border: 8px solid var(--rail);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25), inset 0 0 28px rgba(0, 0, 0, .35), var(--shadow);
}
.ot-board {
  display: grid; grid-template-columns: 1.1em repeat(var(--n), 1fr); gap: 3px;
  color: var(--felt-muted); font-size: 12px;
}
.ot-label { display: grid; place-items: center; font-weight: 600; text-transform: lowercase; }
.ot-sq {
  aspect-ratio: 1; display: grid; place-items: center; padding: 0; border: 0; border-radius: 4px;
  background: rgba(0, 0, 0, .14); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .28); font: inherit; color: inherit;
  perspective: 300px;
}
button.ot-sq { cursor: pointer; }
.ot-sq.last { box-shadow: inset 0 0 0 2px var(--gold); }
.ot-disc {
  display: block; width: 82%; aspect-ratio: 1; border-radius: 50%;
  box-shadow: 0 2px 3px rgba(0, 0, 0, .45), inset 0 -2px 3px rgba(0, 0, 0, .25);
}
.ot-disc.black { background: radial-gradient(circle at 35% 30%, #5a5148, #17130f 65%); }
.ot-disc.white { background: radial-gradient(circle at 35% 30%, #fffef9, #e6dcc8 70%); }
.ot-disc.tiny { width: 14px; height: 14px; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
.ot-disc.big { width: 48px; height: 48px; flex: none; }
.ot-disc.placed { animation: pop .3s ease-out; }
.ot-disc.flip { animation: ot-flip .5s ease-in-out; }
@keyframes ot-flip {
  0% { transform: rotateY(0); filter: invert(1); }
  49% { filter: invert(1); }
  50% { transform: rotateY(90deg); filter: none; }
  100% { transform: rotateY(0); }
}
.ot-disc.ghost { opacity: 0; transition: opacity .12s; box-shadow: none; }
.ot-sq.hint::before {
  content: ""; grid-area: 1 / 1; width: 22%; aspect-ratio: 1; border-radius: 50%;
  background: var(--gold); opacity: .75;
}
.ot-sq.open .ot-disc.ghost { grid-area: 1 / 1; }
.ot-sq.open:hover .ot-disc.ghost, .ot-sq.open:focus-visible .ot-disc.ghost { opacity: .55; }
.ot-sq.open:hover::before { opacity: 0; }
@media (max-width: 560px) {
  .ot-board-wrap { padding: 8px 8px 8px 4px; border-width: 6px; }
  .ot-board { gap: 2px; font-size: 10px; }
  .ot-disc.big { width: 36px; height: 36px; }
}

/* ---------- Gin Rummy ---------- */
.gin { display: grid; gap: 16px; }
.gin > * { min-width: 0; }
.gin-table {
  display: grid; gap: 14px; justify-items: center; padding: 16px; border-radius: var(--radius);
  background:
    url(/art/felt.svg) 0 0 / 160px 160px,
    radial-gradient(ellipse 80% 70% at 50% 40%, var(--felt), var(--felt-deep));
  border: 6px solid var(--rail); color: var(--felt-ink);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25), inset 0 0 28px rgba(0, 0, 0, .35), var(--shadow);
}
.gin-across { display: grid; justify-items: center; gap: 8px; }
.gin-seat {
  text-align: center; padding: 8px 14px; border: 2px solid transparent; border-radius: 10px;
  background: var(--surface-2); color: var(--ink); min-width: 140px; max-width: 100%;
}
.gin-seat.active { border-color: var(--accent); }
.gin-seat.winner-seat { background: var(--accent); color: var(--accent-ink); }
.gin-seat.winner-seat .muted { color: inherit; }
.gin-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gin-score { font-family: Fraunces, Georgia, serif; font-size: 24px; font-weight: 700; line-height: 1.1; }
/* Card backs: a burgundy back with a cream lattice. */
.gin-back {
  width: 34px; aspect-ratio: 5 / 7; border-radius: 5px; border: 2px solid #f6ecd8; flex: none;
  background:
    repeating-linear-gradient(45deg, rgba(246, 236, 216, .22) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(246, 236, 216, .22) 0 2px, transparent 2px 7px),
    #7d2333;
  box-shadow: -1px 1px 3px rgba(0, 0, 0, .35);
}
.gin-backs { display: flex; justify-content: center; }
.gin-backs .gin-back + .gin-back { margin-left: -22px; }
.gin-piles { display: flex; gap: 28px; align-items: flex-start; justify-content: center; flex-wrap: wrap; padding: 6px 0; }
.gin-pile {
  all: unset; box-sizing: border-box; position: relative; display: grid; justify-items: center; gap: 6px;
  width: 84px; border-radius: 10px; cursor: default;
}
.gin-pile > .pc, .gin-pile > .gin-back, .gin-pile > .gin-empty { width: 84px; grid-area: 1 / 1; }
.gin-pile .gin-back.stack {
  box-shadow: 2px 2px 0 #5b1824, 4px 4px 0 #f6ecd8, 5px 5px 0 #5b1824, 0 6px 12px rgba(0, 0, 0, .35);
}
.gin-pile .pc.top { transform: rotate(2deg); }
.gin-pile .pc.top.stacked { box-shadow: -2px 2px 0 #d9ccb4, -4px 4px 0 #c9b99c, 0 6px 12px rgba(0, 0, 0, .35); }
.gin-pile .pc.fresh { animation: pop .35s ease-out; }
.gin-empty { aspect-ratio: 5 / 7; border: 2px dashed rgba(246, 236, 216, .4); border-radius: 8px; }
.gin-pile-label { grid-area: 2 / 1; font-size: 13px; color: var(--felt-muted); font-weight: 600; }
.gin-pile.live { cursor: pointer; }
.gin-pile.live > .pc.top, .gin-pile.live > .gin-back { outline: 3px solid var(--gold); outline-offset: 2px; }
.gin-pile.live:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }
@media (hover: hover) {
  .gin-pile.live:hover > .pc.top, .gin-pile.live:hover > .gin-back { transform: translateY(-4px); }
}
.gin-caption { flex-basis: 100%; text-align: center; font-weight: 600; color: var(--felt-ink); }
.gin-hand-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; box-shadow: var(--shadow); display: grid; gap: 8px;
}
.gin-prompt h2 { margin: 0; font-size: 22px; }
.gin-prompt p { margin: 2px 0 8px; }
.gin-knock { background: var(--good); border-color: var(--good); }
/* Each meld gets its own colour stripe; deadwood has none. */
.gin-m0 { --meld: #2f7d4f; }
.gin-m1 { --meld: #2c6aa0; }
.gin-m2 { --meld: #8a4fb0; }
.gin-m3 { --meld: #b5502c; }
.pc.gin-meld { background: linear-gradient(160deg, #fff 0%, color-mix(in srgb, var(--meld) 14%, #fffdf8) 100%); }
.pc.gin-meld, .fan-card:not(.up) .pc.gin-meld { box-shadow: inset 5px 0 0 var(--meld), -2px 1px 4px rgba(40, 25, 10, .22); }
/* A little air between melds, and before the deadwood. */
.gin-hand .fan-card.gin-break { margin-left: calc(var(--gap) - var(--cw) + 12px); }
.gin-summary { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; justify-content: center; }
.gin-chip { padding: 2px 8px; border-radius: 999px; background: var(--meld); color: #fff; font-weight: 600; white-space: nowrap; }
.gin-dw { margin-left: 6px; }
.gin-result h2 { font-size: 26px; }
.gin-showdown { display: grid; gap: 14px; margin: 10px 0 16px; }
.gin-spread { display: grid; gap: 6px; justify-items: center; }
.gin-spread-head { font-weight: 600; }
.gin-groups { display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: center; }
.gin-group { display: flex; }
.gin-group .pc { width: 54px; }
.gin-group .pc + .pc { margin-left: -16px; }
.gin-group.dead .pc { filter: saturate(.6) brightness(.93); }
.gin-group .pc.laid { outline: 2px dashed var(--accent); outline-offset: -4px; }
.gin-sheet { overflow-x: auto; }
.gin-sheet .hearts-result { margin: 0; }
@media (max-width: 560px) {
  .gin-table { padding: 10px; border-width: 4px; }
  .gin-pile, .gin-pile > .pc, .gin-pile > .gin-back, .gin-pile > .gin-empty { width: 66px; }
  .gin-back { width: 26px; }
  .gin-backs .gin-back + .gin-back { margin-left: -17px; }
  .gin-group .pc { width: 46px; }
  .gin-group .pc + .pc { margin-left: -16px; }
}

/* ---------- Yahtzee ---------- */
/* The dice and table borrow Farkle's look; the tray is green felt. */
.yahtzee { display: grid; gap: 16px; }
.yahtzee > * { min-width: 0; }
.yz-table > .fk-dice {
  background:
    url(/art/felt.svg) 0 0 / 160px 160px,
    radial-gradient(ellipse at 50% 40%, var(--felt), var(--felt-deep));
  align-items: flex-start;
}
.yz-slot { display: grid; justify-items: center; gap: 4px; }
.yz-held { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--gold); min-height: 1.2em; }
.fk-die.yz-blank { background: rgba(255, 255, 255, .08); border: 2px dashed rgba(246, 236, 216, .35); box-shadow: none; }
.yz-rolls { display: flex; gap: 6px; align-items: center; }
.yz-rolls span { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); }
.yz-rolls span.used { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.yz-rolls em { font-style: normal; margin-right: 4px; }
.yz-big { border-color: var(--gold); }
.yz-big .fk-last-text { color: var(--accent); font-weight: 700; }
.yz-card-wrap {
  overflow-x: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.yz-card { border-collapse: collapse; width: 100%; font-size: 15px; font-variant-numeric: tabular-nums; }
.yz-card th, .yz-card td { padding: 5px 10px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.yz-card thead th { font-weight: 700; max-width: 9em; overflow: hidden; text-overflow: ellipsis; border-bottom: 2px solid var(--line); }
.yz-card thead th.active { color: var(--accent); }
.yz-card thead th.won { color: var(--accent); }
.yz-card .yz-cat { text-align: left; font-weight: 600; position: sticky; left: 0; background: var(--surface); }
.yz-card td.just { color: var(--accent); font-weight: 700; animation: pop .35s ease-out; }
.yz-sum th, .yz-sum td { background: var(--surface-2); font-size: 13px; color: var(--muted); }
.yz-sum .yz-cat { background: var(--surface-2); }
.yz-bonus td { font-size: 12px; }
.yz-total th, .yz-total td { font-family: Fraunces, Georgia, serif; font-size: 18px; font-weight: 700; border-bottom: 0; }
.yz-pick {
  min-width: 40px; padding: 3px 8px; border-radius: 8px; border: 1px dashed var(--accent);
  background: transparent; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer;
}
.yz-pick:hover { background: var(--surface-2); }
.yz-pick.zero { border-color: var(--line); color: var(--muted); font-weight: 400; }
.yz-pick.picked { background: var(--accent); border-style: solid; border-color: var(--accent); color: var(--surface); }
.yz-could { color: var(--muted); font-style: italic; }
@media (max-width: 640px) {
  .yz-card { font-size: 14px; }
  .yz-card th, .yz-card td { padding: 5px 6px; }
  .yz-card thead th { max-width: 5.5em; font-size: 13px; }
}
/* ---------- Sea Battle ---------- */
/* Each side's chart is a patch of sea in a wooden frame, with grey hulls and
   red and white pegs like the travel game. */
.bs { display: grid; gap: 16px; }
.bs > * { min-width: 0; }
.bs-status {
  display: grid; gap: 6px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.bs-status.mine { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.bs-status h2 { margin: 0; font-size: 21px; }
.bs-status p { margin: 0; color: var(--muted); }
.bs-actions { margin: 4px 0 0; }
.bs-last.is-hit, .bs-last.is-sunk { color: var(--bad); font-weight: 600; }
.bs-last.fresh { animation: pop .35s ease-out; }
.bs-seas { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.bs-seas.placing { grid-template-columns: minmax(0, 1.35fr) minmax(160px, .6fr); }
.bs-panel {
  --sea: #2f6f95; --sea-deep: #1d4a68; --sea-line: rgba(220, 240, 255, .2);
  display: grid; gap: 8px; padding: 12px; border-radius: var(--radius); border: 6px solid var(--rail); color: #eef6fb;
  background:
    radial-gradient(ellipse 60% 40% at 30% 20%, rgba(255, 255, 255, .12), transparent 70%),
    linear-gradient(170deg, var(--sea), var(--sea-deep));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25), inset 0 0 30px rgba(0, 0, 0, .35), var(--shadow);
}
.bs-panel.target { border-color: var(--accent); }
.bs-panel.own { --sea: #3a7896; --sea-deep: #24506a; }
.bs-title { font: 700 17px Fraunces, Georgia, serif; letter-spacing: .01em; }
.bs-grid {
  display: grid; grid-template-columns: 18px repeat(var(--n), minmax(0, 1fr)); grid-template-rows: 18px;
  grid-auto-rows: auto; gap: 0; width: 100%; max-width: 520px; justify-self: center;
}
.bs-panel.small .bs-grid { max-width: 380px; }
.bs-head { display: grid; place-items: center; font-size: 11px; font-weight: 600; color: rgba(238, 246, 251, .7); }
.bs-cell {
  aspect-ratio: 1; padding: 0; border: 0; border-right: 1px solid var(--sea-line); border-bottom: 1px solid var(--sea-line);
  background: transparent; cursor: default; min-width: 0;
}
.bs-cell:nth-of-type(10n + 1) { border-left: 1px solid var(--sea-line); }
.bs-grid > .bs-cell:nth-child(-n + 30) { border-top: 1px solid var(--sea-line); }
.bs-cell:disabled { cursor: default; }
.bs-panel.target .bs-cell:not(:disabled) { cursor: crosshair; }
.bs-panel.target .bs-cell:not(:disabled):hover,
.bs-panel.own .bs-cell:not(:disabled):hover { background: rgba(255, 255, 255, .16); }
.bs-cell.aiming { background: rgba(243, 210, 122, .45); }
.bs-ship {
  position: relative; margin: 3px; padding: 0; border: 0; border-radius: 999px; pointer-events: none;
  background: linear-gradient(180deg, #c3ccd3, #8b979f 55%, #6d7980); box-shadow: 0 2px 4px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.bs-ship.v { background: linear-gradient(90deg, #c3ccd3, #8b979f 55%, #6d7980); }
button.bs-ship { pointer-events: auto; cursor: grab; }
.bs-ship.picked { outline: 3px solid var(--gold); outline-offset: 1px; }
.bs-ship.sunk { background: linear-gradient(180deg, #6b5b52, #3e332d); opacity: .85; }
.bs-deck { position: absolute; inset: 30% 18%; border-radius: 999px; background: rgba(0, 0, 0, .14); }
.bs-peg {
  pointer-events: none; place-self: center; width: 42%; aspect-ratio: 1; border-radius: 50%; z-index: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .5), inset 0 -2px 2px rgba(0, 0, 0, .25);
}
.bs-peg.miss { width: 30%; background: radial-gradient(circle at 35% 30%, #fff, #d9e3ea); }
.bs-peg.hit { background: radial-gradient(circle at 35% 30%, #ff8a73, #d23a24 55%, #8e1f12); }
.bs-peg.fresh { animation: bs-splash .5s ease-out both; }
@keyframes bs-splash {
  0% { transform: scale(2.4); opacity: 0; box-shadow: 0 0 0 6px rgba(255, 255, 255, .7); }
  60% { transform: scale(.9); opacity: 1; }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) { .bs-peg.fresh, .bs-last.fresh { animation: none; } }
.bs-fleet { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: rgba(238, 246, 251, .85); }
.bs-fleet.own {
  display: grid; align-content: start; gap: 8px; padding: 12px; border-radius: var(--radius); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 14px;
}
.bs-fleet-ship { display: flex; align-items: center; gap: 6px; }
.bs-fleet-ship.sunk { text-decoration: line-through; opacity: .6; }
.bs-fleet-ship.picked { font-weight: 700; color: var(--accent); }
.bs-mini { display: inline-flex; gap: 2px; }
.bs-mini i { width: 7px; height: 7px; border-radius: 2px; background: currentColor; opacity: .7; }
.bs-crews { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bs-crew { display: grid; gap: 4px; padding: 10px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.bs-crew.active { border-color: var(--accent); background: var(--surface-2); }
.bs-crew.won strong { color: var(--accent); }
.bs-crew-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.bs-member { font-size: 14px; }
.bs-member.up { font-weight: 700; }
.bs-member.up::before { content: '🎯 '; }
@media (max-width: 720px) {
  .bs-seas, .bs-seas.placing { grid-template-columns: 1fr; }
  .bs-panel { padding: 8px; border-width: 4px; }
  .bs-panel.small .bs-grid { max-width: 300px; }
  .bs-crews { grid-template-columns: 1fr; }
}
