:root {
  color-scheme: dark;
  --pine: #171e19;
  --pine-deep: #101612;
  --olive: #29322a;
  --cream: #f6e9cd;
  --muted: #ccbda1;
  --brass: #e1b56a;
  --gold: #f0c47b;
  --rust: #763e2e;
  --error: #ffc5ad;
  --line: #756951;
  --body: 'Barlow Semi Condensed', 'Arial Narrow', sans-serif;
  --title: 'Cinzel', Georgia, serif;
  --reading: 'Instrument Serif', Georgia, serif;
  font: 500 17px/1.35 var(--body);
  color: var(--cream);
  background: var(--pine-deep);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-inline-size: 280px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; min-block-size: 44px; }
button:disabled { cursor: default; opacity: .53; }
input { min-block-size: 46px; width: 100%; background: #141a16; border: 1px solid #817259; border-radius: 3px; padding: 8px 11px; }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid #ffe3a5; outline-offset: 3px; }
h1, h2, p, ol, ul { margin: 0; }
a { color: #ffda9a; }
.primary, .secondary, .quiet-button { border-radius: 3px; padding: 8px 15px; font-weight: 700; }
.primary { color: #241b10; background: #e9b76a; border: 1px solid #ffdb92; box-shadow: inset 0 -2px #a3723b; }
.primary:not(:disabled):hover { background: #ffcc7b; }
.primary:not(:disabled):active { transform: translateY(1px); }
.secondary, .quiet-button { background: transparent; border: 1px solid #867354; }
.secondary:not(:disabled):hover, .quiet-button:not(:disabled):hover { background: #3c4635; }
.quiet-button { border-color: transparent; }
.quiet-button[aria-pressed=true] { background: #3a4736; border-color: #a99165; }

.utility { position: relative; z-index: 3; display: flex; align-items: center; gap: 10px 22px; justify-content: space-between; padding: 4px clamp(12px, 3.3vw, 48px); min-height: 58px; background: #171e19; border-bottom: 1px solid #64573f; }
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; background: none; border: 0; padding: 0; font: 700 clamp(.76rem, 2.2vw, 1rem)/1 var(--title); color: #f6d194; letter-spacing: .1em; }
.rail-mark { position: relative; display: grid; gap: 3px; padding: 4px 0; width: 26px; rotate: -24deg; }
.rail-mark::before, .rail-mark::after { content: ''; position: absolute; inset-block: 0; width: 2px; background: currentColor; }
.rail-mark::before { left: 7px; }
.rail-mark::after { right: 7px; }
.rail-mark i { height: 2px; background: currentColor; }
.utilities { display: flex; align-items: center; gap: 2px; }
.utilities .quiet-button { padding-inline: 8px; }
.language-button { width: 44px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 3px; background: transparent; }
.language-button[aria-pressed=true] { border-color: #b39867; background: #29362b; }
.flag { position: relative; display: block; width: 24px; height: 16px; border-radius: 1px; overflow: hidden; border: 1px solid #e7ddc6; }
.flag-fr { background: linear-gradient(90deg,#274a9a 0 33.33%,#fff7ed 33.33% 66.66%,#d23949 66.66%); }
.flag-en { background: linear-gradient(0deg,transparent 38%,#ce3b4b 38% 62%,transparent 62%),linear-gradient(90deg,transparent 41%,#ce3b4b 41% 59%,transparent 59%),linear-gradient(0deg,transparent 30%,#fff 30% 70%,transparent 70%),linear-gradient(90deg,transparent 35%,#fff 35% 65%,transparent 65%),linear-gradient(33deg,transparent 42%,#fff 42% 57%,transparent 57%),linear-gradient(-33deg,transparent 42%,#fff 42% 57%,transparent 57%),#28477b; }
.room-summary { margin-inline-end: auto; }
.room-summary button { font-size: .94rem; padding-inline: 10px; }

.station { min-height: max(630px, calc(100svh - 112px)); isolation: isolate; position: relative; display: grid; align-items: end; overflow: hidden; }
.station-picture, .station-shade, .station-atmosphere { position: absolute; z-index: -1; inset: 0; pointer-events: none; }
.station-picture { background: #414639 url('/assets/locomotive.webp') 50% 46% / cover no-repeat; transform-origin: 75% 40%; animation: station-camera 22s ease-in-out infinite alternate; }
.station-atmosphere span { position: absolute; left: 60%; top: 14%; width: 23%; height: 14%; opacity: 0; background: radial-gradient(ellipse at 61% 69%,#a79d8d9e,transparent 67%); filter: blur(9px); transform-origin: 81% 84%; animation: station-steam 8s linear infinite; }
.station-atmosphere i { position: absolute; left: 82%; top: 37%; width: 3px; height: 3px; border-radius: 50%; background: #ffd591; opacity: 0; animation: station-ember 5.1s ease-out infinite; }
.station-atmosphere i:nth-of-type(2) { left: 88%; top: 40%; animation-delay: 1.1s; }
.station-atmosphere i:nth-of-type(3) { left: 92%; top: 43%; animation-delay: 2.3s; }
@keyframes station-camera { from { transform: scale(1); } to { transform: scale(1.025); } }
@keyframes station-steam { 0% { opacity: 0; transform: scale(.67) translate(6%,10%); } 33% { opacity: .36; } 100% { opacity: 0; transform: scale(1.45) translate(-39%,-29%); } }
@keyframes station-ember { 0%,30% { opacity: 0; transform: none; } 43% { opacity: .85; } 100% { opacity: 0; transform: translate(60px,-52px) scale(.25); } }
.station-shade { background: linear-gradient(0deg,rgba(9,17,12,.97),rgba(11,19,14,.32) 56%,transparent 79%),linear-gradient(90deg,#111b1485,transparent 48%); }
.station-content { padding: 110px clamp(22px,6vw,96px) clamp(30px,6vh,75px); display: grid; grid-template-columns: minmax(0,1fr) minmax(280px,350px); align-items: end; gap: 30px 8vw; }
.title-block h1 { font: 800 clamp(4rem,11vw,11rem)/.78 var(--title); letter-spacing: -.08em; color: #f9e5bb; text-shadow: 0 3px 20px #111710; }
.title-block h1 span { color: #edba70; }
.title-block p { margin-top: 28px; max-width: 33ch; font: 400 clamp(1.3rem,2.8vw,2rem)/1.05 var(--reading); }
.title-block .game-credit { margin-top: 11px; font: 500 .86rem/1.35 var(--body); color: #e5d1a9; }
.entry-form { position: relative; padding: clamp(18px,3vw,34px); display: grid; gap: 10px; background: #19211bf5; border: 1px solid #a78958; box-shadow: 0 13px 29px #10181183; }
.entry-form::before, .lobby-wrap::before { content: ''; position: absolute; top: -2px; inset-inline: 18px; height: 3px; background: #d4ad6d; }
.entry-form h2 { margin-bottom: 6px; font: 700 clamp(1.05rem,2.8vw,1.46rem) var(--title); }
.entry-form label { color: #f1e1bc; }
.entry-form .primary { margin-top: 2px; }
.join-fields { display: grid; gap: 7px; }
.join-input { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px; }
#room-code { text-transform: uppercase; letter-spacing: .09em; }
.entry-status, .error { color: var(--error); }

.lobby { min-height: calc(100svh - 118px); background: radial-gradient(ellipse at center,#334034,#141b15 74%); padding: clamp(25px, 6vw, 100px) 16px; }
.lobby-wrap { margin-inline: auto; max-width: 800px; position: relative; border: 1px solid #9a815a; background: #20291f; padding: clamp(18px, 4vw, 48px); }
.lobby-head { margin-bottom: 20px; }
.lobby-head h1 { font: 700 clamp(1.65rem,5vw,3.45rem)/1.08 var(--title); }
.lobby-head p { margin-top: 5px; color: #decba5; }
.lobby-seats { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.lobby-seat { display: flex; align-items: center; gap: 11px; background: #151d17; min-height: 65px; padding: 10px 13px; border: 1px solid #5e624a; }
.lobby-seat strong { flex: 1; overflow-wrap: anywhere; }
.lobby-seat button { padding-inline: 8px; }
.lobby-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 20px; }
.lobby-actions .primary { margin-inline-start: auto; }
.seat-icon, .player-color { width: 13px; height: 13px; border: 2px solid #271f16; outline: 1px solid #e2ca9e; background: var(--player,#a99773); rotate: 45deg; flex: 0 0 auto; }
.lobby-options { display: flex; align-items: center; gap: 8px; flex-basis: 100%; color: var(--muted); margin-top: 5px; }
.lobby-options input { width: 19px; min-height: 22px; }

.table { min-height: calc(100svh - 106px); display: grid; grid-template-rows: auto minmax(350px,1fr) auto; }
.table-head { display: flex; justify-content: space-between; align-items: stretch; gap: 13px; padding: 8px clamp(9px,2.2vw,26px); background: #242e24; border-bottom: 1px solid #857153; }
.turn-indicator { min-width: 160px; display: grid; align-content: center; gap: 3px; }
.turn-indicator strong { font: 700 .98rem/1.16 var(--title); }
.turn-indicator span { color: #dac89e; font-size: .9rem; }
.player-line { display: flex; align-items: stretch; overflow-x: auto; gap: 7px; scrollbar-width: thin; }
.player-pill { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; min-width: 94px; background: #151e17; color: #f7ebce; border: 1px solid #707253; text-align: start; padding: 4px 9px; border-radius: 3px; }
.player-pill[aria-pressed=true] { border-color: #e6b26d; }
.player-pill.active-seat { box-shadow: inset 0 -3px #c39d62; }
.player-pill .player-color { grid-row: span 2; width: 10px; height: 10px; }
.player-pill small { color: #e2cda4; font-size: .8rem; }
.player-pill strong { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.table-body { position: relative; display: grid; grid-template-columns: minmax(0,1fr) minmax(265px,325px); min-height: 0; }
.map-panel { min-width: 0; min-height: 360px; position: relative; overflow: hidden; background: #272a20; border-inline-end: 1px solid #8b7650; }
.map-viewport { position: absolute; inset: 0; cursor: grab; touch-action: none; overflow: hidden; }
.map-viewport.dragging { cursor: grabbing; }
.map-viewport.targeting { cursor: crosshair; }
.map-viewport canvas { display: block; width: 100%; height: 100%; }
.map-tools { position: absolute; display: flex; flex-direction: column; right: 12px; bottom: 14px; gap: 3px; }
.map-tools button { min-width: 44px; padding: 5px; color: #fff2cf; background: #182017; border: 1px solid #bd9b63; border-radius: 2px; font-weight: 700; }
.map-tools button:hover { background: #3c4937; }
.map-caption, .map-message { position: absolute; pointer-events: none; padding: 7px 11px; background: #172019f5; border: 1px solid #b4a076; }
.map-caption { left: 10px; top: 11px; max-width: calc(100% - 76px); }
.map-message { left: 10px; bottom: 14px; max-width: calc(100% - 76px); }
.turn-banner { position: absolute; pointer-events: none; z-index: 2; inset: 28% 0 auto; display: grid; justify-items: center; gap: 4px; padding: 17px; color: #fff1cc; background: linear-gradient(90deg,transparent,#161e16ee 19% 81%,transparent); text-shadow: 0 2px 4px #070907; font: 700 clamp(1.3rem,4.7vw,3.3rem)/1.03 var(--title); animation: turn-in 1.48s ease both; }
.turn-banner small { font: 600 clamp(.87rem,1.8vw,1.3rem)/1 var(--body); color: #f9d795; }
@keyframes turn-in { 0% { opacity: 0; transform: translateY(10px); } 15%,71% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-7px); } }

.ledger { background: #242c22; min-width: 0; display: grid; grid-template-rows: auto minmax(0,1fr); }
.ledger-tabs { display: grid; grid-template-columns: 1.16fr 1fr .72fr; border-bottom: 1px solid #7c6a4d; }
.ledger-tabs button { border: 0; border-bottom: 2px solid transparent; color: #e7d7b6; background: #1b231b; padding: 7px 4px; font-weight: 700; }
.ledger-tabs button:hover { background: #303b2d; }
.ledger-tabs button[aria-pressed=true] { border-bottom-color: #e8b86e; color: #ffdc99; background: #313a2c; }
.ledger-content { min-height: 0; max-height: max(420px, calc(100svh - 310px)); overflow: auto; padding: 12px; scrollbar-color: #94805a #20281e; }
.ledger-head { margin-bottom: 10px; display: flex; align-items: baseline; flex-wrap: wrap; justify-content: space-between; gap: 3px 9px; }
.ledger-head h2, .tool-heading { font: 700 1.03rem var(--title); }
.ledger-head span { color: #dec99f; font-size: .88rem; }
.contract-list { display: grid; gap: 8px; }
.contract { color: #2d2115; background: #eee0bf; border: 1px solid #c0a371; border-radius: 3px; display: grid; text-align: start; width: 100%; padding: 0; transform-origin: top; box-shadow: 0 4px 6px #111a1370; }
.contract:hover { background: #fff0cb; translate: 0 -1px; }
.contract-dealt { animation: deal-contract .38s cubic-bezier(.2,.65,.3,1) both; }
@keyframes deal-contract { from { opacity: .2; transform: translateY(-11px) rotate(-2deg); } to { opacity: 1; transform: none; } }
.contract-title { padding: 6px 9px; display: flex; justify-content: space-between; font-weight: 700; background: #473d2a; color: #fff2d5; }
.contract-row { display: grid; grid-template-columns: minmax(0,1.05fr) minmax(0,1.2fr) auto; align-items: baseline; gap: 7px; padding: 5px 8px; }
.contract-row + .contract-row { border-top: 1px solid #c9b589; }
.contract-row strong { font-weight: 700; }
.contract-row .pay { text-align: end; font-weight: 700; color: #59401e; }
.contract-row.deliverable { background: #d8e5a7; }
.cargo { margin-block: 12px; display: flex; gap: 5px; flex-wrap: wrap; }
.cargo span { padding: 3px 8px; color: #f4e3ba; background: #373f2b; border: 1px solid #877555; }
.cargo span.empty { border-style: dashed; color: #d6c29a; }
.tools { display: grid; gap: 10px; }
.action-group { display: grid; gap: 5px; }
.action-group h3 { margin: 5px 0 1px; color: #eac895; font: 700 .95rem var(--title); }
.action-options { display: flex; flex-wrap: wrap; gap: 5px; }
.action-options button { text-align: start; padding-inline: 8px; }
.action-list { display: grid; gap: 4px; margin-top: 6px; max-height: 220px; overflow: auto; padding: 3px; }
.action-list button { text-align: start; padding-inline: 9px; }
.action-list button[aria-pressed=true] { background: #4e593d; border-color: #e0b369; }
.action-list-title { display: block; color: #e9d9b8; }
.action-group .reason, .empty-list { color: #dfcaa2; }
.log-list { padding: 0; list-style: none; display: grid; gap: 0; }
.log-list li { padding: 8px 1px; border-bottom: 1px solid #5b5943; color: #f2e4c7; }
.log-list time { color: #d1b881; display: block; font-size: .84rem; }
.log-event { text-align: start; padding: 4px 8px; width: 100%; }
.event-notice { margin-bottom: 11px; padding-bottom: 11px; border-bottom: 1px solid #736244; }
.event-notice h2 { margin-bottom: 5px; font: 700 .91rem var(--title); color: #edc28e; }
.event-notice button { color: #ffe2b5; }

.action-strip { position: relative; z-index: 2; display: flex; align-items: center; gap: 9px; justify-content: space-between; padding: 8px clamp(9px,2.2vw,26px); border-top: 1px solid #a18459; background: #182118; min-height: 64px; }
.instruction { flex: 1; min-width: 0; }
.instruction strong { display: block; color: #ffe0a6; font-weight: 700; }
.instruction p { color: #eddabd; font-size: .93rem; }
.strip-buttons { display: flex; flex-wrap: wrap; gap: 6px; justify-content: end; }
.action-strip.is-yours { border-top-color: #edb76c; box-shadow: inset 0 1px #edb76c; }

.audio-controls { border-top: 1px solid #5a553e; background: #151d16; }
.audio-controls:empty { display: none; }
.inspection { color-scheme: light; color: #2f2317; background: #f4e7c9; border: 2px solid #aa8050; box-shadow: 0 16px 45px #0709059c; max-width: min(650px,calc(100vw - 24px)); width: 100%; padding: 0; }
.inspection::backdrop { background: #0b130de0; }
.dialog-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 9px 16px; background: #273527; color: #fff0cb; }
.dialog-top h2 { font: 700 clamp(1.05rem,3.6vw,1.6rem)/1.15 var(--title); }
.dialog-close { padding: 0; min-width: 44px; font-size: 1.65rem; }
.dialog-body { padding: clamp(14px,3vw,26px); display: grid; gap: 13px; max-height: calc(80svh - 62px); overflow: auto; }
.dialog-body .secondary { color: #322419; border-color: #8e6744; }
.dialog-body .secondary:hover { background: #e7cf9f; }
.dialog-body h3 { margin: 5px 0 0; font: 700 1.03rem var(--title); }
.dialog-body ol, .dialog-body ul { padding-inline-start: 24px; }
.dialog-body li + li { margin-top: 6px; }
.dialog-body a { color: #6a3421; }
.dialog-body .contract-row { border-bottom: 1px solid #a48558; padding-block: 11px; }
.dialog-body .contract-row button { grid-column: 1 / -1; justify-self: start; }
.dialog-body .primary { justify-self: start; }
.final-results { list-style: none; padding-inline-start: 0 !important; }
.final-results li { display: flex; gap: 12px; justify-content: space-between; border-bottom: 1px solid #b89b6c; padding-bottom: 6px; }
.event-reel { border-block: 1px solid #bd9d6a; padding-block: 12px; display: grid; gap: 9px; }
.reel-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.network-status { position: fixed; z-index: 8; right: 12px; bottom: 12px; color: #ffebcc; background: #3f251f; border: 1px solid #d09b72; padding: 9px 13px; max-width: min(350px,calc(100vw - 24px)); box-shadow: 0 7px 16px #100c08a0; }
.network-status button { margin-inline-start: 6px; }
.freight-animation { pointer-events: none; position: fixed; z-index: 7; padding: 3px 8px; color: #251c12; background: #d9ddad; border: 1px solid #4f5633; font-weight: 700; white-space: nowrap; }
.freight-pay { background: #ffd480; border-color: #6e4b21; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 850px) {
  .station-content { gap: 32px; padding-inline: 24px; }
  .title-block h1 { font-size: clamp(3.5rem,11.7vw,7rem); }
  .table-body { grid-template-columns: minmax(0,1fr) minmax(245px,31vw); }
  .table-head { gap: 8px; }
}

@media (max-width: 650px) {
  .utility { padding-inline: 10px; flex-wrap: wrap; gap: 2px 8px; }
  .room-summary { order: 3; width: 100%; }
  .room-summary.practice-summary { display: none; }
  .brand { font-size: .76rem; gap: 7px; }
  .rail-mark { width: 20px; }
  .rail-mark::before { left: 5px; }
  .rail-mark::after { right: 5px; }
  .utilities .quiet-button { padding-inline: 6px; }
  .room-summary button { min-height: 44px; }
  .station { min-height: auto; }
  .station-picture { background-position: 53% top; background-size: auto 65%; }
  .station-atmosphere span { top: 9%; }
  .station-atmosphere i { top: 20%; }
  .station-atmosphere i:nth-of-type(2) { top: 23%; }
  .station-atmosphere i:nth-of-type(3) { top: 26%; }
  .station-shade { background: linear-gradient(0deg,#0e170f 40%,#14201594 68%,#13211408 95%); }
  .station-content { grid-template-columns: 1fr; padding: clamp(150px,39vw,300px) 15px 24px; gap: 19px; }
  .title-block h1 { font-size: clamp(3rem,15.5vw,6rem); }
  .title-block p { margin-top: 19px; }
  .title-block .game-credit { margin-top: 7px; }
  .entry-form { padding: 15px; }
  .table { grid-template-rows: auto auto auto; }
  .table-head { display: grid; gap: 6px; }
  .turn-indicator { min-width: 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px 10px; }
  .player-line { max-width: calc(100vw - 18px); }
  .table-body { grid-template-columns: minmax(0,1fr); }
  .map-panel { min-height: clamp(295px,40svh,440px); border-inline-end: 0; }
  .map-tools { right: 8px; bottom: 8px; }
  .ledger { border-top: 1px solid #a18459; min-height: 190px; }
  .ledger-content { max-height: 44svh; }
  .action-strip { position: sticky; top: 0; grid-row: 2; flex-wrap: wrap; gap: 4px 8px; box-shadow: 0 3px 8px #111b1266; }
  .instruction { min-width: min(100%,125px); }
  .strip-buttons { margin-inline-start: auto; }
  .strip-buttons button { padding-inline: 9px; }
}

@media (max-width: 375px) {
  .utility { justify-content: start; }
  .utilities { margin-inline-start: auto; }
  .rail-mark { display: none; }
  .lobby-seats { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.calm *, .calm *::before, .calm *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
.calm .station-picture, .calm .station-atmosphere * { animation: none !important; }
