/* Trackbound table. The map fills the window beside a side column (players, your
   tickets, log); your cards and the face-up row sit under the map. */


#view-trackbound:not([hidden]) { display: block; }

html:has(body.tb-play),
body.tb-play { overflow: hidden; }
body.tb-play .shell {
  max-width: none; height: 100vh; height: 100dvh; padding: 8px 12px; overflow: hidden;
}
body.tb-play .top { padding: 0 2px 6px; margin-bottom: 8px; }
body.tb-play #view-trackbound:not([hidden]) {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
}
body.tb-play #trackbound-root { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
body.tb-play .tb-play {
  flex: 1; min-height: 0; min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 300px);
  grid-template-rows: minmax(0, 1fr);
  gap: 10px;
}
body.tb-play .tb-felt {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden; padding: 8px 10px;
}
body.tb-play .tb-felt > .panel-head { flex: 0 0 auto; margin-bottom: 4px; }
body.tb-play .tb-side {
  min-width: 0; min-height: 0; overflow: hidden auto;
  display: flex; flex-direction: column; gap: 6px; padding: 14px;
}
body.tb-play .tb-play:not(:has(.tb-side .fold:not(.floated))) { grid-template-columns: minmax(0, 1fr); }
body.tb-play .tb-side:not(:has(.fold:not(.floated))) { display: none; }

