:root {
  --bg: #09131f;
  --panel: #102033;
  --panel-2: #162940;
  --line: #233c58;
  --text: #dce8f5;
  --muted: #8ea6bf;
  --accent: #4ea1ff;
  --warn: #ffc14d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 20px; font-weight: 800; white-space: nowrap; }
.brand span { color: var(--accent); }
.stats { display: flex; gap: 12px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.stats b { color: var(--warn); }
.top-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.top-actions input {
  width: 120px; padding: 6px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}

button {
  cursor: pointer; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font: inherit;
}
button:hover { border-color: var(--accent); }
button.active { background: #1d4d7a; border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }

main {
  display: grid;
  grid-template-columns: 230px minmax(320px, 1fr) 210px;
  gap: 12px; padding: 12px; align-items: start;
}
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px;
}
.panel h2 { margin: 4px 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.panel h2:not(:first-child) { margin-top: 18px; }

.tools { display: grid; gap: 5px; }
.tools button { display: grid; gap: 1px; text-align: left; position: relative; }
.tools small { color: var(--warn); font-size: 11px; }
.hint { color: var(--muted); font-size: 11px; margin: 10px 0 0; }
kbd {
  position: absolute; right: 7px; top: 6px; font: 10px monospace;
  color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 3px;
}
.credit { color: #647e99; font-size: 10px; margin: 14px 0 0; }

.diplomacy { display: grid; gap: 6px; }
.dip-row { display: grid; gap: 3px; font-size: 11px; }
.dip-row > span:first-child { display: grid; color: var(--text); }
.dip-row small { color: var(--warn); font-size: 10px; }
.dip-actions { display: flex; flex-wrap: wrap; gap: 3px; }
.dip-actions button { padding: 3px 5px; font-size: 10px; }

.stage { position: relative; line-height: 0; }
canvas {
  width: 100%; height: auto; display: block; background: #0e2a44;
  border: 1px solid var(--line); border-radius: 10px; image-rendering: pixelated; cursor: crosshair;
}

.radial { position: absolute; width: 220px; height: 220px; line-height: 1.2; z-index: 5; }
.radial[hidden] { display: none; }
.radial button {
  position: absolute; width: 66px; height: 42px; padding: 3px; font-size: 10px;
  text-align: center; border-radius: 8px; transform: translate(-50%, -50%);
  background: #102033ee;
}
.radial .radial-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--accent);
  display: grid; place-items: center; font-size: 10px; color: var(--muted);
  background: #0b1a2bcc;
}

.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: #09131fd9; border-radius: 10px; line-height: 1.4; z-index: 6;
}
.overlay[hidden] { display: none; }
.card { background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; padding: 24px 30px; text-align: center; }
.card h2 { margin-top: 0; }

ol { margin: 0; padding-left: 20px; font-variant-numeric: tabular-nums; }
ol li { padding: 2px 0; }
.backend { font-size: 11px; color: var(--muted); margin-bottom: 0; }

.log {
  margin: 0 12px 12px; padding: 8px 12px; min-height: 32px; max-height: 80px;
  overflow-y: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; color: var(--muted); font-size: 11px;
}
.log div + div { margin-top: 2px; }

.start-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 8px; padding: 8px 12px;
  background: #0d1c2e; border: 1px solid var(--accent); border-radius: 10px;
  line-height: 1.4;
}
.start-banner[hidden] { display: none; }
.start-copy { display: grid; }
.start-copy strong { font-size: 16px; }
.start-copy strong::after { content: ".pages"; color: var(--accent); }
.start-copy span { color: var(--muted); font-size: 11px; }
.nation-grid { display: flex; flex-wrap: wrap; gap: 5px; margin-left: auto; }
.nation-grid button { padding: 4px 7px; font-size: 11px; }
.nation-grid button strong { font-size: 15px; margin-right: 3px; }

@media (max-width: 1050px) {
  main { grid-template-columns: 1fr; }
  .panel { order: 2; }
  .stage { order: 1; }
  .top-actions { margin-left: 0; }
}
