/* CityGrowth — pastel, flat, minimal borders */
:root {
  --bg: #f4f6f8;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --ink: #2f3a35;
  --ink-soft: #5a655f;
  --ink-faint: #8b948f;
  --accent: #6fae8a;
  --accent-ink: #2e6b4f;
  --ring: rgba(111, 174, 138, 0.35);
  --line: rgba(40, 60, 50, 0.08);
  --shadow: 0 10px 34px rgba(40, 60, 50, 0.18);
  --radius: 16px;
  --topbar-bg: rgba(255, 255, 255, 0.85);
  --chip-bg: #eef5ef;
  --chip-ink: #5a655f;
  /* HDR-1 (round 53): the header's height is a variable, because the nav now
     lives inside it and every floating panel offsets from it. One number, one
     place — no panel can be left behind under the bar again (HUD-1). */
  --hdr-h: 52px;
  --foot-h: 34px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #app {
  width: 100%; height: 100%; overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #3f4a45; background: #e9eef2;
}

#scene { position: absolute; inset: 0; cursor: move; }
#scene.orbit { cursor: grab; }
#scene.orbit:active { cursor: grabbing; }
#scene.possess { cursor: crosshair; }

/* First-person possession (#52): the exit button and the look hint, pinned to
   the BOTTOM right so the eye can always find the way out.

   R105: they used to sit top right, which is where every right-hand panel
   lives — #info, #legend, #map, #charts and #calls are all at right:16px
   under the header. So possessing anybody put the ✕ exactly over the open
   panel's own close button and, at z-28 against their z-9, ate the click:
   the detail panel could not be shut without leaving the mode first. The
   bottom right is empty but for the minimap, and `:has` lifts the pair clear
   of it when it is shown and drops them to the footer when it is not — no
   state for the page to keep in sync, and if a browser cannot do `:has` the
   bar simply sits a little high.

   --mini-h is the minimap's circle plus its gap; it is restated in the mobile
   block, where the circle is smaller. */
:root { --mini-h: 178px; }
#possess-exit {
  position: absolute; bottom: calc(var(--foot-h) + 12px + var(--mini-h)); right: 14px; z-index: 28;
  width: 34px; height: 34px; border: none; border-radius: 10px;
  background: rgba(46, 59, 52, 0.85); color: #fff;
  font-size: 15px; line-height: 1; cursor: pointer;
  box-shadow: 0 4px 14px rgba(20, 30, 24, 0.35);
}
#possess-exit:hover { background: #b3452f; }
#possess-hint {
  position: absolute; bottom: calc(var(--foot-h) + 12px + var(--mini-h)); right: 58px; z-index: 28;
  padding: 7px 12px; border-radius: 10px;
  background: rgba(46, 59, 52, 0.72); color: #eaf2ec;
  font-size: 12.5px; letter-spacing: .2px;
  pointer-events: none; box-shadow: 0 4px 14px rgba(20, 30, 24, 0.3);
}
/* the minimap is off (or hidden with everything else): take its room back */
body:has(#minimap-wrap.collapsed) #possess-exit,
body:has(#minimap-wrap.collapsed) #possess-hint { bottom: calc(var(--foot-h) + 12px); }

/* ---- left panel ------------------------------------------------------- */
/* HUD-1/HUD-3: below the header, above the footer, and only ever as tall as
   the space between them — it used to sit at top:16px under an opaque 46px
   header bar, so its own title row was painted over and cut off. */
#hud {
  position: absolute; top: calc(var(--hdr-h) + 12px); left: 16px; width: min(620px, calc(100vw - 32px));
  padding: 12px 14px 12px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(40, 60, 50, 0.10);
  display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100vh - var(--hdr-h) - var(--foot-h) - 24px); overflow-y: auto; scrollbar-width: thin;
}
#hud header { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
#hud header #title { flex: 1 1 auto; }
/* A4 (#63): clock · mood · stats, side by side. The first two wrap inside
   their own column instead of overflowing a narrow panel; the third takes the
   room that is left, because a twelve-tile grid needs it. */
#hud-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.5fr); gap: 12px; align-items: start; }
#hud-cols .hud-col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
#hud-cols .gt { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-faint); }
#hud-cols #clock, #hud-cols #mood { white-space: normal; line-height: 1.15; }
/* A3 (#63): a block that outgrows its panel scrolls rather than being clipped. */
#hud-cols .hud-col > div:last-child { max-height: 42vh; overflow-y: auto; scrollbar-width: thin; min-height: 0; }
@media (max-width: 860px) { #hud-cols { grid-template-columns: 1fr; } }
#title { font-size: 17px; font-weight: 700; letter-spacing: .2px; color: #2f3a35; }
#era { font-size: 12px; font-weight: 600; color: #5f8a72; background: #e7f2ea; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
/* R4: the clock and the mood are readings, not chrome. They were coloured
   pills of run-on text; they are tile grids now, on the panel's own ground,
   sharing every rule with #stats below. */
#clock, #mood { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 4px;
  font-size: 12px; font-weight: 600; background: none; padding: 0; border-radius: 0; }

#stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 4px; }
.stat { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.stat .ico { font-size: 13px; }
.stat .val { font-size: 13.5px; font-weight: 700; color: #2f3a35; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: 10px; color: #7a857f; }

#tiers { display: flex; flex-direction: column; gap: 3px; }
.tier { display: grid; grid-template-columns: 14px 78px 1fr 48px; align-items: center; gap: 6px; font-size: 11px; color: #5a655f; }
.tier .sw { display: inline-block; width: 14px; height: 6px; border-radius: 3px; }
.tier .bar { display: block; height: 6px; background: #eef2ef; border-radius: 3px; overflow: hidden; }
.tier .bar i { display: block; height: 100%; background: #a9c4b4; border-radius: 3px; transition: width .4s ease; }
.tier .val { text-align: right; font-variant-numeric: tabular-nums; color: #7a857f; }

#controls { display: flex; gap: 8px; align-items: center; }
#controls button, #seed-row button {
  border: none; border-radius: 10px; padding: 7px 14px;
  font-size: 13px; font-weight: 600; color: #3f4a45; background: #e4efe9; cursor: pointer;
  transition: transform .05s ease, background .12s ease;
}
#controls button:hover, #seed-row button:hover { background: #d3e6dd; transform: translateY(-1px); }
#controls button:active { transform: translateY(0); }
#controls #play { min-width: 74px; }

#seed-row { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #7a857f; }
#seed-row input {
  flex: 1; min-width: 0; border: none; border-radius: 8px; padding: 6px 9px;
  font: inherit; font-size: 12.5px; color: #2f3a35; background: #f1f5f2; outline: none;
}
#seed-row input:focus { background: #e9f1ec; }
#seed-row button { padding: 6px 10px; }

#layers { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 12px; font-weight: 600; color: #4a6a58; }
#layers label { display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; background: #eef5ef; padding: 4px 9px; border-radius: 9px; }
#layers input { accent-color: #6fae8a; cursor: pointer; }

/* ---- legend (right) ----------------------------------------------------- */
#legend {
  position: absolute; top: calc(var(--hdr-h) + 12px); right: 16px; width: 300px;
  padding: 10px 12px 12px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(40, 60, 50, 0.10);
  font-size: 12px;
}
#legend-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; color: #2f3a35; }
/* R123b: the legend's toggle is a `.min` like every other panel's close
   button — it was the one square dash left. */
#legend-shut { display: none; }
#legend .rows { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; }
#legend .row { display: flex; align-items: center; gap: 6px; color: #4d5852; white-space: nowrap; overflow: hidden; min-width: 0; }
#legend .row .sw { flex: none; width: 14px; height: 12px; border-radius: 3px; }
#legend .row .sw.road { height: 4px; width: 20px; border-radius: 2px; }
#legend .row .lbl { overflow: hidden; text-overflow: ellipsis; }
#legend .row .unlock { margin-left: auto; font-size: 9.5px; color: #9aa59f; padding-right: 4px; }
#legend .roads { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(0,0,0,0.06); display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; }

/* ---- tooltip + hint ------------------------------------------------------ */
#tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(6px);
  padding: 7px 10px; border-radius: 10px; box-shadow: 0 4px 16px rgba(40,60,50,0.14);
  font-size: 12px; color: #4d5852; display: flex; flex-direction: column; gap: 2px; max-width: 260px;
}
#tooltip b { color: #2f3a35; font-size: 13px; }
#tooltip[hidden] { display: none; }   /* R541: the flex above would otherwise keep it up */


/* #57: the legend's top-bar button is a DESKTOP control too. It used to be
   hidden here and only restored in the mobile block below, which left the
   legend unclosable on a desktop: its own `–` collapsed the rows but never the
   panel, `#legend-shut` was mobile-only, and there was no key for it — so
   there was no way to shut it and no way back. The minimap keeps its own
   arrangement: it has the `m` key and `h`, so it is never stuck. */
/* R151: a rule here used to hide the minimap pill inside the top bar on the
   desktop and show it again under 720px — it was mobile-only for want of room.
   The nav is split across two bars now and that pill lives in the footer's
   view group, where there is room at every width, so both rules are gone
   rather than left pointing at a bar the button no longer sits in. */
#topbar button[hidden] { display: none; }
#footbar button[hidden] { display: none; }

@media (max-width: 720px) {
  #hud { width: calc(100vw - 32px); }
  /* legend + minimap: restored on mobile as panels reachable from the top bar */
  #legend {
    display: block; position: fixed; top: calc(var(--hdr-h) + 8px); right: 10px; width: min(300px, calc(100vw - 90px));
    max-height: calc(100vh - 70px); overflow-y: auto; z-index: 10;
  }
  #legend-shut { display: inline-block; position: absolute; top: 8px; right: 8px; border: none; background: none; font-size: 14px; color: #7a857f; cursor: pointer; }
  #legend-head { padding-right: 18px; }
  #legend.collapsed-panel { display: none; }
  /* MINI-1: the minimap is round and bottom-right on EVERY viewport, so this
     block only shrinks it. It used to re-pin it fixed/top-left, which both
     contradicted MINI-1 and never applied: the desktop rule below carries the
     same specificity and comes later in the file, so it won anyway. The shape
     is restated rather than inherited so the circle cannot be lost by an
     ordering change. */
  #minimap-wrap {
    display: block; width: 132px; height: 132px; z-index: 10;
    border-radius: 50%; overflow: hidden;
  }
  #minimap { width: 132px; height: 132px; }
  #minimap-wrap.collapsed { display: none; }
  :root { --mini-h: 142px; }   /* R105: the possession bar clears the smaller circle */
  #layers { display: flex; flex-wrap: wrap; }
  /* R84: on a phone the pills are icons only — the names would not fit */
  #topbar button b { display: none; }
  #topbar button { padding: 5px 8px; gap: 0; }
  #topbar .navsect + .navsect { margin-left: 4px; padding-left: 5px; }
  #visuals { top: calc(var(--hdr-h) + 8px); right: 10px; left: auto; width: min(300px, calc(100vw - 20px)); max-height: calc(100vh - 70px); overflow-y: auto; }
  #visuals { top: calc(var(--hdr-h) + 8px); width: min(320px, calc(100vw - 20px)); max-height: calc(100vh - 70px); }
  #info { top: calc(var(--hdr-h) + 8px); right: 10px; left: auto; width: min(330px, calc(100vw - 20px)); max-height: calc(100vh - 90px); }
  #charts { top: calc(var(--hdr-h) + 8px); right: 10px; left: auto; width: min(330px, calc(100vw - 20px)); max-height: calc(100vh - 70px); }
}

/* ---- #59: the merged settings panel -------------------------------------
   Graphics, layers, zoning, world and reporting were two panels behind two
   icons. These are the content-level rules the old settings panel brought with
   it; the panel's own layout (the three-column grid) lives further down and
   must stay the one that positions it. */
#visuals label.wide { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
#visuals label.row { flex-direction: row; align-items: center; gap: 6px; cursor: pointer; }
#visuals input[type=text] { font: inherit; font-size: 12.5px; border: 1px solid rgba(80,110,90,0.25); border-radius: 8px; padding: 6px 8px; background: #fff; color: #2f3a35; }
#visuals select { font: inherit; font-size: 12px; border: none; border-radius: 7px; padding: 5px 7px; background: #f1f5f2; color: #2f3a35; }
#visuals button { border: none; border-radius: 8px; padding: 6px 11px; font: inherit; font-size: 12px; font-weight: 600; background: #e4efe9; color: #3f4a45; cursor: pointer; }
#visuals button:hover { background: #d3e6dd; }
#visuals .row-actions { display: flex; gap: 6px; }
#visuals #perf { font-size: 11px; color: #7a857f; }
#version { font-size: 10.5px; color: #9aa59f; font-variant-numeric: tabular-nums; grid-column: 1 / -1; }   /* R78: the build stamp */
/* R89: the citizens pager and the places list */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 11.5px; color: var(--ink-soft); }
.pager.hidden { display: none; }
/* R121: the same pager inside a details card, a shade tighter */
.pager.card { margin: 2px 0 8px; }
.pager button { border: none; background: #e4efe9; color: #3f4a45; font: inherit; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; cursor: pointer; }
.pager button:disabled { opacity: 0.4; cursor: default; }
.pager button:not(:disabled):hover { background: #d3e6dd; }
#notables, #families { margin-top: 8px; }
#notables-list, #families-list { display: flex; flex-direction: column; gap: 2px; max-height: 190px; overflow-y: auto; scrollbar-width: thin; }
#notables-list a, #families-list a { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--ink); cursor: pointer; padding: 2px 4px; border-radius: 6px; }
#notables-list a:hover, #families-list a:hover { background: rgba(80,120,100,0.1); }
#notables-list small, #families-list small { color: var(--ink-faint); flex: none; }
#places { margin-top: 8px; }
#places-list { display: flex; flex-direction: column; gap: 2px; max-height: 190px; overflow-y: auto; scrollbar-width: thin; }
#places-list a { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--ink); cursor: pointer; padding: 2px 4px; border-radius: 6px; }
#places-list a:hover { background: #e4efe9; }
#places-list small { color: var(--ink-faint); }
#citizens-list li .vip { color: #8a6f2a; font-weight: 700; }
/* R88: the worker switch inside the performance panel, above its buttons */
#perf-worker { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-soft); cursor: pointer; margin-top: 6px; }
#perf-worker small { color: var(--ink-faint); }
#perf-worker input { accent-color: #6fae8a; }

/* ---- round 3: mood, settings, feed, labels, minimap, photo mode ---------- */

#perf { font-size: 11px; color: #7a857f; font-variant-numeric: tabular-nums; }
#feed-wrap { border-top: 1px solid rgba(0,0,0,0.06); padding-top: 6px; }
#feed-wrap .feed-title { font-size: 10.5px; font-weight: 700; color: #7a857f; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
#feed { display: flex; flex-direction: column; gap: 2px; height: 96px; overflow-y: auto; overflow-x: hidden; font-size: 11px; color: #5a655f; scrollbar-width: thin; padding-right: 4px; }
#feed .ev { display: flex; gap: 6px; align-items: baseline; white-space: nowrap; overflow: hidden; flex: none; line-height: 1.35; }
#feed .ev .x { overflow: hidden; text-overflow: ellipsis; }
#feed .ev .t { color: #9aa59f; font-variant-numeric: tabular-nums; flex: none; width: 34px; }
#feed .ev.fire { color: #b3573d; }
#feed .ev.crime { color: #a05248; }
#feed .ev.jam { color: #b3815e; }
#feed .ev.transit { color: #5b84a8; }
#feed .ev.upgrade { color: #4a7a5e; }
#feed .ev.downgrade, #feed .ev.blight { color: #a0764a; }
#feed .ev.landmark, #feed .ev.era { color: #4a7a5e; font-weight: 600; }
#feed .ev.district { color: #6b5f9a; }
#feed .ev.weather, #feed .ev.season { color: #6f7f96; }
#feed .ev.mood { color: #8a6d3b; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#labels .label { pointer-events: auto; cursor: pointer; }
#labels .label {
  position: absolute; transform: translate(-50%, -50%);
  font-size: 12px; font-weight: 700; letter-spacing: .4px; color: #3b4a42;
  background: #ffffff; padding: 3px 9px;
  border: 1px solid #8a948f; border-radius: 999px;
  box-shadow: 0 2px 8px rgba(40,60,50,0.14);
  white-space: nowrap; text-transform: uppercase; text-align: center;
}
/* MINI-1 (round 53): a round minimap, always bottom right, `m` to hide it,
   click for the full map. The canvas keeps its square pixel buffer — the
   circle is the frame clipping it, which costs nothing to draw. */
#minimap-wrap {
  position: absolute; right: 16px; bottom: calc(var(--foot-h) + 12px);
  width: 168px; height: 168px;
  border-radius: 50%; overflow: hidden; cursor: pointer;
  box-shadow: 0 6px 24px rgba(40,60,50,0.18), 0 0 0 3px rgba(255,255,255,0.8) inset;
  transition: box-shadow .15s ease;
}
#minimap-wrap:hover { box-shadow: 0 8px 28px rgba(40,60,50,0.24), 0 0 0 3px var(--accent) inset; }
#minimap {
  width: 168px; height: 168px; display: block;
  background: #cfe0d0; image-rendering: pixelated;
}
body.photo #hud, body.photo #legend, body.photo #labels, body.photo #minimap, body.photo #tooltip { display: none !important; }