.tb-prompt { flex: 0 0 auto; margin: 0 0 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.tb-your-turn {
  display: inline-block; padding: 1px 10px; border-radius: 999px;
  background: var(--turn-green); color: #fff; font-weight: 750;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}
.tb-your-turn.start { animation: tb-turn-pop 0.5s ease-out; }
/* Your turn, as in Skip-Bo: the table is framed in your colour, and the frame flashes when the turn begins. */
.tb-felt.mine {
  box-shadow: 0 0 0 2px var(--turn-green),
    0 0 22px color-mix(in srgb, var(--turn-green) 45%, transparent);
}
.tb-felt { position: relative; }
.tb-felt::after {
  content: ""; position: absolute; inset: 0; z-index: 4; border-radius: inherit; pointer-events: none;
  opacity: 0; will-change: opacity; box-shadow: inset 0 0 0 4px var(--turn-green), inset 0 0 36px color-mix(in srgb, var(--turn-green) 70%, transparent);
}
.tb-felt.mine.start::after { animation: turn-glow 0.9s ease-out 2; }
@keyframes tb-turn-pop { from { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.12); } }
.tb-last {
  display: inline-block; padding: 2px 12px; border-radius: 999px;
  background: #c26a00; color: #fff; font-weight: 800;
}
/* the last round: an amber frame round the map, the same amber as the Last round notice */
.tb-felt.last-round .tb-map { outline: 3px solid #c26a00; outline-offset: 2px; }

/* ------------------------------------------------------------------ map */

.tb-board { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
.tb-map { flex: 1; min-width: 0; min-height: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.tb-map.zoomed { cursor: grab; }
.tb-map.panning { cursor: grabbing; }
.tb-zoom { position: absolute; right: 6px; bottom: 6px; display: flex; flex-direction: column; gap: 4px; }
.tb-zoom button { width: 30px; min-width: 0; height: 30px; padding: 0; font-weight: 700; background: var(--surface); }

/* Board styles (html[data-rails], see styles.js). Every colour and shape of the board and the
   cards is a --tb-* setting; Classic sets them here, each style below sets its own. A sample
   on the styles page carries data-rails itself, so it shows its own style whatever the page uses.
   The board is the same in both themes, like the Skip-Bo felt. */
:root, .rails-face[data-rails="classic"] {
  --tb-goal-label: #ffe7a8;
  --tb-land: #2e424e; --tb-coast: #4d6a7c; --tb-grid: rgba(255, 255, 255, 0.04);
  --tb-pink: #e46fb5; --tb-white: #eeeae4; --tb-blue: #2f7de1; --tb-yellow: #f2cc3a; --tb-orange: #f08a2a;
  --tb-black: #2c2a2a; --tb-red: #d8383a; --tb-green: #3aa856; --tb-gray: #9a9a9a;
  --tb-sea: #142029; --tb-sea-edge: rgba(255, 255, 255, 0.12);
  --tb-space-edge: #10161b; --tb-space-fade: 0.78; --tb-space-rx: 1.6px; --tb-tunnel-edge: #f2ebe4;
  --tb-train-edge: #0b0f12; --tb-train-cap: round; --tb-shine: rgba(255, 255, 255, 0.5);
  --tb-dot: #f2ebe4; --tb-dot-edge: #af3d47;
  --tb-label: #f6f1ea; --tb-label-halo: #182730; --tb-label-font: 600 8.5px var(--font); --tb-label-case: none;
  --tb-render: auto;
  --tb-card-radius: 6px; --tb-card-border: 2px solid rgba(255, 255, 255, 0.75);
  --tb-card-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.tb-sea { fill: var(--tb-sea); stroke: var(--tb-sea-edge); stroke-width: 1; }
.tb-land-layer { pointer-events: none; }
.tb-land :is(circle, line) { fill: var(--tb-land); stroke: var(--tb-land); stroke-linecap: round; }
.tb-coast :is(circle, line) { fill: var(--tb-coast); stroke: var(--tb-coast); stroke-linecap: round; }
.tb-coastline { fill: var(--tb-land); stroke: var(--tb-coast); stroke-width: 1.6; stroke-linejoin: round; }
.tb-riverbank, .tb-river { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.tb-riverbank { stroke: var(--tb-coast); stroke-width: 13; }
.tb-river { stroke: var(--tb-sea); stroke-width: 10; }
.tb-grid { fill: none; stroke: var(--tb-grid); stroke-width: 0.6; }
/* Open track is printed on the map: a touch faded, so the trains on top stand out. */
.tb-space { stroke: var(--tb-space-edge); stroke-width: 0.9; opacity: var(--tb-space-fade); rx: var(--tb-space-rx); shape-rendering: var(--tb-render); }
.tb-route:is(.can, .path, .trying) .tb-space { opacity: 1; }
.tb-route.tunnel .tb-space { stroke: var(--tb-tunnel-edge); stroke-width: 1.3; stroke-dasharray: 2.2 1.6; }
.tb-space.loco { opacity: 1; stroke: #fff; stroke-width: 1.1; }
/* A claimed route is a game piece on the map: bold, outlined, shadowed, with a shine and car joints. */
.tb-train-shadow { stroke: rgba(0, 0, 0, 0.55); stroke-width: 11.5; stroke-linecap: var(--tb-train-cap); }
.tb-train-case { stroke: var(--tb-train-edge); stroke-width: 11; stroke-linecap: var(--tb-train-cap); }
.tb-train { stroke: var(--own); stroke-width: 8.2; stroke-linecap: var(--tb-train-cap); }
.tb-shine { stroke: var(--tb-shine); stroke-width: 1.5; stroke-linecap: round; pointer-events: none; }
.tb-joint { fill: rgba(0, 0, 0, 0.55); pointer-events: none; }
/* One player's trains lit from the Players panel; everything else steps back. */
.tb-map.spotting .tb-routes { opacity: 0.35; }
.tb-map.spotting .tb-trains > .tb-route:not(.spot) { opacity: 0.15; }
.tb-player[data-tb] { cursor: pointer; }
.tb-player[data-tb]:hover, .tb-player.spot { background: color-mix(in srgb, var(--you) 16%, transparent); }
.tb-route polyline { fill: none; stroke-linejoin: round; }
.tb-hit { stroke: transparent; stroke-width: 12; stroke-linecap: round; }
.tb-route.can { cursor: pointer; }
.tb-route.can .tb-space { stroke: var(--pending); stroke-width: 1.5; stroke-dasharray: none; }
.tb-route.can:hover .tb-space, .tb-route.can:focus .tb-space { stroke: #fff; stroke-width: 2.2; }
.tb-route.can:hover .tb-hit { stroke: rgba(255, 255, 255, 0.12); }
/* A clicked ticket: its cheapest way stays bright, the rest of the map steps back. */
.tb-map.focusing :is(.tb-routes, .tb-trains) > .tb-route:not(.path) { opacity: 0.22; }
.tb-route.path .tb-space { stroke: #fff; stroke-width: 2; stroke-dasharray: none; }
.tb-route.path .tb-train-case { stroke: #ffe7a8; }
.tb-route.trying .tb-space { stroke: var(--pending); stroke-width: 2.4; animation: tb-pulse 1s ease-in-out infinite alternate; }
@keyframes tb-pulse { to { stroke: #fff; } }

.tb-dot { fill: var(--tb-dot); stroke: var(--tb-dot-edge); stroke-width: 2; shape-rendering: var(--tb-render); }
.tb-stops { pointer-events: none; }
.tb-stop-dot { fill: var(--tb-dot); stroke: var(--tb-dot-edge); stroke-width: 1.1; }
.tb-stop-label {
  font: var(--tb-label-font); font-size: 5.6px; font-weight: 500; text-transform: var(--tb-label-case); fill: var(--tb-label);
  opacity: 0.85; paint-order: stroke; stroke: var(--tb-label-halo); stroke-width: 1.8px; stroke-linejoin: round;
}
.tb-label {
  font: var(--tb-label-font); text-transform: var(--tb-label-case); fill: var(--tb-label); pointer-events: none;
  paint-order: stroke; stroke: var(--tb-label-halo); stroke-width: 2.6px; stroke-linejoin: round;
}
.tb-city.goal .tb-dot { fill: var(--pending); stroke: #fff; }
.tb-city.goal .tb-label { fill: var(--tb-goal-label); }
.tb-city.focus .tb-dot { fill: #fff; stroke: var(--pending); stroke-width: 3; }
.tb-city.focus .tb-label { fill: #fff; font-weight: 800; }
.tb-city.can { cursor: pointer; }
.tb-city.can:hover .tb-dot { stroke: var(--pending); stroke-width: 3; }
.tb-station { fill: none; stroke: var(--own); stroke-width: 3; }

/* ------------------------------------------------------------------ cards */

.tb-tray {
  flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 8px 20px; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 6px;
}
.tb-hand, .tb-market { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tb-cap { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.tb-cards { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.tb-card {
  position: relative; width: 57px; height: 80px; min-width: 0; padding: 0; border-radius: var(--tb-card-radius);
  background: var(--c); border: var(--tb-card-border); box-shadow: var(--tb-card-shadow);
  display: grid; place-items: center;
}
.tb-card-art { width: 42px; height: 25px; overflow: visible; }
.tb-card-art :is(rect, circle) { fill: rgba(255, 255, 255, 0.92); stroke: rgba(0, 0, 0, 0.6); stroke-width: 1; }
.tb-card.loco .tb-card-art { width: 45px; height: 27px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5)); }
.tb-card.loco { background: linear-gradient(135deg, #d8383a, #f08a2a, #f2cc3a, #3aa856, #2f7de1, #b05bd8); }
.tb-n {
  position: absolute; right: -7px; top: -8px; min-width: 24px; height: 24px; padding: 0 6px;
  border-radius: 999px; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  font: 700 0.9rem/22px var(--font); text-align: center; font-variant-numeric: tabular-nums;
}
button.tb-card { cursor: pointer; transition: transform 0.12s; }
button.tb-card.can:hover, button.tb-card.can:focus-visible { transform: translateY(-3px); outline: 2px solid var(--pending); outline-offset: 2px; }
/* The two piles look like what is in them: a face-down stack of train cards, a destination ticket. */
.tb-market .tb-cards { align-items: flex-start; }
.tb-pile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; padding: 0;
  background: none; border: 0; color: var(--text); font: inherit;
}
.tb-pile-top { position: relative; display: block; }
.tb-pile-art {
  display: grid; place-items: center; height: 80px; border-radius: var(--tb-card-radius);
  border: 2px solid rgba(255, 255, 255, 0.75); box-sizing: border-box;
}
.tb-pile-deck {
  width: 57px; background: repeating-linear-gradient(45deg, #2b2f3a 0 6px, #343949 6px 12px);
  box-shadow: 3px 3px 0 -1px #20232c, 3px 3px 0 0 rgba(255, 255, 255, 0.5), 6px 6px 0 -1px #20232c, 6px 6px 0 0 rgba(255, 255, 255, 0.35);
}
.tb-pile-ticket {
  width: 80px; background: #f3e6c4; border-color: #f7f0de;
  /* a perforated stub on the left, like a real ticket */
  background-image: radial-gradient(circle at 0 50%, transparent 5px, #f3e6c4 5.5px),
    repeating-linear-gradient(to bottom, #b89a63 0 4px, transparent 4px 8px);
  background-size: 100% 100%, 1.5px 100%; background-position: 0 0, 18px 0; background-repeat: no-repeat;
  box-shadow: 3px 3px 0 -1px #d9c69a, 3px 3px 0 0 rgba(0, 0, 0, 0.25);
}
.tb-ticket-art { width: 48px; height: 24px; margin-left: 14px; }
.tb-pile-name { font-size: 0.72rem; line-height: 1.15; color: var(--muted); text-align: center; max-width: 84px; hyphens: manual; }
button.tb-pile { cursor: pointer; }
button.tb-pile .tb-pile-art { outline: 3px solid var(--pending); outline-offset: 2px; }
button.tb-pile:hover .tb-pile-art, button.tb-pile:focus-visible .tb-pile-art { transform: translateY(-3px); }
button.tb-pile .tb-pile-name { color: var(--text); font-weight: 650; }
.tb-new-tickets { border-color: var(--pending); font-weight: 700; }

/* ------------------------------------------------------------------ side */

.tb-players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tb-player { padding: 4px 6px 4px 8px; border-radius: 6px; border-left: 3px solid transparent; min-width: 0; }
.tb-player.turn { border-left-color: var(--you, var(--orange)); background: var(--accent-faint); }
.tb-total { margin-left: auto; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.tb-stats { margin-top: 1px; line-height: 1.3; }
.tb-who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tb-who .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tb-seat { display: flex; align-items: center; gap: 8px; min-width: 0; }

.tb-tickets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 0.84rem; }
.tb-tickets li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; min-width: 0; padding: 2px 6px; border-radius: 6px;
  border-left: 3px solid var(--border);
}
.tb-tickets li[data-tb] { cursor: pointer; }
.tb-tickets li[data-tb]:hover, .tb-tickets li.focus { background: var(--accent-faint); }
.tb-tickets li.done { border-left-color: var(--found); color: var(--muted); }
.tb-tickets li.missed, .tb-tickets li.blocked { border-left-color: var(--missing); }
li.blocked .tb-mark { color: var(--missing); font-weight: 800; }
.tb-city.cut .tb-dot { stroke: var(--missing); stroke-width: 3.2; }
.tb-all-open { margin-top: 6px; }
.tb-all-open.on { background: var(--accent-faint); border-color: var(--accent-border-strong); }
.tb-tickets .clip { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-tickets .num, .tb-offer .num { font-variant-numeric: tabular-nums; }
.tb-need { flex-basis: 100%; padding-left: calc(1em + 6px); font-size: 0.75rem; color: var(--muted); }
.tb-mark { width: 1em; text-align: center; flex: 0 0 auto; }
li.done .tb-mark { color: var(--found); }
li.missed .tb-mark { color: var(--missing); }
.tb-long {
  flex: 0 0 auto; font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0 5px; border-radius: 999px; background: color-mix(in srgb, var(--pending) 25%, transparent); color: var(--text);
}
.tb-key { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; }
/* Each entry is a small box: the sample on top, the explanation under it. */
.tb-key li {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); line-height: 1.35;
}
.tb-key li.tb-key-head {
  padding: 0; border: 0; background: none;
  margin-top: 6px; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
}
.tb-key li.tb-key-head:first-child { margin-top: 0; }
.tb-key li.tb-key-points { display: block; }
.tb-key-art .tb-label { display: none; }
.tb-key-art { flex: 0 0 auto; width: 96px; height: 26px; border-radius: 4px; background: var(--tb-sea); padding: 1px 2px; }
.tb-final { margin-top: 10px; }
.tb-win-tickets summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); margin: 4px 0 2px; }
.tb-win-tickets .tb-final { margin-top: 6px; }
.tb-final > b { display: block; font-size: 0.82rem; margin-bottom: 2px; }
.tb-log {
  list-style: none; margin: 0; padding: 0; font-size: 0.82rem; color: var(--muted);
}
.tb-log li {
  border-left: 3px solid var(--border); padding: 1px 0 1px 8px; margin-bottom: 3px;
  overflow-wrap: anywhere; min-width: 0;
}

/* ------------------------------------------------------------------ dialogs */

.tb-dialog .cc-card { width: min(460px, 94vw); }
.tb-dialog .cc-count { font-family: inherit; }
.tb-offers { display: flex; flex-direction: column; gap: 4px; }
.tb-offer {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--border); cursor: pointer; min-width: 0;
}
.tb-offer:hover { background: var(--accent-faint); }
.tb-offer .clip { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-ways { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow: auto; }
.tb-way { justify-content: flex-start; text-align: left; }
.tb-chips { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.tb-chip { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.tb-chip i {
  width: 12px; height: 16px; border-radius: 3px; background: var(--c);
  border: 1px solid rgba(255, 255, 255, 0.7); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.tb-chip.loco i { background: linear-gradient(135deg, #d8383a, #f2cc3a, #3aa856, #2f7de1); }

/* ------------------------------------------------------------------ lobby page */

.tb-form { max-width: 280px; margin-top: 12px; }
.tb-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tb-rules { margin: 0 0 8px; max-width: 62rem; }

/* Phones: the map on top, then cards, then the side panels; the page scrolls. */
@media (max-width: 720px) {
  html:has(body.tb-play), body.tb-play { overflow: auto; }
  body.tb-play .shell { height: auto; overflow: visible; }
  body.tb-play .tb-play { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
  body.tb-play .tb-felt { overflow: visible; }
  .tb-board { flex: none; aspect-ratio: var(--tb-ar, 3 / 2); max-height: 70vh; }
  body.tb-play .tb-side { overflow: visible; }
  .tb-card { width: 44px; height: 62px; }
  .tb-card-art { width: 32px; height: 19px; }
  .tb-pile-art { height: 62px; }
  .tb-pile-deck { width: 44px; }
  .tb-pile-ticket { width: 64px; }
  .tb-ticket-art { width: 38px; margin-left: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .tb-your-turn.start, .tb-felt.mine.start::after, .tb-route.trying .tb-space { animation: none; }
  button.tb-card { transition: none; }
}

/* ------------------------------------------------------------------ board styles */

/* Vintage map: parchment, sepia ink, serif names; muted inks for the routes. */
html[data-rails="vintage"], .rails-face[data-rails="vintage"] {
  --tb-goal-label: #9a3d0c;
  --tb-land: #eadfc4; --tb-coast: #8a6a45; --tb-grid: rgba(90, 70, 45, 0.18);
  --tb-pink: #b8708e; --tb-white: #f7f0de; --tb-blue: #3d5f8c; --tb-yellow: #d1a73f; --tb-orange: #c27434;
  --tb-black: #3b3229; --tb-red: #a9443a; --tb-green: #557d45; --tb-gray: #a39b88;
  --tb-sea: #c9d8d2; --tb-sea-edge: #8a6a45; --tb-space-edge: #4a3826; --tb-space-fade: 0.92; --tb-tunnel-edge: #4a3826;
  --tb-train-edge: #2e2117; --tb-shine: rgba(255, 255, 255, 0.35);
  --tb-dot: #f7f0de; --tb-dot-edge: #7a2e26;
  --tb-label: #3b2a1c; --tb-label-halo: #eadfc4; --tb-label-font: italic 700 9px Georgia, "Times New Roman", serif;
  --tb-card-radius: 4px; --tb-card-border: 2px solid #f7f0de;
  --tb-card-shadow: 0 2px 4px rgba(60, 40, 20, 0.45), inset 0 0 0 1px #4a3826;
}

/* Metro: a transit diagram. Light paper, bold flat lines, white stops with black rings. */
html[data-rails="metro"], .rails-face[data-rails="metro"] {
  --tb-goal-label: #b34d00;
  --tb-land: #ffffff; --tb-coast: #cdd7de; --tb-grid: transparent;
  --tb-pink: #e5007d; --tb-white: #ffffff; --tb-blue: #0072bc; --tb-yellow: #ffcd00; --tb-orange: #f68b1f;
  --tb-black: #231f20; --tb-red: #e2231a; --tb-green: #00a14b; --tb-gray: #a7a9ac;
  --tb-sea: #e3edf3; --tb-sea-edge: #c9c9c4; --tb-space-edge: rgba(0, 0, 0, 0.35); --tb-space-fade: 1;
  --tb-space-rx: 3.6px; --tb-tunnel-edge: #231f20;
  --tb-train-edge: #231f20; --tb-shine: transparent;
  --tb-dot: #ffffff; --tb-dot-edge: #231f20;
  --tb-label: #1a1a1a; --tb-label-halo: #ffffff; --tb-label-font: 700 8.5px var(--font);
  --tb-card-radius: 3px; --tb-card-border: 1px solid rgba(0, 0, 0, 0.25); --tb-card-shadow: none;
}

/* Neon: dark glass, glowing lines and cyan names. */
html[data-rails="neon"], .rails-face[data-rails="neon"] {
  --tb-goal-label: #ffe94d;
  --tb-land: #0d0d22; --tb-coast: rgba(125, 249, 255, 0.55); --tb-grid: rgba(125, 249, 255, 0.08);
  --tb-pink: #ff4fd8; --tb-white: #f4f4ff; --tb-blue: #3d8bff; --tb-yellow: #ffe94d; --tb-orange: #ff9a3d;
  --tb-black: #5a5a78; --tb-red: #ff3d5a; --tb-green: #3dff8b; --tb-gray: #8c8ca8;
  --tb-sea: #06060d; --tb-sea-edge: rgba(125, 249, 255, 0.35); --tb-space-edge: rgba(255, 255, 255, 0.85);
  --tb-space-fade: 0.9; --tb-tunnel-edge: #7df9ff;
  --tb-train-edge: #f4f4ff; --tb-shine: rgba(255, 255, 255, 0.7);
  --tb-dot: #06060d; --tb-dot-edge: #7df9ff;
  --tb-label: #7df9ff; --tb-label-halo: #0d0d22; --tb-label-font: 700 8.5px var(--mono);
  --tb-card-radius: 8px; --tb-card-border: 2px solid var(--c); --tb-card-shadow: 0 0 10px var(--c);
}
@scope (html[data-rails="neon"], .rails-face[data-rails="neon"]) to (.rails-face) {
  :scope .tb-space { filter: drop-shadow(0 0 2.5px rgba(255, 255, 255, 0.45)); }
  :scope .tb-train { filter: drop-shadow(0 0 4px var(--own)); }
  :scope .tb-label { filter: drop-shadow(0 0 3px rgba(125, 249, 255, 0.6)); }
  :scope .tb-card:not(.loco) { background: #0b0b16; }
  :scope .tb-card:not(.loco) .tb-card-art :is(rect, circle) { fill: none; stroke: var(--c); stroke-width: 1.4; }
}

/* Pixel art: square tracks, hard edges, chunky cards and capital names. */
html[data-rails="pixel"], .rails-face[data-rails="pixel"] {
  --tb-goal-label: #ffec27;
  --tb-land: #2b5a3c; --tb-coast: #000000; --tb-grid: rgba(0, 0, 0, 0.18);
  --tb-pink: #ff77a8; --tb-white: #fff1e8; --tb-blue: #29adff; --tb-yellow: #ffec27; --tb-orange: #ffa300;
  --tb-black: #000000; --tb-red: #ff004d; --tb-green: #00e436; --tb-gray: #c2c3c7;
  --tb-sea: #1d2b53; --tb-sea-edge: #000000; --tb-space-edge: #000000; --tb-space-fade: 1; --tb-space-rx: 0px;
  --tb-tunnel-edge: #fff1e8; --tb-render: crispEdges;
  --tb-train-edge: #000000; --tb-train-cap: butt; --tb-shine: transparent;
  --tb-dot: #fff1e8; --tb-dot-edge: #ff004d;
  --tb-label: #fff1e8; --tb-label-halo: #000000; --tb-label-font: 700 7.5px var(--mono); --tb-label-case: uppercase;
  --tb-card-radius: 0; --tb-card-border: 2px solid #000000; --tb-card-shadow: 3px 3px 0 #000000;
}

/* The styles page: one corner of the map per style. */
.rails-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 10px; }
.rails-sample {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 10px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; color: var(--text); cursor: pointer;
}
.rails-sample.on { border-color: var(--orange); box-shadow: 0 0 0 2px var(--orange); }
.rails-sample .name { font-weight: 700; }
.rails-face { display: flex; flex-direction: column; gap: 8px; }
.rails-map { width: 100%; height: auto; display: block; }
.rails-face .tb-cards { justify-content: center; }

