:root {
  --bg: #0d1220;
  --ink: #eef1f7;
  --muted: #9aa3b8;
  --accent: #ffd166;
  --glass: rgba(16, 22, 38, 0.72);
  --line: rgba(255, 255, 255, 0.12);
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.4 var(--sans); overflow: hidden; }
#map { position: fixed; inset: 0; background: var(--bg); }
.leaflet-container { background: var(--bg); font: inherit; outline: none; }
.leaflet-tile { image-rendering: auto; }
body.pixelated .leaflet-tile { image-rendering: pixelated; }
.leaflet-control-zoom { display: none; }

.glass { background: var(--glass); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35); }

/* loading */
#loading { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; background: var(--bg);
  transition: opacity 0.6s ease; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); }
#loading i { display: inline-block; width: 10px; height: 10px; margin-right: 10px; background: var(--accent);
  animation: blink 0.9s steps(2, start) infinite; vertical-align: 1px; }
body.ready #loading { opacity: 0; pointer-events: none; }
@keyframes blink { to { visibility: hidden; } }

/* search */
#top { position: fixed; z-index: 950; top: max(16px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: min(560px, calc(100% - 32px)); }
.pill { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 8px 0 16px; border-radius: 999px; }
.pill .ic { color: var(--muted); flex: none; }
#q { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: none; color: var(--ink); font: 500 16px var(--sans); }
#q::placeholder { color: var(--muted); }
#q::-webkit-search-cancel-button { display: none; }
.kbd { font: 600 12px var(--sans); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; }
.ibtn { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 999px; border: 0;
  background: transparent; color: var(--ink); cursor: pointer; }
.ibtn:hover { background: rgba(255, 255, 255, 0.08); }
.ibtn:focus-visible, #q:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#results { list-style: none; margin: 8px 0 0; padding: 6px; border-radius: 18px; display: none; max-height: 50vh; overflow: auto; }
#results.on { display: block; }
#results li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 12px; cursor: pointer; }
#results li[aria-selected="true"], #results li:hover { background: rgba(255, 255, 255, 0.08); }
#results .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; align-self: center; }
#chip { display: none; margin: 8px auto 0; width: max-content; max-width: 100%; padding: 8px 16px; border-radius: 999px;
  font-weight: 600; }
#chip.on { display: block; }

/* credits (bottom-left) */
#credits { position: fixed; z-index: 940; left: max(16px, env(safe-area-inset-left)); bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; font: 500 13px/1 var(--sans); }
#credits a { color: var(--ink); text-decoration: none; }
#credits a b { color: var(--accent); font-weight: 700; }
#credits a:hover { text-decoration: underline; }
#credits .sep { color: var(--muted); }
#madeby:empty, #madeby:empty + .sep { display: none; }

#attr { position: fixed; z-index: 930; left: max(16px, env(safe-area-inset-left)); bottom: calc(54px + env(safe-area-inset-bottom));
  max-width: min(560px, calc(100% - 200px)); font-size: 10.5px; color: var(--muted); text-shadow: 0 1px 2px #000; opacity: .8; }
#attr a { color: inherit; }

/* controls (right) */
#rail { position: fixed; z-index: 945; right: max(16px, env(safe-area-inset-right)); bottom: calc(64px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; }
#rail .grp { display: flex; flex-direction: column; padding: 4px; border-radius: 16px; }
#rail .ibtn { width: 40px; height: 40px; border-radius: 12px; }
.ibtn.on { background: rgba(255, 209, 102, 0.2); color: var(--accent); }

/* Autumn badge (bottom-right) */
#autumn { position: fixed; z-index: 945; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px 0 8px; border-radius: 999px; text-decoration: none;
  color: hsl(40 10% 97%); font: 500 13px/1 var(--sans); }
#autumn svg { border-radius: 5px; flex: none; }
#autumn b { font-weight: 700; }
#autumn:hover { border-color: rgba(216, 107, 35, 0.6); }

#toast { position: fixed; z-index: 960; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translate(-50%, 8px);
  padding: 10px 18px; border-radius: 999px; font-weight: 600; opacity: 0; transition: 0.3s ease; pointer-events: none; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* map labels */