/* ---- zones row (now a group inside #visuals, HUD-3) --------------------- */
/* R78: a column block like the other groups — the zoning layers keep their
   tints as full-width rows, the name layers (R48) sit under them plain */
#zones-row label { user-select: none; }
#zones-row label.z { gap: 6px; padding: 3px 8px; border-radius: 9px; font-weight: 600; }
#zones-row label.res { background: #ece3f5; color: #6b4f8f; }
#zones-row label.com { background: #e3f2e8; color: #3f7a58; }
#zones-row label.ind { background: #f3e8dc; color: #8a5f3a; }
#zones-row label.hood { background: #ece9f3; color: #5a4f7a; }
#perf { font-size: 11px; color: #7a857f; font-variant-numeric: tabular-nums; }
#labels .label small { display: block; font-size: 10px; font-weight: 600; letter-spacing: 0; text-transform: none; color: #5a655f; }
/* R48: street names lie along their streets, house numbers sit over the doors */
#labels .label.street { font-size: 11px; font-weight: 700; letter-spacing: .3px; text-transform: none; padding: 1px 7px; background: rgba(255,255,255,0.86); border-color: #b9c2bd; box-shadow: none; color: #46554d; }
#labels .label.house { font-size: 10px; font-weight: 700; letter-spacing: 0; text-transform: none; padding: 0 5px; border-radius: 4px; background: rgba(255,255,255,0.9); border-color: #b9c2bd; box-shadow: none; color: #3b4a42; }
#labels .label.far { font-size: 14px; letter-spacing: .6px; }
#zones-row input { accent-color: #6fae8a; }

/* ---- toasts ------------------------------------------------------------- */
/* R218 — the toasts: a row just above the footer, on the minimap's spacing
   (16 from the screen's edge, 12 over the footer, 12 between toasts), running
   left to right and stopping short of the minimap. A new one slides in from
   the left, opening its own room so the others ease along; each fades out
   where it stands. */
#toasts { position: absolute; left: 16px; right: calc(16px + 168px + 16px); bottom: calc(var(--foot-h) + 12px);
  display: flex; flex-direction: row; flex-wrap: nowrap; align-items: flex-end; pointer-events: none; z-index: 6; }
