:root {
  --bg: #080b10;
  --bg-elevated: #0b0e14;
  --panel: rgba(15, 20, 28, 0.88);
  --panel-2: rgba(11, 14, 20, 0.78);
  --ink: #f2f5f8;
  --ink-dim: #8e9bae;
  --accent: #007aff;
  --accent-gold: #e8c46a;
  --accent-deep: #005ecb;
  --accent-2: #30d158;
  --danger: #ff453a;
  --line: rgba(255, 255, 255, 0.12);
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  --font-formal: "New York", "New York Small", ui-serif, serif;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  font-size: 15px;
}

* { box-sizing: border-box; }
#file-warning { display: none; }
html, body { height: 100%; }
/* The viewport scroller lives on <html>: lock it there too, or programmatic
 * scrolls (focus jumps, scroll anchoring) still shove the app offscreen. */
html { overflow: hidden; overflow: clip; overflow-anchor: none; }
/* iOS Safari: track the dynamic viewport so the layout doesn't jump or hide
   behind the collapsing toolbar. */
@supports (height: 100dvh) { html, body { height: 100dvh; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  /* `hidden` merely hides the scrollbar — focus jumps and Chrome's scroll
   * anchoring can still scroll the body programmatically, leaving the game
   * shoved up with dead space below and NO way for the user to scroll back.
   * `clip` removes the scroll box entirely (hidden stays as the fallback
   * for older engines, with anchoring disabled so it can't drift either). */
  overflow: hidden;
  overflow: clip;
  overflow-anchor: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button, summary, input { touch-action: manipulation; }
button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

#app, .screen { height: 100%; }
.screen { display: none; }
.screen.active { display: block; }

/* ---------- global mute / help ---------- */
#btn-mute, #btn-help, #btn-games {
  position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); z-index: 50;
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(18, 23, 35, .72); border: 1px solid var(--line);
  color: var(--ink); font-size: 1.1rem; cursor: pointer;
  backdrop-filter: blur(6px);
}
.mute-menu {
  position: fixed; top: calc(14px + env(safe-area-inset-top, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px)); z-index: 50;
}
.mute-menu > #btn-mute { position: static; }
.mute-panel {
  position: absolute; top: 48px; right: 0; display: flex; flex-direction: column; gap: 4px;
  padding: 8px; border-radius: 10px; background: rgba(14,17,26,.95);
  border: 1px solid var(--line); min-width: 140px;
}
.mute-panel.hidden { display: none; }
.mute-panel .mute-cat { text-align: left; font-size: .85rem; padding: 8px 10px; }
.mute-panel .mute-cat.off { opacity: .55; text-decoration: line-through; }
#btn-mute { right: calc(14px + env(safe-area-inset-right, 0px)); }
#btn-help { right: calc(64px + env(safe-area-inset-right, 0px)); font-family: var(--font-formal); font-weight: 700; color: var(--accent); }
#btn-games { right: calc(114px + env(safe-area-inset-right, 0px)); }
.games-list { margin: 0 0 12px; text-align: left; }
.game-row { display: flex; gap: 6px; margin-top: 6px; }
.game-resume { flex: 1; text-align: left; font-size: .84rem; padding: 7px 12px; }
.game-resume.your-move { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 8px rgba(232, 196, 106,.25); }
.game-forget { padding: 2px 10px; }
#btn-mute:hover, #btn-help:hover { border-color: var(--accent); }

#help-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5, 7, 12, .72);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.help-card {
  width: min(680px, 94vw); max-height: 88vh; overflow-y: auto;
  background: var(--panel); border: 1px solid rgba(232, 196, 106, .35);
  border-radius: 14px; padding: 28px 34px;
  box-shadow: 0 30px 90px rgba(0,0,0,.7);
}
.rules-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.rules-head h2 {
  margin: 0; color: var(--accent);
  font-family: var(--font-formal); letter-spacing: .04em;
}
.rules-section { margin: 26px 0; font-size: .95rem; line-height: 1.65; color: var(--ink-dim); }
.rules-section b { color: var(--ink); }
.rules-section h3 {
  font-family: var(--font-formal); color: var(--ink);
  letter-spacing: .04em; margin: 0 0 8px;
  border-bottom: 1px solid rgba(232, 196, 106, .25); padding-bottom: 6px;
}
.rules-art {
  width: 100%; border-radius: 10px; margin-bottom: 12px;
  border: 1px solid rgba(232, 196, 106, .25);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.payoff-lookup { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.payoff-lookup select {
  flex: 1; min-width: 130px; background: rgba(10, 14, 22, .8); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: .88rem;
}
.payoff-arrow { color: var(--ink-dim); }
.payoff-result {
  font-family: ui-monospace, monospace; color: var(--accent);
  font-size: 1.05rem; font-weight: 700; min-width: 80px; text-align: right;
}
.conductor-section { border-top: 1px dashed var(--line); padding-top: 18px; }
.conductor-hint { font-size: .85rem; }
#conductor-log { max-height: 240px; overflow-y: auto; margin: 10px 0; }
.conductor-q {
  background: rgba(232, 196, 106, .1); border-radius: 8px 8px 8px 2px;
  padding: 8px 12px; margin: 8px 0 4px; color: var(--ink); font-size: .9rem;
}
.conductor-a {
  border-left: 3px solid var(--accent); padding: 6px 12px;
  margin: 0 0 10px 10px; font-size: .92rem; color: var(--ink-dim);
}
.conductor-a.pending { opacity: .6; font-style: italic; }
.conductor-error { border-left-color: var(--danger); color: var(--danger); }
#conductor-form { display: flex; gap: 8px; }
#conductor-form input { flex: 1; }
#conductor-form button { padding: 8px 18px; }

/* ---------- identity ---------- */
.avatar-chip {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(232, 196, 106, .45); flex: none; background: #0b0e14;
  /* The portraits are dark oils — lift them off the dark UI. */
  filter: brightness(1.18) contrast(1.05);
  cursor: zoom-in;
}
.avatar-chip.clickable { cursor: pointer; width: 48px; height: 48px; }
.avatar-chip.clickable:hover { filter: brightness(1.35); }

/* Tap any portrait to see it properly. */
/* ---- deals -------------------------------------------------------- */
.trade-offer {
  margin: 8px 0; padding: 8px 10px; border-radius: 8px;
  background: rgba(232, 196, 106, .08); border: 1px solid rgba(232, 196, 106, .35);
  font-size: .88rem; line-height: 1.5;
}
#trade-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 11, 16, .88); backdrop-filter: blur(6px);
  animation: win-fade .2s ease-out;
}
.trade-card {
  width: min(440px, 92vw); max-height: 86vh; overflow: auto;
  background: var(--panel); border: 1px solid rgba(232, 196, 106, .35);
  border-radius: 12px; padding: 18px 20px;
  box-shadow: 0 20px 70px rgba(0,0,0,.7);
}
.trade-card h3 { margin: 0 0 10px; font-family: var(--font-display); }
.trade-card h4 {
  margin: 14px 0 6px; font-size: .78rem; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: .08em;
}
.trade-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 6px 0; font-size: .9rem;
}
.trade-row select, .trade-row input {
  background: rgba(10, 14, 22, .8); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
  font-size: .88rem; min-width: 150px;
}
.trade-deeds { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; }
.trade-deeds label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

