:root {
  --ground: #E4E6E1;
  --plane: #ECEEE9;
  --ink: #111111;
  --muted: #5A5E57;
  --rule: #B3B8AF;
  --panel: #FFFFFF;
  --amber: #E8A317;
  --sans: 'Hanken Grotesk', system-ui, sans-serif;
  --mono: 'Martian Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--ground); color: var(--ink); font-family: var(--sans); }
a { color: var(--ink); }
a:hover { color: var(--muted); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 9px; letter-spacing: 0.02em; text-transform: none; }

.root { position: relative; height: 100vh; height: 100dvh; overflow: hidden; }
.stage { position: absolute; inset: 0; background: var(--plane); }
.nomap { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 32px; font: 500 13px/1.6 var(--mono); text-align: center; }
.ov { position: absolute; z-index: 2; }
.panel { background: var(--panel); border: 1px solid var(--ink); }
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; gap: 6px; }

.brand { left: 32px; top: 28px; pointer-events: none; }
.word { margin: 0; font-weight: 800; font-size: 34px; line-height: 1; letter-spacing: 0.01em; }
.sub { margin: 10px 0 0; max-width: 360px; font-size: 11px; line-height: 1.6; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: #3B3F38; }

.tour-note { margin-top: 8px; color: var(--ink); font-weight: 700; }
.tour-note::before { content: ''; display: inline-block; width: 8px; height: 8px; background: var(--amber); margin-right: 8px; }
.alert { left: 32px; top: 132px; max-width: 440px; padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; }
.alert p { margin: 0; font-size: 11px; line-height: 1.6; }
.alert strong { font-weight: 500; }
.sq { width: 12px; height: 12px; background: var(--amber); margin-top: 3px; flex: none; }

.counter { right: 32px; top: 28px; display: flex; }
.counter .cell { padding: 12px 18px; display: flex; flex-direction: column; gap: 6px; }
.counter .cell + .cell { border-left: 1px solid var(--ink); }
.big { font-weight: 800; font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }
.cap { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; display: flex; gap: 6px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); display: inline-block; }
.is-paused .dot { background: var(--rule); }

.side { right: 32px; top: 176px; width: 320px; display: flex; flex-direction: column; gap: 12px; }
.phead { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--ink); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.pbody { padding: 14px; }
.swatch { width: 18px; height: 7px; border-radius: 2px; display: inline-block; box-shadow: 0 0 0 1px var(--ink); }
.dest { margin: 0; font-weight: 800; font-size: 26px; line-height: 1.1; }
.facts { margin: 12px 0 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; font-size: 11px; line-height: 1.4; }
.facts dt { font-size: 9px; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.hint { margin: 0; padding: 12px 14px; font-size: 11px; line-height: 1.5; }
.rows { list-style: none; margin: 0; padding: 6px 14px 10px; font-size: 12px; }
.rows li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--rule); }
.rows li:last-child { border-bottom: 0; }
.rows .v { font-weight: 500; white-space: nowrap; }
.rows .long { background: var(--amber); padding: 0 4px; }
#ln-rows, #sc-rows { font-size: 11px; }
#sc-rows li { padding: 6px 0; }
#ln-rows li { padding: 3px 0; align-items: flex-start; }
#ln-rows .code { white-space: nowrap; }
#ln-rows .code .swatch { margin-right: 6px; vertical-align: middle; }
#ln-rows .v { white-space: normal; text-align: right; }
#ln-rows .v > span:not(.long) { display: block; white-space: nowrap; }
.search input { display: block; width: 100%; height: 44px; border: 0; border-radius: 0; background: transparent; color: var(--ink); padding: 0 14px; font: 500 12px var(--mono); letter-spacing: 0.04em; text-transform: uppercase; -webkit-appearance: none; appearance: none; }
.search input::placeholder { color: var(--muted); }
.search input:focus-visible { outline: 3px solid var(--amber); outline-offset: -3px; }
.search input::-webkit-search-cancel-button { display: none; }
.search .rows { padding: 0; border-top: 1px solid var(--ink); }
.search .rows li { padding: 0; border-bottom: 1px dashed var(--rule); cursor: pointer; align-items: stretch; gap: 0; }
.search .rows li:last-child { border-bottom: 0; }
.search .rows li > span { padding: 11px 14px; }
.search .rows li > span:first-child { flex: 1; min-width: 0; }
.search .rows li[aria-selected="true"], .search .rows li:hover { background: var(--ink); color: var(--panel); }
.text-view { left: 32px; top: 196px; width: 360px; max-height: calc(100dvh - 196px - 200px); overflow-y: auto; }
.text-view:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.text-view h2 { margin: 0; font-weight: 500; }
.text-view h2:not(:first-child) { border-top: 1px solid var(--ink); }
.text-view .rows { font-size: 11px; }
.text-view .rows li { padding: 5px 0; }
.text-view .stacked li { align-items: flex-start; padding: 3px 0; }
.text-view .stacked .v { white-space: normal; text-align: right; }
.text-view .stacked .v > span { display: block; white-space: nowrap; }
.btn[aria-expanded="true"] { background: var(--ink); color: var(--panel); }
.side { max-height: calc(100dvh - 176px - 84px); overflow-y: auto; }
/* The lines list gives way first on short screens, scrolling inside its own panel. */
.side > .panel { flex: none; }
.side > #lines-card { flex: 0 1 auto; min-height: 120px; display: flex; flex-direction: column; }
#lines-card #ln-rows { overflow-y: auto; min-height: 0; }