body:has(#minimap-wrap.collapsed) #toasts { right: 16px; }
body:has(#cine-bar:not([hidden])) #toasts { bottom: calc(var(--foot-h) + 12px + 76px); }   /* above the cinematic caption */
.toast {
  flex: none; display: flex; gap: 8px; align-items: center; padding: 8px 0; margin-right: 0; border-radius: 14px;
  max-width: 0; overflow: hidden;
  background: rgba(255,255,255,0.86); backdrop-filter: blur(8px); box-shadow: 0 6px 20px rgba(40,60,50,0.16);
  font-size: 13px; font-weight: 600; color: #3b4a42; white-space: nowrap;
  opacity: 0; transform: translateX(-28px);
  transition: opacity .35s ease, transform .45s cubic-bezier(.2,.7,.3,1), max-width .45s cubic-bezier(.2,.7,.3,1),
    padding .45s cubic-bezier(.2,.7,.3,1), margin .45s cubic-bezier(.2,.7,.3,1);
}
.toast.show, .toast.hide { max-width: 340px; padding: 8px 14px; margin-right: 12px; transform: none; }
.toast.show { opacity: 1; }
.toast.hide { opacity: 0; transition: opacity .5s ease; }
.toast > span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.toast .i { font-size: 15px; }
.toast.fire { color: #b3573d; }
.toast.crime { color: #a05248; }
.toast.jam { color: #b3815e; }
.toast.transit { color: #5b84a8; }
.toast.upgrade { color: #3f7a58; }
.toast.downgrade, .toast.blight { color: #a0764a; }
.toast.era, .toast.landmark { color: #3f7a58; }
.toast.zone, .toast.merge { color: #6b4f8f; }
body.photo #toasts { display: none !important; }

/* ---- nav (inside the header) + minimise buttons ------------------------- */
/* HDR-1 (round 53): the nav is a flex child of #hdr, not a floating strip.
   Its whole history was a stacking fight — first with the full-width mobile
   HUD, then with the opaque header bar it had to thread through. Inside the
   header there is nothing to fight: no absolute position, no transform, no
   backdrop, no z-index. On a narrow viewport it scrolls sideways rather than
   wrapping, so the header keeps its height. */
/* R122 — the hamburger. When the buttons do not fit the header, the nav
   becomes a dropdown under a burger: the same buttons, stacked, with their
   labels back (there is room for words in a column). `#topbar.burger` is set
   by main.js when it measures an overflow, so the switch follows the actual
   width rather than a guessed breakpoint. */
#navburger {
  flex: none; display: none; width: 32px; height: 28px; border: none; border-radius: 9px;
  background: rgba(0,0,0,0.06); cursor: pointer; padding: 7px 8px; margin-right: 4px;
  flex-direction: column; justify-content: space-between; align-items: stretch;
}
#navburger[hidden] { display: none; }
#navburger.show { display: flex; }
#navburger span { display: block; height: 2px; border-radius: 1px; background: #4d5852; }
#navburger:hover { background: rgba(0,0,0,0.12); }
html[data-theme="night"] #navburger { background: rgba(255,255,255,0.10); }
html[data-theme="night"] #navburger span { background: #cfe0d6; }
#topbar.burger {
  position: absolute; top: var(--hdr-h); left: 8px; right: auto; z-index: 40;
  flex-direction: column; align-items: stretch; justify-content: flex-start;
  width: max-content; min-width: 190px; max-height: calc(100vh - var(--hdr-h) - 24px);
  overflow-y: auto; overflow-x: hidden; gap: 2px; padding: 8px;
  background: rgba(255,255,255,0.97); backdrop-filter: blur(10px);
  border-radius: 14px; box-shadow: 0 14px 40px rgba(40,60,50,0.25);
}
#topbar.burger .navsect { display: flex; flex-direction: column; align-items: stretch; gap: 2px; }
#topbar.burger .navsect + .navsect { margin: 4px 0 0; padding: 4px 0 0; border-left: none; border-top: 1px solid rgba(80,110,90,0.16); }
#topbar.burger button { justify-content: flex-start; gap: 8px; padding: 7px 10px; width: 100%; }
#topbar.burger button b { display: inline !important; }
#topbar.burger[hidden] { display: none; }
html[data-theme="night"] #topbar.burger { background: rgba(20,26,31,0.97); }

#topbar {
  flex: 1 1 auto; min-width: 0;
  display: flex; gap: 2px; align-items: center; justify-content: center;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
}
#topbar::-webkit-scrollbar { display: none; }
/* R84: the nav in groups of white pills, cut from the same cloth as the
   region names on the map — white, a thin grey ring, fully rounded, a soft
   shadow. The name rides beside the icon; on a phone (the media query at the
   foot of this file) the names go and the icons stay. */
#topbar .navsect { flex: none; display: flex; align-items: center; gap: 4px; }
#topbar .navsect + .navsect { margin-left: 8px; padding-left: 10px; border-left: 1px solid var(--line); }
#topbar button {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #8a948f; background: #ffffff; color: #3b4a42;
  font: inherit; font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  line-height: 1; padding: 5px 11px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(40,60,50,0.14);
  opacity: 0.55; transition: opacity .12s ease, background .12s ease, transform .05s ease;
}
#topbar button i { font-style: normal; font-size: 14px; line-height: 1; }
#topbar button em { font-style: normal; font-size: 9px; opacity: 0.7; }
#topbar button.on { opacity: 1; background: #ffffff; border-color: #6f9c85; color: #2f4a3d; }
#topbar button:hover { opacity: 1; transform: translateY(-1px); }
/* R319: moved out of the header at runtime so the header's overflow cannot
   clip it, then pinned beneath the Media pill. */
#media-menu {
  position: fixed; z-index: 40; display: flex; flex-direction: column; gap: 4px;
  min-width: 160px; padding: 7px; background: rgba(255,255,255,0.97);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 34px rgba(40,60,50,0.24);
}
#media-menu[hidden] { display: none; }
#media-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  color: var(--ink); font: inherit; font-size: 12px; cursor: pointer; text-align: left;
}
#media-menu button[hidden] { display: none; }
#media-menu button i { font-style: normal; }
#media-menu button:hover, #media-menu button.on { border-color: #6f9c85; background: rgba(255,255,255,0.72); }
html[data-theme="night"] #media-menu { background: rgba(20,26,31,0.97); }
body.zen #media-menu, body.photo #media-menu { display: none !important; }

/* R151 — the second bar. The header carries what the town IS (the panels you
   read); the footer carries what you DO with it (the view, the camera, the
   help). Eleven pills in one strip went into the hamburger on any laptop, and
   a hamburger is where buttons go to be forgotten.

   Cut from the same cloth as the header's — the same pills, one step smaller,
   because the footer is the quieter bar. */
#footbar { flex: none; display: flex; align-items: center; gap: 0; pointer-events: auto; min-width: 0; }
#footbar .navsect { flex: none; display: flex; align-items: center; gap: 4px; }
#footbar .navsect + .navsect { margin-left: 8px; padding-left: 10px; border-left: 1px solid var(--line); }
#footbar button {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid #9aa4a0; background: #ffffff; color: #3b4a42;
  font: inherit; font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  line-height: 1; padding: 4px 9px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  box-shadow: 0 1px 5px rgba(40,60,50,0.12);
  opacity: 0.55; transition: opacity .12s ease, background .12s ease, transform .05s ease;
}
#footbar button i { font-style: normal; font-size: 13px; line-height: 1; }
#footbar button.on { opacity: 1; background: #ffffff; border-color: #6f9c85; color: #2f4a3d; }
#footbar button:hover { opacity: 1; transform: translateY(-1px); }
/* the footer is a fixed-height strip and the event line is the elastic part —
   it gives way before the buttons do */
#footbar + #foot-ev { flex: 1 1 40px; min-width: 0; }
/* R196 — the camera menu: one pill in the bar, its items a column of pills
   opening upward out of the footer */
#footbar .camdrop { position: relative; }
#cam-btn em { font-style: normal; font-size: 9px; opacity: 0.7; }
#cam-btn[aria-expanded="true"] { opacity: 1; border-color: #6f9c85; }
#cam-menu { position: fixed; z-index: 40;   /* R220: out of the footer, placed by main.js */
   display: flex; flex-direction: column; align-items: stretch; gap: 4px;
  padding: 6px; border-radius: 14px; background: rgba(255, 255, 255, 0.96); box-shadow: 0 8px 26px rgba(40, 60, 50, 0.22); }
#cam-menu[hidden] { display: none; }
#cam-menu button { display: inline-flex; align-items: center; gap: 5px; justify-content: flex-start; padding: 6px 11px;
  border: 1px solid #9aa4a0; background: #fff; color: #3b4a42; border-radius: 999px; cursor: pointer; white-space: nowrap;
  font: inherit; font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; line-height: 1; }
#cam-menu button i { font-style: normal; font-size: 13px; line-height: 1; }
#cam-menu button:hover { border-color: #6f9c85; }
#cam-menu button.on { border-color: #6f9c85; color: #2f4a3d; }
body.zen #cam-menu, body.photo #cam-menu { display: none !important; }
#cam-menu button b { display: inline !important; }
html[data-theme="night"] #cam-menu { background: rgba(26, 31, 36, 0.96); }

/* R196 — full screen: the header and footer go with the panels, and the name
   stays top left, white over the world with a shadow to read by, half faded */
body.zen #hdr { background: transparent; border-bottom: 0; box-shadow: none; backdrop-filter: none; pointer-events: none; }
body.zen #hdr > :not(#hdr-brand):not(#hdr-town) { display: none !important; }
body.zen #hdr-brand, body.zen #hdr-town { color: #fff !important; background: none !important; opacity: 0.5; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55); }
body.zen #foot, body.zen aside, body.zen #minimap-wrap, body.zen #labels, body.zen #toasts, body.zen #alerts, body.zen #cine-bar, body.zen #tooltip { display: none !important; }
/* narrow: the names go, the icons stay — the same rule the header follows */
@media (max-width: 1180px) { #footbar button b { display: none; } #footbar button { padding: 4px 7px; } }
@media (max-width: 720px)  { #footbar .navsect[data-group="help"] { display: none; } }
@media (max-width: 560px)  { #footbar { display: none; } }
/* R122: a proper close button — a circle with a cross in it. It was a rounded
   square with an en dash, which reads as "minus" rather than "close" and sat
   oddly against the round panels. The cross is drawn from two lines rather
   than typed, so it is the same weight and the same size in every panel
   whatever the font does. */
.min {
  position: relative; border: none; background: rgba(0,0,0,0.06); color: transparent;
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer; margin-left: 6px;
  vertical-align: middle; flex: none; font-size: 0; line-height: 0; padding: 0;
  overflow: hidden; text-indent: -999px;
  transition: background 0.12s ease;
}
/* R123b: the buttons are EMPTY in the markup now. `color: transparent` and
   `font-size: 0` were being overridden by the panels' own id-scoped button
   rules — `#info button { font-size: 12px; color: … }` outranks a class — so
   the old en dash showed through the drawn cross. Nothing to bleed through if
   there is nothing in the button; the belt-and-braces above is for anything
   that ever puts text back. */
.min::before, .min::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 1.6px;
  margin: -0.8px 0 0 -5px; border-radius: 1px; background: #4d5852;
}
.min::before { transform: rotate(45deg); }
.min::after { transform: rotate(-45deg); }
.min:hover { background: rgba(200,70,55,0.16); }
.min:hover::before, .min:hover::after { background: #b3452f; }
html[data-theme="night"] .min { background: rgba(255,255,255,0.10); }
html[data-theme="night"] .min::before, html[data-theme="night"] .min::after { background: #cfe0d6; }

/* R122: a panel is never taller than the window less the chrome; what does not
   fit scrolls under its own sticky header. Seven panels declared this and the
   map, the legend, the calls and the tips did not — the map alone is a 440px
   canvas plus a header and the overlays block, which is taller than a laptop
   window with the browser's own chrome on it. */
#legend, #charts, #feed-panel, #calls, #household, #citizens, #directory, #perf-panel, #map, #visuals, #info, #tips {
  max-height: calc(100vh - var(--hdr-h) - var(--foot-h) - 24px);
  overflow-y: auto; scrollbar-width: thin;
}
#legend > .min { display: none; }   /* a stray one directly under the panel; the header's is #legend-toggle */
#hud.collapsed, #legend.collapsed-panel, #minimap-wrap.collapsed { display: none !important; }
body.photo #topbar { display: none !important; }

/* ---- visuals modal ------------------------------------------------------ */
/* #57: three columns. As one column this panel was taller than the viewport
   on a laptop, so the bottom groups were unreachable. `auto-fit` + a 230px
   floor means the same rule gives three columns at the desktop width, two in
   a narrow window and one on a phone — no media query to keep in step. */
#visuals {
  position: absolute; top: calc(var(--hdr-h) + 8px); left: 50%; transform: translateX(-50%);
  width: min(880px, calc(100vw - 32px)); z-index: 9;
  max-height: calc(100vh - var(--hdr-h) - var(--foot-h) - 24px); overflow-y: auto; scrollbar-width: thin;
  padding: 12px 14px 14px; background: rgba(255,255,255,0.9); backdrop-filter: blur(10px);
  border-radius: 16px; box-shadow: 0 10px 34px rgba(40,60,50,0.18); font-size: 12.5px; color: #3f4a45;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px; align-items: start; align-content: start;
}
/* the title and the preset picker run the full width above the columns */
#visuals header, #visuals .sel { grid-column: 1 / -1; }
/* #59: the folded-in settings groups are grid items like the visuals ones.
   `details.group` opens and closes; the loose labels and action rows that
   came with them are collected into their own column-spanning strip so they
   do not each become a lonely grid cell. */
/* R160 — the panel's tabs. About is a section beside the settings groups, not
   around them: choosing it hides every other child of the panel in one rule,
   so the settings keep the grid and the markup the tests already pin. */
#visuals .set-tabs { grid-column: 1 / -1; display: flex; gap: 2px; margin: -2px 0 2px; border-bottom: 1px solid rgba(80,110,90,0.16); }
#visuals .set-tabs button { background: none; border-radius: 8px 8px 0 0; padding: 6px 12px; color: #6a756f;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
#visuals .set-tabs button:hover { background: #eef4f0; }
#visuals .set-tabs button[aria-selected="true"] { color: #2f4a37; background: none; border-bottom-color: #5aa552; }
#visuals > #about-tab { grid-column: 1 / -1; display: none; }
/* R203: the Look tab, hidden the same way as About */
#visuals > #look-tab { grid-column: 1 / -1; display: none; }
#visuals.tab-look > #look-tab { display: block; }
#visuals.tab-look > :not(header):not(.set-tabs):not(#look-tab) { display: none !important; }
#look-tab .look-pick { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 8px; margin: 4px 0; }
#look-tab .look-pick select, #look-tab .look-grid select { font: inherit; padding: 4px 6px; border-radius: 6px; }
/* R223: resolution and colour palette side by side, and every slider close
   beside its label rather than pushed to the far edge of the column */
#look-tab .look-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
#look-tab label.range { display: grid; grid-template-columns: 116px minmax(0, 1fr); justify-content: stretch; align-items: center; gap: 8px; }
#look-tab label.range input[type=range] { width: 100%; max-width: 220px; }
#look-tab .look-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 18px; margin-top: 6px; }
#visuals.tab-about > #about-tab { display: block; }
#visuals.tab-about > :not(header):not(.set-tabs):not(#about-tab) { display: none !important; }
.about .ab-head b { display: block; font-size: 18px; font-weight: 700; color: #2f4a37; letter-spacing: -0.01em; }
.about .ab-head b span { color: #5aa552; }
.about .ab-head small { display: block; font-size: 11px; opacity: 0.6; margin-top: 1px; }
.about .ab-list { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; margin: 10px 0 14px; }
.about .ab-list dt { color: #7a857f; }
.about .ab-list dd { margin: 0; color: #2f3a35; overflow-wrap: anywhere; }
.about .ab-list [hidden] { display: none; }
#visuals details.group { align-self: start; }
#visuals > label, #visuals > .row-actions, #visuals > #perf { grid-column: 1 / -1; }
#visuals > label.opt { flex-direction: row; align-items: center; gap: 7px; font-weight: 500; }
#visuals > .row-actions { flex-wrap: wrap; }
#visuals .row { display: flex; align-items: center; gap: 6px; }
#visuals #seed-row input { flex: 1 1 auto; min-width: 0; }
#visuals details.group label { font-weight: 500; }
#visuals details.group > label:not(.row) { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
/* R78: the preset details — every row is a name on the left and its control
   on the right; a slider takes the line below its name, full width */
#preset-details > label.row { display: flex; flex-direction: row; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 0; }
#preset-details > label.row input[type=checkbox] { margin: 0; }
#preset-details > label.range { padding-left: 0; gap: 2px; }
#preset-details > label.range > span { display: flex; justify-content: space-between; gap: 6px; color: #6a756f; }
#preset-details > label.range > span b { font-variant-numeric: tabular-nums; color: var(--ink); }
#preset-details > label.range input[type=range] { width: 100%; max-width: none; }
#preset-details > button { margin-top: 4px; }
#visuals.collapsed { display: none; }
#visuals header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: #2f3a35; font-size: 14px; }
#visuals .sel { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
#visuals select { font: inherit; font-size: 12px; border: none; border-radius: 7px; padding: 5px 7px; background: #f1f5f2; color: #2f3a35; }
#visuals .group { display: flex; flex-direction: column; gap: 4px; background: #f4f7f5; border-radius: 10px; padding: 8px 10px; }
#visuals .gt { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: #7a857f; }
#visuals label { display: flex; align-items: center; gap: 7px; cursor: pointer; }
/* R121: a slider is NOT a child of the line above it. Every `label.range` in
   the settings carried a 22px indent, so "people drawn" read as a sub-setting
   of "lamp shadows" and the whole panel looked like a hierarchy that is not
   there. The indent belongs to the rows that genuinely depend on the switch
   above them, and those say so with `.sub`. (The `#preset-details` rule that
   tried to undo this had the same specificity and lost by source order.) */
#visuals label.range { justify-content: space-between; color: #6a756f; padding-left: 0; }
#visuals label.range.sub { padding-left: 22px; position: relative; }
#visuals label.range.sub::before { content: "↳"; position: absolute; left: 6px; color: #b3bdb7; font-size: 11px; }
#visuals input[type=range] { width: 120px; max-width: 52%; accent-color: #6fae8a; }
/* #59b: the two rate sliders — full width under their own label, because the
   value is the point and a 120px stub beside a long label is unreadable */
#visuals label.rate { display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding-left: 0; color: var(--ink); }
#visuals label.rate > span { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 500; }
#visuals label.rate b { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }
#visuals label.rate input[type=range] { width: 100%; max-width: none; }
#visuals .hint { font-size: 10.5px; line-height: 1.35; color: var(--ink-faint); font-weight: 400; }
#visuals input[type=checkbox] { accent-color: #6fae8a; }
/* ---- history charts ------------------------------------------------------ */
#charts {
  position: absolute; top: calc(var(--hdr-h) + 8px); right: 16px; width: 320px; z-index: 9;
  padding: 12px 14px 14px; background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  border-radius: 16px; box-shadow: 0 10px 34px rgba(40,60,50,0.18); font-size: 12.5px; color: #3f4a45;
  display: flex; flex-direction: column; gap: 8px;
  max-height: calc(100vh - 80px); overflow-y: auto; scrollbar-width: thin;
}
#charts.collapsed { display: none; }
#charts header { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; color: #2f3a35; font-size: 14px; }
#charts-span { font-size: 10.5px; font-weight: 600; color: #7a857f; margin-left: auto; }
#charts-rows { display: flex; flex-direction: column; gap: 8px; }
#charts .chart { display: flex; flex-direction: column; gap: 2px; }
#charts .ct { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; }
#charts .cl { font-weight: 600; color: #5a655f; }
#charts .cv { font-weight: 700; color: #2f3a35; font-variant-numeric: tabular-nums; }
#charts canvas { width: 100%; height: 54px; display: block; border-radius: 8px; background: #f4f7f5; }
#charts-mix { display: flex; flex-direction: column; gap: 5px; }
/* R139 (backlog 51) — the town chronicle: a page per year, newest first */
#chronicle { display: flex; flex-direction: column; gap: 10px; max-height: 46vh; overflow-y: auto; }
.chron { border-left: 2px solid var(--line, #d8d2c6); padding: 0 0 2px 8px; }
.chron.running { border-left-color: #b08b4f; }
.chron h4 { margin: 0 0 2px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; }
.chron h4 span { font-weight: 400; opacity: 0.7; font-size: 11px; white-space: nowrap; }
.chron > small { display: block; opacity: 0.65; font-size: 11px; margin-bottom: 3px; }
.chron ul { margin: 3px 0 0; padding-left: 14px; }
.chron li { margin: 1px 0; font-size: 11px; line-height: 1.35; }
.chron li[data-go] { cursor: pointer; }
.chron li[data-go]:hover { text-decoration: underline; }
.chron .hint { margin: 2px 0 0; font-size: 11px; opacity: 0.55; }
/* R140 (backlog 53) — the year's photograph, taken as the year turned */
.chron-shot { display: block; width: 100%; border-radius: 3px; margin: 2px 0 4px; }
#charts .mix-bar { display: flex; height: 9px; border-radius: 5px; overflow: hidden; background: #eef2ef; }
#charts .mix-bar i { display: block; height: 100%; }
#charts .mix-keys { display: flex; flex-wrap: wrap; gap: 3px 9px; font-size: 10.5px; color: #7a857f; }
#charts .mix-keys span { display: flex; align-items: center; gap: 4px; }
#charts .mix-keys i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* panels above the map labels */
#labels { z-index: 1; }
#hud, #legend, #minimap-wrap, #tooltip, #toasts { z-index: 5; }
#tooltip { z-index: 8; }
#hud { z-index: 6; }

/* ---- R121: every panel's header sticks -----------------------------------
   A panel scrolls its own content; the header scrolled away with it, so on a
   long citizens list or a long details card the close button was somewhere
   above the top of the panel and the only way out was the toolbar. The header
   is pinned to the top of the scroll box now, the content runs under it, and
   the title sits left with the close button hard right — the same place in
   every panel, always reachable.

   The background has to be its own: the panels are translucent with a
   backdrop blur, and a transparent sticky header shows the scrolling text
   straight through itself. */
#legend > header,
#charts > header,
#feed-panel > header,
#calls > header,#household > header,
#album > header,
#papers > header,
#citizens > header,
#directory > header,
#perf-panel > header,
#map > header,
#visuals > header,
#info > header,
#tips > header {
  /* R196: a sticky box sticks inside the panel's padding, so `top: 0` left a
     padding-high gap above the header; it sticks at the panel's edge instead */
  position: sticky; top: calc(var(--panel-pad-y, 12px) * -1); z-index: 4;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  /* R121b: the negative margin pulls the header out to the panel's own edges,
     so it must match that panel's padding. It was one hard-coded 12/14 for
     every panel — right for the seven that use 12px 14px, two pixels out on
     the legend and the tips, and badly wrong on the map, which has NO padding
     of its own (its header carries it) and clips its overflow: the title was
     pulled outside the rounded corner and cut off. */
  margin: calc(var(--panel-pad-y, 12px) * -1) calc(var(--panel-pad-x, 14px) * -1) 8px;
  padding: 10px var(--panel-pad-x, 14px);
  background: rgba(255,255,255,0.94); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(80,110,90,0.14);
  border-radius: 14px 14px 0 0;
}
#legend { --panel-pad-y: 10px; --panel-pad-x: 12px; }
#tips { --panel-pad-y: 14px; --panel-pad-x: 16px; }
/* the map's panel has no padding — the header is already at its edge, so it
   pulls out by nothing and keeps the header's own generous inset */
#map { --panel-pad-y: 0px; --panel-pad-x: 0px; }
#map > header { padding: 10px 12px; }
/* the title takes the room, the close button keeps its corner */
#legend > header > span:first-child,
#charts > header > span:first-child,
#feed-panel > header > span:first-child,
#calls > header > span:first-child,#household > header > span:first-child,
#album > header > span:first-child,
#papers > header > span:first-child,
#citizens > header > span:first-child,
#directory > header > span:first-child,
#perf-panel > header > span:first-child,
#map > header > span:first-child,
#visuals > header > span:first-child,
#info > header > span:first-child,
#tips > header > span:first-child { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#legend > header > button,
#charts > header > .min,
#feed-panel > header > .min,
#calls > header > .min,#household > header > .min,
#album > header > .min,
#papers > header > .min,
#citizens > header > .min,
#directory > header > .min,
#perf-panel > header > .min,
#map > header > .min,
#visuals > header > .min,
#info > header > .min,
#tips > header > .min { flex: none; margin-left: auto; }
html[data-theme="night"] #legend > header,
html[data-theme="night"] #charts > header,
html[data-theme="night"] #feed-panel > header,
html[data-theme="night"] #calls > header,html[data-theme="night"] #household > header,
html[data-theme="night"] #citizens > header,
html[data-theme="night"] #directory > header,
html[data-theme="night"] #perf-panel > header,
html[data-theme="night"] #map > header,
html[data-theme="night"] #visuals > header,
html[data-theme="night"] #info > header,
html[data-theme="night"] #tips > header {
  background: rgba(20,26,31,0.94); border-bottom-color: rgba(255,255,255,0.12);
}

/* R124: the cinematic mode's own bar — what the camera answers to, bottom
   left, above the footer. Pointer-events off: it is a caption, not a control,
   and a click on the world behind it must still take the camera back. */
#cine-bar {
  position: fixed; left: 14px; bottom: calc(var(--foot-h) + 12px); z-index: 30;
  display: flex; flex-direction: column; gap: 4px; pointer-events: none;
  padding: 8px 12px; border-radius: 12px; max-width: min(520px, calc(100vw - 28px));
  background: rgba(18,24,29,0.55); backdrop-filter: blur(8px); color: #eef3f0;
  font-size: 11.5px; letter-spacing: 0.01em; text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
#cine-bar[hidden] { display: none; }
#cine-bar .cb-now b { font-size: 12.5px; font-weight: 700; }
#cine-bar .cb-keys { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; opacity: 0.85; }
#cine-bar kbd {
  display: inline-block; min-width: 15px; text-align: center; padding: 1px 5px; margin-right: 2px;
  border-radius: 5px; background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.18);
  font: inherit; font-size: 11px; font-weight: 700;
}
body.photo #cine-bar { display: none !important; }

/* R231: the stream's overlay (?stream=1). White on the picture with a soft
   shadow, so it reads on sky, water and snow alike; nothing in it takes a
   click. The header is hidden, not removed, so the view keeps its size. */
#stream-hud { position: fixed; inset: 0; z-index: 31; pointer-events: none; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
#stream-hud[hidden] { display: none; }
body.stream #hdr { visibility: hidden !important; }
#stream-hud .sh-top { position: absolute; left: 18px; top: 14px; display: flex; align-items: baseline; gap: 14px; font-size: 13px; font-weight: 600; white-space: nowrap; }
#stream-hud .sh-logo, #stream-hud #sh-town { font-size: 15px; font-weight: 700; letter-spacing: .2px; }
#stream-hud #sh-town:empty { display: none; }
#stream-hud .sh-cap { position: absolute; left: 18px; bottom: 16px; display: flex; flex-direction: column; gap: 3px; max-width: min(560px, calc(100vw - 200px)); }
#stream-hud #sh-shot { font-size: 14px; font-weight: 700; }
#stream-hud #sh-where { font-size: 12.5px; opacity: 0.85; }
#stream-hud #sh-where:empty { display: none; }
#stream-hud .sh-credit { position: absolute; right: 18px; bottom: 16px; font: 15px Arial, Helvetica, sans-serif; letter-spacing: .3px; opacity: 0.4; }
body.photo #stream-hud { display: none !important; }


/* R121: the citizens' filters — two columns of short labelled controls. */
#cit-filters .cit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; }
#cit-filters .cit-grid label { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 11.5px; font-weight: 600; color: #6a756f; cursor: pointer; }
#cit-filters .cit-grid input, #cit-filters .cit-grid select { width: 100%; min-width: 0; font: inherit; font-size: 12px; border: 1px solid rgba(80,110,90,0.22); border-radius: 7px; padding: 4px 6px; background: #fff; color: #2f3a35; }
#cit-filters .row-actions { margin-top: 6px; }
html[data-theme="night"] #cit-filters .cit-grid input, html[data-theme="night"] #cit-filters .cit-grid select { background: #1a2026; color: #e8edf1; border-color: rgba(255,255,255,0.14); }

/* ---- overlay + activity + info panel ------------------------------------ */
/* R121: one overlays block at the foot of the map, in two columns — the map's
   own layer on the left, the ground's on the right. They used to sit a
   headerful apart and read as unrelated controls. */
#overlays { font-size: 12px; color: #3b4a42; padding: 8px 10px; margin: 2px 0; border-radius: 10px; background: linear-gradient(135deg, #eef6f0, #e6eef9); border: 1px solid rgba(80,110,90,0.18); }
#overlays .ov-title { font-weight: 700; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: #6a756f; margin-bottom: 6px; }
#overlays .ov-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
#overlays .ov { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#overlays .ov > span { font-weight: 700; font-size: 11.5px; color: #3b4a42; }
#overlays select { width: 100%; min-width: 0; font: inherit; font-size: 12.5px; font-weight: 600; border: 1px solid rgba(80,110,90,0.25); border-radius: 8px; padding: 6px 8px; background: #fff; color: #2f3a35; cursor: pointer; }
#overlay-legend { display: inline-block; margin-top: 6px; font-weight: 600; color: #6a756f; }
#feed .ev.loc { cursor: pointer; }
#feed .ev.loc:hover { background: rgba(80,120,100,0.1); border-radius: 5px; }
#feed .ev .go { color: #4a7a5e; margin-left: auto; flex: none; font-size: 11px; }
.toast.loc { pointer-events: auto; cursor: pointer; }
.toast.loc:hover { background: rgba(255,255,255,0.98); }
.toast .go { color: #4a7a5e; font-size: 12px; margin-left: 2px; }
.moodrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.moodrow .mood { font-weight: 700; color: #3b4a42; }
.moodrow .stress { font-weight: 700; color: #b8452e; font-size: 0.9em; }
.reasons { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
#overlay-legend { display: flex; align-items: center; gap: 4px; font-size: 10.5px; color: #7a857f; }
#overlay-legend[hidden] { display: none; }
#overlay-legend i { display: inline-block; width: 12px; height: 8px; border-radius: 2px; }
#overlay-legend i.lo { background: #4fc2b8; } #overlay-legend i.hi { background: #e0442a; }
#activity { display: flex; gap: 8px; flex-wrap: wrap; font-size: 11px; color: #5a655f; }
#activity span { background: #f1f5f2; border-radius: 8px; padding: 2px 7px; }
#info {
  position: absolute; top: calc(var(--hdr-h) + 8px); right: 16px; width: 330px; max-height: calc(100vh - var(--hdr-h) - var(--foot-h) - 24px); overflow-y: auto; z-index: 9;
  padding: 12px 14px 14px; background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  border-radius: 16px; box-shadow: 0 10px 34px rgba(40,60,50,0.18); font-size: 12.5px; color: #3f4a45; scrollbar-width: thin;
}
#info.collapsed { display: none; }
/* R602 — the life card: a citizen as a life game shows them, a pane of the card's own glass */
#life-card { margin: 0 0 10px; padding: 10px 12px 12px; border-radius: 16px; background: linear-gradient(160deg, rgba(255,255,255,0.80), rgba(232,246,237,0.62));
  border: 1px solid rgba(255,255,255,0.9); box-shadow: inset 0 1px 0 rgba(255,255,255,0.95), 0 6px 18px rgba(40,60,50,0.12);
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3); }
#life-card[hidden] { display: none; }
.life-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.life-face { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 23px; background: #fff;
  box-shadow: 0 2px 8px rgba(40,60,50,0.16), inset 0 0 0 2px #bfe7cc; }
.life-who b { display: block; font-size: 14px; color: #2f3a35; }
.life-who small { color: #6a766f; }
.life-thought { position: relative; margin: 0 0 12px 24px; }
.life-thought .bubble { display: inline-block; padding: 7px 13px; border-radius: 18px; background: #fff; color: #33443b; font-style: italic; box-shadow: 0 3px 10px rgba(40,60,50,0.14); }
.life-thought i { position: absolute; background: #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(40,60,50,0.12); }
.life-thought .d1 { width: 10px; height: 10px; left: -12px; top: 9px; }
.life-thought .d2 { width: 6px; height: 6px; left: -21px; top: 20px; }
.life-mood, .need { position: relative; display: grid; grid-template-columns: 18px 64px 1fr 12px 24px; align-items: center; gap: 6px; margin: 5px 0; }
.life-mood { margin-bottom: 10px; }
.life-mood .nm, .need .nm { color: #5c6862; font-weight: 600; font-size: 11.5px; }
#life-card .ic { font-size: 13px; text-align: center; }
#life-card .meter { position: relative; display: block; height: 10px; border-radius: 999px; background: rgba(40,60,50,0.10); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,0.08); }
#life-card .meter i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #86d9a0, #22b358); transition: width .6s cubic-bezier(.2,.8,.2,1); }
#life-card [data-level="ok"] .meter i { background: linear-gradient(90deg, #f5dc86, #e6ad35); }
#life-card [data-level="low"] .meter i { background: linear-gradient(90deg, #f3a08b, #d8463a); }
#life-card .trend { font-size: 9px; color: #9aa59f; }
#life-card .trend[data-dir="up"] { color: #22a353; }
#life-card .trend[data-dir="down"] { color: #cc4b3c; }
#life-card .val { font-size: 11px; font-weight: 700; color: #3f4a45; text-align: right; }
#life-card .delta { position: absolute; right: 34px; top: -6px; font-size: 11px; font-weight: 800; pointer-events: none; animation: life-float 1.3s ease-out forwards; }
#life-card .delta.up { color: #1f9a4f; }
#life-card .delta.down { color: #cc4b3c; }
@keyframes life-float { from { opacity: 0; transform: translateY(6px); } 20% { opacity: 1; } to { opacity: 0; transform: translateY(-14px); } }
.life-outing { display: flex; gap: 8px; align-items: center; margin: 10px 0 2px; padding: 6px 10px; border-radius: 12px; background: rgba(255,255,255,0.72); color: #3f4a45; }
.life-join { margin: 6px 0 2px; display: flex; flex-direction: column; gap: 7px; align-items: flex-start; color: #6a766f; }
.life-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
html[data-theme="night"] #life-card { background: linear-gradient(160deg, rgba(40,50,56,0.82), rgba(26,34,38,0.72)); border-color: rgba(255,255,255,0.14); box-shadow: 0 6px 18px rgba(0,0,0,0.3); }
html[data-theme="night"] .life-who b, html[data-theme="night"] #life-card .val { color: #e8edf1; }
html[data-theme="night"] .life-thought .bubble, html[data-theme="night"] .life-outing { background: rgba(255,255,255,0.1); color: #e8edf1; }
/* R602 — the pills: every button on a card and in the household panel, white and rounded like the header's */
.pill, #info-body button:not(.min), #household-body button { display: inline-flex; align-items: center; gap: 5px; border: 1px solid #b7c1bc; background: #fff; color: #33443b;
  font: inherit; font-size: 11.5px; font-weight: 700; line-height: 1; padding: 6px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(40,60,50,0.12); transition: transform .05s ease, border-color .12s ease, box-shadow .12s ease; }
.pill:hover, #info-body button:not(.min):not(:disabled):hover, #household-body button:hover { border-color: #6f9c85; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(40,60,50,0.18); }
.pill.on, #info-body button.on, #household-body button.on { border-color: #22b358; color: #1f6b3e; background: #effaf2; }
#info-body button:disabled { opacity: .45; cursor: default; }
html[data-theme="night"] .pill, html[data-theme="night"] #info-body button:not(.min), html[data-theme="night"] #household-body button { background: #27303a; color: #e8edf1; border-color: rgba(255,255,255,0.18); }
/* R603 — the family diary: a glass book over the dimmed town */
#diary { position: fixed; inset: 0; z-index: 72; display: grid; place-items: center; background: rgba(18,24,22,0.36); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
#diary[hidden] { display: none !important; }
#diary .dy-book { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 80px); display: flex; flex-direction: column; border-radius: 22px; padding: 16px 18px;
  background: rgba(255,255,255,0.64); border: 1px solid rgba(255,255,255,0.78); color: #22302a;
  box-shadow: 0 24px 60px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.9); -webkit-backdrop-filter: blur(20px) saturate(1.35); backdrop-filter: blur(20px) saturate(1.35); }
#diary header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
#diary .dy-icon { font-size: 24px; }
#diary h3 { flex: 1; margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
#diary .dy-entries { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; overflow-y: auto; padding: 2px; }
#diary .dy-entry { display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; background: rgba(255,255,255,0.8); box-shadow: 0 4px 14px rgba(40,60,50,0.12); }
#diary .dy-entry img, #diary .dy-noshot { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
#diary .dy-noshot { display: grid; place-items: center; font-size: 26px; background: linear-gradient(135deg, #eef6f0, #dcecE2); opacity: 0.85; }
#diary .dy-text { padding: 8px 12px 10px; }
#diary .dy-text small { color: #6a766f; }
#diary .dy-text p { margin: 3px 0 0; font-size: 13px; line-height: 1.35; }
#diary .dy-text a { color: inherit; cursor: pointer; text-decoration: underline; text-decoration-color: rgba(34,48,42,0.25); }
#diary footer { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
#diary .pill:disabled { opacity: .4; cursor: default; transform: none; }
#diary .dy-empty { grid-column: 1 / -1; text-align: center; color: #6a766f; padding: 30px 0; }
@media (max-width: 600px) { #diary .dy-entries { grid-template-columns: 1fr; } }
html[data-theme="night"] #diary .dy-book { background: rgba(20,26,30,0.72); border-color: rgba(255,255,255,0.16); color: #eef3ef; }
html[data-theme="night"] #diary .dy-entry { background: rgba(255,255,255,0.08); }
/* R602 — a house's people, a chip each */
.res-chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 4px 0 10px; }
#info-body .res-chip { justify-content: flex-start; gap: 8px; padding: 5px 10px 5px 5px; border-radius: 14px; white-space: normal; text-align: left; font-weight: 600; }
.res-chip .av { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: #f1f7f3; font-size: 16px; }
.res-chip b { display: block; font-size: 12px; }
.res-chip small { display: block; font-weight: 500; color: #6a766f; font-size: 10.5px; }
.res-chip.vip .av { box-shadow: inset 0 0 0 2px #22b358; }
#info header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: #2f3a35; font-size: 14px; margin-bottom: 8px; }
#info .kv { display: grid; grid-template-columns: 96px 1fr; gap: 3px 8px; margin-bottom: 8px; }
#info .kv b { color: #7a857f; font-weight: 600; }
#info .kv .bad { color: #b3452f; }   /* R116: savings in the red */
#info .tag { display: inline-block; padding: 1px 7px; border-radius: 999px; background: #eef3ef; font-size: 11px; margin-right: 4px; }
#info .tag.open { background: #dff2e5; color: #2f7a4e; } #info .tag.closed { background: #f5e1e1; color: #9a4a4a; }
#info .bar { display: block; height: 6px; background: #eef2ef; border-radius: 3px; overflow: hidden; }
#info .bar i { display: block; height: 100%; background: linear-gradient(90deg, #a9c4b4, #e0442a); }
#info ul { list-style: none; margin: 2px 0 8px; padding: 0; max-height: 132px; overflow-y: auto; }
#info li { display: flex; justify-content: space-between; gap: 6px; padding: 2px 0; border-bottom: 1px solid rgba(0,0,0,0.04); }
#info li a { color: #4a7a5e; cursor: pointer; text-decoration: none; }
#info li small { color: #9aa59f; }
#info button { border: none; border-radius: 8px; padding: 6px 11px; font: inherit; font-size: 12px; font-weight: 600; background: #e4efe9; color: #3f4a45; cursor: pointer; margin-right: 6px; }
#info button.on { background: #6fae8a; color: #fff; }
#info h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: #7a857f; margin: 8px 0 3px; }

/* ---- GUI overhaul (issue #31): header, footer, tips, night theme --------- */
/* Modern white pastel: soft box shadows, rounded corners, friendly pastels. */
#app { background: var(--bg); }

/* header — brand, live season/clock/year chip, quick actions */
#hdr {
  position: absolute; top: 0; left: 0; right: 0; height: var(--hdr-h); z-index: 25;
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--surface); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 20px rgba(40, 60, 50, 0.08);
  color: var(--ink);
}
#hdr-brand { flex: none; font-size: 15px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
/* R605: the new logo everywhere — on a white pill wherever the ground under it can be dark */
#hdr-brand img { display: block; height: 30px; width: auto; margin: -4px 0; }   /* the image carries its own margin */
html[data-theme="night"] #hdr-brand { background: rgba(255,255,255,0.92); border-radius: 999px; padding: 3px 10px; }
#title .title-logo { height: 32px; width: auto; vertical-align: middle; margin: -6px 0; }
#stream-hud .sh-logo { display: inline-flex; align-items: center; background: rgba(255,255,255,0.92); border-radius: 999px; padding: 3px 10px; }
#stream-hud .sh-logo img { display: block; height: 26px; width: auto; margin: -3px 0; }
/* R196: the town's numbers and its calendar, each in a recessed well — sunk
   into the header with an inner shadow and a hairline border */
.hdr-well { flex: none; display: inline-flex; align-items: center; gap: 12px; font-size: 12px; font-weight: 600;
  color: var(--chip-ink); background: var(--chip-bg); padding: 4px 12px; border-radius: 999px; white-space: nowrap;
  font-variant-numeric: tabular-nums; border: 1px solid rgba(80, 110, 90, 0.22); box-shadow: inset 0 1px 3px rgba(40, 60, 50, 0.2); }
#hdr-actions { flex: none; display: flex; gap: 6px; }
/* R196: white circles, cut from the nav pills' cloth, the icon the pills' size */
#hdr-actions button {
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  border: 1px solid #8a948f; background: #fff; color: #3b4a42; box-shadow: 0 2px 8px rgba(40, 60, 50, 0.14);
  font-size: 14px; line-height: 1; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  transition: background .12s ease, transform .05s ease;
}
#hdr-actions button svg { display: block; }
#hdr-actions button:hover { border-color: #6f9c85; transform: translateY(-1px); }
#hdr-actions button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
#hdr-actions button[hidden] { display: none; }

/* footer — the transport controls (HUD-1), the latest event, brand credit */
#foot {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--foot-h); z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px; background: var(--surface); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 12px;
  pointer-events: none; white-space: nowrap; overflow: hidden;
}
/* HUD-1: the footer as a whole stays click-through (it overlays the map), but
   the control group must not — it is the pause button. */
#foot-controls { flex: none; display: flex; gap: 6px; pointer-events: auto; }
#foot-controls button {
  border: none; border-radius: 8px; padding: 5px 12px;
  font: inherit; font-size: 12px; font-weight: 600; color: #3f4a45; background: #e4efe9; cursor: pointer;
  transition: background .12s ease, transform .05s ease;
}
#foot-controls button:hover { background: #d3e6dd; transform: translateY(-1px); }
#foot-controls button:active { transform: translateY(0); }
#foot-controls #play { min-width: 66px; }
#foot-ev { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
/* #59: the two rates, next to the brand. Tabular figures so they do not
   jitter as the numbers change, and a warning colour when the simulation is
   falling short of the speed that was asked for. */
/* R121: a button now — it opens the performance panel — but it must still
   read as part of the footer, not as a control competing with the transport. */
#foot-rates {
  flex: none; color: var(--ink-faint); font-size: 11px; font-variant-numeric: tabular-nums;
  white-space: nowrap; cursor: pointer;
  background: none; border: 0; padding: 0 2px; font-family: inherit; line-height: inherit;
}
#foot-rates:hover { color: var(--ink); text-decoration: underline; }
#foot-rates.short { color: #b3815e; font-weight: 600; }
#foot-brand { flex: none; color: var(--ink-faint); font-size: 11px; }
body.photo #foot { display: none !important; }


/* tips panel — one-tip modal, single responsibility */
#tips {
  position: absolute; top: calc(var(--hdr-h) + 8px); left: 50%; transform: translateX(-50%); width: min(420px, calc(100vw - 24px)); z-index: 22;
  padding: 14px 16px; background: var(--surface); backdrop-filter: blur(12px);
  border-radius: var(--radius); box-shadow: var(--shadow); font-size: 13px; color: var(--ink);
}
#tips.collapsed { display: none; }
#tips header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 14px; margin-bottom: 8px; }
#tips-body { display: flex; flex-direction: column; gap: 5px; color: var(--ink-soft); line-height: 1.5; }
#tips-body b { color: var(--ink); }

/* settings accordion group */
#visuals details.group { border: 1px solid var(--line); border-radius: 10px; padding: 2px 10px 8px; background: #fafbfa; }
#visuals details.group summary { cursor: pointer; font-weight: 700; color: var(--ink-soft); padding: 6px 0; }
#visuals details.group label { margin-top: 6px; }
#visuals label { color: var(--ink); }

/* ---- night theme (issue #31) ------------------------------------------- */
/* Inverts the pastel chrome: dark surfaces, light ink, softer shadows. */
html[data-theme="night"] body { background: #14181d; }
html[data-theme="night"] #app { background: #14181d; }
html[data-theme="night"] #hdr { background: rgba(24, 29, 35, 0.92); border-bottom-color: rgba(255,255,255,0.08); color: #e8edf1; }
html[data-theme="night"] #hdr-brand { color: #e8edf1; }
html[data-theme="night"] .hdr-well { background: #1a1f24; color: #b7c2cb; border-color: #39424c; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45); }
html[data-theme="night"] #hdr-actions button { background: #2a323a; color: #d5dde3; border-color: #4a555f; box-shadow: none; }
html[data-theme="night"] #hdr-actions button:hover { background: #333c45; }
html[data-theme="night"] #hdr-actions button.on { background: #4a9b70; color: #fff; }
html[data-theme="night"] #topbar { background: rgba(24, 29, 35, 0.88); box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
html[data-theme="night"] #topbar button { color: #b7c2cb; background: #20262c; border-color: #39424c; box-shadow: none; }
html[data-theme="night"] #topbar button.on { background: #2a323a; border-color: #6f9c85; color: #e8edf1; }
html[data-theme="night"] #foot { background: rgba(24, 29, 35, 0.92); border-top-color: rgba(255,255,255,0.08); color: #9fb0bb; }
html[data-theme="night"] #foot-brand, html[data-theme="night"] #foot-rates { color: #5e6d78; }
html[data-theme="night"] #foot-rates.short { color: #c99a6e; }
html[data-theme="night"] #hud, html[data-theme="night"] #legend, html[data-theme="night"] #info,
html[data-theme="night"] #charts, html[data-theme="night"] #visuals,
html[data-theme="night"] #tips, html[data-theme="night"] #tooltip, html[data-theme="night"] #toasts .toast {
  background: rgba(28, 34, 41, 0.92); color: #dde5ea; box-shadow: 0 10px 34px rgba(0,0,0,0.45);
}
html[data-theme="night"] #hud header #title, html[data-theme="night"] #title,
html[data-theme="night"] #legend-head, html[data-theme="night"] #charts header,
html[data-theme="night"] #visuals header,
html[data-theme="night"] #info header, html[data-theme="night"] #tips header { color: #e8edf1; }
html[data-theme="night"] .stat .val, html[data-theme="night"] .tier, html[data-theme="night"] .chart .cv { color: #e8edf1; }
html[data-theme="night"] .stat .lbl, html[data-theme="night"] .tier .val, html[data-theme="night"] .tier .lbl,
html[data-theme="night"] .chart .cl, html[data-theme="night"] #charts-span, html[data-theme="night"] #perf,
html[data-theme="night"] #info .kv b, html[data-theme="night"] #info h4, html[data-theme="night"] #feed .ev .t,
html[data-theme="night"] #visuals label { color: #93a3ae; }
html[data-theme="night"] #era { background: #20262c; color: #cfe0d6; }
html[data-theme="night"] #controls button, html[data-theme="night"] #seed-row button,
html[data-theme="night"] #info button, html[data-theme="night"] #visuals button {
  background: #20262c; color: #cfe0d6;
}
html[data-theme="night"] #controls button:hover, html[data-theme="night"] #seed-row button:hover,
html[data-theme="night"] #info button:hover, html[data-theme="night"] #visuals button:hover { background: #2a323a; }
html[data-theme="night"] #info button.on { background: #4a9b70; color: #fff; }
html[data-theme="night"] #layers label, html[data-theme="night"] #activity span, html[data-theme="night"] #zones-row label {
  background: #20262c; color: #cfe0d6;
}
html[data-theme="night"] #seed-row input, html[data-theme="night"] #visuals input[type=text],
html[data-theme="night"] #visuals select,
html[data-theme="night"] #overlays select { background: #1a2026; color: #e8edf1; border-color: rgba(255,255,255,0.14); }
html[data-theme="night"] #seed-row input:focus { background: #222a31; }
html[data-theme="night"] #overlays { background: linear-gradient(135deg, #1d252b, #1a232b); border-color: rgba(255,255,255,0.12); color: #cfe0d6; }
html[data-theme="night"] #overlays .ov > span { color: #cfe0d6; }
html[data-theme="night"] #feed-wrap, html[data-theme="night"] #legend .roads { border-top-color: rgba(255,255,255,0.1); }
html[data-theme="night"] #legend .rows { color: #b7c2cb; }
html[data-theme="night"] #visuals .group, html[data-theme="night"] #charts canvas,
html[data-theme="night"] #info .bar, html[data-theme="night"] #tiers .tier .bar, html[data-theme="night"] #charts .mix-bar { background: #1a2026; }
html[data-theme="night"] #legend .tier .bar { background: #1a2026; }
html[data-theme="night"] #minimap { box-shadow: 0 6px 24px rgba(0,0,0,0.4); }
html[data-theme="night"] .toast { color: #dde5ea; }
html[data-theme="night"] .min { background: rgba(255,255,255,0.12); color: #b7c2cb; }
html[data-theme="night"] .min:hover { background: rgba(255,255,255,0.2); }
/* labels keep their white pill in the night theme too — the pill is what makes
   them readable, so no night override (issue #40 removed the glow for good). */
html[data-theme="night"] #visuals details.group { background: #1a2026; border-color: rgba(255,255,255,0.1); }
html[data-theme="night"] #visuals details.group summary { color: #93a3ae; }

/* ---- map panel (issue #31): a zoomable top-view map with overlays ------- */
/* R110: twice the size, and in the MIDDLE — a map you have opened deliberately
   is the thing you are looking at, so it takes the centre of the screen rather
   than perching in the corner with the rest of the panels. A drag still wins:
   `placePanel` sets left/top and clears the transform. */
#map {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 640px; z-index: 12;
  background: var(--surface); backdrop-filter: blur(10px); border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 12.5px; color: var(--ink);
}
#map.collapsed { display: none; }
/* R574 (backlog 55): the map large — a window over most of the screen, the canvas filling its left and
   a column for the legend and the readout on its right; the canvas's buffer is set to half its size */
#map-side { display: none; }
#map-big { margin-left: auto; font-size: 14px; line-height: 1; padding: 3px 7px; }
#map.big { position: fixed; top: calc(var(--hdr-h) + 14px); bottom: calc(var(--foot-h) + 14px); left: 4vw; right: 4vw; width: auto; transform: none; z-index: 60;
  display: grid; grid-template-columns: minmax(0, 1fr) 250px; grid-template-rows: auto minmax(0, 1fr) auto auto; }
#map.big > header { grid-column: 1 / -1; }
#map.big canvas { grid-column: 1; grid-row: 2 / span 3; width: 100%; height: 100%; }
#map.big #map-side { display: flex; flex-direction: column; gap: 10px; grid-column: 2; grid-row: 2; overflow-y: auto; padding: 4px 12px 10px; font-size: 12px; }
#map.big #map-zoom, #map.big #overlays { grid-column: 2; }
#map-legend h5 { margin: 0 0 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .7; }
#map-legend .sw { display: flex; align-items: center; gap: 7px; margin: 2px 0; }
#map-legend .sw i { display: inline-block; width: 14px; height: 10px; border-radius: 3px; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }
#map-legend .ramp { height: 10px; border-radius: 5px; margin: 4px 0 2px; }
#map-legend .ends { display: flex; justify-content: space-between; font-size: 10.5px; opacity: .7; }
#map-readout { border-top: 1px solid rgba(0,0,0,0.08); padding-top: 8px; line-height: 1.45; min-height: 4.5em; }
#map-readout b { font-weight: 600; }
#map-readout small { display: block; opacity: .65; }
html[data-theme="night"] #map-readout { border-top-color: rgba(255,255,255,0.1); }
#map header { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; padding: 10px 12px 6px; }
#map header select { font: inherit; font-size: 11.5px; border: none; border-radius: 7px; padding: 4px 6px; background: #f1f5f2; color: var(--ink); }
#map canvas { display: block; width: 100%; height: 440px; image-rendering: pixelated; cursor: crosshair; }
#map #map-zoom { display: flex; align-items: center; gap: 6px; padding: 6px 12px 10px; font-size: 11px; color: var(--ink-faint); }
#map #map-zoom input { flex: 1; accent-color: var(--accent); }
#map #map-zoom output { font-variant-numeric: tabular-nums; min-width: 30px; text-align: right; }
html[data-theme="night"] #map { background: rgba(28, 34, 41, 0.92); color: #dde5ea; }
html[data-theme="night"] #map header select { background: #1a2026; color: #e8edf1; }
html[data-theme="night"] #map #map-zoom { color: #93a3ae; }

@media (max-width: 720px) {
  #hdr { height: 40px; }
  #hdr-chip { max-width: 52vw; overflow: hidden; text-overflow: ellipsis; }
  #hdr-actions button { width: 28px; height: 28px; }
  #foot { height: 26px; font-size: 11px; }
  #tips { top: 48px; }
  /* R110: a phone has no middle to spare — the map fills what there is, and
     the canvas comes down to something that fits above the fold. */
  #map { top: 50%; left: 50%; right: auto; transform: translate(-50%, -50%); width: min(640px, calc(100vw - 20px)); }
  #map canvas { height: min(440px, 52vh); }
  #map canvas { height: 180px; }
  #map.big { left: 8px; right: 8px; top: calc(var(--hdr-h) + 8px); bottom: calc(var(--foot-h) + 8px); grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) auto auto auto; }
  #map.big canvas { grid-row: 2; height: 100%; }
  #map.big #map-side { grid-column: 1; grid-row: 3; max-height: 30vh; }
  #map.big #map-zoom, #map.big #overlays { grid-column: 1; }
}

/* =========================================================================
   Round 53 — the panels that took the load off "stats and controls"
   ========================================================================= */

/* FEED-1 — "What is happening", in its own panel and filtered by category. */
#feed-panel {
  position: absolute; top: calc(var(--hdr-h) + 8px); left: 16px; width: 300px; z-index: 9;
  max-height: calc(100vh - var(--hdr-h) - var(--foot-h) - 24px); overflow: hidden;
  padding: 12px 14px 14px; background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  border-radius: var(--radius); box-shadow: var(--shadow); font-size: 12.5px; color: var(--ink);
  display: flex; flex-direction: column; gap: 8px;
}
#feed-panel.collapsed { display: none; }
#feed-panel header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: var(--ink); font-size: 14px; }
#feed-panel #feed { overflow-y: auto; scrollbar-width: thin; max-height: 46vh; }
#feed-panel #feed:empty::after { content: 'Nothing worth reporting yet — the categories are in settings ▸ what to report.'; color: var(--ink-faint); font-size: 11.5px; }
#feed-kinds-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; font-size: 11.5px; font-weight: 600; }
#feed-kinds-rows label { display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; }

/* UI-CIT — the citizens of each region. One <details> per district; only the
   open one renders a list, and that list is a bounded sample. */
#citizens {
  position: absolute; top: calc(var(--hdr-h) + 8px); left: 16px; width: 320px; z-index: 9;
  max-height: calc(100vh - var(--hdr-h) - var(--foot-h) - 24px); overflow: hidden;
  padding: 12px 14px 14px; background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  border-radius: var(--radius); box-shadow: var(--shadow); font-size: 12.5px; color: var(--ink);
  display: flex; flex-direction: column; gap: 8px;
}
#citizens.collapsed { display: none; }
/* R319: the directory uses the citizens frame, with its three bounded lists
   scrolling together beneath a persistent close button. */
#directory {
  position: absolute; top: calc(var(--hdr-h) + 8px); left: 16px; width: 320px; z-index: 9;
  max-height: calc(100vh - var(--hdr-h) - var(--foot-h) - 24px); overflow-y: auto;
  padding: 12px 14px 14px; background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  border-radius: var(--radius); box-shadow: var(--shadow); font-size: 12.5px; color: var(--ink);
  display: flex; flex-direction: column; gap: 8px;
}
#directory.collapsed { display: none; }
@media (max-width: 720px) {
  #citizens, #directory { left: 10px; width: calc(100vw - 20px); }
}
/* R104: the call sheet borrows the citizens panel's frame and sits beside it */
#calls {
  position: absolute; top: calc(var(--hdr-h) + 8px); left: 16px; width: 340px; z-index: 9;
  max-height: calc(100vh - var(--hdr-h) - var(--foot-h) - 24px); overflow: hidden;
  padding: 12px 14px 14px; background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  border-radius: var(--radius); box-shadow: var(--shadow); font-size: 12.5px; color: var(--ink);
  display: flex; flex-direction: column; gap: 8px;
}
#calls.collapsed { display: none; }
/* R563: the household panel, in the calls panel's frame */
#household { position: absolute; top: calc(var(--hdr-h) + 8px); left: 16px; width: 340px; z-index: 9; max-height: calc(100vh - var(--hdr-h) - var(--foot-h) - 24px); overflow: hidden;
  padding: 12px 14px 14px; background: rgba(255,255,255,0.92); backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 12.5px; color: var(--ink);
  display: flex; flex-direction: column; gap: 8px; }
#household.collapsed { display: none; }
#household-body { overflow-y: auto; scrollbar-width: thin; min-height: 0; flex: 1 1 auto; }
#household-body .hh-home { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; margin-bottom: 6px; }
#household-body .hh-home small { font-weight: 400; opacity: .6; }
#household-body .hh-member { padding: 6px 0; border-top: 1px solid rgba(0,0,0,0.06); }
#household-body .hh-name { display: flex; align-items: baseline; gap: 6px; }
#household-body .hh-name small { opacity: .6; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#household-body .hh-name button { flex: none; }
#household-body .kv.needs { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 3px 8px; align-items: center; margin: 4px 0; }
#household-body .kv.needs b { font-weight: 500; opacity: .7; font-size: 11px; }
#household-body .bar { display: block; height: 6px; background: #eef2ef; border-radius: 3px; overflow: hidden; }
#household-body .bar i { display: block; height: 100%; background: linear-gradient(90deg, #e0442a, #a9c4b4); }
#household-body .hh-want { font-size: 11.5px; opacity: .75; }
#household-body h4 { margin: 10px 0 4px; font-size: 12px; }
#household-body .hh-diary { list-style: none; margin: 0; padding: 0; }
#household-body .hh-diary li { padding: 3px 0; border-top: 1px solid rgba(0,0,0,0.05); }
#household-body .hh-diary small { display: block; opacity: .55; font-size: 10.5px; }
#household-body .none { opacity: .55; padding: 6px 2px; }
html[data-theme="night"] #household { background: rgba(24, 29, 35, 0.94); color: #e8edf1; }
html[data-theme="night"] #household-body .bar { background: #1a2026; }
/* R147b: the album borrows the same frame. A panel is not just an <aside> and
   an entry in the two registries — without its own rule it lays out in normal
   document flow and `.collapsed` switches nothing off, which is why it stood
   on the page whether it was open or not. */
#album {
  position: absolute; top: calc(var(--hdr-h) + 8px); left: 16px; width: 320px; z-index: 9;
  max-height: calc(100vh - var(--hdr-h) - var(--foot-h) - 24px); overflow: hidden;
  padding: 12px 14px 14px; background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  border-radius: var(--radius); box-shadow: var(--shadow); font-size: 12.5px; color: var(--ink);
  display: flex; flex-direction: column; gap: 8px;
}
#album.collapsed { display: none; }
/* R233 — the newspaper, in the album's frame but broader, and printed */
#papers {
  position: absolute; top: calc(var(--hdr-h) + 8px); left: 16px; width: min(460px, calc(100vw - 32px)); z-index: 9;
  max-height: calc(100vh - var(--hdr-h) - var(--foot-h) - 24px); overflow: hidden;
  padding: 12px 14px 14px; background: rgba(255,255,255,0.94); backdrop-filter: blur(10px);
  border-radius: var(--radius); box-shadow: var(--shadow); font-size: 12.5px; color: var(--ink);
  display: flex; flex-direction: column; gap: 8px;
}
#papers.collapsed { display: none; }
#papers header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 14px; }
.papers-nav { display: flex; gap: 6px; align-items: center; }
.papers-nav select { flex: 1 1 auto; min-width: 0; font: inherit; padding: 3px 4px; }
.papers-nav button { font: inherit; padding: 2px 9px; cursor: pointer; }
#papers-read { overflow-y: auto; min-height: 0; flex: 1 1 auto; scrollbar-width: thin; }
#papers-read .none { font-size: 11px; opacity: 0.55; }
.np { background: #f4efe3; color: #1d1b17; padding: 12px 14px 14px; border-radius: 3px; font-family: Georgia, 'Times New Roman', serif; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }
.np-mast { font-family: 'Old English Text MT', 'UnifrakturMaguntia', Georgia, serif; font-size: 27px; text-align: center; line-height: 1.1; letter-spacing: .01em; }
.np-date { display: flex; justify-content: space-between; gap: 8px; border-top: 3px double #1d1b17; border-bottom: 1px solid #1d1b17; margin: 6px 0 9px; padding: 2px 0; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; }
.np-head { font-size: 21px; line-height: 1.15; margin: 0 0 8px; font-weight: 700; }
.np-photo { margin: 0 0 8px; }
.np-photo img { display: block; width: 100%; filter: grayscale(0.9) sepia(0.18) contrast(1.12); border: 1px solid rgba(0,0,0,0.25); }
.np-photo figcaption { font-size: 10px; font-style: italic; opacity: 0.75; padding-top: 2px; }
.np-lead { font-size: 13px; line-height: 1.4; margin: 0 0 8px; }
.np-lead::first-letter { font-size: 2.4em; float: left; line-height: 0.9; padding: 2px 4px 0 0; font-weight: 700; }
.np-cols { column-count: 2; column-gap: 14px; column-rule: 1px solid rgba(0,0,0,0.2); }
@media (max-width: 440px) { .np-cols { column-count: 1; } }
.np-story { margin: 0 0 7px; font-size: 12px; line-height: 1.35; break-inside: avoid; }
[data-fly] { cursor: pointer; }
[data-fly]:hover { text-decoration: underline; text-decoration-thickness: 1px; }
.np-brief { margin-top: 8px; border-top: 1px solid #1d1b17; padding-top: 5px; font-size: 11px; }
.np-brief ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
.np-brief li { display: flex; justify-content: space-between; gap: 6px; border-bottom: 1px dotted rgba(0,0,0,0.25); }
.shot.paper { cursor: pointer; }
#album header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 14px; }
#calls header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 14px; }
#calls-list { overflow-y: auto; scrollbar-width: thin; min-height: 0; flex: 1 1 auto; }
#calls-list h4 {
  margin: 9px 0 3px; font-size: 11px; letter-spacing: .03em; opacity: .62; font-weight: 700;
  display: flex; justify-content: space-between; gap: 8px; align-items: baseline;
}
#calls-list h4:first-child { margin-top: 0; }
#calls-list h4.stn { cursor: pointer; border-radius: 5px; padding: 2px 4px; margin-left: -4px; }
#calls-list h4.stn:hover { background: rgba(0,0,0,0.05); opacity: .85; }
#calls-list h4.none-stn { cursor: default; color: #b03a2e; opacity: .8; }
#calls-list h4 span { font-weight: 600; opacity: .7; }
#calls-list .call {
  display: flex; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 7px;
  border-left: 3px solid transparent;
}
#calls-list .call .what { flex: 1 1 auto; min-width: 0; cursor: pointer; border-radius: 5px; }
#calls-list .call .what:hover { background: rgba(0,0,0,0.05); }
#calls-list .call b { display: block; font-weight: 600; }
#calls-list .call small { display: block; opacity: .62; }
#calls-list .call.waiting { border-left-color: #d9483b; }
#calls-list .call.enroute { border-left-color: #2f6bff; }
#calls-list .call.onscene { border-left-color: #5aa96b; }
#calls-list .call .ride {
  flex: 0 0 auto; border: 0; background: rgba(0,0,0,0.06); border-radius: 6px;
  padding: 3px 7px; cursor: pointer; font-size: 12px; line-height: 1.4;
}
#calls-list .call .ride:hover { background: rgba(47,107,255,0.18); }
#calls-list .call .ride.off { opacity: .3; cursor: default; background: none; }
#calls-list .none { opacity: .55; padding: 6px 2px; }

/* R107: the aquarium switch, lit while the camera is running itself */
#hdr-aquarium.on { background: #2f6bff; color: #fff; }

/* R109: the pace select sits in the footer controls and has to look like the
   buttons beside it rather than like a form. */
#foot-controls #speed {
  border: none; border-radius: 8px; padding: 5px 8px;
  font: inherit; font-size: 12px; cursor: pointer;
  background: rgba(255,255,255,0.82); color: var(--ink);
}

