/* =========================================================================
   Plugsim — night dispatch console.
   Sodium-orange accent on a cold blue-black ground; condensed signage type
   for labels, mono for every number the player has to compare.
   ========================================================================= */

:root {
  --ground:      #080b10;
  --panel:       #0f1620;
  --panel-2:     #151f2c;
  --panel-3:     #1c2836;
  --line:        #253243;
  --line-soft:   #1a2431;

  --text:        #ccd8e5;
  --text-dim:    #8496a8;
  --text-faint:  #5d6d7e;

  --sodium:      #ff8a3d;
  --sodium-dim:  #b35d24;
  --money:       #e7c56a;
  --good:        #4fb477;
  --bad:         #e5544b;
  --warn:        #d9a441;

  --weed:        #6fbf5b;
  --shroom:      #b48cd8;

  --shadow: 0 10px 32px rgba(0, 0, 0, .55);
  --radius: 4px;

  --font-display: 'Barlow Condensed', 'Oswald', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; color: inherit; }

/* Uppercase signage label used all over the console. */
.cash__label,
.rail__tabs button,
.sect__title,
.stat__label,
.chip__label {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: .10em;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-faint);
}

/* ── Map ───────────────────────────────────────────────────────────────── */

#map { position: absolute; inset: 0; background: #d8d4cd; z-index: 0; }
.leaflet-container { background: #d8d4cd; font-family: var(--font-body); }

/* The basemap keeps OSM's own colours — green parks, blue water, warm roads.
   It used to be inverted into a near-black sheet, which killed every colour on
   it and made highlighted buildings glare. A light map under dark chrome reads
   far better, especially on a phone. */
/* The map has to sit *inside* a dark console, not shine out of it.
   Inverting the raster and spinning the hue back is what turns a light OSM
   tile into a night map while keeping parks green and water blue — brightness
   alone just gives flat grey. The exposure is driven from the clock at
   runtime; this is the daytime value and the starting point before the first
   tick. */
.leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(1.02) contrast(.78) saturate(.78);
  transition: filter 1.4s linear;
}

/* Overnight, the streetlights are the only thing on. */
body.is-night .bmark__chip { box-shadow: 0 0 14px rgba(255, 138, 61, .35); }
body.is-night .cmark { filter: drop-shadow(0 0 6px rgba(255, 200, 120, .45)); }
.leaflet-tile {
  image-rendering: -webkit-optimize-contrast;
}

.leaflet-control-attribution {
  background: rgba(8, 11, 16, .78) !important;
  color: var(--text-faint) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }
