/* ==========================================================================
   Aurora Skyline — Flagship Obsidian Glassmorphic City Builder HUD
   Inspired by Cities: Skylines II, Pocket City 2 & SimCity
   ========================================================================== */

@font-face {
  font-family: 'Lilita One';
  src: url('./assets/fonts/lilita_one_regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-glass: rgba(14, 19, 30, 0.84);
  --bg-glass-strong: rgba(11, 16, 26, 0.92);
  --bg-surface: rgba(255, 255, 255, 0.045);
  --bg-surface-hover: rgba(255, 255, 255, 0.095);
  --bg-surface-active: rgba(56, 189, 248, 0.18);

  --border-subtle: rgba(255, 255, 255, 0.11);
  --border-strong: rgba(255, 255, 255, 0.22);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-r: #34d399;       /* Emerald Residential */
  --accent-c: #38bdf8;       /* Cobalt Commercial */
  --accent-i: #fbbf24;       /* Amber Industrial */
  --accent-alert: #f87171;   /* Crimson Alert */
  --accent-gold: #f59e0b;    /* Gold Milestone */
  --accent-violet: #a78bfa;  /* Civic / Wonders */

  --shadow-panel: 0 12px 32px rgba(2, 6, 16, 0.52), 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --font-display: 'Lilita One', system-ui, -apple-system, sans-serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #090e18;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

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

button {
  cursor: pointer;
  border: none;
  background: transparent;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Core Layout & Canvas
   ========================================================================== */

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#viewport-canvas-wrap {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: radial-gradient(circle at 50% 35%, #16243b 0%, #090e18 100%);
  touch-action: none;
}

#viewport-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

#hud-root {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-panel);
  pointer-events: auto;
}

/* Custom sleek scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* ==========================================================================
   TOP TELEMETRY BAR
   ========================================================================== */

#top-bar {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  height: 54px;
  border-radius: var(--radius-lg);
  padding: 0 9px;
  display: flex;
  align-items: center;
  gap: 5px;
  z-index: 30;
}

.tb-divider {
  width: 1px;
  height: 28px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

/* City Identity */
.tb-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-shrink: 0;
}

.city-crest {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.28), rgba(52, 211, 153, 0.22));
  border: 1px solid rgba(56, 189, 248, 0.36);
  display: grid;
  place-items: center;
  color: #7dd3fc;
  flex-shrink: 0;
}

.city-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.city-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.city-name-btn {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.02em;
  color: #fff;
  padding: 1px 4px;
  margin: -1px -4px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 155px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s;
}
.city-name-btn:hover {
  background: var(--bg-surface-hover);
}

.city-name-input {
  font-family: var(--font-display);
  font-size: 15px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent-c);
  border-radius: 6px;
  padding: 1px 6px;
  width: 135px;
  color: #fff;
  outline: none;
}

.tier-badge {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.42);
  color: #fcd34d;
  white-space: nowrap;
  flex-shrink: 0;
}

.milestone-progress-track {
  width: 100%;
  min-width: 110px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.milestone-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #f59e0b, #fbbf24, #34d399);
  transition: width 0.35s ease;
}

/* Telemetry Pills */
.tb-pill {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
  text-align: left;
}
button.tb-pill:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.pill-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.pill-values {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.val-primary {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.val-delta {
  font-size: 11px;
  font-weight: 600;
}
.val-delta.pos { color: var(--accent-r); }
.val-delta.neg { color: var(--accent-alert); }
.val-delta.neutral { color: var(--text-secondary); }

.val-sub {
  font-size: 11px;
  color: var(--text-secondary);
}

.tb-pop {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.pop-col {
  display: flex;
  flex-direction: column;
}

.happiness-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 8px;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.25);
  font-size: 12px;
  font-weight: 700;
  color: #6ee7b7;
}
.happiness-chip.warn {
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.35);
  color: #fde68a;
}
.happiness-chip.bad {
  background: rgba(248, 113, 113, 0.16);
  border-color: rgba(248, 113, 113, 0.4);
  color: #fca5a5;
}

/* R / C / I Demand Bars */
.tb-demand {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  height: 38px;
  flex-shrink: 0;
}

.demand-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.demand-track {
  position: relative;
  width: 8px;
  height: 20px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}

.demand-zero {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: rgba(255, 255, 255, 0.28);
  z-index: 2;
}

.demand-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 50%;
  height: 0%;
  transition: height 0.25s ease, bottom 0.25s ease, top 0.25s ease;
  border-radius: 2px;
}
.demand-r { background: var(--accent-r); box-shadow: 0 0 6px rgba(52, 211, 153, 0.5); }
.demand-c { background: var(--accent-c); box-shadow: 0 0 6px rgba(56, 189, 248, 0.5); }
.demand-i { background: var(--accent-i); box-shadow: 0 0 6px rgba(251, 191, 36, 0.5); }

.demand-lbl {
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}
.lbl-r { color: var(--accent-r); }
.lbl-c { color: var(--accent-c); }
.lbl-i { color: var(--accent-i); }

/* Power & Water Mini-Pills */
.tb-utilities {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

.util-mini {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.26);
  color: #a7f3d0;
  transition: transform 0.12s, background 0.15s;
}
.util-mini:hover { transform: translateY(-1px); }
.util-mini.warn {
  background: rgba(251, 191, 36, 0.16);
  border-color: rgba(251, 191, 36, 0.42);
  color: #fde68a;
}
.util-mini.deficit {
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.55);
  color: #fecaca;
  animation: pulse-alert 1.5s infinite;
}

@keyframes pulse-alert {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.35); }
  50% { box-shadow: 0 0 0 4px rgba(248, 113, 113, 0); }
}

/* Clock & Time of Day */
.tb-clock {
  flex-direction: row;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
}

.clock-ico {
  font-size: 15px;
}

.clock-text {
  display: flex;
  flex-direction: column;
}