/* R108: the cut fade. Above everything the camera shows and below the header,
   so the chrome stays readable while the world is black — and it never eats a
   click, because it is only ever there for a few hundred milliseconds. */
#cutfade {
  position: absolute; inset: 0; z-index: 24; background: #000;
  opacity: 0; pointer-events: none; transition: opacity 420ms ease;
}
#cutfade.on { opacity: 1; transition-duration: 260ms; }

/* R111: the generation screen. Dark, because a white flash before a city is
   the wrong first frame, and because a light wireframe on dark is the only way
   this reads. Above everything the scene draws, below the header. */
#gen {
  position: absolute; inset: 0; z-index: 23;
  background: radial-gradient(120% 90% at 50% 42%, #16202b 0%, #0b1016 70%, #070a0e 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
#gen[hidden] { display: none; }
/* R157: the preview is draggable, so it must say so and must not let a drag
   on it scroll the page instead. `aspect-ratio` replaces the old `height:auto`
   — the canvas buffer is now sized from the box in device pixels, so the box
   can no longer take its height from the buffer. */
/* R158: bigger, and 3:2 rather than 12:7 — a square map seen from the side is
   closer to 5:4 than to a letterbox, so the old shape wasted its width and
   ran out of height. Capped by the viewport height too, leaving room for the
   stage line and the bar underneath. */
#gen-canvas { display: block; width: min(980px, 94vw, calc((100vh - 150px) * 1.5)); aspect-ratio: 3 / 2;
  cursor: grab; touch-action: none; }
