:root {
  color-scheme: dark;
  --bg: #090d12;
  --panel: rgba(14, 20, 27, .95);
  --panel-2: #111923;
  --line: rgba(178, 205, 222, .14);
  --line-strong: rgba(200, 255, 54, .34);
  --text: #f5f8f2;
  --muted: #8e9ba7;
  --lime: #c8ff36;
  --lime-deep: #7fa919;
  --cyan: #5ee7ff;
  --magenta: #ff4aa8;
  --orange: #ff8b38;
  --danger: #ff4d59;
  --radius: 8px;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { overflow: hidden; }
button { font: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-rows: 72px 1fr; background: #080c11; }
.topbar { display: grid; grid-template-columns: 260px minmax(220px, 1fr) auto; align-items: center; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(8, 12, 17, .97); z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; letter-spacing: .08em; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: #0b1014; background: var(--lime); border-radius: 6px 6px 14px 6px; font-weight: 950; font-size: 23px; box-shadow: 0 0 24px rgba(200,255,54,.15); }
.brand > span:last-child { display: grid; }
.brand strong { font-size: 17px; line-height: 1; }
.brand small { margin-top: 4px; color: var(--lime); font: 700 10px/1 var(--mono); letter-spacing: .26em; }
.season { justify-self: center; display: flex; align-items: center; gap: 9px; font: 700 11px/1 var(--mono); letter-spacing: .12em; color: var(--muted); }
.season strong { color: var(--text); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 9px var(--lime); }
.resources { display: flex; align-items: center; height: 100%; }
.resources > div { min-width: 104px; height: 42px; display: grid; align-content: center; padding: 0 16px; border-left: 1px solid var(--line); }
.resources span { color: var(--muted); text-transform: uppercase; font: 700 9px/1 var(--mono); letter-spacing: .12em; }
.resources strong { margin-top: 6px; font: 750 14px/1 var(--mono); }
.resources .stamina strong { color: var(--cyan); }

.game-layout { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.map-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: 58px 1fr; border-right: 1px solid var(--line); }
.map-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 14px 9px 20px; background: #0c1219; border-bottom: 1px solid var(--line); }
.mission-chip { min-width: 0; display: flex; align-items: center; gap: 12px; }
.mission-chip span { flex: none; padding: 5px 7px; border: 1px solid rgba(200,255,54,.4); border-radius: 3px; color: var(--lime); font: 700 9px/1 var(--mono); letter-spacing: .1em; }
.mission-chip strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.toolbar-actions { display: flex; align-items: center; gap: 7px; }
.tool-button { height: 36px; padding: 0 12px; color: #d5dde2; background: #131c25; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; font-size: 12px; font-weight: 700; transition: .18s ease; }
.tool-button:hover, .tool-button:focus-visible { border-color: rgba(200,255,54,.5); color: var(--text); outline: none; }
.tool-button.primary { color: #10150a; background: var(--lime); border-color: var(--lime); }
.tool-button.primary[aria-pressed="true"] { color: var(--lime); background: #19210d; box-shadow: inset 0 0 0 1px var(--lime); }
.tool-button.icon-only { width: 36px; padding: 0; font-size: 18px; }
.button-icon { font-size: 17px; vertical-align: -1px; }

.canvas-wrap { position: relative; min-height: 0; overflow: hidden; background: #0a1115; }
#worldCanvas { display: block; width: 100%; height: 100%; cursor: grab; outline: none; touch-action: none; }
#worldCanvas:focus-visible { box-shadow: inset 0 0 0 2px var(--lime); }
#worldCanvas.building { cursor: crosshair; }
.coords, .zoom-level { position: absolute; top: 14px; z-index: 2; padding: 6px 9px; color: #c9d4da; background: rgba(7,11,15,.72); border: 1px solid var(--line); backdrop-filter: blur(8px); font: 700 10px/1 var(--mono); letter-spacing: .08em; pointer-events: none; }
.coords { left: 14px; }
.zoom-level { left: 142px; color: var(--lime); }
.build-hint { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); z-index: 3; display: flex; align-items: center; gap: 12px; max-width: calc(100% - 28px); padding: 9px 13px; background: rgba(14,22,10,.94); border: 1px solid var(--lime); border-radius: 5px; box-shadow: 0 10px 34px rgba(0,0,0,.3); }
.build-hint[hidden] { display: none; }
.build-hint strong { color: var(--lime); font: 800 10px/1 var(--mono); letter-spacing: .13em; }
.build-hint span { color: #d8e6cb; font-size: 12px; }
.legend { position: absolute; left: 14px; bottom: 14px; z-index: 2; display: grid; gap: 8px; padding: 11px 12px; background: rgba(7,11,15,.78); border: 1px solid var(--line); border-radius: 5px; backdrop-filter: blur(8px); font: 650 10px/1 var(--mono); color: #b8c3ca; pointer-events: none; }
.legend span { display: flex; align-items: center; gap: 8px; }
.legend i { flex: none; display: inline-block; }
.legend-swatch { width: 14px; height: 9px; border: 1px solid; }
.legend-swatch.territory { border-color: var(--lime); background: rgba(200,255,54,.18); }
.legend-swatch.rival { border-color: var(--magenta); background: rgba(255,74,168,.16); }
.legend-diamond { width: 9px; height: 9px; background: var(--danger); transform: rotate(45deg); }
.legend-node { width: 9px; height: 9px; border-radius: 50%; background: white; box-shadow: 0 0 0 2px rgba(255,255,255,.2); }
.minimap-box { position: absolute; right: 14px; bottom: 14px; z-index: 2; width: 182px; background: rgba(7,11,15,.84); border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0,0,0,.28); pointer-events: none; }
.minimap-box canvas { display: block; width: 180px; height: 140px; }
.minimap-box > span { position: absolute; left: 8px; top: 7px; color: #d9e2e7; font: 700 8px/1 var(--mono); letter-spacing: .12em; }
.toast { position: absolute; left: 50%; bottom: 22px; z-index: 6; transform: translate(-50%, 20px); opacity: 0; padding: 10px 14px; color: #11160a; background: var(--lime); border-radius: 5px; font-size: 12px; font-weight: 800; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { color: #fff; background: var(--danger); }

.command-panel { min-height: 0; overflow-y: auto; background: #0b1016; }
.alliance-card { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 11px; padding: 18px; border-bottom: 1px solid var(--line); }
.alliance-emblem { display: grid; place-items: center; width: 44px; height: 44px; color: var(--lime); background: rgba(200,255,54,.08); border: 1px solid rgba(200,255,54,.34); clip-path: polygon(50% 0, 93% 23%, 84% 78%, 50% 100%, 16% 78%, 7% 23%); font-size: 19px; font-weight: 950; }
.alliance-card > div:nth-child(2) { display: grid; min-width: 0; }
.alliance-card span, .section-heading span { color: var(--muted); font: 700 9px/1 var(--mono); letter-spacing: .12em; }
.alliance-card strong { margin-top: 5px; font-size: 13px; }
.alliance-card small { margin-top: 4px; color: #6e7c88; font-size: 10px; }
.alliance-card .power { align-self: start; color: var(--lime); font: 750 12px/1 var(--mono); }
.objective-card, .intel-card, .network-card { margin: 14px; padding: 15px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); }
.section-heading { display: flex; align-items: center; justify-content: space-between; }
.section-heading > strong { color: var(--lime); font: 800 10px/1 var(--mono); }
.section-heading button { width: 24px; height: 24px; color: var(--muted); background: transparent; border: 0; cursor: pointer; font-size: 17px; }
.objective-card h1 { margin: 14px 0 6px; font-size: 21px; letter-spacing: -.025em; }
.objective-card p { margin: 0; color: #9daab3; font-size: 12px; line-height: 1.5; }
.progress-track { height: 4px; margin: 14px 0 16px; overflow: hidden; background: #26313a; }
.progress-track span { display: block; width: 50%; height: 100%; background: var(--lime); box-shadow: 0 0 12px rgba(200,255,54,.4); transition: width .35s ease; }
.mission-steps { list-style: none; display: grid; gap: 14px; margin: 0; padding: 0; }
.mission-steps li { display: grid; grid-template-columns: 26px 1fr; align-items: center; gap: 9px; color: #71808b; }
.mission-steps li > span { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid #3a4650; border-radius: 50%; font: 700 10px/1 var(--mono); }
.mission-steps li > div { display: grid; gap: 3px; }
.mission-steps li strong { font-size: 12px; }
.mission-steps li small { color: #66737e; font-size: 10px; }
.mission-steps li.done > span { color: #10150a; background: var(--lime); border-color: var(--lime); }
.mission-steps li.done, .mission-steps li.active { color: var(--text); }
.mission-steps li.active > span { color: var(--lime); border-color: var(--lime); box-shadow: 0 0 0 3px rgba(200,255,54,.08); }
.intel-card { min-height: 170px; }
.empty-intel { min-height: 132px; display: grid; place-items: center; align-content: center; text-align: center; }
.empty-intel .scan-icon { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 10px; color: var(--cyan); border: 1px solid rgba(94,231,255,.3); border-radius: 50%; font-size: 22px; }
.empty-intel strong { font-size: 13px; }
.empty-intel p { max-width: 230px; margin: 5px 0 0; color: #73808b; font-size: 11px; line-height: 1.45; }
.intel-title { display: flex; align-items: center; gap: 10px; margin: 13px 0 12px; }
.intel-symbol { display: grid; place-items: center; width: 38px; height: 38px; color: var(--lime); background: rgba(200,255,54,.09); border: 1px solid rgba(200,255,54,.26); font-weight: 900; }
.intel-title > div { display: grid; gap: 4px; }
.intel-title strong { font-size: 14px; }
.intel-title small { color: var(--muted); font: 700 9px/1 var(--mono); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-grid > div { padding: 9px; background: #0c131a; border: 1px solid var(--line); }
.stat-grid span { display: block; color: var(--muted); font: 700 8px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.stat-grid strong { display: block; margin-top: 6px; font: 750 11px/1 var(--mono); }
.health-bar { height: 5px; margin-top: 12px; background: #2a3035; }
.health-bar span { display: block; height: 100%; background: var(--lime); }
.intel-action { width: 100%; height: 35px; margin-top: 12px; color: #0e1209; background: var(--lime); border: 0; border-radius: 4px; cursor: pointer; font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: .07em; }
.intel-action.danger { color: white; background: var(--danger); }
.network-card { display: grid; gap: 10px; }
.network-row { display: flex; align-items: center; justify-content: space-between; padding-top: 9px; border-top: 1px solid var(--line); color: #8b99a4; font-size: 11px; }
.network-row strong { color: #dce4e8; font: 700 10px/1 var(--mono); }
.panel-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 14px 18px; }
.panel-footer button { padding: 0; color: #82909a; background: transparent; border: 0; cursor: pointer; font-size: 10px; text-decoration: underline; text-underline-offset: 3px; }
.panel-footer > span { color: #4d5a64; font: 700 8px/1 var(--mono); }

@media (max-width: 1050px) {
  .topbar { grid-template-columns: 210px 1fr auto; padding: 0 14px; }
  .resources > div { min-width: 82px; padding: 0 10px; }
  .resources > div:nth-child(2), .resources > div:nth-child(3) { display: none; }
  .game-layout { grid-template-columns: minmax(0, 1fr) 310px; }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .app-shell { min-height: 100svh; grid-template-rows: 60px auto; }
  .topbar { position: sticky; top: 0; grid-template-columns: 1fr auto; height: 60px; padding: 0 12px; }
  .season { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .resources > div { min-width: auto; padding: 0 10px; }
  .resources > div:not(.stamina) { display: none; }
  .game-layout { display: block; }
  .map-panel { height: 66svh; min-height: 470px; grid-template-rows: auto 1fr; border-right: 0; }
  .map-toolbar { align-items: flex-start; padding: 9px 10px; }
  .mission-chip { display: grid; gap: 6px; }
  .mission-chip strong { max-width: 180px; font-size: 11px; }
  #centerButton { display: none; }
  .tool-button { padding: 0 9px; }
  .tool-button.primary { font-size: 0; width: 38px; }
  .tool-button.primary .button-icon { font-size: 19px; }
  .legend { display: none; }
  .minimap-box { right: 8px; bottom: 8px; width: 122px; }
  .minimap-box canvas { width: 120px; height: 94px; }
  .build-hint { top: 48px; width: calc(100% - 20px); }
  .build-hint span { font-size: 10px; }
  .command-panel { max-height: none; overflow: visible; border-top: 1px solid var(--line); }
  .alliance-card { padding: 14px; }
  .objective-card, .intel-card, .network-card { margin: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
