* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  background: #10141c;
  color: #d7dde8;
  font-size: 13px;
  user-select: none;
}
#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  background: #1a2130;
  border-bottom: 1px solid #2c3648;
  flex: 0 0 auto;
  flex-wrap: wrap;
}
#brand { font-weight: 800; letter-spacing: 2px; color: #8fb7ff; font-size: 14px; }
#build-tag { font-weight: 400; letter-spacing: 0; color: #4a5468; font-size: 10px; }
#cityname {
  background: #10141c; border: 1px solid #2c3648; color: #e8edf5;
  padding: 3px 8px; border-radius: 4px; width: 130px; font-size: 13px;
}
.stat { padding: 3px 8px; background: #222b3d; border-radius: 4px; white-space: nowrap; }
.stat.money { cursor: pointer; color: #ffd97a; font-weight: 600; }
.stat.money:hover { background: #2c3852; }
.spacer { flex: 1; }
#happy-bar {
  display: inline-block; width: 60px; height: 8px; background: #10141c;
  border-radius: 4px; overflow: hidden; vertical-align: middle; margin-left: 4px;
}
#happy-fill { display: block; height: 100%; width: 50%; background: #6fcf6f; transition: width .5s, background .5s; }
#speed-controls { display: flex; gap: 2px; }
button {
  background: #222b3d; color: #d7dde8; border: 1px solid #2c3648;
  border-radius: 4px; padding: 3px 9px; cursor: pointer; font-size: 12px;
  font-family: inherit;
}
button:hover { background: #2c3852; }
button.spd.on { background: #3d63a8; border-color: #5580c9; color: #fff; }
select {
  background: #222b3d; color: #d7dde8; border: 1px solid #2c3648;
  border-radius: 4px; padding: 3px 5px; font-size: 12px; font-family: inherit;
}
.linkish {
  background: none; border: none; color: #7fa8e8; cursor: pointer;
  font-size: 11px; padding: 0 2px; float: right;
}
.linkish:hover { background: none; text-decoration: underline; }

/* ---------- layout ---------- */
#main { display: flex; flex: 1 1 auto; min-height: 0; }
#toolbar {
  flex: 0 0 118px; overflow-y: auto;
  background: #1a2130; border-right: 1px solid #2c3648;
  padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.tool-group-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: #6b7890; margin: 6px 2px 1px;
}
.tool {
  display: flex; align-items: center; gap: 6px;
  background: #222b3d; border: 1px solid #2c3648; border-radius: 5px;
  padding: 4px; cursor: pointer; text-align: left; width: 100%;
}
.tool:hover { background: #2c3852; }
.tool.on { background: #3d63a8; border-color: #6f96d8; }
.tool.locked { opacity: .38; cursor: not-allowed; }
.tool canvas { flex: 0 0 26px; border-radius: 3px; background: #55794a; }
.tool .t-name { font-size: 11px; line-height: 1.15; }
.tool .t-cost { font-size: 10px; color: #ffd97a; }
.tool.locked .t-cost { color: #93a0b5; }

#viewport { position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; background: #0a0d13; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }

/* ---------- HUD widgets ---------- */
#tooltip {
  position: absolute; pointer-events: none; z-index: 30;
  background: rgba(16,20,28,.92); border: 1px solid #3a465c; border-radius: 5px;
  padding: 5px 8px; font-size: 11.5px; max-width: 230px; line-height: 1.35;
}
#tooltip .bad { color: #ff8f8f; }
#tooltip .good { color: #8fe89f; }
#tooltip b { color: #fff; }

#rci-panel {
  position: absolute; right: 10px; bottom: 10px; z-index: 20;
  display: flex; gap: 7px; align-items: flex-end;
  background: rgba(20,26,38,.85); border: 1px solid #2c3648;
  border-radius: 6px; padding: 7px 9px 4px;
}
.rci-col { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.rci-bar {
  width: 13px; height: 56px; background: #10141c; border-radius: 3px;
  display: flex; align-items: flex-end; overflow: hidden;
}
.rci-fill { width: 100%; height: 0%; transition: height .6s; }
#rci-r { background: #4caf6d; } #rci-c { background: #4c86d8; } #rci-i { background: #cfa23c; }
.rci-lab { font-size: 10px; font-weight: 700; }

#minimap {
  position: absolute; left: 10px; bottom: 10px; z-index: 20;
  border: 1px solid #3a465c; border-radius: 4px; cursor: pointer;
  image-rendering: pixelated; width: 128px; height: 128px;
  background: #0a0d13;
}

#ticker {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px; z-index: 20;
  background: rgba(20,26,38,.85); border: 1px solid #2c3648; border-radius: 6px;
  padding: 5px 14px; font-size: 12px; max-width: 55%; text-align: center;
  color: #b9c6da; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#ticker b { color: #ffd97a; }

#toasts {
  position: absolute; top: 10px; right: 10px; z-index: 40;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  background: rgba(28,36,52,.95); border: 1px solid #3d63a8; border-radius: 6px;
  padding: 7px 12px; font-size: 12px; max-width: 280px;
  animation: toast-in .25s ease-out;
  box-shadow: 0 3px 14px rgba(0,0,0,.4);
}
.toast.warn { border-color: #c96a3a; }
.toast.big { border-color: #ffd97a; font-size: 13px; }
.toast b { color: #ffd97a; }
@keyframes toast-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.out { transition: opacity .5s; opacity: 0; }

/* ---------- panels ---------- */
#info-panel, #budget-panel, #checklist {
  position: absolute; z-index: 25;
  background: rgba(22,28,40,.96); border: 1px solid #3a465c; border-radius: 7px;
  padding: 9px 11px; font-size: 12px;
  box-shadow: 0 4px 18px rgba(0,0,0,.45);
}
#info-panel { right: 10px; top: 10px; width: 245px; }
#budget-panel { left: 50%; top: 60px; transform: translateX(-50%); width: 290px; }
#checklist { left: 10px; top: 10px; width: 235px; }
.panel-title { font-weight: 700; color: #e8edf5; margin-bottom: 6px; font-size: 12.5px; }
#info-body .row, #budget-body .row, .wm-body .row {
  display: flex; justify-content: space-between; padding: 1.5px 0;
}
#info-body .row span:last-child, #budget-body .row span:last-child, .wm-body .row span:last-child { color: #e8edf5; }
#info-body .sec, .wm-body .sec { margin-top: 6px; font-weight: 600; color: #9fb4d4; }
#info-body .names, .wm-body .names { color: #b9c6da; font-size: 11px; line-height: 1.4; }
#budget-body .row.total { border-top: 1px solid #3a465c; margin-top: 4px; padding-top: 4px; font-weight: 700; }
.budget-tax { margin-top: 8px; }
.budget-tax input { width: 100%; }
#checklist ul { list-style: none; margin: 0 0 5px; }
#checklist li { padding: 2px 0 2px 18px; position: relative; color: #b9c6da; }
#checklist li::before {
  content: ""; position: absolute; left: 2px; top: 6px; width: 9px; height: 9px;
  border: 1px solid #5a6a85; border-radius: 2px;
}
#checklist li.done { color: #6fcf6f; text-decoration: line-through; }
#checklist li.done::before { background: #4caf6d; border-color: #4caf6d; }

/* ---------- help ---------- */
#help-overlay {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(8,10,15,.72);
  display: flex; align-items: center; justify-content: center;
}
#help-card {
  background: #1a2130; border: 1px solid #3d63a8; border-radius: 10px;
  max-width: 560px; width: 92%; max-height: 86%; overflow-y: auto;
  padding: 18px 22px;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
#help-card .panel-title { font-size: 17px; color: #8fb7ff; }
#help-body p, #help-body ol { margin: 8px 0; line-height: 1.5; }
#help-body ol { padding-left: 20px; }
#help-body b { color: #ffd97a; }
#help-close {
  margin-top: 12px; width: 100%; padding: 8px;
  background: #3d63a8; border-color: #5580c9; color: #fff; font-size: 14px; font-weight: 600;
}
#help-close:hover { background: #4a74c0; }

/* ---------- v2 panels ---------- */
#event-card {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 52px; z-index: 35;
  width: 360px; background: rgba(24,30,44,.97);
  border: 1px solid #d8b84a; border-radius: 8px; padding: 11px 13px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  animation: toast-in .3s ease-out;
}
#event-card .panel-title { color: #ffd97a; }
#event-body { font-size: 12px; line-height: 1.45; color: #c9d3e4; margin-bottom: 9px; }
#event-buttons { display: flex; gap: 7px; }
.ev-btn { flex: 1; padding: 6px 8px; font-size: 12px; line-height: 1.25; }
.ev-btn.yes { background: #3d63a8; border-color: #5580c9; color: #fff; }
.ev-btn.yes:hover { background: #4a74c0; }

#follow-panel {
  position: absolute; left: 150px; bottom: 10px; z-index: 22; width: 230px;
  background: rgba(22,28,40,.94); border: 1px solid #3a465c; border-radius: 7px;
  padding: 8px 11px; font-size: 12px;
}
#follow-body { color: #b9c6da; line-height: 1.45; }
#follow-body b { color: #ffd97a; }

#policies-panel {
  position: absolute; left: 50%; top: 60px; transform: translateX(-50%); z-index: 26;
  width: 330px; background: rgba(22,28,40,.97); border: 1px solid #3a465c;
  border-radius: 8px; padding: 10px 13px; max-height: 75%; overflow-y: auto;
}
.policy-row { display: block; padding: 6px 0; border-bottom: 1px solid #26304400; cursor: pointer; }
.policy-row b { color: #e8edf5; font-size: 12px; }
.policy-row .p-cost { color: #ffd97a; font-size: 11px; margin-left: 4px; }
.policy-row .p-desc { color: #93a0b5; font-size: 11px; }

#times-panel {
  position: absolute; inset: 0; z-index: 45;
  background: rgba(8,10,15,.7);
  display: flex; align-items: center; justify-content: center;
}
#times-inner {
  background: #ece5d3; color: #2a2620; width: 470px; max-width: 94%;
  max-height: 86%; overflow-y: auto; padding: 18px 24px;
  font-family: Georgia, "Times New Roman", serif;
  box-shadow: 0 12px 44px rgba(0,0,0,.6);
  border: 1px solid #b8ae96;
}
#times-masthead {
  font-size: 23px; font-weight: 700; letter-spacing: 2px; text-align: center;
  border-bottom: 2.5px solid #2a2620; padding-bottom: 5px;
}
#times-date { text-align: center; font-size: 11px; padding: 4px 0 8px; border-bottom: 1px solid #2a2620; }
#times-headline { font-size: 19px; font-weight: 700; line-height: 1.25; padding: 10px 0 8px; }
#times-columns { display: flex; gap: 14px; font-size: 12px; line-height: 1.5; padding-bottom: 10px; }
.times-col { flex: 1; border-top: 1px solid #8a8272; padding-top: 6px; }
#times-stats {
  font-size: 10.5px; border-top: 2px solid #2a2620; padding-top: 5px; text-align: center;
}
#times-close {
  margin-top: 10px; width: 100%; background: #2a2620; color: #ece5d3;
  border: none; padding: 7px; font-family: inherit;
}

#endgame-overlay {
  position: absolute; inset: 0; z-index: 55;
  background: rgba(8,10,15,.78);
  display: flex; align-items: center; justify-content: center;
}
#endgame-card {
  background: #1a2130; border: 1px solid #ffd97a; border-radius: 10px;
  width: 420px; max-width: 92%; padding: 20px 24px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
#endgame-card .panel-title { font-size: 18px; color: #ffd97a; }
#endgame-body { font-size: 13px; line-height: 1.5; color: #c9d3e4; margin: 8px 0 14px; }
#endgame-card button { width: 100%; margin-top: 6px; padding: 8px; font-size: 13px; }
#endgame-continue { background: #3d63a8; border-color: #5580c9; color: #fff; }

#newgame-modal {
  position: absolute; inset: 0; z-index: 55;
  background: rgba(8,10,15,.78);
  display: flex; align-items: center; justify-content: center;
}
#newgame-card {
  background: #1a2130; border: 1px solid #3d63a8; border-radius: 10px;
  width: 480px; max-width: 94%; max-height: 88%; overflow-y: auto;
  padding: 16px 20px;
}
#scenario-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
.scen {
  text-align: left; padding: 8px 11px; line-height: 1.4; font-size: 12px;
  border: 1px solid #2c3648; border-radius: 7px; background: #222b3d;
}
.scen b { color: #e8edf5; font-size: 13px; }
.scen span { color: #93a0b5; }
.scen .scen-goal { color: #ffd97a; }
.scen.on { border-color: #6f96d8; background: #2c3c5c; }
#disasters-row { display: block; font-size: 12px; color: #b9c6da; margin-bottom: 10px; cursor: pointer; }
#newgame-buttons { display: flex; gap: 8px; }
#newgame-start { flex: 1; background: #3d63a8; border-color: #5580c9; color: #fff; padding: 8px; font-size: 13px; }
#newgame-cancel { padding: 8px 14px; }

/* ---------- AI mayor panel ---------- */
#mayor-panel {
  position: absolute; right: 10px; top: 10px; z-index: 27; width: 320px;
  background: rgba(22,28,40,.97); border: 1px solid #3a465c; border-radius: 8px;
  padding: 10px 13px; max-height: 84%; overflow-y: auto; font-size: 12px;
}
#mayor-mode-row { display: flex; gap: 12px; margin-bottom: 7px; }
#mayor-mode-row label { cursor: pointer; color: #c9d3e4; }
#mayor-profile-row { margin-bottom: 4px; color: #93a0b5; }
#mayor-profile-row select { margin-left: 4px; }
.mayor-sec {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: #6b7890; margin: 9px 0 4px;
}
.need-row { display: flex; align-items: center; gap: 6px; padding: 1.5px 0; }
.need-name { flex: 0 0 92px; font-size: 11px; color: #b9c6da; }
.need-bar {
  flex: 1; height: 7px; background: #10141c; border-radius: 3px; overflow: hidden;
}
.need-fill { display: block; height: 100%; width: 0; transition: width .4s; }
.need-score { flex: 0 0 22px; text-align: right; font-size: 10px; color: #93a0b5; }
.need-w { flex: 0 0 52px; height: 10px; }
#mayor-gov { color: #b9c6da; line-height: 1.5; }
#mayor-gov b { color: #ffd97a; }
.mlog { color: #93a0b5; font-size: 11px; padding: 1.5px 0; line-height: 1.35; }

/* ---------- living city ---------- */
#pulse-feed {
  position: absolute; right: 10px; bottom: 108px; z-index: 19; width: 250px;
  background: rgba(20,26,38,.82); border: 1px solid #2c3648; border-radius: 7px;
  padding: 6px 9px; font-size: 11px;
}
#pulse-head { font-weight: 700; color: #9fb4d4; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 3px; }
#pulse-feed.collapsed { width: auto; }
#pulse-feed.collapsed #pulse-items { display: none; }
.pulse-item { color: #b9c6da; padding: 1.5px 0; line-height: 1.35; }
.pulse-dot { display: inline-block; width: 6px; height: 6px; border-radius: 3px;
  margin-right: 5px; vertical-align: middle; }

#citizens-panel {
  position: absolute; left: 128px; top: 10px; z-index: 26; width: 300px;
  background: rgba(22,28,40,.97); border: 1px solid #3a465c; border-radius: 8px;
  padding: 10px 13px; max-height: 82%; overflow-y: auto; font-size: 12px;
}
#citizen-search {
  width: 100%; background: #10141c; border: 1px solid #2c3648; color: #e8edf5;
  padding: 4px 8px; border-radius: 4px; margin-bottom: 6px; font-size: 12px;
}
.cit-row { padding: 5px 4px; border-radius: 5px; cursor: pointer; line-height: 1.3; }
.cit-row:hover { background: #2c3852; }
.cit-row b { color: #e8edf5; }
.cit-stage { float: right; color: #6b7890; font-size: 10px; text-transform: uppercase; }
.cit-last { color: #93a0b5; font-size: 11px; }
.cit-name { font-size: 15px; font-weight: 700; color: #ffd97a; margin: 6px 0 3px; }
.cit-meta { color: #b9c6da; line-height: 1.5; margin-bottom: 6px; }
.cit-mood { color: #93a0b5; margin-bottom: 8px; }
.cit-mood-bar { display: inline-block; width: 70px; height: 8px; background: #10141c;
  border-radius: 4px; overflow: hidden; vertical-align: middle; }
.cit-mood-bar span { display: block; height: 100%; }
#cit-follow { width: 100%; padding: 6px; background: #3d63a8; border-color: #5580c9; color: #fff; }
.linklike { color: #7fa8e8; cursor: pointer; text-decoration: underline; font-size: 11px; }

#stats-panel {
  position: absolute; left: 50%; top: 54px; transform: translateX(-50%); z-index: 26;
  width: 300px; background: rgba(22,28,40,.97); border: 1px solid #3a465c;
  border-radius: 8px; padding: 10px 13px; max-height: 84%; overflow-y: auto; font-size: 12px;
}
.chart-row { margin-bottom: 7px; }
.chart-label { color: #93a0b5; font-size: 11px; margin-bottom: 2px; }
.chart-label b { color: #e8edf5; }
.chart-row canvas { border-radius: 4px; display: block; }
#stats-employers .row { display: flex; justify-content: space-between; padding: 2px 0;
  color: #b9c6da; font-size: 11.5px; }
#stats-employers .row span:last-child { color: #ffd97a; }

/* ---------- window manager ---------- */
.wm-window {
  position: absolute; z-index: 60;
  background: rgba(22,28,40,.97); border: 1px solid #5a6a8a;
  border-radius: 8px; font-size: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  min-width: 220px;
}
.wm-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 8px 6px 12px; cursor: move; user-select: none;
  border-bottom: 1px solid #2c3648;
}
.wm-title {
  font-weight: 700; color: #ffd97a; font-size: 12.5px; pointer-events: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px;
}
.wm-btns { display: flex; gap: 3px; flex: 0 0 auto; }
.wm-btns button {
  width: 20px; height: 18px; padding: 0; font-size: 12px; line-height: 1;
  background: #222b3d; border: 1px solid #2c3648;
}
.wm-btns button:hover { background: #2c3852; }
.wm-body { padding: 9px 12px 11px; }
.wm-body canvas { border-radius: 5px; display: block; border: 1px solid #3a3026; }
#wm-dock {
  position: absolute; bottom: 10px; left: 150px; z-index: 24;
  display: flex; gap: 5px; flex-wrap: wrap; max-width: 45%;
}
.wm-chip {
  background: rgba(28,36,52,.95); border: 1px solid #5a6a8a; border-radius: 5px;
  padding: 4px 10px; font-size: 11px; color: #ffd97a;
  max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wm-chip:hover { background: #2c3852; }
.cw-actions { display: flex; gap: 5px; margin-bottom: 7px; }
.cw-actions button { flex: 1; padding: 5px 4px; font-size: 11px; }
.cw-actions .cw-follow { background: #3d63a8; border-color: #5580c9; color: #fff; }
.hw-activity { margin-top: 7px; }
.home-line { color: #e8d8b0; font-size: 12px; padding: 1.5px 0; font-style: italic; }
.home-inv { color: #b9c6da; line-height: 1.5; }
.home-meta { color: #6b7890; font-size: 11px; margin-top: 4px; }
#cit-home { width: 100%; padding: 6px; margin-top: 5px; }

/* ---------- save manager ---------- */
#saves-panel {
  position: absolute; left: 50%; top: 54px; transform: translateX(-50%); z-index: 29;
  width: 380px; background: rgba(22,28,40,.97); border: 1px solid #3a465c;
  border-radius: 8px; padding: 10px 13px; max-height: 84%; overflow-y: auto; font-size: 12px;
}
#saves-new-row { display: flex; gap: 6px; margin-bottom: 8px; }
#save-name {
  flex: 1; background: #10141c; border: 1px solid #2c3648; color: #e8edf5;
  padding: 4px 8px; border-radius: 4px; font-size: 12px;
}
#save-new { background: #3d63a8; border-color: #5580c9; color: #fff; }
.save-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 4px; border-bottom: 1px solid #26304466;
}
.save-info b { color: #e8edf5; }
.save-info span { color: #93a0b5; font-size: 11px; line-height: 1.35; }
.save-btns { display: flex; gap: 4px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
.save-btns button { padding: 3px 7px; font-size: 11px; }
.save-del { color: #ff8f8f; }
#save-io {
  width: 100%; height: 54px; background: #10141c; border: 1px solid #2c3648;
  color: #93a0b5; border-radius: 4px; font-size: 10px; font-family: monospace;
  padding: 5px; resize: vertical; margin-bottom: 6px;
}
#saves-io-row { display: flex; gap: 6px; }

.hidden { display: none !important; }