#gen-canvas:active { cursor: grabbing; }
#gen-text { display: flex; flex-direction: column; align-items: center; gap: 9px; width: min(420px, 78vw); }
#gen-stage { color: #cfe2f2; font-size: 13px; letter-spacing: .04em; text-shadow: 0 1px 12px rgba(0,0,0,0.6); }
#gen-bar { width: 100%; height: 3px; border-radius: 3px; background: rgba(190, 220, 245, 0.16); overflow: hidden; }
#gen-bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: #9fd0ff; transition: width 260ms ease; }

/* R113: the chrome belongs to a world, not to the making of one. Off the top
   and the bottom while the land is built, and slid back when it is there —
   which is also what makes the first sight of a city an arrival rather than a
   page that was always sitting behind a panel. */
#hdr, #foot { transition: transform 420ms cubic-bezier(.2,.7,.3,1), opacity 300ms ease; }
body.generating #hdr { transform: translateY(-110%); opacity: 0; pointer-events: none; }
body.generating #foot { transform: translateY(110%); opacity: 0; pointer-events: none; }
body.generating #toasts, body.generating #tooltip { opacity: 0; }
/* R501: the tips and the minimap sit above the loading screen, so they step aside with the header */
body.generating #tips, body.generating #minimap-wrap { visibility: hidden !important; pointer-events: none; }
/* A3/A5 (#63): the citizens panel scrolls as a whole; the per-district lists
   keep their own inner scroll so one crowded district cannot bury the rest. */