.val-date {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.val-sub-mini {
  font-size: 10px;
  color: var(--text-secondary);
}

/* Speed Controls */
.speed-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.spd-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  transition: background 0.12s, color 0.12s;
}
.spd-btn:hover {
  background: var(--bg-surface-hover);
  color: #fff;
}
.spd-btn.active {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #082f49;
  font-weight: 800;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.4);
}
.spd-btn[data-speed="0"].active {
  background: linear-gradient(135deg, #d97706, #fbbf24);
  color: #451a03;
  box-shadow: 0 2px 10px rgba(251, 191, 36, 0.35);
}

.turbo-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 3px 7px;
  margin-left: 2px;
  border-radius: 6px;
  background: linear-gradient(135deg, #db2777, #f43f5e);
  color: #fff;
  letter-spacing: 0.03em;
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.45);
}

/* Quick Action Icons */
.tb-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.icon-btn {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
  display: grid;
  place-items: center;
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}
.icon-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.icon-btn.active {
  background: var(--bg-surface-active);
  border-color: var(--accent-c);
  color: #7dd3fc;
}
.icon-btn.qa-trigger.active {
  background: rgba(167, 139, 250, 0.22);
  border-color: var(--accent-violet);
  color: #ddd6fe;
}

.btn-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--accent-gold);
  color: #1c1917;
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

/* Overlay Dropdown */
.overlay-dropdown-wrap {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 210px;
  border-radius: var(--radius-md);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 60;
}

.overlay-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-primary);
  text-align: left;
  transition: background 0.12s;
}
.overlay-item:hover {
  background: var(--bg-surface-hover);
}
.overlay-item.active {
  background: var(--bg-surface-active);
  color: #7dd3fc;
  font-weight: 700;
}
.overlay-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ==========================================================================
   OVERLAY LEGEND STRIP
   ========================================================================== */

#overlay-legend {
  position: absolute;
  top: var(--hud-top-offset, 74px);
  left: 50%;
  transform: translateX(-50%);
  border-radius: 14px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 25;
  transition: top 0.2s ease;
}

.legend-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #e2e8f0;
  white-space: nowrap;
}

.legend-ramp-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 210px;
}

.legend-scale-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.legend-bound {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  line-height: 1.1;
}
.legend-bound.legend-mid {
  color: #cbd5e1;
  text-align: center;
}
.legend-bound.legend-high {
  color: #f1f5f9;
  text-align: right;
}

.legend-bar {
  width: 100%;
  height: 7px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.legend-clear {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.legend-clear:hover {
  background: rgba(248, 113, 113, 0.25);
  color: #fff;
}

/* ==========================================================================
   ACTIVE EVENT CHIPS (Top-Left)
   ========================================================================== */

#event-banners {
  position: absolute;
  top: var(--hud-top-offset, 74px);
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  pointer-events: none;
  z-index: 28;
  max-width: 310px;
  transition: left 0.22s cubic-bezier(0.22, 1, 0.36, 1), top 0.2s ease;
}

body.qa-drawer-open #event-banners {
  left: 336px;
  max-width: min(310px, calc(100vw - 352px));
}

/* ==========================================================================
   QUICK-START MAYOR GUIDE PILL (Top-Right, Fresh Cities)
   ========================================================================== */

.quickstart-guide {
  position: absolute;
  top: var(--hud-top-offset, 74px);
  right: 14px;
  width: 236px;
  border-radius: 13px;
  padding: 9px 11px 10px;
  z-index: 24;
  border-color: rgba(52, 211, 153, 0.32);
  background: linear-gradient(155deg, rgba(12, 24, 34, 0.9), rgba(11, 16, 26, 0.88));
  transition: top 0.2s ease, opacity 0.18s ease, transform 0.18s ease;
}

body.inspector-open .quickstart-guide {
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px);
}

.qs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 7px;
}

.qs-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.qs-badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(52, 211, 153, 0.18);
  border: 1px solid rgba(52, 211, 153, 0.42);
  color: #6ee7b7;
}

.qs-title {
  font-size: 11.5px;
  font-weight: 800;
  color: #f8fafc;
}

.qs-progress {
  font-size: 10.5px;
  font-weight: 700;
  color: #7dd3fc;
}

.qs-close {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.qs-close:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.qs-checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.qs-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 6px;
  border-radius: 7px;
  font-size: 11.5px;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.qs-item:hover:not(.done) {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.3);
  color: #fff;
}
.qs-item.done {
  background: rgba(52, 211, 153, 0.09);
  border-color: rgba(52, 211, 153, 0.22);
  color: #86efac;
  cursor: default;
}
.qs-item.done .qs-label {
  text-decoration: line-through;
  opacity: 0.82;
}

.qs-check {
  width: 14px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: #38bdf8;
  flex-shrink: 0;
}
.qs-item.done .qs-check {
  color: #34d399;
}

.qs-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-chip {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 11px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow-panel);
  font-size: 12px;
}
.event-chip.chip-enter {
  animation: slideInLeft 0.25s ease-out;
}
.event-chip.danger {
  border-color: rgba(248, 113, 113, 0.55);
  background: linear-gradient(135deg, rgba(69, 10, 10, 0.88), rgba(14, 19, 30, 0.9));
}
.event-chip.warn {
  border-color: rgba(251, 191, 36, 0.5);
  background: linear-gradient(135deg, rgba(69, 26, 3, 0.85), rgba(14, 19, 30, 0.9));
}
.event-chip.good {
  border-color: rgba(52, 211, 153, 0.5);
  background: linear-gradient(135deg, rgba(6, 78, 59, 0.85), rgba(14, 19, 30, 0.9));
}

.event-chip-text {
  flex: 1;
  min-width: 0;
}
.event-chip-title {
  font-weight: 700;
  color: #fff;
}
.event-chip-sub {
  font-size: 10.5px;
  color: var(--text-secondary);
}

