/* Ticket to Ride — tokens from the Board & Card Games hub so it reads as a sibling site. */
:root {
  --bg: #0f1117;
  --bg-soft: #161923;
  --card: #1a1e2b;
  --card-hover: #212636;
  --line: #2a3042;
  --text: #e8eaf0;
  --muted: #969db4;
  --accent: #6ea8fe;
  --accent-warm: #f0b354;
  --good: #6ee7a8;
  --bad: #f08c8c;
  /* the printed board: parchment land, grey-blue sea, like the real game's vintage map */
  --land: #eadfbf;
  --land-edge: #7d6a48;
  --sea: #9fbcc4;
  --land-far: #d3cbb4;
  --lake: #a9c5cc;
  --print-ink: #2b2116;
  --board-edge: #2c2219;
  --radius: 12px;
  --tab-h: 58px;
  --head-h: 48px;
  /* train card colours (game colours, own shades) */
  --c-pink: #d77bd0; --c-white: #eef0f4; --c-blue: #4f8ff0; --c-yellow: #f2cf45;
  --c-orange: #f0913a; --c-black: #2b2f3a; --c-red: #e2504c; --c-green: #4fbf6a; --c-gray: #8d93a6; --c-loco: #b9a3ff;
  /* player colours */
  --p0: #e2504c; --p1: #4f8ff0; --p2: #f2cf45; --p3: #4fbf6a; --p4: #2b2f3a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overflow: hidden; overflow-x: clip; touch-action: manipulation;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ app frame */
#app { height: 100dvh; display: grid; grid-template-rows: var(--head-h) 1fr var(--tab-h); }
header.top {
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  border-bottom: 1px solid var(--line); background: var(--bg); min-width: 0;
}
header.top .logo { width: 26px; height: 26px; flex: none; }
header.top h1 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
header.top .sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
header.top .spacer { flex: 1; }
.toptabs { display: none; }

nav.tabbar {
  display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line);
  background: var(--bg-soft); padding-bottom: env(safe-area-inset-bottom);
}
nav.tabbar button, .toptabs button {
  background: none; border: 0; color: var(--muted); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; font-size: 11.5px; font-weight: 600;
  transition: color .15s, transform .08s;
}
nav.tabbar button svg { width: 22px; height: 22px; }
nav.tabbar button[aria-selected="true"], .toptabs button[aria-selected="true"] { color: var(--accent-warm); }
nav.tabbar button:active { transform: scale(.94); }

main { min-height: 0; position: relative; }
.view { position: absolute; inset: 0; display: none; flex-direction: column; min-height: 0; }
.view.active { display: flex; }