.area-label { background: none; border: 0; pointer-events: none; }
.area-label span { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; color: #fff; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.18em; font-size: 12px; opacity: var(--o, 1); transition: opacity 0.4s ease;
  text-shadow: 0 0 2px var(--bg), 0 0 6px rgba(13, 18, 32, 0.95), 0 1px 3px rgba(0, 0, 0, 0.9); }
.pin { background: none; border: 0; }
.pin span { position: absolute; left: -9px; top: -26px; width: 18px; height: 18px; background: var(--accent);
  border: 3px solid var(--bg); border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); }

@media (max-width: 640px) {
  .kbd { display: none; }
  #credits { font-size: 12px; padding: 7px 11px; max-width: calc(100% - 190px); }
  #credits .sep, #writeup { display: none; }
  #attr { display: none; }
  #rail { bottom: calc(60px + env(safe-area-inset-bottom)); gap: 8px; }
  #rail .ibtn { width: 38px; height: 38px; }
  #autumn { height: 30px; font-size: 12px; }
}

/* simulated traffic canvas: above tiles, below labels and pins */
.traffic-layer { position: absolute; inset: 0; z-index: 450; pointer-events: none; image-rendering: pixelated; transition: opacity .15s; }
.ibtn.off { opacity: .45; }

/* first-visit intro */
#intro { position: fixed; z-index: 1500; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100% - 32px));
  padding: 26px 26px 22px; border-radius: 18px; display: grid; gap: 12px; }
#intro h1 { margin: 0; font: 800 30px/1.1 var(--sans); letter-spacing: -0.01em; }
#intro h1 b { color: var(--accent); }
#intro p { margin: 0; color: var(--muted); }
#intro ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; }
#intro kbd { display: inline-block; min-width: 22px; text-align: center; margin-right: 8px; font: 600 12px var(--sans);
  border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--ink); }
#intro .row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
#intro .cta { background: var(--accent); color: #1a1405; border: 0; border-radius: 999px; padding: 10px 18px; font: 700 15px var(--sans); cursor: pointer; }
#intro .cta:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
#intro a { color: var(--ink); text-decoration: none; font-weight: 600; }
#intro a:hover { text-decoration: underline; }

/* landmark labels at street level */
.lm-label { background: none; border: 0; pointer-events: none; }
.lm-label span { position: absolute; transform: translate(-50%, -130%); white-space: nowrap; color: #fff; font: 700 12px var(--sans);
  padding: 3px 8px; border-radius: 999px; background: rgba(13, 18, 32, 0.72); box-shadow: 0 2px 6px rgba(0,0,0,.35); opacity: var(--o, 1); }

[hidden] { display: none !important; }

/* night: a moonlit grade on the tiles; street lamps, lit windows and headlights come from traffic.js */
body.night .leaflet-tile-pane { filter: url(#nightf) contrast(1.08); }
.leaflet-tile-pane { transition: filter 0.6s ease; }
.ibtn.on { background: rgba(255, 210, 120, 0.22); color: var(--accent); }

/* the city's name, in the empty space beside the city when fully zoomed out */
#citytitle { position: fixed; z-index: 900; left: max(48px, env(safe-area-inset-left)); top: 50%; transform: translateY(-50%);
  pointer-events: none; color: #fff; opacity: var(--o, 0); transition: opacity .5s ease; }
#citytitle small { display: block; font: 700 13px/1 var(--sans); letter-spacing: .5em; color: var(--accent); margin-bottom: 12px; }
#citytitle b { display: block; font: 900 clamp(44px, 6vw, 88px)/.9 var(--sans); letter-spacing: .2em;
  text-shadow: 0 0 34px rgba(120, 190, 255, .3), 0 4px 30px rgba(0, 0, 0, .6); }
#citytitle i { display: block; height: 3px; width: 46%; margin: 16px 0 14px; background: linear-gradient(90deg, var(--accent), transparent); }
#citytitle span { display: block; font: 600 15px/1 var(--sans); letter-spacing: .14em; color: rgba(238, 241, 247, .7); }
@media (max-width: 900px) {  /* phones / narrow: a centred band under the city */
  #citytitle { left: 50%; top: auto; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); text-align: center; }
  #citytitle small { font-size: 10px; margin-bottom: 8px; }
  #citytitle b { font-size: 40px; letter-spacing: .24em; margin-right: -.24em; }
  #citytitle i { margin: 10px auto 8px; background: linear-gradient(90deg, transparent, var(--accent), transparent); }
  #citytitle span { font-size: 12px; }
}