.event-chip-btn {
  padding: 4px 8px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.event-chip-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ==========================================================================
   MILESTONE CELEBRATION TOAST
   ========================================================================== */

.milestone-toast {
  position: absolute;
  top: var(--hud-top-offset, 76px);
  left: 50%;
  transform: translateX(-50%);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(245, 158, 11, 0.55);
  background: linear-gradient(135deg, rgba(30, 24, 12, 0.94), rgba(14, 19, 30, 0.92));
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.65), 0 0 28px rgba(245, 158, 11, 0.25);
  z-index: 45;
  overflow: hidden;
  max-width: 520px;
  animation: milestonePop 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes milestonePop {
  from { opacity: 0; transform: translate(-50%, -18px) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.milestone-crown {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #451a03;
  font-size: 22px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.5);
}

.milestone-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #fbbf24;
}

.milestone-title {
  font-family: var(--font-display);
  font-size: 20px;
  color: #fff;
  line-height: 1.15;
}

.milestone-detail {
  font-size: 12px;
  color: #e2e8f0;
  margin-top: 2px;
}

.close-x {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.close-x:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

/* ==========================================================================
   FLOATING RIGHT-SIDE TILE INSPECTOR
   ========================================================================== */

.inspector-panel {
  position: absolute;
  top: var(--hud-top-offset, 76px);
  right: 14px;
  width: 312px;
  max-height: calc(100vh - 220px);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 26;
  animation: slideInRight 0.2s ease-out;
  transition: top 0.2s ease;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.025);
}

.insp-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.insp-title-wrap > div {
  min-width: 0;
  overflow: hidden;
}

.insp-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-subtle);
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}

.panel-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
}

.insp-body {
  padding: 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.insp-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.insp-stat-box {
  padding: 7px 9px;
  border-radius: 9px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.insp-stat-box span {
  display: block;
  font-size: 10px;
  color: var(--text-secondary);
}
.insp-stat-box strong {
  font-size: 14px;
  color: #fff;
}

.insp-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid transparent;
}
.status-pill.ok {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.35);
  color: #6ee7b7;
}
.status-pill.bad {
  background: rgba(248, 113, 113, 0.16);
  border-color: rgba(248, 113, 113, 0.42);
  color: #fca5a5;
}
.status-pill.info {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.35);
  color: #7dd3fc;
}

.upgrade-box {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.22);
}

.upgrade-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 5px;
}

.mini-bar-track {
  width: 100%;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.25s ease;
}

.heatmap-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hm-row {
  display: grid;
  grid-template-columns: 78px 1fr 30px;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}
.hm-label {
  color: var(--text-secondary);
}
.hm-val {
  text-align: right;
  font-weight: 700;
  color: #e2e8f0;
}

.diag-box {
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.09);
  border: 1px solid rgba(245, 158, 11, 0.28);
  font-size: 11.5px;
  color: #fde68a;
}
.diag-box.good {
  background: rgba(52, 211, 153, 0.09);
  border-color: rgba(52, 211, 153, 0.28);
  color: #a7f3d0;
}
.diag-box ul {
  margin: 4px 0 0 15px;
  padding: 0;
}
.diag-box li {
  margin-bottom: 2px;
}

.insp-footer {
  display: flex;
  gap: 7px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.insp-btn {
  flex: 1;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-subtle);
  color: #fff;
  transition: background 0.14s;
}
.insp-btn:hover { background: rgba(255, 255, 255, 0.16); }
.insp-btn.danger {
  background: rgba(248, 113, 113, 0.18);
  border-color: rgba(248, 113, 113, 0.42);
  color: #fecaca;
}
.insp-btn.danger:hover { background: rgba(248, 113, 113, 0.3); }
.insp-btn.accent {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.45);
  color: #bae6fd;
}

/* ==========================================================================
   QA & GOD MODE DRAWER (Left-Side, F9)
   ========================================================================== */

.qa-drawer {
  position: absolute;
  top: var(--hud-top-offset, 76px);
  left: 14px;
  width: 304px;
  max-height: calc(100vh - var(--hud-top-offset, 76px) - 108px);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 35;
  border-color: rgba(167, 139, 250, 0.35);
  animation: slideInLeft 0.2s ease-out;
  transition: top 0.2s ease;
}

.qa-scroll {
  padding: 10px 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.qa-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.qa-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.qa-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #c4b5fd;
}

.qa-btn-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.qa-chip {
  padding: 6px 0;
  border-radius: 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
}
.qa-chip:hover { background: var(--bg-surface-hover); color: #fff; }
.qa-chip.active {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  border-color: #c4b5fd;
  color: #fff;
}

.qa-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--bg-surface);
  cursor: pointer;
}
.qa-toggle input {
  accent-color: #a78bfa;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.qa-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.qa-action-btn {
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 11.5px;
  font-weight: 700;
  color: #e2e8f0;
  transition: background 0.12s;
}
.qa-action-btn:hover { background: var(--bg-surface-hover); }
.qa-action-btn.accent {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  border-color: #7dd3fc;
  color: #082f49;
}
.qa-action-btn.running {
  background: linear-gradient(135deg, #dc2626, #f87171);
  border-color: #fca5a5;
  color: #fff;
}

.qa-autobuild-row {
  display: flex;
  gap: 6px;
}

.qa-select {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
  font-size: 11.5px;
  color: #fff;
}

.qa-status-line {
  font-size: 11px;
  color: var(--text-secondary);
}

.qa-event-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}
.qa-evt-btn {
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 600;
  text-align: left;
}
.qa-evt-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}
.qa-evt-btn.span-2 {
  grid-column: span 2;
  text-align: center;
}

.qa-slider {
  width: 100%;
  accent-color: #38bdf8;
  cursor: pointer;
}

