/* Freedom Simulator — prototype styles. Dark command-room look; colours come from rules.js. */

:root {
  --bg: #12141a;
  --bg-2: #1a1d25;
  --bg-3: #232733;
  --line: #2f3442;
  --text: #ece7db;
  --muted: #9aa0ad;
  --gold: #d8b45a;
  --sea: #252b30;
  --sea-line: #6f7c80;
  --focus: #ffe27a;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0 0 6px; line-height: 1.2; }
p { margin: 0 0 10px; line-height: 1.45; }

/* ---- Top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.brand { display: flex; flex-direction: column; }
.brand-title { font-weight: 800; letter-spacing: 0.14em; color: var(--gold); }
.brand-sub { font-size: 12px; color: var(--muted); }
.status { display: flex; gap: 12px; flex-wrap: wrap; flex: 1; justify-content: center; font-size: 13px; }
.status-round { color: var(--gold); font-weight: 600; }
.status-power { border-left: 3px solid var(--pc); padding-left: 6px; }
.status-power.out { opacity: 0.4; text-decoration: line-through; }
.top-actions { display: flex; gap: 8px; }

/* ---- Layout ---- */
.layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 360px; min-height: 0; }
.board { padding: 12px 16px; min-width: 0; }
#map { width: 100%; height: auto; display: block; background: radial-gradient(ellipse at 60% 50%, #1b1d22 0%, #121316 75%); border-radius: var(--radius); border: 1px solid var(--line); }
.panel { border-left: 1px solid var(--line); background: var(--bg-2); padding: 16px; overflow-y: auto; max-height: calc(100vh - 60px); display: flex; flex-direction: column; gap: 12px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.legend-item i.legend-objective { border: 2px dashed #e8ecf2; background: transparent; }
.disclaimer { font-size: 11px; color: #6c7280; margin-top: 6px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .panel { border-left: 0; border-top: 1px solid var(--line); max-height: none; }
}

/* ---- Map ---- */
.link-land { stroke: #5a6172; stroke-width: 3; }
.link-coast { stroke: var(--sea-line); stroke-width: 1.5; stroke-dasharray: 2 5; opacity: 0.7; }
.link-sea { stroke: var(--sea-line); stroke-width: 2.5; stroke-dasharray: 8 6; opacity: 0.8; }

.space { cursor: pointer; outline: none; }
.space .ring { fill: none; stroke: transparent; stroke-width: 3; }
.space:hover .ring, .space:focus-visible .ring { stroke: #ffffff55; }
.space.is-target .ring { stroke: #ffffffaa; stroke-dasharray: 5 4; }
.space.is-selected .ring { stroke: #ffffff; stroke-dasharray: none; stroke-width: 3.5; }
.space.is-highlight .ring { stroke: var(--focus); stroke-dasharray: none; stroke-width: 4; }

.sea-body { fill: var(--sea); stroke: var(--sea-line); stroke-width: 2; fill-opacity: 0.85; }
.sea-label { fill: #c3cbcd; font-size: 12px; font-weight: 600; text-anchor: middle; letter-spacing: 0.04em; }
.sea-caption { fill: #9aa4a7; font-size: 10px; text-anchor: middle; letter-spacing: 0.06em; text-transform: uppercase; }
.sea-empty { fill: #7d878a; font-size: 11px; text-anchor: middle; }
.chip { stroke: #0006; }
.chip-text { fill: #fff; font-size: 13px; font-weight: 700; text-anchor: middle; }

.land-body { stroke: #0008; stroke-width: 2; }
.objective-ring { fill: none; stroke: #f4f6fa; stroke-width: 3; }
.inf-count { fill: #fff; font-size: 17px; font-weight: 800; text-anchor: middle; paint-order: stroke; stroke: #0007; stroke-width: 3px; }
.inf-caption { fill: #ffffffcc; font-size: 9px; font-weight: 700; text-anchor: middle; letter-spacing: 0.08em; text-transform: uppercase; paint-order: stroke; stroke: #0006; stroke-width: 2px; }
.mine-ring { fill: none; stroke: transparent; stroke-width: 0; }
.space.is-mine .mine-ring { stroke: var(--mc); stroke-width: 3; stroke-opacity: 0.6; }
.legend-item i.legend-mine { background: transparent; border: 3px solid #ffffff66; }
.land-label { fill: var(--text); font-size: 12.5px; text-anchor: middle; paint-order: stroke; stroke: #11151d; stroke-width: 4px; }
.capital-star { fill: #ffffff; font-size: 15px; text-anchor: middle; paint-order: stroke; stroke: #000a; stroke-width: 3px; }
.air-badge rect { fill: #0c0f15; stroke: #c9d3e3; stroke-width: 1; }
.air-badge text { fill: #e6eefb; font-size: 11px; font-weight: 700; text-anchor: middle; }

.arrow { stroke-width: 3.5; fill: none; opacity: 0.95; }
.arrow-air { stroke-dasharray: 2 5; stroke-linecap: round; }
.arrow-fleet { stroke-width: 5; opacity: 0.8; }
.arrow-count { font-size: 13px; font-weight: 800; text-anchor: middle; paint-order: stroke; stroke: #0b0e14; stroke-width: 4px; }
.build-mark { fill: none; stroke-width: 2; stroke-dasharray: 1 4; stroke-linecap: round; }

/* ---- Panel content ---- */
.power-head { border-left: 4px solid var(--pc, var(--gold)); padding-left: 10px; }
.eyebrow { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.meta { font-size: 13px; color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); }
.notice { background: #3a2a14; border: 1px solid #7a5a22; padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.selected { background: var(--bg-3); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.order-form { border-top: 1px solid var(--line); padding-top: 10px; }
.order-form h4 { font-size: 13px; color: var(--gold); }
.form-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; }
.form-row input[type=number] { width: 64px; }
input, select { background: #0f1218; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
select { max-width: 100%; }
.order-list ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.order-list li span { display: inline-block; max-width: calc(100% - 32px); }

.step-dots { display: flex; gap: 6px; flex-wrap: wrap; }
.step-dot { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg-3); cursor: pointer; font-size: 12px; }
.step-dot.on { background: var(--gold); color: #1b1608; border-color: var(--gold); font-weight: 700; }
.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.event { border-left: 4px solid var(--pc); background: var(--bg-3); padding: 8px 10px; border-radius: 0 8px 8px 0; font-size: 13.5px; line-height: 1.4; cursor: pointer; }
.event.focus { outline: 2px solid var(--focus); }

/* ---- Buttons ---- */
button { cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-3); padding: 8px 14px; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: var(--gold); color: #1b1608; border-color: var(--gold); font-weight: 700; }
button.ghost { background: transparent; }
button.small { padding: 5px 10px; font-size: 13px; }
button.icon { padding: 0 6px; border: 0; background: transparent; color: var(--muted); }
button.icon:hover { color: #fff; }
button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.actions.sticky { position: sticky; bottom: -16px; background: var(--bg-2); padding: 10px 0 4px; margin-top: auto; }

/* ---- Overlay ---- */
.overlay { position: fixed; inset: 0; background: #07090ccc; display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10; }
.overlay[hidden] { display: none; }
.dialog { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(640px, 100%); max-height: 90vh; overflow-y: auto; }
.dialog h1 { color: var(--gold); letter-spacing: 0.06em; }
.lede { color: var(--muted); }
.setup fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0 0 12px; }
.setup legend { padding: 0 6px; color: var(--gold); font-size: 13px; }
.setup-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 6px 10px; border-left: 4px solid var(--pc); margin-bottom: 6px; }
.setup-power { font-weight: 600; }
.setup-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.setup-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.handover { border-left: 6px solid var(--pc); padding-left: 16px; }
.help-steps, .help-phases { padding-left: 20px; font-size: 14px; line-height: 1.5; }
.help-phases { margin-left: 16px; }
.help-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
.help-table td, .help-table th { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: left; vertical-align: top; }
.dialog h3 { margin-top: 14px; color: var(--gold); font-size: 15px; }

/* ---- Forces overview ---- */
.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.totals div { background: var(--bg-3); border-radius: 8px; padding: 8px 4px; text-align: center; display: flex; flex-direction: column; }
.totals b { font-size: 20px; color: var(--text); }
.totals span { font-size: 11px; color: var(--muted); }
.howto { background: var(--bg-3); border-radius: var(--radius); padding: 8px 12px; font-size: 13px; }
.howto summary { cursor: pointer; color: var(--gold); font-weight: 600; }
.howto ol { padding-left: 18px; margin: 8px 0 2px; line-height: 1.5; }
.forces { display: flex; flex-direction: column; gap: 6px; }
.force-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; border-left: 4px solid var(--pc); background: var(--bg-3); padding: 8px 10px; border-radius: 0 8px 8px 0; }
.force-row:hover { background: #2b3040; }
.force-name { font-weight: 700; }
.force-units { font-size: 13px; }
.force-units em { color: var(--gold); font-style: normal; }
.force-can { font-size: 12px; color: var(--muted); }
.explain { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.back { align-self: flex-start; }
.reach-title { font-size: 13px; margin-bottom: 4px; }
.reach { margin: 0 0 6px; padding-left: 18px; font-size: 13px; }

/* ---- Ghost markers where the board wraps ---- */
.ghost-body { fill: #252b3088; stroke: var(--sea-line); stroke-width: 1.5; stroke-dasharray: 4 3; }
.ghost-label { fill: #c3cbcd; font-size: 16px; text-anchor: middle; }
.ghost-name { fill: #9aa4a7; font-size: 11px; text-anchor: middle; paint-order: stroke; stroke: #11151d; stroke-width: 4px; }
.ghost-fleets { font-size: 10px; font-weight: 700; text-anchor: middle; }
.income-line { font-size: 13px; color: var(--muted); }
.income-line b { color: var(--text); }

/* ---- Icons ---- */
.ico { width: 16px; height: 16px; fill: currentColor; vertical-align: -3px; flex: none; }
.ico-sm { width: 12px; height: 12px; vertical-align: -1px; }
.ico-lg { width: 22px; height: 22px; }
.node-ico { fill: #fff; opacity: 0.92; }
.chip-ico { fill: #fff; }
.air-badge use { fill: #e6eefb; }
.objective-badge circle { fill: #0c0f15; stroke: #e8ecf2; stroke-width: 1.2; }
.objective-badge use { fill: #e8ecf2; }
.structure-row rect { fill: #0c0f15; stroke: #8a93a3; stroke-width: 1; }
.structure-row use { fill: #e8ecf2; }
.chip-text { text-anchor: middle; }

/* ---- Tooltip ---- */
.tooltip { position: fixed; z-index: 20; max-width: 280px; background: #0b0d12f2; border: 1px solid #3a4152; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; line-height: 1.45; pointer-events: none; box-shadow: 0 6px 20px #0008; }
.tooltip b { display: block; font-size: 13.5px; }
.tip-sub { display: block; color: var(--muted); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; border-left: 3px solid var(--pc, transparent); padding-left: 4px; }
.tip-note { margin-top: 6px; color: var(--muted); }
.tip-objective { color: var(--text); }
.tip-objective b { display: inline; font-size: inherit; }

/* ---- Panel pieces ---- */
.totals div { align-items: center; gap: 2px; cursor: help; }
.pill { display: inline-flex; align-items: center; gap: 5px; background: #0f1218; border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; font-size: 12.5px; margin: 0 6px 6px 0; }
.unit-line { display: flex; flex-wrap: wrap; margin: 0; }
.objective-note { font-size: 13px; background: #1c2130; border-radius: 8px; padding: 6px 8px; }
.objectives-box, .research-box { background: var(--bg-3); border-radius: var(--radius); padding: 10px 12px; font-size: 13px; }
.objectives-box h4, .research-box h4 { color: var(--gold); display: flex; align-items: center; gap: 6px; }
.obj-bar { display: grid; grid-template-columns: 28px 1fr 34px; align-items: center; gap: 8px; margin: 4px 0; font-size: 12px; }
.obj-name { font-weight: 700; color: var(--pc); }
.obj-track { height: 8px; background: #0f1218; border-radius: 4px; overflow: hidden; }
.obj-track i { display: block; height: 100%; background: var(--pc); }
.obj-num { text-align: right; color: var(--muted); }
.obj-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.obj-chip { font-size: 12px; padding: 3px 8px; border-left: 4px solid var(--pc); border-radius: 0 6px 6px 0; }
.objectives-box details summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.research-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.pips { display: inline-flex; gap: 3px; vertical-align: 1px; }
.pip { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--gold); display: inline-block; }
.pip.on { background: var(--gold); }
.done { font-size: 12px; color: var(--gold); white-space: nowrap; }
.build-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.build-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; font-size: 12px; }
.build-btn .ico-lg { fill: var(--text); }
.build-name em { color: var(--gold); font-style: normal; }
.build-cost { color: var(--muted); font-size: 11.5px; }
.status-power .ico { fill: currentColor; margin-right: 2px; }

/* ---- Objectives at a glance ---- */
.objective-flag line { stroke: #f4f6fa; stroke-width: 2; }
.objective-flag path { stroke: #f4f6fa; stroke-width: 1.5; stroke-linejoin: round; }
#map .space, #map line { transition: opacity 0.15s; }
#map.objectives-only .space:not(.is-objective),
#map.objectives-only .link-land,
#map.objectives-only .link-coast,
#map.objectives-only .link-sea { opacity: 0.18; }
.legend-toggle { padding: 3px 9px; border-radius: 999px; font-size: 12px; color: var(--text); }
.legend-toggle.on { background: #f4f6fa; color: #12141a; border-color: #f4f6fa; }
.legend-toggle.on .ico { fill: #12141a; }