/* board on top, panel in the leftover space */
.board-wrap { position: relative; flex: none; background: radial-gradient(120% 90% at 50% 45%, #0c1320, var(--sea) 70%); overflow: hidden; touch-action: none; }
.board-wrap svg.board { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
.panel { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px 14px; border-top: 1px solid var(--line); }
.zoom {
  position: absolute; right: 6px; bottom: 6px; display: flex; flex-direction: column;
  border-radius: 11px; border: 1px solid var(--line); background: rgba(22,25,35,.92); overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.zoom button {
  width: 40px; height: 38px; border: 0; background: none; color: var(--text); font-size: 19px; line-height: 1;
  display: grid; place-items: center; transition: transform .08s, background .12s;
}
.zoom button + button { border-top: 1px solid var(--line); }
.zoom button:hover { background: var(--card-hover); }
.zoom button:active { transform: scale(.9); background: var(--card-hover); }
/* the fit button: dimmed while the whole board is in view (auto), lit once zoomed by hand */
.zoom [data-z="fit"] { color: var(--muted); opacity: .45; transition: color .15s, opacity .15s, transform .08s, background .12s; }
.zoom [data-z="fit"].lit { color: var(--accent-warm); opacity: 1; }
.board-tip {
  position: absolute; left: 8px; top: 8px; right: 52px; pointer-events: none;
  font-size: 12.5px; color: var(--text); text-shadow: 0 1px 2px #000;
}

@media (min-width: 900px) {
  #app { grid-template-rows: 56px 1fr; }
  :root { --head-h: 56px; }
  nav.tabbar { display: none; }
  .toptabs { display: flex; gap: 4px; margin-left: 18px; }
  .toptabs button { flex-direction: row; gap: 7px; font-size: 14px; padding: 8px 14px; border-radius: 10px; }
  .toptabs button svg { width: 18px; height: 18px; }
  .toptabs button[aria-selected="true"] { background: rgba(240,179,84,.12); }
  .view { flex-direction: row; }
  .board-wrap { flex: none; } /* sized by app.js sizeBoards to the board's real shape */
  .panel { flex: none; width: 400px; border-top: 0; border-left: 1px solid var(--line); padding: 14px 16px 18px; }
  /* Table and Lab: the board as big as it fits at its own shape; the panel takes the width left over */
  #v-table .panel, #v-lab .panel, #v-play:not(.game) .panel { flex: 1 0 400px; width: auto; max-width: 620px; }
  #v-table.active, #v-lab.active, #v-play.active:not(.game) { justify-content: center; }
}

/* ------------------------------------------------------------------ board svg */
.land { fill: var(--land); }
/* real geography (map.art): widths in screen px so coasts stay crisp at every zoom */
.geo-shelf { fill: none; stroke: rgba(240,248,250,.35); stroke-width: 7px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.geo-land { fill: var(--land); stroke: var(--land-edge); stroke-width: 1.3px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.geo-land.far { fill: var(--land-far); }
.geo-home { fill: var(--land); stroke: none; }
.geo-lake { fill: var(--lake); stroke: var(--land-edge); stroke-width: 1px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.geo-states { fill: none; stroke: rgba(120,95,55,.2); stroke-width: .8px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.geo-border { fill: none; stroke: rgba(110,75,40,.5); stroke-width: 1.1px; stroke-dasharray: 5 3; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.city circle.dot { fill: #b8352a; stroke: #2b2116; stroke-width: 2.2; }
.city circle.ring { fill: #f6efd9; stroke: #2b2116; stroke-width: 1.4; opacity: .95; }
.city text {
  font: 700 var(--lf, 15px) Georgia, "Times New Roman", serif; fill: var(--print-ink); paint-order: stroke; stroke: #f6efd9;
  stroke-width: calc(var(--lf, 15px) * .36); stroke-linejoin: round; pointer-events: none; letter-spacing: .01em;
}
.city rect.dot { fill: #f6efd9; stroke: #2b2116; stroke-width: 2.2; }
.city[data-border] rect.dot { fill: #c1563f; stroke: #2b2116; stroke-width: 1.6; }
.city.sel .dot { fill: var(--accent-warm); }
.city.end .dot { fill: var(--accent); }
/* track bed under each city pair (both tracks of a double route share one); ferries cross on a sea-blue band */
.bed { stroke: rgba(70,52,28,.22); stroke-linecap: round; fill: none; }
.bed.ferry { stroke: rgba(30,80,130,.35); stroke-dasharray: 1.5 3.5; }
/* open spaces: flat coloured tiles */
.car { stroke: rgba(36,26,14,.85); stroke-width: 1.3; }
.car.blk { stroke: rgba(36,26,14,.85); stroke-width: 1.3; }
.car.tunnel { stroke: #0b0d12; stroke-width: 1.8; }
.car.blk.tunnel { stroke: #0b0d12; }
/* tunnels: rail ties sticking out on both sides */
.ties { stroke: #3a2c1c; stroke-dasharray: 1.7 2.5; opacity: .85; fill: none; }
.heat .car.blk { stroke: rgba(8,10,15,.9); } /* Busy routes colours every space, so no outline */
.loco-mark { fill: #f4efe4; stroke: #0b0d12; stroke-width: 1.3; }
.cbm { fill: rgba(8,10,15,.78); display: none; pointer-events: none; }
svg.cb .cbm { display: inline; }
svg.cb.heat .route:not(.claimed) .cbm { display: none; }
.route.claimed[data-own="4"] .cbm, .route:not(.claimed) .car.blk + .cbm { fill: rgba(244,239,228,.85); }
/* claimed: a train sitting on the board (fat cars on a dark casing, shine on top) */
.casing { stroke: #06080c; stroke-linecap: round; display: none; }
.route.claimed .casing { display: inline; }
.route.claimed .ties { display: none; }
.route.claimed .car { stroke: rgba(0,0,0,.55); stroke-width: 1; stroke-dasharray: none; }
.route.claimed[data-own="4"] .car { stroke: #b9c0ce; stroke-width: 1.2; }
.route.claimed .loco-mark { display: none; }
.shine { fill: #fff; opacity: .34; pointer-events: none; display: none; }
.route.claimed .shine { display: inline; }
.route.claimed[data-own="4"] .shine { opacity: .2; }
.route.dim { opacity: .4; }
.route.hl .car { stroke: var(--accent-warm); stroke-width: 2.6; animation: ttr-pop .55s cubic-bezier(.3,.7,.2,1); transform-box: fill-box; transform-origin: center; }
@keyframes ttr-pop { from { transform: scale(1.6); opacity: .3; } to { transform: none; opacity: 1; } }
.route.path .car { stroke: #fff; stroke-width: 2.4; filter: drop-shadow(0 0 3px rgba(190,95,0,1)); }
.route.blocked .car { opacity: .35; }
.route.sel .car { stroke: #fff; stroke-width: 3.2; filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 7px rgba(110,168,254,1)); animation: ttr-sel .8s ease-in-out infinite alternate; }
@keyframes ttr-sel { from { stroke: #fff; } to { stroke: var(--accent); } }
.route.sel .ties { opacity: 1; }
.station { stroke: #0b0d12; stroke-width: 1.5; }

/* ------------------------------------------------------------------ widgets */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 14px;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover:not(:disabled) { background: var(--card-hover); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0d1424; }
.btn.warm { background: var(--accent-warm); border-color: var(--accent-warm); color: #1c1405; }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; }
.row { display: flex; gap: 8px; align-items: center; min-width: 0; }
.row > * { min-width: 0; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.sec { margin: 12px 0 6px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.sec:first-child { margin-top: 2px; }
select, input[type=text], input[type=number] {
  background-color: var(--bg-soft); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; font-size: 16px; min-width: 0;
  -webkit-appearance: none; appearance: none; height: 38px;
}
select {
  padding-right: 28px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23969db4' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
select option { background: var(--card); color: var(--text); }
.names { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.names .row i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.seg { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { background: none; border: 0; border-radius: 8px; padding: 6px 11px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--card-hover); color: var(--text); }
.q {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--line); color: var(--muted); font-size: 11.5px; font-weight: 700; background: none; padding: 0; flex: none;
}
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 13px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.setting { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setting .label { flex: 1; min-width: 0; }
/* Sound & effects rows (js/fx.js) look like the other settings rows */
.fx-set .fx-row { padding: 10px 0; min-height: 0; border-top: 0; border-bottom: 1px solid var(--line); }
.fx-set .fx-row.dim { opacity: .4; }
.fx-set .switch input:checked + span { background: var(--accent); }
.fx-set .fx-why { padding: 8px 0 0; }
.fx-still .route.hl .car { animation: none; }

/* players strip */
.players { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.players::-webkit-scrollbar { display: none; }
.pchip {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 6px 9px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; text-align: left; position: relative;
}
.pchip .nm { font-size: 12.5px; font-weight: 700; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.pchip .nm i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.pchip .sc { font-size: 19px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pchip .mt { font-size: 11px; color: var(--muted); line-height: 1.25; } /* wraps to 2 lines with 4-5 players */
.pchip .nm { overflow: hidden; text-overflow: ellipsis; }
.pchip.on { border-color: var(--accent-warm); box-shadow: 0 0 0 1px var(--accent-warm) inset; }
.pchip.turn { border-color: rgba(240,179,84,.7); background: linear-gradient(180deg, rgba(240,179,84,.09), var(--card) 70%); }
.pchip.turn::before { content: ""; position: absolute; top: -1px; left: 10px; right: 10px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent-warm); }
.pchip { transition: border-color .2s, background .2s; }
/* phone: name and score share the first line, so the chips take one short row */
@media (max-width: 899px) {
  .pchip { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: 6px; padding: 5px 9px 6px; }
  .pchip .sc { font-size: 18px; grid-row: 1; grid-column: 2; }
  .pchip .mt { grid-column: 1 / -1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* tickets */
.tlist { display: flex; flex-direction: column; gap: 6px; }
.ticket {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 10px; align-items: center;
  padding: 8px 10px 7px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; text-align: left; width: 100%;
  transition: border-color .15s, background .15s;
}
.ticket .cities { font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; grid-row: 1; grid-column: 1; }
.ticket .pts { font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; grid-row: 1; grid-column: 3; min-width: 22px; text-align: right; }
/* one line per ticket: name · status · points, with the chance bar underneath */
.ticket .info { grid-row: 1; grid-column: 2; font-size: 12px; color: var(--muted); display: flex; gap: 7px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ticket .info:empty { display: none; }
.ticket.pick .info { grid-row: 2; grid-column: 1 / -1; } /* choosing: the longer numbers get their own line */
.ticket.done { border-color: rgba(110,231,168,.45); }
.ticket.dead { border-color: rgba(240,140,140,.45); }
.ticket.pick[aria-pressed="true"] { border-color: var(--accent); background: rgba(110,168,254,.08); }
.ticket.long .pts { color: var(--accent-warm); }
.bar { height: 4px; border-radius: 3px; background: var(--line); overflow: hidden; grid-column: 1 / -1; }
.bar i { display: block; height: 100%; border-radius: 3px; transition: width .3s; }
.chance { font-weight: 700; }

/* cards */
.hand { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; padding-top: 3px; }
/* a train card: a printed face inside a cream card edge, with a soft shadow */
.tcard {
  position: relative; aspect-ratio: 5 / 7.4; border-radius: 7px; border: 2px solid #ece6d8;
  display: block; overflow: hidden; padding: 0;
  font-weight: 800; font-size: 14px; color: #0f1117;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.28), 0 2px 5px rgba(0,0,0,.5);
  transition: transform .18s ease, opacity .18s;
}
.tcard svg { position: absolute; inset: 0; width: 100%; height: 100%; }
/* how many: a corner badge, so the drawing stays visible */
.tcard .n {
  position: absolute; left: 2px; top: 2px; background: rgba(12,14,20,.86); color: #fff; border-radius: 5px;
  min-width: 17px; padding: 0 4px; text-align: center; line-height: 17px; font-size: 12.5px; font-variant-numeric: tabular-nums;
}
/* two or more: the card edge of a second card peeks out behind, like a little pile */
.tcard.pile { box-shadow: inset 0 0 0 1px rgba(0,0,0,.28), 2.5px -2.5px 0 -.5px #bfb8a8, 0 2px 5px rgba(0,0,0,.5); overflow: visible; }
.tcard.pile svg { border-radius: 5px; }
.tcard.zero { opacity: .22; border-color: #6b6f7c; box-shadow: none; }
.tcard .cbm { display: none; }
body.cb .tcard .cbm { display: inline; }
.tcard.face { cursor: pointer; }
.tcard.face:active { transform: scale(.94); }
.tcard.deck { background: linear-gradient(160deg, #2c3550, #1a1e2b); color: var(--text); }
.tcard.deck .n { background: rgba(15,17,23,.7); color: var(--text); }
.market { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; align-items: end; }
.market .tcard { font-size: 11px; }
.tdeck {
  aspect-ratio: 5 / 7.4; border-radius: 7px; border: 2px solid #ece6d8; color: #c9cfdd;
  background: radial-gradient(circle at 50% 42%, rgba(110,168,254,.28) 0 22%, transparent 23%),
    repeating-linear-gradient(135deg, rgba(110,168,254,.12) 0 4px, transparent 4px 8px), linear-gradient(160deg, #2b3a62, #1a2138);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; gap: 0; padding: 2px;
  /* a face-down pile: two more card edges behind */
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.3), 2px -2px 0 -.5px #bfb8a8, 4px -4px 0 -1px #8f8a7f, 0 3px 6px rgba(0,0,0,.5);
  transition: transform .08s, border-color .12s;
}
.tdeck.tix {
  background: radial-gradient(circle at 50% 42%, rgba(240,179,84,.3) 0 22%, transparent 23%),
    repeating-linear-gradient(135deg, rgba(240,179,84,.13) 0 4px, transparent 4px 8px), linear-gradient(160deg, #4a3a22, #2a2114);
}
button.tdeck:not(:disabled):hover { border-color: #fff; }
button.tdeck:not(:disabled):active { transform: scale(.94); }
button.tdeck:disabled { opacity: .45; cursor: not-allowed; }
div.tdeck { background: var(--bg-soft); border-style: dashed; border-color: var(--line); box-shadow: none; }
.tdeck b { font-size: 16px; color: #fff; line-height: 1.15; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
/* phone: shorter cards (the drawing is cropped, not squashed) so the hand and tickets fit under the map */
@media (max-width: 899px) {
  .tcard, .tdeck { aspect-ratio: 5 / 5.6; }
  .hand .tcard { aspect-ratio: 5 / 6.2; }
  .sec { margin: 9px 0 5px; }
}
.fly { position: fixed; z-index: 50; pointer-events: none; transition: transform .45s cubic-bezier(.3,.7,.2,1), opacity .45s; }

/* status line + log */
.status { font-size: 14px; font-weight: 600; min-height: 22px; display: flex; align-items: center; gap: 8px; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent-warm); flex: none; }
.hint { background: rgba(110,168,254,.1); border: 1px solid rgba(110,168,254,.4); border-radius: 10px; padding: 8px 10px; font-size: 13.5px; }
.log { font-size: 12.5px; color: var(--muted); max-height: 140px; overflow-y: auto; }
.log div { padding: 2px 0; }

/* sheet (bottom on phone, centred card on laptop) */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; opacity: 0; transition: opacity .2s; }
.scrim.show { opacity: 1; }
.scrim.light { background: rgba(0,0,0,.18); } /* the claim sheet: keep the chosen route visible on the map */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--card); border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 82dvh; overflow-y: auto;
  transform: translateY(100%); transition: transform .25s cubic-bezier(.3,.7,.2,1);
}
.sheet.show { transform: none; }
.sheet h2 { margin: 0 0 4px; font-size: 18px; }
.sheet .acts { display: flex; gap: 8px; margin-top: 14px; }
.sheet .acts .btn { flex: 1; }
@media (min-width: 900px) {
  /* laptop: the sheet sits over the side panel, so the map (and the route being claimed) stays in view */
  /* ...low in the panel, so the cards you pay with stay in view above it */
  .sheet { left: auto; right: 10px; bottom: 12px; top: auto; width: 400px; border-radius: 16px; border: 1px solid var(--line);
    transform: translate(0, 14px); opacity: 0; transition: transform .2s, opacity .2s; box-shadow: 0 18px 50px rgba(0,0,0,.5); }
  .sheet.show { transform: none; opacity: 1; }
  body[data-view="settings"] .sheet { right: calc(50% - 200px); bottom: auto; top: 50%; transform: translate(0, -46%); } /* no map there: centre it */
  body[data-view="settings"] .sheet.show { transform: translate(0, -50%); }
}
.paylist { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.payopt { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; text-align: left; }
.payopt:hover { border-color: var(--accent); }
.payopt:active { transform: scale(.98); }
.pip { width: 16px; height: 22px; border-radius: 4px; border: 1px solid rgba(255,255,255,.25); display: inline-block; flex: none; }
/* claim sheet: each way to pay shows the actual cards */
.payopt { min-height: 48px; font-size: 15px; font-weight: 600; }
.payopt .mini { position: relative; width: 24px; height: 34px; border-radius: 4px; border: 1.5px solid #ece6d8; overflow: hidden; flex: none; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.payopt .mini svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.payopt .mini.pile { box-shadow: 2px -2px 0 -.5px #bfb8a8, 0 1px 3px rgba(0,0,0,.5); overflow: visible; }
.payopt .mini.pile svg { border-radius: 3px; }
.payopt .go { margin-left: auto; color: var(--accent); font-size: 20px; line-height: 1; }

/* scores table */
table.scores { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
table.scores th, table.scores td { padding: 5px 4px; text-align: right; border-bottom: 1px solid var(--line); }
table.scores th:first-child, table.scores td:first-child { text-align: left; }
table.scores th { color: var(--muted); font-weight: 600; font-size: 11.5px; }
table.scores tr.win td { color: var(--accent-warm); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 14px); transform: translate(-50%, 20px); opacity: 0; z-index: 60;
  background: #262c3d; border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; font-size: 14px;
  display: flex; gap: 12px; align-items: center; transition: transform .2s, opacity .2s; max-width: calc(100vw - 32px);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast button { background: none; border: 0; color: var(--accent-warm); font-weight: 700; padding: 0; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

.cover { position: fixed; inset: 0; background: var(--bg); z-index: 45; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.cover h2 { margin: 0; font-size: 22px; }

.lab-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.lab-table td, .lab-table th { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.lab-table td:first-child, .lab-table th:first-child { text-align: left; }
.lab-table th { color: var(--muted); font-weight: 600; font-size: 11.5px; position: sticky; top: 0; background: var(--bg); cursor: pointer; }
.lab-table tr { cursor: pointer; }
.lab-table tr:hover td { background: var(--card); }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend .grad { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #3a4258, #f0b354, #f05a4c); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13.5px; }
.kv b { font-variant-numeric: tabular-nums; }
.note { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.empty { color: var(--muted); font-size: 13.5px; padding: 10px 0; }

/* online rooms */
.code-big { text-align: center; font-size: 38px; font-weight: 800; letter-spacing: .22em; color: var(--accent-warm); margin: 4px 0 0; font-variant-numeric: tabular-nums; user-select: all; -webkit-user-select: all; }
.sheet input.text { width: 100%; }
.sheet input.code-in { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; text-align: center; }

/* ================================================================== the real table (2026-10-20)
   Everything sits on a wooden table (css/table.css, the shared kit). The board is a physical board: a dark printed
   edge with the 0-100 score track all the way round and the players' wooden markers on it; the map inside. */
.view.tbl-surface { position: absolute; color: var(--text); }
.board-wrap {
  --frame: 11px;
  background: var(--board-edge); border-radius: 5px; margin: 5px 6px;
  box-shadow: inset 0 0 0 1px rgba(255,235,190,.12), 0 2px 3px rgba(0,0,0,.5), 0 10px 26px rgba(0,0,0,.5);
}
.board-wrap svg.board {
  position: absolute; left: var(--frame); top: var(--frame); width: calc(100% - 2 * var(--frame)); height: calc(100% - 2 * var(--frame));
  background: radial-gradient(130% 100% at 50% 40%, #b3cdd2, var(--sea) 75%); border-radius: 1px;
  box-shadow: 0 0 0 1px #1c150e;
}
.track { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tr-edge { fill: none; stroke: #120d08; stroke-width: 1; }
.tr-cell { fill: #efe4c4; }
.tr-cell.odd { fill: #e2d4ac; }
.tr-cell.five { fill: #cdb67c; }
.tr-num { fill: #2b2116; font-family: Georgia, "Times New Roman", serif; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.track-marks { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.ttr-mk { position: absolute; left: 0; top: 0; transition: transform .8s cubic-bezier(.3,.7,.2,1); }
.fx-still .ttr-mk { transition: none; }
.zoom { right: calc(var(--frame) + 5px); bottom: calc(var(--frame) + 5px); background: rgba(246,239,220,.94); border-color: #a8956a; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.zoom button { color: var(--print-ink); }
.zoom button + button { border-top-color: #cdbd94; }
.zoom button:hover, .zoom button:active { background: #e9dcb8; }
.zoom [data-z="fit"] { color: #6b5d45; }
.zoom [data-z="fit"].lit { color: #b8352a; }
.board-tip { left: calc(var(--frame) + 6px); top: calc(var(--frame) + 6px); color: var(--print-ink); text-shadow: 0 0 3px #f6efd9, 0 0 2px #f6efd9; }
/* the hint, written on a slip of paper laid on the board */
.board-note {
  position: absolute; left: calc(var(--frame) + 6px); bottom: calc(var(--frame) + 6px); right: calc(var(--frame) + 56px); z-index: 4;
  background: #fbf6e6; color: var(--print-ink); border-radius: 3px; padding: 6px 9px; font-size: 13px; line-height: 1.35;
  box-shadow: 0 1px 1px rgba(0,0,0,.25), 0 6px 14px rgba(0,0,0,.35); transform: rotate(-.6deg); display: none; pointer-events: none;
}
.board-note.show { display: block; }
/* the companion and the lab keep their panel; it reads as a dark notepad beside the board */
#v-table .panel, #v-lab .panel, .tabletop:not(.game) .panel { background: var(--bg); }

/* ------------------------------------------------------------------ cards */
.ttr-card { --card-paper: #fbf8ef; --card-edge: rgba(0,0,0,.35); overflow: hidden; }
.ttr-card > svg { position: absolute; inset: 6%; width: 88%; height: 88%; border-radius: calc(var(--card-w) * .05); }
.ttr-back { --back: #24365c; --ink: rgba(236,204,128,.42); --back-frame: #f4efe2; }
.ttr-tback { --back: #8a5524; --ink: rgba(255,238,200,.32); --back-frame: #f4efe2; }
.tbl-mini.tbl-card { aspect-ratio: 44 / 67; }
.tbl-deck .tbl-badge { right: -5px; bottom: -5px; font-size: 10.5px; }
/* a face-up card refilled from the deck turns over */
.ttr-card.turn-up { animation: ttr-turnup .5s cubic-bezier(.3,.7,.3,1); transform-origin: 50% 50%; }
@keyframes ttr-turnup { 0% { transform: perspective(500px) rotateY(-90deg) scale(1.06); filter: brightness(.6); } 60% { transform: perspective(500px) rotateY(12deg) scale(1.03); } 100% { transform: none; } }
.fx-still .ttr-card.turn-up { animation: none; }

/* ------------------------------------------------------------------ the game table (Play) */
.tabletop.game { justify-content: space-between; }
.tabletop .rivals:empty, .tabletop .supply:empty, .tabletop .mine:empty { display: none; }
.tabletop.game .panel { flex: none; border: 0; padding: 4px 10px; overflow: visible; background: none; }
.tabletop.game .notes { display: none; }
.tabletop .status {
  background: rgba(14,10,6,.55); border-radius: 9px; padding: 3px 4px 3px 10px; min-height: 40px; color: #f3ecdc;
  box-shadow: inset 0 1px 0 rgba(255,230,180,.08);
}
.tabletop .status .st-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabletop .status .btn { min-height: 34px; background: rgba(250,244,228,.12); border-color: rgba(250,244,228,.25); color: #f6efdc; }
.tabletop .status .btn.primary { background: var(--accent); color: #0d1424; }
.notes-sheet .sec:first-child { margin-top: 10px; }

/* rivals: the far side of the table */
.rivals { display: flex; gap: 6px; padding: 6px 8px 0; flex: none; }
.seat {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 3px; align-items: stretch; cursor: pointer;
  border-radius: 8px; padding: 3px; transition: background .2s;
}
.seat:active { background: rgba(255,240,200,.08); }
.seat .tbl-plate, .me-seat .tbl-plate { display: flex; align-items: center; gap: 5px; padding: 1px 7px; font-size: 12px; line-height: 19px; }
.tbl-plate i { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.5), inset 0 1px 1px rgba(255,255,255,.4); }
.tbl-plate .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl-plate .sc { font-variant-numeric: tabular-nums; font-size: 13px; color: #ffe2a0; }
.seat.turn .tbl-plate, .me-seat.turn .tbl-plate { border-color: #f0c35a; box-shadow: 0 0 0 2px rgba(240,195,90,.5), 0 2px 4px rgba(0,0,0,.4); }
.seat-stuff { display: flex; align-items: flex-end; justify-content: space-between; gap: 3px; min-height: 22px; }
.seat-stuff b, .me-stuff b { font-size: 11px; font-weight: 700; color: #efe6d2; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px #000; line-height: 1; }
.backs { position: relative; display: inline-block; flex: none; }
.backs .tbl-card { --card-w: 11px; position: absolute; left: 0; bottom: 0; transform-origin: 50% 100%; transform: translate(var(--x), var(--y)) rotate(var(--r)); box-shadow: 0 1px 1px rgba(0,0,0,.4); }
.backs .tbl-card::after { display: none; }
.backs > b { position: absolute; right: -4px; bottom: -3px; z-index: 30; }
.tixb { position: relative; display: inline-flex; align-items: flex-end; gap: 2px; flex: none; }
.tixb .tbl-card { --card-w: 10px; transform: rotate(-80deg) translateX(3px); box-shadow: 1px 1px 0 #e8e2d2, 2px 2px 0 #b9b19d, 2px 3px 3px rgba(0,0,0,.45); }
.heap { display: inline-flex; align-items: flex-end; gap: 1px; flex: none; }
.heap svg { width: 24px; height: 18px; overflow: visible; }
.heap rect { fill: var(--piece); stroke: rgba(0,0,0,.55); stroke-width: .6; filter: drop-shadow(.5px 1px .6px rgba(0,0,0,.55)); }

/* the supply beside the board */
.supply { --card-w: min(41px, calc((100vw - 64px) / 8)); display: flex; align-items: flex-end; justify-content: center; gap: 5px; padding: 8px 6px 2px; flex: none; }
.supply .row5 { display: flex; gap: 4px; }
.supply .slot, .stk-btn { background: none; border: 0; padding: 0; display: block; color: inherit; }
.supply .slot { width: var(--card-w); transition: transform .12s; }
.supply .slot:active { transform: translateY(-3px) scale(.97); }
.supply .row5 .tbl-spot { flex: none; }
.stk-btn { width: var(--card-w); transition: transform .1s; }
.stk-btn:not(:disabled):active { transform: scale(.95); }
.stk-btn:disabled { cursor: not-allowed; }
.stk-btn:disabled .tbl-back { filter: saturate(.55) brightness(.8); }
.stk-btn .tbl-deck { display: block; }
.disc { margin-left: 3px; }
.disc .tbl-card { box-shadow: 0 1px 2px rgba(0,0,0,.45); }

/* my seat: plate and trains, my tickets in front of me, my hand held in a fan */
.mine {
  --card-w: 44px; flex: none; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "me tix" "hand hand";
  gap: 4px 8px; padding: 2px 8px 4px; align-items: center;
}
.me-seat { grid-area: me; display: flex; flex-direction: column; gap: 4px; min-width: 84px; }
.me-stuff { display: flex; align-items: center; gap: 6px; }
.me-stuff .heap svg { width: 30px; height: 22px; }
.st-btn { display: inline-flex; align-items: center; gap: 3px; min-height: 30px; padding: 2px 7px; border-radius: 7px; background: rgba(250,244,228,.1); border: 1px solid rgba(250,244,228,.25); font-size: 12px; font-weight: 700; color: #f3ecdc; }
.st-btn svg { width: 15px; height: 15px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.5)); }
.st-btn.on { border-color: var(--accent-warm); background: rgba(240,179,84,.25); }
.st-btn:disabled { opacity: .5; }
.mytix { grid-area: tix; display: flex; gap: 6px; overflow-x: auto; align-items: center; padding: 3px 2px 5px; scrollbar-width: none; min-width: 0; }
.mytix::-webkit-scrollbar { display: none; }
.mytix .empty { color: #d9cdb2; font-size: 12.5px; padding: 0; }
.mytix .q { border-color: rgba(250,244,228,.35); color: #e9dfc8; }
.hand { grid-area: hand; }
.mine .tbl-fan > .tbl-card { cursor: default; }
/* held cards of one colour are bunched: more card edges show above the face */
.ttr-card.held { overflow: visible; }
.ttr-card.held.p2 { box-shadow: 0 -2.5px 0 -.5px #ece6d6, 0 -3px 0 -.5px rgba(0,0,0,.25), 0 2px 6px rgba(0,0,0,.35); }
.ttr-card.held.p3 { box-shadow: 0 -2.5px 0 -.5px #ece6d6, 0 -3px 0 -.5px rgba(0,0,0,.25), 0 -5px 0 -1px #ddd5c0, 0 -5.5px 0 -1px rgba(0,0,0,.25), 0 2px 6px rgba(0,0,0,.35); }
.ttr-card .idx {
  position: absolute; left: 3%; top: 3%; z-index: 2; min-width: 16px; padding: 0 3px; border-radius: 4px; text-align: center;
  background: #fbf8ef; color: #1b1b1b; font: 800 12px/16px Georgia, "Times New Roman", serif; box-shadow: 0 0 0 1px rgba(0,0,0,.3);
}
/* a destination ticket: a cream card lying sideways, the two places, the points, a little map */
.tkt {
  position: relative; flex: none; width: 118px; height: 50px; padding: 4px 26px 4px 6px; border-radius: 5px; border: 1px solid rgba(0,0,0,.35);
  background: linear-gradient(135deg, rgba(255,255,255,.4), transparent 45%), #f4ead0; color: var(--print-ink); text-align: left; overflow: hidden;
  box-shadow: 0 1px 1px rgba(0,0,0,.3), 0 3px 7px rgba(0,0,0,.3); transition: transform .15s, box-shadow .15s;
}
.tkt .tk-map { position: absolute; right: 2px; bottom: 2px; width: 46px; height: 32px; opacity: .9; }
.tkt .tk-map use { fill: #d9c99c; stroke: #a8946a; stroke-width: 3; }
.tkt .tk-map line { stroke: #b8352a; stroke-linecap: round; }
.tkt .tk-map circle { fill: #b8352a; stroke: #2b2116; stroke-width: 3; }
.tkt .tk-c { position: relative; display: block; font: 700 10.5px/1.2 Georgia, "Times New Roman", serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tkt .tk-p { position: absolute; right: 3px; top: 3px; min-width: 20px; height: 20px; padding: 0 3px; border-radius: 10px; background: #2b2116; color: #fbf3dc; font: 800 11.5px/20px system-ui, sans-serif; text-align: center; }
.tkt { display: flex; flex-direction: column; justify-content: flex-start; }
.tkt .tk-ch { position: absolute; right: 4px; bottom: 3px; z-index: 1; font: 800 11px/1 system-ui, sans-serif; text-shadow: 0 0 2px #f4ead0, 0 0 2px #f4ead0; }
.tkt .tk-ch.ok { color: #1d7a45; font-size: 14px; }
.tkt .tk-ch.bad { color: #b3261e; font-size: 14px; }
.tkt.done { background: linear-gradient(135deg, rgba(255,255,255,.4), transparent 45%), #e2ecd2; }
.tkt.dead { background: linear-gradient(135deg, rgba(255,255,255,.3), transparent 45%), #ead6cb; }
.tkt.long .tk-p { background: #8a5524; }
.tkt.sel { transform: translateY(-3px); box-shadow: 0 0 0 2px var(--accent-warm), 0 8px 14px rgba(0,0,0,.4); }

/* phone held sideways: board on the left, the rest of the table in a column on the right */
@media (max-width: 899px) and (orientation: landscape) {
  .view.active.tabletop.game { display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: auto auto auto minmax(0, 1fr); grid-template-areas: "board riv" "board sup" "board panel" "board mine"; }
  .tabletop.game .board-wrap { grid-area: board; min-height: 0; }
  .tabletop.game .rivals { grid-area: riv; }
  .tabletop.game .supply { grid-area: sup; --card-w: 30px; padding-top: 6px; }
  .tabletop.game .panel { grid-area: panel; }
  .tabletop.game .mine { grid-area: mine; --card-w: 32px; align-self: end; overflow: hidden; }
  .tabletop.game .tkt { width: 100px; height: 40px; }
  .tabletop.game .tkt .tk-map { display: none; }
}

/* laptop: rivals across the far side, the board in the middle with the supply beside it, my seat at the near edge,
   and the helpers in a slim side panel */
@media (min-width: 900px) {
  .board-wrap { --frame: 18px; margin: 6px 10px; }
  .view.active.tabletop.game {
    display: grid; grid-template-columns: minmax(0, 1fr) auto 330px; grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "riv riv side" "board sup side" "mine mine side";
  }
  .tabletop.game .board-wrap { grid-area: board; min-height: 0; }
  .tabletop.game .rivals { grid-area: riv; justify-content: center; gap: 18px; padding: 10px 16px 2px; }
  .tabletop.game .seat { flex: 0 1 210px; padding: 6px 8px; background: rgba(0,0,0,.14); border-radius: 12px; }
  .tabletop.game .seat .tbl-plate { font-size: 13.5px; line-height: 22px; }
  .tabletop.game .seat-stuff { min-height: 34px; padding: 0 4px; }
  .tabletop.game .backs .tbl-card { --card-w: 19px; }
  .tabletop.game .tixb .tbl-card { --card-w: 16px; }
  .tabletop.game .seat-stuff b, .tabletop.game .me-stuff b { font-size: 12.5px; }
  .tabletop.game .heap svg { width: 36px; height: 30px; }
  .tabletop.game .supply {
    grid-area: sup; --card-w: 62px; display: grid; grid-template-columns: repeat(2, var(--card-w)); gap: 12px 10px;
    align-content: center; padding: 14px 14px 6px 4px;
  }
  .tabletop.game .supply .row5 { display: contents; }
  .tabletop.game #p-tix { order: 1; }
  .tabletop.game #p-deck { order: 2; }
  .tabletop.game .supply .slot, .tabletop.game .supply .row5 .tbl-spot { order: 3; }
  .tabletop.game .disc { order: 9; margin: 0; }
  .tabletop.game .panel {
    grid-area: side; width: auto; border-left: 1px solid var(--line); background: var(--bg); padding: 14px 16px 18px; overflow-y: auto;
  }
  .tabletop.game .notes { display: block; margin-top: 12px; }
  .tabletop.game .notes-btn { display: none; }
  .tabletop .status { background: none; padding: 0; color: var(--text); box-shadow: none; }
  .tabletop .status .btn { background: var(--card); border-color: var(--line); color: var(--text); }
  .tabletop .status .btn.primary { background: var(--accent); color: #0d1424; }
  .tabletop.game .mine { grid-area: mine; --card-w: 64px; grid-template-columns: auto minmax(0, 1fr) minmax(0, 40%); grid-template-areas: "me hand tix"; padding: 0 16px 10px; gap: 16px; align-items: end; }
  .tabletop.game .me-seat { min-width: 130px; padding-bottom: 6px; }
  .tabletop.game .me-stuff .heap svg { width: 46px; height: 36px; }
  .tabletop.game .mytix { flex-wrap: wrap; overflow: visible; justify-content: flex-start; align-content: flex-end; padding-bottom: 6px; }
  .tabletop.game .tkt { width: 150px; height: 62px; padding-right: 30px; }
  .tabletop.game .tkt .tk-c { font-size: 12.5px; }
  .tabletop.game .tkt .tk-map { width: 58px; height: 40px; }
  .tabletop.game .ttr-card .idx { font-size: 14px; line-height: 19px; min-width: 19px; }
}

/* review pass: printed spaces read as ink on the board, so the plastic trains on claimed routes stand out */
.route:not(.claimed) .car { fill-opacity: .8; }
.route.claimed .casing { stroke: rgba(10,8,5,.92); }
/* phone: a smaller zoom control in the board's corner, the ticket deck set apart from the face-up row */
@media (max-width: 899px) {
  .zoom { border-radius: 9px; background: rgba(246,239,220,.86); }
  .zoom button { width: 32px; height: 30px; font-size: 16px; }
  .supply #p-tix { margin-right: 5px; }
}
/* second review pass: up to three tickets fit side by side (names shorten), the chance is a small pencilled note,
   and the narrowest phones get a smaller zoom control and name plates */
@media (max-width: 899px) {
  .mytix .tkt { flex: 0 1 118px; min-width: 86px; }
  .tkt .tk-ch:not(.ok):not(.bad) { font: italic 700 10px/1 Georgia, "Times New Roman", serif; }
}
@media (max-width: 360px), (max-width: 899px) and (orientation: landscape) {
  .seat .tbl-plate { padding: 1px 5px; gap: 4px; font-size: 11px; }
  .seat .tbl-plate .sc { font-size: 12px; }
}
@media (max-width: 360px) {
  .zoom button { width: 28px; height: 26px; font-size: 15px; }
}
/* edge pass: four rivals on a phone (5 players) get smaller fans, ticket backs and heaps so every seat fits across */
@media (max-width: 899px) {
  .rivals.tight { gap: 3px; padding: 6px 5px 0; }
  .rivals.tight .seat { padding: 3px 1px; }
  .rivals.tight .seat-stuff { gap: 2px; }
  .rivals.tight .backs > b { right: -3px; }
  .rivals.tight .tixb .tbl-card { --card-w: 8px; }
  .rivals.tight .heap svg { width: 15px; height: 12px; }
}
/* visibility pass: the zoom control sits in whichever corner of the map is free (board.js picks it), so the map can
   use the full width. In auto only + shows (− and the fit button do nothing there); zoomed in, all three show, growing
   away from the corner so the + never moves under the finger. */
.zoom.auto [data-z="out"], .zoom.auto:not(.crop) [data-z="fit"] { display: none; }
.zoom.c-tr, .zoom.c-tl { top: calc(var(--frame) + 5px); bottom: auto; }
.zoom.c-bl, .zoom.c-tl { left: calc(var(--frame) + 5px); right: auto; }
.zoom.c-br, .zoom.c-bl { flex-direction: column-reverse; }
.zoom.c-br button + button, .zoom.c-bl button + button { border-top: 0; border-bottom: 1px solid #cdbd94; }

/* phone on its side: Table and Lab put the board on the left and the panel on the right, like Play (on top, the
   board got 127 px of height) */
@media (max-width: 899px) and (orientation: landscape) {
  #v-table.active, #v-lab.active, #v-play.active:not(.game) { flex-direction: row; align-items: stretch; }
  #v-table .board-wrap, #v-lab .board-wrap, #v-play:not(.game) .board-wrap { flex: none; }
  #v-table .panel, #v-lab .panel, #v-play:not(.game) .panel { flex: 1 0 280px; border-top: 0; border-left: 1px solid var(--line); }
  /* the side column is narrow: the player chips wrap onto a second row instead of squeezing names away */
  #v-table .players, #v-lab .players { flex-wrap: wrap; overflow: visible; }
  #v-table .players .pchip, #v-lab .players .pchip { flex: 1 1 96px; }
  /* ...and the Table's status line keeps its words on one line, the buttons drop below (as on narrow phones) */
  #v-table .status { flex-wrap: wrap; row-gap: 6px; }
  #v-table .status .grow { flex: 1 1 150px; }
}

/* narrow phones: the Table's status line keeps its words on one line (the buttons drop below), and with 4-5 players
   each chip shows the name on top with the score and trains under it */
@media (max-width: 380px) {
  #v-table .status { flex-wrap: wrap; row-gap: 6px; }
  #v-table .status .grow { flex: 1 1 150px; }
  .players:has(> .pchip:nth-child(4)) .pchip { padding: 5px 6px; grid-template-columns: auto minmax(0, 1fr); column-gap: 4px; }
  .players:has(> .pchip:nth-child(4)) .pchip .nm { grid-column: 1 / -1; grid-row: 1; }
  .players:has(> .pchip:nth-child(4)) .pchip .sc { grid-column: 1; grid-row: 2; font-size: 16px; }
  .players:has(> .pchip:nth-child(4)) .pchip .mt { grid-column: 2; grid-row: 2; align-self: center; }
}

/* visibility round 2 (2026-10-20): the map gets the space. Play's supply and panel share a wrapper that is invisible
   on a phone and is the right-hand column on a laptop. */
.deal { display: contents; }
/* phone: each rival is one chip with the counts folded in (cards, tickets, trains); the face-up row is a quarter
   shorter */
.seat.chip .tbl-plate { flex-wrap: wrap; row-gap: 0; column-gap: 4px; line-height: 16px; padding-top: 1px; padding-bottom: 1px; }
.seat.chip .cnt { line-height: 14px; }
/* the default view is zoomed in: the fit button (whole map) is a live control, not a dimmed one */
.zoom.crop [data-z="fit"] { color: var(--print-ink); opacity: 1; }
.seat.chip .cnt { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; font-size: 10.5px; font-weight: 700; color: #efe6d2; white-space: nowrap; font-variant-numeric: tabular-nums; }
.seat.chip .ic { display: inline-block; flex: none; border-radius: 1.5px; box-shadow: 0 0 0 1px rgba(0,0,0,.45); }
.seat.chip .ic + .ic, .seat.chip .cnt .ic:not(:first-child) { margin-left: 3px; }
.seat.chip .ic-c { width: 6px; height: 9px; background: #24365c; border: 1px solid #f4efe2; }
.seat.chip .ic-t { width: 9px; height: 6px; background: #8a5524; border: 1px solid #f4efe2; }
.seat.chip .ic-r { width: 10px; height: 4px; }
@media (max-width: 899px) {
  .supply { --card-w: min(30px, calc((100vw - 64px) / 10.6)); }
  .rivals.tight .seat.chip { padding: 0; }
  .rivals.tight .seat.chip .tbl-plate { padding: 1px 4px; }
  /* the hand tucks up under the tickets: no empty band between them */
  .tabletop.game .mine { row-gap: 0; padding-bottom: 2px; }
  .tabletop.game .mytix { padding-bottom: 2px; }
}
/* laptop: the board between the rivals and my seat, as tall as that leaves; deck, face-up cards and ticket deck at the
   top of the right-hand column, the helpers under them */
@media (min-width: 900px) {
  .view.active.tabletop.game {
    grid-template-columns: minmax(0, 1fr) 290px; grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "riv deal" "board deal" "mine deal";
  }
  .tabletop.game .deal { grid-area: deal; display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); }
  .tabletop.game .supply {
    grid-area: auto; --card-w: 47px; grid-template-columns: repeat(5, var(--card-w)); gap: 10px 7px; padding: 12px 10px 10px;
    justify-content: center; align-content: start;
  }
  .tabletop.game #p-tix { order: 1; }
  .tabletop.game #p-deck { order: 2; }
  .tabletop.game .disc { order: 3; grid-column: 3 / span 3; align-self: center; }
  .tabletop.game .supply .slot, .tabletop.game .supply .row5 .tbl-spot { order: 4; }
  .tabletop.game .panel { grid-area: auto; flex: 1 1 auto; min-height: 0; border-left: 0; }
  /* rivals: the plate and the cards / tickets / trains on one line */
  .tabletop.game .rivals { padding: 8px 16px 0; }
  .tabletop.game .rivals { gap: 12px; }
  .tabletop.game .seat.chip { flex: 0 1 250px; padding: 0; background: none; }
  .tabletop.game .seat.chip .tbl-plate { flex-wrap: nowrap; line-height: 24px; column-gap: 6px; }
  .tabletop.game .seat.chip .cnt { font-size: 12.5px; gap: 3px; }
  .tabletop.game .seat.chip .ic-c { width: 8px; height: 12px; }
  .tabletop.game .seat.chip .ic-t { width: 12px; height: 8px; }
  .tabletop.game .seat.chip .ic-r { width: 13px; height: 5px; }
  /* my seat: plate, hand and tickets in one row along the near edge */
  .tabletop.game .mine { --card-w: 50px; padding: 0 16px 4px; grid-template-columns: auto minmax(230px, 1fr) minmax(0, max-content); }
  .tabletop.game .mytix { flex-wrap: nowrap; overflow-x: auto; align-content: normal; }
  .tabletop.game .tkt { width: 136px; height: 56px; }
  .tabletop.game .tkt .tk-map { width: 50px; height: 34px; }
}
/* shorter laptop screens (1280x800): a slightly smaller hand so the board keeps its height */
@media (min-width: 900px) and (max-height: 840px) {
  .tabletop.game .mine { --card-w: 42px; }
  .tabletop.game .rivals { padding-top: 4px; }
  .tabletop.game .tkt { height: 48px; }
  .tabletop.game .mytix { padding-bottom: 2px; }
}
/* narrowest phones (and a phone on its side): the counts tighten so a fifth player's name and numbers are not clipped */
@media (max-width: 360px), (max-width: 899px) and (orientation: landscape) {
  .seat.chip .cnt { font-size: 9.5px; gap: 1px; letter-spacing: -.2px; }
  .seat.chip .cnt .ic:not(:first-child) { margin-left: 2px; }
}
/* phone on its side: the side column is narrow, so the rival chips go two to a row instead of shortening names */
@media (max-width: 899px) and (orientation: landscape) {
  .tabletop.game .rivals { flex-wrap: wrap; row-gap: 4px; }
  .tabletop.game .rivals .seat.chip { flex: 1 1 40%; min-width: 0; }
}