.qa-telemetry-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.telem-box {
  padding: 5px 4px;
  border-radius: 7px;
  background: var(--bg-surface);
  text-align: center;
}
.telem-box span {
  display: block;
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.telem-box strong {
  font-size: 12.5px;
  color: #fff;
}

.inv-pill {
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 9.5px;
  font-weight: 800;
}
.inv-pill.ok { background: rgba(52, 211, 153, 0.2); color: #6ee7b7; }
.inv-pill.fail { background: rgba(248, 113, 113, 0.25); color: #fecaca; }

.qa-invariants-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 10.5px;
}
.inv-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.inv-dot.ok { background: var(--accent-r); box-shadow: 0 0 6px rgba(52, 211, 153, 0.7); }
.inv-dot.fail { background: var(--accent-alert); box-shadow: 0 0 6px rgba(248, 113, 113, 0.8); }
.inv-name {
  flex: 1;
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inv-detail {
  color: var(--text-muted);
  font-size: 10px;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   BOTTOM NEWS TICKER
   ========================================================================== */

.news-ticker {
  position: absolute;
  bottom: 12px;
  left: 14px;
  max-width: 260px;
  padding: 7px 12px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 20;
  transition: bottom 0.2s ease, max-width 0.2s ease;
}

.ticker-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ticker-dot.info { background: var(--accent-c); box-shadow: 0 0 8px var(--accent-c); }
.ticker-dot.good { background: var(--accent-r); box-shadow: 0 0 8px var(--accent-r); }
.ticker-dot.warn { background: var(--accent-i); box-shadow: 0 0 8px var(--accent-i); }
.ticker-dot.alert { background: var(--accent-alert); box-shadow: 0 0 8px var(--accent-alert); }

.ticker-text {
  font-size: 11.5px;
  color: #e2e8f0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  transition: opacity 0.25s;
}

/* ==========================================================================
   BOTTOM CATEGORY BUILD DOCK
   ========================================================================== */

#build-dock-wrap {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  pointer-events: none;
  z-index: 25;
  max-width: calc(100vw - 440px);
}

.tool-hint-pill {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
}

.hint-tool-name {
  font-weight: 800;
  color: #fff;
}

.hint-sep { opacity: 0.4; }

.hint-tool-desc {
  overflow: hidden;
  text-overflow: ellipsis;
}

.hint-drag-cost {
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(56, 189, 248, 0.2);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #bae6fd;
  font-weight: 700;
}

.build-dock {
  border-radius: var(--radius-lg);
  padding: 7px 10px 9px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-width: 100%;
}

.dock-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.dock-tabs::-webkit-scrollbar {
  display: none;
}

.dock-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.dock-tab:hover {
  background: var(--bg-surface-hover);
  color: #fff;
}
.dock-tab.active {
  background: var(--bg-surface-active);
  border-color: rgba(56, 189, 248, 0.45);
  color: #e0f2fe;
}
.dock-tab[data-cat="bulldoze"].active {
  background: rgba(248, 113, 113, 0.22);
  border-color: rgba(248, 113, 113, 0.55);
  color: #fecaca;
}

.tool-shelf {
  display: flex;
  align-items: stretch;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
  min-height: 88px;
}
.tool-shelf::-webkit-scrollbar {
  display: none;
}

.tool-shelf.compact-empty {
  min-height: 0;
  display: none;
}

.tool-card {
  position: relative;
  min-width: 112px;
  max-width: 128px;
  padding: 25px 8px 8px;
  border-radius: 11px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  text-align: center;
  flex-shrink: 0;
  transition: transform 0.12s, background 0.14s, border-color 0.14s, box-shadow 0.14s;
}
.tool-card:hover:not(.locked) {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}
.tool-card.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent-c);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.35), 0 6px 16px rgba(2, 132, 199, 0.28);
}
.tool-card.locked {
  background: rgba(15, 23, 42, 0.56);
  border-color: rgba(245, 158, 11, 0.24);
  cursor: not-allowed;
}
.tool-card.locked .tool-card-ico,
.tool-card.locked .tool-card-name,
.tool-card.locked .tool-card-meta {
  opacity: 0.55;
}

.tool-card-ico {
  font-size: 20px;
  line-height: 1.1;
}

.tool-card-name {
  font-size: 11px;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.tool-card-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
}
.tool-cost {
  font-weight: 700;
  color: #6ee7b7;
}
.tool-cost.unaffordable {
  color: var(--accent-alert);
}
.tool-upkeep {
  color: var(--text-muted);
}

.footprint-badge {
  position: absolute;
  top: 5px;
  left: 5px;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.1;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #cbd5e1;
  pointer-events: none;
}

.tool-lock-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: rgba(45, 28, 6, 0.92);
  border: 1px solid rgba(245, 158, 11, 0.55);
  color: #fcd34d;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}

/* ==========================================================================
   MODALS
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(4, 8, 16, 0.62);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  padding: 20px;
  pointer-events: auto;
}

.modal-dialog {
  width: min(760px, 95vw);
  max-height: min(84vh, 720px);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-color: rgba(255, 255, 255, 0.16);
  background: var(--bg-glass-strong);
  animation: modalIn 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-icon {
  font-size: 20px;
}

.modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: 0.02em;
  color: #fff;
}

.modal-body {
  padding: 16px 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Budget Modal Specifics */
.budget-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 14px;
}

.card-box {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.card-box h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #93c5fd;
}

.slider-row {
  display: grid;
  grid-template-columns: 112px 1fr 48px;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
}
.slider-row:last-child { margin-bottom: 0; }
.slider-row input[type="range"] {
  width: 100%;
  accent-color: #38bdf8;
  cursor: pointer;
}
.slider-val {
  text-align: right;
  font-weight: 700;
}

.ledger-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.07);
  font-size: 12.5px;
}
.ledger-row.total {
  border-bottom: none;
  border-top: 1px solid var(--border-strong);
  margin-top: 6px;
  padding-top: 8px;
  font-weight: 800;
  font-size: 14px;
}

