:root {
  --bg: #0f1424; --panel: #151b2e; --card: #1a2138; --line: #2a3352; --text: #e6edf3; --muted: #9aa4c2;
  --accent: #64ffda; --btn: #2a3456; --btn-hover: #34406a; --warn: #f2b33d; --bad: #ff7b7b; --good: #6ee7a8;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }
button, select, input { font: inherit; color: inherit; }
/* iPhone: quick taps on + / - were read as double-tap-to-zoom. `manipulation` keeps scrolling and pinch zoom but drops the
   double-tap zoom (and its delay) everywhere; inputs at 16px+ stop Safari zooming in when one is focused. */
html, button, a, select, input, label, summary { touch-action: manipulation; }
@media (pointer: coarse) { input, select, textarea { font-size: max(16px, 1em); } }
button { min-height: 40px; padding: 0 14px; border: 0; border-radius: 9px; background: var(--btn); cursor: pointer; font-weight: 600; }
button:hover { background: var(--btn-hover); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); color: #0f1424; }
button.big { min-height: 48px; font-size: 1.05rem; width: 100%; margin: 8px 0; }
button.mini { min-height: 32px; min-width: 32px; padding: 0 8px; border-radius: 7px; }
button.mini.wide { padding: 0 10px; }
button.link { background: none; padding: 0; min-height: 0; color: var(--accent); font-weight: 500; text-align: left; text-decoration: underline; }
button[aria-pressed="true"] { background: #4a5a96; outline: 1px solid var(--accent); }
select, .num-input, .text-input { min-height: 38px; background: #0f1424; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; max-width: 100%; }
.num-input { width: 6.5em; }
.small { font-size: 0.85rem; }
.muted { color: var(--muted); }
.warn-text { color: var(--warn); }
.neg { color: var(--bad); }
.pos { color: var(--good); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app { display: flex; flex-direction: column; height: calc(100vh - 56px); min-height: 520px; padding: 6px 10px 8px; gap: 6px; }
#topbar { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; background: var(--panel); border-radius: 10px; padding: 6px 12px; }
.alerts-btn { margin-left: auto; min-height: 34px; }
.alerts-btn.has { background: #6b4a12; }
#layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr); gap: 10px; }
#mapcol { display: flex; flex-direction: column; min-height: 0; gap: 6px; }
.map-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-height: 34px; padding: 0 12px; border-radius: 17px; font-size: 0.9rem; }
#mapwrap { position: relative; flex: 1; min-height: 240px; background: #0b1020; border-radius: 10px; touch-action: none; user-select: none; -webkit-user-select: none; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; }
#controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.speeds { display: inline-flex; gap: 4px; }
#status, .hint { margin: 0; }
#side { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-radius: 10px; }
#tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
#tabs button { min-height: 36px; padding: 0 11px; background: transparent; }
#tabs button[aria-selected="true"] { background: var(--btn); box-shadow: inset 0 -2px 0 var(--accent); }
#panel { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px 16px; }

.card { background: var(--card); border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; }
.card h3 { margin: 0 0 6px; font-size: 1rem; }
details.card summary { cursor: pointer; font-weight: 600; min-height: 32px; }
details.fold > summary h3 { display: inline; margin: 0; }
details.card.fold[open] > summary { margin-bottom: 6px; }
details.subfold > summary { cursor: pointer; min-height: 28px; }
.region-head h2 { margin: 0; font-size: 1.3rem; }
.region-head p { margin: 2px 0 10px; }
.row { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.row.wrap { flex-wrap: wrap; }
.row select { flex: 1; min-width: 0; }
.bar-row { display: grid; grid-template-columns: 70px 1fr 48px; gap: 4px 8px; align-items: center; margin: 3px 0; }
.bar { height: 10px; background: #0f1424; border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.bar-num { font-variant-numeric: tabular-nums; text-align: right; font-size: 0.85rem; }
.bar-note { grid-column: 2 / 4; margin-top: -2px; }
.stat-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.stat { flex: 1; min-width: 70px; background: #0f1424; border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; }
.stat-n { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 0.8rem; color: var(--muted); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 3px 4px; vertical-align: middle; }
th { font-weight: 500; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.jobs td.btns { white-space: nowrap; text-align: right; }
.jobs td.btns button { margin-left: 4px; }
@media (max-width: 520px) { .jobs { font-size: 0.9rem; } .jobs td.btns button { margin-left: 2px; } } /* Steam numbers (18,000/20,000) are wider */
.stock td.small { line-height: 1.3; }
.kv th { color: var(--muted); }
table.data { font-size: 0.85rem; }
table.data th { color: var(--muted); }
ul.alerts { list-style: none; padding: 0; margin: 0; }
.alert { display: flex; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); }
.alert:first-child { border-top: 0; }
.alert-icon { width: 1.2em; flex: none; }
.alert.bad .alert-icon { color: var(--bad); }
.alert.warn .alert-icon { color: var(--warn); }
.alert.info .alert-icon { color: var(--muted); }
ol.queue, ul.rules, ul.notables, ul.slots, ul.log { padding-left: 0; list-style: none; margin: 6px 0; }
ol.queue li, ul.rules li, ul.notables li, ul.slots li { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 5px 0; border-top: 1px solid var(--line); }
ul.notables li { display: block; }
ul.notables li button { margin-top: 4px; }
progress { width: 90px; height: 10px; accent-color: var(--accent); }
ul.log li { padding: 6px 0; border-top: 1px solid var(--line); }
ul.log li.bad { border-left: 3px solid var(--bad); padding-left: 8px; }
ul.log li.good { border-left: 3px solid var(--good); padding-left: 8px; }
.tip { color: var(--muted); margin-top: 2px; }
.tech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.track h4 { margin: 0 0 6px; font-size: 0.9rem; color: var(--muted); }
.tech { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; padding: 6px 8px; margin: 0 0 6px; min-height: 44px; font-weight: 500; }
.tech-name { font-weight: 700; font-size: 0.88rem; }
.tech-text { font-size: 0.76rem; color: var(--muted); }
.tech.done { background: #1f4a3a; }
.tech.done .tech-text { color: #bfe8d4; }
.tech.queued { background: #4a5a96; }
.tech.locked { opacity: 0.6; }
.tech.branch { margin-left: 12px; width: calc(100% - 12px); border-left: 3px solid var(--muted); }
.building-notes { padding-left: 18px; margin: 4px 0; }
.building-notes li { margin-bottom: 4px; }
.policy { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); cursor: pointer; }
.policy input { width: 22px; height: 22px; margin-top: 2px; }
.policy.locked { opacity: 0.6; cursor: default; }
.panel-empty p { margin-top: 0; }
.pick-list { display: flex; flex-direction: column; gap: 8px; }
.pick { display: flex; flex-direction: column; align-items: flex-start; text-align: left; padding: 10px 12px; min-height: 60px; }
.note { color: var(--accent); }
.graphs canvas.chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.legend { display: flex; gap: 14px; margin: 0 0 4px; font-size: 0.85rem; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
.readout { margin: 4px 0 0; min-height: 1.2em; }

#modal-root[hidden] { display: none; }
.modal-back { position: fixed; inset: 0; background: rgba(5, 8, 16, 0.72); display: flex; align-items: flex-start; justify-content: center; padding: 60px 12px 20px; z-index: 50; overflow-y: auto; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 480px; padding: 14px 16px 18px; }
.modal.wide { max-width: 620px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.modal-head h2 { margin: 0; font-size: 1.3rem; }
.icon-btn { min-width: 40px; padding: 0; }
.form-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.form-row > span:first-child { min-width: 80px; color: var(--muted); }
.form-row input[type=range] { flex: 1; min-width: 120px; }
.radio, .check { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; margin-right: 10px; cursor: pointer; }
.checks .check { display: flex; }
.preview { background: var(--card); border-radius: 8px; padding: 4px 10px; margin: 8px 0; }
.preview p { margin: 6px 0; }
#toast-root { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 60; width: min(92vw, 380px); pointer-events: none; }
.toast { font-size: 0.92rem; background: #24304f; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.35); }

@media (max-width: 900px) {
  #app { height: auto; min-height: 0; }
  #layout { display: flex; flex-direction: column; }
  #mapwrap { flex: none; height: auto; aspect-ratio: 1000 / 640; min-height: 0; }
  #side { min-height: 60vh; }
  #panel { overflow: visible; }
  .hint { display: none; }
  #topbar { font-size: 0.9rem; gap: 4px 12px; }
  #toast-root { left: 8px; right: 8px; bottom: 8px; width: auto; }
  .toast { padding: 8px 12px; font-size: 0.88rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* Plan tab, decision cards, skip buttons */
.plan-head { border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: var(--card); border-left: 4px solid var(--good); }
.plan-head.warn { border-left-color: var(--warn); }
.plan-head.bad { border-left-color: var(--bad); }
.skip-row { margin-top: 8px; align-items: center; }
.plan-list, .card-facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.plan-item { display: flex; gap: 8px; align-items: flex-start; }
.plan-item.done { color: var(--muted); }
.plan-item.done .alert-icon { color: var(--good); }
.plan-item.must .alert-icon { color: var(--bad); }
.plan-item.should .alert-icon { color: var(--warn); }
.steps { margin: 8px 0 0; padding-left: 1.3em; display: grid; gap: 10px; }
.steps li.now { color: var(--accent); }
.card-dialog .stat-row { margin: 10px 0; }
.card-facts { margin: 10px 0; }
.card-facts li { padding-left: 1em; position: relative; }
.card-facts li::before { content: '•'; position: absolute; left: 0; color: var(--muted); }
.skip-summary ul { margin: 8px 0 14px; padding-left: 1.2em; display: grid; gap: 6px; }

.guidance { display: grid; gap: 6px; margin: 8px 0; }
.guide { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; min-height: 36px; }
.guide input { margin-top: 4px; }

.dilemma-options { display: grid; gap: 8px; margin: 10px 0; }
.dilemma-opt { text-align: left; padding: 10px 12px; min-height: 52px; height: auto; line-height: 1.35; font-weight: 500; }
.dilemma-opt strong { font-weight: 700; }
.crisis-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.crisis { display: flex; gap: 10px; align-items: flex-start; }
.badge-dot { flex: none; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #1a2138; background: #fff; }
.crisis-outbreak { background: #ff7b7b; } .crisis-drought { background: #f2b33d; } .crisis-blight { background: #c9a063; }
.crisis-winter { background: #9fd0ff; } .crisis-flood { background: #6fb4ff; }

.spec-line { margin: 0 0 8px; }
.score-parts { margin: 6px 0; gap: 2px; }
.milestones { margin: 4px 0 10px; }
.over-score { font-size: 1.05rem; }
/* Job info boxes and locks (Region tab, Jobs block) */
.jobs .info-btn { min-width: 22px; min-height: 22px; padding: 0; margin-left: 2px; border-radius: 50%; font: italic 700 12px Georgia, serif; vertical-align: middle; }
.jobs tr.job-info td { padding: 0 6px 8px; }
.jobs tr.job-info p { margin: 0; padding: 8px 10px; border-radius: 8px; background: rgba(140, 195, 255, 0.08); border-left: 3px solid #8cc3ff; line-height: 1.4; }
.jobs button.lock { opacity: 0.55; }
.jobs button.lock.on { opacity: 1; outline: 2px solid #ffe08a; outline-offset: -2px; }
/* Move dialog: notable skills under each name, supply share buttons */
.checks .notable-check { align-items: flex-start; margin-bottom: 6px; }
.checks .notable-check input { margin-top: 4px; }
.notable-skills { display: block; line-height: 1.35; }
.chips.pct .chip { min-height: 32px; padding: 0 10px; }

/* Leader's building suggestions for planned slots */
.suggest { border-left: 3px solid var(--muted); padding-left: 8px; margin: 6px 0; }
.suggest p { margin: 0 0 2px; }
.suggest .row { align-items: baseline; margin: 4px 0; }
.suggest .row button { flex: none; }
.jobs tr.job-over td { padding: 0 6px 6px; }
.jobs tr.job-over p { margin: 0; line-height: 1.35; }

/* Advisor tip (top of the side panel) and FAQ */
.advisor { background: rgba(140, 195, 255, 0.10); border-left: 3px solid #8cc3ff; border-radius: 8px; padding: 8px 10px; margin: 0 0 10px; }
.advisor.urgent { background: rgba(255, 196, 110, 0.12); border-left-color: #ffc46e; }
.advisor.inline { margin: 8px 0 0; }
.advisor p { margin: 4px 0 6px; line-height: 1.4; }
.advisor-head { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.advisor-who { font-size: 0.8rem; color: var(--muted); }
.advisor .tip-btns { margin: 0; }
.advisor.fresh { animation: advisor-in 0.45s ease-out; }
@keyframes advisor-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .advisor.fresh { animation: none; } }
details.faq { border-top: 1px solid var(--line); padding: 2px 0; }
details.faq summary { cursor: pointer; min-height: 32px; padding: 6px 0; }
details.faq p { margin: 0 0 8px; line-height: 1.45; }
.t-goods { display: contents; }
.t-delta { font-size: 0.8em; margin-left: 3px; white-space: nowrap; }
@media (max-width: 700px) { .t-goods .t-item { font-size: 0.85rem; } }

/* Leader block: what each candidate brings */
.fx { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.fx-chip { font-size: 0.82rem; padding: 2px 7px; border-radius: 6px; background: var(--btn); white-space: nowrap; }
.fx-chip.zero { opacity: 0.55; }
.fx-chip.neg strong { color: var(--bad); }
.fx-chip.top { outline: 1px solid var(--good); }
.fx-chip.top strong { color: var(--good); }
ul.cands { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 8px; }
ul.cands li { border: 1px solid var(--line); border-radius: 9px; padding: 8px; }
ul.cands li.pick { border-color: var(--accent); }
ul.cands li button { margin-top: 6px; }
.tag-pick { margin-left: 6px; font-size: 0.78rem; font-weight: 700; padding: 1px 7px; border-radius: 8px; background: var(--accent); color: #0f1424; }

/* 2026-11-18: regions table, log filters, notable history */
.regions-table { width: 100%; margin-top: 6px; }
.regions-table tr.bad td:first-child { box-shadow: inset 3px 0 0 var(--bad, #e06c6c); }
.regions-table tr.warn td:first-child { box-shadow: inset 3px 0 0 var(--warn, #e0b45c); }
.regions-table td, .regions-table th { padding: 4px 6px; vertical-align: top; }
.log-filters { gap: 6px; margin-bottom: 4px; }
.log-filters select { min-height: 34px; max-width: 100%; }
ul.timeline { margin: 4px 0 0; padding-left: 18px; }
ul.timeline li { margin: 2px 0; }
.slot-time { display: block; }
@media (max-width: 520px) { .regions-table th:nth-child(4), .regions-table td:nth-child(4) { display: none; } }

/* map picker */
.map-row { align-items: flex-start; }
.map-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; flex: 1; }
.map-pick { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.map-pick input { position: absolute; opacity: 0; pointer-events: none; }
.map-pick:has(input:checked) { outline: 2px solid var(--accent); background: #24304f; }
.map-pick:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.map-thumb { width: 100px; height: 64px; border-radius: 6px; display: block; }
.map-name { font-size: 0.85rem; text-align: center; }
.map-blurb { flex: 1; margin: 4px 0; }
.regions-table td:nth-child(2), .regions-table td:nth-child(3), .regions-table td:nth-child(5) { white-space: nowrap; }
@media (max-width: 560px) {
  .map-row { flex-direction: column; align-items: stretch; }
  .map-picks { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .map-pick { padding: 4px; }
  .map-thumb { width: 100%; height: auto; aspect-ratio: 100 / 64; }
  .map-name { font-size: 0.78rem; }
}

/* Welcome dialog */
.intro-step h3 { margin: 10px 0 2px; font-size: 1em; }
.intro-step p { margin: 0 0 4px; }
#move-from, #move-to { width: 100%; }