.legend { left: 32px; bottom: 28px; max-width: 420px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; font-size: 10px; line-height: 1.3; text-transform: uppercase; letter-spacing: 0.04em; }
.sw { width: 22px; height: 6px; display: inline-block; }
.ring { position: relative; width: 10px; height: 10px; margin: 2px; border-radius: 2px; border: 1.5px dashed var(--ink); background: #fff; display: inline-block; }
.ring::before { content: ''; position: absolute; left: 50%; top: -6px; margin-left: -3.5px; border: 3.5px solid transparent; border-bottom: 4px solid var(--ink); border-top: 0; }

.controls { right: 32px; bottom: 28px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.btn { min-width: 44px; height: 44px; border: 1px solid var(--ink); background: var(--panel); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; font: 500 12px var(--mono); letter-spacing: 0.04em; }
.btn:hover, .btn[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.btn:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.wide { padding: 0 14px; }
#share { min-width: 104px; }
.sr-only { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.full { width: 100%; margin-top: 14px; }

/* Billboard station labels (MapLibre markers) */
.stn-label { display: none; border: 0; cursor: pointer; white-space: nowrap; font: 500 10px/1 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; background: var(--ink); color: var(--panel); padding: 4px 6px; }
.stn-label.tier-1, .z-mid .stn-label.tier-2, .z-near .stn-label, .stn-label.is-active { display: block; }
.stn-label:hover, .stn-label.is-active { background: var(--amber); color: var(--ink); }

/* Bus popup */
.hw-popup .maplibregl-popup-content { border: 1px solid var(--ink); border-radius: 0; box-shadow: none; padding: 10px 28px 10px 12px; font: 400 11px/1.5 var(--mono); }
.hw-popup .maplibregl-popup-tip { display: none; }
.hw-popup b { font-weight: 500; }

@media (max-width: 760px) {
  .stack { display: contents; }
  .search { order: 5; }
  .root { height: auto; overflow: visible; display: flex; flex-direction: column; }
  .stage { position: relative; height: 520px; order: 2; }
  .ov { position: static; margin: 12px 16px; }
  .brand { order: 1; margin-top: 20px; }
  .alert { order: 3; max-width: none; }
  .counter { order: 4; }
  .side { order: 5; width: auto; max-height: none; overflow: visible; }
  .controls { order: 6; }
  .text-view { order: 7; width: auto; max-height: none; }
  .legend { order: 8; max-width: none; margin-bottom: 24px; }
}
/* Desktop: alert, station search and the text view stack in one column under the brand. */
@media (min-width: 761px) {
  .stack { left: 32px; top: 132px; bottom: 176px; width: 440px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; pointer-events: none; }
  .stack > .ov { position: static; pointer-events: auto; }
  .stack > .search { width: 360px; flex: none; }
  .stack > .text-view { flex: 0 1 auto; min-height: 0; max-height: none; }
  .root:has(#tour-note:not([hidden])) .stack { top: 172px; }
}