.sparkline-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.spark-card {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(9, 14, 24, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.spark-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.bonds-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.bond-card {
  padding: 11px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bond-card.locked { opacity: 0.5; }
.bond-title { font-weight: 800; font-size: 14px; color: #fff; }
.bond-meta { font-size: 11px; color: var(--text-secondary); }

.primary-btn {
  padding: 7px 12px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #082f49;
  font-weight: 800;
  font-size: 12px;
  transition: filter 0.12s;
}
.primary-btn:hover:not(:disabled) { filter: brightness(1.1); }
.primary-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.secondary-btn {
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-subtle);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}
.secondary-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }

/* Ordinances Grid */
.ordinances-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.ord-card {
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.ord-card:hover { background: var(--bg-surface-hover); }
.ord-card.active {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.55);
}
.ord-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.ord-name { font-weight: 800; font-size: 13px; color: #fff; }
.ord-cost { font-size: 11px; font-weight: 700; color: #fbbf24; }
.ord-desc { font-size: 11.5px; color: var(--text-secondary); }

/* Missions List */
.missions-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.mission-card {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.mission-card.done {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.09);
}
.mission-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mission-title { font-weight: 800; font-size: 13.5px; color: #fff; }
.mission-reward {
  font-size: 11.5px;
  font-weight: 800;
  color: #fcd34d;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(245, 158, 11, 0.18);
}

/* Maps & Save/Load Modal */
.maps-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.map-card {
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-card.current {
  border-color: var(--accent-c);
  background: rgba(56, 189, 248, 0.1);
}

.save-slots-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.save-slot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.io-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Dilemma Modal */
.dilemma-desc {
  font-size: 13.5px;
  color: #e2e8f0;
  line-height: 1.5;
  margin: 0;
}

.dilemma-choices {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.dilemma-btn {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.14);
  text-align: left;
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}
.dilemma-btn:hover {
  background: var(--bg-surface-active);
  border-color: var(--accent-c);
  transform: translateX(3px);
}
.dilemma-btn-label {
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  margin-bottom: 3px;
}
.dilemma-btn-effect {
  font-size: 12px;
  color: #bae6fd;
}

/* ==========================================================================
   CURSOR TOOLTIP & TOASTS
   ========================================================================== */

.cursor-tooltip {
  position: fixed;
  z-index: 95;
  pointer-events: none;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(11, 16, 26, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #f8fafc;
  font-size: 11.5px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}
.cursor-tooltip.invalid {
  border-color: rgba(248, 113, 113, 0.65);
  color: #fecaca;
}

.toast-stack {
  position: fixed;
  bottom: 268px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
  z-index: 70;
}

.toast-item {
  padding: 8px 13px;
  border-radius: 10px;
  background: var(--bg-glass-strong);
  border: 1px solid var(--border-strong);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-panel);
  animation: toastIn 0.22s ease-out;
}
.toast-item.good { border-color: rgba(52, 211, 153, 0.55); color: #a7f3d0; }
.toast-item.warn { border-color: rgba(251, 191, 36, 0.55); color: #fde68a; }
.toast-item.error { border-color: rgba(248, 113, 113, 0.6); color: #fecaca; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   RESPONSIVE ADAPTATIONS (Desktop Compact, Tablet <=1220px, Narrow <=820px)
   ========================================================================== */

@media (max-width: 1320px) {
  #top-bar {
    gap: 7px;
    padding: 0 9px;
  }
  .tb-pill {
    padding: 4px 8px;
  }
  .city-name-btn {
    max-width: 118px;
    font-size: 15px;
  }
  .milestone-progress-track {
    min-width: 85px;
  }
  .val-primary {
    font-size: 13px;
  }
  .icon-btn {
    width: 31px;
    height: 31px;
    font-size: 14px;
  }
  .spd-btn {
    width: 25px;
    height: 25px;
  }
}

@media (max-width: 1220px) {
  #top-bar {
    height: auto;
    min-height: 48px;
    flex-wrap: wrap;
    padding: 7px 10px;
    gap: 6px 8px;
    row-gap: 6px;
  }
  .tb-divider {
    display: none;
  }
  .tb-identity {
    flex-shrink: 0;
  }
  .tb-pill {
    padding: 4px 8px;
  }
  .city-name-btn {
    max-width: 124px;
    font-size: 14.5px;
  }
  .tb-actions {
    margin-left: auto;
    gap: 4px;
  }
  .icon-btn {
    width: 30px;
    height: 30px;
    font-size: 13.5px;
  }
  .spd-btn {
    width: 25px;
    height: 25px;
  }

  #event-banners {
    top: var(--hud-top-offset, 112px);
  }
  #overlay-legend {
    top: var(--hud-top-offset, 112px);
  }
  .milestone-toast {
    top: var(--hud-top-offset, 114px);
  }
  .inspector-panel {
    top: var(--hud-top-offset, 114px);
    max-height: calc(100vh - 280px);
  }
  .qa-drawer {
    top: var(--hud-top-offset, 114px);
    max-height: calc(100vh - 210px);
  }
  .quickstart-guide {
    top: var(--hud-top-offset, 114px);
  }

  /* Center full-width scrollable bottom dock & lift News Ticker safely above it */
  #build-dock-wrap {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: calc(100vw - 24px);
  }
  .build-dock {
    max-width: calc(100vw - 24px);
  }
  .dock-tabs {
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tool-shelf {
    overflow-x: auto;
    scrollbar-width: none;
  }
  .news-ticker {
    bottom: 98px;
    left: 12px;
    max-width: min(340px, calc(100vw - 24px));
    transition: bottom 0.2s ease;
  }
  body.dock-shelf-open .news-ticker {
    bottom: 204px;
  }
  .toast-stack {
    bottom: 210px;
  }
  .budget-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  #top-bar {
    top: 6px;
    left: 6px;
    right: 6px;
    padding: 6px 8px;
    gap: 5px 6px;
    border-radius: 13px;
  }
  .city-crest {
    display: none;
  }
  .pill-label {
    display: none;
  }
  .val-sub {
    display: none;
  }
  .val-sub-mini {
    display: none;
  }
  .city-name-btn {
    max-width: 102px;
    font-size: 13.5px;
  }
  .milestone-progress-track {
    min-width: 72px;
  }
  .tier-badge {
    font-size: 9px;
    padding: 2px 5px;
  }
  .tb-pill {
    padding: 3px 6px;
  }
  .val-primary {
    font-size: 12.5px;
  }
  .val-delta {
    font-size: 10px;
  }
  .happiness-chip {
    padding: 2px 5px;
    font-size: 11px;
  }
  .tb-demand {
    height: 30px;
    padding: 3px 6px;
    gap: 5px;
  }
  .demand-track {
    height: 15px;
    width: 7px;
  }
  .util-mini {
    font-size: 9.5px;
    padding: 1px 5px;
  }
  .tb-clock {
    padding: 3px 6px;
  }
  .val-date {
    font-size: 11px;
  }
  .spd-btn {
    min-width: 36px;
    min-height: 36px;
    width: 36px;
    height: 36px;
    font-size: 13px;
  }
  .icon-btn {
    min-width: 36px;
    min-height: 36px;
    width: 36px;
    height: 36px;
    font-size: 15px;
  }
  .close-x {
    min-width: 36px;
    min-height: 36px;
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
  .vc-btn,
  .vc-btn.vc-bm {
    min-width: 36px;
    min-height: 36px;
    height: 36px;
    font-size: 13px;
  }

  #event-banners {
    top: var(--hud-top-offset, 124px);
    left: 8px;
    max-width: min(290px, calc(100vw - 16px));
  }
  body.qa-drawer-open #event-banners {
    left: 316px;
    max-width: calc(100vw - 324px);
  }
  #overlay-legend {
    top: var(--hud-top-offset, 124px);
    max-width: calc(100vw - 16px);
    padding: 5px 10px;
    gap: 8px;
  }
  .legend-ramp-wrap {
    min-width: 150px;
  }
  .milestone-toast {
    top: var(--hud-top-offset, 124px);
    max-width: calc(100vw - 16px);
    padding: 10px 12px;
  }
  .inspector-panel {
    top: var(--hud-top-offset, 124px);
    right: 8px;
    width: min(300px, calc(100vw - 16px));
    max-height: calc(100vh - 300px);
  }
  .qa-drawer {
    top: var(--hud-top-offset, 124px);
    left: 8px;
    width: min(296px, calc(100vw - 16px));
    max-height: calc(100vh - 240px);
  }
  .quickstart-guide {
    top: var(--hud-top-offset, 124px);
    right: 8px;
    width: min(226px, calc(100vw - 16px));
    padding: 7px 9px 8px;
  }

  #build-dock-wrap {
    bottom: 6px;
    left: 6px;
    right: 6px;
    transform: none;
    max-width: none;
    width: auto;
  }
  .build-dock {
    width: 100%;
    max-width: 100%;
    padding: 6px 8px 7px;
  }
  .tool-hint-pill {
    max-width: 100%;
    font-size: 10.5px;
    padding: 3px 10px;
  }
  .dock-tab {
    min-height: 38px;
    padding: 7px 11px;
    font-size: 12px;
  }
  .tool-card {
    min-width: 102px;
    max-width: 116px;
    padding: 24px 6px 7px;
  }
  .news-ticker {
    bottom: 92px;
    left: 6px;
    right: 6px;
    max-width: none;
    padding: 5px 10px;
  }
  body.dock-shelf-open .news-ticker {
    bottom: 196px;
  }
  .toast-stack {
    bottom: 204px;
    right: 8px;
  }
  .ordinances-grid,
  .maps-grid,
  .bonds-grid,
  .sparkline-wrap {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body.qa-drawer-open #event-banners {
    left: 8px;
    top: auto;
    bottom: 206px;
    max-width: calc(100vw - 16px);
    z-index: 38;
  }
}

/* ==========================================================================
   NEW AAA HUD ADDITIONS: WEATHER, UNDO, AUDIO MIXER, MINIMAP, OVERLAYS, ANALYTICS
   ========================================================================== */

/* Top Bar Weather Pill & Disabled Icon State */
.tb-weather {
  flex-direction: row;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  height: 36px;
}
.weather-ico {
  font-size: 14px;
  line-height: 1;
}

.icon-btn:disabled {
  opacity: 0.36;
  cursor: not-allowed;
  transform: none !important;
}
.undo-badge {
  background: #38bdf8;
  color: #082f49;
}

/* Audio Popover Mixer */
.audio-popover-wrap {
  position: relative;
}
.audio-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 224px;
  border-radius: var(--radius-md);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  z-index: 65;
}
.ap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}
.ap-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #93c5fd;
}
.ap-mute-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(52, 211, 153, 0.16);
  border: 1px solid rgba(52, 211, 153, 0.38);
  color: #a7f3d0;
}
.ap-mute-chip.muted {
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}
.ap-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}
.ap-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.ap-toggle input {
  accent-color: #38bdf8;
  cursor: pointer;
}
.ap-val {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* Pending Dilemma Pulsing Event Chip & Unaffordable Dilemma Choice */
.event-chip.dilemma-pulse {
  border-color: rgba(251, 191, 36, 0.72);
  background: linear-gradient(135deg, rgba(66, 32, 6, 0.92), rgba(15, 23, 42, 0.94));
  animation: pulse-dilemma 1.8s infinite;
  cursor: pointer;
}
.event-chip.dilemma-pulse.chip-enter {
  animation: slideInLeft 0.25s ease-out, pulse-dilemma 1.8s infinite;
}
@keyframes pulse-dilemma {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.45), var(--shadow-panel); }
  50% { box-shadow: 0 0 0 5px rgba(251, 191, 36, 0), var(--shadow-panel); }
}

