:root {
  --bg: #0A0E1A;
  --panel: #141c33;
  --panel-2: #1C2642;
  --panel-lt: #2B3859;
  --line: rgba(140, 204, 255, 0.14);
  --ink: #FFFFFF;
  --ink-2: #b9c6e4;
  --ink-3: #7d8cb0;
  --nova: #52A8FF;
  --energy: #8CCCFF;
  --gold: #FFE666;
  --attack: #FFB84D;
  --good: #73E68C;
  --bad: #FF6666;
  --f-nova: #52A8FF;
  --f-vexari: #8CD959;
  --f-solari: #FFD14D;
  --f-mechron: #FF9940;
  --f-corsairs: #D966D9;
  --head: "SF Pro Display", "Helvetica Neue", "Segoe UI", system-ui, -apple-system, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg) url("/art/bg_frontier.jpg") center / cover fixed;
  color: var(--ink);
  font: 15px/1.45 var(--body);
  min-height: 100vh;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(10,14,26,0.82), rgba(10,14,26,0.94));
}
h1, h2, h3, h4 { font-family: var(--head); margin: 0 0 0.5em; letter-spacing: 0.02em; }
h2 { font-size: 1.15rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--energy); }
h3 { font-size: 1rem; }
a { color: var(--nova); }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--ink-3); }
.small { font-size: 0.85rem; }
.num { font-variant-numeric: tabular-nums; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--attack); }
[hidden] { display: none !important; }