#portrait-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(8, 11, 16, .93); backdrop-filter: blur(6px);
  animation: win-fade .2s ease-out; cursor: zoom-out;
}
#portrait-overlay img {
  width: min(340px, 78vw); height: min(340px, 78vw); border-radius: 50%;
  object-fit: cover; border: 4px solid var(--line);
  filter: brightness(1.15) contrast(1.05);
  box-shadow: 0 20px 70px rgba(0,0,0,.7);
}
#portrait-overlay .portrait-name {
  font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; letter-spacing: .04em;
}
.identity-picker { margin: 6px 0 14px; }
.picker-label {
  display: block; font-size: .72rem; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: .1em; margin: 10px 0 6px;
}
.avatar-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-pick {
  width: 62px; height: 62px; border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(255,255,255,.14); cursor: pointer; background: #0b0e14;
  filter: brightness(1.18) contrast(1.05);
  transition: transform .1s, border-color .15s;
}
.avatar-pick:hover { transform: scale(1.12); }
.avatar-pick.selected { border-color: var(--accent); box-shadow: 0 0 10px rgba(232, 196, 106,.4); }
.color-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.color-pick {
  width: 26px; height: 26px; border-radius: 50%; padding: 0;
  border: 2px solid rgba(255,255,255,.25); cursor: pointer;
}
.color-pick.selected { border-color: #fff; box-shadow: 0 0 10px rgba(255,255,255,.35); }
.color-pick.taken { opacity: .25; cursor: not-allowed; }
.hotseat-row { display: flex; align-items: center; gap: 10px; }
.hotseat-row input { flex: 1; }
.hotseat-row input:disabled { opacity: .4; }
.bot-toggle {
  width: 38px; height: 38px; padding: 0; border-radius: 8px;
  font-size: 1.05rem; flex: none;
}
.bot-toggle.is-bot { border-color: var(--accent); box-shadow: 0 0 8px rgba(232, 196, 106,.25); }
.bot-remove { padding: 2px 8px; font-size: .78rem; }
.bot-level-tag { padding: 2px 10px; font-size: .74rem; border-radius: 10px; }
.bot-level-tag:disabled { opacity: .7; cursor: default; }
.game-options {
  margin: 10px 0 2px; text-align: left;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
.game-options summary {
  cursor: pointer; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .12em; color: var(--accent);
}
.game-options label {
  display: block; margin: 8px 0 0; font-size: .88rem; cursor: pointer;
}
.game-options h4 {
  margin: 14px 0 2px; font-size: .74rem; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: .1em;
}
.game-options input { margin-right: 6px; }
.opt-hint { display: block; margin-left: 22px; font-size: .74rem; color: var(--ink-dim); }
.clock-row { display: flex !important; align-items: center; gap: 10px; }
.clock-row select {
  flex: 1; background: rgba(10, 14, 22, .8); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font-size: .85rem;
}
.custom-win { cursor: default !important; }
.custom-win input { margin: 5px 0 0; }
#win-summary { max-width: min(92vw, 760px); overflow-x: auto; margin: 4px 0 16px; }
.summary-table {
  border-collapse: collapse; font-size: .8rem; margin: 0 auto;
  color: var(--ink-dim); white-space: nowrap;
}
.summary-table th {
  text-transform: uppercase; letter-spacing: .08em; font-size: .66rem;
  color: var(--accent); padding: 4px 10px; border-bottom: 1px solid var(--line);
  text-align: right;
}
.summary-table th:first-child { text-align: left; }
.summary-table td { padding: 5px 10px; text-align: right; border-bottom: 1px solid rgba(44,55,80,.4); }
.summary-table .sum-name { text-align: left; color: var(--ink); font-weight: 600; }
.summary-table .winner-row td { color: var(--ink); background: rgba(232, 196, 106, .07); }
.sum-dim { color: var(--ink-dim); font-size: .72rem; }
.replay-bar {
  position: absolute; left: 16px; right: 16px; bottom: 14px; z-index: 14;
  display: flex; align-items: center; gap: 12px;
  background: rgba(10, 14, 22, .85); border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 14px; padding: 10px 16px;
  backdrop-filter: blur(24px) saturate(1.8); -webkit-backdrop-filter: blur(24px) saturate(1.8);
  box-shadow: 0 12px 36px rgba(0, 0, 0, .6);
}
.replay-bar button {
  padding: 6px 12px; border-radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-weight: 600; font-size: .82rem;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16);
  color: #fff; cursor: pointer; transition: background .12s, border-color .12s;
}
.replay-bar button:hover { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .3); }
.rp-track {
  flex: 1; height: 8px; border-radius: 4px;
  background: rgba(255, 255, 255, .1); overflow: hidden; cursor: pointer;
  position: relative;
}
.rp-track:hover { background: rgba(255, 255, 255, .18); }
.rp-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), #30b0c7);
  box-shadow: 0 0 10px rgba(0, 122, 255, .5);
  transition: width .14s linear;
}
.rp-caption {
  max-width: 36%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .82rem; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-weight: 500; color: rgba(255, 255, 255, .88);
}
.btn-replay { margin-bottom: 10px; }
.catalog-btn.tint-on { border-color: var(--accent); color: var(--accent); }
.rr-group.owner-tinted .rr-edge { filter: url(#glow); }
.restart-btn { margin-top: 10px; font-size: .78rem; padding: 5px 10px; opacity: .75; }
.restart-btn:hover { opacity: 1; }
.btn-rematch { margin-bottom: 10px; margin-right: 8px; }
.invite-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.invite-facebook { color: #8ab4f8; border-color: rgba(138, 180, 248, .4); }
.invite-facebook:hover { color: #c2d7fc; border-color: rgba(138, 180, 248, .7); }
.seat-facebook { color: #8ab4f8; }
.record-line { font-size: .78rem; color: var(--ink-dim); margin: -6px 0 10px; min-height: 1em; }
.win-avatar {
  width: 120px; height: 120px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--accent); margin-bottom: 14px;
  filter: brightness(1.15) contrast(1.05);
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}

/* ---------- geography (satellite) ---------- */
.terrain-img {
  opacity: 0.86;
  filter: brightness(0.36) contrast(1.28) saturate(0.65);
}
.geo-state {
  fill: rgba(255, 255, 255, 0.001); /* invisible fill keeps state-name hover tooltips */
  stroke: rgba(145, 185, 240, .26);
  stroke-width: .75;
  stroke-linejoin: round;
}
.geo-state:hover { stroke: rgba(255, 255, 255, .75); }
.grat-line {
  fill: none; stroke: rgba(140, 180, 230, .14); stroke-width: .5;
  stroke-dasharray: 4 4;
}
.grat-label {
  font-size: 7.5px; fill: rgba(180, 215, 255, .55);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; letter-spacing: .06em;
  paint-order: stroke; stroke: rgba(4, 8, 18, .75); stroke-width: 2px;
}
.river {
  fill: none; stroke: rgba(90, 165, 245, .42); stroke-width: .85;
  stroke-linecap: round; stroke-linejoin: round; pointer-events: stroke;
}
.lake {
  fill: rgba(12, 38, 84, .45); stroke: rgba(110, 185, 255, .45); stroke-width: .55;
  stroke-linejoin: round;
}

/* ---------- hero screens ---------- */
/* Scroll-safe centering: `margin: auto` on the card centers it when it fits
 * and lets the screen scroll when it doesn't. A flex-centered child inside
 * `overflow: hidden` clips at BOTH ends once it outgrows the viewport —
 * expanded options + a full seat list used to make Start unreachable. */
#screen-home.active, #screen-lobby.active, #screen-hotseat.active {
  display: flex;
  position: relative; overflow-y: auto; overflow-x: hidden;
  padding: 18px 0;
}
#screen-home .hero-card, #screen-lobby .hero-card, #screen-hotseat .hero-card { margin: auto; }
.hero-bg { position: fixed; inset: 0; z-index: 0; }
.hero-bg video, .hero-bg img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  filter: saturate(1.05);
}
.hero-bg.dim video, .hero-bg.dim img { filter: saturate(.7) brightness(.55); }
.hero-shade {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 85%, rgba(8, 11, 16, .88) 0%, rgba(8, 11, 16, .45) 45%, rgba(8, 11, 16, .35) 100%),
    linear-gradient(180deg, rgba(8, 11, 16, .35) 0%, rgba(8, 11, 16, .15) 40%, rgba(8, 11, 16, .8) 100%);
}

.home-card {
  width: min(460px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 34px 38px;
  box-shadow: 0 18px 60px rgba(0,0,0,.45);
}
.hero-card {
  position: relative; z-index: 1;
  background: rgba(16, 20, 30, .78);
  border: 1px solid rgba(232, 196, 106, .28);
  backdrop-filter: blur(10px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(232, 196, 106, .15);
}

.logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 3.1rem;
  letter-spacing: .14em;
  text-align: center;
  margin: 0 0 6px;
  background: linear-gradient(180deg, #f7e3a4 0%, var(--accent) 45%, #a8781f 85%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 18px rgba(232, 196, 106, .25);
}
.tagline { color: var(--ink-dim); margin: 0 0 22px; text-align: center; }
.deco-rule {
  display: flex; align-items: center; gap: 10px;
  font-variant: small-caps; letter-spacing: .12em; font-size: .82rem;
}
.deco-rule::before, .deco-rule::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232, 196, 106,.5));
}
.deco-rule::after { background: linear-gradient(90deg, rgba(232, 196, 106,.5), transparent); }
h2 { margin: 0 0 6px; font-family: var(--font-display); letter-spacing: .03em; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: .8rem; color: var(--ink-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .08em; }
input {
  width: 100%;
  background: rgba(10, 13, 20, .85);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1rem;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232, 196, 106,.15); }

.home-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.home-more { margin-top: 4px; text-align: left; }
.home-more > summary {
  cursor: pointer; color: var(--ink-dim); font-size: .9rem; padding: 6px 0;
  list-style: none;
}
.home-more > summary::-webkit-details-marker { display: none; }
.home-more[open] > summary { color: var(--accent); }
.home-more .ghost { width: 100%; margin-top: 6px; }
button.ghost-strong {
  border-color: rgba(232, 196, 106,.45); color: var(--accent);
  background: rgba(232, 196, 106,.08);
}
.daily-streak { margin: 0; font-size: .85rem; color: var(--accent); }
.daily-board {
  text-align: left; font-size: .82rem; color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  max-height: 140px; overflow: auto;
}
.daily-board ol { margin: 4px 0 0; padding-left: 1.2em; }
.daily-board li { margin: 2px 0; }
.home-host-hint { margin: 10px 0 0; font-size: .78rem; opacity: .85; }
.home-host-hint code { font-size: .75rem; color: var(--accent); }
.join-row { display: flex; gap: 10px; }
.join-row input { width: 110px; text-transform: uppercase; text-align: center; letter-spacing: .2em; font-weight: 700; }
.join-row button { flex: 1; }

