:root {
  --bg: #0b1220;
  --panel: #121a2b;
  --panel2: #182338;
  --text: #eef3ff;
  --muted: #9aa8c3;
  --primary: #3b82f6;
  --primary2: #2563eb;
  --danger: #ef4444;
  --good: #22c55e;
  --gold: #f5c542;
  --border: #243149;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 16px;
  font-family: "Segoe UI", Tahoma, system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  height: 100%; overflow: hidden;
}
#app { height: 100%; width: 100%; max-width: 520px; margin: 0 auto; position: relative; }
.screen {
  display: none; height: 100%; overflow: auto; padding: 14px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}
.screen.active { display: block; }
.hero {
  min-height: 100%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; gap: 10px;
}
.logo {
  width: 88px; height: 88px; border-radius: 24px; display:grid; place-items:center;
  font-size: 42px; background: linear-gradient(145deg, #1e3a5f, #0f172a);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
h1 { margin: 8px 0 0; font-size: 1.7rem; }
.sub, .muted, .tiny { color: var(--muted); }
.tiny { font-size: 12px; word-break: break-all; }
.status {
  margin: 12px 0; padding: 10px 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border); font-size: 14px;
}
.status.ok { color: var(--good); }
.status.err { color: #ff8e8e; }
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--panel2);
  color: var(--text); border-radius: 12px; padding: 12px 14px; font-weight: 700;
  font-size: 14px; cursor: pointer;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--primary), var(--primary2)); border-color: transparent; }
.btn.danger { background: linear-gradient(180deg, #f87171, var(--danger)); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn:active { transform: scale(.98); }
.top { margin-bottom: 12px; }
.top.bar { display:flex; align-items:center; justify-content:space-between; gap: 8px; }
.title { font-weight: 800; font-size: 1.05rem; }
.resources { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.res {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 6px; text-align: center;
}
.res b { display:block; font-size: 12px; color: var(--gold); }
.res span { font-size: 12px; }
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.panel.compact { padding: 10px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display:flex; align-items:center; justify-content:space-between; gap: 8px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 12px; padding: 10px;
}
.item .meta { font-size: 12px; color: var(--muted); }
.row { display:flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.input {
  flex: 1; min-width: 90px; background: #0d1524; color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; font-size: 14px;
}
.input.small { flex: 0 0 84px; min-width: 70px; }
.civ-list { display: grid; gap: 10px; padding-bottom: 90px; }
.civ {
  text-align: right; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 14px; cursor: pointer;
}
.civ.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.civ h3 { margin: 0 0 4px; }
.civ p { margin: 0; color: var(--muted); font-size: 13px; }
.bottom-bar, .bottom-nav {
  position: sticky; bottom: 0; background: linear-gradient(180deg, transparent, var(--bg) 30%);
  padding: 12px 0 calc(8px + env(safe-area-inset-bottom)); display:flex; gap: 8px;
}
.map-wrap {
  position: relative; background: #071018; border: 1px solid var(--border);
  border-radius: 18px; overflow: hidden; margin-bottom: 10px; touch-action: none;
}
#map {
  width: 100%; height: auto; display: block;
  background:
    radial-gradient(circle at 30% 20%, #16324f 0%, transparent 40%),
    radial-gradient(circle at 70% 80%, #1a3b2f 0%, transparent 35%),
    #0a1420;
}
.map-hud { position: absolute; inset: 8px 8px auto 8px; display:flex; flex-direction: column; gap: 6px; }
.pill {
  align-self: flex-start; background: rgba(8,14,24,.82); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 10px; font-size: 12px; backdrop-filter: blur(6px);
}
.pill.dim { color: var(--muted); }
.reports { max-height: 140px; overflow: auto; font-size: 12px; color: var(--muted); }
.reports div { padding: 6px 0; border-bottom: 1px dashed #243149; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #111827; border: 1px solid var(--border); color: var(--text);
  padding: 10px 14px; border-radius: 999px; z-index: 50; max-width: 90%;
  box-shadow: var(--shadow); font-size: 13px;
}
.toast.hidden { display: none; }
select.input { color-scheme: dark; }
