/* Hexfield — browser UI. No frameworks, no external assets. */
:root {
  --bg: #0d1117;
  --bg-2: #121923;
  --panel: #161e2a;
  --panel-2: #1c2635;
  --line: #273347;
  --line-2: #33425a;
  --text: #e6ebf2;
  --muted: #8b98ad;
  --faint: #7d8aa0;
  --accent: #f0b429;
  --accent-ink: #1a1305;
  --good: #3ecf8e;
  --ok: #8bd17c;
  --warn: #f5c542;
  --bad: #f08a3c;
  --worst: #f0506e;
  --timber: #2f8a55;
  --clay: #c4613f;
  --wool: #93c95a;
  --grain: #e9b934;
  --stone: #8d99ae;
  --p0: #ef4f5a;
  --p1: #3d8ef8;
  --p2: #f79a2b;
  --p3: #eceef2;
  --radius: 14px;
  --shadow: 0 10px 30px rgb(0 0 0 / .35), 0 2px 6px rgb(0 0 0 / .25);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Hoard", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 700px at 50% 35%, #172338 0%, transparent 70%),
    radial-gradient(800px 500px at 85% 100%, #1a1f2f 0%, transparent 70%),
    var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.sprite { position: absolute; width: 0; height: 0; }
button { font: inherit; color: inherit; }
h2 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ layout */
.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 340px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top top" "left board right" "tray tray tray";
  gap: 12px;
  padding: 12px 14px 14px;
}
.topbar { grid-area: top; display: flex; align-items: center; gap: 16px; min-width: 0; }
.left { grid-area: left; display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: auto; scrollbar-width: thin; }
.right { grid-area: right; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
/* the stage: open sea edge to edge, the island as large as the panel allows */
.board-wrap {
  grid-area: board; position: relative; min-height: 0; min-width: 0; overflow: hidden;
  border-radius: 20px; border: 1px solid #1c4266;
  background: radial-gradient(120% 95% at 50% 42%, #1f74a8 0%, #14527f 45%, #0a2c4d 100%);
  box-shadow: inset 0 0 90px rgb(3 12 24 / .55), 0 10px 30px rgb(0 0 0 / .3);
}
.tray { grid-area: tray; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

/* ------------------------------------------------------------ top bar */
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-mark { width: 30px; height: 30px; fill: var(--accent); filter: drop-shadow(0 2px 8px rgb(240 180 41 / .35)); }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: .02em; }
.brand-sub { font-size: 11px; color: var(--muted); }
.status { flex: 1; min-width: 0; display: flex; justify-content: center; }
.top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.seed { font: 12px var(--mono); color: var(--faint); margin-right: 6px; cursor: copy; }
.seed:hover { color: var(--muted); }

/* ------------------------------------------------------------ buttons */
.btn {
  --b: var(--panel-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line-2);
  background: var(--b);
  padding: 7px 12px; border-radius: 10px;
  font-weight: 600; font-size: 13px;
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, transform .08s, opacity .15s, box-shadow .15s;
}
.btn svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.btn:hover:not(:disabled) { background: #243146; border-color: #41536f; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.primary:disabled { background: var(--panel-2); color: var(--muted); border-color: var(--line-2); opacity: .55; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.btn.primary { background: linear-gradient(180deg, #f6c445, #e6a41c); color: var(--accent-ink); border-color: #f8d06a; }
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #ffd25c, #eeae27); border-color: #ffe08a; }
.btn.primary.pulse:not(:disabled) { animation: glow 1.8s ease-in-out infinite; }
.btn.danger { background: transparent; border-color: #5a2a36; color: #ff9aae; }
.btn.danger:hover:not(:disabled) { background: #3a1d26; border-color: #7a3446; }
.btn.big { padding: 12px 20px; font-size: 15px; border-radius: 12px; }
.btn.big svg { width: 18px; height: 18px; }
.btn.icon-only { padding: 4px 9px; }
.btn.tool { flex-direction: column; gap: 3px; padding: 7px 10px 6px; min-width: 76px; font-size: 12px; }
.btn.tool svg { width: 20px; height: 20px; }
.btn.tool .cost { display: flex; gap: 1px; min-height: 13px; }
.btn.tool .cost svg { width: 13px; height: 13px; }
.btn.tool .cost svg.miss { fill: none; stroke: var(--faint); stroke-width: 1.6; opacity: .75; }
.btn.tool:disabled { opacity: 1; background: transparent; border-color: var(--line); color: var(--faint); }
.btn.tool:disabled > svg { opacity: .55; }
.btn.tool[aria-pressed="true"] { background: #2b3a52; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px rgb(240 180 41 / .18), 0 0 22px rgb(240 180 41 / .35); } }

/* ------------------------------------------------------------ status pill */
.pill {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 16px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  font-weight: 600; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pill .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc, var(--muted)); flex: none; box-shadow: 0 0 10px var(--pc); }
.pill.mine { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(240 180 41 / .12); }
.spinner { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--pc, var(--accent)); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { rotate: 360deg; } }

/* ------------------------------------------------------------ players */
.players { display: flex; flex-direction: column; gap: 10px; }
.player {
  --pc: var(--muted);
  position: relative;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px 10px 16px;
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s, translate .2s;
}
.player::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--pc); }
.player.active { border-color: color-mix(in srgb, var(--pc) 70%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--pc) 45%, transparent), 0 8px 26px color-mix(in srgb, var(--pc) 18%, transparent); }
.player.me { background: linear-gradient(180deg, #1b2537, var(--bg-2)); }
.p-head { display: flex; align-items: center; gap: 8px; }
.p-name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-tag { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 5px; text-transform: uppercase; letter-spacing: .05em; }
.p-fame { margin-left: auto; display: flex; align-items: baseline; gap: 3px; font-variant-numeric: tabular-nums; }
.p-fame b { font-size: 24px; line-height: 1; }
.p-fame small { color: var(--muted); font-size: 11px; }
.p-fame .hid { color: var(--accent); font-size: 12px; font-weight: 700; }
.p-stats { display: flex; gap: 12px; margin-top: 8px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.p-stats span { display: inline-flex; align-items: center; gap: 4px; }
.p-stats svg { width: 15px; height: 15px; fill: currentColor; }
.p-stats .warn { color: var(--worst); font-weight: 700; }
.p-badges { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: rgb(240 180 41 / .14); color: var(--accent); border: 1px solid rgb(240 180 41 / .35); }
.badge svg { width: 12px; height: 12px; fill: currentColor; }
.p-think { position: absolute; right: 10px; bottom: 10px; display: none; }
.player.thinking .p-think { display: block; }
.player.awaited { border-color: color-mix(in srgb, var(--pc) 80%, transparent); animation: due 1.8s ease-in-out infinite; }
.player.awaited .p-tag { display: inline-flex; align-items: center; gap: 5px; flex: none; color: var(--text); border-color: var(--pc); background: color-mix(in srgb, var(--pc) 22%, transparent); font-weight: 800; }
.player.awaited .p-think { display: none; } /* shown only in the phone strip, which has no tags */
.p-due { display: block; width: 7px; height: 7px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 8px var(--pc); animation: due-dot 1.2s ease-in-out infinite; }
@keyframes due { 50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc) 30%, transparent), 0 0 24px color-mix(in srgb, var(--pc) 28%, transparent); } }
@keyframes due-dot { 50% { opacity: .35; scale: .75; } }
@media (prefers-reduced-motion: reduce) { .player.awaited, .p-due { animation: none; } }
.delta { position: absolute; right: 54px; top: 8px; font-weight: 800; font-size: 13px; color: var(--good); pointer-events: none; animation: rise 1.4s ease-out forwards; }
.delta.neg { color: var(--worst); }
@keyframes rise { from { opacity: 0; translate: 0 6px; } 15% { opacity: 1; translate: 0 0; } to { opacity: 0; translate: 0 -16px; } }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { translate: -4px 0; } 40%, 80% { translate: 4px 0; } }

.bank-row { display: flex; justify-content: space-between; gap: 2px; }
.bank-row .bk { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.bank-row .bk.low { color: var(--bad); }
.bank-row .bk.out { color: var(--worst); }
.bank-row svg { width: 15px; height: 15px; flex: none; }
.bank-row .bk-deck svg { fill: #9c88e0; }
h2 .h-sub { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--faint); margin-left: 6px; font-size: 11.5px; }

/* income panel */
.econ { display: flex; flex-direction: column; }
.ec-row { display: grid; grid-template-columns: 18px minmax(30px, 1fr) 22px auto 30px; align-items: center; gap: 7px; padding: 3px 0; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ec-row svg { width: 16px; height: 16px; }
.ec-row.none svg { opacity: .45; }
.ec-bar { height: 7px; border-radius: 4px; background: var(--panel-2); display: flex; overflow: hidden; }
.ec-bar i { display: block; height: 100%; }
.ec-bar i.bl { background: repeating-linear-gradient(135deg, #59647a 0 3px, transparent 3px 6px); }
.ec-n { text-align: right; font-weight: 700; }
.ec-row.none .ec-n { color: var(--faint); font-weight: 500; }
.ec-nums { display: flex; gap: 3px; min-width: 0; font-size: 11.5px; }
.ec-num { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 3px; border-radius: 6px; background: #e9e4d6; color: #2a2f38; font-weight: 700; font-size: 11px; }
.ec-num.hot { color: #8a3a14; font-weight: 800; }
.ec-num sup { font-size: 8px; margin-left: 1px; }
.ec-ratio { text-align: right; color: var(--faint); font-size: 11.5px; }
.ec-ratio.dock { color: var(--accent); font-weight: 700; }

/* fame race: ten segments toward the win */
.p-race { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; margin-top: 7px; }
.p-race i { height: 4px; border-radius: 2px; background: var(--line-2); }
.p-race i.on { background: var(--pc); }

.card-delta { position: absolute; left: 0; right: 0; top: 4px; text-align: center; font-size: 17px; color: #fff; text-shadow: 0 1px 4px rgb(0 0 0 / .8); z-index: 2; }
.card-delta.neg { color: #ffd0d8; }

/* "while you waited" recap over the board */
.recap { position: absolute; left: 12px; top: 12px; max-width: min(250px, 70%); padding: 10px 12px; border-radius: 12px; background: rgb(17 24 35 / .94); border: 1px solid var(--line-2); box-shadow: 0 12px 30px rgb(0 0 0 / .45); font-size: 12.5px; display: flex; flex-direction: column; gap: 5px; opacity: 0; translate: 0 -6px; pointer-events: none; transition: opacity .25s, translate .25s; }
.recap.show { opacity: 1; translate: 0 0; pointer-events: auto; }
.rc-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.rc-head .t-x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 2px; }
.rc-mine { display: flex; gap: 6px; flex-wrap: wrap; }
.rc-chip { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; color: var(--good); font-variant-numeric: tabular-nums; }
.rc-chip.neg { color: var(--worst); }
.rc-chip svg { width: 16px; height: 16px; }
.rc-line { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.rc-line b { color: var(--text); }
.rc-line .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.rc-line.warn { color: var(--worst); font-weight: 600; }

/* hover card for spots */
.tt-line { display: flex; align-items: center; gap: 5px; }
.tt-line svg { width: 14px; height: 14px; }
.tt-pips { color: var(--accent); letter-spacing: -1px; }

/* resource colouring */
.r-timber { --rc: var(--timber); }
.r-clay { --rc: var(--clay); }
.r-wool { --rc: var(--wool); }
.r-grain { --rc: var(--grain); }
.r-stone { --rc: var(--stone); }
svg.ri { fill: var(--rc); }

/* ------------------------------------------------------------ board */
/* absolutely fill the grid cell: the SVG then scales its viewBox to fit (meet) instead of
   sizing the cell from its own aspect ratio and overflowing on wide/short windows */
.board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: manipulation; user-select: none; }
/* tiles: the landscape is drawn in js/art.js; here only how it is lit */
.hex-tile .scene, .hex-tile .rim, .hex-tile .edge, .hex-tile .flash { pointer-events: none; }
.hex-tile .flash { fill: #fff8d0; opacity: 0; }
.hex-tile.produce .flash { animation: produce 1.3s ease-out; }
@keyframes produce { 0% { opacity: 0; } 22% { opacity: .5; } 100% { opacity: 0; } }
.tile-shade { fill: #2b1d08; opacity: .38; pointer-events: none; }
.tile-shade polygon { stroke: #2b1d08; stroke-width: 3; stroke-linejoin: round; }

.tokens { pointer-events: none; }
.token .t-shadow { fill: #05080d; opacity: .28; }
/* quiet markers: flat paper, ink numbers, nothing that glows. The busy numbers are simply heavier and warmer. */
.token .disc { fill: #e9e4d6; stroke: #4a4a44; stroke-width: 1; stroke-linejoin: round; }
.token text { font: 700 16.5px var(--font); text-anchor: middle; dominant-baseline: central; fill: #2a2f38; }
.token .pip { fill: #2a2f38; opacity: .2; }
.token .pip.on { opacity: .9; }
.token.hot text { fill: #8a3a14; font-weight: 800; font-size: 18px; }
.token.hot .pip.on { fill: #8a3a14; opacity: 1; }
.token.blocked { opacity: .45; }
.token.produce .disc { animation: tokenpop 1.1s ease-out; }
@keyframes tokenpop { 30% { stroke: var(--accent); stroke-width: 4.5; } }

/* the coast, from open water in to dry sand; each band is one merged outline */
.coast { pointer-events: none; }
.coast polygon { stroke-linejoin: round; }
.coast .shelf { opacity: .22; } .coast .shelf polygon { fill: #37a5d6; stroke: #37a5d6; stroke-width: 18; }
.coast .shallow { opacity: .5; } .coast .shallow polygon { fill: #45bfd9; stroke: #45bfd9; stroke-width: 10; }
.coast .foam { opacity: .78; } .coast .foam polygon { fill: #f4fbff; stroke: #f4fbff; stroke-width: 6; }
.coast .beach polygon { fill: #e6d19b; stroke: #e6d19b; stroke-width: 5; }
.coast .sand { opacity: .55; } .coast .sand polygon { fill: #c9ad6f; stroke: #c9ad6f; stroke-width: 3; }

.docks { pointer-events: none; }
.dock-badge { pointer-events: auto; }
.jetty-shadow { stroke: #06223a; stroke-width: 7; stroke-linecap: round; opacity: .35; }
.jetty { stroke: #6f4a26; stroke-width: 7; stroke-linecap: butt; }
.jetty-planks { stroke: #c79a62; stroke-width: 4.6; stroke-dasharray: 3.4 1.5; }
.dock-badge .pb-shadow { fill: #06223a; opacity: .4; }
.dock-badge .pb-wood { fill: url(#g-wood-ring); stroke: #3f2812; stroke-width: 1.3; }
.dock-badge .pb-face { fill: #e9e4d6; stroke: #4a4a44; stroke-width: .8; }
.dock-badge text { text-anchor: middle; fill: #2a2f38; }
.dock-badge .rate { font: 800 9.5px var(--font); }
.dock-badge .rate.big { font: 800 12.5px var(--font); }
.dock-badge .any { font: 700 6.5px var(--font); letter-spacing: .08em; text-transform: uppercase; fill: #6b6a60; }

/* pieces: painted timber in the owner's colour, darker on the sides away from the light */
.trail line { stroke-linecap: round; }
.trail .r-shadow { stroke: #000; stroke-width: 11; opacity: .28; }
.trail .under { stroke: #14100a; stroke-width: 11.5; }
.trail .top { stroke: var(--pc); stroke-width: 8.2; }
.trail .low { stroke: color-mix(in srgb, var(--pc) 62%, #000); stroke-width: 2.6; stroke-linecap: butt; }
.trail .shine { stroke: color-mix(in srgb, var(--pc) 45%, #fff); stroke-width: 1.6; stroke-linecap: butt; opacity: .9; }
.piece { pointer-events: none; }
.piece .p-shadow { fill: #000; opacity: .4; }
.piece .p-face { fill: var(--pc); }
.piece .p-dark { fill: color-mix(in srgb, var(--pc) 62%, #000); }
.piece .p-roof { fill: color-mix(in srgb, var(--pc) 72%, #fff); }
.piece .p-line { fill: none; stroke: #14100a; stroke-width: 1.7; stroke-linejoin: round; }
.piece .p-edge { fill: none; stroke: #14100a; stroke-width: .9; stroke-linejoin: round; opacity: .7; }
.piece .p-door { fill: color-mix(in srgb, var(--pc) 35%, #000); }
.piece .p-win { fill: #ffe9a3; stroke: #14100a; stroke-width: .6; }
.piece .p-shine { fill: none; stroke: #fff; stroke-width: 1.3; stroke-linecap: round; opacity: .55; }
.pop { transform-box: fill-box; transform-origin: 50% 100%; animation: pop .5s var(--spring, cubic-bezier(.2, 1.6, .4, 1)); }
@keyframes pop { from { scale: 0; opacity: 0; } to { scale: 1; opacity: 1; } }
.trail.pop { transform-box: view-box; animation: draw .45s ease-out; }
@keyframes draw { from { opacity: 0; } to { opacity: 1; } }

.bandit { transition: transform .55s cubic-bezier(.4, 1.4, .5, 1); pointer-events: none; }
.bandit .eye { fill: #e9e4d6; }

/* interactive targets */
.v-target, .e-target, .hex-target { cursor: pointer; }
.v-target circle.ring { fill: rgb(255 255 255 / .16); stroke: #fff; stroke-width: 2.4; animation: breathe 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.v-target:hover circle.ring { fill: var(--accent); stroke: #fff; animation: none; scale: 1.25; }
.v-target circle.ring.scored { fill: rgb(240 180 41 / calc(.25 + var(--heat) * .7)); stroke: #fff; stroke-width: 1.8; animation: none; }
.v-target .v-pips { font-size: 13px; font-weight: 800; text-anchor: middle; fill: #10151d; pointer-events: none; }
.v-target:hover circle.ring.scored { fill: var(--accent); scale: 1.15; }
.v-target circle.hit, .e-target line.hit { fill: transparent; stroke: transparent; }
.e-target line.bed { stroke: #0b0f15; stroke-width: 12.5; stroke-linecap: round; opacity: .6; }
.e-target line.bed { transition: opacity .15s; }
.e-target line.vis { stroke: #fff; stroke-width: 7.5; stroke-linecap: round; opacity: .88; transition: stroke .12s, stroke-width .12s; }
.e-target:hover line.vis, .e-target:focus-visible line.vis { stroke: var(--accent); stroke-width: 10; opacity: 1; }
.e-target:hover line.bed { opacity: .7; }
.e-target line.hit { stroke-width: 22; stroke-linecap: round; }
.hex-target { fill: transparent; stroke: rgb(255 255 255 / .38); stroke-width: 2.5; stroke-dasharray: 6 6; transition: fill .15s, stroke .15s; }
.hex-target:hover { fill: rgb(20 10 10 / .35); stroke: #ff6b6b; stroke-width: 4; stroke-dasharray: none; }
.glow-mark { fill: none; stroke: var(--accent); stroke-width: 4; animation: breathe 1.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; pointer-events: none; }
@keyframes breathe { 50% { scale: 1.18; opacity: .7; } }
@keyframes march { to { stroke-dashoffset: -22; } }

/* dice */
.dice { position: absolute; right: 12px; bottom: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.dice .d-row { display: flex; gap: 8px; align-items: center; }
.die {
  width: 42px; height: 42px; border-radius: 10px;
  background: radial-gradient(circle at 30% 25%, #fff 0%, #f6f0df 45%, #d9cfb4 100%);
  box-shadow: 0 7px 16px rgb(0 0 0 / .5), inset 0 -4px 3px rgb(0 0 0 / .16), inset 0 2px 2px #fff, inset 0 0 0 1px rgb(0 0 0 / .08);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 6px; gap: 1px;
}
.die i { width: 8px; height: 8px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #4a4032, #17130d); box-shadow: inset 0 1px 1.5px rgb(0 0 0 / .7), 0 1px 0 rgb(255 255 255 / .7); place-self: center; visibility: hidden; }
.die i.on { visibility: visible; }
.die.red { background: radial-gradient(circle at 30% 25%, #ff8a7a 0%, #d83a32 45%, #a01e1e 100%); box-shadow: 0 7px 16px rgb(0 0 0 / .5), inset 0 -4px 3px rgb(0 0 0 / .25), inset 0 2px 2px rgb(255 255 255 / .55); }
.die.red i { background: radial-gradient(circle at 40% 35%, #fff, #e9dcc4); box-shadow: inset 0 1px 1.5px rgb(0 0 0 / .35); }
.dice .total { font-weight: 800; font-size: 24px; min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; text-shadow: 0 2px 6px rgb(0 0 0 / .6); }
.dice .total.seven { color: var(--worst); }
.dice.rolling .die { animation: tumble .55s cubic-bezier(.3, .7, .4, 1); }
.dice.rolling .die:nth-child(2) { animation-duration: .65s; }
@keyframes tumble { 0% { rotate: -200deg; translate: -40px -30px; scale: .7; } 70% { rotate: 12deg; translate: 0 0; scale: 1.05; } 100% { rotate: 0deg; scale: 1; } }

.tip {
  position: fixed; z-index: 40; pointer-events: none; opacity: 0;
  background: #0b0f15; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 6px 9px; font-size: 12.5px; max-width: 280px; box-shadow: var(--shadow);
  transition: opacity .12s;
}
.tip.show { opacity: 1; }

.victims { margin: 0; inset: auto; padding: 6px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow); color: var(--text); }
.victims h3 { padding: 4px 8px 2px; }
.victims button { display: flex; width: 100%; gap: 8px; align-items: center; justify-content: flex-start; }
.victims .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); }

/* ------------------------------------------------------------ right panel */
.coach { display: flex; flex-direction: column; min-height: 0; flex: 0 1 auto; max-height: 58%; }
.coach-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.coach-head h2 { margin: 0 auto 0 0; }
.switch { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; }
.switch input { accent-color: var(--accent); margin: 0; }
.switch select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 4px; font: inherit; }
.log-opts { margin: -4px 0 8px; }
.coach-actions { display: flex; align-items: center; gap: 4px 6px; margin: 10px 0 6px; flex-wrap: wrap; }
.left, .right, .coach, .log-card, .tray, .actions { min-width: 0; }
.reviewing { font-size: 12px; color: var(--muted); margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.reviewing::before { content: ""; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.coach-out { overflow: auto; scrollbar-width: thin; flex: 0 0 auto; max-height: 60%; }
.coach-out:empty { display: none; }
.opts { list-style: none; margin: 4px 0 6px; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.opt { display: grid; grid-template-columns: 50px 1fr auto; gap: 8px; align-items: start; padding: 7px 8px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; cursor: default; transition: border-color .15s; }
.opt:hover { border-color: var(--accent); }
.opt .loss { font: 700 11px var(--mono); padding: 2px 0; border-radius: 6px; text-align: center; }
.opt .loss.best { background: rgb(62 207 142 / .15); color: var(--good); }
.opt .loss.near { background: rgb(245 197 66 / .14); color: var(--warn); }
.opt .loss.far { background: rgb(240 138 60 / .15); color: var(--bad); }
.opt .do { padding: 2px 8px; font-size: 11px; }
.opt .do > .kb { position: static; margin-left: 5px; }
.coach-note { font-size: 12px; color: var(--muted); margin: 4px 0; }
.evals { display: flex; flex-direction: column; gap: 7px; margin: 6px 0; }
.ev-row { display: grid; grid-template-columns: 64px 1fr 40px; gap: 8px; align-items: center; font-size: 12.5px; }
.ev-row .bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.ev-row .bar i { display: block; height: 100%; background: var(--pc); border-radius: 99px; }
.ev-row .pips { grid-column: 2 / 4; display: flex; gap: 8px; color: var(--muted); font: 11px var(--mono); margin-top: -3px; }
.ev-row .pips span { display: inline-flex; align-items: center; gap: 2px; }
.ev-row .pips svg { width: 11px; height: 11px; }
.accuracy { font-size: 12px; color: var(--muted); margin-top: 6px; }
.accuracy:empty { display: none; }
.accuracy b { color: var(--text); }
.reviews { flex: 1 1 auto; list-style: none; margin: 6px 0 0; padding: 0; overflow: auto; scrollbar-width: thin; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.rev { font-size: 12.5px; display: grid; grid-template-columns: 22px 1fr auto; gap: 2px 6px; padding: 5px 4px; border-top: 1px solid var(--line); align-items: baseline; }
.rev .vd { text-align: center; }
.rev-move { min-width: 0; }
.rev .loss-n { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.rev.v-mistake .loss-n, .rev.v-blunder .loss-n { color: var(--worst); }
.rev.v-inaccuracy .loss-n { color: var(--warn); }
.rev .best-line { grid-column: 2 / -1; color: var(--muted); font-size: 12px; }
/* a hint or evaluation takes the panel; the review list is one click away in "All moves" */
.coach:has(.coach-out:not(:empty)) :is(.reviews, .accuracy) { display: none; }
.coach:has(.coach-out:not(:empty)) { max-height: 66%; }
.coach:has(.coach-out:not(:empty)) .coach-out { max-height: none; flex: 1 1 auto; }
.vd { font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.vd-forced { color: var(--faint); }
.rev:hover { background: rgb(255 255 255 / .03); }
dialog.wide { width: min(900px, calc(100vw - 32px)); }
.table-scroll { max-height: min(60dvh, 560px); overflow: auto; scrollbar-width: thin; margin-top: 8px; }
.review-table td { vertical-align: top; }
.review-table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.review-table tr.forced td { opacity: .55; }
.review-table thead th { position: sticky; top: 0; background: #172030; }
.ripple { fill: none; stroke: var(--pc); stroke-width: 3; animation: ripple 1.2s ease-out forwards; transform-box: fill-box; transform-origin: center; pointer-events: none; }
@keyframes ripple { from { scale: .6; opacity: 1; } to { scale: 3.2; opacity: 0; } }
.vd-best { color: var(--good); }
.vd-good { color: var(--ok); }
.vd-inaccuracy { color: var(--warn); }
.vd-mistake { color: var(--bad); }
.vd-blunder { color: var(--worst); }

.log-card { flex: 1 1 0; min-height: 140px; display: flex; flex-direction: column; }
.log { list-style: none; margin: 0; padding: 2px 2px 0 0; overflow: auto; scrollbar-width: thin; flex: 1; font-size: 12.5px; display: flex; flex-direction: column; gap: 2px; }
.log li { display: grid; grid-template-columns: 16px 1fr; gap: 6px; padding: 2px 0; animation: fadein .3s ease-out; }
.log .ic { color: var(--pc, var(--faint)); font-weight: 800; text-align: center; }
.log .why { grid-column: 2; color: var(--faint); font-style: italic; font-size: 11.5px; }
.log.no-why .why { display: none; }
.log li.k-turn { display: block; margin-top: 8px; padding: 3px 8px; border-radius: 6px; background: color-mix(in srgb, var(--pc) 14%, transparent); color: var(--pc); font-weight: 700; font-size: 12px; }
.log li.k-private { color: #e59cf2; font-style: italic; }
.log li.k-win { color: var(--accent); font-weight: 800; }
.log li.k-award { color: var(--accent); }
@keyframes fadein { from { opacity: 0; translate: 0 4px; } }

/* ------------------------------------------------------------ tray */
.tray {
  display: grid; grid-template-columns: auto auto 1fr; align-items: end; gap: 18px;
  background: linear-gradient(180deg, #172131, #111823);
  border: 1px solid var(--line); border-radius: 18px; padding: 10px 14px;
  box-shadow: 0 -6px 30px rgb(0 0 0 / .25);
}
.hand { position: relative; display: flex; gap: 8px; }
.rcard {
  position: relative; width: 56px; height: 72px; border-radius: 10px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--rc, var(--muted)) 100%, #fff 18%), color-mix(in srgb, var(--rc, var(--muted)) 80%, #000 30%));
  border: 1px solid rgb(255 255 255 / .18);
  box-shadow: 0 4px 12px rgb(0 0 0 / .35), inset 0 1px 0 rgb(255 255 255 / .25);
  display: grid; place-items: center;
  transition: translate .2s, opacity .2s, filter .2s;
}
/* the face: a pale window with the picture, the name on the coloured band under it */
.rcard::before { content: ""; position: absolute; inset: 4px 4px 17px; border-radius: 7px; background: radial-gradient(circle at 50% 30%, #fffdf4, color-mix(in srgb, var(--rc, #888) 26%, #f1e4c4)); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .22), inset 0 2px 5px rgb(0 0 0 / .18); }
.rcard svg { position: relative; width: 38px; height: 38px; margin-top: -13px; filter: drop-shadow(0 1px 1px rgb(0 0 0 / .25)); }
.rcard .n { position: absolute; top: -7px; right: -7px; min-width: 24px; height: 24px; border-radius: 12px; display: grid; place-items: center; background: #0d1117; border: 2px solid var(--rc); font-weight: 800; font-size: 13px; padding: 0 5px; font-variant-numeric: tabular-nums; }
.rcard .lbl { position: absolute; bottom: 3px; font-size: 9.5px; font-weight: 800; color: #fff; text-shadow: 0 1px 1px rgb(0 0 0 / .45); text-transform: uppercase; letter-spacing: .06em; }
.rcard.zero { opacity: .3; filter: saturate(.25); box-shadow: none; }
.rcard.zero .n { border-color: var(--line-2); color: var(--muted); }
.rcard.bump { animation: bump .5s ease-out; }
@keyframes bump { 35% { translate: 0 -10px; } }
.venturehand { display: flex; gap: 6px; min-height: 67px; align-items: center; }
.venturehand:empty::before { content: "None yet: buy one for wool, grain and stone"; color: var(--faint); font-size: 12px; max-width: 150px; line-height: 1.35; }
.venture-wrap { padding-left: 18px; border-left: 1px solid var(--line); }
/* room above the ventures for a playable card to grow into (see "ventures" below) */
.venture-wrap > .tray-cap { margin-bottom: 12px; }
/* captions over the two hands: what it is, how many, and the over-7 warning */
.tray-cap { display: flex; align-items: center; gap: 7px; height: 18px; margin-bottom: 7px; font-size: 11px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.tray-cap b { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.cap-warn { text-transform: none; letter-spacing: 0; font-size: 11px; font-weight: 700; color: #ffb3c1; background: #3a1d26; border: 1px solid #7a3446; border-radius: 999px; padding: 0 8px; line-height: 16px; }
.dcard {
  position: relative; width: 56px; height: 64px; border-radius: 9px; padding: 0;
  background: linear-gradient(160deg, #5b4a8c, #2f2552); border: 1px solid #7b68b8;
  display: grid; place-items: center; cursor: default;
  box-shadow: 0 4px 10px rgb(0 0 0 / .3);
  transition: translate .15s, box-shadow .15s;
}
.dcard::before { content: ""; position: absolute; inset: 4px 4px 16px; border-radius: 6px; background: radial-gradient(circle at 50% 30%, #4b3c7c, #1d1638); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .16), inset 0 2px 6px rgb(0 0 0 / .4); }
.dcard.landmark::before { background: radial-gradient(circle at 50% 30%, #7a5c16, #2b1f07); }
.dcard svg { position: relative; width: 33px; height: 33px; margin-top: -12px; filter: drop-shadow(0 1px 1.5px rgb(0 0 0 / .5)); }
.dcard .n { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; border-radius: 10px; background: #0d1117; border: 2px solid #9c88e0; font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.dcard .lbl { position: absolute; bottom: 3px; left: 0; right: 0; text-align: center; white-space: nowrap; font-size: 8px; font-weight: 700; color: #e6dcff; text-transform: uppercase; letter-spacing: .02em; }
.dcard.playable { cursor: pointer; border-color: var(--accent); }
.dcard.new { opacity: .55; }
.dcard.new::after { content: "new"; position: absolute; top: 4px; left: 4px; font-size: 8px; font-weight: 800; text-transform: uppercase; color: var(--accent); }
.dcard.landmark { background: linear-gradient(160deg, #8a6b1c, #4a3810); border-color: #c9a33f; }
.actions { display: flex; align-items: center; gap: 13px; justify-content: flex-end; flex-wrap: wrap; }
.build { display: flex; gap: 9px; }

/* ------------------------------------------------------------ dialogs */
dialog {
  background: linear-gradient(180deg, #1a2433, #131b27);
  color: var(--text);
  border: 1px solid var(--line-2); border-radius: 18px;
  padding: 20px 22px; width: min(520px, calc(100vw - 32px));
  box-shadow: 0 30px 80px rgb(0 0 0 / .6);
}
dialog:modal { overscroll-behavior: contain; max-height: calc(100dvh - 40px); }
dialog::backdrop { background: rgb(4 7 12 / .62); backdrop-filter: blur(3px); overflow: hidden; overscroll-behavior: contain; }
dialog h2 { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0 0 6px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.dlg-head form { margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.dlg-actions form { margin: 0 auto 0 0; }
@media (prefers-reduced-motion: no-preference) {
  dialog, dialog::backdrop, .toasts .toast {
    transition: opacity .2s ease-out, translate .22s cubic-bezier(.2, .9, .3, 1), overlay .22s allow-discrete, display .22s allow-discrete;
  }
  dialog { opacity: 0; translate: 0 14px; }
  dialog[open] { opacity: 1; translate: 0 0; }
  dialog::backdrop { opacity: 0; }
  dialog[open]::backdrop { opacity: 1; }
  @starting-style {
    dialog[open] { opacity: 0; translate: 0 14px; }
    dialog[open]::backdrop { opacity: 0; }
  }
}

fieldset.seg { border: 0; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
fieldset.seg legend { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; padding: 0; }
.seg label { position: relative; padding: 7px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; font-weight: 600; font-size: 13px; transition: background-color .15s, border-color .15s; }
.seg label:has(input:checked) { background: rgb(240 180 41 / .14); border-color: var(--accent); color: var(--accent); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.field input { font: inherit; font-size: 14px; color: var(--text); background: #0e141d; border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 11px; }
.field input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.field input:user-invalid { border-color: var(--worst); }
.field input[readonly] { color: var(--muted); background: transparent; border-style: dashed; cursor: default; }
.acct-as { margin-right: auto; align-self: center; font-size: 13px; }
.acct-new { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-2); }

.steppers { display: flex; flex-direction: column; gap: 6px; }
.stepper { display: grid; grid-template-columns: 28px 1fr auto 34px 30px 34px; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.stepper svg { width: 22px; height: 22px; }
.stepper .name { font-weight: 600; text-transform: capitalize; }
.stepper .have { font-size: 12px; color: var(--muted); }
.stepper .val { text-align: center; font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; }
.stepper .btn { padding: 4px 0; }

/* bank trade: a fixed grid, one column per resource you can get; your card counts inline */
.bank-trade { display: flex; flex-direction: column; gap: 6px; }
.bt-row { display: grid; grid-template-columns: 124px repeat(5, minmax(0, 1fr)); align-items: center; gap: 5px; padding: 5px 8px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.bt-row.off { opacity: .6; }
.bt-row.off .res-btn:disabled { opacity: .5; }
.bt-head { background: none; border-color: transparent; padding-block: 0; font-size: 11px; font-weight: 600; color: var(--muted); text-align: center; }
.bt-head span:first-child { text-align: left; }
.bt-head .bt-get { grid-column: 2 / -1; }
.bt-give { display: grid; grid-template-columns: 22px auto 1fr; grid-template-rows: auto auto; column-gap: 6px; align-items: center; font-weight: 700; font-size: 14px; }
.bt-give svg { width: 22px; height: 22px; grid-row: 1 / 3; }
.bt-have { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; grid-row: 1 / 3; }
.bt-rate { font-size: 12px; font-weight: 700; color: var(--muted); }
.bt-rate.dock { color: var(--accent); }
.bt-need { grid-column: 3; font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.bt-self { text-align: center; color: var(--faint); }
.res-btn svg { width: 20px; height: 20px; }
.bt-row .res-btn { width: 100%; flex-direction: column; justify-content: center; gap: 1px; padding: 4px 2px 3px; min-width: 0; }
.res-btn .bt-cnt { font-size: 11px; line-height: 1; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.trade-hand { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 8px 0 2px; padding: 8px 12px; border-radius: 12px; background: #0e141d; border: 1px solid var(--line); }
.trade-hand .th-label { font-size: 12px; color: var(--muted); font-weight: 600; margin-right: 2px; }
.trade-hand .th-res { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.trade-hand .th-res svg { width: 20px; height: 20px; }
.trade-hand .th-res b { font-size: 15px; }
.trade-hand .th-res.zero { opacity: .35; }
/* what changes: the new count, then a small +n / −n */
.trade-hand .th-d { font-size: 11px; font-weight: 700; margin-left: -2px; }
.trade-hand .th-res.up .th-d { color: var(--good); }
.trade-hand .th-res.down .th-d { color: var(--worst); }
.trade-hand .th-total { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
dialog:not(.trade) .trade-hand { margin-top: 14px; }
.replies { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; height: 152px; overflow: auto; align-content: start; }
.reply { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.reply .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); }
.reply .ans { margin-left: auto; font-weight: 700; }
.reply .ans.yes { color: var(--good); }
.reply .ans.no { color: var(--worst); }

dialog.botoffer { width: min(480px, calc(100vw - 32px)); }
.botoffer .trade-hand { gap: 10px; }
.botoffer h2 { display: flex; align-items: center; gap: 9px; }
.botoffer h2 .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.bo-cards { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; margin-top: 14px; }
.bo-side { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 8px 12px; border-radius: 12px; background: #0e141d; border: 1px solid var(--line); }
.bo-side h3 { margin: 0; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.bo-side .mini-cards { justify-content: center; }
.bo-arrow { align-self: center; font-size: 22px; color: var(--muted); }
/* the coach's verdict: one line, coloured edge; Space presses the matching button */
.bo-coach { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-height: 1.4em; margin: 12px 0 0; padding: 8px 12px; border-radius: 10px; border-left: 3px solid var(--line-2); background: #0e141d; font-size: 13.5px; }
.bo-coach .tag { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.bo-coach.yes { border-left-color: var(--good); }
.bo-coach.yes b { color: var(--good); }
.bo-coach.no { border-left-color: var(--worst); }
.bo-coach.no b { color: var(--worst); }
.bo-actions { flex-wrap: nowrap; }
.bo-actions .dlg-undo { margin-right: auto; }
.dlg-head .dlg-undo { margin-left: auto; }
.mini-cards { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-cards .rcard { width: 42px; height: 56px; }
.mini-cards .rcard::before { inset: 3px; }
.mini-cards .rcard svg { width: 30px; height: 30px; margin-top: 0; }
.mini-cards .rcard .n { width: 20px; min-width: 20px; height: 20px; font-size: 11px; }

.pick-res { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
.pick-res button { position: relative; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 10px; }
.pick-res button .rcard { transition: translate .15s, box-shadow .15s; }
.pick-res button:hover .rcard { translate: 0 -4px; }
.pick-res button[aria-pressed="true"] .rcard { box-shadow: 0 0 0 3px var(--accent), 0 10px 20px rgb(0 0 0 / .4); translate: 0 -6px; }
.pick-res button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.info-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.info-table th, .info-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line); }
.info-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.hist { display: grid; grid-template-columns: repeat(11, 1fr); gap: 6px; align-items: end; height: 170px; margin-top: 14px; }
.hist .col { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; font-size: 11px; color: var(--muted); }
.hist .bars { position: relative; width: 100%; flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.hist .bar { width: 70%; background: #4d8ef0; border-radius: 4px 4px 0 0; min-height: 1px; }
.hist .bar.seven { background: var(--worst); }
.hist .exp { position: absolute; left: 6%; right: 6%; border-top: 2px dashed rgb(255 255 255 / .45); }
.hist .num { font-weight: 700; color: var(--text); }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
kbd { font: 700 11.5px var(--mono); background: #0e141d; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; color: var(--text); }
.help p { color: var(--muted); font-size: 13px; }

.over-banner { font-size: 26px; font-weight: 900; margin: 4px 0 10px; }
.over-banner.win { color: var(--accent); text-shadow: 0 0 30px rgb(240 180 41 / .4); }
.vcounts { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0 4px; font-size: 13px; }
.misses { list-style: none; padding: 0; margin: 8px 0 0; font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; }
.misses li { padding: 6px 8px; border-radius: 8px; background: var(--panel-2); }
.misses .eng { color: var(--muted); }

/* ------------------------------------------------------------ toasts */
.toasts {
  inset: auto auto 130px 14px; margin: 0; padding: 0; border: 0; background: none; overflow: visible;
  display: flex; flex-direction: column-reverse; gap: 8px; align-items: stretch; width: min(360px, calc(100vw - 28px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; width: 100%;
  background: #121a26; border: 1px solid var(--line-2); border-left: 4px solid var(--tc, var(--accent));
  border-radius: 12px; padding: 8px 10px; box-shadow: var(--shadow); font-size: 12.5px;
  animation: toastin .28s cubic-bezier(.2, .9, .3, 1);
}
.toast .t-body { flex: 1; min-width: 0; }
.toast .t-title { font-weight: 800; }
.toast .t-sub { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: pre-line; }
.toast .t-x { background: none; border: 0; color: var(--faint); cursor: pointer; padding: 0 2px; font-size: 14px; }
.toast.out { animation: toastout .25s ease-in forwards; }
@keyframes toastin { from { opacity: 0; translate: 0 -12px; scale: .97; } }
@keyframes toastout { to { opacity: 0; translate: 0 -8px; } }

/* ------------------------------------------------------------ responsive */
@media (min-width: 1800px) {
  body { font-size: 15px; }
  .app { grid-template-columns: 320px minmax(0, 1fr) 400px; gap: 16px; padding: 16px 20px 18px; }
  .log, .rev, .opt { font-size: 13.5px; }
  h2 { font-size: 13px; }
  .rcard { width: 66px; height: 88px; }
}
@media (max-width: 1280px) {
  .app { grid-template-columns: 236px minmax(0, 1fr) 300px; }
  .brand-sub { display: none; }
  .btn.tool { min-width: 64px; }
}
@media (min-width: 900px) and (max-width: 1180px) {
  .app {
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "top top" "board left" "board right" "tray tray";
  }
  .left { max-height: 46dvh; }
  .bank { display: none; }
  .player { padding: 8px 10px 8px 14px; }
  .p-stats { margin-top: 4px; }
  .top-actions .btn span { display: none; }
  .toasts { inset: auto 14px 130px auto; }
  .rcard { width: 50px; height: 66px; }
  .btn.tool { min-width: 58px; padding: 6px 7px; }
  .btn.tool span { font-size: 11px; }
  .btn.big { padding: 10px 14px; }
}
@media (max-width: 899px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; grid-template-columns: 1fr; grid-template-rows: auto; grid-template-areas: "top" "board" "tray" "left" "right"; }
  .board-wrap { height: min(92vw, calc(100dvh - 250px)); min-height: 300px; }
  .left { overflow: visible; }
  .players { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
  .right { min-height: 0; }
  .coach { max-height: none; }
  .log-card { max-height: 420px; }
  .tray { grid-template-columns: 1fr; gap: 10px; padding: 10px; }
  .toasts { inset: 64px auto auto 50%; translate: -50% 0; }
  .venture-wrap { border-left: 0; padding-left: 0; }
  .venturehand { min-height: 0; }
  .venture-wrap:has(.venturehand:empty) { display: none; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .actions .build { grid-column: 1 / -1; grid-row: 1; display: grid; grid-template-columns: repeat(5, 1fr); }
  .actions .btn.big { width: 100%; }
  .top-actions .btn span { display: none; }
  .topbar { flex-wrap: wrap; }
  .status { order: 3; flex-basis: 100%; }
}
@media (min-width: 700px) and (max-width: 899px) {
  .tray { grid-template-columns: auto 1fr; }
  .venture-wrap, .venture-wrap:has(.venturehand:empty) { display: block; border-left: 1px solid var(--line); padding-left: 12px; }
  .venturehand { min-height: 64px; }
  .actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; }
  .actions .build { display: flex; }
  .actions .btn.big { width: auto; }
}
@media (max-width: 560px) {
  .tray { position: sticky; bottom: 8px; z-index: 5; }
  .app { padding: 8px 10px; gap: 10px; }
  .hand { gap: 5px; justify-content: space-between; }
  .rcard { width: 17.5vw; max-width: 60px; height: 64px; }
  .btn.tool span { display: none; }
  .btn.tool { min-width: 0; }
  .seed { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.glow-mark.mine { stroke: #ff6b81; stroke-dasharray: 5 4; }

/* ------------------------------------------------------------ one-click building */
.targets.quick .e-target line.vis { stroke-width: 5; }
.targets.quick .e-target line.bed { stroke-width: 9.5; }
.targets.quick .v-target circle.ring { animation: none; fill: rgb(255 255 255 / .12); }
.v-target.k-town circle.ring { fill: none; stroke: var(--accent); stroke-width: 3; stroke-dasharray: 4 4; }
.v-target.k-town:hover circle.ring { fill: rgb(240 180 41 / .25); stroke-dasharray: none; }
.btn.tool.ready:not(:disabled) { border-color: rgb(240 180 41 / .7); box-shadow: 0 0 0 1px rgb(240 180 41 / .35) inset; color: var(--text); }

/* ------------------------------------------------------------ trade dialog */
dialog.trade { width: min(860px, calc(100vw - 32px)); }
.trade-cols { display: grid; grid-template-columns: 1fr 1.15fr; gap: 14px; margin-top: 12px; }
.trade-col { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; }
.trade-col h3 { color: var(--text); font-size: 14px; }
.trade-col h3 .muted { font-weight: 500; font-size: 12px; }
@media (max-width: 480px) {
  .bt-row { grid-template-columns: 96px repeat(5, minmax(0, 1fr)); }
  .bt-need { display: none; }
  .trade-hand { gap: 8px 12px; padding: 8px 10px; }
  .trade-hand .th-label { display: none; }
}
.pick-label { font-size: 12px; font-weight: 600; color: var(--muted); margin: 4px 0 6px; }
.picks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 8px; }
.pick { position: relative; }
.pick-add {
  width: 100%; height: 66px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; position: relative;
  border: 1px solid var(--line-2); background: color-mix(in srgb, var(--rc) 22%, var(--panel-2));
  transition: background-color .12s, border-color .12s, transform .08s;
}
.pick-add svg { width: 26px; height: 26px; fill: var(--rc); margin-bottom: 10px; }
.pick-add:hover:not(:disabled) { border-color: var(--rc); background: color-mix(in srgb, var(--rc) 35%, var(--panel-2)); }
.pick-add:active:not(:disabled) { transform: scale(.96); }
.pick-add:disabled { opacity: .42; cursor: not-allowed; }
.pick.on .pick-add:disabled { opacity: 1; }
.pick.on .pick-add { border-color: var(--rc); box-shadow: 0 0 0 2px color-mix(in srgb, var(--rc) 60%, transparent); }
.pick-add .n { position: absolute; top: 4px; right: 6px; font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; padding: 0 5px; border-radius: 8px; background: var(--rc); color: #0d1117; }
.pick-add .have { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: 11px; font-weight: 600; color: var(--text); opacity: .8; font-variant-numeric: tabular-nums; }
.pick-add .have b { color: var(--accent); }
.trade-count { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.pick-sub { position: absolute; left: 4px; top: 4px; width: 20px; height: 20px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--bg); color: var(--text); cursor: pointer; font-weight: 800; line-height: 1; padding: 0; }
.pick-sub:hover { border-color: var(--worst); color: var(--worst); }
.offer-bar { display: flex; align-items: center; gap: 8px; margin-top: 4px; min-height: 40px; }
.offer-summary { flex: 1; min-width: 0; font-size: 13px; }
.reply .btn { padding: 4px 12px; }
@media (max-width: 700px) {
  .trade-cols { grid-template-columns: 1fr; }
  .replies { height: auto; min-height: 60px; }
}

.co-x { float: right; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0 2px 0 8px; }
.co-x:hover { color: var(--text); }

/* keyboard: a badge on every control that has a key, letter tags on board targets */
/* zero specificity: never overrides a component's own positioning */
:where([data-key]) { position: relative; }
.kb { position: absolute; top: 3px; right: 4px; font: 700 9.5px/1 var(--mono); padding: 2px 3px; border-radius: 3px; color: var(--faint); border: 1px solid transparent; background: rgb(255 255 255 / .05); pointer-events: none; white-space: nowrap; letter-spacing: 0; text-transform: none; }
/* the keys for what you can do right now read a little stronger */
.btn.tool.ready > .kb, .btn.big:not(:disabled) > .kb, .dcard.playable > .kb { color: var(--text); }
.btn.primary > .kb { color: rgb(0 0 0 / .6); border-color: rgb(0 0 0 / .25); background: rgb(255 255 255 / .22); }
.btn.big > .kb { top: 4px; right: 5px; }
:disabled > .kb { opacity: .55; }
/* inline badges where a corner badge would cover text */
.top-actions .kb, .coach-actions .kb, .switch .kb, .seg .kb, .dlg-actions .kb, .offer-bar .kb, .reply .kb, .victims .kb, #over-all .kb, .dlg-head .kb { position: static; margin-left: 6px; }
.btn.icon-only > .kb { margin-left: 4px; }
.stepper .btn > .kb { top: -7px; right: -7px; background: var(--bg); padding: 1px 2px; font-size: 8.5px; }
.pick-add > .kb { top: 5px; left: 5px; right: auto; }
.pick.on .pick-add > .kb { display: none; } /* the − button takes that corner once picked */
.pick-sub > .kb { display: none; } /* listed in help; the tile badge already shows the key */
.dcard > .kb { top: 4px; left: 4px; right: auto; padding: 1px 2px; font-size: 8.5px; color: #f3e9ff; border-color: rgb(255 255 255 / .35); }
.pick-res button > .kb { top: -6px; left: -6px; right: auto; z-index: 1; background: var(--bg); }
.res-btn > .kb { top: 2px; left: 2px; right: auto; padding: 0 2px; font-size: 8px; border: 0; background: none; color: var(--muted); }
.key-tag { pointer-events: none; }
.key-tag rect { fill: #0d1117; stroke: var(--accent); stroke-width: 1.2; opacity: .92; }
.key-tag text { font: 800 10px var(--mono); fill: var(--accent); text-anchor: middle; }
.key-tag.on rect { fill: var(--accent); }
.key-tag.on text { fill: #10151d; }
.key-tag.dim { opacity: .08; }
/* the recommended choice in any scope: ringed green, and Space presses it */
.obvious { box-shadow: 0 0 0 2px var(--good), 0 0 12px rgb(62 207 142 / .35); }
.obvious > .kb { color: var(--good); border-color: var(--good); }
.obvious > .kb::before { content: "␣"; margin-right: 4px; padding-right: 4px; border-right: 1px solid currentColor; }
/* the top-ranked spot: always the first key (A) */
.key-tag.best rect { fill: var(--good); stroke: var(--good); opacity: 1; }
.key-tag.best text { fill: #08130d; }
.victims kbd, .help kbd { font: 700 10.5px var(--mono); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--muted); }

/* while robbing, the key tags replace the hex letters so only one letter shows per hex */

/* dialogs take focus so Enter reaches their ↵ action; no ring on the panel itself */
dialog:focus { outline: none; }
/* status pill key hints */
.pill kbd { font: 700 11px var(--mono); padding: 1px 5px; border-radius: 4px; border: 1px solid currentColor; opacity: .7; margin: 0 2px; }

/* "can pay for" chips in dialogs and the trade summary */
.th-builds { flex-basis: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.th-builds .th-label { margin-right: 4px; }
.bchip { padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: rgb(255 255 255 / .07); border: 1px solid var(--line); }
.bchip.gain { color: #10151d; background: var(--good); border-color: var(--good); }
.bchip.lost { color: var(--worst); text-decoration: line-through; opacity: .8; }
#offer-summary .th-builds { margin-top: 6px; }
.bt-unlock { position: absolute; bottom: 2px; left: 4px; font-style: normal; font-size: 10px; color: var(--good); }

/* bandit targets: who each hex would block */
.hex-target.empty { stroke-opacity: .15; }
.hex-target.hurts { stroke: var(--bad); }
.rb-chip { pointer-events: none; }
.rb-chip circle { stroke: #10151d; stroke-width: 2; }
.rb-chip text { font: 800 10px var(--font); fill: #10151d; text-anchor: middle; }
.rb-chip.me circle { stroke: var(--bad); stroke-width: 2.5; }
.tt-line .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

/* setup spots by quality: great ones stand out, poor ones recede */
.v-target.t-hi circle.ring.scored { stroke-width: 2.6; scale: 1.18; }
.v-target.t-lo { opacity: .55; }
.v-target.t-lo:hover { opacity: 1; }

/* a player close to winning */
.player.threat { box-shadow: 0 0 0 2px var(--bad), 0 0 18px rgb(255 80 80 / .25); }
.badge.near { color: var(--bad); border-color: var(--bad); }

/* ------------------------------------------------------------ playtest round 2 */
/* coach options: the one you picked stays lit on the board */
.opt { cursor: pointer; }
.opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.opt.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel-2)); }

/* dice say whose they are; before your roll they're last turn's and recede */
.dice .d-who { font-size: 12px; font-weight: 600; color: #c5d6ea; white-space: nowrap; text-shadow: 0 1px 3px rgb(0 0 0 / .6); }
.dice.stale .die, .dice.stale .total { opacity: .45; filter: saturate(.4); }

/* player stats: labelled, cards first */
.p-stats { font-size: 12px; margin-top: 7px; }
.p-stats span { display: inline; white-space: nowrap; }
.p-stats b { color: var(--text); font-weight: 700; }
.p-stats .st-cards b { font-size: 14px; }
.p-stats .warn, .p-stats .warn b { color: var(--worst); }

/* ventures you can't play now: dimmed, with the reason */
.dcard.blocked { opacity: .55; }
.dcard.new::after { content: none; }
/* the reason sits on the card's bottom edge, clear of the picture; the close-up spells it out */
.dcard .why-tag { position: absolute; bottom: -9px; left: 50%; translate: -50% 0; z-index: 1; white-space: nowrap; font-size: 8px; font-weight: 800; line-height: 11px; padding: 0 5px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; color: #e9e2ff; background: #0d1117; border: 1px solid #5d4f8e; }

/* hand strips warn past seven cards */
.trade-hand .th-total.over { color: #ffb3c1; font-weight: 700; }

/* offer replies give a reason */
.reply .why { font-size: 12px; font-style: italic; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* bank grid: each cell shows what you'd hold after; rows you can't pay are one line */
.res-btn .bt-cnt { color: var(--text); }
.bt-after { grid-column: 3; font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.bt-row.off { padding-block: 3px; opacity: .7; }
.bt-row.off .bt-need { grid-column: 2 / -1; font-size: 12px; color: var(--faint); white-space: normal; }
.bt-row.off .bt-give svg, .bt-row.off .bt-have { grid-row: auto; }
.bt-row.off .bt-give { grid-template-rows: auto; }

/* hoard: the tracker's estimate under each resource */
.pick-res .haul { display: block; margin-top: 6px; font: 700 12px var(--mono); color: var(--muted); text-align: center; }

/* help: rules first, keys tucked away */
.help-costs { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: center; font-size: 13px; margin-bottom: 8px; }
.help-costs svg { width: 18px; height: 18px; margin-right: 2px; vertical-align: middle; }
.help-keys { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.help-keys summary { cursor: pointer; font-weight: 700; color: var(--text); padding: 4px 0; }

/* game over: where every point came from */
.table-x { overflow-x: auto; }
.fame-table th, .fame-table td.num { text-align: center; }
.fame-table th:first-child { text-align: left; }
.fame-table th { font-size: 11px; line-height: 1.2; }

/* new game */
.seg-note { font-size: 12px; margin: 6px 0 0; }
.nowrap { white-space: nowrap; }

@media (max-width: 899px) {
  .pill { white-space: normal; text-align: left; line-height: 1.35; border-radius: 16px; }
}
/* touch-only devices: no keyboard, so no key badges or board letters */
@media (hover: none) and (pointer: coarse) {
  .kb, .key-tag, .pill kbd { display: none !important; }
}
/* the coach never squeezes below its own controls (it overlapped the log on short windows) */
.coach { flex-shrink: 0; }
@media (min-width: 900px) and (max-width: 1180px) {
  .right { overflow: auto; scrollbar-width: thin; }
  .coach { max-height: none; }
}

/* ------------------------------------------------------------ stage pass */
/* the prompt is the one thing to read each turn: larger, and lit when it's yours */
.pill { padding: 9px 20px; font-size: 15px; background: var(--panel-2); }
.pill.mine { background: linear-gradient(180deg, #2a2412, #1c1a14); box-shadow: 0 0 0 3px rgb(240 180 41 / .14), 0 6px 22px rgb(240 180 41 / .12); }

/* cards collected on a roll travel from the hex that paid to whoever got them */
.fly {
  position: fixed; z-index: 30; width: 26px; height: 34px; border-radius: 6px; pointer-events: none;
  display: grid; place-items: center; will-change: transform, opacity;
  background: linear-gradient(160deg, color-mix(in srgb, var(--rc) 100%, #fff 18%), color-mix(in srgb, var(--rc) 80%, #000 30%));
  border: 1.5px solid var(--pc, #fff); box-shadow: 0 6px 14px rgb(0 0 0 / .45);
}
.fly svg { width: 22px; height: 22px; }

/* coach: one number, one bar, then the moves */
.accuracy { margin-top: 10px; }
.acc-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 12px; color: var(--muted); }
.acc-top .acc-n { font-size: 20px; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.acc-meta { margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.acc-bar { display: flex; gap: 2px; height: 6px; margin-top: 7px; border-radius: 3px; overflow: hidden; }
.acc-bar i { min-width: 3px; }
.q-best { background: var(--good); }
.q-good { background: var(--ok); opacity: .75; }
.q-inaccuracy { background: var(--warn); }
.q-mistake { background: var(--bad); }
.q-blunder { background: var(--worst); }
.coach-empty { margin: 0; padding: 10px 12px; border-radius: 10px; border: 1px dashed var(--line-2); color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.coach-empty b { color: var(--text); }
.reviews { margin-top: 8px; }
.rev:first-child { border-top: 0; }

/* players: whose turn it is reads at a glance; you are always findable */
.player.me .p-tag { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 800; }
.player.me.awaited .p-tag .p-due { background: var(--accent-ink); box-shadow: none; }
.player.active::after { content: ""; position: absolute; left: 5px; top: 0; bottom: 0; width: 60px; background: linear-gradient(90deg, color-mix(in srgb, var(--pc) 22%, transparent), transparent); pointer-events: none; }
.p-fame b { font-size: 26px; }

/* one-click build targets stay out of the way until the pointer is over the board */
.targets.quick .e-target { opacity: .7; transition: opacity .15s; }
.board:hover .targets.quick .e-target, .targets.quick .e-target:hover { opacity: 1; }

@media (max-width: 899px) {
  .tray { align-items: stretch; }
  .board-wrap { border-radius: 16px; }
}
@media (max-width: 560px) {
  .rcard { height: 62px; }
  .tray-cap { margin-bottom: 5px; }
}

/* awards sit beside the name; the stat line never wraps */
.badge.award { padding: 2px 5px; flex: none; }
.badge.award svg { width: 13px; height: 13px; }
.p-stats { display: flex; flex-wrap: nowrap; justify-content: space-between; gap: 0 6px; }
@media (max-width: 1280px) { .p-stats { font-size: 11.5px; } .p-stats .st-cards b { font-size: 13px; } }
/* short windows (most laptops): tighter panels so the whole left column stays in view */
@media (min-width: 900px) and (max-height: 800px) {
  .app { gap: 10px; padding-block: 10px; }
  .left, .right, .players { gap: 8px; }
  .player { padding: 7px 12px 8px 16px; }
  .p-fame b { font-size: 22px; }
  .p-race { margin-top: 5px; }
  .p-stats { margin-top: 5px; }
  .card { padding: 9px 12px; }
  h2 { margin-bottom: 7px; }
  .ec-row { padding: 1px 0; }
  .bank h2 { display: none; } /* the row of counts under "Your income" explains itself; the tooltip names it */
  .tray { padding: 8px 14px; }
  .tray-cap { margin-bottom: 5px; }
  .rcard { height: 64px; }
  .dcard { height: 58px; }
  .venturehand { min-height: 60px; }
  .venture-wrap > .tray-cap { margin-bottom: 9px; }
  .btn.big { padding: 10px 18px; }
}
@media (max-width: 899px) {
  /* small boards: the dice shrink into the corner instead of covering a hex */
  .dice { right: 8px; bottom: 6px; gap: 3px; }
  .dice .d-who { font-size: 10.5px; }
  .dice .d-row { gap: 5px; }
  .die { width: 28px; height: 28px; border-radius: 7px; padding: 4px; }
  .die i { width: 5px; height: 5px; }
  .dice .total { font-size: 17px; min-width: 20px; }
}
@media (max-width: 699px) {
  .actions .btn.big { grid-column: 1 / -1; }
}
/* game over: room for all four actions on one line; the pill brings the result back */
#dlg-over { width: min(640px, calc(100vw - 32px)); }
#dlg-over .dlg-actions { flex-wrap: nowrap; }
@media (max-width: 560px) { #dlg-over .dlg-actions { flex-wrap: wrap; } }
#over-all { white-space: nowrap; }
.pill > span:not(.dot):not(.spinner) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 900px) { .pill > span.muted { flex-shrink: 1000; } } /* one line: the round gives way before the instruction does */
.pill-link { flex: none; font: inherit; font-size: 13px; font-weight: 700; color: var(--accent); background: rgb(240 180 41 / .12); border: 1px solid rgb(240 180 41 / .4); border-radius: 999px; padding: 2px 10px; margin-left: 4px; cursor: pointer; }
.pill-link:hover { background: rgb(240 180 41 / .22); }
.pill-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============ five and six players ============ */
:root { --p4: #3ecf8e; --p5: #b07cf7; }
body.many .players { gap: 6px; }
body.many .player { padding-block: 7px; }
body.many .p-race { margin-top: 4px; }
body.many .p-stats { margin-top: 4px; font-size: 11.5px; gap: 2px 8px; }

/* ============ colour-blind friendly marks ============ */
body.marks { --p0: #e69f00; --p1: #56b4e9; --p2: #009e73; --p3: #f0e442; --p4: #cc79a7; --p5: #ffffff; }
.p-seat { display: none; flex: none; min-width: 17px; height: 17px; border-radius: 5px; background: var(--pc); color: #10151d; font: 800 11px/17px var(--mono); text-align: center; margin-right: 6px; }
body.marks .p-seat { display: inline-block; }
.piece .seat-mark { display: none; font: 800 10px var(--mono); text-anchor: middle; fill: #10151d; stroke: rgb(255 255 255 / .75); stroke-width: 2.2px; paint-order: stroke; pointer-events: none; }
body.marks .piece .seat-mark { display: block; }
.board [role="button"]:focus { outline: none; }
.board [role="button"]:focus-visible .ring, .board [role="button"]:focus-visible .vis, .board polygon[role="button"]:focus-visible { stroke: #fff; stroke-width: 3.5; opacity: 1; }
.log:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.p-open { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
.p-open span { display: inline-flex; align-items: center; gap: 3px; }
.p-open svg { width: 13px; height: 13px; }

/* ============ new game: more options ============ */
.multi { margin-top: 4px; }
.names { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 12px; }
.more-opts { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.more-opts summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; }
.more-opts summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ============ saved games and progress ============ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 14px; }
.tab { position: relative; font: inherit; font-weight: 700; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; cursor: pointer; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
#games-body { min-height: 220px; }
.games-table td { vertical-align: middle; }
.games-table .won { font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions .btn { padding: 4px 10px; font-size: 12.5px; text-decoration: none; }
.nowrap { white-space: nowrap; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat-tiles > div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat-tiles b { font-size: 24px; font-variant-numeric: tabular-nums; }
.stat-tiles b.up { color: var(--good); }
.stat-tiles b.down { color: var(--worst); }
.stat-tiles span { font-size: 12px; color: var(--muted); }
.spark { width: 100%; height: auto; margin-top: 14px; background: #0e141d; border: 1px solid var(--line); border-radius: 12px; }
.spark .grid { stroke: var(--line); stroke-width: 1; }
.spark .axis { fill: var(--faint); font: 10px var(--mono); }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: #0e141d; stroke: var(--accent); stroke-width: 2; }
.spark circle.won { fill: var(--accent); }
.spark-key { font-size: 12px; margin: 6px 0 0; }
.bar-cell { width: 28%; }
.bar-cell .bar { display: block; height: 8px; border-radius: 4px; background: #0e141d; overflow: hidden; }
.bar-cell .bar i { display: block; height: 100%; background: var(--warn); border-radius: 4px; }
#dlg-games h3 { margin: 18px 0 8px; }

/* ============ replay ============ */
.replay-bar { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 3; display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; justify-content: center; padding: 8px 12px; border-radius: 14px; background: rgb(17 24 35 / .95); border: 1px solid var(--line-2); box-shadow: 0 10px 30px rgb(0 0 0 / .45); }
.replay-bar .btn { padding: 6px 10px; }
.replay-bar input[type="range"] { width: clamp(120px, 22vw, 320px); accent-color: var(--accent); }
.rp-pos { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 150px; }
body.replaying .dice { bottom: 74px; }
body.replaying .tray .actions, body.replaying #btn-hint, body.replaying #btn-eval { opacity: .35; pointer-events: none; }
.rp-decision { padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--muted); }
.rp-decision p { margin: 0 0 6px; }
.rp-decision.v-best, .rp-decision.v-good { border-left-color: var(--good); }
.rp-decision.v-inaccuracy { border-left-color: var(--warn); }
.rp-decision.v-mistake, .rp-decision.v-blunder { border-left-color: var(--worst); }

/* ============ lobby, joining, pass and play ============ */
.lobby { position: absolute; inset: 50% auto auto 50%; translate: -50% -50%; z-index: 4; width: min(430px, calc(100% - 24px)); padding: 18px 20px; border-radius: 16px; background: rgb(17 24 35 / .97); border: 1px solid var(--line-2); box-shadow: 0 18px 50px rgb(0 0 0 / .55); }
.lobby h2 { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0 0 10px; }
.seat-list { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; }
.seat-list li { display: flex; align-items: center; gap: 8px; }
.seat-list .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.invite { display: flex; gap: 8px; }
.invite input { flex: 1; min-width: 0; font: 12.5px var(--mono); color: var(--text); background: #0e141d; border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; }
.warn-note { color: var(--warn); font-size: 12.5px; }
.warn-note code { font: 12px var(--mono); background: #0e141d; padding: 1px 5px; border-radius: 5px; }
dialog.curtain { text-align: center; width: min(420px, calc(100vw - 32px)); }
dialog.curtain::backdrop { background: #070a10; backdrop-filter: none; }
dialog.curtain .dlg-actions { justify-content: center; }
body.curtained .app { visibility: hidden; }

/* ============ counter-offers ============ */
.bo-counter { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: #0e141d; border: 1px solid var(--line); }
.bo-note { min-height: 1.2em; font-size: 12.5px; margin: 8px 0 0; }
.reply .ans.counter { color: var(--warn); font-weight: 600; font-size: 12.5px; text-align: right; }
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

@media (max-width: 899px) {
  .replay-bar { position: static; translate: none; margin: 8px auto 0; }
  .rp-pos { min-width: 0; }
}

/* the replay bar takes its own strip under the board instead of covering it */
body.replaying .board { height: calc(100% - 104px); }
body.replaying .dice { bottom: 114px; }
.replay-bar .kb { display: none; }
.replay-bar input[type="range"] { flex: 1 1 160px; width: auto; }
.row-actions { flex-wrap: nowrap; }
.games-table td:nth-child(3) { white-space: nowrap; }
dialog.wide { width: min(980px, calc(100vw - 32px)); }
@media (max-width: 899px) { .row-actions { flex-wrap: wrap; } body.replaying .board { height: 100%; } }

/* ============ your move: what you can press grows ============ */
/* Anything that moves the game on is drawn larger while it is yours to press, and what you
   can't use right now steps back, so the next click is the biggest thing on the screen.
   The size is a state, so it holds under reduced motion; only the spring is dropped. */
:root {
  --spring: linear(0, .009, .035 2.1%, .141 4.4%, .723 12.9%, .938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, .991, .977 51%, .974 53.8%, .975 57.1%, .997 69.8%, 1.003 76.9%, 1);
  --zoom: 1.1; --zoom-main: 1.2;
}
.actions .btn, .dcard { transform-origin: 50% 100%; }
.actions .btn { transition: scale .32s cubic-bezier(.3, 1.4, .5, 1), background-color .15s, border-color .15s, opacity .2s, box-shadow .2s; }
.dcard { transition: scale .32s cubic-bezier(.3, 1.4, .5, 1), translate .2s, box-shadow .2s, opacity .2s, margin .32s; }
@supports (transition-timing-function: linear(0, 1)) {
  .actions .btn { transition-duration: .6s, .15s, .15s, .2s, .2s; transition-timing-function: var(--spring), ease, ease, ease, ease; }
  .dcard { transition-duration: .6s, .2s, .2s, .2s, .6s; transition-timing-function: var(--spring), ease, ease, ease, var(--spring); }
}
@media (prefers-reduced-motion: reduce) { .actions .btn, .dcard { transition-property: background-color, border-color, opacity, box-shadow; } }
.actions .btn.go { scale: var(--zoom); z-index: 1; }
.actions .btn.go-main { scale: var(--zoom-main); z-index: 2; margin-inline: 6px; }
.actions .btn.go:hover { scale: calc(var(--zoom) + .05); }
.actions .btn.go-main:hover { scale: calc(var(--zoom-main) + .04); }
.actions .btn.go:active { scale: 1; }
body.my-turn .actions .btn.tool:not(.go) { scale: .92; opacity: .7; }
.actions .btn.tool.go { background: #24324a; box-shadow: 0 0 0 1px rgb(240 180 41 / .45) inset, 0 8px 18px rgb(0 0 0 / .35); }
.actions .btn.go-main { box-shadow: 0 0 0 4px rgb(240 180 41 / .16), 0 10px 26px rgb(240 180 41 / .28); }
.venturehand { gap: 9px; }

/* ============ ventures: the card you can play is the card you see ============ */
/* A playable venture stands up out of the tray, larger, ringed in gold and softly lit, with
   its key on it; the rest of the hand steps back while it is your move. The moment a card
   becomes playable (your turn starts, the dice are rolled) it springs up once, so the change
   is noticed without anything flashing for the rest of the turn. Grown from the centre, it
   keeps clear of the caption above and the tray's edge below. */
.dcard { transform-origin: 50% 50%; }
.dcard.playable { scale: 1.24; z-index: 2; margin-inline: 7px; box-shadow: 0 0 0 2px var(--accent), 0 0 18px rgb(240 180 41 / .38), 0 10px 22px rgb(0 0 0 / .45); }
.dcard.playable::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none; box-shadow: 0 0 0 2px rgb(240 180 41 / .9), 0 0 22px 4px rgb(240 180 41 / .45); opacity: 0; }
.dcard.playable:hover, .dcard.playable:focus-visible { scale: 1.32; translate: 0 -3px; }
.dcard.playable:active { scale: 1.16; translate: 0; }
.dcard.playable > .kb { background: var(--accent); color: #1b1404; border-color: transparent; font-weight: 800; }
body.my-turn .venturehand.has-ready .dcard:not(.playable) { scale: .9; opacity: .5; }
@media (prefers-reduced-motion: no-preference) {
  .dcard.rise { animation: venture-rise .75s var(--spring, cubic-bezier(.3, 1.5, .5, 1)) backwards; animation-delay: calc(var(--i, 0) * 60ms); }
  .dcard.playable::after { animation: venture-glow 2.6s ease-in-out infinite; }
  .dcard.playable:hover::after, .dcard.playable:focus-visible::after { animation: none; opacity: 1; }
}
@keyframes venture-rise { from { scale: 1; translate: 0 5px; } 45% { translate: 0 -5px; } }
@keyframes venture-glow { 50% { opacity: .75; } }
.cap-ready { text-transform: none; letter-spacing: 0; font-size: 11px; font-weight: 750; color: #1b1404; background: var(--accent); border-radius: 999px; padding: 0 8px; line-height: 16px; }

/* the close-up: a large copy of the card that rises out of it, with its rules */
.vpeek { position: fixed; inset: auto; margin: 0; padding: 0; border: 0; background: none; overflow: visible; color: var(--text); width: 200px; pointer-events: none; opacity: 0; translate: 0 12px; scale: .55; transform-origin: var(--from, 50%) 100%; transition: opacity .14s, scale .14s, translate .14s; }
.vpeek.show { opacity: 1; scale: 1; translate: 0; transition: opacity .18s, scale .32s cubic-bezier(.3, 1.35, .5, 1), translate .32s cubic-bezier(.3, 1.35, .5, 1); }
@starting-style { .vpeek.show { opacity: 0; translate: 0 12px; scale: .55; } }
@media (prefers-reduced-motion: reduce) { .vpeek, .vpeek.show { scale: 1; translate: 0; transition: opacity .12s; } }
.vp-card { border-radius: 16px; padding: 10px 10px 12px; background: linear-gradient(160deg, #5b4a8c, #2a2049); border: 1px solid #8f7bd0; box-shadow: 0 18px 44px rgb(0 0 0 / .55), inset 0 1px 0 rgb(255 255 255 / .15); text-align: center; }
.vp-card.landmark { background: linear-gradient(160deg, #8a6b1c, #3e2f0c); border-color: #c9a33f; }
.vp-card.playable { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 0 30px rgb(240 180 41 / .3), 0 18px 44px rgb(0 0 0 / .55); }
.vp-art { height: 104px; border-radius: 11px; display: grid; place-items: center; background: radial-gradient(circle at 50% 32%, #4b3c7c, #1d1638); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .16), inset 0 3px 10px rgb(0 0 0 / .45); }
.vp-card.landmark .vp-art { background: radial-gradient(circle at 50% 32%, #7a5c16, #2b1f07); }
.vp-art svg { width: 78px; height: 78px; filter: drop-shadow(0 3px 4px rgb(0 0 0 / .5)); }
.vp-name { margin-top: 9px; font-size: 14px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #f1eaff; }
.vp-name span { color: var(--accent); letter-spacing: 0; }
.vp-does { margin: 6px 2px 0; font-size: 12.5px; line-height: 1.4; color: #ddd3f5; text-wrap: pretty; }
.vp-state { margin-top: 9px; padding-top: 8px; border-top: 1px solid rgb(255 255 255 / .14); font-size: 11.5px; font-weight: 650; color: #b9aedb; }
.vp-card.playable .vp-state { color: var(--accent); }
.vp-state kbd { font: inherit; font-weight: 800; background: var(--accent); color: #1b1404; border-radius: 4px; padding: 0 5px; }
/* in a dialog the answer that moves on is the larger button */
dialog :is(.dlg-actions, .offer-bar) .obvious:not(:disabled), dialog :is(.dlg-actions, .offer-bar):not(:has(.obvious:not(:disabled))) .btn.primary:not(:disabled), .victims button.obvious { scale: 1.08; transform-origin: 100% 50%; margin-inline: 8px 4px; }
.victims button.obvious { transform-origin: 0 50%; margin-left: 0; }
dialog .dlg-actions .btn, dialog .offer-bar .btn { transition: scale .25s cubic-bezier(.3, 1.4, .5, 1), background-color .15s, border-color .15s, opacity .15s; }
@media (max-width: 899px) { :root { --zoom: 1.04; --zoom-main: 1.04; } .actions .btn.go-main { margin-inline: 0; } }

/* board targets: large, and they arrive with a small zoom of their own, best spots first */
.targets > * { transform-box: fill-box; transform-origin: center; }
@media (prefers-reduced-motion: no-preference) {
  .targets > * { animation: target-in .5s cubic-bezier(.3, 1.5, .5, 1) backwards; animation-delay: calc(var(--i, 0) * 14ms); }
  .targets > polygon.hex-target { animation-name: target-fade; }
  .targets .best .halo { animation: halo 1.7s ease-out infinite; }
}
@keyframes target-in { from { scale: .2; opacity: 0; } }
@keyframes target-fade { from { opacity: 0; } }
@keyframes halo { from { scale: 1; opacity: .9; } to { scale: 2; opacity: 0; } }
.v-target .halo { fill: none; stroke: var(--good); stroke-width: 2.5; opacity: 0; transform-box: fill-box; transform-origin: center; pointer-events: none; }
.v-target circle.ring, .v-target .v-pips { transition: scale .18s cubic-bezier(.3, 1.5, .5, 1); transform-box: fill-box; transform-origin: center; }
.v-target circle.ring.scored { stroke-width: 2.2; filter: drop-shadow(0 1.5px 1.5px rgb(0 0 0 / .45)); }
.v-target:hover circle.ring.scored, .v-target:focus-visible circle.ring.scored { scale: 1.3; }
.v-target:hover .v-pips { scale: 1.25; }
.v-target.best circle.ring.scored { stroke: var(--good); stroke-width: 3; }
.v-target.k-town circle.ring { fill: rgb(240 180 41 / .14); stroke-width: 3.2; animation: none; }
.v-target.k-town .up { fill: var(--accent); stroke: #10151d; stroke-width: 1.2; stroke-linejoin: round; pointer-events: none; }
.targets.quick .v-target.k-town .up { opacity: .85; }
.e-target.best line.vis { stroke: var(--good); }
.hex-target { stroke: rgb(255 255 255 / .6); stroke-width: 3; }
.hex-target.best { stroke: var(--good); stroke-width: 4; stroke-dasharray: none; fill: rgb(62 207 142 / .12); }
/* one-click building in your main phase: smaller than a chosen build mode, still easy to hit */
.targets.quick .v-target circle.ring.scored { scale: .85; }
.targets.quick .v-target .v-pips { scale: .85; }
.targets.quick .v-target:hover circle.ring.scored { scale: 1.2; }

/* ============ small screens: nothing sits on top of what you are reading ============ */
.row2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.field input { min-width: 0; width: 100%; }
.tray-hint { display: none; }
.v-target.t-lo { opacity: .8; }
.g-meta { display: block; font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.games-tools { display: flex; justify-content: flex-end; margin-top: 10px; }
.games-tools .btn { font-size: 12.5px; padding: 4px 10px; }
.term { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.fame-note { font-size: 12px; margin: 6px 0 14px; }
/* the result's five actions wrap instead of sliding out of the dialog */
#dlg-over { width: min(900px, calc(100vw - 32px)); }
#dlg-over .dlg-actions { flex-wrap: wrap; }
/* a table cell again, so its bottom rule lines up with the rest of the row */
.games-table td.row-actions { display: table-cell; text-align: right; white-space: nowrap; }
.games-table .row-actions .btn { margin-left: 4px; }
@media (max-width: 899px) {
  /* one column, in the order you look things up: board, your hand, the others, the coach */
  .app { grid-template-areas: "top" "board" "tray" "players" "coach" "econ" "bank" "log"; }
  .left, .right { display: contents; }
  .players { grid-area: players; }
  .coach { grid-area: coach; }
  .econ { grid-area: econ; }
  .bank { grid-area: bank; }
  .log-card { grid-area: log; }
  /* the board keeps its own height; the recap and the replay controls get a strip below it */
  :root { --bh: max(300px, min(92vw, calc(100dvh - 250px))); }
  .board-wrap { height: auto; min-height: 0; display: flex; flex-direction: column; }
  .board, body.replaying .board { position: relative; inset: auto; flex: none; height: var(--bh); }
  .dice, body.replaying .dice { bottom: auto; top: calc(var(--bh) - 6px); translate: 0 -100%; }
  .recap { position: static; max-width: none; margin: 0 8px 8px; translate: none; transition: none; flex-flow: row wrap; gap: 4px 12px; align-items: center; }
  .recap:not(.show) { display: none; }
  .recap .rc-head { flex-basis: 100%; }
  .replay-bar { position: static; margin: 0 8px 8px; }
  .replay-bar .btn { min-height: 38px; min-width: 38px; }
  .replay-bar { gap: 6px 4px; padding: 8px; }
  .replay-bar .btn:not(.primary) { padding: 6px 4px; } /* the seven step buttons stay on one row */
  /* toasts cover the title row, never the status line or the board */
  .toasts { inset: 6px auto auto 50%; translate: -50% 0; }
  .toast:nth-child(n+2) { display: none; } /* one at a time: the newest */
  /* a hint is one tap away from the board; the answer scrolls into view */
  .tray-hint { display: inline-flex; align-self: stretch; justify-content: center; }
}
@media (max-width: 699px) {
  .actions { grid-template-columns: 1fr 56px; }
  .actions .btn.big { grid-column: 1; }
  .actions .tray-hint { grid-column: 2; grid-row: 2; min-width: 0; }
  .actions .tray-hint svg { width: 24px; height: 24px; }
}
@media (max-width: 480px) {
  .fame-table { font-size: 12px; }
  .fame-table th, .fame-table td { padding: 6px 1px; }
  .fame-table th { font-size: 9.5px; }
  body.replaying .tray { position: static; } /* nothing to press there: it must not cover the replay controls */
}
@media (max-width: 700px) {
  /* saved games: one card per game instead of a table wider than the screen */
  .games-table thead { display: none; }
  .games-table, .games-table tbody { display: block; }
  .games-table tr { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "who who" "state acc" "when when" "acts acts"; gap: 3px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .games-table td { border: 0; padding: 0; }
  .games-table td:nth-child(1) { grid-area: when; font-size: 12px; }
  .games-table td:nth-child(2) { grid-area: who; }
  .games-table td:nth-child(3) { grid-area: state; white-space: normal; }
  .games-table td:nth-child(4) { grid-area: acc; }
  .games-table td.row-actions { grid-area: acts; display: flex; flex-wrap: wrap; gap: 4px; flex-wrap: nowrap; justify-content: flex-start; white-space: nowrap; margin-top: 6px; }
  .games-table .row-actions .btn { margin: 0; }
  .games-table .row-actions .btn { flex: 1 1 auto; padding: 7px 6px; font-size: 12.5px; text-align: center; justify-content: center; } /* all four on one row at 360px */
}
@media (max-width: 480px) {
  /* a rate you can't pay still says what is missing */
  .bt-row.off .bt-need { display: block; }
}
@media (hover: none) and (pointer: coarse) {
  /* fingers: bigger spots to hit, bigger numbers to read */
  .v-target circle.hit { r: 27px; }
  .v-target circle.ring.scored { r: 15px; }
  .v-target .v-pips { font-size: 15px; }
}

/* ------------------------------------------------------------ phones: the whole game on one screen
   Top to bottom: a slim bar, who is winning, the board from edge to edge, your cards and the
   one thing to press. Everything you look up now and then (coach, income, bank, log) is below. */
@media (max-width: 560px) {
  .app { grid-template-areas: "top" "players" "board" "tray" "coach" "econ" "bank" "log"; gap: 8px; padding: 6px 10px 8px; }
  /* the board takes what the bar, the strip and the tray leave (the tray reports its own height) */
  :root { --bh: max(260px, min(100vw, calc(100dvh - 166px - var(--tray-h, 152px)))); }

  /* bar: the mark, the tools, and under them one quiet line saying what to do */
  .topbar { gap: 6px 8px; }
  .brand > div { display: none; }
  .brand-mark { width: 26px; height: 26px; filter: none; }
  .top-actions { margin-left: auto; gap: 2px; }
  .top-actions .btn { padding: 6px 9px; min-height: 34px; border-color: transparent; background: none; }
  .pill { width: 100%; padding: 7px 12px; font-size: 14px; border-radius: 12px; gap: 8px; }
  .pill.mine { box-shadow: none; }
  .pill > span.muted { display: none; }
  .pill > span:not(.dot):not(.spinner) { overflow: visible; }

  /* news is one line across the tools, never over the line that says what to do */
  .toasts { inset: 4px auto auto 50%; width: calc(100vw - 16px); }
  .toast { padding: 7px 10px; border-radius: 10px; min-height: 0; }
  .toast .t-body { display: flex; align-items: baseline; gap: 8px; min-width: 0; white-space: nowrap; }
  .toast .t-title { font-size: 13px; flex: none; }
  .toast .t-sub { font-size: 13px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* the others at a glance: name, fame, cards. Tap for the full cards. */
  #players { display: grid; grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; cursor: pointer; }
  #players:not(.open) .player { padding: 6px 8px 6px 11px; border-radius: 12px; min-width: 0; }
  #players:not(.open) :is(.p-seat, .p-tag, .p-race, .p-badges, .p-open, .badge, .p-fame small, .p-fame .hid) { display: none; }
  #players:not(.open) .p-head { gap: 4px; }
  #players:not(.open) .p-name { font-size: 12.5px; min-width: 0; }
  #players:not(.open) .p-fame b { font-size: 18px; }
  #players:not(.open) .p-stats { margin-top: 1px; font-size: 11px; justify-content: flex-start; color: var(--muted); }
  #players:not(.open) .p-stats > span:not(.st-cards) { display: none; }
  #players:not(.open) .p-stats .st-cards b { font-size: inherit; }
  #players:not(.open) .player.awaited .p-think { display: block; right: 8px; bottom: 9px; }
  #players:not(.open) .player.awaited .p-due { width: 9px; height: 9px; }
  /* five or six at the table: the name on its own line, fame and the card count under it */
  body.many #players:not(.open) { gap: 4px; }
  body.many #players:not(.open) .player { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 0 5px; padding: 5px 5px 5px 9px; }
  body.many #players:not(.open) .p-head { display: contents; }
  body.many #players:not(.open) .p-name { grid-column: 1 / -1; font-size: 11.5px; }
  body.many #players:not(.open) .p-fame { margin: 0; }
  body.many #players:not(.open) .p-fame b { font-size: 16px; }
  body.many #players:not(.open) .p-stats { margin: 0; }
  body.many #players:not(.open) .st-cards { font-size: 0; }
  body.many #players:not(.open) .st-cards b { font-size: 11.5px; font-weight: 600; }
  body.many #players:not(.open) .st-cards b::after { content: ""; display: inline-block; width: 6px; height: 8px; margin-left: 3px; border: 1px solid currentColor; border-radius: 1.5px; opacity: .7; }
  body.many #players:not(.open) .player.awaited .p-think { right: 5px; bottom: 8px; }
  body.many #players:not(.open) .player.awaited .p-due { width: 7px; height: 7px; }
  #players.open { grid-auto-flow: row; grid-auto-columns: auto; }

  /* the board runs from edge to edge */
  .board-wrap { margin-inline: -10px; border-radius: 0; border-inline: 0; }
  /* what happened while you waited shows on your counters (+1) and in the log: no strip pushing the tray down */
  .recap, .recap.show { display: none; }

  /* your cards as five counters, then the builds, then the one big button */
  .tray { padding: 8px; gap: 8px; bottom: 6px; border-radius: 16px; }
  #hand-cap:not(:has(.cap-warn)) { display: none; }
  #hand-cap > span:first-child, #hand-cap > b { display: none; }
  #hand { gap: 6px; }
  #hand .rcard { display: flex; flex: 1; width: auto; max-width: none; height: 38px; flex-direction: row; align-items: center; justify-content: center; gap: 5px; border-radius: 10px;
    background: color-mix(in srgb, var(--rc) 20%, var(--panel-2)); border: 1px solid color-mix(in srgb, var(--rc) 55%, transparent); box-shadow: none; }
  #hand .rcard::before, #hand .rcard .lbl { display: none; }
  #hand .rcard svg { width: 22px; height: 22px; margin: 0; filter: none; }
  #hand .rcard .n { position: static; min-width: 0; height: auto; border: 0; background: none; font-size: 16px; color: var(--text); }
  #hand .rcard.zero { opacity: .45; filter: saturate(.3); border-color: var(--line); background: none; }
  .actions { gap: 6px; }
  .actions .build { gap: 6px; }
  .btn.tool { padding: 5px 2px 4px; border-radius: 10px; }
  .btn.big { padding: 11px 16px; }
  /* one big button at a time: while something has to be answered, End turn waits out of sight */
  .actions:has(#btn-answer:not([hidden]), #btn-discard:not([hidden])) #btn-end { display: none; }
  /* dialogs: every action stays on the screen */
  dialog .dlg-actions { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
  dialog .bo-actions { flex-wrap: nowrap; gap: 6px; }
  dialog .bo-actions .btn { padding-inline: 10px; }
  dialog .bo-actions .dlg-undo { font-size: 0; padding-inline: 8px; } /* the arrow alone: four answers on one row */
  dialog .bo-actions .dlg-undo svg { margin: 0; }
  .dlg-head .dlg-undo { font-size: 0; padding-inline: 8px; } /* the arrow alone beside the title */
}