.event-chip-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.dilemma-btn-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}
.dilemma-cost-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(52, 211, 153, 0.16);
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: #6ee7b7;
  white-space: nowrap;
}
.dilemma-cost-badge.need {
  background: rgba(248, 113, 113, 0.22);
  border-color: rgba(248, 113, 113, 0.58);
  color: #fecaca;
}
.dilemma-btn.unaffordable {
  opacity: 0.65;
  border-color: rgba(248, 113, 113, 0.38);
  background: rgba(69, 10, 10, 0.26);
}
.dilemma-btn.unaffordable:hover {
  transform: none;
  border-color: rgba(248, 113, 113, 0.65);
  background: rgba(69, 10, 10, 0.38);
}

/* Delete Save Slot Button & QA Span-2 Action */
.secondary-btn.danger-sm {
  background: rgba(248, 113, 113, 0.16);
  border-color: rgba(248, 113, 113, 0.42);
  color: #fecaca;
  padding: 7px 9px;
}
.secondary-btn.danger-sm:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.3);
}
.qa-action-btn.span-2 {
  grid-column: span 2;
}

/* Clear Abandoned Dynamic Tool Card */
.tool-card.action-clear-abandoned {
  background: linear-gradient(155deg, rgba(120, 53, 15, 0.35), rgba(15, 23, 42, 0.8));
  border-color: rgba(251, 191, 36, 0.48);
}
.tool-card.action-clear-abandoned:hover {
  background: linear-gradient(155deg, rgba(146, 64, 14, 0.5), rgba(15, 23, 42, 0.9));
  border-color: rgba(251, 191, 36, 0.8);
}

/* Bottom-Right View Controls + Minimap Stack */
.bottom-right-stack {
  position: absolute;
  bottom: 12px;
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  z-index: 24;
  pointer-events: none;
}