button {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: filter .12s, transform .08s, box-shadow .12s, border-color .15s;
}
button:hover { filter: brightness(1.15); transform: translateY(-1px); border-color: rgba(255,255,255,0.22); }
button:active { transform: scale(0.98); }
button:disabled { opacity: .45; cursor: default; transform: none; filter: none; }
button.primary {
  background: linear-gradient(180deg, #64b5f6 0%, var(--accent) 60%, var(--accent-deep) 100%);
  color: #ffffff; border-color: rgba(255,255,255,.2); font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 122, 255, .35), inset 0 1px 0 rgba(255,255,255,.3);
  text-shadow: 0 1px 1px rgba(0,0,0,.3);
}
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--line); }
button.danger { background: var(--danger); border-color: transparent; color: #fff; box-shadow: 0 4px 16px rgba(255, 69, 58, 0.35); }

.error { color: var(--danger); min-height: 1.2em; margin: 14px 0 0; }
.room-code { color: var(--accent); letter-spacing: .25em; font-family: ui-monospace, monospace; }

.lobby-players { list-style: none; padding: 0; margin: 10px 0 20px; }
.lobby-players li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px; border-bottom: 1px solid var(--line);
}
.dot { width: 13px; height: 13px; border-radius: 50%; flex: none; box-shadow: 0 0 6px currentColor; }
.lobby-players .host-tag, .disc-tag { font-size: .72rem; color: var(--ink-dim); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.lobby-players li.open-seat { opacity: .75; }
.lobby-players li.open-seat .avatar-chip { filter: grayscale(1); }

/* QR invite: dark modules on white with a quiet zone, or phones won't scan it. */
.qr-box { display: flex; justify-content: center; margin: 10px 0; }
.qr-box svg { width: min(220px, 60vw); height: auto; background: #fff; border-radius: 8px; }

.push-toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; z-index: 60;
  background: var(--panel, #1c2230); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.45); max-width: min(92vw, 480px);
}
.push-toast span { font-size: .9rem; }
.push-toast button { flex: none; }

/* Event vignettes: brief cinematic clips over the map. */
.vignette {
  position: absolute; left: 50%; top: 12%; transform: translateX(-50%);
  z-index: 30; border-radius: 12px; overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,.6); border: 1px solid var(--line);
  animation: vignette-in .35s ease-out;
  pointer-events: none;
}
.vignette video { display: block; width: min(46vw, 560px); height: auto; }
/* The game-start opener: bigger, centered, tap to skip. */
.vignette-grand { top: 50%; transform: translate(-50%, -50%); pointer-events: auto; cursor: pointer; }
.vignette-grand video { width: min(78vw, 1100px); }
@keyframes vignette-in-grand { from { opacity: 0; transform: translate(-50%, -50%) scale(.94); } }
.vignette-grand { animation: vignette-in-grand .45s ease-out; }
.vignette-out { opacity: 0; transition: opacity .4s; }

/* Region-choice overlays on the board. */
.region-choice { cursor: pointer; }
.region-blob { fill-opacity: .16; stroke-opacity: .75; stroke-width: 2.5; stroke-linejoin: round; }
.region-choice:hover .region-blob { fill-opacity: .32; stroke-opacity: 1; stroke-width: 3.5; }
.region-label {
  font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: .08em;
  fill: #fdfbf4; text-anchor: middle; dominant-baseline: middle;
  paint-order: stroke; stroke: rgba(2, 6, 15, .85); stroke-width: 5px;
  pointer-events: none;
}
.region-choice:hover .region-label { fill: #f7e3a4; }
.region-choice.region-top .region-blob { fill-opacity: .28; stroke-opacity: 1; stroke-width: 3.2; }
.region-choice.region-top .region-label { fill: #f7e3a4; }
@keyframes vignette-in { from { opacity: 0; transform: translateX(-50%) scale(.96); } }
@media (max-width: 700px) { .vignette video { width: 86vw; } }

/* Winner vignette replaces the hero art backdrop when it can play; same
 *  dimming as the still so the card stays readable. */
#win-overlay #win-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; filter: brightness(.55) saturate(1.1);
}

#hotseat-names { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

/* ---------- game layout ---------- */
/* Column flex so the waiting strip consumes height INSTEAD of pushing the
 * board below the fold — .game-layout gets the remainder, keeping anything
 * anchored to the map's bottom edge (focus bar, threatboard) on screen. */
#screen-game.active { display: flex; flex-direction: column; position: relative; }
.game-layout { display: flex; flex: 1 1 0; min-height: 0; }
.map-pane { flex: 1; position: relative; background: var(--bg); min-width: 0; }
#board { width: 100%; height: 100%; display: block; touch-action: none; }
.side-pane {
  width: 344px; flex: none;
  display: flex; flex-direction: column; gap: 10px;
  padding: 10px; background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  scrollbar-width: thin;
  scrollbar-color: var(--line) rgba(255,255,255,.04);
}
.side-pane::-webkit-scrollbar { width: 10px; }
.side-pane::-webkit-scrollbar-track { background: rgba(255,255,255,.04); }
.side-pane::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
.side-pane::-webkit-scrollbar-thumb:hover { background: var(--accent-deep); }

/* Short-but-wide desktop windows (the 900px breakpoint below only reacts to
 * width, so a normal laptop window at reduced height got no relief). Trim
 * padding so fewer panels spill past the fold. */
@media (max-height: 820px) {
  .side-pane { gap: 6px; padding: 8px; }
  .panel { padding: 8px; }
  .player-row { padding: 6px; margin-bottom: 4px; }
  #turn-panel .prompt { margin-bottom: 6px; }
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}
.panel h3 {
  margin: 0 0 8px; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .14em; color: var(--accent);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  font-weight: 700;
}

.player-row { padding: 8px; border-radius: 8px; margin-bottom: 6px; background: rgba(10, 13, 20, .5); border: 1px solid transparent; transition: border-color .2s; }
.player-row.current { border-color: var(--accent); box-shadow: 0 0 14px rgba(232, 196, 106,.14) inset; }
.player-row.declared {
  border-color: var(--danger);
  box-shadow: 0 0 18px rgba(230,57,70,.18) inset;
}
.player-head { display: flex; align-items: center; gap: 8px; }
.player-head .name { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-head .cash { font-family: ui-monospace, monospace; color: var(--accent); }
.player-head .cash.masked { color: var(--ink-dim); letter-spacing: .08em; }
.player-head .cash.askable { cursor: pointer; text-decoration: underline dotted rgba(232, 196, 106, .5); text-underline-offset: 3px; }
.player-head .cash.askable:hover { color: var(--accent); }
.player-head .odds {
  flex: none; font-family: ui-monospace, monospace; font-size: .82rem; font-weight: 700;
  color: var(--ink-dim); background: rgba(232, 196, 106, .08);
  border: 1px solid rgba(232, 196, 106, .22); border-radius: 999px;
  padding: 1px 7px; letter-spacing: .02em;
}
.player-head .odds.odds-high { color: var(--accent); border-color: rgba(232, 196, 106, .5); background: rgba(232, 196, 106, .16); }
.player-head .odds.odds-low { opacity: .72; }
.eye-btn {
  background: none; border: none; padding: 0 2px; font-size: .9rem;
  cursor: pointer; opacity: .55; line-height: 1; flex: none;
}
.eye-btn:hover { opacity: 1; }
.player-sub { font-size: .78rem; color: var(--ink-dim); margin-top: 3px; line-height: 1.5; }
.player-sub .rr-chip, .rr-chip { display: inline-block; padding: 0 5px; border-radius: 4px; margin: 1px 2px 1px 0; font-size: .72rem; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.6); }

#turn-panel .prompt { font-size: 1.02rem; margin-bottom: 10px; line-height: 1.45; }
#turn-panel .actions { display: flex; flex-wrap: wrap; gap: 8px; }
#turn-panel .actions button { font-size: .92rem; padding: 8px 12px; }
.route-commit-drawer {
  margin-top: 10px; padding: 10px; border-radius: 14px;
  border: 1px solid rgba(0, 122, 255, .32);
  background: linear-gradient(145deg, rgba(15, 20, 28, .9), rgba(8, 11, 16, .76));
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.route-commit-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.route-commit-head strong {
  color: var(--ink); font-family: var(--font-display); font-size: .82rem;
  letter-spacing: .08em; text-transform: uppercase;
}
.route-commit-head span { color: var(--ink-dim); font-size: .68rem; }
.route-commit-presets {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px;
  align-items: center; margin-top: 8px;
}
.route-commit-presets .route-commit-button { width: 100%; text-align: left; }
.route-fee-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 28px; padding: 4px 8px; border: 1px solid rgba(0, 122, 255, .3);
  border-radius: 999px; color: var(--accent); background: rgba(0, 122, 255, .1);
  font: 700 .68rem/1.2 ui-monospace, "SF Mono", monospace; text-align: center;
}
.route-fee-pill-alt { color: var(--accent-gold); border-color: rgba(232, 196, 106, .35); background: rgba(232, 196, 106, .1); }
.route-catalog-button { width: 100%; justify-self: stretch; text-align: left; }
.dice { display: flex; gap: 6px; margin: 8px 0; perspective: 300px; }
.die {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(160deg, #fdfbf4, #d9d3c4);
  color: #171410;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.2rem;
  box-shadow: 0 3px 8px rgba(0,0,0,.45), inset 0 1px 0 #fff;
}
.die.bonus { background: linear-gradient(160deg, #f2d488, var(--accent-deep)); }
.dice.rolling .die { animation: die-roll .55s cubic-bezier(.3,1.6,.5,1); }
@keyframes die-roll {
  0% { transform: rotateX(140deg) rotateZ(-60deg) translateY(-16px); opacity: .2; }
  60% { transform: rotateX(-24deg) rotateZ(12deg); opacity: 1; }
  100% { transform: none; }
}

.map-speed-die { display: none; filter: url(#glow); transform-box: fill-box; transform-origin: center; }
.z-near .map-speed-die { display: block; }
.map-speed-die-glow { opacity: .2; }
.map-speed-die-face { stroke: rgba(255, 255, 255, .88); stroke-width: 1.2; }
.map-speed-die-value {
  fill: var(--bg); font-family: ui-monospace, "SF Mono", monospace;
  font-size: 9px; font-weight: 900;
}
.map-speed-die.rolling { animation: map-die-roll .55s cubic-bezier(.3,1.6,.5,1); }
@keyframes map-die-roll {
  0% { opacity: .15; transform: rotate(-80deg) scale(.35); }
  65% { opacity: 1; transform: rotate(12deg) scale(1.14); }
  100% { opacity: 1; transform: none; }
}

.log { flex: 1; min-height: 130px; overflow-y: auto; font-size: .84rem; }
.log .entry { padding: 3px 0; border-bottom: 1px dotted var(--line); color: var(--ink-dim); }
.log .entry b { color: var(--ink); }

.chat { max-height: 220px; display: flex; flex-direction: column; }
#chat-messages {
  flex: 1; overflow-y: auto; font-size: .84rem; margin-bottom: 6px;
  font-family: "Avenir Next", "Segoe UI", system-ui, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
#chat-messages div { padding: 2px 0; }
#chat-messages .chat-gif,
#chat-messages .chat-image {
  display: block; max-width: min(100%, 220px); max-height: 160px; width: auto; height: auto;
  margin: 4px 0 2px; border-radius: 8px; border: 1px solid var(--line);
}
#chat-messages .chat-note { color: var(--ink-dim); font-style: italic; }
.chat-form { display: flex; gap: 6px; align-items: center; }
.chat-form #chat-input { flex: 1; min-width: 0; }
.chat-gif-btn {
  flex: none; padding: 4px 8px; font-size: .72rem; font-weight: 800;
  letter-spacing: .06em; color: var(--accent);
}
#chat-input {
  font-family: "Avenir Next", "Segoe UI", system-ui, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.giphy-picker {
  margin: 0 0 6px; padding: 8px; border: 1px solid var(--line); border-radius: 8px;
  background: rgba(10, 13, 20, .55);
}
.giphy-form { display: flex; gap: 6px; margin-bottom: 6px; }
.giphy-form input { flex: 1; min-width: 0; }
.giphy-note { margin: 0 0 6px; font-size: .78rem; }
.giphy-results {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  max-height: 180px; overflow-y: auto;
}
.giphy-hit {
  padding: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  background: #0b0e14; cursor: pointer; aspect-ratio: 1 / 1;
}
.giphy-hit:hover { border-color: var(--accent); }
.giphy-hit img { display: block; width: 100%; height: 100%; object-fit: cover; }
.giphy-attrib {
  margin: 6px 0 0; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-dim); text-align: right;
}
.hidden { display: none !important; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- banner ---------- */
.banner {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%);
  background: rgba(16, 20, 30, .92);
  border: 1px solid var(--accent);
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 22px;
  font-size: 1.05rem;
  box-shadow: 0 10px 40px rgba(0,0,0,.5), 0 0 24px rgba(232, 196, 106,.15);
  max-width: 80%;
  text-align: center;
  z-index: 5;
  animation: banner-in .25s ease-out;
}
@keyframes banner-in { from { opacity: 0; transform: translate(-50%, -8px); } }

/* Persistent trip/economy strip over the board. */
.trip-hud {
  position: absolute; z-index: 4; top: 54px; left: 16px;
  display: flex; align-items: stretch; gap: 1px;
  max-width: calc(100% - 32px); overflow-x: auto;
  border: 1px solid rgba(232, 196, 106,.38); border-radius: 10px;
  background: rgba(14,17,26,.88); backdrop-filter: blur(7px);
  box-shadow: 0 8px 26px rgba(0,0,0,.35);
}
.trip-hud > div {
  min-width: 112px; padding: 7px 10px;
  border-left: 1px solid rgba(255,255,255,.08);
}
.trip-hud > div:first-child { border-left: 0; }
.trip-hud span, .trip-hud small {
  display: block; color: var(--ink-dim); font-size: .65rem; line-height: 1.25;
}
.trip-hud b { display: block; color: var(--ink); font-size: .82rem; white-space: nowrap; }
.trip-hud-title { min-width: 130px !important; }
.trip-declared { color: #ff8d96 !important; font-weight: 800; margin-top: 3px; }
.trip-fee-era { color: var(--accent-gold) !important; font-weight: 700; margin-top: 3px; display: block; }
.trip-endgame b { white-space: normal; max-width: 200px; }
.trip-endgame-safe b { color: #7dcfb6; }
.trip-endgame-risk b { color: #ff8d96; }
.trip-endgame-near b { color: var(--accent-gold); }

/* Midgame board focus — one job at a glance */
.midgame-focus {
  position: absolute; z-index: 5; left: 16px; bottom: 14px;
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 5px 7px; border-radius: 10px;
  border: 1px solid rgba(232, 196, 106,.35);
  background: rgba(14,17,26,.88); backdrop-filter: blur(7px);
  box-shadow: 0 8px 26px rgba(0,0,0,.35);
  font-size: .68rem;
}
.midgame-focus .focus-label {
  font-family: var(--font-display); font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent); padding: 0 4px;
}
.midgame-focus .focus-btn {
  padding: 4px 8px; font-size: .68rem; border-radius: 6px;
  background: transparent; border: 1px solid transparent; color: var(--ink-dim);
  cursor: pointer; text-transform: capitalize;
}
.midgame-focus .focus-btn:hover { color: var(--ink); border-color: var(--line); }
.midgame-focus .focus-btn.on {
  color: var(--ink); border-color: rgba(232, 196, 106,.55);
  background: rgba(232, 196, 106,.12);
}
body.midgame-focus-race .trip-hud:not(:has(.trip-endgame)) { opacity: .72; }
body.midgame-focus-race .threatboard { box-shadow: 0 0 0 1px rgba(255,141,150,.55), 0 8px 26px rgba(0,0,0,.35); }
body.midgame-focus-fees .trip-hud { box-shadow: 0 0 0 1px rgba(232, 196, 106,.55), 0 8px 26px rgba(0,0,0,.35); }
body.midgame-focus-ownership #rr-list { outline: 1px solid rgba(232, 196, 106,.35); }

.replay-coach {
  position: absolute; z-index: 7; left: 50%; bottom: 64px;
  transform: translateX(-50%);
  max-width: min(420px, calc(100% - 24px));
  padding: 10px 14px; border-radius: 10px;
  border: 1px solid rgba(232, 196, 106,.45);
  background: rgba(14,17,26,.94); backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  font-size: .82rem; line-height: 1.35;
}
.replay-coach b { display: block; color: var(--accent); margin-bottom: 3px; }
.replay-coach span { color: var(--ink-dim); }

/* ---------- board svg ---------- */
.rr-casing { fill: none; stroke: #05070c; stroke-width: 4.2; stroke-linecap: round; transition: stroke-width .3s; }
.rr-edge {
  fill: none; stroke-linecap: round; stroke-width: 2.6;
  filter: drop-shadow(0 0 1px rgba(0,0,0,0.85));
  transition: opacity .3s, stroke-width .3s;
}
/* crosstie bars: short dashes on a thick stroke read as perpendicular ties */
.rr-ties {
  fill: none; stroke: rgba(5, 7, 12, .55); stroke-width: 2.6;
  stroke-dasharray: .9 4.6; stroke-linecap: butt;
  pointer-events: none; transition: opacity .3s;
}
.z-far .rr-ties { display: none; }
.rr-label {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  font-size: 6px; font-weight: 800; letter-spacing: .16em;
  fill: #ffffff; opacity: .95;
  paint-order: stroke; stroke: rgba(4, 8, 16, .9); stroke-width: 2px;
  pointer-events: none;
}
.z-far .rr-label { display: none; }
.rr-group { opacity: 1; transition: opacity .25s; }
.rr-group.owned .rr-casing { stroke-width: 5.2; }
.rr-group.owned .rr-edge { stroke-width: 3.5; filter: url(#glow); }
.rr-group.owned .rr-ties { stroke-width: 3.5; }
.rr-group.focus .rr-casing { stroke-width: 5.8; }
.rr-group.focus .rr-edge { stroke-width: 4.2; filter: url(#glow); }
.rr-group.focus .rr-ties { stroke-width: 4.2; }
.rr-group.faded, .owner-stripes.faded { opacity: .12; }
.owner-stripes {
  fill: none; stroke-width: 1.6; stroke-linecap: round;
  stroke-dasharray: 6 5; pointer-events: none;
  transition: opacity .25s;
}

/* route paths (illuminated vector movement) */
.route-underglow {
  fill: none; stroke-linecap: round; stroke-linejoin: round;
  stroke-width: 6; opacity: .45; filter: url(#routeGlow);
  pointer-events: none;
}
.route-path {
  fill: none; stroke-linecap: round; stroke-linejoin: round;
  stroke-width: 3.2; stroke-dasharray: 5 4;
  animation: route-dash .85s linear infinite; filter: url(#glow);
  pointer-events: none;
}
@keyframes route-dash { from { stroke-dashoffset: 18; } to { stroke-dashoffset: 0; } }

/* ---------- railroads ledger ---------- */
#rr-panel summary {
  cursor: pointer; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .14em; color: var(--accent);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  font-weight: 700;
}
#rr-list { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.rr-row {
  display: flex; align-items: center; gap: 6px;
  font-size: .76rem; padding: 3px 4px; border-radius: 5px; cursor: default;
}
.rr-row:hover { background: rgba(0, 122, 255, .1); }
.rr-swatch { width: 14px; height: 5px; border-radius: 2px; flex: none; }
.rr-row .rr-abbr { font-weight: 700; min-width: 44px; }
.rr-row .rr-owner { flex: 1; text-align: right; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-row .rr-owner.mine { color: var(--accent); }
.rr-row .owner-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* nodes, junctions, mileposts & cities */
.milepost { fill: #ffffff; stroke: var(--bg); stroke-width: 1.25; }
.milepost.junction-dot { fill: #ffffff; stroke: var(--bg); stroke-width: 1.4; }
.junction-ring {
  fill: none; stroke: rgba(255, 255, 255, .8); stroke-width: 1.2;
  stroke-dasharray: 2 1.5; pointer-events: none;
}
.city-node { cursor: pointer; }
.city-halo {
  fill: rgba(255, 255, 255, .14);
  stroke: rgba(255, 255, 255, .32);
  stroke-width: .8;
}
.city-node.is-junction .city-halo {
  fill: rgba(0, 122, 255, .18);
  stroke: rgba(0, 122, 255, .5);
  stroke-width: 1.1;
}
.city-dot { fill: var(--bg); stroke: var(--accent); stroke-width: 1.8; }
.city-node.is-junction .city-dot { stroke: #ffffff; stroke-width: 2.2; }
.city-label {
  font-size: 5.6px; fill: #ffffff;
  paint-order: stroke; stroke: rgba(4, 8, 16, .95); stroke-width: 2.2px;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: .02em;
  transition: font-size .14s ease;
}
.city-label.crowded { font-size: 4.6px; }
/* Peek: hover with a mouse, or press-and-hold on touch, blows the label up. */
.city-node:hover .city-label,
.city-node.hot .city-label {
  font-size: 13px; stroke-width: 3.6px; fill: #ffffff;
}
/* home-city pennants */
.home-pin { pointer-events: all; }
.home-pole { stroke: var(--bg); stroke-width: 1.1; }
.home-flag { stroke: var(--bg); stroke-width: .8; }
.home-label {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; font-size: 8px; font-weight: 700; letter-spacing: .08em;
  text-anchor: middle; paint-order: stroke; stroke: rgba(2, 6, 15, .95); stroke-width: 3px;
  pointer-events: none;
}
.home-mine .home-pole { stroke-width: 1.6; }
.home-mine .home-flag { filter: url(#glow); }
.home-pin.homebound .home-flag { filter: url(#glow); }
.origin-mark { stroke-width: 1.6; stroke-dasharray: 3 2; opacity: .85; }
.origin-mine .origin-mark { stroke-width: 2.2; opacity: 1; }
.origin-label {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; font-size: 7.5px; font-weight: 700; letter-spacing: .08em;
  text-anchor: middle; paint-order: stroke; stroke: rgba(2, 6, 15, .95); stroke-width: 3px;
  pointer-events: none;
}
.home-link {
  background: none; border: none; padding: 0; font: inherit; color: inherit;
  cursor: pointer; text-decoration: underline dotted rgba(0, 122, 255, .5);
  text-underline-offset: 2px;
}
.home-link:hover { color: var(--accent); }
.home-base { fill: var(--bg); }
.train { pointer-events: none; transition: transform .3s cubic-bezier(.4, 0, .2, 1); }
body[data-bot-pace="fast"] .train { transition-duration: .12s; }
body[data-bot-pace="turbo"] .train { transition-duration: .04s; }
.train-ring { opacity: 0; }
.train.active .train-ring { opacity: .95; animation: train-pulse 1.6s ease-in-out infinite; }
.train.declared .train-ring {
  opacity: 1; stroke-width: 3.2; stroke-dasharray: 3 2;
  animation: rover-target 1s ease-in-out infinite;
}
.train-shadow { fill: rgba(4, 8, 16, .38); }
.train-body { stroke: #0b0e14; stroke-width: 1.1; }
.train-cab { fill: rgba(10, 14, 22, .55); }
.train-wheel { fill: #141a26; stroke: #d8dee9; stroke-width: .7; }
.train-cow { fill: #d8dee9; stroke: #0b0e14; stroke-width: .7; }
.train-lamp { fill: #fff8dc; }
.train.active .train-lamp { animation: lamp-glow 1.6s ease-in-out infinite; }
@keyframes lamp-glow { 50% { fill: #ffe27a; r: 1.6; } }
@keyframes train-pulse {
  0%, 100% { stroke-opacity: .9; r: 12; }
  50% { stroke-opacity: .3; r: 15; }
}
@keyframes rover-target {
  50% { r: 17; stroke-opacity: .45; }
}
.route-ghost {
  fill: none; stroke: rgba(255, 255, 255, .75); stroke-width: 2;
  stroke-dasharray: 3 6; stroke-linecap: round; stroke-linejoin: round;
  pointer-events: none; animation: ghost-march 1.2s linear infinite;
}
@keyframes ghost-march { to { stroke-dashoffset: -9; } }
.route-ghost-alt { stroke: rgba(244, 132, 95, .85); animation-duration: 1.6s; }
.route-ghost-hit {
  fill: none; stroke: rgba(0,0,0,0.001); stroke-width: 11;
  stroke-linecap: round; stroke-linejoin: round;
  pointer-events: stroke; cursor: pointer;
}
.fee-preview { margin-top: 4px; color: var(--accent); font-size: .8rem; }
.dest-ring { fill: none; stroke-width: 2.5; pointer-events: none; animation: dest-spin 14s linear infinite; transform-box: fill-box; transform-origin: center; }
.dest-ring.homebound { stroke-width: 4; filter: url(#glow); animation-duration: 5s; }
@keyframes dest-spin { to { transform: rotate(360deg); } }
.reach-hit { fill: transparent; stroke: none; cursor: pointer; }
.reach-halo {
  fill: rgba(0, 122, 255, .25); stroke: var(--accent); stroke-width: 2;
  cursor: pointer; transition: fill .15s, transform .15s;
  animation: reach-pulse 1.8s ease-in-out infinite;
}
@keyframes reach-pulse {
  0%, 100% { stroke-opacity: .95; r: 8.5; }
  50% { stroke-opacity: .45; r: 10.5; }
}
.reach-halo:hover { fill: rgba(0, 122, 255, .65); }
.reach-halo.suggested { fill: rgba(52, 199, 89, .3); stroke: #34c759; }
.reach-halo.fee-rival { fill: rgba(255, 69, 58, .28); stroke: #ff453a; }
.reach-halo.fee-own { fill: rgba(0, 122, 255, .28); stroke: var(--accent); }
.reach-halo.fee-bank { fill: rgba(255, 159, 10, .28); stroke: #ff9f0a; }
.reach-halo.focused {
  stroke: #ffffff; stroke-width: 3.2;
  filter: drop-shadow(0 0 8px rgba(0, 122, 255, .9));
}

/* floating map controls */
.map-controls {
  position: absolute; top: 12px; right: 12px;
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(14, 18, 28, .85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px; padding: 4px; z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.map-ctrl-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 7px;
  color: #f4f7fb; font-size: 1.15rem; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s, transform .1s;
}
.map-ctrl-btn:hover { background: rgba(255, 255, 255, .12); color: #ffffff; }
.map-ctrl-btn:active { background: rgba(255, 255, 255, .22); transform: scale(.94); }
.gallery-claim {
  margin: 0 0 10px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid rgba(138, 180, 248, .35); background: rgba(138, 180, 248, .08);
}
.gallery-claim .primary { width: 100%; margin-top: 6px; }
.gallery-claim-list {
  display: flex; flex-direction: column; gap: 6px; margin-top: 6px;
}
.gallery-claim-list .primary { width: 100%; }
.gallery-claim-reserved {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 6px; font-size: .88rem;
}
body.home-offline #btn-create,
body.home-offline #btn-join,
body.home-offline #btn-watch,
body.home-offline #btn-records,
body.home-offline #btn-practice-code {
  opacity: .45;
  pointer-events: none;
  cursor: not-allowed;
}
body.home-offline .practice-code-row.home-network-gated,
body.home-offline #home-code {
  opacity: .55;
}
body.home-offline #home-code { pointer-events: none; }
#gallery-claim-sheet,
#endturn-overlay,
#odds-why-overlay,
#declare-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 11, 16, .88); backdrop-filter: blur(6px);
  animation: win-fade .2s ease-out;
}
.step-key-list {
  display: flex; flex-direction: column; gap: 4px; margin-top: 8px;
}
.step-key-list button { text-align: left; font-size: .85rem; padding: 7px 10px; }
.daily-board-list { margin: 4px 0 12px; padding-left: 1.3em; color: var(--ink-dim); }
.reach-halo.fee-free { fill: rgba(72, 187, 120, .55); }
.reach-halo.fee-free.suggested { fill: rgba(72, 187, 120, .85); }
.reach-halo.fee-bank { fill: rgba(232, 196, 106, .5); }
.reach-halo.fee-rival { fill: rgba(230, 90, 110, .55); stroke-width: 2.2; }
.reach-halo.fee-rival.suggested { fill: rgba(230, 90, 110, .82); }
@keyframes halo-breathe { 50% { fill: rgba(250, 224, 154, 1); } }
.reach-halo.fee-free.suggested { animation-name: halo-breathe-free; }
@keyframes halo-breathe-free { 50% { fill: rgba(110, 220, 150, 1); } }

/* Economy layer: Bank track fades, owned lines punch through. */
#board.economy-layer .rr-group:not(.owned) { opacity: .28; }
#board.economy-layer .rr-group.owned { opacity: 1; }
#board.economy-layer .owner-stripes { stroke-width: 2.2; }
#board.all-sold-flash .rr-group {
  animation: all-sold-pulse 1.6s ease-out;
}
@keyframes all-sold-pulse {
  0% { filter: brightness(1); }
  35% { filter: brightness(1.55) saturate(1.3); }
  100% { filter: brightness(1); }
}
body.fee-era .trip-fee-era { display: block; }

.trip-fee-era {
  display: none; color: #ffb4a2 !important; font-weight: 800; margin-top: 3px; letter-spacing: .04em;
}

/* Declared-race threatboard glance */
.threatboard {
  position: absolute; z-index: 4; top: 54px; right: 16px;
  max-width: min(280px, calc(100% - 32px));
  padding: 8px 10px; border-radius: 10px;
  border: 1px solid rgba(255,141,150,.45);
  background: rgba(14,17,26,.9); backdrop-filter: blur(7px);
  box-shadow: 0 8px 26px rgba(0,0,0,.35);
  font-size: .72rem;
}
.threat-head {
  font-family: var(--font-display); font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: #ff8d96; margin-bottom: 6px; font-size: .68rem;
}
.threat-row {
  display: grid; grid-template-columns: 10px 1fr; gap: 2px 8px;
  padding: 5px 0; border-top: 1px solid rgba(255,255,255,.06);
}
.threat-row:first-of-type { border-top: 0; }
.threat-swatch {
  grid-row: span 2; width: 8px; height: 8px; border-radius: 50%; margin-top: 4px;
}
.threat-row b { color: var(--ink); font-size: .78rem; }
.threat-meta, .threat-rival { grid-column: 2; color: var(--ink-dim); line-height: 1.3; }
.threat-row.exposed .threat-rival { color: #ff8d96; }
.threat-row.safe .threat-rival { color: #7dcfb6; }

.game-story {
  margin-top: 14px; text-align: left;
  padding: 12px 14px; border-radius: 10px;
  border: 1px solid rgba(232, 196, 106,.35);
  background: rgba(14,17,26,.45);
}
.game-story-title {
  font-family: var(--font-display); font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent); font-size: .72rem; margin-bottom: 6px;
}
.game-story p {
  margin: 0 0 6px; color: var(--ink); font-size: .88rem; line-height: 1.4;
}
.game-story p:last-child { margin-bottom: 0; }


/* ---------- decision clock ---------- */
.turn-timer {
  position: absolute; top: 16px; left: 16px; z-index: 6;
  width: 150px; height: 26px; border-radius: 13px;
  background: rgba(14, 17, 26, .8); border: 1px solid var(--line);
  overflow: hidden; backdrop-filter: blur(4px);
}
.timer-fill {
  position: absolute; inset: 0; width: 100%;
  background: linear-gradient(90deg, rgba(42, 157, 143, .55), rgba(232, 196, 106, .55));
  transition: width .25s linear;
}
.timer-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: ui-monospace, monospace; font-size: .8rem; color: var(--ink);
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
}
.turn-timer.urgent { border-color: var(--danger); }
.turn-timer.urgent .timer-fill { background: linear-gradient(90deg, rgba(230, 57, 70, .7), rgba(230, 57, 70, .4)); }
.turn-timer.urgent .timer-label { animation: timer-blink 1s step-end infinite; }
@keyframes timer-blink { 50% { opacity: .45; } }

/* ---------- timed game clock ---------- */
.game-timer {
  position: absolute; top: 16px; left: 178px; z-index: 6;
  height: 26px; padding: 0 12px; border-radius: 13px;
  display: flex; align-items: center;
  background: rgba(14, 17, 26, .8); border: 1px solid var(--line);
  backdrop-filter: blur(4px);
  font-family: ui-monospace, monospace; font-size: .8rem; color: var(--ink);
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
  white-space: nowrap;
}
.game-timer.urgent { border-color: var(--danger); animation: timer-blink 1s step-end infinite; }

/* ---------- deed catalog ---------- */
#store-overlay {
  position: absolute; inset: 0; z-index: 15;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 7, 12, .7);
  backdrop-filter: blur(3px);
  padding: 14px;
}
.store-modal {
  width: min(1160px, 100%); height: min(860px, 100%);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 18px 20px;
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 30px 90px rgba(0,0,0,.7);
}
.store-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.store-hint { min-width: 180px; }
.store-head h3 {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif; font-weight: 700; color: var(--ink);
  letter-spacing: .02em; font-size: 1.4rem; white-space: nowrap;
}
.store-hint { flex: 1; font-size: .8rem; color: var(--ink-dim); margin: 0; }
.store-head .ghost { flex: none; }
.store-body { flex: 1; min-height: 0; display: flex; gap: 14px; position: relative; }
.store-grid {
  flex: 1; overflow-y: auto; padding-right: 6px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  grid-auto-rows: max-content;
  gap: 12px; align-content: start;
}
.deed-card {
  display: flex; flex-direction: column; border-radius: var(--radius-md); overflow: hidden;
  cursor: pointer; background: rgba(14, 18, 28, 0.75);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color .15s, transform .12s, box-shadow .15s;
}
.deed-card:hover { border-color: rgba(0, 122, 255, 0.6); transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0,0,0,.5); }
.deed-card.selected { border-color: var(--accent); box-shadow: 0 0 18px rgba(0, 122, 255, .35); }
.deed-card.owned { opacity: .6; }
.deed-band {
  padding: 7px 10px; display: flex; align-items: center;
}
.deed-band .deed-name {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif; font-weight: 700; font-size: .92rem; line-height: 1.15;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.85);
  letter-spacing: .02em;
}
.deed-band.tall { width: 10px; padding: 0; border-radius: 3px; align-self: stretch; }
.deed-thumb {
  position: relative; width: 100%;
  background-size: 100% 100%; background-repeat: no-repeat;
}
.deed-thumb svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.deed-foot { padding: 8px 10px 10px; }
.deed-sub { display: flex; justify-content: space-between; align-items: center; font-size: .84rem; }
.deed-abbr { color: var(--ink-dim); font-weight: 700; letter-spacing: .04em; }
.deed-price { color: var(--accent); font-family: ui-monospace, monospace; font-weight: 700; }
.deed-stats { font-size: .74rem; color: var(--ink-dim); margin-top: 4px; }
.deed-cities {
  font-size: .72rem; line-height: 1.5; margin-top: 6px;
  color: #cfc9b8; font-variant: small-caps; letter-spacing: .03em;
  border-top: 1px dashed rgba(232, 196, 106, .18); padding-top: 5px;
}
.deed-links {
  font-size: .74rem; margin-top: 6px; color: var(--ink-dim);
}
.deed-links.linked { color: #7bd389; font-weight: 600; }
.deed-owner { font-size: .78rem; color: var(--ink-dim); display: inline-flex; align-items: center; gap: 5px; }
.owner-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.catalog-btn { grid-column: 1 / -1; font-size: .82rem; padding: 7px; }
.assist-control {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 8px;
  color: var(--ink-dim); font-size: .78rem;
}
.assist-control select {
  min-width: 0; flex: 1; color: var(--ink); background: rgba(10,13,20,.85);
  border: 1px solid var(--line); border-radius: 7px; padding: 6px;
}

/* First-game contextual guidance. */
.coachmark {
  position: fixed; left: 18px; bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 70; display: flex; align-items: center; gap: 8px;
  width: min(560px, calc(100vw - 36px));
  padding: 12px; border: 1px solid var(--accent); border-radius: 12px;
  background: rgba(20,26,38,.97); box-shadow: 0 18px 55px rgba(0,0,0,.58);
}
.coachmark > div { flex: 1; min-width: 0; }
.coachmark b, .coachmark span { display: block; }
.coachmark b { color: var(--accent); margin-bottom: 3px; }
.coachmark span { color: var(--ink-dim); font-size: .84rem; line-height: 1.4; }
.coachmark button { flex: none; padding: 7px 10px; font-size: .78rem; }

#mobile-sheet-toggle { display: none; }

.store-detail {
  width: 350px; flex: none;
  overflow-y: auto;
  background: rgba(12, 15, 23, .98); border: 1px solid rgba(232, 196, 106, .3);
  border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.detail-back { display: none; align-self: flex-start; padding: 5px 10px; font-size: .85rem; }
.detail-head { display: flex; gap: 10px; align-items: center; }
.detail-name { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; color: var(--ink); }
.detail-price { font-size: .88rem; color: var(--accent); }
.detail-map { border-radius: 10px; border: 1px solid var(--line); overflow: hidden; }

@media (max-width: 900px) {
  .store-detail {
    position: absolute; inset: 0; width: auto; z-index: 2;
    border-radius: 12px;
  }
  .detail-back { display: inline-block; }
}
.verdict {
  border-radius: 8px; padding: 8px 12px; font-weight: 700; text-align: center;
  letter-spacing: .04em; font-size: .9rem;
}
.tone-good { color: #7bd389; }
.tone-mid { color: var(--accent); }
.tone-bad { color: var(--danger); }
.verdict.tone-good { background: rgba(67, 170, 139, .15); border: 1px solid rgba(67, 170, 139, .4); }
.verdict.tone-mid { background: rgba(232, 196, 106, .12); border: 1px solid rgba(232, 196, 106, .35); }
.verdict.tone-bad { background: rgba(230, 57, 70, .12); border: 1px solid rgba(230, 57, 70, .4); }
.metric-list { display: flex; flex-direction: column; gap: 8px; }
.metric { font-size: .82rem; line-height: 1.45; }
.metric-label {
  display: block; text-transform: uppercase; letter-spacing: .08em;
  font-size: .68rem; color: var(--ink-dim);
}
.metric-value { color: var(--ink); }
.metric.tone-bad .metric-value { color: var(--danger); }

/* ---------- win overlay ---------- */
#win-overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  animation: win-fade .6s ease-out;
}
@keyframes win-fade { from { opacity: 0; } }
#win-overlay > img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; filter: brightness(.5) saturate(1.1);
}
.win-card {
  position: relative; z-index: 2; text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 42px 60px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 30px 90px rgba(0,0,0,.7);
  max-height: 88vh; overflow-y: auto; max-width: 94vw;
}
.win-kicker { color: var(--ink-dim); letter-spacing: .3em; font-size: .8rem; margin-bottom: 8px; text-transform: uppercase; }
#win-title {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif; font-weight: 800; font-size: 2.4rem; margin: 0 0 22px;
  background: linear-gradient(180deg, #ffffff, #8e9bae);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.win-confetti { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.win-confetti i {
  position: absolute; top: -12px; width: 9px; height: 14px; display: block;
  animation: confetti-fall linear infinite;
}
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

@media (max-width: 900px) {
  .game-layout { display: block; position: relative; }
  .map-pane { width: 100%; height: 100%; }
  .side-pane {
    position: absolute; z-index: 11; left: 0; right: 0; bottom: 0;
    width: 100%; border-left: none; border-top: 1px solid var(--line);
    max-height: 56%; padding: 8px; background: rgba(23,30,44,.96);
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -12px 40px rgba(0,0,0,.45);
    transition: max-height .2s ease;
  }
  #mobile-sheet-toggle {
    display: block; order: -2; position: sticky; top: 0; z-index: 3;
    width: 100%; padding: 6px; font-size: .78rem;
    background: rgba(23,30,44,.98);
  }
  .side-pane.sheet-collapsed { max-height: 48px; overflow: hidden; }
  .side-pane.sheet-collapsed > :not(#mobile-sheet-toggle) { display: none !important; }
  .side-pane.replay-hidden { display: none; }
  /* On a phone the actions are what matter — put the turn panel first. */
  #turn-panel { order: -1; }
  .logo { font-size: 2.3rem; }
  .home-card { padding: 24px 22px; }
  .help-card { padding: 20px 18px; }
  .banner { font-size: .92rem; padding: 10px 16px; max-width: 92%; }
  .trip-hud {
    top: 48px; left: 6px; right: 6px; max-width: none;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0; padding: 0; overflow: hidden;
  }
  .trip-hud > div { min-width: 0; padding: 5px 7px; }
  .trip-hud-title { grid-column: 1 / -1; min-width: 0 !important; }
  .threatboard {
    top: auto; bottom: auto; right: 6px; left: 6px; max-width: none;
    position: relative; margin: 6px; order: 2;
    max-height: 28vh; overflow: auto;
  }
  #map-pane .threatboard { position: absolute; bottom: 56px; left: 6px; right: 6px; margin: 0; }
  .midgame-focus { left: 8px; right: 8px; bottom: 8px; }
  .coachmark { align-items: stretch; flex-wrap: wrap; }
  .coachmark > div { flex-basis: 100%; }
  .replay-coach { bottom: 96px; }
  .first-trip-board { left: 6px; right: 6px; bottom: auto; top: auto; }
  #turn-panel .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  #turn-panel .actions button.primary { grid-column: 1 / -1; }
  .route-commit-drawer { margin-top: 8px; padding: 9px; border-radius: 16px; }
  .route-commit-presets { grid-template-columns: 1fr; }
  .route-commit-presets .route-commit-button,
  .route-commit-presets .route-fee-pill { width: 100%; }
  .route-catalog-button { justify-self: stretch; }
}

/* Touch devices: 16px inputs stop iOS Safari from zooming the page on focus. */
@media (pointer: coarse) {
  input { font-size: 16px; }
  #turn-panel .actions button { padding: 11px 14px; }
}

/* Short viewports (phone landscape). */
@media (max-height: 560px) {
  .logo { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
  .win-confetti, .vignette { display: none !important; }
}

/* ---------------------------------------------------------------- new-feature styles */
/* Hall of Records overlay shares the help-overlay treatment. */
#records-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5, 7, 12, .72);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
#records-overlay.hidden { display: none; }
#records-body h3 {
  font-family: var(--font-formal); color: var(--ink);
  letter-spacing: .04em; margin: 18px 0 8px;
  border-bottom: 1px solid rgba(232, 196, 106, .25); padding-bottom: 6px;
}
.records-btn { margin: 0 auto 10px; display: block; font-size: .85rem; }
.record-game { font-size: .92rem; margin: 8px 0; color: var(--ink-dim); }
.record-game b { color: var(--ink); }
.record-replay-row { display: flex; gap: 6px; margin-top: 4px; }
.record-replay-row .record-replay { font-size: .82rem; padding: 2px 10px; }
.record-ach { margin-top: 3px; }
.ach-mini {
  display: inline-block; font-size: .78rem; color: var(--ink-dim);
  border: 1px solid rgba(232, 196, 106, .25); border-radius: 999px;
  padding: 1px 8px; margin: 2px 3px 0 0;
}

/* Win-screen extras: series score + achievement chips. */
.series-line { margin: 12px 0 4px; font-size: 1rem; color: var(--ink); }
.ach-chips { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.ach-chip {
  font-size: .82rem; color: var(--ink-dim);
  border: 1px solid rgba(232, 196, 106, .35); border-radius: 999px;
  padding: 3px 10px; background: rgba(232, 196, 106, .07);
}
.ach-chip b { color: var(--accent); }

/* Chess-clock bank chips in the players panel. */
.bank-clock {
  font-size: .78rem; color: var(--ink-dim); margin-left: 6px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.bank-clock.urgent { color: #e76f51; }
.bank-clock.overtime { color: #e63946; font-weight: 700; }

/* Conductor's pick. */
.pick-hint { margin-top: 8px; font-size: .88rem; text-align: left; }
.pick-hint b { color: var(--accent); }
.deed-card.pick { outline: 2px solid var(--accent); outline-offset: -2px; }
.pick-badge {
  margin-left: auto; flex-shrink: 0;
  font-size: .68rem; background: var(--accent); color: #241a10;
  border-radius: 999px; padding: 2px 8px; font-weight: 700;
  white-space: nowrap;
}

/* Presence: who is at the table right now. */
.presence { margin-left: 5px; font-size: .62rem; vertical-align: 1px; }
.presence.on { color: #43aa8b; text-shadow: 0 0 5px rgba(67, 170, 139, .8); }
.presence.off { color: #5a6372; }

/* Take-backs + commentary in the log. */
.undo-btn { margin-top: 8px; }
.entry .remark { color: var(--accent); font-style: italic; }

/* Host proxy: acting for an offline player is explicit and clearly labeled. */
.proxy-note {
  margin: 8px 0; padding: 8px 10px; border-radius: 8px; font-size: .88rem;
  background: rgba(232, 196, 106, .12); border: 1px solid rgba(232, 196, 106, .4);
  display: flex; align-items: center; gap: 8px;
}
.proxy-note b { color: var(--accent); }
.proxy-note button { padding: 3px 10px; flex: none; margin-left: auto; }
.proxy-btn { margin-top: 8px; }
.god-desk-btn {
  width: 100%; margin: 0 0 8px; font-size: .82rem; letter-spacing: .04em;
  border-color: rgba(232, 196, 106, .35);
}
.god-desk-btn.on {
  color: #171410; background: linear-gradient(160deg, #f2d488, var(--accent-deep, #c9a227));
  border-color: transparent; font-weight: 700;
}
.god-desk-badge {
  margin: 0 0 8px; padding: 6px 10px; border-radius: 8px; font-size: .78rem;
  color: var(--accent); background: rgba(232, 196, 106, .1);
  border: 1px solid rgba(232, 196, 106, .3);
}
.god-log-toggle {
  display: flex; align-items: center; gap: 6px; margin: -2px 0 10px;
  font-size: .78rem; color: var(--muted, #9aa3b5); cursor: pointer; user-select: none;
}
.god-log-toggle input { accent-color: var(--accent, var(--accent-gold)); }
.god-bank-offer {
  margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; font-size: .8rem;
  color: var(--ink, #e8ecf4); background: rgba(69, 123, 157, .15);
  border: 1px solid rgba(69, 123, 157, .4);
}
.god-bank-offer .actions { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.rr-chip-buy, .rr-chip-offer { cursor: pointer; outline: 1px dashed rgba(255,255,255,.35); }
.rr-chip-buy:hover, .rr-chip-offer:hover { outline-color: var(--accent, var(--accent-gold)); }
.god-bank { display: inline-flex; gap: 2px; flex: none; }

/* Tap-to-spotlight a railroad: invisible fat hit strokes over every line. */
.rr-hit {
  stroke: transparent; stroke-width: 7; stroke-linecap: round;
  fill: none; pointer-events: stroke; cursor: pointer;
}

/* ---------- table life ---------- */
.waiting-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  /* Right padding clears the fixed corner buttons (⌂ ? 🔊 occupy ~156px)
   * so the clock's margin-left:auto never lands underneath them. */
  padding: 6px calc(160px + env(safe-area-inset-right, 0px)) 6px 12px;
  background: linear-gradient(90deg, rgba(14,17,26,.95), rgba(30,36,52,.9));
  border-bottom: 1px solid var(--line); font-size: .86rem; z-index: 8;
}
.waiting-strip .wait-name { font-weight: 700; }
.waiting-strip .wait-status { color: var(--ink-dim); }
.waiting-strip .wait-clock {
  font-family: ui-monospace, monospace; color: var(--accent); margin-left: auto;
}
.waiting-strip button { padding: 2px 8px; font-size: .75rem; }
.host-tools { padding: 8px 10px; }
.host-tools h3 { margin: 0 0 6px; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-dim); }
.host-tools button { margin: 3px 4px 3px 0; }
.host-transfer-row { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.host-transfer-row select { flex: 1; min-width: 0; }
.race-alert {
  position: absolute; top: 52px; left: 50%; transform: translateX(-50%);
  z-index: 7; max-width: min(92%, 420px); padding: 8px 14px;
  background: rgba(90, 20, 28, .88); border: 1px solid rgba(230, 57, 70, .55);
  border-radius: 10px; color: #fce8ea; font-size: .88rem; text-align: center;
  backdrop-filter: blur(4px);
  animation: race-pulse 1.6s ease-in-out infinite;
}
.race-alert.hidden { display: none; }
@keyframes race-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230, 57, 70, .25); }
  50% { box-shadow: 0 0 18px 2px rgba(230, 57, 70, .35); }
}
.threatboard.threatboard-live { border-color: rgba(230, 57, 70, .45); }
.threatboard.drama .threat-row.exposed {
  background: rgba(230, 57, 70, .12);
}
.catchup-banner {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 9; padding: 6px 14px; border-radius: 999px;
  background: rgba(14,17,26,.9); border: 1px solid var(--line);
  font-size: .8rem; color: var(--accent); letter-spacing: .06em;
}
.catchup-digest {
  position: absolute; left: 12px; right: 12px; bottom: 14px; z-index: 10;
  max-height: 42%; overflow: auto; padding: 12px 14px; border-radius: 12px;
  background: rgba(14,17,26,.94); border: 1px solid rgba(232, 196, 106,.4);
  box-shadow: 0 12px 32px rgba(0,0,0,.45); text-align: left;
}
.catchup-digest strong { display: block; color: var(--accent); margin-bottom: 6px; }
.catchup-digest ul { margin: 0 0 8px; padding-left: 1.2em; font-size: .85rem; color: var(--ink-dim); }
.catchup-digest li { margin: 2px 0; }
.city-finder { display: flex; gap: 6px; margin: 0 0 8px; }
.city-finder input { flex: 1; min-width: 0; font-size: .9rem; padding: 7px 9px; }
.bid-custom { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.bid-custom input { width: 7rem; }
.practice-code-row { margin-top: 6px; }
.practice-code-row input { text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.social-rail { margin: 8px 0 12px; text-align: left; }
.social-rail .picker-label { margin-top: 8px; }
.lobby-schedule { color: var(--accent) !important; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lobby-table-card {
  margin: 10px 0 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(232, 196, 106, .06);
  font-size: .88rem;
  color: var(--ink-dim);
}
.lobby-table-card strong { display: block; color: var(--accent); margin-bottom: 4px; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; }
.lobby-table-extras { margin-top: 4px; font-size: .8rem; opacity: .85; }
.auction-advice { margin-top: 8px; }
.auction-advice.tone-good { color: var(--accent-2); }
.auction-advice.tone-bad { color: var(--danger); }
.auction-advice.tone-mid { color: var(--accent); }
.schedule-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.schedule-row input { flex: 1; min-width: 140px; }
.schedule-hint { margin: 0 0 8px; }
#win-story-overlay {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 7, 12, .78); backdrop-filter: blur(5px);
}
#win-story-overlay.hidden { display: none; }
.win-story-card {
  background: rgba(14, 17, 26, .92); border: 1px solid rgba(232, 196, 106, .45);
  border-radius: 14px; padding: 28px 32px; max-width: 420px; width: 92vw; text-align: center;
}
.first-trip-board {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 12;
  pointer-events: none;
}
.first-trip-board.hidden { display: none; }
.first-trip-board-inner {
  pointer-events: auto;
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: 12px;
  background: rgba(14, 17, 26, .92); border: 1px solid rgba(232, 196, 106, .45);
  box-shadow: 0 10px 28px rgba(0,0,0,.4);
}
.first-trip-board .first-trip-cue { font-size: 1.6rem; line-height: 1; margin: 0; flex-shrink: 0; }
.first-trip-board-copy { flex: 1; min-width: 0; text-align: left; }
.first-trip-board-copy strong { display: block; color: var(--accent); font-size: .92rem; }
.first-trip-board-copy p { margin: 2px 0 0; font-size: .8rem; color: var(--ink-dim); line-height: 1.35; }
#btn-first-trip-dismiss { padding: 4px 8px; flex-shrink: 0; }
.rematch-companions {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  margin: 8px 0 4px;
}
.trade-fair {
  margin: 8px 0 0; padding: 8px 10px; border-radius: 8px;
  background: rgba(232, 196, 106,.08); border: 1px solid rgba(232, 196, 106,.28);
  font-size: .85rem; color: var(--accent);
}
.trade-fair-strategic {
  margin: 4px 0 0; padding: 6px 10px; border-radius: 8px;
  background: rgba(69, 123, 157, .12); border: 1px solid rgba(69, 123, 157, .35);
  font-size: .82rem; color: var(--ink-dim);
}
.declare-sheet-lines {
  margin: 8px 0 12px; padding: 0; list-style: none;
  font-size: .88rem; line-height: 1.55; color: var(--ink);
}
.declare-sheet-lines li { margin: 4px 0; }
.declare-sheet-verdict {
  margin: 0 0 12px; font-size: .9rem; color: var(--accent);
}
.win-story-beat {
  font-family: var(--font-formal); font-size: 1.35rem; line-height: 1.35;
  color: var(--ink); min-height: 4.5em; display: flex; align-items: center; justify-content: center;
}
@media (max-width: 900px) {
  .waiting-strip { font-size: .8rem; padding: 5px calc(160px + env(safe-area-inset-right, 0px)) 5px 8px; gap: 6px; }
  .race-alert { top: 44px; font-size: .8rem; padding: 6px 10px; }
  .side-pane.sheet-collapsed #host-tools,
  .side-pane.sheet-collapsed #rr-panel,
  .side-pane.sheet-collapsed #log-panel,
  .side-pane.sheet-collapsed #chat-panel { display: none; }
  .side-pane #turn-panel { order: -1; }
  #map-pane .milepost,
  #board .node-hit { stroke-width: 14; }
}

.fast-mode-opt {
  display: block; margin: 0 0 10px; padding: 8px 10px;
  border: 1px solid rgba(232, 196, 106, .35); border-radius: 8px;
  background: rgba(232, 196, 106, .07);
}
.fast-mode-opt .opt-hint { display: inline; }

/* ---------- reference dialog ---------- */
.reference-dialog {
  max-width: 620px; width: 92vw;
  background: rgba(12, 16, 26, .94);
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 16px;
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .7);
  padding: 0; color: #fff;
}
.dialog-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.dialog-header h3 { margin: 0; font-size: 1.1rem; font-weight: 700; color: var(--accent-gold); }
.dialog-close {
  background: transparent; border: none; font-size: 1.2rem;
  color: rgba(255, 255, 255, .6); cursor: pointer; padding: 4px 8px;
}
.dialog-close:hover { color: #fff; }
.reference-body { padding: 16px 18px; max-height: 72vh; overflow-y: auto; }
.reference-tabs {
  display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid rgba(255, 255, 255, .1);
  padding-bottom: 8px;
}
.ref-tab-btn {
  background: transparent; border: 1px solid transparent; color: rgba(255, 255, 255, .6);
  padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: .85rem; font-weight: 600;
  transition: all .15s ease;
}
.ref-tab-btn:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.ref-tab-btn.active { color: var(--accent); background: rgba(0, 122, 255, .15); border-color: rgba(0, 122, 255, .3); }
.ref-tab-content { display: none; }
.ref-tab-content.active { display: block; }
.ref-section { margin-bottom: 18px; }
.ref-section h4 { margin: 0 0 8px; font-size: .95rem; color: var(--accent-gold); }
.ref-list { margin: 8px 0 0 18px; padding: 0; font-size: .84rem; line-height: 1.5; color: rgba(255, 255, 255, .8); }
.engine-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-top: 10px; }
.engine-card {
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 10px; padding: 12px;
}
.engine-card.highlight { border-color: rgba(232, 196, 106, .4); background: rgba(232, 196, 106, .06); }
.engine-title { font-weight: 700; font-size: .9rem; color: #fff; margin-bottom: 2px; }
.engine-cost { font-size: .8rem; font-weight: 600; color: var(--accent); margin-bottom: 6px; }
.engine-card.highlight .engine-cost { color: var(--accent-gold); }
.engine-desc { margin: 0; font-size: .78rem; color: rgba(255, 255, 255, .75); line-height: 1.35; }
.ref-search-row { margin-bottom: 12px; }
.ref-search-row input {
  width: 100%; padding: 8px 12px; border-radius: 8px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .15);
  color: #fff; font-size: .85rem;
}
.ref-rr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.ref-rr-item {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, .03); border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 8px; padding: 8px 10px;
}
.ref-rr-color { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ref-rr-info { flex: 1; min-width: 0; }
.ref-rr-name { font-weight: 600; font-size: .84rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ref-rr-meta { font-size: .74rem; color: rgba(255, 255, 255, .6); margin-top: 1px; }

/* ---------- train radar ---------- */
.train-radar {
  position: absolute; top: 12px; left: 12px;
  display: flex; gap: 6px; flex-wrap: wrap; max-width: calc(100% - 180px);
  background: rgba(14, 18, 28, .85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px; padding: 4px 6px; z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.radar-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 6px; padding: 3px 8px; font-size: .78rem; color: #fff;
  cursor: pointer; transition: all .15s ease;
}
.radar-chip:hover {
  background: rgba(255, 255, 255, .15); border-color: rgba(255, 255, 255, .3);
  transform: translateY(-1px);
}
.radar-chip.radar-actor {
  border-color: var(--accent-gold); background: rgba(232, 196, 106, .15);
}
.radar-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.radar-name { font-weight: 600; }
.radar-node { font-size: .72rem; color: rgba(255, 255, 255, .6); }

/* ---------- player portfolio inspector ---------- */
.player-portfolio-btn {
  background: transparent; border: none; padding: 2px 4px;
  font-size: .85rem; cursor: pointer; opacity: .75;
  transition: opacity .15s, transform .1s;
}
.player-portfolio-btn:hover { opacity: 1; transform: scale(1.15); }

.portfolio-dialog {
  max-width: 540px; width: 92vw; padding: 0; color: var(--ink);
  background: rgba(15, 20, 28, .94);
  border: 1px solid rgba(255, 255, 255, .15); border-radius: 16px;
  backdrop-filter: blur(24px) saturate(1.5); -webkit-backdrop-filter: blur(24px) saturate(1.5);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .72);
}
.portfolio-dialog::backdrop { background: rgba(8, 11, 16, .72); backdrop-filter: blur(4px); }
.portfolio-body { padding: 16px 18px; max-height: 72vh; overflow-y: auto; }
.portfolio-header-title {
  display: flex; align-items: center; gap: 8px;
}
.portfolio-dot {
  width: 12px; height: 12px; border-radius: 50%;
}
.portfolio-summary-card {
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 12px; padding: 14px; margin-bottom: 16px;
}
.portfolio-stat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center;
}
.portfolio-stat-label {
  display: block; font-size: .72rem; color: rgba(255, 255, 255, .6); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px;
}
.portfolio-stat-val {
  font-size: 1.05rem; font-weight: 700; color: #fff;
}
.portfolio-stat-val.cash-val { color: #52c41a; }
.portfolio-stat-val.gold-val { color: var(--accent-gold); }
.portfolio-engine-row {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, .08); font-size: .8rem;
}
.portfolio-engine-badge {
  background: rgba(0, 122, 255, .15); border: 1px solid rgba(0, 122, 255, .3);
  color: #8ab4f8; padding: 2px 8px; border-radius: 6px; font-weight: 600;
}
.portfolio-performance {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
  margin-top: 12px;
}
.performance-gauge {
  padding: 9px; border-radius: 9px; background: rgba(0, 122, 255, .07);
  border: 1px solid rgba(0, 122, 255, .18);
}
.performance-gauge-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.performance-gauge-head span {
  color: var(--ink-dim); font-size: .65rem; text-transform: uppercase; letter-spacing: .08em;
}
.performance-gauge-head strong { color: var(--ink); font: 700 .66rem/1.2 ui-monospace, "SF Mono", monospace; text-align: right; }
.performance-gauge-track {
  height: 7px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, .08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35);
}
.performance-gauge-track span {
  display: block; width: var(--gauge-value); height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  box-shadow: 0 0 12px rgba(0, 122, 255, .45);
}
.performance-gauge-gold { background: rgba(232, 196, 106, .06); border-color: rgba(232, 196, 106, .2); }
.performance-gauge-gold .performance-gauge-track span {
  background: linear-gradient(90deg, #a8792d, var(--accent-gold));
  box-shadow: 0 0 12px rgba(232, 196, 106, .4);
}
.portfolio-declared-badge {
  background: rgba(232, 196, 106, .2); border: 1px solid rgba(232, 196, 106, .4);
  color: var(--accent-gold); padding: 2px 8px; border-radius: 6px; font-weight: 700;
}
.portfolio-bankrupt-badge {
  background: rgba(255, 77, 79, .2); border: 1px solid rgba(255, 77, 79, .4);
  color: #ff7875; padding: 2px 8px; border-radius: 6px; font-weight: 700;
}
.portfolio-journey-row {
  display: flex; justify-content: space-between; margin-top: 8px; font-size: .78rem; color: rgba(255, 255, 255, .7);
}
.portfolio-deeds-section h4 {
  margin: 0 0 10px; font-size: .92rem; color: var(--accent-gold);
}
.portfolio-regions-grid {
  display: flex; flex-direction: column; gap: 10px; max-height: 280px; overflow-y: auto;
}
.portfolio-region-group {
  background: rgba(255, 255, 255, .02); border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 8px; padding: 8px 10px;
}
.portfolio-region-title {
  font-size: .74rem; font-weight: 700; color: rgba(255, 255, 255, .6); text-transform: uppercase; margin-bottom: 6px;
}
.portfolio-rr-list {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.portfolio-rr-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 6px; padding: 4px 8px; font-size: .78rem; color: #fff;
  cursor: pointer; transition: all .12s;
}
.portfolio-rr-chip:hover {
  background: rgba(255, 255, 255, .15); border-color: rgba(255, 255, 255, .3);
  transform: translateY(-1px);
}
.portfolio-rr-color { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.portfolio-rr-name { font-weight: 600; }
.portfolio-rr-price { font-size: .72rem; color: rgba(255, 255, 255, .6); }