/* ---------- Buttons & inputs ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 9px;
  padding: 0.5em 0.9em; cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--panel-lt); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #5fb2ff, #2f7fe0); border-color: transparent; color: #05101f; }
.btn.danger { background: linear-gradient(180deg, #ff8a6a, #e2493a); border-color: transparent; color: #1a0603; }
.btn.small { padding: 0.3em 0.6em; font-size: 0.82rem; }
.btn.ghost { background: transparent; }
input[type=text], input[type=number], select {
  background: #0d1428; border: 1px solid var(--line); border-radius: 8px; padding: 0.45em 0.6em; min-width: 0;
}
input[type=number] { width: 6.5em; }
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--nova); outline-offset: 1px; }

/* ---------- Layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.panel {
  background: rgba(20, 28, 51, 0.88); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; backdrop-filter: blur(6px);
}
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

/* ---------- Join screen ---------- */
.join { padding: 28px 0 60px; }
.join-hero { text-align: center; margin-bottom: 24px; }
.join-hero img { width: min(240px, 60vw); mix-blend-mode: screen; }
.join-hero h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); text-transform: uppercase; letter-spacing: 0.14em; margin-top: 6px; }
.join-hero p { color: var(--ink-2); max-width: 640px; margin: 0 auto; }
.factions { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); margin: 22px 0; }
.faction-card {
  text-align: left; cursor: pointer; padding: 16px; border-radius: var(--radius);
  background: rgba(20,28,51,0.9); border: 2px solid var(--line); position: relative;
}
.faction-card img { width: 64px; height: 64px; object-fit: contain; float: right; margin: -4px -4px 4px 8px; }
.faction-card h3 { font-size: 1.15rem; }
.faction-card ul { padding-left: 1.1em; margin: 8px 0 0; color: var(--ink-2); font-size: 0.9rem; }
.faction-card .tag { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }
.faction-card[aria-pressed=true] { border-color: var(--fc); box-shadow: 0 0 0 1px var(--fc), 0 0 28px color-mix(in srgb, var(--fc) 35%, transparent); }
.faction-card.locked { opacity: 0.45; cursor: default; }
.join-form { max-width: 560px; margin: 0 auto; }
.join-form label { display: block; font-size: 0.85rem; color: var(--ink-2); margin-bottom: 4px; }
.join-form input { width: 100%; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(10,14,26,0.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.topbar .wrap { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.ident { display: flex; gap: 10px; align-items: center; min-width: 0; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.ident .portrait { width: 40px; height: 40px; }
.ident b { font-family: var(--head); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.res { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; font-size: 0.85rem; }
.chip b { font-variant-numeric: tabular-nums; }
.chip .inc { color: var(--good); font-size: 0.75rem; margin-left: 4px; }
.chip .inc.neg { color: var(--bad); }
.tickbox { display: flex; gap: 6px; align-items: center; }
.tickbox .t { font-family: var(--head); font-weight: 800; }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 0 16px; max-width: 1180px; margin: 0 auto; scrollbar-width: none; }
nav.tabs button {
  background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 12px; cursor: pointer;
  color: var(--ink-2); font-weight: 600; white-space: nowrap;
}
nav.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--nova); }
.badge { background: var(--bad); color: #fff; border-radius: 99px; font-size: 0.7rem; padding: 1px 6px; margin-left: 4px; }
main { padding: 18px 0 60px; }

/* ---------- Banners ---------- */
.banner { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; border: 1px solid; }
.banner.shield { border-color: rgba(140,204,255,0.4); background: rgba(82,168,255,0.1); }
.banner.ally { border-color: rgba(255,184,77,0.6); background: rgba(255,184,77,0.1); }
.banner.alert.hollow { border-color: rgba(158,89,242,0.7); background: rgba(158,89,242,0.14); }
.banner.alert { border-color: rgba(255,102,102,0.55); background: rgba(255,102,102,0.12); }

/* ---------- Command ---------- */
.world-card { display: flex; gap: 14px; align-items: center; }
.world-card .planet { width: 86px; height: 86px; object-fit: contain; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.pip { display: flex; gap: 12px; align-items: flex-start; }
.pip img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; object-position: top; border: 2px solid var(--line); flex-shrink: 0; }
.pip q { font-style: italic; color: var(--ink-2); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--ink-3); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
td.r, th.r { text-align: right; }
.table-scroll { overflow-x: auto; }

/* ---------- Launch & battle preview ---------- */
.launch-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; align-items: center; max-width: 640px; }
.launch-grid select { width: 100%; }
.send-list { display: grid; gap: 6px; margin-top: 8px; }
.send-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.send-row input { width: 5.5em; }
.preview:empty { display: none; }
.preview { margin-top: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: start; }
.versus .vs { font-family: var(--head); font-weight: 800; color: var(--ink-3); align-self: center; }
.versus > div:last-child { text-align: right; }
.unknown { font-family: var(--head); font-size: 1.8rem; font-weight: 800; color: var(--ink-3); letter-spacing: 0.1em; }
.odds { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.odds-bar span.good { background: var(--good); }
.odds-bar span.warn { background: var(--attack); }
.odds-bar span.bad { background: var(--bad); }
@media (max-width: 560px) { .send-row { grid-template-columns: 1fr auto; } .send-row > span:nth-child(2) { display: none; } }

/* ---------- Autopilot ---------- */
.ap-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 10px; }
.ap-switch { display: flex; gap: 8px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.ap-switch input { margin-top: 3px; accent-color: var(--nova); }
.ap-switch span { display: flex; flex-direction: column; }
.log-item.auto { border-left-color: var(--energy); }

/* ---------- Planets & research ---------- */
.ship.building { min-height: 0; }
.ship.building.unbuilt { opacity: 0.85; }
.tree { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tree-col { display: flex; flex-direction: column; gap: 8px; }
.tech { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--panel); display: flex; flex-direction: column; gap: 6px; }
.tech.done { border-color: rgba(115,230,140,0.45); opacity: 0.8; }
.tech.active { border-color: var(--nova); box-shadow: 0 0 0 1px var(--nova); }
.tech.locked { opacity: 0.55; }
.bar { height: 10px; background: #0d1428; border-radius: 99px; overflow: hidden; margin: 10px 0 6px; border: 1px solid var(--line); }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, #2f7fe0, #8CCCFF); }
@media (max-width: 1000px) { .tree { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .tree { grid-template-columns: 1fr; } }

/* ---------- Activity log ---------- */
.log { display: grid; gap: 6px; margin-top: 10px; }
.log-item { display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.log-item:hover { background: var(--panel-2); }
.log-item.win { border-left-color: var(--good); }
.log-item.loss { border-left-color: var(--bad); }
.log-item.unread b::after { content: " ●"; color: var(--nova); font-size: 0.7em; vertical-align: middle; }
.log-icon { font-weight: 800; width: 1.1em; flex-shrink: 0; }
.log-item.win .log-icon { color: var(--good); }
.log-item.loss .log-icon { color: var(--bad); }

/* ---------- Shipyard ---------- */
.tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.tier { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--panel); font-size: 0.85rem; }
.tier.done { border-color: rgba(115,230,140,0.5); }
.tier.next { border-color: var(--nova); }
.tier b { display: block; font-family: var(--head); }
.ships { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.ship { background: rgba(20,28,51,0.92); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.ship .art { height: 150px; background: #050810 center / cover no-repeat; position: relative; }
.ship .art .cls { position: absolute; left: 8px; top: 8px; background: rgba(5,8,16,0.8); border-radius: 6px; padding: 2px 7px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }
.ship .body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.ship .stats { display: flex; gap: 10px; flex-wrap: wrap; font-size: 0.82rem; color: var(--ink-2); }
.ship .flavor { font-size: 0.8rem; color: var(--ink-3); font-style: italic; }
.ship.locked .art { filter: grayscale(1) brightness(0.4); }
.ship.locked .art::after { content: "🔒"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 2rem; }
.ship .buy { margin-top: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---------- Galaxy ---------- */
.sector-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.systems { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.world-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.world-row:last-child { border-bottom: 0; }
.world-row img { width: 30px; height: 30px; object-fit: contain; }
.world-row .nm { min-width: 0; }
.world-row .nm b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.world-row.mine { background: rgba(82,168,255,0.1); border-radius: 8px; }
.world-row .acts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.ai { display: inline-block; font-size: 0.72rem; color: var(--ink-3); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; margin-left: 4px; white-space: nowrap; }

/* ---------- Comms ---------- */
.msg-log { max-height: 420px; min-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; margin: 10px 0; }
.msg { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px 12px 12px 4px; padding: 8px 11px; max-width: 85%; align-self: flex-start; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; background: rgba(82,168,255,0.16); border-radius: 12px 12px 4px 12px; }
.compose { display: flex; gap: 8px; align-items: flex-end; }
.compose textarea { flex: 1; background: #0d1428; border: 1px solid var(--line); border-radius: 8px; padding: 8px; resize: vertical; font: inherit; color: inherit; }
textarea { background: #0d1428; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; color: inherit; }

/* ---------- Help ---------- */
.faq details { border-bottom: 1px solid var(--line); padding: 8px 0; }
.faq details:last-child { border-bottom: 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq summary:hover { color: var(--energy); }
.faq details p { margin: 6px 0 2px; color: var(--ink-2); }
.modal-card .faq { margin-top: 12px; }

/* ---------- Nearby ---------- */
.planet-list .world-row { grid-template-columns: 30px 1fr; }
.planet-list .world-row .acts { grid-column: 1 / -1; justify-content: flex-start; padding-left: 38px; }

/* ---------- Reports ---------- */
.reports { display: grid; gap: 14px; grid-template-columns: minmax(240px, 340px) 1fr; }
.report-list { max-height: 70vh; overflow-y: auto; }
.report-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 9px 6px; cursor: pointer; }
.report-item:hover, .report-item[aria-current=true] { background: rgba(82,168,255,0.08); }
.report-item.unread b::before { content: "● "; color: var(--nova); }
.outcome { font-family: var(--head); font-size: 1.2rem; font-weight: 800; }

/* ---------- Modal & toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); max-width: 640px; width: 100%; max-height: 86vh; overflow-y: auto; padding: 20px; position: relative; }
.modal-close { position: absolute; right: 10px; top: 6px; background: none; border: 0; font-size: 1.6rem; cursor: pointer; color: var(--ink-2); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgba(0,0,0,0.5); }
.toast.err { border-color: var(--bad); }

@media (max-width: 980px) {
  .res { order: 3; flex-basis: 100%; }
  .tickbox { margin-left: auto; }
}
@media (max-width: 720px) {
  .reports { grid-template-columns: 1fr; }
  .report-list { max-height: 260px; }
  .ident b { max-width: 150px; }
  .systems { grid-template-columns: 1fr; }
}

/* ---------- Sign-in ---------- */
.age { display: flex; gap: 8px; align-items: center; font-size: 0.9rem; }
.age input { accent-color: var(--nova); width: 18px; height: 18px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 0.85rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.google-btn { display: flex; justify-content: center; min-height: 44px; }

/* ---------- Portraits, tags, banners ---------- */
.portrait { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid var(--line); flex-shrink: 0; }
.portrait.sm { width: 30px; height: 30px; }
.portrait.big { width: 72px; height: 72px; }
.who { display: flex; gap: 8px; align-items: center; min-width: 0; }
.ntag { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gold); border: 1px solid rgba(255,230,102,0.4); border-radius: 5px; padding: 0 5px; margin-left: 2px; font-weight: 700; vertical-align: middle; }
.portrait-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px; }
.pick { background: none; border: 2px solid transparent; border-radius: 50%; padding: 2px; cursor: pointer; display: grid; place-items: center; }
.pick.on { border-color: var(--nova); }
.pick .portrait { width: 48px; height: 48px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; color: var(--ink-3); }
.swatch.on { outline: 2px solid #fff; outline-offset: 2px; }
.banner-chip { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.menu-list { display: grid; gap: 8px; }
.menu-list button, .menu-list .menu-link { text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-size: 1rem; cursor: pointer; }
.subtabs { margin-bottom: 14px; }
.menu-list .menu-link { display: block; color: var(--ink); text-decoration: none; }
.badge.dotbadge { padding: 0; width: 8px; height: 8px; display: inline-block; vertical-align: top; }

/* ---------- Phones: bottom tab bar ---------- */
.bottombar { display: none; }
@media (max-width: 720px) {
  nav.tabs { display: none; }
  .bottombar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: rgba(10,14,26,0.97); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
    backdrop-filter: blur(8px);
  }
  .bottombar button { background: none; border: 0; color: var(--ink-3); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: 0.7rem; min-height: 56px; position: relative; cursor: pointer; }
  .bottombar button[aria-current=true] { color: var(--ink); }
  .bottombar button[aria-current=true] .bi { transform: scale(1.12); }
  .bottombar .bi { font-size: 1.3rem; line-height: 1; }
  .bottombar .badge { position: absolute; top: 4px; left: 55%; }
  main { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .topbar .wrap { padding-top: 8px; padding-bottom: 8px; gap: 8px; }
  .res { gap: 5px; }
  .chip { padding: 3px 7px; font-size: 0.8rem; }
  .hide-sm { display: none; }
  .tickbox .btn.small { padding: 0.35em 0.55em; }
  .btn { min-height: 40px; }
  .btn.small { min-height: 34px; }
  input[type=number] { font-size: 16px; }
  input[type=text], input[type=email], select, textarea { font-size: 16px; }
  .ident b { max-width: 140px; }
}

/* ---------- Landing page ---------- */
.land-nav { position: sticky; top: 0; z-index: 20; background: rgba(10,14,26,0.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.land-nav .wrap { padding-top: 10px; padding-bottom: 10px; }
.land-nav nav { gap: 16px; }
.land-nav nav a:not(.btn) { color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.doc-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--head); font-weight: 800; letter-spacing: 0.04em; }
.doc-brand img { width: 32px; height: 32px; border-radius: 8px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, 420px); gap: 32px; align-items: center; padding-top: 36px; padding-bottom: 28px; }
.hero-logo { width: min(220px, 50vw); mix-blend-mode: screen; margin-left: -12px; }
.hero-copy h1 { font-size: clamp(2rem, 5vw, 3.2rem); text-transform: uppercase; letter-spacing: 0.16em; margin: 0 0 10px; }
.lede { font-size: 1.12rem; color: var(--ink-2); max-width: 560px; }
.hero-points { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 8px; color: var(--ink-2); }
.signin-card { box-shadow: 0 20px 60px rgba(0,0,0,0.45), 0 0 0 1px rgba(82,168,255,0.18); }
.signin-card label { font-size: 0.85rem; color: var(--ink-2); }
.landing section.wrap { margin-bottom: 34px; }
.landing h2 { margin-bottom: 14px; }
.live-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-family: var(--head); font-size: 1.8rem; font-weight: 900; color: var(--nova); line-height: 1.1; }
.stats b small { font-size: 0.9rem; color: var(--ink-3); font-weight: 600; }
.stats span { color: var(--ink-3); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.faction-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; margin: 14px 0 8px; background: #0d1428; }
.news-item { padding: 6px 0; border-bottom: 1px solid var(--line); }
.news-item:last-child { border-bottom: 0; }
.top-row { padding: 5px 0; }
.top-row .rank { width: 1.4em; color: var(--ink-3); font-weight: 800; }
.pulse { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--good); margin-right: 6px; box-shadow: 0 0 0 0 rgba(115,230,140,0.7); animation: pulse 2s infinite; vertical-align: middle; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(115,230,140,0.6); } 70% { box-shadow: 0 0 0 10px rgba(115,230,140,0); } 100% { box-shadow: 0 0 0 0 rgba(115,230,140,0); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }
.shot-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.shot { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.shot img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; }
.shot.tall img { aspect-ratio: 16 / 10; object-fit: contain; background: #070a14; }
.shot figcaption { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; font-size: 0.88rem; color: var(--ink-2); }
.shot figcaption b { color: var(--ink); }
.how-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.how-grid p { margin: 6px 0 0; }
.site-foot { border-top: 1px solid var(--line); padding: 18px 0 28px; color: var(--ink-3); font-size: 0.85rem; }
.site-foot .row { gap: 16px; }
.site-foot a { color: var(--ink-2); }
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; padding-top: 18px; }
  .hero-logo { width: 160px; }
  .land-nav nav a:not(.btn) { display: none; }
}

/* ---------- Privacy / Terms ---------- */
.doc-head { border-bottom: 1px solid var(--line); background: rgba(10,14,26,0.9); }
.doc-head .wrap { padding-top: 12px; padding-bottom: 12px; }
.doc { max-width: 760px; padding-top: 28px; padding-bottom: 40px; line-height: 1.65; }
.doc h1 { font-size: 2rem; }
.doc h2 { margin-top: 28px; }
.doc h3 { margin-top: 18px; color: var(--ink-2); }
.doc li { margin: 4px 0; }
.doc code { background: #0d1428; padding: 1px 6px; border-radius: 5px; }

/* ---------- Moderation ---------- */
.admin-stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); margin-bottom: 14px; }
.admin-stats .panel { padding: 10px 12px; display: flex; flex-direction: column; }
.admin-stats b { font-family: var(--head); font-size: 1.5rem; color: var(--nova); }
.admin-stats span { font-size: 0.75rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
.quote { margin: 6px 0; padding: 8px 10px; border-left: 3px solid var(--bad); background: var(--panel); border-radius: 0 8px 8px 0; font-size: 0.9rem; }
.msg-scroll { max-height: 240px; overflow-y: auto; }

/* ---------- Rankings ---------- */
.stats-row { grid-template-columns: repeat(4, 1fr); }
.rank-big { font-family: var(--head); font-size: 2rem; font-weight: 900; color: var(--gold); line-height: 1; }
.rank-layout { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); }
.rank-cell { font-weight: 800; width: 2.2em; }
tr.me-row td { background: rgba(82,168,255,0.1); }
@media (max-width: 860px) { .rank-layout { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Nearby (compact) ---------- */
.sys-list { display: grid; gap: 6px; }
.sys-row { background: rgba(20,28,51,0.88); border: 1px solid var(--line); border-radius: 10px; }
.sys-row.open { border-color: rgba(82,168,255,0.35); }
.sys-head { width: 100%; display: flex; gap: 10px; align-items: center; background: none; border: 0; padding: 10px 12px; cursor: pointer; text-align: left; min-height: 48px; }
.sys-head .caret { color: var(--ink-3); width: 1em; }
.sys-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sys-meta { white-space: nowrap; }
.sys-row .planet-list { padding: 0 12px 8px; }
.chips { gap: 6px; }

/* ---------- Cycle arc ---------- */
.cycle-strip { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 14px; background: rgba(20,28,51,0.85); }
.cycle-strip.phase-signal { border-color: rgba(158,89,242,0.45); background: rgba(158,89,242,0.08); }
.cycle-strip.phase-crown { border-color: rgba(158,89,242,0.7); background: rgba(158,89,242,0.14); }
.cycle-bar { position: relative; flex: 0 1 260px; height: 8px; background: #0d1428; border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.cycle-bar > span { display: block; height: 100%; background: linear-gradient(90deg, #2f7fe0, #9E59F2); }
.cycle-bar i { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,0.35); }
.crown-panel { margin-top: 14px; border-color: rgba(158,89,242,0.55); background: linear-gradient(180deg, rgba(158,89,242,0.12), rgba(20,28,51,0.9)); }
.crown-bar span { background: linear-gradient(90deg, #9E59F2, #c9a6ff); }
.pip.story img { width: 80px; height: 80px; }
.record { border-top: 1px solid var(--line); padding: 10px 0; }
.record:first-of-type { border-top: 0; }
.record-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr; gap: 12px; margin-top: 6px; }
@media (max-width: 560px) { .record-grid { grid-template-columns: 1fr; } }

/* ---------- Powers ---------- */
.powers { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.power .band { font-weight: 800; font-family: var(--head); }
.standing-bar { position: relative; height: 8px; border-radius: 99px; margin: 10px 0 8px; background: linear-gradient(90deg, #FF6666 0%, #FF9940 20%, #b9c6e4 38%, #8CCCFF 57%, #73E68C 70%, #FFE666 85%); opacity: 0.85; }
.standing-bar span { position: absolute; top: -4px; width: 4px; height: 16px; margin-left: -2px; border-radius: 2px; background: #fff; box-shadow: 0 0 0 2px #0A0E1A; }
.contract { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--panel); }
.contract.active { border-color: rgba(82,168,255,0.5); }
.contract.done { opacity: 0.7; }
.contract.failed { opacity: 0.6; }
.contract q { color: var(--ink-2); font-style: italic; }

/* ---------- The Frontier Dispatch ---------- */
.masthead { font-family: Georgia, "Times New Roman", serif; text-transform: none; letter-spacing: 0.01em; color: var(--ink); font-weight: 800; }
.dispatch-head { text-align: center; border-bottom: 3px double var(--line); padding-bottom: 8px; margin-bottom: 12px; }
.dispatch-head .masthead { font-size: clamp(1.6rem, 5vw, 2.6rem); margin: 0; }
.headline { font-family: Georgia, serif; font-size: 1.1rem; font-weight: 700; line-height: 1.3; margin: 10px 0 4px; }
.headline.big { font-size: clamp(1.2rem, 3.5vw, 1.7rem); text-align: center; margin: 4px 0 16px; }
.kicker { font-size: 0.82rem; letter-spacing: 0.12em; color: var(--gold); margin: 0 0 6px; }
.dispatch-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
.news-item { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.news-item:last-child { border-bottom: 0; }
.nicon { width: 1.4em; flex-shrink: 0; text-align: center; }
.rumour { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; font-size: 0.92rem; }
.rumour q { color: var(--ink-2); font-style: italic; }
.dispatch-front { background: linear-gradient(180deg, rgba(255,230,102,0.05), rgba(20,28,51,0.9)); }
@media (max-width: 860px) { .dispatch-grid { grid-template-columns: 1fr; } }

/* ---------- Coordinates & friends ---------- */
.where { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 14px; align-items: center; }
.wheel { width: 200px; height: 200px; display: block; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.fcode { font-size: 1.3rem; font-weight: 800; letter-spacing: 0.08em; background: #0d1428; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.friend { border-top: 1px solid var(--line); padding: 8px 0; }
@media (max-width: 560px) { .where { grid-template-columns: 1fr; justify-items: center; } }

/* Carrier groups */
.group-icon { width: 30px; height: 30px; display: grid; place-items: center; font-size: 20px; }
.group-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: rgba(82, 168, 255, 0.06); }

/* ---------- Mission sheet (target first) ---------- */
.modal-card.sheet { max-width: 560px; }
@media (max-width: 720px) {
  .modal:has(.sheet) { place-items: end center; padding: 0; }
  .modal-card.sheet { border-radius: 18px 18px 0 0; max-height: 92vh; padding-bottom: calc(20px + env(safe-area-inset-bottom)); animation: sheet-up 0.18s ease-out; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.mission label { display: block; margin: 10px 0 4px; }
.mission select, .mission input[type=text] { width: 100%; }
.m-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; padding-right: 28px; }
.m-icon { font-size: 1.5rem; width: 44px; height: 44px; display: grid; place-items: center; background: var(--panel-2); border-radius: 12px; flex: none; }
.m-kinds { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding-bottom: 4px; scrollbar-width: none; }
.m-kinds::-webkit-scrollbar { display: none; }
.m-kinds .btn { white-space: nowrap; }
.m-help { margin: 6px 0 0; }
.m-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 6px; }
.m-ships { display: flex; flex-direction: column; }
.m-ship { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.stepper { display: flex; align-items: center; gap: 4px; flex: none; }
.stepper input { width: 4.6em; text-align: center; }
.stepper .btn { width: 34px; padding: 0; justify-content: center; }
.fleet-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.fleet-card.returning { opacity: 0.8; }
.bar.thin { height: 4px; margin: 7px 0 5px; }

/* ---------- Command: needs-you + stat tiles ---------- */
.needs { margin-bottom: 12px; }
.needs q { font-size: 1.02rem; }
.todo-list { margin-bottom: 12px; padding-top: 12px; padding-bottom: 6px; }
.todo { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.todo:first-of-type { border-top: 0; }
.todo .ti { font-size: 1.15rem; text-align: center; }
.todo .tt { font-size: 0.92rem; }
.stat-tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.stat-tiles .tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; display: flex; flex-direction: column; min-width: 0; }
.stat-tiles .k { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
.stat-tiles b { font-family: var(--head); font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-tiles .s { font-size: 0.75rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 900px) { .stat-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- Resource icons ---------- */
.ri { display: inline-block; width: 1em; text-align: center; margin-right: 3px; font-style: normal; }
.ri.a { color: #c9d3e6; }
.ri.n { color: #6fe0ff; }
.ri.i { color: #c9a6ff; }

/* ---------- Swipeable sub-tabs on phones ---------- */
@media (max-width: 720px) {
  .sector-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px 2px; }
  .sector-tabs::-webkit-scrollbar { display: none; }
  .sector-tabs .btn { white-space: nowrap; flex: none; }
  /* Top bar: name + clock on one row, resources on the next. */
  .ident .portrait { width: 34px; height: 34px; }
  .ident .muted.small { display: none; }
  .res .rl { display: none; }
  .res { flex-wrap: nowrap; }
  .chip .inc { margin-left: 3px; }
}
details.fold { margin-top: 10px; }
details.fold > summary { cursor: pointer; color: var(--ink-2); font-weight: 600; padding: 8px 0; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸ "; color: var(--ink-3); }
details.fold[open] > summary::before { content: "▾ "; }
.rec { display: flex; gap: 12px; align-items: center; justify-content: space-between; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.rec .kicker { display: block; margin: 0 0 2px; }

/* ---------- Sector grid: a fixed window, no inner scrolling ---------- */
.sector { margin-bottom: 14px; overflow-anchor: none; }
.sector-top { margin-bottom: 8px; }
.spoke-tabs { display: flex; gap: 4px; margin-bottom: 12px; max-width: 420px; }
.spoke-tabs .btn { flex: 1; justify-content: center; font-weight: 800; min-width: 0; }
.sector-body { display: grid; grid-template-columns: minmax(0, 320px) 1fr; gap: 18px; align-items: start; }
.gwrap { width: 100%; max-width: 320px; }
.chart { background: radial-gradient(ellipse at 50% 40%, rgba(82, 168, 255, 0.10), transparent 70%), #070b17; border: 1px solid var(--line); border-radius: 14px; padding: 10px 10px 4px 4px; }
.glanes, .grow { display: grid; grid-template-columns: 24px repeat(6, 1fr); gap: 4px; align-items: center; }
.glanes { font-size: 0.66rem; color: var(--ink-3); text-align: center; padding: 2px 0 4px; }
.grow { margin-bottom: 4px; }
.rlabel { font-size: 0.66rem; color: var(--ink-3); text-align: right; padding-right: 4px; font-variant-numeric: tabular-nums; }
.pan { width: 100%; background: transparent; border: 1px dashed var(--line); color: var(--ink-2); border-radius: 10px; padding: 7px; font-size: 0.8rem; cursor: pointer; margin: 6px 0; }
.pan:disabled { opacity: 0.35; cursor: default; }
.pan:not(:disabled):hover { border-color: var(--energy); color: var(--ink); }
/* Each system is a dot; what's there sets its colour and symbol. */
.cell { aspect-ratio: 1; border: 0; background: none; padding: 0; cursor: pointer; display: grid; place-items: center; touch-action: manipulation; }
.cell span { width: 74%; height: 74%; border-radius: 50%; display: grid; place-items: center; font-size: 0.78rem; line-height: 1; color: var(--ink-2); background: rgba(140, 204, 255, 0.12); transition: transform 0.1s; }
.cell.unk span { width: 26%; height: 26%; background: rgba(255, 255, 255, 0.13); }
.cell.live span { box-shadow: 0 0 0 1px rgba(115, 230, 140, 0.35); }
.cell.open span { color: var(--good); background: rgba(115, 230, 140, 0.14); }
.cell.npc span { color: var(--attack); background: rgba(255, 184, 77, 0.16); }
.cell.gov span { color: #ffb0b0; background: rgba(255, 102, 102, 0.22); }
.cell.friend span { color: #FF8FB8; background: rgba(255, 143, 184, 0.22); }
.cell.mine span { color: #1a1400; background: var(--gold); box-shadow: 0 0 12px rgba(255, 230, 102, 0.55); }
.cell.crown span { background: rgba(158, 89, 242, 0.5); }
.cell.sel span { outline: 2px solid #fff; outline-offset: 2px; transform: scale(1.08); }
.cell:hover span { transform: scale(1.12); }
.grid-core { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: radial-gradient(ellipse at center, rgba(158, 89, 242, 0.18), transparent 70%), #070b17; }
.sealed { height: 180px; display: grid; place-items: center; text-align: center; color: var(--ink-3); border: 1px dashed var(--line); border-radius: 14px; padding: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 10px; }
.legend > span { display: inline-flex; align-items: center; }
.legend .lg { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; margin-right: 5px; font-size: 0.62rem; background: rgba(140,204,255,0.12); }
.legend .lg.mine { color: #1a1400; background: var(--gold); }
.legend .lg.gov { color: #ffb0b0; background: rgba(255,102,102,0.22); }
.legend .lg.npc { color: var(--attack); background: rgba(255,184,77,0.16); }
.legend .lg.open { color: var(--good); background: rgba(115,230,140,0.14); }
.legend .lg.friend { color: #FF8FB8; background: rgba(255,143,184,0.22); }
.legend .lg.unk { width: 6px; height: 6px; margin: 0 9px 0 5px; background: rgba(255,255,255,0.25); }
.panel-lite { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
#gdetail .sys-row { margin: 0; }
@media (max-width: 720px) {
  .sector-body { grid-template-columns: 1fr; gap: 12px; }
  .gwrap { max-width: 340px; margin: 0 auto; }
}

/* ---------- Traits & population ---------- */
.trait { display: inline-block; font-size: 0.75rem; padding: 1px 7px; border-radius: 99px; background: rgba(140, 204, 255, 0.12); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.popbar { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; margin-top: 8px; }
.popbar .bar.thin { margin: 0; }
.popbar .bar span { background: linear-gradient(90deg, #3fb36b, #73E68C); }
.ai.spec { color: var(--gold); border-color: rgba(255, 230, 102, 0.4); }