.leaflet-bar a {
  background: var(--panel-2) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
.leaflet-bar a:hover { background: var(--panel-3) !important; }

/* The zoom control sits bottom-right, where the event ticker and the inspector
   both overlay the map — the minus button was completely unclickable. Lift it
   clear of the ticker, and shift it aside when the inspector is open. */
.leaflet-control-zoom {
  margin-bottom: 60px !important;
  margin-right: 12px !important;
  transition: margin-right .2s ease;
}
body.has-inspector .leaflet-control-zoom { margin-right: 344px !important; }
.leaflet-control-zoom a {
  width: 34px !important;
  height: 34px !important;
  line-height: 32px !important;
  font-size: 19px !important;
}
.leaflet-control-attribution { margin-bottom: 44px !important; }

.district-label { cursor: pointer; }
.district-label span {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #26323f;
  text-shadow:
     0 1px 0 rgba(255, 255, 255, .95), 0 -1px 0 rgba(255, 255, 255, .95),
     1px 0 0 rgba(255, 255, 255, .95), -1px 0 0 rgba(255, 255, 255, .95),
     0 0 7px rgba(255, 255, 255, .9);
  white-space: nowrap;
  transition: color .12s ease;
}
.district-label:hover span { color: #b8500f; }
.district-label.is-selected span {
  color: #a8410a;
  text-shadow:
     0 1px 0 rgba(255, 255, 255, .95), 0 -1px 0 rgba(255, 255, 255, .95),
     1px 0 0 rgba(255, 255, 255, .95), -1px 0 0 rgba(255, 255, 255, .95),
     0 0 9px rgba(255, 236, 220, .95);
}

/* Property markers */
.bmark { position: relative; width: 34px; height: 34px; cursor: pointer; }
.bmark__chip {
  position: absolute; inset: 3px;
  display: grid; place-items: center;
  background: var(--panel-2);
  border: 1.5px solid var(--line);
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .6);
  transition: transform .12s ease, border-color .12s ease;
}
.bmark__chip svg { width: 17px; height: 17px; fill: var(--text-dim); }
.bmark:hover .bmark__chip { transform: scale(1.12); }
.bmark--grow_house .bmark__chip, .bmark--closet_grow .bmark__chip { border-color: #37613a; }
.bmark--grow_house svg, .bmark--closet_grow svg { fill: var(--weed); }
.bmark--press_room .bmark__chip { border-color: #6b4f30; }
.bmark--press_room svg { fill: #c98f4a; }
.bmark--pill_press .bmark__chip { border-color: #2f5a68; }
.bmark--pill_press svg { fill: #63b9d4; }
.bmark--machine_shop .bmark__chip { border-color: #55606d; }
.bmark--machine_shop svg { fill: #9aa7b5; }
.bmark--fungi_room .bmark__chip { border-color: #4d3b63; }
.bmark--fungi_room svg { fill: var(--shroom); }
.bmark--lab .bmark__chip { border-color: #2f5a68; }
.bmark--lab svg { fill: #63b9d4; }
.bmark--stash .bmark__chip, .bmark--lockup .bmark__chip { border-color: #4a4a52; }
.bmark--stash svg, .bmark--lockup svg { fill: #9aa7b5; }
.bmark--phoneshop .bmark__chip, .bmark--checkcashing .bmark__chip,
.bmark--bodega .bmark__chip, .bmark--laundromat .bmark__chip,
.bmark--autoshop .bmark__chip, .bmark--cafe .bmark__chip,
.bmark--barbershop .bmark__chip, .bmark--carwash .bmark__chip,
.bmark--gym .bmark__chip, .bmark--nightclub .bmark__chip { border-color: #6b5a2c; }
.bmark--phoneshop svg, .bmark--checkcashing svg,
.bmark--bodega svg, .bmark--laundromat svg, .bmark--autoshop svg,
.bmark--cafe svg, .bmark--barbershop svg, .bmark--carwash svg,
.bmark--gym svg, .bmark--nightclub svg { fill: var(--money); }

/* Streaming survey indicator */
.loading {
  position: absolute; top: 68px; left: 50%; transform: translateX(-50%);
  z-index: 720;
  padding: 6px 14px;
  background: rgba(15, 22, 32, .95);
  border: 1px solid var(--sodium-dim);
  border-radius: 999px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--sodium);
  box-shadow: var(--shadow);
  pointer-events: none;
}
.loading[hidden] { display: none; }

.bmark.is-selected .bmark__chip {
  border-color: var(--sodium);
  box-shadow: 0 0 0 3px rgba(255, 138, 61, .22), 0 3px 10px rgba(0, 0, 0, .6);
}
.bmark.is-off .bmark__chip { opacity: .4; filter: grayscale(1); }
.bmark.is-ghost .bmark__chip { opacity: .7; border-style: dashed; }
.bmark.is-stalled::after {
  content: '';
  position: absolute; top: -1px; right: -1px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--warn);
  border: 1.5px solid var(--panel);
  animation: pulse 1.8s ease-in-out infinite;
}
.bmark__lvl {
  position: absolute; bottom: -3px; left: -3px;
  min-width: 15px; height: 15px; padding: 0 3px;
  display: grid; place-items: center;
  background: var(--sodium); color: #17100a;
  font-family: var(--font-mono); font-size: 9px; font-weight: 600;
  border-radius: 3px; border: 1.5px solid var(--panel);
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* Couriers */
.cmark {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  background: var(--panel-3);
  border: 1.5px solid #35455a;
  border-radius: 50%;
  color: var(--text-faint);
  font-size: 10px;
  cursor: pointer;
  transition: transform .1s ease;
}
.cmark:hover { transform: scale(1.2); }
.cmark.is-laden { border-color: var(--sodium); color: var(--sodium); box-shadow: 0 0 9px rgba(255, 138, 61, .4); }
.cmark.is-idle { opacity: .45; }

/* Incident ping */
.ping {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--bad);
  animation: ping 2.2s ease-out forwards;
}
@keyframes ping {
  from { transform: scale(.4); opacity: 1; }
  to   { transform: scale(4.5); opacity: 0; }
}

/* ── HUD ───────────────────────────────────────────────────────────────── */

.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 700;
  display: flex; align-items: stretch; gap: 1px;
  background: var(--line-soft);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.hud__block {
  display: flex; align-items: center; gap: 14px;
  padding: 9px 16px;
  background: rgba(15, 22, 32, .94);
  backdrop-filter: blur(8px);
}
.hud__brand { flex-direction: column; align-items: flex-start; gap: 1px; min-width: 168px; }
.hud__city {
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
  letter-spacing: .02em; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}
.hud__clock { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.hud__clock .dot { margin: 0 5px; color: var(--text-faint); }
.hud__cash { flex: 0 0 auto; }
.hud__tools { margin-left: auto; gap: 10px; }

.cash { display: flex; flex-direction: column; gap: 1px; }
.cash__value {
  font-family: var(--font-mono); font-size: 15px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.cash__value--clean { color: var(--money); }
.cash__value--dirty { color: var(--text-dim); }

.heatbar {
  width: 96px; height: 7px;
  background: var(--panel-3);
  border: 1px solid var(--line);
  overflow: hidden;
}
.heatbar i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #3d6f8a, var(--warn) 55%, var(--bad));
  transition: width .4s ease;
}
.heatbar__num {
  font-family: var(--font-mono); font-size: 12px;
  font-variant-numeric: tabular-nums; color: var(--text-dim); min-width: 22px;
}

.hud__speed { gap: 3px; padding: 9px 12px; }
.spd {
  min-width: 38px; padding: 6px 8px;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  cursor: pointer; transition: all .12s ease;
}
.spd:hover { border-color: var(--sodium-dim); color: var(--text); }
.spd.is-on {
  background: var(--sodium); border-color: var(--sodium);
  color: #17100a; font-weight: 600;
}

.overlay-pick { display: flex; flex-direction: column; gap: 2px; }
.overlay-pick select {
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); padding: 4px 6px; font-size: 12px; cursor: pointer;
}

.ghostbtn {
  padding: 6px 12px;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 12px; cursor: pointer; transition: all .12s ease;
  border-radius: var(--radius);
}
.ghostbtn:hover { border-color: var(--sodium-dim); color: var(--text); background: var(--panel-3); }
.ghostbtn:disabled { opacity: .38; cursor: not-allowed; }

.primarybtn {
  padding: 8px 16px;
  background: var(--sodium); border: 1px solid var(--sodium);
  color: #17100a; font-weight: 600; font-size: 13px;
  cursor: pointer; border-radius: var(--radius); transition: filter .12s ease;
}
.primarybtn:hover { filter: brightness(1.12); }
.primarybtn:disabled { opacity: .4; cursor: not-allowed; filter: none; }

/* ── Left rail ─────────────────────────────────────────────────────────── */

.rail {
  position: absolute; top: 61px; left: 12px; bottom: 52px; z-index: 690;
  width: 292px;
  display: flex; flex-direction: column;
  background: rgba(15, 22, 32, .95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.rail__tabs { display: flex; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.rail__tabs button {
  flex: 1; padding: 10px 2px; font-size: 10.5px;
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  cursor: pointer; transition: all .12s ease;
}
.rail__tabs button:hover { color: var(--text-dim); background: rgba(255, 255, 255, .03); }
.rail__tabs button.is-on { color: var(--sodium); border-bottom-color: var(--sodium); }
.rail__body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 12px 20px; }

/* ── Inspector ─────────────────────────────────────────────────────────── */

.inspector {
  position: absolute; top: 61px; right: 12px; bottom: 52px; z-index: 690;
  width: 320px;
  background: rgba(15, 22, 32, .95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px 22px;
}
.inspector__close {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 26px; height: 26px;
  background: transparent; border: 0; color: var(--text-faint);
  cursor: pointer; font-size: 14px; border-radius: var(--radius);
}
.inspector__close:hover { background: var(--panel-3); color: var(--text); }

/* ── Shared panel furniture ────────────────────────────────────────────── */

.sect { margin-bottom: 16px; }
.sect:last-child { margin-bottom: 0; }
.sect__title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 7px; padding-bottom: 5px;
  border-bottom: 1px solid var(--line-soft);
}

.ttl {
  font-family: var(--font-display); font-weight: 700;
  font-size: 20px; line-height: 1.15; letter-spacing: .01em;
  margin: 0 24px 2px 0; text-wrap: balance;
}
.subttl {
  font-size: 12px; color: var(--text-dim); margin: 0 0 12px;
}

/* Label / value rows */
.rows { display: flex; flex-direction: column; gap: 5px; }
.row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-size: 12.5px;
}
.row > span:first-child { color: var(--text-dim); }
.row > span:last-child {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  color: var(--text);
}
.row .good { color: var(--good); }
.row .bad { color: var(--bad); }
.row .warn { color: var(--warn); }
.row .money { color: var(--money); }

/* Meters */
.meter { height: 5px; background: var(--panel-3); overflow: hidden; margin-top: 3px; }
.meter i { display: block; height: 100%; background: var(--sodium); transition: width .3s ease; }
.meter--heat i { background: linear-gradient(90deg, #3d6f8a, var(--warn) 60%, var(--bad)); }
.meter--weed i { background: var(--weed); }
.meter--shroom i { background: var(--shroom); }
.meter--rep i { background: #8f8ce0; }

/* Cards used in the build palette and lists */
.card {
  width: 100%; text-align: left;
  display: block; padding: 10px 11px; margin-bottom: 7px;
  background: var(--panel-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius); cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.card:hover { border-color: var(--sodium-dim); background: var(--panel-3); }
.card.is-on { border-color: var(--sodium); }
.card.is-locked { opacity: .5; cursor: not-allowed; }
.card.is-locked:hover { border-color: var(--line-soft); background: var(--panel-2); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card__name {
  font-family: var(--font-display); font-weight: 600; font-size: 15px;
  letter-spacing: .01em;
}
.card__cost {
  font-family: var(--font-mono); font-size: 12px; color: var(--money);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.card__cost.is-short { color: var(--bad); }
.card__blurb { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; line-height: 1.45; }
.card__meta {
  display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim);
}

/* Price sparkline */
.spark { display: block; width: 100%; height: 34px; margin-top: 6px; }
.spark--empty {
  height: 34px; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint);
  border: 1px dashed var(--line-soft); border-radius: var(--radius);
}

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  background: var(--panel-3); border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-mono); font-size: 11px;
}
.chip--weed { color: var(--weed); border-color: #37613a; }
.chip--shroom { color: var(--shroom); border-color: #4d3b63; }
.chip--warn { color: var(--warn); border-color: #6b5a2c; }
.chip--bad { color: var(--bad); border-color: #6b3230; }
.chip--good { color: var(--good); border-color: #2c6047; }

.empty {
  padding: 18px 12px; text-align: center;
  color: var(--text-faint); font-size: 12px; line-height: 1.6;
  border: 1px dashed var(--line); border-radius: var(--radius);
}

.btnrow { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.btnrow .ghostbtn, .btnrow .primarybtn { flex: 1; min-width: 84px; text-align: center; }

.field { margin-bottom: 9px; }
.field label {
  display: block; margin-bottom: 4px;
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: .09em; font-size: 10.5px; color: var(--text-faint); font-weight: 600;
}
.field select, .field input {
  width: 100%;
  max-width: 100%;
  min-width: 0; padding: 7px 8px;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); font-size: 12.5px; border-radius: var(--radius);
}
.field select:focus, .field input:focus {
  outline: none; border-color: var(--sodium);
}

/* ── Ticker ────────────────────────────────────────────────────────────── */

.ticker {
  position: absolute; left: 12px; right: 12px; bottom: 8px; z-index: 680;
  height: 34px; display: flex; align-items: center; gap: 20px;
  padding: 0 14px;
  background: rgba(15, 22, 32, .93);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: var(--font-mono); font-size: 11.5px;
}
.ticker__item { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.ticker__time { color: var(--text-faint); }
.ticker__item.is-bad .ticker__text { color: var(--bad); }
.ticker__item.is-good .ticker__text { color: var(--good); }
.ticker__text { color: var(--text-dim); }

/* ── Placement bar ─────────────────────────────────────────────────────── */

.placing {
  position: absolute; top: 72px; left: 50%; transform: translateX(-50%); z-index: 720;
  display: flex; align-items: center; gap: 14px;
  padding: 8px 10px 8px 16px;
  background: rgba(255, 138, 61, .14);
  border: 1px solid var(--sodium);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  font-size: 13px;
}
.placing #placingText { color: var(--sodium); font-weight: 500; }

/* ── Toasts ────────────────────────────────────────────────────────────── */

#toasts {
  position: absolute; bottom: 52px; left: 50%; transform: translateX(-50%);
  z-index: 900; display: flex; flex-direction: column; gap: 6px;
  align-items: center; pointer-events: none;
}
.toast {
  padding: 9px 16px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--text-faint);
  border-radius: var(--radius);
  font-size: 13px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px);
  transition: opacity .22s ease, transform .22s ease;
  max-width: 460px;
}
.toast.is-in { opacity: 1; transform: none; }
.toast--good { border-left-color: var(--good); }
.toast--bad { border-left-color: var(--bad); }
.toast--warn { border-left-color: var(--warn); }

/* ── Start screen ──────────────────────────────────────────────────────── */

.start {
  position: absolute; inset: 0; z-index: 1000;
  display: grid; place-items: center;
  background:
    radial-gradient(1100px 620px at 50% -10%, rgba(255, 138, 61, .10), transparent 65%),
    var(--ground);
}
.start[hidden] { display: none; }
.start__panel {
  width: min(560px, calc(100vw - 32px));
  padding: 34px 34px 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .7);
}
.start__kicker {
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: .22em; font-size: 11px; color: var(--sodium); font-weight: 600;
}
.start__panel h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: 56px; line-height: .95; letter-spacing: .04em;
  margin: 6px 0 8px;
}
.start__tag { color: var(--text-dim); font-size: 14px; margin: 0 0 26px; }

.start__field label {
  display: block; margin-bottom: 7px;
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: .1em; font-size: 11px; color: var(--text-faint); font-weight: 600;
}
.start__searchrow { display: flex; gap: 7px; }
.start__searchrow input {
  flex: 1; padding: 10px 12px;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); font-size: 14px; border-radius: var(--radius);
}
.start__searchrow input:focus { outline: none; border-color: var(--sodium); }
.start__hint { font-size: 11.5px; color: var(--text-faint); margin: 9px 0 0; line-height: 1.5; }

.start__results { margin-top: 8px; max-height: 190px; overflow-y: auto; }
.start__results:empty { display: none; }
.result {
  width: 100%; text-align: left; display: block;
  padding: 8px 11px; margin-bottom: 4px;
  background: var(--panel-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius); cursor: pointer; transition: border-color .12s ease;
}
.result:hover { border-color: var(--sodium); }
.result b {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 13.5px; font-weight: 600;
}
.result b em {
  font-style: normal; font-family: var(--font-display);
  text-transform: uppercase; letter-spacing: .09em;
  font-size: 10px; font-weight: 600; color: var(--sodium);
}
.result span { display: block; font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.start__actions { display: flex; gap: 7px; margin-top: 24px; flex-wrap: wrap; }
.start__status {
  margin-top: 16px; min-height: 18px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim);
}
.start__status.is-bad { color: var(--bad); }

/* ── Modal ─────────────────────────────────────────────────────────────── */

.modal {
  position: absolute; inset: 0; z-index: 950;
  display: grid; place-items: center;
  background: rgba(6, 9, 13, .78); backdrop-filter: blur(3px);
}
.modal[hidden] { display: none; }
.modal__panel {
  position: relative;
  width: min(600px, calc(100vw - 32px)); max-height: 82vh; overflow-y: auto;
  padding: 28px 30px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.modal__panel h2 {
  font-family: var(--font-display); font-size: 26px; font-weight: 700;
  margin: 0 0 14px;
}
.modal__panel h3 {
  font-family: var(--font-display); font-size: 16px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--sodium); margin: 22px 0 8px;
}
.chain { margin: 0; padding-left: 20px; }
.chain li { margin-bottom: 8px; font-size: 13px; line-height: 1.55; color: var(--text-dim); }
.chain li b { color: var(--text); }
.chain li i { color: var(--text); font-style: normal; border-bottom: 1px dotted var(--text-faint); }
.keys { font-size: 12.5px; color: var(--text-dim); }
kbd {
  display: inline-block; padding: 1px 6px; margin: 0 1px;
  background: var(--panel-3); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 3px;
  font-family: var(--font-mono); font-size: 11px; color: var(--text);
}

/* ── Scrollbars ────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #2a3a4c; }

:focus-visible { outline: 2px solid var(--sodium); outline-offset: 1px; }

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

/* Upgrade disclosure */
.upgrades { margin: 12px 0 4px; border-top: 1px solid var(--line-soft); }
.upgrades > summary {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0 8px;
  cursor: pointer; list-style: none;
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: .1em; font-size: 11px; font-weight: 600; color: var(--text-faint);
}
.upgrades > summary::-webkit-details-marker { display: none; }
.upgrades > summary:hover { color: var(--sodium); }
.upgrades > summary::after {
  content: '▾'; margin-left: 8px; transition: transform .15s ease; color: var(--text-faint);
}
.upgrades[open] > summary::after { transform: rotate(180deg); }
.upgrades__count { font-family: var(--font-mono); letter-spacing: 0; color: var(--text-dim); }
.upgrades__body { padding-bottom: 4px; }

/* ── Touch + small screens ─────────────────────────────────────────────── */

/* The grip only exists on phones, where the panels are dismissible sheets. */
.sheet__grip { display: none; }

@media (max-width: 1180px) and (min-width: 781px) {
  .rail { width: 258px; }
  .inspector { width: 286px; }
}

@media (max-width: 780px) {
  /* Panels stop being rails and become sheets that slide up over the map. */
  .rail,
  .inspector {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 54px;
    width: auto;
    height: auto;
    max-height: min(64vh, 540px);
    border-radius: 12px 12px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    transform: translateY(102%);
    transition: transform .22s ease;
    z-index: 760;
  }
  .rail.is-open,
  .inspector.is-open { transform: none; }

  .sheet__grip {
    display: block;
    position: sticky;
    top: 0;
    width: 100%;
    /* A proper thumb target — the old 22px strip was easy to miss entirely. */
    height: 30px;
    flex: 0 0 auto;
    background: linear-gradient(180deg, var(--panel) 55%, transparent);
    border: 0;
    cursor: grab;
    z-index: 3;
    touch-action: none;
  }
  .sheet__grip:active { cursor: grabbing; }
  .sheet__grip::before {
    content: '';
    position: absolute;
    top: 10px; left: 50%;
    width: 46px; height: 5px;
    transform: translateX(-50%);
    background: var(--text-faint);
    border-radius: 3px;
    transition: background .15s ease, width .15s ease;
  }
  .sheet__grip:hover::before,
  .sheet__grip:active::before { background: var(--sodium); width: 56px; }

  /* The sheets themselves are dragged, so the browser must not claim the
     vertical gesture first. */
  .rail.is-open, .inspector.is-open { touch-action: pan-y; }
  .inspector { padding-top: 0; }
  .inspector__close { top: 20px; }

  /* Bottom navigation replaces the rail tabs as the primary way around. */
  .mobilenav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 800;
    display: flex;
    height: 54px;
    background: rgba(15, 22, 32, .97);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobilenav button {
    flex: 1; min-width: 0; padding: 0 2px; font-size: 11px;
    background: transparent;
    border: 0;
    border-top: 2px solid transparent;
    color: var(--text-faint);
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mobilenav button.is-on { color: var(--sodium); border-top-color: var(--sodium); }

  /* The HUD has to survive at 360px without eating the map: two tight rows,
     with each label sitting inline beside its value rather than above it. */
  .hud { flex-wrap: wrap; gap: 0; }
  .hud__block { padding: 5px 10px; gap: 8px; }
  .hud__brand {
    min-width: 0; flex: 1 1 auto;
    flex-direction: row; align-items: baseline; gap: 8px;
  }
  .hud__city { font-size: 15px; max-width: 40vw; }
  .hud__clock { font-size: 10px; }
  .hud__speed { order: 4; padding: 4px 8px 6px; gap: 2px; }
  .spd { min-width: 28px; padding: 7px 2px; font-size: 9.5px; }

  .hud__cash { flex: 1 1 auto; order: 3; justify-content: flex-start; gap: 14px; padding: 4px 10px 6px; }
  .cash { flex-direction: row; align-items: baseline; gap: 5px; }
  .cash__label { font-size: 9px; }
  .cash__value { font-size: 13px; }

  /* Tools ride alongside the city name on row one; speed sits with the cash
     on row two. Floating the tools absolutely put them on top of the speed
     buttons at phone width. */
  .hud__tools { order: 2; margin-left: auto; padding: 5px 8px; gap: 6px; }
  .hud__tools .cash__label { display: none; }
  .overlay-pick select { max-width: 104px; font-size: 11px; padding: 4px; }
  .hud__tools .ghostbtn { padding: 6px 9px; font-size: 11px; }

  /* Ticker sits above the nav and shows only the latest line. */
  .ticker {
    left: 0; right: 0; bottom: 54px;
    height: 28px;
    border-radius: 0;
    border-left: 0; border-right: 0;
    font-size: 11px;
    padding: 0 10px;
    z-index: 700;
  }
  .ticker .ticker__item:not(:first-child) { display: none; }
  .rail.is-open ~ .ticker,
  .inspector.is-open ~ .ticker { display: none; }

  /* Very narrow: the projection is the first thing that can go. */
  @media (max-width: 430px) {
    .hud__cash .cash:last-child { display: none; }
  }

  #toasts { bottom: 92px; left: 10px; right: 10px; transform: none; }
  .toast { max-width: none; }

  /* Fingers need bigger targets than a mouse does. */
  .card { padding: 13px 12px; }
  .ghostbtn, .primarybtn { padding: 11px 14px; font-size: 13px; }
  .btnrow .ghostbtn, .btnrow .primarybtn { min-width: 0; }
  .field select, .field input { padding: 11px 9px; font-size: 16px; }
  .rail__tabs button { padding: 12px 4px; }
  .leaflet-control-zoom { display: none; }
  .leaflet-control-attribution { margin-bottom: 84px !important; }

  .start__panel { padding: 26px 20px 22px; }
  .start__panel h1 { font-size: 42px; }
  .start__searchrow { flex-direction: column; }
  .start__actions button { flex: 1 1 auto; }
  .modal__panel { padding: 22px 18px; max-height: 78vh; }
}

/* Landscape phones are short: give the sheets less height. */
@media (max-width: 900px) and (max-height: 480px) {
  .rail, .inspector { height: 74vh; }
}

/* Ray's card. It should read as somebody talking to you, not as chrome. */
.sect--helper {
  border-left: 3px solid var(--sodium);
  background: linear-gradient(90deg, rgba(255, 138, 61, 0.10), transparent 70%);
}
.sect--helper .sect__title { color: var(--sodium); }
.sect--helper .card__blurb { line-height: 1.5; }

/* Where you are, and where home is. */
.pmark {
  width: 16px; height: 16px; border-radius: 50%;
  background: #4ea8ff; border: 2px solid #fff;
  box-shadow: 0 0 0 4px rgba(78, 168, 255, 0.28), 0 1px 4px rgba(0, 0, 0, 0.5);
}
.pmark--live { animation: pmark-pulse 2.2s ease-out infinite; }
@keyframes pmark-pulse {
  0%   { box-shadow: 0 0 0 3px rgba(78, 168, 255, 0.40), 0 1px 4px rgba(0, 0, 0, 0.5); }
  70%  { box-shadow: 0 0 0 16px rgba(78, 168, 255, 0), 0 1px 4px rgba(0, 0, 0, 0.5); }
  100% { box-shadow: 0 0 0 3px rgba(78, 168, 255, 0), 0 1px 4px rgba(0, 0, 0, 0.5); }
}
@media (prefers-reduced-motion: reduce) { .pmark--live { animation: none; } }

/* Your line on the board should be findable without reading every row. */
.row--you {
  background: rgba(255, 138, 61, 0.12);
  border-radius: 6px;
  padding-left: 6px;
  padding-right: 6px;
  margin-left: -6px;
  margin-right: -6px;
}

/* Running out of money stops production silently. This is the one warning that
   has to be visible without opening anything. */
.hud__warning {
  color: var(--bad);
  font-weight: 600;
  letter-spacing: .01em;
  border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent);
  border-radius: 7px;
  padding: 5px 10px;
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  max-width: 34ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 780px) {
  .hud__warning { max-width: 100%; font-size: 11px; padding: 4px 8px; }
}

/* --- Building name labels -------------------------------------------------
   The name rides above the marker and is part of it, so tapping the words
   opens the business exactly as tapping the icon does. */
.bmark__label {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line);
  color: var(--text);
  font: 600 11.5px/1.35 var(--font-display);
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: border-color .16s ease, color .16s ease, transform .16s ease;
}
.bmark:hover .bmark__label,
.bmark.is-selected .bmark__label {
  border-color: var(--sodium);
  color: var(--sodium);
  transform: translateX(-50%) translateY(-1px);
}
.bmark.is-stalled .bmark__label { border-color: var(--warn); color: var(--warn); }
.bmark.is-off .bmark__label { opacity: .5; }

/* Firearms lines show what they build, with whatever is bolted to it. */
.bmark__chip .art--gun { width: 26px; height: 13px; }
.bmark--machine_shop .art--gun path[fill] { fill: #9aa7b5; }
.bmark--gunsmith .art--gun path[fill] { fill: #7fb2d4; }

.art { display: block; }
.art--product { flex: none; }
.art--attach { flex: none; opacity: .9; }

/* Leaflet clips nothing on a divIcon by default, but be explicit — the label
   sits outside the 34px icon box. */
.leaflet-marker-icon .bmark { overflow: visible; }

@media (max-width: 780px) {
  /* On a phone the labels crowd the map, so only the selected one shows. */
  .bmark__label { display: none; }
  .bmark.is-selected .bmark__label { display: block; }
}

/* --- Goods and weapons, drawn ---------------------------------------------- */

.card--goods .card__name {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.goods__art {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: color-mix(in srgb, currentColor 11%, transparent);
  border: 1px solid color-mix(in srgb, currentColor 24%, transparent);
  flex: none;
}
.goods__art .art { width: 22px; height: 22px; }
.goods__art .art--gun { width: 28px; height: 14px; }

/* A card that leads with a picture. */
.card--art, .card--attach { padding-top: 10px; }
.card__art {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 6px 12px;
  margin: -4px -2px 8px;
  border-radius: 10px;
  background:
    radial-gradient(120% 100% at 50% 0%, color-mix(in srgb, var(--sodium) 7%, transparent), transparent 70%),
    var(--panel-2);
  border: 1px solid var(--line-soft);
}
.card__art--small { padding: 6px; }
.card:hover .card__art { border-color: var(--line); }

/* The showcase: the weapon this line builds, at a size you can read. */
.showcase {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px;
  margin-bottom: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background:
    radial-gradient(140% 120% at 22% 0%, color-mix(in srgb, var(--sodium) 10%, transparent), transparent 62%),
    linear-gradient(180deg, var(--panel-2), var(--panel));
}
.showcase__art {
  flex: 1 1 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 130px;
}
.showcase__art .art { width: 100%; height: auto; max-width: 190px; }
.showcase__meta { flex: 1 1 150px; min-width: 140px; }
.showcase__name {
  font: 600 15px/1.2 var(--font-display);
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 5px;
}
.showcase__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font: 500 11px/1.5 var(--font-mono);
  color: var(--text-dim);
  margin-bottom: 8px;
}
.chip--art {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
.chip--art .art { width: 18px; height: 18px; opacity: .85; }

@media (max-width: 780px) {
  .showcase { padding: 11px; gap: 10px; }
  .showcase__art .art { max-width: 150px; }
}

/* What the city is doing right now. Quiet most of the time; lit when it isn't. */
.hud__pulse {
  font: 600 11.5px/1.4 var(--font-display);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 5px 11px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  white-space: nowrap;
  transition: color .4s ease, border-color .4s ease, background .4s ease;
}
.hud__pulse.is-busy {
  color: var(--sodium);
  border-color: color-mix(in srgb, var(--sodium) 45%, transparent);
  background: color-mix(in srgb, var(--sodium) 12%, transparent);
}
@media (max-width: 780px) { .hud__pulse { display: none; } }

/* --- Things happening, on the map ------------------------------------------
   These are meant to be found by looking, so they read at a glance without
   shouting: a glyph until you hover, the whole story when you do. */
.imark {
  display: flex;
  align-items: center;
  gap: 0;
  height: 22px;
  padding: 0 3px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  backdrop-filter: blur(6px);
  cursor: pointer;
  white-space: nowrap;
  transition: gap .18s ease, padding .18s ease;
}
.imark--bad  { color: var(--bad); }
.imark--warn { color: var(--warn); }
.imark--good { color: var(--good); }

.imark__glyph {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  font-size: 11px;
  line-height: 1;
  flex: none;
}
.imark__label {
  max-width: 0;
  overflow: hidden;
  font: 600 10px/1 var(--font-display);
  letter-spacing: .05em;
  text-transform: uppercase;
  transition: max-width .22s ease, margin .22s ease;
}
.imark:hover { gap: 5px; padding-right: 8px; }
.imark:hover .imark__label { max-width: 20ch; }

/* Unseen ones breathe, so something new catches the eye without a banner. */
.imark.is-new { animation: imark-pulse 1.9s ease-out infinite; }
.imark.is-seen { opacity: .7; border-style: dashed; }
@keyframes imark-pulse {
  0%   { box-shadow: 0 0 0 0 currentColor; }
  70%  { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .imark.is-new { animation: none; } }

/* On a phone the labels would cover the map; the glyph is enough. */
@media (max-width: 780px) {
  .imark:hover { gap: 0; padding-right: 3px; }
  .imark:hover .imark__label { max-width: 0; }
}
