:root {
  --bg: #0b1420;
  --panel: rgba(12, 20, 30, 0.88);
  --panel-solid: #0f1a27;
  --line: rgba(160, 190, 220, 0.14);
  --text: #eef3f8;
  --muted: rgba(214, 228, 242, 0.62);
  --accent: #3ddc97;
  --accent-ink: #062a1b;
  --warn: #ffb347;
  --bad: #ff4d5e;
  --radius: 16px;
  --display: 'Unbounded', 'Manrope', system-ui, sans-serif;
  --body: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--body); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }

#map { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; background: #0b121c; }
.map-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* 3D map labels (MapLibre markers): compact tags with a congestion dot */
.road-label {
  --c: #ffb347;
  display: none; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 8px;
  background: rgba(10, 16, 24, 0.74); border: 0; color: #eef3f8;
  font: 700 11.5px/1.25 var(--body); white-space: nowrap; cursor: pointer;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.road-label::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); flex: none; }
.road-label .pct { color: var(--c); font-weight: 800; }
.labels-on .road-label { display: inline-flex; }
.road-label.sel { background: #fff; color: #0b1118; }
.road-label.sel .pct { color: #0b1118; }
.road-label.building::after { content: '⚒'; color: #ffc83c; }
.labels-compact .road-label:not(.sel) .nm { display: none; }
.map-hint .road-label:not(.minor) { animation: labelPulse 1.6s ease-in-out infinite; }
@keyframes labelPulse { 50% { box-shadow: 0 0 0 5px rgba(61, 220, 151, 0.3); } }
.road-label.minor { display: none !important; font-size: 10.5px; padding: 2px 7px 2px 6px; }
.labels-on.labels-streets .road-label.minor { display: inline-flex !important; }
.is-day .road-label { background: rgba(255, 255, 255, 0.9); color: #1c2733; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); }
.district-label {
  font: 700 11px var(--body); letter-spacing: .28em; text-transform: uppercase;
  color: rgba(196, 214, 232, 0.4); pointer-events: none; text-shadow: 0 1px 6px #000;
}
.is-day .district-label { color: rgba(40, 52, 66, 0.5); text-shadow: 0 1px 4px rgba(255, 255, 255, 0.7); }
.landmark {
  display: none; font: 600 11px var(--body); color: rgba(235, 242, 250, 0.9); white-space: nowrap;
  text-shadow: 0 1px 4px #000, 0 0 2px #000; pointer-events: none;
}
.landmark::before { content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #ffd166; margin-right: 5px; vertical-align: 2px; }
.labels-on.labels-landmarks .landmark { display: block; }
.is-day .landmark { color: #1f2b38; text-shadow: 0 1px 3px #fff, 0 0 2px #fff; }
.maplibregl-ctrl-attrib { background: rgba(8, 13, 20, 0.6) !important; color: rgba(214, 228, 242, 0.6); font-size: 10px; }
.maplibregl-ctrl-attrib a { color: rgba(214, 228, 242, 0.75) !important; }
.maplibregl-ctrl-attrib-button { filter: invert(1); opacity: .5; }
body.playing .maplibregl-ctrl-bottom-right { bottom: calc(60px + var(--safe-b)); }
body:not(.playing) .maplibregl-ctrl-bottom-right { bottom: 0; }
.maplibregl-canvas:focus { outline: none; }
.vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(4, 8, 14, 0.75) 100%);
}
/* 3D: sky colour on the horizon, driven by the time of day (daynight.js) */
:root { --sky-top: #24406c; --sky-mid: #1a2c4c; }
.is-3d .vignette {
  background:
    linear-gradient(180deg, var(--sky-top) 0%, color-mix(in srgb, var(--sky-mid) 45%, transparent) 13%, transparent 30%),
    radial-gradient(120% 90% at 50% 50%, transparent 62%, rgba(4, 8, 14, 0.55) 100%);
  transition: background 1s linear;
}
.is-3d.is-day .vignette {
  background:
    linear-gradient(180deg, var(--sky-top) 0%, color-mix(in srgb, var(--sky-mid) 50%, transparent) 13%, transparent 30%),
    radial-gradient(120% 90% at 50% 50%, transparent 70%, rgba(20, 30, 40, 0.25) 100%);
}
.weather { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }

/* Clock inside the HUD */
.clock { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.clock b { font-family: var(--display); font-size: 21px; font-weight: 800; }
.clock i { font-style: normal; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: #2a1800; background: var(--warn); padding: 2px 6px; border-radius: 6px; }
.clock .ic { font-size: 16px; }
.clock-mini { display: none !important; }

/* Incidents: a pin standing on the road */
.incident { --p: 0%; position: relative; width: 40px; height: 54px; border: 0; padding: 0; background: none; cursor: pointer; display: block; }
.incident .head {
  position: absolute; left: 0; top: 0; width: 40px; height: 40px; border-radius: 50%;
  background: conic-gradient(#ff4d5e var(--p), rgba(255, 255, 255, 0.3) 0);
  display: grid; place-items: center; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
.incident .emo { width: 32px; height: 32px; border-radius: 50%; background: #0f1a27; display: grid; place-items: center; font-size: 17px; }
.incident .stem { position: absolute; left: 19px; top: 39px; width: 2px; height: 14px; background: #ff4d5e; }
.incident .ring { position: absolute; left: 50%; bottom: -5px; width: 26px; height: 10px; margin-left: -13px; border-radius: 50%; border: 2px solid #ff4d5e; animation: incRing 1.4s ease-out infinite; }
.incident.working .head { background: conic-gradient(#3ddc97 var(--p), rgba(255, 255, 255, 0.3) 0); }
.incident.working .stem { background: #3ddc97; }
.incident.working .ring { border-color: #3ddc97; }
@keyframes incRing { from { transform: scale(0.7); opacity: 1; } to { transform: scale(2); opacity: 0; } }
.overlay-2d { position: fixed; left: 0; top: 0; z-index: 2; }

.toast {
  position: fixed; left: 50%; top: calc(84px + var(--safe-t)); transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 24px);
  padding: 9px 14px; border-radius: 999px; background: rgba(15, 26, 39, 0.95); border: 1px solid rgba(255, 77, 94, 0.6);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); font-size: 13px; cursor: pointer; white-space: nowrap; overflow: hidden;
}
.toast.in { animation: toastIn .35s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast span:not(.emo) { min-width: 0; }
.toast .emo { font-size: 18px; }
.toast span:not(.emo) { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.toast u { text-decoration: none; color: var(--accent); font-weight: 800; }

.taxi-tag {
  position: fixed; left: 50%; top: calc(84px + var(--safe-t)); transform: translateX(-50%); z-index: 3;
  display: flex; flex-direction: column; align-items: center; padding: 8px 16px; border-radius: 16px;
  background: rgba(91, 42, 134, 0.92); color: #fff; font-size: 14px; text-align: center; pointer-events: none;
}
.taxi-tag span { font-size: 11px; opacity: .8; }
.icon-btn.on { background: var(--warn); color: #2a1800; }

/* Project finished: a ring and a floating number over the road */
.celebrate { position: relative; pointer-events: none; display: grid; place-items: center; }
.celebrate b {
  font: 800 18px var(--display); color: #3ddc97; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6); white-space: nowrap;
  animation: floatUp 2.5s ease-out forwards;
}
.celebrate .ring { position: absolute; width: 60px; height: 60px; border-radius: 50%; border: 3px solid #3ddc97; animation: burst 1.2s ease-out forwards; }
@keyframes floatUp { 0% { transform: translateY(10px) scale(.6); opacity: 0; } 15% { transform: translateY(0) scale(1.1); opacity: 1; } 100% { transform: translateY(-60px) scale(1); opacity: 0; } }
@keyframes burst { from { transform: scale(.3); opacity: 1; } to { transform: scale(3); opacity: 0; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06);
  border-radius: 14px; padding: 11px 16px; font-weight: 700;
  transition: transform .12s ease, background .2s ease, border-color .2s ease, opacity .2s;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover:not(:disabled) { background: #5cebab; }
.btn.ghost, .btn.primary.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.big { padding: 16px 28px; font-size: 17px; border-radius: 16px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .4; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 20px; font-weight: 600; line-height: 1;
}
.icon-btn.on { background: var(--warn); color: #2a1800; border-color: transparent; }

.lang-switch { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.lang-switch button { border: 0; background: transparent; padding: 6px 10px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--muted); }
.lang-switch button.on { background: var(--accent); color: var(--accent-ink); }

.kicker { font-size: 12px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); }
.fine { font-size: 12px; color: var(--muted); margin: 12px 0 0; }

/* ---------- title screen ---------- */
.start {
  position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: center;
  padding: calc(24px + var(--safe-t)) 20px calc(16px + var(--safe-b));
  background: linear-gradient(90deg, rgba(7, 12, 19, 0.95) 0%, rgba(7, 12, 19, 0.75) 45%, rgba(7, 12, 19, 0.1) 100%);
  overflow-y: auto;
}
.top-right { position: absolute; top: calc(16px + var(--safe-t)); right: 16px; }
.start-inner { max-width: 560px; animation: rise .7s ease both; }
.logo { font-family: var(--display); font-weight: 800; font-size: clamp(36px, 9.5vw, 62px); line-height: .98; margin: 14px 0 18px; letter-spacing: -0.02em; }
.logo span { display: block; }
.logo em {
  display: block; font-style: normal;
  background: linear-gradient(90deg, #3ddc97, #b6f36a 55%, #ffd166);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { font-size: clamp(18px, 4.6vw, 22px); font-weight: 700; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 22px; max-width: 440px; }
.start-stats { display: flex; gap: 26px; margin-bottom: 26px; }
.start-stats b { display: block; font-family: var(--display); font-size: 26px; font-weight: 800; }
.start-stats span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.start-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.meta { font-size: 13px; color: var(--muted); margin-top: 14px; }
.start-foot { position: absolute; left: 20px; right: 20px; bottom: calc(14px + var(--safe-b)); font-size: 11px; color: rgba(214, 228, 242, 0.42); max-width: 640px; }
.start-foot p { margin: 0 0 4px; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- HUD: one bar ---------- */
.hud {
  position: fixed; top: calc(10px + var(--safe-t)); left: 10px; right: 10px; z-index: 3;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-bar {
  display: flex; align-items: stretch; min-width: 0; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}
.logo-btn { flex: none; width: 52px; border: 0; background: rgba(61, 220, 151, 0.08); display: grid; place-items: center; }
.logo-btn:hover { background: rgba(61, 220, 151, 0.16); }
.stat { position: relative; min-width: 0; padding: 9px 18px 10px; border-left: 1px solid var(--line); }
.stat-label { display: block; font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .val { display: flex; align-items: baseline; gap: 4px; white-space: nowrap; min-width: 0; }
.stat b { font-family: var(--display); font-size: 21px; font-weight: 800; white-space: nowrap; }
.stat .unit { display: inline; font-size: 10px; font-weight: 700; color: var(--muted); }
.stat-label .s { display: none; }
.stat small { display: block; font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.index b { font-size: 24px; }
.stat.index.goal { background: rgba(61, 220, 151, 0.1); }
.delta { font-size: 11px; font-weight: 800; margin-left: 4px; }
.delta.up { color: var(--bad); }
.delta.down { color: var(--accent); }
.bar { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); margin-top: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s ease, background .4s; }
.bar.month { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; border-radius: 0; height: 2px; }
.bar.month span { width: 100%; transform-origin: left; transform: scaleX(0); background: rgba(255, 255, 255, 0.45); transition: none; }
.hud-tools { display: flex; gap: 8px; }
.flash { animation: flash .6s ease; }
@keyframes flash { 0% { filter: brightness(1.8); } 100% { filter: none; } }

/* ---------- first-time hint, paused tag ---------- */
.onboard {
  position: fixed; right: 10px; top: calc(66px + var(--safe-t)); width: 290px; z-index: 2; pointer-events: none;
  padding: 14px 16px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  animation: rise .5s ease both;
}
.onboard-head { display: flex; gap: 10px; align-items: center; }
.onboard-head b { font-family: var(--display); font-size: 15px; }
.onboard p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.pulse { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(61, 220, 151, .7); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 12px rgba(61, 220, 151, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0); } }
.paused-tag {
  position: fixed; left: 50%; top: calc(84px + var(--safe-t)); transform: translateX(-50%); z-index: 2;
  padding: 6px 14px; border-radius: 999px; background: var(--warn); color: #2a1800; font-weight: 800; font-size: 13px;
  letter-spacing: .1em; text-transform: uppercase; pointer-events: none;
}
.map-ctrl { position: fixed; right: 10px; bottom: calc(132px + var(--safe-b)); display: none; flex-direction: column; gap: 6px; z-index: 2; }
body.playing .map-ctrl { display: flex; }
.minimap {
  position: fixed; left: 10px; bottom: calc(66px + var(--safe-b)); z-index: 2; width: 160px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.minimap canvas { display: block; width: 148px; height: 104px; border-radius: 9px; cursor: pointer; }
.minimap-n { position: absolute; left: 50%; top: 9px; transform: translateX(-50%); font-size: 9px; font-weight: 800; letter-spacing: .14em; color: var(--muted); pointer-events: none; }

/* ---------- bottom: decisions + feed + controls ---------- */
.dock {
  position: fixed; left: 10px; right: 10px; bottom: calc(10px + var(--safe-b)); z-index: 3;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "actions actions" "feed controls";
  gap: 8px; pointer-events: none;
}
.dock > * { pointer-events: auto; }
.actions {
  grid-area: actions; justify-self: center; display: flex; gap: 4px; padding: 5px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.act { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border: 0; border-radius: 12px; background: transparent; font-weight: 700; color: var(--text); white-space: nowrap; }
.act:hover { background: rgba(255, 255, 255, 0.07); }
.act.primary { background: var(--accent); color: var(--accent-ink); }
.act.primary:hover { background: #5cebab; }
.act-ico { font-size: 16px; }
.act .count { font-style: normal; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 800; display: inline-grid; place-items: center; }
.act.alert { animation: actPulse 1.4s ease-in-out infinite; }
@keyframes actPulse { 50% { box-shadow: 0 0 0 4px rgba(255, 77, 94, 0.35); } }
.feed {
  grid-area: feed; display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 8px 14px; border-radius: 14px; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-size: 13px; overflow: hidden;
}
.feed-label { flex: none; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.feed-label::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; }
.feed-text { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.feed-text.in { animation: feedIn .45s ease both; }
.feed-text[data-kind="done"] { color: #a8f5cf; font-weight: 700; }
.feed-text[data-kind="rashid"] { color: #ffe08a; font-weight: 700; }
@keyframes feedIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.controls {
  grid-area: controls; display: flex; align-items: center; gap: 2px; padding: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.tool { width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; font-size: 17px; }
.tool:hover { background: rgba(255, 255, 255, 0.08); }
.tool.on { background: var(--warn); }
.controls .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.speed { display: flex; gap: 2px; }
.speed button { border: 0; background: transparent; border-radius: 10px; padding: 0 10px; height: 38px; font-weight: 800; font-size: 13px; color: var(--muted); }
.speed .icon-btn { width: 38px; height: 38px; border: 0; background: transparent; color: var(--text); padding: 0; backdrop-filter: none; }
.speed .icon-btn.on { background: var(--warn); color: #2a1800; }
.speed button.on:not(.icon-btn) { background: rgba(255, 255, 255, 0.12); color: var(--text); }

/* ---------- sheet ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; height: 60vh; height: 60dvh; display: flex; flex-direction: column;
  background: var(--panel-solid); border-top: 1px solid var(--line); border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
  transform: translateY(100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: var(--safe-b); z-index: 5;
}
.sheet.open { transform: none; }
.sheet-inner { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sheet-head { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 18px 16px 12px; border-bottom: 1px solid var(--line); }
.sheet-grab { position: absolute; top: 7px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: rgba(255, 255, 255, 0.18); }
.sheet-title { flex: 1; min-width: 0; }
.sheet-title h2 { font-family: var(--display); font-size: 19px; font-weight: 800; margin: 0; line-height: 1.2; }
.sheet-title p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.road-stat { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; }
.road-stat b { font-family: var(--display); font-size: 28px; font-weight: 800; }
.road-stat span { color: var(--muted); font-size: 13px; font-weight: 600; }
.meter { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin-top: 6px; }
.meter span { display: block; height: 100%; border-radius: 3px; transition: width .4s; }
.meter.small { width: 64px; height: 5px; margin: 0; flex: none; }
.sheet-body { overflow-y: auto; padding: 10px 12px 16px; -webkit-overflow-scrolling: touch; }
.sheet-pause { padding: 8px 16px 10px; font-size: 11px; color: var(--warn); text-align: center; border-top: 1px solid var(--line); font-weight: 600; }

.proj { display: grid; grid-template-columns: 40px 1fr; gap: 4px 12px; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.025); margin-bottom: 8px; }
.proj.done { border-color: rgba(61, 220, 151, 0.35); background: rgba(61, 220, 151, 0.05); }
.proj.building { border-color: rgba(255, 200, 60, 0.4); background: rgba(255, 200, 60, 0.05); }
.proj-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(61, 220, 151, 0.12); color: var(--accent); }
.proj-body h3 { margin: 1px 0 3px; font-size: 15px; font-weight: 800; }
.proj-body p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.proj-action { grid-column: 2; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn.build { padding: 8px 14px; background: var(--accent); color: var(--accent-ink); border: 0; gap: 10px; }
.btn.build small { font-weight: 600; opacity: .75; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); color: var(--muted); }
.chip svg { width: 14px; height: 14px; }
.chip.good { background: rgba(61, 220, 151, 0.13); color: #8ff0c2; }
.chip.bad { background: rgba(255, 77, 94, 0.13); color: #ff9aa5; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; }
.status svg { width: 18px; height: 18px; }
.status.done { color: var(--accent); }
.status.building { color: #ffd166; }
.why { font-size: 12px; color: var(--muted); }

.list { padding: 8px; }
.list-head { margin: 10px 12px 4px; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.road-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px; border: 0; border-radius: 12px; background: transparent; text-align: left; }
.road-row:hover { background: rgba(255, 255, 255, 0.05); }
.road-row .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.road-row .road-name { flex: 1; min-width: 0; font-weight: 700; }
.road-row b { font-family: var(--display); width: 48px; text-align: right; font-size: 15px; }
.tag-build, .tag-n { font-style: normal; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.tag-build { color: #ffd166; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(3, 7, 12, 0.6); z-index: 10; opacity: 0; transition: opacity .2s; }
.modal.open { opacity: 1; }
.modal-card {
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: 22px; padding: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55); transform: translateY(10px) scale(.98); transition: transform .25s ease;
}
.modal.open .modal-card { transform: none; }
.modal h2 { font-family: var(--display); font-weight: 800; font-size: 22px; line-height: 1.2; margin: 6px 0 10px; }
.modal p { margin: 0 0 12px; }

.intro { display: grid; gap: 16px; }
.intro .avatar { width: 96px; height: 96px; }
.intro .avatar svg { width: 100%; height: 100%; display: block; }
.who { display: flex; flex-direction: column; }
.who b { color: #ffe08a; }
.who span { font-size: 12px; color: var(--muted); }
.intro .tip { padding: 10px 12px; border-radius: 12px; background: rgba(255, 224, 138, 0.08); border-left: 3px solid #ffe08a; }
.intro .how { display: flex; gap: 10px; align-items: flex-start; color: var(--muted); font-size: 14px; }
.intro .how svg { flex: none; color: var(--accent); }

.event { text-align: left; }
.event-emoji { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; font-size: 34px; background: rgba(255, 255, 255, 0.06); margin-bottom: 12px; }
.event p { color: rgba(238, 243, 248, 0.86); }
.choices { display: grid; gap: 8px; margin-top: 16px; }
.choice {
  display: grid; grid-template-columns: 32px 1fr; gap: 6px 10px; align-items: start; text-align: left;
  padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04);
  transition: border-color .15s, background .15s, transform .12s;
}
.choice:hover:not(:disabled) { border-color: rgba(61, 220, 151, 0.6); background: rgba(61, 220, 151, 0.06); }
.choice:active:not(:disabled) { transform: scale(.98); }
.choice:disabled { opacity: .45; }
.choice-key { grid-row: span 2; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: rgba(255, 255, 255, 0.08); }
.choice-text { font-weight: 700; }
.choice .chips, .choice .why { grid-column: 2; }

.menu { display: grid; gap: 14px; }
.menu h2 { margin: 0; }
.menu .lang-switch { justify-self: start; }
.menu-actions { display: grid; gap: 8px; }
.menu-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.menu-tools .btn { flex: 1; }
.help ul { padding-left: 18px; margin: 0 0 8px; }
.help li { margin-bottom: 8px; }

/* ---------- end ---------- */
.end { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(5, 9, 15, 0.72); z-index: 8; overflow-y: auto; }
.end-card { width: min(520px, 100%); background: var(--panel-solid); border: 1px solid var(--line); border-radius: 26px; padding: 26px 22px; animation: rise .5s ease both; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55); }
.end-card h1 { font-family: var(--display); font-weight: 800; font-size: clamp(28px, 8vw, 40px); line-height: 1.05; margin: 10px 0 8px; }
.end-desc { color: var(--muted); margin: 0 0 18px; }
.end-index { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.end-index span { color: var(--muted); font-weight: 700; font-size: 13px; }
.end-index b { font-family: var(--display); font-size: 30px; }
.end-index s { color: var(--muted); font-size: 22px; }
.end-index em { font-style: normal; }
.spark { width: 100%; height: 90px; margin: 10px 0 14px; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.goal-line { stroke: rgba(255, 255, 255, 0.25); stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.end-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.end-stats div { padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); }
.end-stats span { display: block; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.end-stats b { font-family: var(--display); font-size: 18px; }
.end-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.end-actions .btn { flex: 1; min-width: 150px; padding: 14px; }

/* ---------- phones ---------- */
@media (max-width: 639px) {
  .hud { left: 6px; right: 6px; top: calc(6px + var(--safe-t)); }
  .hud-bar { flex: 1; }
  .logo-btn { width: 38px; }
  .stat { flex: 1; padding: 7px 8px 8px; }
  .stat b { font-size: 16px; }
  .stat.index b { font-size: 18px; }
  .stat-label { font-size: 9px; letter-spacing: .03em; }
  .stat-label .l { display: none; }
  .stat-label .s { display: inline; }
  .stat .yr, .stat.index .delta, .clock-stat, .hud-tools { display: none; }
  #hudMonthName { display: none; }
  .clock-mini { display: block !important; }
  .stat .unit { font-size: 9px; }
  .onboard { left: 6px; right: 6px; width: auto; top: calc(66px + var(--safe-t)); padding: 10px 12px; }
  .onboard p { font-size: 12px; }
  .toast, .taxi-tag, .paused-tag { top: calc(70px + var(--safe-t)); }
  .dock { left: 6px; right: 6px; bottom: calc(6px + var(--safe-b)); grid-template-areas: "feed controls" "actions actions"; gap: 6px; }
  .controls { padding: 2px; }
  .speed button { height: 34px; font-size: 12px; }
  .speed .icon-btn { width: 34px; height: 34px; }
  .actions { justify-self: stretch; padding: 4px; }
  .act { flex: 1; justify-content: center; padding: 10px 8px; gap: 6px; }
  #btnIncidents { flex: 0 0 auto; }
  #btnIncidents [data-t] { display: none; }
  .controls .tool, .controls .sep { display: none; }
  .speed button { padding: 0 6px; }
  .feed { min-height: 40px; padding: 5px 10px; font-size: 12px; }
  .feed-label { display: none; }
  .onboard p { display: none; }
  body.playing .maplibregl-ctrl-bottom-right { bottom: calc(108px + var(--safe-b)); }
  .start { background: linear-gradient(180deg, rgba(7, 12, 19, 0.05) 0%, rgba(7, 12, 19, 0.35) 25%, rgba(7, 12, 19, 0.9) 50%, rgba(7, 12, 19, 0.94) 100%); justify-content: flex-end; padding-bottom: calc(120px + var(--safe-b)); }
}

@media (min-width: 640px) {
  .start { padding-left: 7vw; }
  .start-foot { left: 7vw; }
  .intro { grid-template-columns: 110px 1fr; }
  .intro .avatar { width: 110px; height: 110px; }
  .modal-card { padding: 28px; }
}

@media (max-width: 899px) { .minimap { display: none; } .map-ctrl { display: none !important; } }

@media (min-width: 900px) {
  .sheet {
    left: auto; top: calc(80px + var(--safe-t)); right: 10px; bottom: calc(120px + var(--safe-b)); width: 400px; height: auto; max-height: none;
    border: 1px solid var(--line); border-radius: 20px; transform: translateX(calc(100% + 24px));
  }
  .sheet.open { transform: none; }
  .sheet-grab { display: none; }
  body.sheet-open .map-ctrl, body.sheet-open .onboard { display: none !important; }
}

@media (max-width: 380px) {
  .stat-label { font-size: 8.5px; }
  .stat b { font-size: 14px; }
  .stat.index b { font-size: 16px; }
  .feed-label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