#citizens { max-height: calc(100vh - var(--hdr-h) - var(--foot-h) - 24px); }
#citizens-list { overflow-y: auto; scrollbar-width: thin; min-height: 0; flex: 1 1 auto; }
#citizens header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 14px; }
#citizens-find {
  border: none; border-radius: 8px; padding: 6px 9px; font: inherit; font-size: 12.5px;
  color: var(--ink); background: #f1f5f2; outline: none;
}
#citizens-find:focus { background: #e9f1ec; }
#citizens details, #directory details { border-bottom: 1px solid rgba(0,0,0,0.06); padding-bottom: 4px; }
#citizens summary, #directory summary { cursor: pointer; font-weight: 700; padding: 4px 0; list-style: none; display: flex; justify-content: space-between; gap: 8px; }
#citizens summary::-webkit-details-marker, #directory summary::-webkit-details-marker { display: none; }
#citizens summary .n, #directory summary .n { font-weight: 600; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
#citizens ul, #directory ul { list-style: none; margin: 2px 0 6px; padding: 0; max-height: 240px; overflow-y: auto; scrollbar-width: thin; }
#citizens li, #directory li { display: flex; justify-content: space-between; gap: 6px; padding: 2px 0; border-bottom: 1px solid rgba(0,0,0,0.04); }
#citizens li a, #directory li a { color: #4a7a5e; cursor: pointer; text-decoration: none; }
#citizens li small, #directory li small { color: var(--ink-faint); text-align: right; }
#citizens .more, #directory .more { color: var(--ink-faint); font-size: 11px; padding: 3px 0; }

/* PERF-1 — what each system costs per cycle, dearest first. */
#perf-panel {
  position: absolute; top: calc(var(--hdr-h) + 8px); right: 16px; width: 330px; z-index: 9;
  max-height: calc(100vh - var(--hdr-h) - var(--foot-h) - 24px); overflow-y: auto; scrollbar-width: thin;
  padding: 12px 14px 14px; background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  border-radius: var(--radius); box-shadow: var(--shadow); font-size: 12.5px; color: var(--ink);
  display: flex; flex-direction: column; gap: 8px;
}
#perf-panel.collapsed { display: none; }
#perf-panel header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 14px; }
#perf-frame { font-size: 11.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
/* PERF-3: the rows scroll, the header and the buttons do not — the record
   button must not sit twenty-six rows below the fold on a short screen. */
