@font-face { font-family: 'Plex Sans'; src: url('vendor/fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Sans'; src: url('vendor/fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Plex Sans'; src: url('vendor/fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Plex Mono'; src: url('vendor/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Mono'; src: url('vendor/fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }

:root {
  --paper: #F5F6F4;
  --ink: #15191D;
  --rule: #D8DCD9;
  --muted: #6B7278;
  --signal: #2B4ACB;
  --positive: #1E7A4F;
  --negative: #B3261E;
  --route: #15191D;
  /* Map colour: places by kind, routes by drive time. Cool to warm, no orange or amber. */
  --yard: #2B4ACB;
  --depot: #B4237A;
  --site: #12A36B;
  --band1: #0AA2B8;
  --band2: #2B6FE0;
  --band3: #7E3FD0;
  --band4: #D6336C;
  --halo: #FFFFFF;
  --let: #6E5AA8;
  --box: #4B5563;
  --map-bg: #95ac74;
  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s6: 48px;
  --sans: 'Plex Sans', system-ui, sans-serif;
  --mono: 'Plex Mono', ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111417; --ink: #E7EAE8; --rule: #2A3036; --muted: #8C949A;
    --signal: #7D95F2; --positive: #4CB883; --negative: #EF6A5F; --route: #E7EAE8;
  --halo: #1A1E22;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111417; --ink: #E7EAE8; --rule: #2A3036; --muted: #8C949A;
  --signal: #7D95F2; --positive: #4CB883; --negative: #EF6A5F; --route: #E7EAE8;
  --halo: #1A1E22;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font: 400 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.shell {
  display: grid; height: 100%;
  grid-template-columns: 1fr 360px;
  /* Whole-pixel header: a fractional one puts every map tile row on a fractional pixel,
     which shows as hairline gaps between tiles on scaled screens. */
  grid-template-rows: 56px 1fr;
}
.bar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s3); overflow: hidden;
  border-bottom: 1px solid var(--rule);
}
.bar .mark { font-weight: 600; letter-spacing: 0.08em; font-size: 13px; }
.bar .meta { color: var(--muted); font-size: 13px; }
.bar .spacer { flex: 1; }

#map { background: var(--paper); min-height: 0; }
.rail {
  border-left: 1px solid var(--rule);
  overflow-y: auto; min-height: 0;
  padding: var(--s3);
}
.rail h2 {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin: var(--s4) 0 var(--s1);
}
.rail h2:first-child { margin-top: 0; }
.rail p { margin: 0 0 var(--s2); color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; justify-content: space-between; gap: var(--s2);
  padding: 6px 0; border-top: 1px solid var(--rule);
  cursor: pointer;
}
.list li:last-child { border-bottom: 1px solid var(--rule); }
.list li:hover .name { color: var(--signal); }
.list li[aria-selected="true"] .name { color: var(--signal); font-weight: 500; }
.list .code { color: var(--muted); font-size: 12px; }

.readout { border-top: 1px solid var(--ink); padding-top: var(--s2); }
.readout .big { font-family: var(--mono); font-size: 28px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.readout .row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--rule); }
.readout .row span:first-child { color: var(--muted); }

button.link {
  font: inherit; color: var(--signal); background: none; border: 0; padding: 0; cursor: pointer;
}
button.link:focus-visible, .list li:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

.gap { margin-top: var(--s2); }
.swatch { display: inline-block; flex: none; margin-right: 8px; vertical-align: middle; background: var(--c); }
.swatch.dot { width: 10px; height: 10px; border-radius: 50%; }
.swatch.bar { width: 18px; height: 4px; border-radius: 2px; }
.big .swatch.bar { width: 24px; height: 6px; margin-right: 12px; }
.key { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.key ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; align-content: start; }
.key li { display: flex; align-items: center; color: var(--muted); font-size: 13px; }
.list .name { display: flex; align-items: center; }
.seg { display: flex; border: 1px solid var(--rule); }
.seg button {
  flex: 1; font: inherit; font-size: 13px; padding: 6px 0; cursor: pointer;
  background: none; color: var(--muted); border: 0; border-left: 1px solid var(--rule);
}
.seg button:first-child { border-left: 0; }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.seg button:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }

/* The town map */
.tmap { position: relative; overflow: hidden; background: var(--map-bg); min-height: 0; }
.tmap canvas { display: block; cursor: grab; touch-action: none; }
.tmap canvas:active { cursor: grabbing; }
.map-controls { position: absolute; top: var(--s2); left: var(--s2); display: flex; flex-direction: column; border: 1px solid var(--rule); background: var(--paper); }
.map-controls button { font: 500 14px var(--sans); width: 36px; height: 32px; border: 0; border-top: 1px solid var(--rule); background: none; color: var(--ink); cursor: pointer; }
.map-controls button:first-child { border-top: 0; }
.map-controls button[data-z="fit"] { font-size: 11px; letter-spacing: 0.04em; }
.map-controls button:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }

.swatch.tri { width: 0; height: 0; background: none; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid #C62F4A; }
.list.plain li { cursor: default; font-size: 13px; }
.list.plain li:hover .name { color: inherit; }

@media (max-width: 1023px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 55vh auto; height: auto; }
  .rail { border-left: 0; border-top: 1px solid var(--rule); overflow: visible; padding: var(--s2); }
  .bar { padding: var(--s2); flex-wrap: wrap; gap: var(--s1) var(--s2); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ============================================================================================
   The game (index.html). The map preview (preview.html) uses the rules above.
   ============================================================================================ */

/* Palettes: A Ultramarine (the plan), B Violet, C Newsprint. Picked in Insights. */
:root[data-palette="violet"] { --paper: #F4F4F6; --ink: #17171C; --rule: #DADAE0; --muted: #6C6C78; --signal: #5B3CC4; --positive: #2D7A4A; --yard: #5B3CC4; }
:root[data-palette="newsprint"] { --paper: #FAFAF7; --ink: #111111; --rule: #DDDDD8; --muted: #6E6E69; --signal: #111111; --positive: #1E7A4F; --yard: #111111; }
@media (prefers-color-scheme: dark) {
  :root[data-palette="violet"]:not([data-theme="light"]) { --paper: #131318; --ink: #E8E8EE; --rule: #2B2B34; --muted: #8F8F9C; --signal: #A08BF0; --positive: #58BE86; --yard: #A08BF0; --halo: #1A1A20; }
  :root[data-palette="newsprint"]:not([data-theme="light"]) { --paper: #121212; --ink: #EDEDEA; --rule: #2E2E2C; --muted: #93938E; --signal: #EDEDEA; --positive: #58BE86; --yard: #EDEDEA; --halo: #1A1A1A; }
}

.game {
  display: grid; height: 100%;
  grid-template-columns: minmax(0, 1fr) 380px;
  /* Whole pixels above and beside the map, or its picture and patches show seams. */
  grid-template-rows: 56px minmax(0, 1fr) 128px;
}
.topbar { gap: var(--s2); }
.topbar .clock { font-size: 14px; min-width: 150px; }
.speeds { display: flex; border: 1px solid var(--rule); }
.speeds button, .endday, .panelkeys button, .btn {
  font: 500 12px var(--sans); color: var(--ink); background: none; cursor: pointer;
  border: 0; padding: 6px 10px; letter-spacing: 0.02em;
}
.speeds button + button { border-left: 1px solid var(--rule); }
.speeds button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.endday { border: 1px solid var(--signal); color: var(--signal); }
.endday:hover { background: var(--signal); color: var(--paper); }
kbd { font: 500 10px var(--mono); color: var(--muted); border: 1px solid var(--rule); padding: 0 4px; margin-left: 4px; }
.endday:hover kbd { color: inherit; border-color: currentColor; }
.stat { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.stat .k { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-size: 15px; }
.stat .v.neg { color: var(--negative); }
.stat .v.pos { color: var(--positive); }
.panelkeys { display: flex; border-left: 1px solid var(--rule); padding-left: var(--s1); }
.panelkeys button[aria-pressed="true"] { color: var(--signal); }
button:focus-visible { outline: 2px solid var(--signal); outline-offset: 1px; }

.game #map { grid-column: 1; grid-row: 2; }
.tmap-top { position: absolute; left: 0; top: 0; pointer-events: none; }

.game .rail { grid-column: 2; grid-row: 2; position: relative; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.phone { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s3) var(--s3) var(--s2); }
.calls { list-style: none; margin: 0; padding: 0; }
.calls li { padding: 10px 0; border-top: 1px solid var(--rule); font-size: 13px; }
.calls li:first-child { border-top: 0; padding-top: 0; }
.calls li.new { animation: slidein 240ms ease-out; }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.calls .l1 { display: flex; justify-content: space-between; gap: var(--s1); }
.calls .l1 .who { font-weight: 500; }
.calls .t { font-family: var(--mono); color: var(--muted); margin-right: 8px; font-size: 12px; }
.calls .what, .calls .route { color: var(--muted); }
.calls .route { font-size: 12px; }
.calls .status { margin-top: 2px; }
.calls .status.pos { color: var(--positive); }
.calls .status.neg { color: var(--negative); }
.calls .status.live { color: var(--signal); }
.calls .status.off { color: var(--muted); }
.calls li.dim { opacity: 0.62; }
.intro { color: var(--muted); font-size: 13px; }
.intro p { margin: 0 0 var(--s1); }
.intro strong { color: var(--ink); font-weight: 500; }

.today { border-top: 1px solid var(--ink); padding: var(--s2) var(--s3) var(--s3); }
.today .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
.today .n { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 18px; line-height: 1.2; }
.today .k { font-size: 11px; color: var(--muted); }

.game .rail h2, .panel h2, .timeline h2 {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 var(--s1);
}

/* Panels open over the rail; the map stays in view. */
.panel { position: absolute; inset: 0; background: var(--paper); overflow-y: auto; padding: var(--s3); }
.panel[hidden] { display: none; }
.panel header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s2); border-bottom: 1px solid var(--ink); padding-bottom: var(--s1); }
.panel header h1 { font-size: 16px; font-weight: 600; margin: 0; }
.panel header .close { font: 500 12px var(--sans); background: none; border: 0; color: var(--muted); cursor: pointer; }
.panel h2 { margin-top: var(--s3); }
.panel p { margin: 0 0 var(--s1); color: var(--muted); font-size: 13px; }
.panel .lead { color: var(--ink); font-size: 14px; }
.panel .big { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 30px; line-height: 1.1; }
.panel .big.neg { color: var(--negative); }
.panel .big.pos { color: var(--positive); }
.rows { width: 100%; border-collapse: collapse; font-size: 13px; }
.rows td, .rows th { padding: 5px 0; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.rows th { font-weight: 500; color: var(--muted); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
.rows td.r, .rows th.r { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; padding-left: var(--s1); white-space: nowrap; }
.rows tr.total td { border-top: 1px solid var(--ink); border-bottom: 0; font-weight: 500; }
.rows td .sub { display: block; color: var(--muted); font-size: 12px; }
.neg { color: var(--negative); }
.pos { color: var(--positive); }
.meter { height: 6px; background: var(--rule); margin-top: 4px; display: flex; }
.meter i { display: block; height: 100%; background: var(--ink); }
.meter i.sig { background: var(--signal); }
.meter i.mut { background: var(--muted); }
.actions { display: flex; gap: var(--s1); flex-wrap: wrap; margin-top: var(--s2); }
.btn { border: 1px solid var(--ink); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.quiet { border-color: var(--rule); color: var(--muted); }
.palettes { display: grid; gap: var(--s1); }
.palettes button { display: flex; align-items: center; gap: var(--s2); width: 100%; text-align: left; font: 400 13px var(--sans); color: var(--ink); background: none; border: 1px solid var(--rule); padding: 8px 10px; cursor: pointer; }
.palettes button[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 3px 0 0 var(--ink); }
.palettes .sw { display: flex; }
.palettes .sw i { width: 14px; height: 14px; display: block; }
.note { font-size: 12px; color: var(--muted); border-left: 2px solid var(--rule); padding-left: var(--s1); margin-top: var(--s2); }

/* The timeline: each driver's day as planned, with a line for now. */
.timeline { grid-column: 1 / -1; grid-row: 3; border-top: 1px solid var(--rule); padding: 10px var(--s3) 0; overflow: hidden; }
.tl { position: relative; }
.tl-axis, .tl-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 120px; align-items: center; column-gap: var(--s2); }
.tl-axis .track { position: relative; height: 18px; }
.tl-axis .h { position: absolute; top: 0; font: 400 11px var(--mono); color: var(--muted); transform: translateX(-50%); }
.tl-axis .h::after { content: ""; position: absolute; left: 50%; top: 16px; height: 200px; border-left: 1px solid var(--rule); }
.tl-row { height: 38px; }
.tl-row .who { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-row .who small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.tl-row .track { position: relative; height: 22px; }
.tl-row .aside { font-size: 11px; color: var(--muted); text-align: right; }
.task { position: absolute; top: 0; height: 22px; font: 500 10px var(--sans); line-height: 20px; padding: 0 3px; overflow: hidden; white-space: nowrap; box-sizing: border-box; }
.task.drive, .task.return { top: 9px; height: 4px; background: var(--ink); padding: 0; }
.task.return { background: var(--muted); }
.task.load, .task.unload { background: var(--ink); color: var(--paper); border-left: 1px solid var(--paper); }
.task.wait { top: 10px; height: 2px; background: repeating-linear-gradient(90deg, var(--muted) 0 2px, transparent 2px 5px); padding: 0; }
.task.planned.load, .task.planned.unload { background: var(--paper); color: var(--ink); border: 1px solid var(--ink); line-height: 18px; }
.task.planned.drive { background: repeating-linear-gradient(90deg, var(--ink) 0 4px, transparent 4px 7px); }
.task.planned.return { background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 7px); }
.task.current.drive, .task.current.return { background: var(--signal); }
.task.current.load, .task.current.unload { background: var(--signal); color: var(--paper); border-color: var(--signal); }
.task.late { box-shadow: inset 0 -3px 0 var(--negative); }
.tl-now { position: absolute; top: 0; height: 100px; border-left: 1.5px solid var(--signal); pointer-events: none; }
.tl-empty { color: var(--muted); font-size: 12px; }

.toast { position: fixed; left: 50%; top: 68px; transform: translateX(-50%); background: var(--ink); color: var(--paper); font-size: 13px; padding: 8px 14px; pointer-events: none; opacity: 0; transition: opacity 200ms; z-index: 10; }
.toast.on { opacity: 1; }

@media (max-width: 1439px) {
  .game { grid-template-columns: minmax(0, 1fr) 320px; }
  .topbar .panelkeys kbd { display: none; }
  .topbar { gap: 12px; }
}
@media (max-width: 1180px) {
  .stat .k { display: none; }
  .tl-axis, .tl-row { grid-template-columns: 110px minmax(0, 1fr) 90px; }
}
@media (max-width: 1023px) {
  .game { grid-template-columns: 1fr; grid-template-rows: auto 55vh auto auto; height: auto; }
  .game #map { grid-row: 2; }
  .game .rail { grid-column: 1; grid-row: 3; overflow: visible; border-left: 0; border-top: 1px solid var(--rule); }
  .phone { max-height: 50vh; }
  .timeline { grid-row: 4; padding-bottom: var(--s2); }
  .panel { position: fixed; inset: auto 0 0 0; max-height: 80vh; border-top: 1px solid var(--ink); z-index: 5; }
  .topbar { flex-wrap: wrap; padding: var(--s1) var(--s2); }
  .stat .k { display: inline; }
  .tl-axis, .tl-row { grid-template-columns: 70px minmax(0, 1fr) 0; }
  .tl-row .aside { display: none; }
}

/* Phase 2: offers, the standing instruction, job filters, day rate. */
.phone-h { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px var(--s1); margin-bottom: var(--s1); }
.phone-h h2 { margin: 0; }
.policy { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; gap: var(--s1); width: 100%; }
.policy select { font: 500 12px var(--sans); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); padding: 3px 4px; max-width: 200px; }
.offers { border: 1px solid var(--signal); padding: var(--s2); margin: 0 0 var(--s2); }
.offers h2 { color: var(--signal); }
.offer { padding: var(--s1) 0; border-top: 1px solid var(--rule); font-size: 13px; }
.offer:first-of-type { border-top: 0; padding-top: 0; }
.offer .l1 { display: flex; justify-content: space-between; gap: var(--s1); }
.offer .t { font-family: var(--mono); color: var(--muted); margin-right: 8px; font-size: 12px; }
.offer .due { font-size: 11px; color: var(--muted); white-space: nowrap; }
.offer .what, .offer .route { color: var(--muted); }
.offer .route { font-size: 12px; }
.offer p { margin: 4px 0; }
.offer .lead { color: var(--ink); }
.offer .why { color: var(--muted); font-size: 12px; }
.opts { display: grid; gap: 4px; margin-top: 6px; }
.opt { display: grid; grid-template-columns: 1fr auto; column-gap: var(--s1); align-items: baseline; width: 100%; text-align: left; font: 400 13px var(--sans); color: var(--ink); background: none; border: 1px solid var(--ink); padding: 6px 8px; cursor: pointer; }
.opt:hover { background: var(--ink); color: var(--paper); }
.opt:hover .m, .opt:hover .r { color: inherit; }
.opt .n { font-weight: 500; }
.opt .m { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.opt .r { grid-column: 1 / -1; font-size: 11px; color: var(--muted); }
.opt.quiet { border-color: var(--rule); color: var(--muted); }
.panel .offers { margin-top: var(--s2); }
.filters { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: var(--s2); }
.filters button { font: 500 12px var(--sans); background: none; border: 1px solid var(--rule); color: var(--muted); padding: 4px 8px; cursor: pointer; }
.filters button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); }
.filters .num { color: var(--muted); margin-left: 4px; }
.task.dayrate { background: repeating-linear-gradient(135deg, var(--ink) 0 6px, transparent 6px 9px); color: var(--paper); line-height: 22px; }
.task.dayrate.planned { background: var(--paper); color: var(--ink); border: 1px dashed var(--ink); line-height: 18px; }
.task.dayrate.current { background: var(--signal); color: var(--paper); }
