:root {
  --bg: #0b1219; --sea: #0f1c27; --panel: #131d27; --panel2: #1a2632; --line: #2a3a49;
  --ink: #ebe6d8; --dim: #97a3ab; --gold: #e8c45a;
  --us: #3d7fd6; --us-lean: #7d9cc8; --neutral: #8d8873; --su-lean: #c47a6d; --su: #d23b30;
  --good: #6fbf73; --bad: #e0675b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif; }
body { display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

header { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: #0a1016; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 800; letter-spacing: 3px; color: var(--gold); }
.brand span { font-weight: 400; color: var(--dim); font-size: 12px; letter-spacing: 2px; }
.year { font-size: 26px; font-weight: 700; min-width: 64px; text-align: center; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; font-size: 13px; white-space: nowrap; }
.chip b { font-size: 15px; }
.bar { display: inline-block; width: 90px; height: 8px; border-radius: 4px; background: #24323f; vertical-align: middle; margin: 0 6px; overflow: hidden; }
.bar i { display: block; height: 100%; }
.score .vs { display: inline-flex; width: 110px; height: 8px; border-radius: 4px; overflow: hidden; vertical-align: middle; margin: 0 6px; }
.grow { flex: 1; }
.primary { background: var(--gold); color: #1a1406; border: 0; border-radius: 6px; padding: 8px 18px; font-weight: 700; }
.primary:disabled { opacity: .4; cursor: default; }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.ghost:hover:not(:disabled) { border-color: var(--dim); }
.ghost:disabled { opacity: .4; cursor: default; }

main { flex: 1; display: flex; min-height: 0; }
#mapbox { flex: 1; position: relative; background: var(--sea); min-width: 0; }
#map { width: 100%; height: 100%; display: block; cursor: grab; }
.land { stroke: none; transition: fill .6s; }
.land.click { cursor: pointer; }
.border { fill: none; stroke: #0b141c; stroke-width: 1.4; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.coast { fill: none; stroke: #0b141c; stroke-width: .6; vector-effect: non-scaling-stroke; pointer-events: none; }
.selected { fill: none; stroke: var(--gold); stroke-width: 2.2; vector-effect: non-scaling-stroke; pointer-events: none; }
.hover { fill: none; stroke: #fff; stroke-width: 1.2; vector-effect: non-scaling-stroke; pointer-events: none; }
.capital { fill: #f3ead2; stroke: #111; stroke-width: .8; vector-effect: non-scaling-stroke; pointer-events: none; }
.war { font-size: 12px; text-anchor: middle; dominant-baseline: central; fill: #ffcf8a; pointer-events: none; }
.label { font: 600 7px system-ui, sans-serif; fill: #fff; text-anchor: middle; paint-order: stroke; stroke: rgba(0,0,0,.7); pointer-events: none; }

#tip { position: absolute; pointer-events: none; background: rgba(10,16,22,.95); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; font-size: 13px; }
#legend { position: absolute; top: 10px; left: 10px; display: flex; flex-wrap: wrap; gap: 10px; background: rgba(10,16,22,.8); padding: 6px 10px; border-radius: 6px; font-size: 12px; color: var(--dim); max-width: calc(100% - 20px); }
#legend i { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.hatch { background: repeating-linear-gradient(45deg, #3c3f3a 0 3px, #26292a 3px 6px); }
#news { position: absolute; left: 10px; bottom: 10px; width: min(420px, 60%); max-height: 30%; overflow-y: auto; margin: 0; padding: 8px 12px; list-style: none; background: rgba(10,16,22,.9); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
#news li { padding: 3px 0; color: var(--dim); border-bottom: 1px solid #1c2834; }
#news li.now { color: var(--ink); }
#news li span { color: #5d6b75; margin-right: 6px; }

#panel { width: 340px; background: var(--panel); border-left: 1px solid var(--line); padding: 16px; overflow-y: auto; }
#panel h2 { margin: 0; font-size: 24px; }
#panel h3 { margin: 18px 0 8px; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--dim); }
.sub { color: var(--dim); font-size: 13px; }
.align { position: relative; height: 12px; border-radius: 6px; margin: 12px 0 4px; background: linear-gradient(90deg, var(--su), var(--su-lean) 25%, var(--neutral) 50%, var(--us-lean) 75%, var(--us)); }
.align i { position: absolute; top: -3px; width: 4px; height: 18px; background: #fff; border-radius: 2px; box-shadow: 0 0 0 1px #000; transform: translateX(-2px); }
.align b { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(0,0,0,.5); }
.ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 12px; }
.fact { background: var(--panel2); border-radius: 6px; padding: 6px 9px; }
.fact small { display: block; color: var(--dim); font-size: 12px; }
.pips i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #2a3946; margin-right: 3px; }
.pips i.on { background: var(--gold); }
.act { display: grid; grid-template-columns: 1fr auto; width: 100%; text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; margin-bottom: 7px; }
.act:hover:not(:disabled) { border-color: var(--gold); }
.act:disabled { opacity: .45; cursor: default; }
.act b { font-size: 15px; } .act em { font-style: normal; color: var(--gold); font-weight: 700; }
.act small { grid-column: 1 / -1; color: var(--dim); font-size: 12.5px; }
.warbox { margin-top: 12px; padding: 9px 11px; border-radius: 8px; border: 1px solid #5a3a22; background: #21180f; }
.warbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 6px 0 3px; }
.empty { color: var(--dim); }
.empty li { margin-bottom: 8px; }

#modal { position: fixed; inset: 0; background: rgba(3,6,10,.75); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
#modal[hidden] { display: none; }
.card { background: #f1ead6; color: #1c1a15; width: min(560px, 100%); max-height: 92vh; overflow-y: auto; border-radius: 6px; padding: 26px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.card .kicker { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: #8b2a20; font-weight: 700; }
.card h1 { margin: 6px 0 10px; font-size: 30px; line-height: 1.1; }
.card p { line-height: 1.55; }
.card .choice { display: block; width: 100%; text-align: left; margin-top: 8px; background: #fffaf0; border: 1px solid #b9ae92; border-radius: 6px; padding: 11px 13px; }
.card .choice:hover { border-color: #1c1a15; background: #fff; }
.card .choice b { display: block; font-size: 16px; }
.card .choice span { font-size: 13px; color: #5c5544; }
.card .sides { display: flex; gap: 10px; flex-wrap: wrap; }
.card .sides .choice { flex: 1; min-width: 200px; }
.card ul { padding-left: 20px; } .card li { margin-bottom: 6px; }
.card .go { width: 100%; margin-top: 14px; background: #1c1a15; color: #f1ead6; border: 0; border-radius: 6px; padding: 12px; font-weight: 700; letter-spacing: 1px; }

#toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: #f1ead6; color: #1c1a15; padding: 8px 16px; border-radius: 6px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.5); z-index: 20; }

@media (max-width: 820px) {
  main { flex-direction: column; }
  #panel { width: 100%; height: 45%; border-left: 0; border-top: 1px solid var(--line); }
  #news { display: none; }
}

.warline { fill: none; stroke: #ffa040; stroke-width: 2.5; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; pointer-events: none; animation: march 2.5s linear infinite; }
@keyframes march { to { stroke-dashoffset: -10; } }
.zone { pointer-events: none; }
.zonefill { opacity: 1; }
.zonehatch { fill: url(#occupied); opacity: .35; }
.zonecover { fill: none; stroke-width: 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.zoneline { fill: none; stroke: #0b141c; stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-dasharray: 4 2; }
.capital.fallen { stroke: #fff; stroke-width: 1.2; }
.selected.mine { stroke: #f5e3a3; stroke-width: 1.6; }
.you { font-size: 13px; font-weight: 400; color: var(--gold); }
.pacts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.pacts span { font-size: 12px; padding: 2px 8px; border-radius: 10px; border: 1px solid; }
.card .nations { max-height: 220px; overflow-y: auto; border: 1px solid #c9bea2; border-radius: 6px; padding: 4px 10px; background: #f8f2e2; }
.card .nations h4 { margin: 8px 0 4px; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: #8b2a20; }
.card .nat { background: #fffaf0; border: 1px solid #c9bea2; border-left: 4px solid var(--c); border-radius: 4px; padding: 3px 8px; margin: 0 4px 4px 0; font-size: 13px; color: #1c1a15; }
.card .nat:hover { border-color: #1c1a15; border-left-color: var(--c); }
.parties { display: flex; gap: 12px; }
.pbar { width: 24px; height: 124px; display: flex; flex-direction: column; border-radius: 4px; overflow: hidden; border: 1px solid var(--line); flex: none; }
.pbar i { display: block; width: 100%; }
.plist { flex: 1; display: flex; flex-direction: column; justify-content: space-between; font-size: 13px; }
.plist div { display: grid; grid-template-columns: 10px 1fr auto auto auto; gap: 6px; align-items: center; color: var(--dim); }
.plist div i { width: 10px; height: 10px; border-radius: 2px; }
.plist div b { color: var(--ink); }
.plist div em { font-style: normal; font-size: 11px; color: var(--gold); }
.plist div.rul span { color: var(--ink); font-weight: 600; }
.pbtn { width: 20px; height: 18px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: var(--panel2); color: var(--gold); font-weight: 700; line-height: 1; }
.pbtn:disabled { opacity: .3; cursor: default; }
.unit { pointer-events: none; }
.unit rect { stroke: #111; stroke-width: .5; }
.unit path { stroke: rgba(255,255,255,.9); stroke-width: .45; fill: none; }
.terms { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; font-size: 13px; }
.terms label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.terms label em { margin-left: auto; font-style: normal; color: var(--gold); }
.terms label.off { opacity: .4; cursor: default; }
.card .choice.on { border-color: #8b2a20; background: #f3e1c8; box-shadow: inset 4px 0 0 #8b2a20; }
.card .choice:disabled { opacity: .45; cursor: default; }
.zone.cut .zonehatch { display: none; }
.zone.cut .zoneline { stroke-dasharray: none; stroke-width: 1.4; }
.terr { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 8px 0; background: var(--panel2); }
.terr .thead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.terr .meter { display: grid; grid-template-columns: 78px 1fr 28px; gap: 8px; align-items: center; font-size: 12px; margin: 3px 0; color: var(--dim); }
.terr .meter .bar { height: 6px; background: #0b141c; border-radius: 3px; overflow: hidden; display: block; }
.terr .meter .bar i { display: block; height: 100%; }
.terr .meter b { text-align: right; }
.policies { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 8px 0 4px; }
.pol { font-size: 11px; padding: 5px 2px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--dim); }
.pol.on { border-color: var(--gold); color: var(--gold); background: rgba(240,200,90,.08); }
.tacts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 8px; }
.act.small { padding: 6px 8px; margin: 0; }
.act.small b { font-size: 12px; }
.land.restless { animation: restless 2.4s ease-in-out infinite; }
@keyframes restless { 50% { filter: brightness(1.35) saturate(1.3); } }
.tacts .act.small { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; position: relative; }
.tacts .act.small b { white-space: nowrap; }
.tacts .act.small em { position: static; font-size: 11px; }
.zone.cut .zonefill { pointer-events: fill; cursor: pointer; }
.selected.region { stroke-dasharray: 5 3; }
#tip .dim { color: #8a8f94; font-size: 11px; }