#perf-rows { display: flex; flex-direction: column; gap: 3px; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.prow { display: grid; grid-template-columns: 1fr 54px 46px; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-soft); }
.prow .pl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .pbar { grid-column: 1 / -1; height: 4px; background: #eef2ef; border-radius: 2px; overflow: hidden; }
.prow .pbar i { display: block; height: 100%; background: linear-gradient(90deg, #a9c4b4, #e0442a); border-radius: 2px; }
.prow .pv { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }
.prow .pm { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-faint); }
.prow.hot .pv { color: #b3452f; }
#perf-panel .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
#perf-panel button { border: none; border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 11.5px; font-weight: 600; background: #e4efe9; color: var(--ink); cursor: pointer; }

/* ---- PERF-3: the five-second recording and its report -------------------- */
/* A7 (#63): the stress breakdown — one row per factor, bar length by weight,
   colour by whether it fills the meter or drains it. */
.stressbars { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 4px; }
.stressbars .sf { display: grid; grid-template-columns: 1fr 64px 40px; align-items: center; gap: 6px; font-size: 11px; }
.stressbars .sl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
.stressbars .sb { height: 5px; background: #eef2ef; border-radius: 3px; overflow: hidden; }
.stressbars .sb i { display: block; height: 100%; border-radius: 3px; }
.stressbars .sv { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.stressbars .bad .sb i { background: #d98b7a; }
.stressbars .bad .sv { color: #b3452f; }
.stressbars .good .sb i { background: #8fbf9a; }
.stressbars .good .sv { color: #3f7a58; }
html[data-theme="night"] .stressbars .sb { background: #20262c; }
/* R608 — stress and happiness on one scale: split at zero, stress to the left in red, happiness to the right in green */
.balance { display: grid; grid-template-columns: auto 1fr auto 40px; align-items: center; gap: 7px; margin: 2px 0 10px; font-size: 10.5px; font-weight: 700; }
.balance .bl-end.neg { color: #b3452f; }
.balance .bl-end.pos { color: #2f7a4e; }
.balance .bl-track { position: relative; height: 12px; border-radius: 999px; overflow: hidden;
  background: linear-gradient(90deg, rgba(216,70,58,0.16), rgba(40,60,50,0.06) 50%, rgba(34,179,88,0.16)); box-shadow: inset 0 1px 2px rgba(0,0,0,0.08); }
.balance .bl-track i { position: absolute; top: 0; bottom: 0; transition: width .5s ease; }
.balance .bl-track i.neg { background: linear-gradient(270deg, #f2a28e, #d8463a); }
.balance .bl-track i.pos { background: linear-gradient(90deg, #86d9a0, #22b358); }
.balance .bl-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(40,52,46,0.6); }
.balance .bl-val { text-align: right; font-size: 11.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.balance .bl-val.neg { color: #b3452f; }
.balance .bl-val.pos { color: #2f7a4e; }
.stressbars .sb.split { position: relative; background: linear-gradient(90deg, #f4e3df 50%, #e2f1e6 50%); }
.stressbars .sb.split i { position: absolute; top: 0; bottom: 0; border-radius: 0; }
.stressbars .sb.split i.neg { background: #d98b7a; }
.stressbars .sb.split i.pos { background: #8fbf9a; }
.stressbars .sb.split::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: rgba(40,52,46,0.5); }
html[data-theme="night"] .stressbars .sb.split { background: linear-gradient(90deg, #3a2724 50%, #22342a 50%); }

.hidden { display: none !important; }

/* A2 (#63): panel headers are drag handles. The cursor says so, and text
   selection is off so a drag does not paint the title blue. */
.drag-grip { cursor: move; user-select: none; -webkit-user-select: none; touch-action: none; }
.drag-grip button, .drag-grip input, .drag-grip select { cursor: pointer; }
.dragging { opacity: 0.92; box-shadow: 0 18px 44px rgba(30,45,38,0.34) !important; }
#perf-record.armed { background: #e0442a; color: #fff; }
#perf-record[disabled] { opacity: 0.65; cursor: default; }
#perf-record-status { font-size: 11px; font-weight: 600; color: #b3452f; font-variant-numeric: tabular-nums; }
#perf-report {
  position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: rgba(28, 38, 33, 0.44); backdrop-filter: blur(3px); padding: 24px;
}
#perf-report .pr-box {
  display: flex; flex-direction: column; gap: 8px; width: min(860px, 100%); max-height: 100%;
  background: rgba(255,255,255,0.97); border-radius: 16px; box-shadow: 0 18px 50px rgba(30,45,38,0.32);
  padding: 14px 16px 16px; color: var(--ink); font-size: 12.5px;
}
#perf-report header { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; }
#perf-report-meta { font-size: 11px; font-weight: 600; color: var(--ink-faint); font-variant-numeric: tabular-nums; margin-right: auto; }
#perf-report-close { margin-left: auto; }
#perf-report .pr-hint { margin: 0; font-size: 11.5px; color: var(--ink-faint); }
#perf-report textarea {
  flex: 1; min-height: 42vh; resize: vertical; border: 1px solid #dde5e0; border-radius: 10px; padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; line-height: 1.45;
  background: #f7faf8; color: #2f3a35; white-space: pre; overflow: auto;
}
#perf-report .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
#perf-report button { border: none; border-radius: 8px; padding: 6px 11px; font: inherit; font-size: 12px; font-weight: 600; background: #e4efe9; color: var(--ink); cursor: pointer; }
#perf-report button:hover { background: #d6e8dd; }
body.photo #perf-report { display: none !important; }
html[data-theme="night"] #perf-report .pr-box { background: rgba(24, 29, 35, 0.97); color: #e8edf1; }
html[data-theme="night"] #perf-report textarea { background: #151a1f; border-color: #2b333a; color: #dbe3ea; }
html[data-theme="night"] #perf-report button { background: #2a323a; color: #e8edf1; }

/* the panels that share the left column stack in front of the stats panel */
#feed-panel, #citizens, #directory { z-index: 10; }

/* photo mode hides the new chrome too */
body.photo #feed-panel, body.photo #citizens, body.photo #directory, body.photo #perf-panel, body.photo #minimap-wrap { display: none !important; }

/* --- night theme for the round-53 panels -------------------------------- */
html[data-theme="night"] #feed-panel,
html[data-theme="night"] #citizens,
html[data-theme="night"] #directory,
html[data-theme="night"] #perf-panel { background: rgba(24, 29, 35, 0.94); color: #e8edf1; }
html[data-theme="night"] #citizens-find { background: #20262c; color: #e8edf1; }
html[data-theme="night"] #foot-controls button { background: #20262c; color: #b7c2cb; }
html[data-theme="night"] #foot-controls button:hover { background: #2a323a; }
/* R214 — the rest of the night: the album and the calls panels, the footer's
   view pills and camera menu, and the pace select kept their day colours */
html[data-theme="night"] #calls, html[data-theme="night"] #album, html[data-theme="night"] #papers { background: rgba(24, 29, 35, 0.94); color: #e8edf1; }
html[data-theme="night"] #album > header { background: rgba(20,26,31,0.94); border-bottom-color: rgba(255,255,255,0.12); }
html[data-theme="night"] #calls header, html[data-theme="night"] #album header { color: #e8edf1; }
html[data-theme="night"] #calls-list h4.stn:hover, html[data-theme="night"] #calls-list .call .what:hover { background: rgba(255,255,255,0.07); }
html[data-theme="night"] #calls-list .call .ride { background: rgba(255,255,255,0.1); color: #e8edf1; }
html[data-theme="night"] #calls-list .call .ride:hover { background: rgba(47,107,255,0.35); }
html[data-theme="night"] #calls-list h4.none-stn { color: #e07a6e; }
html[data-theme="night"] #footbar button { color: #b7c2cb; background: #20262c; border-color: #39424c; box-shadow: none; }
html[data-theme="night"] #footbar button.on { background: #2a323a; border-color: #6f9c85; color: #e8edf1; }
html[data-theme="night"] #footbar .navsect + .navsect { border-left-color: rgba(255,255,255,0.1); }
html[data-theme="night"] #cam-menu button { background: #20262c; color: #b7c2cb; border-color: #39424c; }
html[data-theme="night"] #foot-controls #speed { background: #20262c; color: #b7c2cb; }
html[data-theme="night"] #foot-controls #speed option { background: #1a2026; color: #e8edf1; }
html[data-theme="night"] .prow .pbar { background: #20262c; }
html[data-theme="night"] #minimap-wrap { box-shadow: 0 6px 24px rgba(0,0,0,0.5), 0 0 0 3px rgba(40,48,56,0.9) inset; }

/* R25: the zone toggles carry their zone's colour — green homes, blue
   commerce, orange industry — so the panel and the map agree. */
#visuals label.z::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
#visuals label.z.res::before { background: #5e8f66; }
#visuals label.z.com::before { background: #4e6f9d; }
#visuals label.z.ind::before { background: #b87a3d; }
#visuals label.z.hood::before { background: #8e73b8; }

/* R26: all / none at the head of every group of switches */
#visuals .gt, #visuals summary { display: flex; align-items: center; gap: 8px; }
#visuals .allnone { margin-left: auto; display: inline-flex; gap: 4px; }
#visuals .allnone button { font: inherit; font-size: 10px; line-height: 1; padding: 2px 6px; border: none; border-radius: 6px; background: #e3e9e5; color: #4f5a54; cursor: pointer; text-transform: none; letter-spacing: 0; }
#visuals .allnone button:hover { background: #d3dcd6; }
html[data-theme="night"] #visuals .allnone button { background: #2b333a; color: #cfe0d6; }

/* R141 (backlog 54) — the street-level walk's own hint bar */
#walk-bar { position: fixed; left: 12px; bottom: 12px; z-index: 40; display: flex; gap: 10px; align-items: center;
  padding: 6px 10px; border-radius: 6px; font-size: 11px; pointer-events: none;
  background: rgba(20, 22, 26, 0.62); color: #f2efe8; backdrop-filter: blur(3px); }
#walk-bar.hidden { display: none; }
#walk-bar b { font-weight: 600; letter-spacing: 0.02em; }
#walk-bar kbd { display: inline-block; padding: 1px 4px; margin: 0 1px; border-radius: 3px;
  background: rgba(255, 255, 255, 0.16); font-family: inherit; font-size: 10px; }

/* R142 (backlog 28) — the grievance feed: what is wrong, and for how many */
#grievances { display: flex; flex-direction: column; gap: 3px; }
.grv { display: grid; grid-template-columns: 1fr 78px 34px; align-items: center; gap: 6px; font-size: 11px; }
.grv i { display: block; height: 6px; border-radius: 3px; background: #c4694f; }
.grv b { text-align: right; font-weight: 500; opacity: 0.7; }
#grievances .hint { margin: 4px 0 0; font-size: 10px; opacity: 0.5; }

/* R146 (backlog 52) — the time-lapse scrub */
#timelapse.hidden { display: none; }
#timelapse { margin: 6px 0 8px; }
#timelapse input[type=range] { width: 100%; }
#timelapse .hint { margin: 2px 0 0; font-size: 10px; opacity: 0.6; }

/* R147 — the standing alerts: what is wrong with the town right now. Built as
   a list because the disasters go in it next. */
#alerts { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; flex-direction: column; gap: 5px; width: min(520px, calc(100vw - 24px)); pointer-events: none; }
.alert { pointer-events: auto; display: flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 7px 9px; border-radius: 7px; color: #fbf3ee; background: rgba(150, 52, 40, 0.93);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.28); animation: alert-in 0.35s ease-out; }
.alert.grave { background: rgba(126, 30, 24, 0.96); animation: alert-in 0.35s ease-out, alert-pulse 2.6s ease-in-out 0.4s infinite; }
.alert .i { font-size: 17px; line-height: 1; }
.alert .b { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.alert b { font-size: 12px; }
.alert small { font-size: 11px; opacity: 0.86; }
.alert .x { pointer-events: auto; border: 0; background: transparent; color: inherit; opacity: 0.6;
  cursor: pointer; font-size: 12px; padding: 2px 4px; border-radius: 4px; }
.alert .x:hover { opacity: 1; background: rgba(255, 255, 255, 0.14); }
@keyframes alert-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes alert-pulse { 0%, 100% { box-shadow: 0 3px 14px rgba(0, 0, 0, 0.28); }
  50% { box-shadow: 0 3px 22px rgba(210, 70, 55, 0.75); } }
body.photo #alerts { display: none; }

/* R147 — the album */
#album-list { display: flex; flex-direction: column; gap: 9px; max-height: 62vh; overflow-y: auto; }
#album-list .none { font-size: 11px; opacity: 0.55; }
.shot { margin: 0; }
.shot img { display: block; width: 100%; border-radius: 4px; }
.shot figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding-top: 3px; }
.shot figcaption b { font-size: 11px; }
.shot figcaption small { font-size: 10px; opacity: 0.62; text-align: right; }

/* R149/R472 — the front door is styled in splash.css, linked from index.html. */

/* R149 — the town's own name, in the header */
#hdr-town { font-weight: 700; color: #2f4a37; }
#hdr-town:empty { display: none; }

/* R237 — the watching screen: the news rises up the left as glass bubbles */
#chat { position: fixed; left: 18px; bottom: 72px; width: min(360px, 42vw); z-index: 20; pointer-events: none;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; }
#chat .bubble { display: flex; gap: 8px; align-items: flex-start; padding: 8px 13px 9px 10px; border-radius: 16px 16px 16px 5px;
  background: rgba(255, 255, 255, 0.13); border: 1px solid rgba(255, 255, 255, 0.26);
  backdrop-filter: blur(9px) saturate(1.15); -webkit-backdrop-filter: blur(9px) saturate(1.15);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14); color: #fff; font-size: 13.5px; line-height: 1.35;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); animation: chat-in 0.7s ease-out both;
  transition: opacity 1.3s ease, transform 1.3s ease, max-height 1.3s ease; max-height: 120px; }
#chat .bubble i { font-style: normal; flex: 0 0 auto; }
#chat .bubble.fire { background: linear-gradient(135deg, rgba(235, 80, 60, 0.3), rgba(235, 80, 60, 0.14)); border-color: rgba(255, 150, 130, 0.42); }
#chat .bubble.medical { background: linear-gradient(135deg, rgba(70, 130, 240, 0.3), rgba(70, 130, 240, 0.14)); border-color: rgba(150, 185, 255, 0.42); }
#chat .bubble.crime { background: linear-gradient(135deg, rgba(235, 70, 70, 0.28) 0%, rgba(235, 70, 70, 0.16) 46%, rgba(70, 120, 240, 0.16) 54%, rgba(70, 120, 240, 0.28) 100%); border-color: rgba(200, 170, 255, 0.4); }
#chat .bubble.gone { opacity: 0; transform: translateY(-14px); max-height: 0; padding-top: 0; padding-bottom: 0; margin-top: -8px; }
@keyframes chat-in { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) { #chat { width: calc(100vw - 36px); } }
/* …and a new issue of the paper, laid on the screen for half a minute */
#paper-show { position: fixed; right: 28px; top: 50%; width: min(430px, 44vw); max-height: 82vh; overflow: hidden; z-index: 21;
  transform: translate(calc(100% + 60px), -50%) rotate(2deg); transition: transform 1.4s cubic-bezier(0.22, 0.8, 0.26, 1), opacity 1.4s ease; opacity: 0;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35); border-radius: 3px; pointer-events: none; }
#paper-show.on { transform: translate(0, -50%) rotate(-1.5deg); opacity: 1; }
#paper-show .np { max-height: 82vh; overflow: hidden; }
@media (max-width: 600px) { #paper-show { width: calc(100vw - 36px); right: 18px; } }

/* R244 — a balloon, clicked */
#balloon-card, #ride-card { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 22; display: flex; gap: 8px; align-items: center;
  padding: 9px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px); box-shadow: var(--shadow); font-size: 13px; color: var(--ink); }
#balloon-card button, #ride-card button { font: inherit; padding: 5px 11px; border-radius: 9px; border: 1px solid rgba(0, 0, 0, 0.14); background: #fff; cursor: pointer; }
#balloon-card button:hover, #ride-card button:hover { background: #f3efe6; }
#balloon-card .bc-x, #ride-card .bc-x { padding: 2px 8px; border: 0; background: none; font-size: 16px; opacity: 0.6; }
html[data-theme="night"] #balloon-card, html[data-theme="night"] #ride-card { background: rgba(24, 29, 35, 0.94); color: #e8edf1; }
html[data-theme="night"] #balloon-card button, html[data-theme="night"] #ride-card button { background: #27303a; color: #e8edf1; border-color: rgba(255, 255, 255, 0.14); }

/* R246 — things that start hidden and are laid out as a flex box keep hidden */
#chat[hidden], #balloon-card[hidden], #ride-card[hidden] { display: none !important; }

/* R246 — a phone: the header's buttons are a group in the panel burger, and
   the footer's view, camera and world buttons open upward from a burger of
   their own (main.js phoneLayout moves them; these are how they look there) */
#footburger {
  display: none; flex: none; width: 32px; height: 28px; border: none; border-radius: 9px; pointer-events: auto;
  background: rgba(0,0,0,0.06); cursor: pointer; padding: 7px 8px;
  flex-direction: column; justify-content: space-between; align-items: stretch;
}
#footburger span { display: block; height: 2px; border-radius: 1px; background: #4d5852; }
body.narrow #footburger:not([hidden]) { display: flex; }
html[data-theme="night"] #footburger { background: rgba(255,255,255,0.10); }
html[data-theme="night"] #footburger span { background: #cfe0d6; }
#topbar.burger #nav-actions button { width: 100%; height: auto; border-radius: 9px; justify-content: flex-start; gap: 8px; padding: 7px 10px; box-shadow: none; border: none; background: transparent; font-size: 15px; }
#topbar.burger #nav-actions button::after { content: attr(data-label); font-size: 13px; font-weight: 600; color: var(--ink); }
#topbar.burger #nav-actions button[hidden] { display: none; }
body.narrow #footbar {
  position: fixed; bottom: calc(var(--foot-h) + 6px); right: 8px; left: auto; z-index: 40;
  display: flex; flex-direction: column; align-items: stretch; width: max-content; min-width: 210px;
  max-height: calc(100vh - var(--hdr-h) - var(--foot-h) - 24px); overflow-y: auto; gap: 2px; padding: 8px;
  background: rgba(255,255,255,0.97); backdrop-filter: blur(10px); border-radius: 14px;
  box-shadow: 0 14px 40px rgba(40,60,50,0.25); pointer-events: auto; white-space: nowrap;
}
body.narrow #footbar[hidden] { display: none !important; }
body.narrow #footbar .navsect { display: flex !important; flex-direction: column; align-items: stretch; gap: 2px; margin: 0; padding: 0; border: none; }
body.narrow #footbar .navsect + .navsect { margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(80,110,90,0.16); }
body.narrow #footbar button { display: flex; justify-content: flex-start; align-items: center; gap: 8px; padding: 7px 10px; width: 100%; }
body.narrow #footbar button b { display: inline !important; }
body.narrow #footbar #foot-rates { font-variant-numeric: tabular-nums; }
body.narrow #foot-ev, body.narrow #foot-brand { display: none; }
html[data-theme="night"] body.narrow #footbar { background: rgba(20,26,31,0.97); }
body.narrow #hdr-brand { display: none; }
body.narrow #hdr-town { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.narrow #hdr-chip { max-width: 44vw; }
body.narrow #hdr { gap: 6px; padding: 0 8px; }
#topbar.burger #nav-stats { flex-direction: row !important; flex-wrap: wrap; gap: 6px 12px; padding: 4px 6px 6px; }
#topbar.burger #nav-stats #hdr-stats { display: flex; flex-wrap: wrap; gap: 6px 12px; box-shadow: none; }

/* R249 — a phone, tidied: both burgers at the right-hand edge and alike, the
   footer as tall as its buttons, and the bars' heights in the variables the
   panels are placed by */
body.narrow { --hdr-h: 40px; --foot-h: 44px; }
body.narrow #hdr { height: var(--hdr-h); }
body.narrow #navburger { order: 99; margin: 0 0 0 auto; }
body.narrow #topbar.burger { left: auto; right: 8px; }
body.narrow #hdr-chip { gap: 6px; padding: 3px 9px; font-size: 11.5px; }
body.narrow #foot { height: var(--foot-h); padding: 0 8px; gap: 8px; font-size: 12px; }
body.narrow #foot-controls { flex: 1 1 auto; align-items: center; gap: 8px; }
body.narrow #foot-controls button, body.narrow #foot-controls select { height: 30px; }
#foot-controls #footburger {
  width: 32px; height: 28px; padding: 7px 8px; border: none; border-radius: 9px; margin: 0 0 0 auto;
  background: rgba(0,0,0,0.06); flex-direction: column; justify-content: space-between; align-items: stretch;
  min-width: 0; font-size: 0;
}
#foot-controls #footburger:hover { background: rgba(0,0,0,0.12); transform: none; }
#foot-controls #footburger span { display: block; height: 2px; border-radius: 1px; background: #4d5852; }
html[data-theme="night"] #foot-controls #footburger { background: rgba(255,255,255,0.10); }
html[data-theme="night"] #foot-controls #footburger span { background: #cfe0d6; }

/* R250 — on a phone the camera's menu is a panel in the footer menu's place */
body.narrow #cam-menu { left: auto !important; right: 8px; bottom: calc(var(--foot-h) + 6px) !important; z-index: 41;
  min-width: 210px; padding: 8px; gap: 4px; background: rgba(255,255,255,0.97); box-shadow: 0 14px 40px rgba(40,60,50,0.25); }
body.narrow #cam-menu button { font-size: 12px; padding: 9px 12px; letter-spacing: .3px; }
html[data-theme="night"] body.narrow #cam-menu { background: rgba(20,26,31,0.97); }

/* R251 — the trivia bar: a glass pill centred at the foot of the watching
   screen, clear of the chat on the left and the credit on the right */
#trivia { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 22; pointer-events: none;
  display: flex; gap: 9px; align-items: center; width: max-content; max-width: min(620px, calc(100vw - 800px));
  padding: 8px 18px 9px 13px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.13); border: 1px solid rgba(255, 255, 255, 0.26);
  backdrop-filter: blur(9px) saturate(1.15); -webkit-backdrop-filter: blur(9px) saturate(1.15);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14); color: #fff; font-size: 13.5px; line-height: 1.35;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); animation: trivia-in 0.7s ease-out both; }
@keyframes trivia-in { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
#trivia[hidden] { display: none !important; }
#trivia i { font-style: normal; flex: 0 0 auto; }
#trivia span { transition: opacity 0.7s ease; }
#trivia.swap span { opacity: 0; }
body.photo #trivia { display: none !important; }
/* Z shows the stream's overlay, whose title takes the header's place */
body.zen #hdr { visibility: hidden !important; }
@media (max-width: 1200px) {
  #trivia { bottom: 58px; max-width: calc(100vw - 36px); border-radius: 18px; }
  body:has(#trivia:not([hidden])) #chat { bottom: 118px; }
}

/* R252 — the licence in Settings → About */
.about .ab-lic { margin: 8px 0 8px; font-size: 12px; line-height: 1.5; color: #2f3a35; }
.about .ab-lic a { white-space: nowrap; }
.about .ab-lic-full { margin: 0 0 14px; }
.about .ab-lic-full summary { cursor: pointer; font-size: 12px; color: #5a8f52; }
.about .ab-lic-full pre { max-height: 260px; overflow: auto; margin: 8px 0 0; padding: 10px 12px; border-radius: 10px;
  background: rgba(47, 74, 55, 0.05); white-space: pre-wrap; overflow-wrap: anywhere; font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
html[data-theme="night"] .about .ab-lic { color: inherit; }
html[data-theme="night"] .about .ab-lic-full pre { background: rgba(255, 255, 255, 0.05); }

/* R269 — GLASS, EVERYWHERE. The watching screen's glass (the chat's bubbles,
   the trivia pill) for the whole interface: the header and the footer, every
   panel and its header, the toasts, the tooltip and the menus are a pane of
   frosted glass over the town — see-through, blurred, a light edge and a soft
   shadow — rather than near-opaque white. One set of tokens, redefined for
   the night theme; each night rule follows its day rule so it wins. */
:root {
  --glass: rgba(255, 255, 255, 0.6);
  --glass-head: rgba(255, 255, 255, 0.42);
  --glass-btn: rgba(255, 255, 255, 0.62);
  --glass-edge: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 8px 28px rgba(30, 45, 38, 0.16);
  --glass-blur: blur(16px) saturate(1.35);
}
html[data-theme="night"] {
  --glass: rgba(20, 26, 32, 0.56);
  --glass-head: rgba(20, 26, 32, 0.4);
  --glass-btn: rgba(42, 50, 58, 0.62);
  --glass-edge: rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
#hdr, #foot, #legend, #charts, #feed-panel, #calls, #household, #citizens, #directory, #album, #papers, #perf-panel, #map, #visuals, #info, #tips,
.toast, #tooltip, #cam-menu, #media-menu, #topbar.burger, body.narrow #footbar, #balloon-card, #ride-card {
  background: var(--glass) !important;
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-color: var(--glass-edge);
}
#legend, #charts, #feed-panel, #calls, #household, #citizens, #directory, #album, #papers, #perf-panel, #map, #visuals, #info, #tips,
.toast, #tooltip, #cam-menu, #media-menu, #topbar.burger, body.narrow #footbar, #balloon-card, #ride-card {
  border: 1px solid var(--glass-edge); box-shadow: var(--glass-shadow);
}
#hdr { border-bottom: 1px solid var(--glass-edge); box-shadow: 0 4px 18px rgba(30, 45, 38, 0.08); }
#foot { border-top: 1px solid var(--glass-edge); }
#legend > header, #charts > header, #feed-panel > header, #calls > header, #household > header, #album > header, #papers > header, #citizens > header, #directory > header,
#perf-panel > header, #map > header, #visuals > header, #info > header, #tips > header {
  background: var(--glass-head) !important;
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-bottom-color: var(--glass-edge) !important;
}
html[data-theme="night"] #legend > header, html[data-theme="night"] #charts > header, html[data-theme="night"] #feed-panel > header,
html[data-theme="night"] #calls > header,html[data-theme="night"] #household > header, html[data-theme="night"] #album > header, html[data-theme="night"] #papers > header,
html[data-theme="night"] #citizens > header, html[data-theme="night"] #directory > header, html[data-theme="night"] #perf-panel > header, html[data-theme="night"] #map > header,
html[data-theme="night"] #visuals > header, html[data-theme="night"] #info > header, html[data-theme="night"] #tips > header {
  background: var(--glass-head) !important;
}
#hdr-actions button, #topbar button, #footbar button, #foot-controls button, #cam-menu button, #media-menu button {
  background: var(--glass-btn); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#hdr-actions button.on { background: var(--accent); }
#topbar button.on, #footbar button.on { background: rgba(255, 255, 255, 0.92); }
html[data-theme="night"] #hdr-actions button, html[data-theme="night"] #topbar button, html[data-theme="night"] #footbar button,
html[data-theme="night"] #foot-controls button, html[data-theme="night"] #cam-menu button, html[data-theme="night"] #media-menu button { background: var(--glass-btn); }
html[data-theme="night"] #hdr-actions button.on { background: #4a9b70; }
html[data-theme="night"] #hdr, html[data-theme="night"] #foot { background: var(--glass) !important; }
/* …and the cards inside a panel are a lighter pane on the pane */
:root { --glass-card: rgba(255, 255, 255, 0.4); }
html[data-theme="night"] { --glass-card: rgba(255, 255, 255, 0.05); }
#visuals .group, #visuals details.group { background: var(--glass-card) !important; border: 1px solid var(--glass-edge); }

/* R272 — THE REST OF THE GLASS. What R269 left solid: the header's two
   inset wells (the town's numbers, the clock and the weather), every text
   field and select in a panel and the footer's pace, the small buttons in a
   panel (all/none, close, clear, the pagers), and the region names over the
   map — those as plain translucency, no blur: there are dozens of them. */
:root { --glass-well: rgba(255, 255, 255, 0.36); --glass-field: rgba(255, 255, 255, 0.55); --glass-label: rgba(255, 255, 255, 0.6); }
html[data-theme="night"] { --glass-well: rgba(255, 255, 255, 0.06); --glass-field: rgba(255, 255, 255, 0.08); --glass-label: rgba(20, 26, 32, 0.55); }
#hdr .hdr-well, #hdr #hdr-chip, #hdr #hdr-stats {
  background: var(--glass-well) !important; border-color: var(--glass-edge) !important;
  box-shadow: inset 0 1px 3px rgba(40, 60, 50, 0.14) !important;
}
#hdr select, #foot select, #footbar select,
#legend select, #charts select, #feed-panel select, #calls select, #household select, #citizens select, #directory select, #album select, #papers select, #perf-panel select, #map select, #visuals select, #info select, #tips select, #overlays select,
#legend input:not([type=range]):not([type=checkbox]):not([type=radio]), #charts input:not([type=range]):not([type=checkbox]):not([type=radio]),
#feed-panel input:not([type=range]):not([type=checkbox]):not([type=radio]), #calls input:not([type=range]):not([type=checkbox]):not([type=radio]), #household input:not([type=range]):not([type=checkbox]):not([type=radio]),
#citizens input:not([type=range]):not([type=checkbox]):not([type=radio]), #directory input:not([type=range]):not([type=checkbox]):not([type=radio]), #album input:not([type=range]):not([type=checkbox]):not([type=radio]),
#papers input:not([type=range]):not([type=checkbox]):not([type=radio]), #visuals input:not([type=range]):not([type=checkbox]):not([type=radio]),
#info input:not([type=range]):not([type=checkbox]):not([type=radio]), #tips input:not([type=range]):not([type=checkbox]):not([type=radio]) {
  background-color: var(--glass-field) !important; border: 1px solid var(--glass-edge) !important;
}
#legend button, #charts button, #feed-panel button, #calls button, #household button, #citizens button, #directory button, #album button, #papers button, #perf-panel button,
#map button, #visuals button, #info button, #tips button, .pager button {
  background-color: var(--glass-btn) !important; border-color: var(--glass-edge);
}
#legend button:hover, #charts button:hover, #feed-panel button:hover, #calls button:hover, #household button:hover, #citizens button:hover, #directory button:hover, #album button:hover,
#papers button:hover, #perf-panel button:hover, #map button:hover, #visuals button:hover, #info button:hover, #tips button:hover, .pager button:hover {
  background-color: rgba(255, 255, 255, 0.85) !important;
}
html[data-theme="night"] #legend button:hover, html[data-theme="night"] #visuals button:hover, html[data-theme="night"] #info button:hover,
html[data-theme="night"] #citizens button:hover, html[data-theme="night"] #directory button:hover, html[data-theme="night"] #feed-panel button:hover, html[data-theme="night"] .pager button:hover { background-color: rgba(255, 255, 255, 0.14) !important; }
#visuals .set-tabs button[aria-selected="true"], #visuals button.on { background-color: rgba(255, 255, 255, 0.9) !important; }
#district-labels .label, .district-labels .label { background: var(--glass-label) !important; border-color: var(--glass-edge) !important; }

/* R275 — the chat and the trivia bar in the ordinary view: above the footer,
   and above the cinematic caption when it shows (its height, measured, in
   --cine-h). With the chat on, the toasts give way to it — the same news. */
body:not(.zen) #chat { bottom: calc(var(--foot-h) + 14px + var(--cine-h, 0px)); z-index: 19; }
body:not(.zen) #trivia { bottom: calc(var(--foot-h) + 12px); }   /* R284: level with the cinematic caption, not over it */
/* R284: the chat's bubbles with a place are buttons; the rest let the town be clicked through them */
#chat .bubble.loc { pointer-events: auto; cursor: pointer; transition: opacity 1.3s ease, transform 1.3s ease, max-height 1.3s ease, background-color 0.2s ease; }
#chat .bubble.loc:hover { background-color: rgba(255, 255, 255, 0.24); }
#chat .bubble.gone { pointer-events: none; }
#trivia { pointer-events: auto; cursor: pointer; }
/* R319: readable panels stay above the event bubbles. The header and camera
   cut still sit above both layers. */
#hud, #legend, #charts, #feed-panel, #calls, #household, #citizens, #directory, #album, #papers,
#perf-panel, #map, #visuals, #info, #tips, #minimap-wrap { z-index: 23; }
/* the toasts the chat leaves (the paper, the hints) stand under the header, clear of the chat */
body.chat-on:not(.zen) #toasts { bottom: auto; top: calc(var(--hdr-h) + 10px); }
@media (min-width: 1201px) {
  /* beside the caption, level with it, when there is room */
  body.cine-on:not(.zen) #trivia { left: calc(var(--cine-r, 0px) + 16px); transform: none; animation: none;
    max-width: min(620px, calc(100vw - var(--cine-r, 0px) - 16px - 200px)); }
}
@media (max-width: 1200px) {
  body:not(.zen) #trivia { bottom: calc(var(--foot-h) + 10px + var(--cine-h, 0px)); }
  body:not(.zen):has(#trivia:not([hidden])) #chat { bottom: calc(var(--foot-h) + 78px + var(--cine-h, 0px)); }
}

/* R278 — the settings as a grid, each box folding from its title to just the
   title. R283: a classic grid — every box as tall as the tallest in its row,
   everything in it showing; the fixed height made every box scroll */
#visuals > .group, #visuals > details.group { box-sizing: border-box; height: auto; overflow: visible; align-self: stretch; }
#visuals > .group.shut, #visuals > details.group:not([open]) { height: auto; overflow: hidden; align-self: start; }
#visuals > .group.shut > :not(.gt) { display: none !important; }
#visuals > .group > .gt.fold, #visuals > details.group > summary { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; list-style: none; }
#visuals > details.group > summary::-webkit-details-marker { display: none; }
#visuals > .group > .gt.fold::before, #visuals > details.group > summary::before {
  content: '▾'; flex: none; font-size: 10px; line-height: 1; opacity: 0.55; transition: transform 0.15s ease;
}
#visuals > .group.shut > .gt.fold::before, #visuals > details.group:not([open]) > summary::before { transform: rotate(-90deg); }
#visuals > .group > .gt.fold:focus-visible, #visuals > details.group > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
#visuals > .group > .gt .allnone, #visuals > details.group > summary .allnone { margin-left: auto; }

/* R280 — an album photograph, full screen */
#album-list .shot img { cursor: zoom-in; }
#lightbox { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 56px 16px 24px; background: rgba(8, 12, 16, 0.82); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#lightbox[hidden] { display: none !important; }
#lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; max-width: 100%; }
#lightbox img { display: block; max-width: min(92vw, 1600px); max-height: calc(100vh - 150px); width: auto; height: auto;
  border-radius: 10px; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5); background: #1a2026; }
#lightbox figcaption { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; max-width: min(92vw, 900px);
  padding: 8px 16px; border-radius: 999px; color: #fff; font-size: 13px; text-align: center; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  background: rgba(255, 255, 255, 0.13); border: 1px solid rgba(255, 255, 255, 0.26); backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px); }
#lightbox figcaption small { opacity: 0.85; }
#lightbox .lb-read { border: 1px solid rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.18); color: #fff; border-radius: 999px; padding: 4px 12px; font: inherit; font-weight: 600; cursor: pointer; }
#lightbox .lb-x, #lightbox .lb-prev, #lightbox .lb-next {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.35); cursor: pointer;
  background: rgba(255, 255, 255, 0.16); color: #fff; font-size: 26px; line-height: 1; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px); }
#lightbox .lb-x { position: absolute; top: 14px; right: 16px; }
#lightbox .lb-x:hover, #lightbox .lb-prev:hover, #lightbox .lb-next:hover, #lightbox .lb-read:hover { background: rgba(255, 255, 255, 0.3); }
#lightbox .lb-prev[hidden], #lightbox .lb-next[hidden] { display: none; }
@media (max-width: 600px) { #lightbox .lb-prev, #lightbox .lb-next { position: absolute; bottom: 18px; } #lightbox .lb-prev { left: 16px; } #lightbox .lb-next { right: 16px; } }

/* R296 — the footer's two readouts in pills, like the header's counters. They
   sat as bare text on the glass with the town showing through, and neither
   the rates nor the credit could be read over a bright map. */
#foot-rates, #foot-brand {
  color: var(--chip-ink); background: var(--glass-well); border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 3px rgba(40, 60, 50, 0.14); border-radius: 999px;
  padding: 3px 10px; font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#foot-rates:hover { color: var(--ink); text-decoration: none; background: rgba(255, 255, 255, 0.6); }
#foot-rates.short { color: #a8663a; }
html[data-theme="night"] #foot-rates, html[data-theme="night"] #foot-brand { color: #b7c2cb; background: var(--glass-well); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45); }
html[data-theme="night"] #foot-rates:hover { color: #e8edf1; background: rgba(255, 255, 255, 0.14); }
html[data-theme="night"] #foot-rates.short { color: #e0a86e; }
body.narrow #foot-rates { padding: 2px 8px; }

/* R297 — the region names: firmer glass and a squarer corner. At 60 % the
   town read straight through them, and a full pill beside the chat's bubbles
   (16px, with one corner cut) looked like a different set of furniture. */
:root { --glass-label: rgba(255, 255, 255, 0.86); }
html[data-theme="night"] { --glass-label: rgba(18, 24, 30, 0.82); }
#district-labels .label, .district-labels .label {
  border-radius: 10px; padding: 3px 10px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 10px rgba(40, 60, 50, 0.18);
}
html[data-theme="night"] #district-labels .label, html[data-theme="night"] .district-labels .label {
  color: #e8edf1; border-color: rgba(255, 255, 255, 0.18) !important;
}

/* R614: the tsunami trigger in Settings, a white pill */
.tsunami-send { display: inline-block; margin-top: 6px; padding: 6px 14px; border-radius: 999px; border: 1px solid rgba(0, 0, 0, 0.12); background: #fff; color: #1d2a33; font-weight: 600; cursor: pointer; }
.tsunami-send:hover { background: #f1f6f9; }