.view-controls-bar {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 6px;
  border-radius: 11px;
  pointer-events: auto;
}
.vc-btn {
  min-width: 26px;
  height: 26px;
  padding: 0 5px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  display: grid;
  place-items: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.vc-btn:hover {
  background: var(--bg-surface-hover);
  color: #fff;
}
.vc-btn.active {
  background: var(--bg-surface-active);
  border-color: rgba(56, 189, 248, 0.5);
  color: #7dd3fc;
}
.vc-btn.vc-bm {
  min-width: 22px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.vc-btn.vc-bm.saved {
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.42);
  color: #6ee7b7;
}
.vc-sep {
  width: 1px;
  height: 16px;
  background: var(--border-subtle);
  margin: 0 2px;
}

/* Minimap Widget */
.minimap-widget {
  width: 190px;
  border-radius: 13px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
  overflow: hidden;
}
.minimap-widget.collapsed {
  width: auto;
}
.minimap-widget.collapsed .minimap-body {
  display: none;
}
.minimap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 1px 4px;
}
.minimap-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.minimap-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.75);
}
.minimap-title {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #cbd5e1;
}
.minimap-toggle {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 12px;
  display: grid;
  place-items: center;
}
.minimap-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}
.minimap-body {
  position: relative;
  width: 176px;
  height: 176px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #0c1624;
}
#minimap-canvas {
  display: block;
  width: 176px;
  height: 176px;
  cursor: crosshair;
}
.minimap-compass {
  position: absolute;
  top: 5px;
  left: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(9, 14, 24, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 9px;
  font-weight: 800;
  color: #e2e8f0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

/* ==========================================================================
   3D-TO-SCREEN WORLD OVERLAYS (FLOATING POPUPS & DISTRICT SIGNS)
   ========================================================================== */

.world-overlays-layer {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  overflow: hidden;
}
.world-popups-layer,
.world-districts-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.world-popup {
  position: absolute;
  top: 0;
  left: 0;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
  will-change: transform, opacity;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  background: rgba(11, 16, 26, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}
.world-popup.tone-cost {
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.45);
}
.world-popup.tone-upgrade {
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.55);
}
.world-popup.tone-refund,
.world-popup.tone-good {
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.55);
}
.world-popup.tone-warn,
.world-popup.tone-error {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.65);
  background: rgba(69, 10, 10, 0.88);
}
.world-popup.tone-milestone {
  color: #fef08a;
  border-color: rgba(245, 158, 11, 0.72);
  background: rgba(45, 28, 6, 0.9);
}
.world-popup.tone-fire {
  color: #fed7aa;
  border-color: rgba(251, 146, 60, 0.65);
}

.district-sign {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 4px;
  border-radius: 99px;
  background: rgba(11, 17, 29, 0.8);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(125, 211, 252, 0.4);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  color: #f8fafc;
  font-family: var(--font-display);
  font-size: 12.5px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  will-change: transform;
  transition: border-color 0.14s, background 0.14s;
}
.district-sign:hover {
  background: rgba(14, 28, 48, 0.94);
  border-color: #38bdf8;
}
.district-sign.offscreen {
  display: none;
}
.ds-pin {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
}

.district-popover {
  position: fixed;
  width: 232px;
  border-radius: 12px;
  padding: 10px 11px;
  z-index: 55;
  pointer-events: auto;
}
.dp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.dp-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7dd3fc;
}
.dp-close {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 14px;
  display: grid;
  place-items: center;
}
.dp-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}
.dp-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dp-input {
  width: 100%;
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #fff;
  font-size: 12.5px;
  outline: none;
}
.dp-actions {
  display: flex;
  gap: 6px;
}
.dp-save {
  flex: 1;
}
.dp-delete {
  flex: 0 0 38px;
  padding: 6px;
}

/* ==========================================================================
   CITY ANALYTICS & MAYOR SCORECARD MODAL
   ========================================================================== */

.modal-dialog.wide {
  width: min(840px, 96vw);
  max-height: min(88vh, 780px);
}

