/* Fonts are served with the game (see tools/vendor.mjs). */
@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url('vendor/fonts/barlow-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url('vendor/fonts/barlow-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url('vendor/fonts/barlow-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Saira Semi Condensed'; font-weight: 500; font-display: swap; src: url('vendor/fonts/saira-semi-condensed-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Saira Semi Condensed'; font-weight: 600; font-display: swap; src: url('vendor/fonts/saira-semi-condensed-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Saira Semi Condensed'; font-weight: 700; font-display: swap; src: url('vendor/fonts/saira-semi-condensed-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Playfair Display'; font-weight: 700; font-display: swap; src: url('vendor/fonts/playfair-display-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Playfair Display'; font-weight: 900; font-display: swap; src: url('vendor/fonts/playfair-display-latin-900-normal.woff2') format('woff2'); }

/* Red Dot City — UI layer over the 3D canvas.
   Controls over the map are navy enamel, like station signs: the .enamel rule below
   recolours everything inside them. Sheets stay on light paper. */
:root {
  --ink: #18232f;
  --ink-2: #3a4754;
  --muted: #66717c;
  --paper: #fbfaf6;
  --paper-2: #efece4;
  --line: rgba(24, 35, 47, 0.14);
  --accent: #e8341a;
  --good: #009645;
  --warn: #e08a00;
  --bad: #c62a10;
  --info: #005ec4;
  --enamel: #14243a;
  --enamel-raised: #223a58;
  --enamel-edge: #375476;
  --enamel-lip: #0a1524;
  --press-lip: #8f1c0c;
  --shadow: 0 6px 20px rgba(16, 28, 40, 0.18), 0 1px 3px rgba(16, 28, 40, 0.12);
  --display: 'Saira Semi Condensed', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r: 10px;
  --console-h: 104px;
  --console-pad: calc(var(--safe-b) * 0.4); /* the console needs little room for the iPad's home bar */
  --block: calc(var(--console-h) - 18px); /* the height of everything in the console */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #bfe3ee; color: var(--ink); font: 15px/1.4 var(--body); -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#ui { position: fixed; inset: 0; pointer-events: none; font-variant-numeric: tabular-nums; }
#ui > * { pointer-events: auto; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }

/* ---------- Enamel ---------- */
.console, .plate, .palette, .tray, .transit-panel, .viewbar, .flyout, .toast, .tip, .legend, .query, .tutorial, .photo-strip {
  --ink: #f3f6f8; --ink-2: #c9d6e2; --muted: #8fa6bd; --paper: #14243a; --paper-2: #223a58;
  --line: rgba(143, 166, 189, 0.28); --info: #7dbcff; --good: #3ecf7a; --warn: #f2a93b; --bad: #ff7a5f;
  color: var(--ink);
}
.plate, .palette, .tray, .transit-panel, .viewbar, .flyout, .toast, .legend, .query, .tutorial, .photo-strip {
  background: var(--enamel) url('assets/tex-enamel.webp'); border: 1px solid var(--enamel-edge);
  box-shadow: 0 3px 0 var(--enamel-lip), 0 8px 18px rgba(8, 18, 30, 0.42);
}

/* ---------- Console ---------- */
/* Only as wide as its contents, with every block sharing the same top and bottom edge
   and fixed widths, so nothing shifts as the numbers change. */
.console {
  position: absolute; left: 0; bottom: 0; width: fit-content; max-width: 100%; height: calc(var(--console-h) + var(--console-pad));
  padding: 0 var(--safe-r) var(--console-pad) var(--safe-l); display: flex; align-items: stretch;
  background: var(--enamel) url('assets/tex-enamel.webp'); border-top: 2px solid var(--enamel-edge); border-right: 2px solid var(--enamel-edge); border-top-right-radius: var(--r);
  box-shadow: 0 -6px 16px rgba(8, 18, 30, 0.4);
}
.con { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-right: 1px solid var(--line); min-width: 0; }
.con:last-child { border-right: 0; }
.con-place { padding-left: 8px; }
.minimap { position: relative; width: var(--block); height: var(--block); flex: none; overflow: hidden; border-radius: 6px; background: #2b8f8e; box-shadow: inset 0 0 0 1px var(--enamel-edge); touch-action: none; cursor: pointer; }
.mini-tiles { position: absolute; left: 50%; top: 50%; width: 70.71%; height: 70.71%; pointer-events: none; }
.mini-view { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.mini-view polygon { fill: rgba(255, 255, 255, 0.14); stroke: #fff; stroke-width: 1.5; stroke-linejoin: round; }
.city-plate { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; width: 96px; cursor: pointer; }
.city-plate .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); flex: none; box-shadow: 0 0 10px 2px rgba(232, 52, 26, 0.7); }
.city-name { font: 700 18px/1.1 var(--display); overflow-wrap: anywhere; }
.con-time { width: 196px; flex-direction: column; align-items: stretch; justify-content: space-between; gap: 2px; }
.city-date { font: 700 19px/1.1 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.weather { font: 500 12px/1.2 var(--body); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.weather .neg { color: var(--bad); }
.speed { display: flex; gap: 4px; margin-bottom: 3px; }
.speed button { flex: 1; min-width: 0; height: 36px; border-radius: 8px; display: grid; place-items: center; font: 700 14px/1 var(--display); color: var(--ink-2); background: var(--enamel-raised); border: 1px solid var(--enamel-edge); box-shadow: 0 3px 0 var(--enamel-lip); transition: transform 0.06s, box-shadow 0.06s; }
.speed button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--enamel-lip); }
.speed button[aria-pressed='true'] { background: var(--accent); border-color: #ff6a4f; color: #fff; box-shadow: 0 3px 0 var(--press-lip); }
.con-money { display: grid; grid-template-columns: auto 112px; gap: 8px 12px; align-items: baseline; align-content: center; }
.k { font: 600 10.5px/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.stat { text-align: right; }
.stat[role='button'] { cursor: pointer; }
.v { font: 700 20px/1.1 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.v.neg { color: var(--bad); }
.con-state { align-items: stretch; }
.rci { display: flex; gap: 3px; align-items: stretch; }
.rci .bar { width: 13px; position: relative; background: var(--enamel-lip); border-radius: 3px; overflow: hidden; }
.rci .bar i { position: absolute; left: 0; right: 0; }
.rci .bar::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(255, 255, 255, 0.3); }
.rci .lbl { position: absolute; bottom: 1px; left: 0; right: 0; text-align: center; font: 700 10px/1 var(--display); color: #fff; z-index: 1; }
.util { width: 100px; display: flex; flex-direction: column; justify-content: space-evenly; }
.gauge { display: grid; grid-template-columns: 1fr 36px; align-items: center; gap: 4px 6px; cursor: pointer; }
.gauge .k { grid-column: 1 / -1; }
.gauge .track { height: 9px; border-radius: 4px; background: var(--enamel-lip); overflow: hidden; }
.gauge .track i { display: block; height: 100%; border-radius: 4px; background: var(--good); transition: width 0.4s; }
.gauge .n { font: 700 13px/1 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.gauge[data-level='warn'] .track i { background: var(--warn); }
.gauge[data-level='bad'] .track i { background: var(--bad); }
.gauge[data-level='bad'] .n { color: var(--bad); }
.con-qol { display: grid; grid-template-columns: repeat(3, 40px); grid-template-rows: 1fr 1fr; gap: 6px; }
.qol { display: grid; place-items: center; border-radius: 6px; background: #f4f1e8; border-bottom: 4px solid var(--good); padding: 0; min-height: 0; }
.qol:active, .goal-chip:active { transform: translateY(1px); }
.qol[data-level='warn'] { border-color: var(--warn); }
.qol[data-level='bad'] { border-color: var(--bad); }
.con-views { display: flex; gap: 8px; }
.con-layers { display: flex; margin-bottom: 3px; }
.pal-btn.menu-btn { flex: none; width: 48px; height: auto; margin-bottom: 3px; font: 700 20px/1 var(--display); color: var(--ink); }
.top-right { position: absolute; top: calc(8px + var(--safe-t)); right: calc(8px + var(--safe-r)); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; pointer-events: none !important; }
.top-right > * { pointer-events: auto; }
.talk { display: flex; flex-direction: column; gap: 3px; max-width: 250px; text-align: left; font: 500 12.5px/1.3 var(--body); color: #eaf0f5; opacity: 1; transition: opacity 0.4s; animation: talk-in 0.3s ease-out; cursor: default; }
.talk[hidden] { display: none; }
.talk.goes { cursor: pointer; }
.talk.out { opacity: 0; }
.talk small { font-size: 11px; opacity: 0.7; }
@keyframes talk-in { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .talk { animation: none; transition: none; } }
.plate { border-radius: var(--r); padding: 8px 12px; }

/* ---------- Milestone banner ---------- */
.banner { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 34px 14px; white-space: nowrap; color: #fff; background: var(--enamel); border: 1px solid var(--enamel-edge); border-bottom: 5px solid var(--accent); border-radius: 10px; box-shadow: 0 10px 28px rgba(4, 10, 18, 0.5); pointer-events: none !important; animation: banner 3.6s ease both; }
.banner b { font: 700 28px/1.1 var(--display); }
.banner span { font: 600 13px/1.2 var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: #8fa6bd; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -14px) scale(0.96); } 7%, 88% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -6px); } }
@media (prefers-reduced-motion: reduce) { .banner { animation: none; } }

/* ---------- Toasts ---------- */
.toasts { position: absolute; top: calc(8px + var(--safe-t)); left: 50%; transform: translateX(-50%); width: min(460px, calc(100% - 24px)); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast {
  pointer-events: auto; border-radius: 10px; padding: 9px 12px 9px 14px;
  border-left: 5px solid var(--info); font-size: 14px; display: flex; gap: 8px; align-items: center; animation: toast-in 0.25s ease-out;
}
.toast.good { border-color: var(--good); } .toast.warn { border-color: var(--warn); } .toast.bad { border-color: var(--bad); }
.toast span { flex: 1; }
.toast button { font: 600 12px/1 var(--body); color: var(--info); padding: 6px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- Palette ---------- */
.palette {
  position: absolute; left: calc(8px + var(--safe-l)); top: calc(8px + var(--safe-t)); padding: 6px;
  border-radius: var(--r);
}
/* The columns and button height come from railLayout in palette.js. */
.rail { display: grid; grid-auto-flow: column; grid-template-rows: repeat(var(--rail-rows, 16), var(--rail-h, 54px)); grid-auto-columns: 72px; gap: var(--rail-gap, 6px) 4px; }
.pal-btn.rail-tab { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.rail-tab .ico { height: 34px; display: grid; place-items: center; }
.rail-tab .lab { font: 600 11.5px/1 var(--display); color: var(--ink); }
.rail-tab[aria-pressed='true'] .lab { color: #fff; }
.rail-tab.dim .ico { opacity: 0.4; }
.tray {
  position: absolute; left: calc(var(--rail-w, 100px) + var(--safe-l)); top: calc(8px + var(--safe-t)); width: 252px; max-height: calc(100% - var(--console-h) - 16px - var(--console-pad) - var(--safe-t));
  overflow-y: auto; touch-action: pan-y; padding: 8px; display: flex; flex-direction: column; gap: 5px; border-radius: var(--r);
}
.tray-group { font: 600 11px/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 6px 2px 2px; }
.tray-group:first-child { padding-top: 2px; }
.tool-card { display: grid; grid-template-columns: 42px 1fr; align-items: center; column-gap: 8px; min-height: 40px; padding: 4px 8px 4px 4px; border-radius: 7px; text-align: left; background: var(--enamel-raised); border: 1px solid var(--enamel-edge); box-shadow: 0 2px 0 var(--enamel-lip); transition: transform 0.06s, box-shadow 0.06s; }
.tool-card:hover:not(:disabled) { background: #2b4769; }
.tool-card:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 var(--enamel-lip); }
.tool-card[aria-checked='true'], .tool-card[aria-checked='true']:hover { background: var(--accent); border-color: #ff6a4f; box-shadow: 0 2px 0 var(--press-lip); }
.tool-card[aria-checked='true'] .sub { color: rgba(255, 255, 255, 0.85); }
.tool-card:disabled { opacity: 0.5; cursor: not-allowed; }
.tool-card .ico { height: auto; }
.ico.thumb img { display: block; width: 42px; height: 42px; }
.rail-tab .ico.thumb img { width: 34px; height: 34px; }
.tool-card .ico svg { background: #f4f1e8; border-radius: 6px; padding: 2px; box-sizing: content-box; }
.tool-card .text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tool-card .name { font: 600 13px/1.15 var(--display); }
.tool-card .sub { font: 500 11px/1.2 var(--body); color: var(--ink-2); }
.pal-btn { width: 44px; height: 44px; border-radius: 8px; display: grid; place-items: center; position: relative; background: var(--enamel-raised); border: 1px solid var(--enamel-edge); box-shadow: 0 3px 0 var(--enamel-lip); transition: transform 0.06s, box-shadow 0.06s; }
.pal-btn svg { background: #f4f1e8; border-radius: 6px; padding: 2px; box-sizing: content-box; }
.pal-btn:hover { background: #2b4769; }
.pal-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--enamel-lip); }
.pal-btn[aria-pressed='true'], .pal-btn[aria-pressed='true']:hover { background: var(--accent); border-color: #ff6a4f; box-shadow: 0 3px 0 var(--press-lip); }
.pal-btn.multi::after { content: ''; position: absolute; right: 2px; bottom: 2px; border: 3px solid transparent; border-right-color: var(--ink-2); border-bottom-color: var(--ink-2); border-radius: 1px; }
.pal-btn.dim svg { opacity: 0.4; }
.viewbar {
  position: absolute; right: calc(8px + var(--safe-r)); bottom: calc(var(--console-h) + 8px + var(--console-pad)); display: flex; flex-direction: column; gap: 6px; padding: 6px;
  border-radius: var(--r);
}
.layer-menu { max-height: calc(100vh - var(--console-h) - 24px); overflow-y: auto; touch-action: pan-y; }
.pal-btn.layers-btn { width: 60px; height: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.layers-btn .ico { height: 30px; }
.layers-btn .lab { font: 600 11px/1 var(--display); color: var(--ink); }
.layers-btn[aria-pressed='true'] .lab { color: #fff; }
.layer-menu .fly-item { min-height: 38px; grid-template-columns: 26px 1fr; padding-top: 4px; padding-bottom: 4px; }
.flyout { position: absolute; min-width: 230px; max-width: calc(100vw - 120px); border-radius: var(--r); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.fly-title { font: 600 11px/1 var(--body); letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); padding: 6px 8px 5px; }
.fly-item { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border-radius: 8px; text-align: left; min-height: 42px; }
.fly-item .name { font: 600 14px/1.2 var(--body); }
.fly-item .cost, .fly-item .lock { font: 500 12px/1 var(--body); color: var(--muted); white-space: nowrap; }
.fly-item:hover:not(:disabled), .fly-item:focus-visible { background: var(--paper-2); }
.fly-item[aria-checked='true'], .fly-item[aria-checked='true']:hover { background: var(--accent); color: #fff; }
.fly-item[aria-checked='true'] .cost, .fly-item[aria-checked='true'] .name small { color: rgba(255, 255, 255, 0.7); }
.fly-item:disabled { opacity: 0.45; cursor: not-allowed; }
.ico { display: grid; place-items: center; height: 26px; }
.ico svg { display: block; }
.flyout .ico svg { background: #f4f1e8; border-radius: 5px; padding: 2px; box-sizing: content-box; }

/* ---------- Pointer tooltip & legend ---------- */
.tip { position: absolute; pointer-events: none !important; background: var(--enamel-lip); color: #fff; padding: 5px 9px; border-radius: 8px; font: 600 13px/1.2 var(--body); white-space: nowrap; transform: translate(-50%, -140%); box-shadow: var(--shadow); }
.tip.bad { background: #c62a10; }
@media (max-width: 760px) { .tip { white-space: normal; max-width: 220px; } }
.legend { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; bottom: calc(var(--console-h) + 8px + var(--console-pad)); border-radius: 10px; padding: 8px 10px; font: 600 12px/1.3 var(--body); display: flex; gap: 8px; align-items: center; }
.legend .ramp { width: 90px; height: 10px; border-radius: 5px; }
.legend button { color: var(--info); font-weight: 600; }

/* ---------- Transit panel ---------- */
/* Beside the rail and over the map, where it can stay open while the city runs. */
.transit-panel { position: absolute; left: calc(var(--rail-w, 100px) + var(--safe-l)); top: calc(8px + var(--safe-t)); width: 310px; max-width: calc(100% - var(--rail-w, 100px) - 80px); max-height: calc(100% - var(--console-h) - 16px - var(--console-pad) - var(--safe-t)); display: flex; flex-direction: column; border-radius: var(--r); }
.transit-panel[hidden] { display: none; }
.transit-panel > header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 6px; border-bottom: 1px solid var(--line); }
.transit-panel h2 { margin: 0; font: 700 18px/1 var(--display); color: var(--ink); }
.transit-panel .close { color: var(--ink); font-size: 22px; line-height: 1; width: 32px; height: 32px; }
.tp-body { overflow-y: auto; touch-action: pan-y; padding: 8px 12px 12px; }
.tp-body h3 { margin: 12px 0 4px; font: 600 11px/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tp-stat { display: flex; flex-direction: column; gap: 3px; }
.tp-stat b { font: 700 17px/1 var(--display); }
.tp-stat span { font-size: 11.5px; color: var(--muted); }
.tp-note { margin: 6px 0; font-size: 12.5px; line-height: 1.35; color: var(--muted); }
.tp-line { border-radius: 8px; margin-bottom: 4px; background: var(--enamel-raised); border: 1px solid var(--enamel-edge); }
.tp-line.open { border-color: var(--info); }
.tp-head { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 5px 8px; text-align: left; color: var(--ink); }
.tp-head .label { flex: 1; min-width: 0; font: 600 14px/1.15 var(--display); }
.tp-head .label small { display: block; font: 400 12px/1.2 var(--body); color: var(--muted); }
.tp-head .val { font: 700 13.5px/1 var(--display); white-space: nowrap; }
.tp-stops { list-style: none; margin: 0; padding: 0 6px; }
.tp-stops button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px; padding: 2px 4px; text-align: left; color: var(--ink); border-top: 1px solid var(--line); }
.tp-stops .code { flex: none; min-width: 38px; font: 700 12.5px/1 var(--display); filter: brightness(1.5); }
.tp-stops .name { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-stops small { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.tp-line .btns { margin: 6px 8px 8px; }
.tp-body > .btns { margin: 8px 0 4px; }

#ui > .station-tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; } /* a full-screen layer: clicks must reach the map */
.station-tag { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 5px; padding: 2px 7px 2px 2px; border-radius: 6px; background: rgba(24, 35, 47, 0.82); color: #fff; font: 600 12px/1.2 var(--display); white-space: nowrap; }
.station-tag[hidden] { display: none; }
.station-tag b { padding: 2px 5px; border-radius: 4px; font: 700 11.5px/1 var(--display); }

/* ---------- Sheets / panels ---------- */
/* An enamel frame like a station sign, around a light body that's easy to read. */
.scrim { position: absolute; inset: 0; background: rgba(8, 16, 26, 0.55); display: grid; place-items: center; padding: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l)); animation: scrim-in 0.14s ease-out; }
.sheet { position: relative; background: var(--enamel) url('assets/tex-enamel.webp'); border: 1px solid var(--enamel-edge); border-radius: 12px; box-shadow: 0 4px 0 var(--enamel-lip), 0 18px 44px rgba(4, 10, 18, 0.6); width: min(640px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; padding: 0 8px 8px; animation: sheet-in 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.1); }
@keyframes scrim-in { from { opacity: 0; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) { .scrim, .sheet { animation: none; } }
.sheet header { position: relative; z-index: 1; flex: none; display: flex; align-items: center; gap: 10px; margin: 0 -8px; padding: 10px 14px; color: #fff; }
.sheet[data-art] header { min-height: 72px; }
/* The picture fills the corner down to the page, behind the tabs. */
.sheet[data-art]::before { content: ''; position: absolute; right: 0; top: 0; width: 340px; height: 74px; background: center / cover no-repeat; -webkit-mask-image: linear-gradient(to right, transparent, #000 55%); mask-image: linear-gradient(to right, transparent, #000 55%); pointer-events: none; }
.sheet[data-art]:has(.tabs)::before { height: 108px; }
.sheet[data-art='budget']::before { background-image: url('assets/sheet-budget.webp'); }
.sheet[data-art='city']::before { background-image: url('assets/sheet-city.webp'); }
.sheet[data-art='awards']::before { background-image: url('assets/sheet-awards.webp'); }
.sheet header::before { content: ''; flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px 2px rgba(232, 52, 26, 0.7); }
.sheet header h2 { margin: 0; font: 700 22px/1.1 var(--display); flex: 1; text-wrap: balance; }
.sheet .close { flex: none; width: 38px; height: 38px; border-radius: 8px; font: 600 22px/1 var(--body); color: #fff; background: var(--enamel-raised); border: 1px solid var(--enamel-edge); box-shadow: 0 3px 0 var(--enamel-lip); margin-bottom: 3px; }
.sheet .close:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--enamel-lip); }
.sheet .body { position: relative; z-index: 1; flex: 1 1 auto; min-height: 0; background: var(--paper) url('assets/tex-paper.webp'); border-radius: 8px; padding: 14px 16px 18px; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; user-select: text; -webkit-user-select: text; }
.sheet .body + .body { flex: none; border-radius: 0 0 8px 8px; }
.sheet .body:has(+ .body) { border-radius: 8px 8px 0 0; }
.sheet .tabs + .body { border-top-left-radius: 0; }
.tabs { position: relative; z-index: 1; flex: none; display: flex; gap: 3px; overflow-x: auto; }
.tabs button { padding: 9px 13px 10px; font: 600 14px/1 var(--display); color: #c9d6e2; background: var(--enamel-raised); border-radius: 7px 7px 0 0; white-space: nowrap; }
.tabs button[aria-selected='true'] { color: var(--ink); background: var(--paper); }
h3 { font: 700 15px/1.2 var(--display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }
h3:first-child { margin-top: 0; }
.row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .label { flex: 1; min-width: 0; }
.row .label small { display: block; color: var(--muted); font-size: 12.5px; }
.row .val { font: 700 16px/1 var(--display); white-space: nowrap; }
.line-chip { flex: none; min-width: 34px; padding: 4px 6px; border-radius: 6px; color: #fff; font: 700 13px/1 var(--display); text-align: center; letter-spacing: 0.04em; }
.muted { color: var(--muted); }
.row input[type='range'] { width: min(46vw, 220px); accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 20px; }
.ledger { width: 100%; border-collapse: collapse; font-size: 14px; }
.ledger td { padding: 4px 0; border-bottom: 1px solid var(--line); }
.ledger td:last-child { text-align: right; font-weight: 600; }
.ledger tr.total td { border-bottom: 0; font: 700 16px/1.3 var(--display); }
.pos { color: var(--good); } .neg { color: var(--bad); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; margin-bottom: 3px; padding: 0 16px; border-radius: 8px; font: 600 14.5px/1 var(--display); background: #e6e2d6; color: var(--ink); border: 1px solid #c7c1b1; box-shadow: 0 3px 0 #b3ad9c; transition: transform 0.06s, box-shadow 0.06s; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #b3ad9c; }
.btn.primary { background: var(--accent); color: #fff; border-color: #ff6a4f; box-shadow: 0 3px 0 var(--press-lip); }
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--press-lip); }
.btn.dark { background: var(--enamel-raised); color: #fff; border-color: var(--enamel-edge); box-shadow: 0 3px 0 var(--enamel-lip); }
.btn.dark:active:not(:disabled) { box-shadow: 0 1px 0 var(--enamel-lip); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 8px; background: #b8b3a5; box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.2); transition: background 0.15s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 6px; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--info); outline-offset: 2px; }
.seg { display: inline-flex; background: #dfdbce; border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { padding: 8px 12px; border-radius: 7px; font: 600 14px/1 var(--display); color: var(--ink-2); min-height: 36px; }
.seg button[aria-pressed='true'] { background: var(--enamel-raised); color: #fff; box-shadow: 0 2px 0 var(--enamel-lip); }
input[type='text'], select { font: 500 15px/1 var(--body); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); min-height: 42px; }
.chart { width: 100%; height: 120px; display: block; }
.chart-wrap { margin-bottom: 14px; }
.chart-wrap .cap { display: flex; justify-content: space-between; font: 600 13px/1.2 var(--body); color: var(--ink-2); margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 8px; }
.kv > div { background: var(--enamel); border-radius: 8px; padding: 8px 10px; box-shadow: 0 2px 0 var(--enamel-lip); }
.kv .k { font: 600 10.5px/1.2 var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: #8fa6bd; }
.kv .v { font: 700 20px/1.2 var(--display); color: #fff; }
.kv .v.neg { color: #ff7a5f; }
.kv .v.pos { color: #3ecf7a; }
.slot { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.slot .label { flex: 1; min-width: 0; }
.slot .label b { font: 700 17px/1.2 var(--display); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .label small { color: var(--muted); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font: 700 11px/1.5 var(--display); letter-spacing: 0.05em; text-transform: uppercase; background: var(--paper-2); color: var(--ink-2); }
.pill.chill { background: #d7efe0; color: #0b6b3a; }
.pill.classic { background: #f9dcd5; color: #9a2410; }
.query { position: absolute; right: calc(76px + var(--safe-r)); bottom: calc(var(--console-h) + 8px + var(--console-pad)); width: min(320px, calc(100% - 70px)); border-radius: var(--r); padding: 12px 14px; }
.query h4 { margin: 0 0 6px; font: 700 19px/1.15 var(--display); padding-right: 28px; }
.query .close { position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; border-radius: 8px; color: var(--muted); font-size: 20px; }
.query dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 13.5px; }
.query dt { color: var(--muted); }
.query dd { margin: 0; font-weight: 600; text-align: right; }
.query .btn { width: 100%; margin-top: 10px; }

/* ---------- Menu ---------- */
.lines { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 16px; }
.line-col { display: flex; flex-direction: column; gap: 10px; }
.line h3 { margin: 0 0 2px; color: var(--route); }
.stop { position: relative; display: grid; grid-template-columns: 44px 1fr; align-items: center; column-gap: 8px; width: 100%; min-height: 50px; padding: 6px 6px 6px 0; border-radius: 8px; text-align: left; transition: background 0.1s; }
.stop:hover { background: var(--paper-2); }
.stop:active { background: #e6e2d6; }
.stop::before { content: ''; position: absolute; left: 19px; top: 0; bottom: 0; width: 6px; background: var(--route); }
.stop:first-of-type::before { top: 50%; }
.stop:last-of-type::before { bottom: 50%; }
.stop:only-of-type::before { display: none; }
.stop .code { position: relative; justify-self: center; display: grid; place-items: center; min-width: 36px; height: 24px; padding: 0 4px; border-radius: 12px; background: #fff; border: 3px solid var(--route); color: var(--route); font: 700 11px/1 var(--display); }
.stop .label { min-width: 0; }
.stop .label b { display: block; font: 700 15px/1.15 var(--display); }
.stop .label small { display: block; color: var(--muted); font-size: 12px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- Title screen ---------- */
.title-screen { position: absolute; inset: 0; overflow: hidden; background: #0e1a2a; }
.title-screen picture { display: contents; }
.title-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform-origin: 70% 60%; animation: title-drift 45s ease-in-out infinite alternate; }
@keyframes title-drift { from { transform: scale(1.01); } to { transform: scale(1.07); } }
.title-col { position: absolute; left: calc(max(28px, 5vw) + var(--safe-l)); top: 0; bottom: 0; width: 330px; display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: calc(12px + var(--safe-t)) 0 calc(12px + var(--safe-b)); }
.wordmark { --ring: 4.5px; margin: 0 0 6px; padding: 0 var(--ring); flex: none; display: flex; flex-direction: column; gap: 2px; font: 700 80px/0.98 var(--display); letter-spacing: 0.01em; color: #fff; -webkit-text-stroke: 9px var(--enamel); paint-order: stroke fill; filter: drop-shadow(0 4px 0 var(--enamel-lip)) drop-shadow(0 8px 14px rgba(4, 16, 28, 0.4)); }
.word { display: flex; align-items: center; justify-content: space-between; white-space: nowrap; } /* so RED DOT reaches the right edge */
.red-dot { flex: none; width: 0.66em; height: 0.66em; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 var(--ring) var(--enamel); }
.word-line { position: relative; flex: 1; height: 0.13em; margin-left: 0.16em; border-radius: 0.07em; background: var(--accent); box-shadow: 0 0 0 var(--ring) var(--enamel); }
.word-line::after { content: ''; position: absolute; right: 0; top: 50%; width: 0.26em; height: 0.26em; transform: translateY(-50%); border-radius: 50%; background: #fff; box-shadow: 0 0 0 var(--ring) var(--enamel); }
.title-btns { display: flex; flex-direction: column; gap: 8px; }
.title-btn { display: flex; align-items: center; gap: 12px; min-height: 54px; margin-bottom: 3px; padding: 6px 16px; border-radius: 9px; text-align: left; color: #fff; background: var(--enamel) url('assets/tex-enamel.webp'); border: 1px solid var(--enamel-edge); box-shadow: 0 4px 0 var(--enamel-lip), 0 8px 18px rgba(8, 18, 30, 0.35); transition: transform 0.06s, box-shadow 0.06s, background-color 0.1s; }
.title-btn:hover { background-color: #1c3149; background-image: none; }
.title-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--enamel-lip), 0 4px 10px rgba(8, 18, 30, 0.35); }
.title-btn .dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.title-btn .text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.title-btn b { font: 700 18px/1.15 var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-btn small { font: 500 12.5px/1.2 var(--body); color: #a9bbcc; }
.title-btn.primary, .title-btn.primary:hover { background: var(--accent); border-color: #ff6a4f; box-shadow: 0 4px 0 var(--press-lip), 0 8px 18px rgba(8, 18, 30, 0.35); }
.title-btn.primary:active { box-shadow: 0 1px 0 var(--press-lip); }
.title-btn.primary .dot { background: #fff; }
.title-btn.primary small { color: rgba(255, 255, 255, 0.86); }
.title-foot { font: 500 12.5px/1.3 var(--body); color: #fff; text-shadow: 0 1px 3px rgba(4, 16, 28, 0.85); }
.title-foot button { font: inherit; color: inherit; font-weight: 600; text-decoration: underline; padding: 4px 0; text-shadow: inherit; }
@media (orientation: portrait) {
  .title-col { left: 50%; transform: translateX(-50%); justify-content: flex-start; padding-top: calc(4vh + var(--safe-t)); }
}
@media (max-height: 640px) {
  .title-col { width: 300px; gap: 6px; }
  .wordmark { --ring: 4px; font-size: 72px; -webkit-text-stroke-width: 8px; }
  .title-btns { gap: 5px; }
  .title-btn { min-height: 44px; padding: 3px 14px; }
  .title-btn b { font-size: 16px; }
  .title-btn small { display: none; }
}
@media (prefers-reduced-motion: reduce) { .title-art { animation: none; } }
#splash { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; overflow: hidden; background: #0e1a2a; }
#splash img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#splash p { position: absolute; left: 0; right: 0; bottom: 8%; margin: 0; text-align: center; color: #fff; font: 700 22px/1 'Saira Semi Condensed', system-ui, sans-serif; text-shadow: 0 2px 8px rgba(4, 10, 18, 0.9); }

/* ---------- New city screen ---------- */
.newcity { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 440px) 1fr; pointer-events: none; }
.newcity > * { pointer-events: auto; }
.newcity .panel { background: var(--paper) url('assets/tex-paper.webp'); height: 100%; overflow: auto; touch-action: pan-y; padding: 0 22px calc(22px + var(--safe-b)) calc(22px + var(--safe-l)); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.nc-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; margin: 0 -22px 0 calc(-22px - var(--safe-l)); padding: calc(10px + var(--safe-t)) 14px 10px calc(14px + var(--safe-l)); color: #fff; background: var(--enamel) url('assets/tex-enamel.webp'); box-shadow: 0 2px 0 var(--enamel-lip); }
.nc-head h2 { margin: 0; font: 700 22px/1.1 var(--display); }
.nc-back { flex: none; width: 42px; height: 40px; margin-bottom: 3px; border-radius: 8px; font: 700 24px/1 var(--display); color: #fff; background: var(--enamel-raised); border: 1px solid var(--enamel-edge); box-shadow: 0 3px 0 var(--enamel-lip); }
.nc-back:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--enamel-lip); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .lab { font: 600 12px/1 var(--body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.field .help { font-size: 13px; color: var(--muted); margin: 0; }
.namebox { display: flex; gap: 6px; }
.namebox input { flex: 1; min-width: 0; font: 700 20px/1 var(--display); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode { text-align: left; border-radius: 12px; padding: 12px; background: var(--paper-2); display: flex; flex-direction: column; gap: 4px; border: 2px solid transparent; }
.mode b { font: 700 20px/1 var(--display); }
.mode small { color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.mode[aria-pressed='true'] { border-color: var(--ink); background: #fff; }
.continue { display: flex; gap: 8px; flex-wrap: wrap; }
.nc-form { display: flex; flex-direction: column; gap: 14px; }
.nc-switch { align-self: stretch; }
.nc-switch button { flex: 1; }
.scn-list { display: flex; flex-direction: column; gap: 10px; }
.scn { border-radius: 12px; padding: 12px 14px; background: var(--paper-2); border: 2px solid transparent; display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.scn[aria-pressed='true'] { border-color: var(--ink); background: #fff; }
.scn-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.scn-head b { font: 700 20px/1 var(--display); }
.scn p { margin: 0; font-size: 13.5px; line-height: 1.35; color: var(--ink-2); }
.scn ul { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.45; }
.scn .btn { align-self: flex-start; }
.tag { font: 700 11px/1 var(--body); letter-spacing: 0.06em; text-transform: uppercase; padding: 4px 7px; border-radius: 6px; background: #dfe9d8; color: #1f5b24; }
.tag.medium { background: #f7e7c6; color: #7a4d00; }
.tag.hard { background: #f6d6cf; color: #8a1e0a; }
.line-plan { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--console-h) + var(--console-pad) + 10px); width: min(460px, calc(100% - 220px)); z-index: 6; }
.line-plan .head { font: 700 15px/1.2 var(--display); }
.line-plan p { margin: 4px 0 8px; font-size: 13.5px; color: var(--ink-2); }
.line-plan .btns { margin-top: 0; justify-content: flex-end; }
.goal-chip { display: flex; flex-direction: column; justify-content: center; gap: 4px; cursor: pointer; min-width: 150px; }
.goal-chip .t { font: 700 14px/1 var(--display); white-space: nowrap; }
.progress { height: 8px; border-radius: 4px; background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 4px; background: var(--good); transition: width 0.4s; }
.goal-check { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.goal-check:last-child { border-bottom: 0; }
.goal-check .top { display: flex; justify-content: space-between; gap: 10px; font-size: 14.5px; }
.goal-check .top b { font: 700 15px/1.2 var(--display); white-space: nowrap; }
.tutorial { position: absolute; left: calc(var(--rail-w, 100px) + var(--safe-l)); bottom: calc(var(--console-h) + 8px + var(--console-pad)); width: min(360px, calc(100% - 24px)); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; z-index: 5; border-left: 4px solid var(--accent); }
.tutorial b { font: 700 19px/1.1 var(--display); }
.tutorial p { margin: 0; font-size: 14px; line-height: 1.4; }
.tutorial .btns { margin-top: 4px; flex-wrap: wrap; }
.tutorial .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }
.tut-top { display: flex; justify-content: space-between; align-items: center; }
.tut-top .k { font: 600 10px/1 var(--body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tut-top .dots { display: flex; gap: 4px; }
.tut-top .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tut-top .dots i.done { background: var(--good); }
.tut-top .dots i.now { background: var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); }
/* On an enamel panel the text colours turn light, so the plain buttons turn dark to match. */
.photo-strip .btn:not(.primary, .ghost), .tutorial .btn:not(.primary, .ghost) { background: var(--enamel-raised); color: #fff; border-color: var(--enamel-edge); box-shadow: 0 3px 0 var(--enamel-lip); }
.photo-strip .btn:not(.primary, .ghost):active:not(:disabled), .tutorial .btn:not(.primary, .ghost):active:not(:disabled) { box-shadow: 0 1px 0 var(--enamel-lip); }
.photo-strip .btn.ghost, .tutorial .btn.ghost { color: var(--ink-2); border-color: var(--enamel-edge); box-shadow: none; }
.photo-strip .seg { background: var(--enamel-lip); }
.tut-start { align-self: stretch; border: 2px dashed var(--line); background: transparent; }
.nc-starts { display: flex; flex-direction: column; gap: 8px; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(232, 52, 26, 0.7); } 50% { box-shadow: 0 0 0 7px rgba(232, 52, 26, 0); } }
.pal-btn.pulse, .tool-card.pulse { animation: pulse 1.4s ease-in-out infinite; outline: 2px solid #ff6a4f; outline-offset: 0; }
@media (prefers-reduced-motion: reduce) { .pal-btn.pulse, .tool-card.pulse { animation: none; } }
.fly-item .name small { display: block; font: 500 12px/1.2 var(--body); color: var(--muted); margin-top: 1px; }
#ui > .town-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; } /* a full-screen layer: clicks must reach the map */
.town-label { position: absolute; left: 0; top: 0; pointer-events: auto; font: 700 13px/1 var(--display); letter-spacing: 0.03em; color: #fff; padding: 3px 7px; border-radius: 6px; background: rgba(24, 35, 47, 0.55); white-space: nowrap; }
.town-label:hover { background: rgba(24, 35, 47, 0.85); }
#ui.photo-on > *:not(.photo-strip) { display: none !important; }
.photo-strip { position: absolute; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%); width: min(620px, calc(100% - 16px)); display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: var(--r); pointer-events: auto; }
.ph-panel { display: flex; flex-direction: column; gap: 8px; }
.ph-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.ph-row .k { font: 600 10px/1 var(--body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.ph-slider { flex: 1 1 220px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.ph-slider .k { width: 38px; }
.ph-slider input { flex: 1; min-width: 0; accent-color: var(--accent); }
.ph-slider .n { font: 700 13px/1 var(--display); min-width: 38px; text-align: right; }
.ph-switch { display: flex; align-items: center; gap: 8px; }
.ph-rides { display: flex; flex-wrap: wrap; gap: 4px; }
.ph-rides .btn, .ph-main .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }
.ph-note { font-size: 13px; color: var(--muted); }
.ph-main { justify-content: center; }
.paper { font-family: Georgia, 'Times New Roman', serif; color: #1d1b18; background: #f7f3ea; margin: -4px -2px 0; padding: 14px 16px 16px; border-radius: 8px; }
.paper .masthead { border-bottom: 3px double #1d1b18; padding-bottom: 6px; margin-bottom: 10px; text-align: center; }
.paper .masthead .name { font: 900 clamp(26px, 6vw, 38px)/1 'Playfair Display', Georgia, serif; letter-spacing: 0.01em; }
.paper .masthead .meta { display: flex; justify-content: space-between; font: 600 11px/1 var(--body); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 8px; border-top: 1px solid #1d1b18; padding-top: 5px; }
.paper h3 { font: 900 clamp(22px, 5vw, 30px)/1.08 'Playfair Display', Georgia, serif; margin: 0 0 6px; color: inherit; text-transform: none; letter-spacing: 0; }
.paper h4 { color: inherit; text-transform: none; letter-spacing: 0; }
.paper h4 { font: 700 17px/1.15 'Playfair Display', Georgia, serif; margin: 0 0 4px; }
.paper p { margin: 0 0 8px; font-size: 14.5px; line-height: 1.45; }
.paper .lead { border-bottom: 1px solid #b9b2a4; padding-bottom: 8px; margin-bottom: 10px; }
.paper .cols { display: grid; grid-template-columns: 1fr 170px; gap: 14px; }
.paper .stories section { border-bottom: 1px solid #d8d1c3; padding-bottom: 6px; margin-bottom: 8px; }
.paper .stories section:last-child { border-bottom: 0; }
.paper aside { border-left: 1px solid #b9b2a4; padding-left: 12px; display: flex; flex-direction: column; gap: 10px; }
.paper .box b { font: 700 11px/1 var(--body); letter-spacing: 0.08em; text-transform: uppercase; }
.paper .box p { margin: 3px 0 0; font-size: 13.5px; }
.paper .box .big { font: 900 28px/1 'Playfair Display', Georgia, serif; }
.paper .letter { border-top: 3px double #1d1b18; margin-top: 8px; padding-top: 8px; }
.paper .letter b { font: 700 11px/1 var(--body); letter-spacing: 0.08em; text-transform: uppercase; }
.paper .letter p { font-style: italic; margin: 4px 0 2px; }
.paper .letter small { color: #6b655a; }
@media (max-width: 560px) { .paper .cols { grid-template-columns: 1fr; } .paper aside { border-left: 0; padding-left: 0; border-top: 1px solid #b9b2a4; padding-top: 8px; } }
.ach { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ach .badge { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--paper-2); color: var(--muted); font: 700 16px/1 var(--display); }
.ach.got .badge { background: var(--accent); color: #fff; }
.ach small { display: block; color: var(--muted); font-size: 12.5px; }
.ach:not(.got) b { color: var(--muted); }
.newcity .peek-area { pointer-events: none !important; }
.peek-hint { position: absolute; bottom: calc(18px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 14px; font: 600 15px/1.2 var(--body); box-shadow: var(--shadow); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; font: 700 22px/1 var(--display); color: var(--ink); }

/* Where the console leaves room, the view cluster sits in the corner. */
@media (min-width: 1140px) {
  .viewbar { bottom: calc(8px + var(--console-pad)); }
}
/* Narrower screens: the city's name sits on the mini-map, and everything tightens up. */
@media (max-width: 1100px) {
  .con-place { position: relative; }
  .city-plate { position: absolute; left: 9px; bottom: 9px; width: var(--block); padding: 2px 4px; border-radius: 0 0 5px 5px; background: rgba(10, 21, 36, 0.78); }
  .city-plate .dot { display: none; }
  .city-name { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; text-align: center; }
  .con { gap: 8px; padding: 8px; }
  .con-time { width: 160px; }
  .con-money { grid-template-columns: auto 98px; gap: 8px; }
  .util { width: 80px; }
  .con-qol { grid-template-columns: repeat(3, 34px); gap: 6px 4px; }
  .pal-btn.layers-btn { width: 52px; }
  .pal-btn.menu-btn { width: 42px; }
  .v { font-size: 18px; }
  .city-date { font-size: 17px; }
}
/* The smallest screens the game runs on. */
@media (max-width: 780px), (max-height: 640px) {
  :root { --console-h: 88px; }
  .layers-btn .lab { display: none; }
  .pal-btn.layers-btn { width: 44px; }
  .con-views { flex-direction: column; gap: 3px; }
  .con-layers { flex: 1; min-height: 0; }
  .layers-btn .ico { height: 24px; }
  .weather { display: none; }
  .speed button { height: 32px; }
  .city-date { font-size: 15px; }
  .viewbar { gap: 4px; }
  .viewbar .pal-btn { width: 40px; height: 40px; }
  .query { right: calc(70px + var(--safe-r)); }
}
/* Smaller rail buttons, when railLayout asks for them. */
.rail.small .rail-tab .ico { height: 22px; }
.rail.small .rail-tab .ico svg { width: 18px; height: 18px; }
.rail.small .rail-tab .ico.thumb img { width: 22px; height: 22px; }
.rail.small .rail-tab .lab { font-size: 10.5px; }
@media (max-width: 780px) {
  .con-time { width: 133px; }
  .con-money { grid-template-columns: auto 82px; gap: 6px; }
  .util { width: 72px; }
  .gauge { grid-template-columns: 1fr 28px; gap: 2px 4px; }
  .gauge .n { font-size: 12px; }
  .v { font-size: 16px; }
  .k { font-size: 9.5px; }
  .con-qol { grid-template-columns: repeat(3, 26px); gap: 4px 3px; }
  .qol svg { width: 16px; height: 16px; }
  .pal-btn.menu-btn { width: 36px; }
  .tray { width: min(252px, calc(100% - var(--rail-w, 100px) - 8px)); }
}
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }


/* ---------- Development site ---------- */
.dev-banner { flex: none; background: #fff4d6; border: 1px solid #e0a800; border-radius: 10px; padding: 12px 14px; display: grid; gap: 6px; justify-items: start; }
.dev-banner b { font: 700 17px/1.15 var(--display); }
.dev-banner p { margin: 0; font-size: 13.5px; }
.dev-banner .btn { text-decoration: none; margin-top: 4px; }
.dev-chip { display: grid; gap: 1px; padding: 6px 10px; text-align: right; background: #fff4d6; border: 1px solid #e0a800; border-radius: 10px; box-shadow: var(--shadow); font-size: 12.5px; line-height: 1.25; }
.dev-chip b { font: 700 13px/1.2 var(--display); }
.dev-chip a { color: var(--info); font-weight: 600; }

/* ---------- About ---------- */
.credits { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.credits a { color: var(--info); }

/* ---------- Too small to play ---------- */
.too-small { display: none; position: fixed; inset: 0; z-index: 100; place-content: center; gap: 8px; padding: 24px; text-align: center; background: var(--paper); color: var(--ink); }
.too-small h1 { margin: 0; font: 700 26px/1.1 var(--display); }
.too-small p { margin: 0; color: var(--muted); max-width: 340px; }
@media (max-width: 699px), (max-height: 539px) { .too-small { display: grid; } }

/* ---------- Performance overlay (?perf) ---------- */
.perf { position: absolute; top: calc(8px + var(--safe-t)); left: var(--rail-w, 100px); max-width: calc(100% - var(--rail-w, 100px) - 16px); display: grid; gap: 6px; justify-items: start; padding: 8px 10px; border-radius: 10px; background: rgba(12, 22, 32, 0.86); color: #fff; font: 500 12px/1.3 ui-monospace, Menlo, monospace; }
.perf-btns { display: flex; gap: 6px; }
.perf-btns button { padding: 6px 10px; border-radius: 7px; background: #33475c; }
.perf-btns button:disabled { opacity: 0.5; }
.perf-results { margin: 0; overflow-x: auto; max-width: 100%; user-select: text; -webkit-user-select: text; }