.analytics-tabs {
  display: flex;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.analytics-tab {
  flex: 1;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 700;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.analytics-tab:hover {
  background: var(--bg-surface-hover);
  color: #fff;
}
.analytics-tab.active {
  background: var(--bg-surface-active);
  border-color: rgba(56, 189, 248, 0.55);
  color: #e0f2fe;
}

.analytics-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.scorecard-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.85), rgba(30, 41, 59, 0.55));
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.grade-emblem {
  width: 78px;
  height: 78px;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.25);
}
.grade-letter {
  font-family: var(--font-display);
  font-size: 36px;
  line-height: 1;
}
.grade-score {
  font-size: 10.5px;
  font-weight: 800;
  opacity: 0.9;
}
.grade-emblem.grade-s {
  background: radial-gradient(circle at 30% 25%, #fde047, #f59e0b 65%, #b45309);
  border-color: #fef08a;
  color: #451a03;
  box-shadow: 0 0 28px rgba(251, 191, 36, 0.55);
}
.grade-emblem.grade-a {
  background: radial-gradient(circle at 30% 25%, #6ee7b7, #10b981 65%, #065f46);
  border-color: #a7f3d0;
  color: #022c22;
  box-shadow: 0 0 24px rgba(52, 211, 153, 0.45);
}
.grade-emblem.grade-b {
  background: radial-gradient(circle at 30% 25%, #7dd3fc, #0284c7 70%, #075985);
  border-color: #bae6fd;
  color: #082f49;
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.42);
}
.grade-emblem.grade-c {
  background: radial-gradient(circle at 30% 25%, #fed7aa, #f97316 70%, #9a3412);
  border-color: #ffedd5;
  color: #431407;
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.35);
}
.grade-emblem.grade-d {
  background: radial-gradient(circle at 30% 25%, #fecaca, #ef4444 70%, #991b1b);
  border-color: #fee2e2;
  color: #450a0a;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

.scorecard-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.sc-city-name {
  font-family: var(--font-display);
  font-size: 22px;
  color: #fff;
  line-height: 1.1;
}
.sc-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}
.sc-kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 3px;
}
.sc-kpi {
  font-size: 11.5px;
  color: var(--text-secondary);
  padding: 3px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}
.sc-kpi strong {
  color: #fff;
  margin-left: 3px;
}

.subscores-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.subscore-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.subscore-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #e2e8f0;
}
.mini-bar-track.thick {
  height: 8px;
}

.advisor-tips-list {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #e2e8f0;
}

/* Specializations 2×2 Grid */
.spec-intro {
  font-size: 12.5px;
  color: var(--text-secondary);
}
.spec-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.spec-card {
  padding: 13px 14px;
  border-radius: 13px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.spec-card.active {
  border-color: var(--spec-accent, #38bdf8);
  background: linear-gradient(155deg, rgba(15, 23, 42, 0.9), rgba(56, 189, 248, 0.1));
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.16);
}
.spec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.spec-title-group {
  display: flex;
  align-items: center;
  gap: 9px;
}
.spec-ico {
  font-size: 22px;
}
.spec-name {
  font-weight: 800;
  font-size: 14px;
  color: #fff;
}
.spec-status {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--spec-accent, #7dd3fc);
}
.spec-pct {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
}
.spec-bonus {
  font-size: 11.5px;
  color: #cbd5e1;
}
.spec-metric {
  font-size: 10.5px;
  color: var(--text-secondary);
}

/* Charts & Efficiency Tab */
.an-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.an-chart-card {
  padding: 11px 13px;
  border-radius: 12px;
  background: rgba(9, 14, 24, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.an-chart-head {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-secondary);
}
.an-chart-head strong {
  color: #fff;
}
.an-chart-empty {
  height: 84px;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--text-muted);
}
.an-chart-legend {
  display: flex;
  gap: 12px;
  font-size: 10.5px;
  color: var(--text-secondary);
}
.an-legend-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.an-legend-dot i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.an-efficiency-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.an-kv-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.an-kv {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
}
.an-kv.total {
  border-bottom: none;
  border-top: 1px solid var(--border-strong);
  padding-top: 7px;
  margin-top: 3px;
  font-weight: 800;
}
.an-util-bars {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.density-stacked-bar {
  width: 100%;
  height: 12px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.07);
  display: flex;
  overflow: hidden;
  margin-bottom: 10px;
}
.dsb-seg.lv1 { background: #64748b; }
.dsb-seg.lv2 { background: #38bdf8; }
.dsb-seg.lv3 { background: #34d399; }
.dsb-seg.lv4 { background: #fbbf24; }

.density-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.density-pill {
  padding: 8px 9px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid #64748b;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.density-pill.lv2 { border-left-color: #38bdf8; }
.density-pill.lv3 { border-left-color: #34d399; }
.density-pill.lv4 { border-left-color: #fbbf24; }
.density-pill span { font-size: 10.5px; color: var(--text-secondary); font-weight: 700; }
.density-pill strong { font-size: 16px; color: #fff; }
.density-pill small { font-size: 10px; color: var(--text-muted); }

/* ==========================================================================
   DESKTOP 1221px-1480px OVERLAP PREVENTION (#news-ticker vs #build-dock-wrap & minimap)
   ========================================================================== */

@media (max-width: 1480px) and (min-width: 1221px) {
  .news-ticker {
    max-width: 245px;
    bottom: 92px;
  }
  body.dock-shelf-open .news-ticker {
    bottom: 202px;
  }
  #build-dock-wrap {
    max-width: calc(100vw - 440px);
  }
}

@media (max-width: 1220px) {
  .bottom-right-stack {
    bottom: 104px;
    right: 10px;
    transition: bottom 0.2s ease;
  }
  body.dock-shelf-open .bottom-right-stack {
    bottom: 208px;
  }
  .toast-stack {
    bottom: 214px;
    right: 212px;
  }
}

@media (max-width: 820px) {
  .bottom-right-stack {
    bottom: 140px;
    right: 8px;
  }
  body.dock-shelf-open .bottom-right-stack {
    bottom: 244px;
  }
  .minimap-widget {
    width: 144px;
  }
  .minimap-body,
  #minimap-canvas {
    width: 130px;
    height: 130px;
  }
  .spec-grid,
  .an-charts-grid,
  .an-efficiency-grid {
    grid-template-columns: 1fr;
  }
  .density-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .tb-weather .val-sub-mini {
    display: none;
  }
}

/* ==========================================================================
   CONFIRMATION DIALOG (Destructive Actions Overlay)
   ========================================================================== */

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(3, 7, 16, 0.72);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  display: grid;
  place-items: center;
  padding: 20px;
  pointer-events: auto;
}

.confirm-dialog {
  width: min(420px, 94vw);
  border-radius: 16px;
  padding: 16px 18px 18px;
  background: var(--bg-glass-strong);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.7), 0 1px 0 rgba(255, 255, 255, 0.08) inset;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: modalIn 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.confirm-dialog.danger {
  border-color: rgba(248, 113, 113, 0.48);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.72), 0 0 28px rgba(248, 113, 113, 0.16);
}

.confirm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.confirm-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: 0.02em;
  color: #fff;
}

.confirm-message {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #cbd5e1;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.confirm-actions button {
  min-height: 36px;
  padding: 8px 14px;
}

.confirm-ok-btn.danger {
  background: linear-gradient(135deg, #dc2626, var(--accent-alert));
  color: #fff;
  box-shadow: 0 4px 14px rgba(248, 113, 113, 0.35);
}

.confirm-ok-btn.danger:hover:not(:disabled) {
  filter: brightness(1.08);
}

/* ==========================================================================
   TOUCH & COARSE POINTER HIT TARGETS (>= 36px-40px)
   ========================================================================== */

@media (pointer: coarse) {
  .icon-btn {
    min-width: 40px;
    min-height: 40px;
    width: 40px;
    height: 40px;
    font-size: 16px;
  }
  .spd-btn {
    min-width: 38px;
    min-height: 38px;
    width: 38px;
    height: 38px;
    font-size: 14px;
  }
  .dock-tab {
    min-height: 40px;
    padding: 8px 13px;
    font-size: 12.5px;
  }
  .close-x {
    min-width: 38px;
    min-height: 38px;
    width: 38px;
    height: 38px;
    font-size: 20px;
  }
  .vc-btn,
  .vc-btn.vc-bm {
    min-width: 38px;
    min-height: 38px;
    height: 38px;
    font-size: 14px;
  }
  .legend-clear,
  .qs-close,
  .minimap-toggle {
    min-width: 36px;
    min-height: 36px;
    width: 36px;
    height: 36px;
  }
  .event-chip-btn {
    min-height: 36px;
    padding: 6px 11px;
  }
}
