/* Deliberately single-theme (dark), like the original: nebula ground, cyan HUD panels. */
:root {
  color-scheme: dark;
  --bg: #071014;
  --panel: #0c1c22;
  --panel-2: #10252d;
  --ink: #e2eef0;
  --muted: #8aa6ad;
  --line: #1f3d47;
  --hud: #5fd3e6;
  --hud-rgb: 95, 211, 230; /* the accent as numbers, for see-through shades */
  --hud-soft: rgba(var(--hud-rgb), 0.12);
  --you: #86e05a;
  --me: var(--you);  /* your empire's color, set by the game */
  --p1: #f0a33a;
  --brand: var(--hud); /* the burst in the mark, and the word Spat: the HUD cyan */
  --good: #86e05a;
  --warn: #f0c04a;
  --bad: #ef6b6b;
  --f-logo: "Exo 2", "Arial Narrow", sans-serif;
  --f-display: "Saira Condensed", "Arial Narrow", Impact, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font-family: var(--f-body); font-size: 15px; line-height: 1.5;
}
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--hud); outline-offset: 2px; }
h2, h3 { font-family: var(--f-display); text-transform: uppercase; margin: 0; line-height: 1.05; }
h2 { font-size: 1.6rem; font-weight: 800; letter-spacing: 0.03em; }
h3 { font-size: 0.95rem; font-weight: 600; letter-spacing: 0.08em; color: var(--hud); }

/* ---------- top bar ---------- */
.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.logo {
  font-family: var(--f-logo); font-style: italic; font-weight: 900; font-size: 1.7rem; line-height: 0.85;
  text-transform: uppercase; display: grid; transform: skewX(-6deg);
  text-shadow: 0 0 18px rgba(var(--hud-rgb), 0.35);
}
.logo span { font-size: 0.55em; }
.logo b { font-weight: inherit; color: var(--brand); }
.stat { display: grid; gap: 1px; }
.stat .k { font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.stat b { font-family: var(--f-display); font-size: 1.35rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat small { font-size: 0.75rem; color: var(--muted); }
.stat small.warn { color: var(--warn); }
.vp-row { display: flex; align-items: center; gap: 8px; }
.vp-row b.you { color: var(--me); }
.vp-track { position: relative; width: 150px; height: 8px; background: var(--line); }
.vp-track i { position: absolute; top: 0; bottom: 0; left: 0; transition: width .4s; }
.vp-track i.you { background: var(--me); opacity: 0.85; }
.vp-track .tick { position: absolute; top: -3px; bottom: -3px; width: 3px; }
.vp-lead { font-family: var(--f-mono); font-size: 0.75rem; color: var(--muted); display: flex; gap: 7px; font-variant-numeric: tabular-nums; }
.vp-lead .me { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.bar-actions { margin-left: auto; display: flex; gap: 10px; }
.primary, .ghost {
  border: 1px solid var(--hud); padding: 8px 18px; cursor: pointer;
  font-family: var(--f-display); font-weight: 800; font-size: 1.05rem; letter-spacing: 0.05em; text-transform: uppercase;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.primary { background: var(--you); border-color: var(--you); color: #0b1a05; }
.primary:disabled { background: var(--line); border-color: var(--line); color: var(--muted); cursor: default; }
.ghost { background: transparent; color: var(--hud); }
.small { padding: 5px 12px; font-size: 0.9rem; }

/* ---------- layout ---------- */
.game { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 370px; }
.mapwrap { min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; background: #050b0e; overflow: hidden; }
.panel { border-left: 1px solid var(--line); background: var(--panel); overflow-y: auto; padding: 14px 16px 24px; display: grid; gap: 18px; align-content: start; }
@media (max-width: 900px) {
  .game { grid-template-columns: 1fr; grid-template-rows: auto auto; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  body { height: auto; min-height: 100%; }
  .bar-actions { margin-left: 0; }
}

/* ---------- panel ---------- */
.chips { display: grid; grid-template-columns: repeat(var(--fleets, 4), minmax(0, 1fr)); gap: 6px; }
.chip {
  display: grid; justify-items: center; gap: 2px; padding: 6px 4px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); text-align: center;
}
.chip svg { width: 16px; height: 20px; }
.chip span { font-size: 0.72rem; font-weight: 600; }
.chip small { font-family: var(--f-mono); font-size: 0.7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.on { border-color: var(--me); box-shadow: inset 0 0 0 1px var(--me); }
.chip.dead { opacity: 0.55; }
.chip.busy small { color: var(--me); }
.sel { display: grid; gap: 12px; }
.head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.where { font-family: var(--f-mono); font-size: 0.78rem; color: var(--muted); }
.capbar { display: grid; gap: 4px; }
.capbar .track { height: 6px; background: var(--line); }
.capbar .track i { display: block; height: 100%; background: var(--me); }
.capbar .lbl { display: flex; justify-content: space-between; font-family: var(--f-mono); font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.comp { display: grid; gap: 4px; }
.comp-row, .build-row { display: grid; grid-template-columns: 46px 1fr auto; gap: 10px; align-items: center; }
.comp-row b { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.comp-row .q, .build-row .q { color: var(--you); font-family: var(--f-mono); font-size: 0.8rem; }
.glyph { width: 46px; height: 18px; display: block; }
.status { padding: 8px 10px; background: var(--panel-2); border-left: 2px solid var(--hud); font-size: 0.9rem; }
.status.colonize { border-left-color: var(--you); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.build { display: grid; gap: 8px; padding-top: 4px; }
.build-row { grid-template-columns: 46px 1fr auto; }
.build-row .nm small { display: block; color: var(--muted); font-family: var(--f-mono); font-size: 0.7rem; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 28px; height: 28px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-family: var(--f-mono); }
.stepper button:hover { border-color: var(--hud); }
.stepper input { width: 52px; height: 28px; background: var(--bg); border: 1px solid var(--line); color: var(--ink); text-align: right; padding: 0 6px; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.hint { font-size: 0.85rem; color: var(--muted); margin: 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 0.9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.howto { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; font-size: 0.9rem; }
.howto li::marker { color: var(--hud); }
.dispatch { display: grid; gap: 8px; }
.dispatch ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-family: var(--f-mono); font-size: 0.78rem; }
.dispatch li { padding-left: 12px; position: relative; }
.dispatch li::before { content: ""; position: absolute; left: 0; top: 0.55em; width: 5px; height: 5px; background: var(--muted); }
.dispatch li.good::before { background: var(--good); }
.dispatch li.bad::before { background: var(--bad); }
.dispatch li button { all: unset; cursor: pointer; color: var(--hud); text-decoration: underline; text-underline-offset: 2px; }
.empty { color: var(--muted); font-size: 0.85rem; }

/* ---------- modal + battle screen ---------- */
.modal { position: fixed; inset: 0; z-index: 10; background: rgba(3, 8, 10, 0.78); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal-card { width: min(920px, 100%); background: var(--panel); border: 1px solid var(--hud); padding: 20px; display: grid; gap: 16px; }
.modal-card.narrow { width: min(480px, 100%); }
.eyebrow { font-family: var(--f-mono); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--hud); }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; }
.side { padding: 14px; background: var(--panel-2); border: 1px solid var(--line); display: grid; gap: 10px; align-content: start; min-width: 0; }
.side-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.side-head b { font-family: var(--f-display); font-size: 1.4rem; font-weight: 800; text-transform: uppercase; }
.val { font-family: var(--f-mono); font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.glyphs {
  min-height: 84px; padding: 8px; display: flex; flex-wrap: wrap; gap: 3px; align-content: flex-start; justify-content: flex-end;
  background: var(--bg);
  background-image: linear-gradient(rgba(var(--hud-rgb), .07) 1px, transparent 1px), linear-gradient(90deg, rgba(var(--hud-rgb), .07) 1px, transparent 1px);
  background-size: 14px 14px;
}
.glyphs svg { display: block; }
.rows { display: grid; gap: 6px; }
.rows .row { display: grid; grid-template-columns: 46px 1fr auto; gap: 10px; align-items: center; font-size: 0.9rem; }
.rows .row b { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.mid { display: grid; justify-items: center; align-content: center; gap: 14px; }
.vs-word { font-family: var(--f-display); font-weight: 800; font-size: 2.8rem; line-height: 1; }
.battle-btn {
  width: 100px; height: 100px; border-radius: 50%; border: 3px solid rgba(255,255,255,.35); cursor: pointer;
  background: radial-gradient(circle at 40% 35%, #b8f58e, var(--you) 55%, #3d8a1f); color: #0b1a05;
  font-family: var(--f-display); font-weight: 800; font-size: 1.3rem; text-transform: uppercase;
  box-shadow: 0 0 24px rgba(134, 224, 90, 0.35); transition: transform .15s;
}
.battle-btn:hover:not(:disabled) { transform: scale(1.05); }
.battle-btn:disabled { filter: grayscale(0.7); cursor: default; }
.verdict { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; }
.pct { font-family: var(--f-display); font-size: 2.2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.pill { font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; border: 1px solid currentColor; }
.note { color: var(--muted); font-size: 0.85rem; }
.oddsbar { height: 8px; background: var(--line); }
.oddsbar i { display: block; height: 100%; }
.report { font-family: var(--f-mono); font-size: 0.85rem; background: var(--bg); border: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 4px; }
.report .t { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
@media (max-width: 720px) {
  .vs { grid-template-columns: 1fr; }
  .mid { grid-auto-flow: column; justify-content: center; align-items: center; }
}

/* end of game */
.result-title { font-family: var(--f-logo); font-style: italic; font-weight: 900; font-size: clamp(2.6rem, 9vw, 4rem); text-transform: uppercase; line-height: 1; text-align: center; }
.result-title.win { color: var(--you); }
.result-title.lose { color: var(--bad); }
.result-sub { text-align: center; color: var(--muted); font-family: var(--f-display); text-transform: uppercase; letter-spacing: 0.05em; font-size: 1.1rem; margin: 0; }
.stats { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.stats th, .stats td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.stats th { font-family: var(--f-display); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.85rem; text-align: center; color: var(--muted); }
.stats td { font-family: var(--f-mono); }
.stats td:first-child { text-align: left; color: var(--you); }
.stats td:last-child { text-align: right; color: var(--p1); }
.stats tr:nth-child(even) { background: var(--hud-soft); }
.choices { display: grid; gap: 8px; }
.choice { display: grid; gap: 2px; text-align: left; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; }
.choice b { font-family: var(--f-display); text-transform: uppercase; font-size: 1.1rem; letter-spacing: 0.04em; }
.choice span { font-size: 0.85rem; color: var(--muted); }
.choice.on { border-color: var(--you); box-shadow: inset 0 0 0 1px var(--you); }
.error { color: var(--bad); font-size: 0.9rem; margin: 0; }

/* map animation */
.route-dash { stroke-dasharray: 6 6; animation: march 1.1s linear infinite; }
@keyframes march { to { stroke-dashoffset: -24; } }
.pulse { animation: pulse 2s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 0% { opacity: .9; transform: scale(.8); } 100% { opacity: 0; transform: scale(1.8); } }
.spin { animation: spin 3s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes spin { to { transform: rotate(360deg); } }
.crackle { animation: crackle 1.6s steps(4) infinite; }
@keyframes crackle { 50% { stroke-dashoffset: 7; opacity: .5; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* empires list */
.empires { display: grid; gap: 6px; }
.emp { display: grid; grid-template-columns: 10px 1fr auto auto; gap: 8px; align-items: center; font-size: 0.88rem; }
.emp .dot { width: 10px; height: 10px; border-radius: 50%; }
.emp .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emp .vpv { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.emp .st { font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); min-width: 64px; text-align: right; }
.emp .st.ready { color: var(--good); }
.emp.out .nm, .emp.out .vpv { text-decoration: line-through; color: var(--muted); }
.banner { padding: 10px 12px; border: 1px solid var(--warn); color: var(--warn); font-size: 0.9rem; background: rgba(240, 192, 74, 0.08); }

/* lobby */
.seats { display: grid; gap: 6px; }
.seat { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--line); }
.seat .dot { width: 10px; height: 10px; border-radius: 50%; }
.seat .tag { font-family: var(--f-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.seat.open { border-style: dashed; }
.invite { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.invite input { flex: 1; min-width: 0; background: var(--bg); color: var(--ink); border: 1px solid var(--line); padding: 8px 10px; font-family: var(--f-mono); font-size: 0.85rem; }
.field { display: grid; gap: 4px; }
.field label { font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.field input { background: var(--bg); color: var(--ink); border: 1px solid var(--line); padding: 8px 10px; font: inherit; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { min-width: 44px; padding: 6px 10px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; font-family: var(--f-display); font-weight: 800; font-size: 1.05rem; }
.seg button.on { border-color: var(--you); box-shadow: inset 0 0 0 1px var(--you); color: var(--you); }
.sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.center-row { display: flex; justify-content: center; }
.stats-wrap { overflow-x: auto; }
.stats.multi td, .stats.multi th { text-align: right; white-space: nowrap; }
.stats.multi td:first-child, .stats.multi th:first-child { text-align: left; color: var(--muted); }
.stats.multi tr:nth-child(even) { background: var(--hud-soft); }

/* fleet ships: one row per class */
.ships { display: grid; gap: 6px; }
.ship-head, .ship-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 40px auto; gap: 8px; align-items: center; }
.ship-head.no-build, .ship-row.no-build { grid-template-columns: 34px minmax(0, 1fr) 40px; }
.ship-head span { font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.ship-head span:nth-child(3), .ship-row .have { text-align: right; }
.ship-head span:nth-child(4) { text-align: center; }
.ship-row .glyph { width: 34px; height: 14px; }
.ship-row .nm { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ship-row .nm small { display: block; color: var(--muted); font-family: var(--f-mono); font-size: 0.7rem; }
.ship-row .have { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.ship-row .q { color: var(--you); font-size: 0.8rem; }
.ship-row .stepper { gap: 3px; }
.ship-row .stepper button { width: 26px; height: 28px; }
.ship-row .stepper input { width: 48px; }

.stepper button:disabled { opacity: 0.35; cursor: not-allowed; }
.stepper button:disabled:hover { border-color: var(--line); }
.note-line { margin: 0; font-size: 0.82rem; color: var(--muted); }
.note-line.warn { color: var(--warn); }
.stepper input.scrap { color: var(--bad); border-color: var(--bad); }
.game-id { display: flex; align-items: baseline; gap: 12px; }
.game-id .k { font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.game-id b { font-family: var(--f-mono); font-size: 1.8rem; letter-spacing: 0.18em; color: var(--you); user-select: all; }
.join-row { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
#mJoinId { text-transform: uppercase; letter-spacing: 0.12em; }

/* battle arena */
.arena { position: relative; background: #04090c; border: 1px solid var(--line); }
.arena canvas { display: block; width: min(100%, calc(52vh * 1000 / 560)); aspect-ratio: 1000 / 560; margin: 0 auto; }
.arena-go { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.arena-go:hover:not(:disabled) { transform: translate(-50%, -50%) scale(1.05); }
.arena-time { position: absolute; right: 10px; top: 8px; font-family: var(--f-mono); font-size: 0.8rem; color: var(--muted); }
.modal-card { width: min(980px, 100%); }
.rejoin { display: grid; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.rejoin input { letter-spacing: 0.1em; }
b.code { font-family: var(--f-mono); color: var(--you); letter-spacing: 0.08em; user-select: all; }

/* races and research */
.race { font-family: var(--f-mono); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 400; }
.side-head .race { margin-left: auto; margin-right: 10px; }
.races { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.race-card { display: grid; gap: 3px; align-content: start; text-align: left; padding: 10px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; }
.race-card b { font-family: var(--f-display); font-size: 1.2rem; text-transform: uppercase; letter-spacing: 0.04em; }
.race-card .style { font-size: 0.8rem; line-height: 1.3; color: var(--hud); }
.race-card span:last-child { font-size: 0.78rem; color: var(--muted); line-height: 1.4; }
.race-card.on { border-color: var(--you); box-shadow: inset 0 0 0 1px var(--you); }
.techs { display: grid; gap: 6px; }
.tech { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); }
.tech b { font-weight: 600; }
.tech p { margin: 2px 0 0; font-size: 0.85rem; color: var(--muted); }
.tech.owned { border-color: rgba(134, 224, 90, 0.5); }
.tech.queued { border-color: var(--you); box-shadow: inset 0 0 0 1px var(--you); }
.tech.locked { opacity: 0.6; }
.tech .counter { margin-left: 8px; font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--warn); }
.tech-act { text-align: right; max-width: 200px; }
.tag { font-family: var(--f-mono); font-size: 0.72rem; color: var(--muted); }
.tag.good { color: var(--good); }
.bstats { display: grid; gap: 10px; }
.bstat { background: var(--bg); border: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 6px; overflow-x: auto; }
.bstat-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.bstat-head .t { color: var(--muted); font-size: 0.82rem; }
.bstat table { width: auto; justify-self: start; border-collapse: collapse; font-family: var(--f-mono); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.bstat th, .bstat td { padding: 3px 18px 3px 0; text-align: right; white-space: nowrap; }
.bstat th:first-child, .bstat thead th { text-align: left; color: var(--muted); font-weight: 400; }
.bstat tbody th { color: var(--ink); }

/* ===================================================================== */
/* HUD theme: full-screen galaxy with floating holographic panels.       */
/* ===================================================================== */
:root {
  --glass: rgba(var(--glass-rgb), 0.74);
  --glass-strong: rgba(var(--glass-rgb), 0.9);
  --glass-rgb: 7, 20, 26;
  --edge: rgba(var(--hud-rgb), 0.38);
  --edge-strong: rgba(var(--hud-rgb), 0.75);
  --cut: 14px;
}
body {
  background: radial-gradient(ellipse 80% 60% at 70% 20%, rgba(40, 110, 130, 0.22), transparent 70%),
              radial-gradient(ellipse 60% 50% at 15% 80%, rgba(90, 60, 160, 0.16), transparent 70%), #02070a;
}
#stars { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.holo {
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  backdrop-filter: blur(12px) saturate(1.2);
  border: 1px solid var(--edge);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 10px 40px rgba(0, 0, 0, 0.45), inset 0 0 40px rgba(var(--hud-rgb), 0.05);
}

/* top HUD */
.bar {
  position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); left: 12px; right: 12px; z-index: 6;
  padding: 8px 18px; border-bottom: 1px solid var(--edge);
  background: var(--glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--edge);
  clip-path: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%, 0 var(--cut));
  box-shadow: 0 0 30px rgba(var(--hud-rgb), 0.08);
}
.bar::after { content: ""; position: absolute; left: 24px; right: 24px; bottom: -1px; height: 1px; background: linear-gradient(90deg, transparent, var(--edge-strong), transparent); }
.stat .k::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; background: var(--hud); transform: rotate(45deg); vertical-align: 1px; box-shadow: 0 0 8px var(--hud); }
.stat b { text-shadow: 0 0 14px rgba(var(--hud-rgb), 0.25); }

/* the map fills the screen; panels float over it */
.game { position: fixed; inset: 0; display: block; z-index: 1; }
.mapwrap { position: absolute; inset: 0; padding: 92px 404px 14px 14px; background: transparent; }
#map { filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.6)); }
.panel {
  position: fixed; top: 92px; right: 12px; bottom: 12px; width: 378px; z-index: 5;
  background: var(--glass); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--edge); border-left: 1px solid var(--edge);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  box-shadow: inset 0 0 50px rgba(var(--hud-rgb), 0.04);
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.panel h3 { display: flex; align-items: center; gap: 8px; }
.panel h3::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--edge), transparent); }
.chip, .status, .ship-row .stepper button, .stepper input { transition: border-color .15s, box-shadow .15s; }
.chip { background: rgba(16, 37, 45, 0.7); }
.chip:hover { border-color: var(--edge-strong); box-shadow: 0 0 14px rgba(var(--hud-rgb), 0.18); }
.status { background: rgba(16, 37, 45, 0.6); }
.trait-name { color: var(--warn); font-weight: 600; }

/* buttons glow */
.primary { box-shadow: 0 0 18px rgba(134, 224, 90, 0.25); }
.primary:hover:not(:disabled) { filter: brightness(1.1); box-shadow: 0 0 26px rgba(134, 224, 90, 0.45); }
.ghost { background: rgba(var(--hud-rgb), 0.06); }
.ghost:hover { background: rgba(var(--hud-rgb), 0.14); box-shadow: 0 0 16px rgba(var(--hud-rgb), 0.25); }

/* dialogs: holographic frame with corner brackets and faint scanlines */
.modal { background: radial-gradient(ellipse at center, rgba(2, 10, 14, 0.6), rgba(1, 4, 6, 0.88)); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; background: var(--glass-strong); border: 1px solid var(--edge);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  box-shadow: 0 0 60px rgba(var(--hud-rgb), 0.12), inset 0 0 80px rgba(var(--hud-rgb), 0.04);
  background-image: repeating-linear-gradient(0deg, rgba(var(--hud-rgb), 0.025) 0 1px, transparent 1px 3px);
  animation: holo-in .22s ease-out;
}
.modal-card::before, .modal-card::after { content: ""; position: absolute; width: 22px; height: 22px; border: 2px solid var(--hud); pointer-events: none; opacity: 0.8; }
.modal-card::before { top: 6px; left: 6px; border-right: 0; border-bottom: 0; }
.modal-card::after { bottom: 6px; right: 6px; border-left: 0; border-top: 0; }
@keyframes holo-in { from { opacity: 0; transform: scale(0.97) translateY(6px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
.arena { border-color: var(--edge); box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6); }

@media (max-width: 900px) {
  body { height: auto; min-height: 100%; }
  .bar { position: sticky; top: 0; left: 0; right: 0; margin: 0; clip-path: none; }
  .game { position: relative; inset: auto; }
  .mapwrap { position: relative; inset: auto; padding: 8px; height: 62vh; }
  #map { height: 100%; }
  .panel { position: relative; top: auto; right: auto; bottom: auto; width: auto; margin: 0 8px 12px; clip-path: none; }
}
@media (max-width: 900px) {
  .mapwrap { height: auto; padding: 4px 6px; }
  .bar { gap: 6px 16px; padding: 8px 10px; }
  .bar .logo { font-size: 1.4rem; }
  .bar-actions { width: 100%; display: grid; grid-template-columns: auto auto 1fr 1fr 1.25fr; gap: 6px; }
  .bar-actions button, .bar-actions .more summary { padding: 7px 6px; font-size: 0.85rem; white-space: nowrap; }
  .bar-actions { grid-template-columns: auto auto 1fr auto auto; }
  #creditsNote { display: none; }
  .vp-track { width: 110px; }
}

/* 3D ship preview */
.preview { margin: 0; display: grid; gap: 2px; }
.ship-preview { width: 100%; aspect-ratio: 720 / 260; display: block; background: radial-gradient(ellipse at 50% 60%, rgba(var(--hud-rgb), 0.10), transparent 70%); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.preview figcaption { font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); text-align: right; }

.ship-thumb { width: 72px; height: 29px; object-fit: contain; display: block; filter: drop-shadow(0 0 6px rgba(var(--hud-rgb), 0.25)); }
.ship-head, .ship-row { grid-template-columns: 72px minmax(0, 1fr) 40px auto; }
.ship-head.no-build, .ship-row.no-build { grid-template-columns: 72px minmax(0, 1fr) 40px; }

/* research tree */
.modal-card.wide { width: min(1180px, 100%); }
.budget { display: grid; grid-template-columns: auto minmax(120px, 1fr) auto auto; gap: 10px; align-items: center; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); }
.budget label { font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.budget input { accent-color: var(--you); width: 100%; }
.budget b { font-family: var(--f-display); font-size: 1.4rem; color: var(--you); font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }
.ttrack { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 34px; overflow-x: auto; }
.tlinks { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.tlinks path { fill: none; stroke: var(--line); stroke-width: 2; }
.tlinks path.next { stroke: var(--you); stroke-dasharray: 5 5; }
.tlinks path.done { stroke: rgba(134, 224, 90, 0.6); }
.tcol { display: grid; gap: 10px; align-content: start; position: relative; z-index: 1; min-width: 210px; }
.tier { font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--hud); }
.fork { display: grid; gap: 4px; padding: 6px; border: 1px dashed rgba(240, 192, 74, 0.45); }
.or { justify-self: center; font-family: var(--f-display); font-weight: 800; font-size: 0.9rem; color: var(--warn); letter-spacing: 0.1em; }
.tnode { display: grid; gap: 4px; padding: 10px 12px; background: rgba(16, 37, 45, 0.85); border: 1px solid var(--line); clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); }
.tnode[data-toggle] { cursor: pointer; }
.tnode[data-toggle]:hover { border-color: var(--edge-strong); box-shadow: 0 0 16px rgba(var(--hud-rgb), 0.2); }
.tnode p { margin: 0; font-size: 0.8rem; color: var(--muted); line-height: 1.4; }
.tnode-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.tnode-head b { font-weight: 600; font-size: 0.92rem; }
.tnode .cost { font-family: var(--f-mono); font-size: 0.75rem; color: var(--warn); }
.tnode .path { font-family: var(--f-mono); font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--hud); }
.tnode .path.counter { color: var(--warn); }
.tnode.owned { border-color: rgba(134, 224, 90, 0.55); background: rgba(30, 60, 30, 0.45); }
.tnode.queued { border-color: var(--you); box-shadow: inset 0 0 0 1px var(--you); }
.tnode.locked { opacity: 0.55; }
.tnode.variant { background-image: linear-gradient(135deg, rgba(240, 192, 74, 0.12), transparent 60%); }
.tnode.variant .tnode-head b::before { content: "◆ "; color: var(--warn); }
.tprog { height: 4px; background: var(--line); }
.tprog i { display: block; height: 100%; background: var(--you); }
@media (max-width: 720px) { .ttrack { grid-template-columns: repeat(3, 230px); } }
.modal-card.wide .preview { width: min(560px, 100%); justify-self: center; }

/* battle orders */
.orders { display: grid; gap: 6px; }
.seg.stance button { flex: 1; min-width: 0; font-size: 0.85rem; padding: 6px 4px; }
.retreat { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; }
.retreat label { font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.retreat select { background: var(--bg); color: var(--ink); border: 1px solid var(--line); padding: 5px 8px; font: inherit; font-size: 0.85rem; }
.retreat .note-line { grid-column: 1 / -1; }

button.link { all: unset; cursor: pointer; color: var(--hud); text-decoration: underline; text-underline-offset: 2px; margin-left: 4px; }

/* comms */
.badge { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #1a1205; font-family: var(--f-mono); font-size: 0.7rem; line-height: 18px; text-align: center; }
.chat {
  position: fixed; left: 12px; bottom: 12px; width: min(380px, calc(100vw - 24px)); height: min(440px, 55vh); z-index: 12;
  display: grid; grid-template-rows: auto 1fr auto;
  background: var(--glass-strong); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--edge); clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
  box-shadow: 0 0 40px rgba(var(--hud-rgb), 0.12); animation: holo-in .2s ease-out;
}
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chat-head b { font-family: var(--f-display); font-size: 1.1rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--hud); }
.chat-head select { flex: 1; min-width: 0; background: var(--bg); color: var(--ink); border: 1px solid var(--line); padding: 5px 6px; font: inherit; font-size: 0.85rem; }
.chat-log { overflow-y: auto; padding: 10px 12px; display: grid; gap: 8px; align-content: start; scrollbar-width: thin; }
.msg { display: grid; grid-template-columns: auto auto 1fr; gap: 2px 8px; align-items: baseline; font-size: 0.9rem; }
.msg .who { font-weight: 600; }
.msg .when { font-family: var(--f-mono); font-size: 0.66rem; color: var(--muted); }
.msg .text { grid-column: 1 / -1; overflow-wrap: anywhere; color: var(--ink); }
.msg.mine .text { color: #cfe9d2; }
.chat-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; background: var(--bg); color: var(--ink); border: 1px solid var(--line); padding: 8px 10px; font: inherit; }
@media (max-width: 900px) { .chat { left: 8px; right: 8px; width: auto; bottom: 8px; height: 60vh; } }

.research-now { display: grid; gap: 6px; }
.rn-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.rn-head span { font-family: var(--f-mono); font-size: 0.8rem; color: var(--warn); font-variant-numeric: tabular-nums; }
.research-now .tprog { height: 6px; }

/* tutorial coach */
.coach {
  position: fixed; z-index: 13; width: min(330px, calc(100vw - 24px)); padding: 14px 16px; display: grid; gap: 8px;
  background: #061218; border: 1px solid var(--you); box-shadow: 0 0 30px rgba(134, 224, 90, 0.25);
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  transition: left .25s ease, top .25s ease; animation: holo-in .2s ease-out;
}
.coach h3 { color: var(--you); font-size: 1.15rem; }
.coach p { margin: 0; font-size: 0.92rem; line-height: 1.45; }
.coach-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.coach-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.coach-ring {
  position: fixed; z-index: 13; pointer-events: none; border: 2px solid var(--you); border-radius: 6px;
  box-shadow: 0 0 0 4px rgba(134, 224, 90, 0.15), 0 0 24px rgba(134, 224, 90, 0.5);
  animation: coach-pulse 1.4s ease-in-out infinite; transition: all .2s ease;
}
@keyframes coach-pulse { 50% { box-shadow: 0 0 0 8px rgba(134, 224, 90, 0.05), 0 0 34px rgba(134, 224, 90, 0.7); } }
.tutorial-offer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid rgba(134, 224, 90, 0.5); background: rgba(30, 60, 30, 0.35); }
.tutorial-offer div { display: grid; gap: 2px; }
.tutorial-offer span { font-size: 0.85rem; color: var(--muted); }

a.ghost, a.primary { display: inline-flex; align-items: center; text-decoration: none; }

#endTurn.undo { background: transparent; color: var(--warn); border: 1px solid var(--warn); }

.note-line.good { color: var(--good); }

/* new game: fits one screen, two columns on wide screens */
.modal[data-kind="new"] .modal-card { width: min(780px, 100%); gap: 14px; }
.ng-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ng-link { font-family: var(--f-mono); font-size: 0.78rem; color: var(--hud); }
.ng-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 22px; }
.ng-col { display: grid; gap: 12px; align-content: start; min-width: 0; }
.ng-rows { gap: 9px; }
.ng-row { display: grid; grid-template-columns: 4.6rem minmax(0, 1fr); align-items: center; gap: 8px; }
.ng-row label { font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.ng-row .seg { flex-wrap: nowrap; gap: 5px; }
.ng-row .seg button { flex: 1; min-width: 0; padding: 5px 4px; font-size: 0.95rem; white-space: nowrap; }
.ng-row .seg button small { font-family: var(--f-mono); font-weight: 400; font-size: 0.7rem; opacity: 0.8; }
.ng-rows .hint { margin: 2px 0 0; font-size: 0.82rem; }
.modal[data-kind="new"] .races { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.modal[data-kind="new"] .race-card, .modal[data-kind="join"] .race-card { padding: 7px 9px; gap: 1px; }
.race-info { margin: 4px 0 0; font-size: 0.82rem; color: var(--muted); line-height: 1.4; min-height: 2.8em; }
.modal[data-kind="new"] .tutorial-offer { padding: 7px 10px; }
.modal[data-kind="new"] .tutorial-offer span { color: var(--ink); font-size: 0.88rem; }
.modal[data-kind="new"] .join-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding-top: 12px; }
.modal[data-kind="new"] .join-row .invite { flex: 1; min-width: 220px; }
.modal[data-kind="new"] .join-row .error { flex-basis: 100%; margin: 0; }
@media (max-width: 680px) {
  .ng-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .modal[data-kind="new"] .modal-card { padding: 14px; gap: 11px; }
  .modal[data-kind="new"] h2 { font-size: 1.5rem; }
  .race-info { min-height: 0; }
}

/* the research screen is long: keep Done in reach at the bottom edge */
.modal[data-kind="research"] .modal-actions { position: sticky; bottom: -20px; margin: 0 -20px -20px; padding: 12px 20px; background: linear-gradient(to top, var(--panel) 70%, transparent); z-index: 2; }

/* enemy fleets out of sight: where you last saw them */
.fleet.ghost { opacity: 0.45; }
.fleet.ghost path { stroke-dasharray: 2 2; }
.sightings { display: grid; gap: 4px; }
.emp .known { grid-column: 2 / -1; font-size: 0.78rem; color: var(--muted); line-height: 1.35; }

/* battle report: what happened, in plain words */
.bsummary { display: grid; gap: 6px; padding: 10px 12px; border-left: 3px solid var(--hud); background: rgba(88, 212, 234, 0.06); }
.bsummary ul { margin: 0; padding-left: 1.1em; display: grid; gap: 3px; font-size: 0.9rem; }
.advice { display: grid; gap: 6px; padding: 10px 12px; border-left: 3px solid var(--warn); background: rgba(242, 193, 78, 0.06); }
.advice ul { margin: 0; padding-left: 1.1em; display: grid; gap: 4px; font-size: 0.9rem; }
.advice .bar { height: 4px; background: var(--line); }
.advice .bar i { display: block; height: 100%; background: var(--warn); }
.condition { pointer-events: auto; }
.cond-name { color: var(--warn); }
.wait-dots { display: inline-flex; gap: 3px; margin-left: 7px; vertical-align: middle; }
.wait-dots i { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); }
.banner .who { font-weight: 600; }
.graphs { display: grid; gap: 8px; margin-top: 12px; }
.graphs .seg button { flex: 1; font-size: 0.8rem; padding: 6px 4px; }
.graph { width: 100%; height: auto; display: block; }
.graph .grid { stroke: var(--line); stroke-width: 1; }
.graph text { fill: var(--muted); font-family: var(--f-mono); font-size: 12px; }
.graph-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.8rem; color: var(--muted); }
.graph-legend i { display: inline-block; width: 12px; height: 3px; margin-right: 6px; vertical-align: middle; }
.update-banner { position: fixed; z-index: 60; left: 0; right: 0; bottom: 16px; margin: 0 auto; width: fit-content; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 32px); padding: 10px 14px; background: var(--panel); border: 1px solid var(--hud); color: var(--text); font-size: 0.9rem; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5); }
.update-banner a { color: var(--hud); }

/* ship file */
.sf-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sf { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; margin-top: 10px; }
.sf-view { position: sticky; top: 0; align-self: start; height: min(460px, 62vh); background: radial-gradient(ellipse at 50% 60%, rgba(79, 195, 247, 0.12), transparent 70%); border: 1px solid var(--line); }
.sf-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.sf-canvas:active { cursor: grabbing; }
.sf-hint { position: absolute; left: 10px; bottom: 8px; font-family: var(--f-mono); font-size: 0.7rem; color: var(--muted); pointer-events: none; }
.sf-side { display: grid; gap: 8px; align-content: start; }
.sf-tabs button { flex: 1; font-size: 0.85rem; padding: 6px 4px; }
.sf-name { margin: 4px 0 0; }
.sf-stats h4, .sf-ups h4 { margin: 10px 0 4px; font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.sf-stats dl { margin: 0; display: grid; gap: 2px; }
.sf-row { display: grid; grid-template-columns: 8.5em 1fr; gap: 8px; padding: 3px 6px; border-left: 2px solid transparent; }
.sf-row dt { color: var(--muted); font-size: 0.85rem; cursor: help; }
.sf-row dd { margin: 0; display: grid; gap: 1px; }
.sf-row dd b { font-family: var(--f-mono); font-weight: 500; }
.sf-row dd small { color: var(--muted); font-size: 0.75rem; line-height: 1.35; }
.sf-row.hit { border-left-color: #ffd34d; background: rgba(255, 211, 77, 0.08); }
.sf-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sf-chip { padding: 5px 9px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-size: 0.82rem; cursor: pointer; }
.sf-chip i { font-style: normal; color: #ffd34d; }
.sf-chip small { color: var(--muted); }
.sf-chip.on { border-color: #ffd34d; box-shadow: inset 0 0 0 1px #ffd34d; }
.sf-detail { margin: 6px 0 0; font-size: 0.85rem; color: var(--muted); line-height: 1.5; }
.sf-detail b { color: var(--text); }
.ship-open { padding: 0; background: none; border: 0; cursor: pointer; line-height: 0; }
.preview.opens canvas { cursor: pointer; }
@media (max-width: 720px) { .sf { grid-template-columns: 1fr; } .sf-view { position: relative; height: 260px; } }

/* the More menu in the top bar */
.more { position: relative; }
.more summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; height: 100%; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: '▾'; font-size: 0.75em; opacity: 0.8; }
.more-menu { position: fixed; z-index: 50; min-width: 170px; display: grid; padding: 6px; background: var(--panel); border: 1px solid var(--edge); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55); }
.more-menu[hidden] { display: none; }
.more-menu a, .more-menu button { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: none; border: 0; color: var(--text); font: inherit; font-size: 0.9rem; text-align: left; text-decoration: none; cursor: pointer; }
.more-menu a:hover, .more-menu button:hover, .more-menu a:focus-visible, .more-menu button:focus-visible { background: var(--panel-2); color: var(--hud); }
.badge.dot { width: 8px; height: 8px; min-width: 0; padding: 0; border-radius: 50%; }
.sf-fitting h4 { margin: 10px 0 4px; font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.sf-fit { padding: 6px 10px; background: var(--panel-2); border: 1px dashed var(--line); color: var(--text); font-size: 0.85rem; cursor: pointer; }
.sf-fit small { color: var(--muted); }
.sf-fit.on { border: 1px solid var(--you); box-shadow: inset 0 0 0 1px var(--you); }
.sf-fit:disabled { opacity: 0.45; cursor: default; }
.sf-note { margin: 6px 0 0; font-size: 0.8rem; color: var(--warn); }
.sf-scope button { flex: 1; font-size: 0.8rem; padding: 5px 4px; }
.linkish { background: none; border: 0; padding: 0; color: var(--hud); text-decoration: underline; cursor: pointer; font: inherit; }
.sf-row.changed { border-left-color: var(--you); }
.sf-was { font-size: 0.75rem; color: var(--muted); font-weight: 400; margin-left: 6px; }
.sf-caption { margin: 0 0 6px; font-size: 0.85rem; color: var(--muted); }

/* battle debrief */
.debrief { display: grid; gap: 14px; margin-top: 6px; }
.debrief section { display: grid; gap: 8px; }
.debrief h3 { margin: 0; font-family: var(--f-mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.db-row { display: grid; grid-template-columns: auto minmax(120px, 0.8fr) 1.6fr; gap: 12px; align-items: center; padding: 10px; background: rgba(6, 16, 21, 0.55); border: 1px solid var(--line); }
.db-ship { position: relative; display: grid; justify-items: center; align-content: start; gap: 2px; padding: 4px; background: radial-gradient(ellipse at 50% 60%, color-mix(in srgb, var(--c) 22%, transparent), transparent 70%); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); color: var(--text); font: inherit; }
button.db-ship { cursor: pointer; }
button.db-ship:hover { border-color: var(--c); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 40%, transparent); }
.db-ship img { display: block; }
.db-m img { width: 120px; height: 48px; object-fit: contain; }
.db-s img { width: 84px; height: 34px; object-fit: contain; }
.db-glyph { display: grid; place-items: center; width: 84px; height: 34px; color: var(--c); font-size: 1.2rem; }
.db-label { font-size: 0.72rem; color: var(--muted); max-width: 120px; text-align: center; line-height: 1.2; }
.db-count { position: absolute; top: 2px; right: 4px; font-family: var(--f-mono); font-size: 0.85rem; color: var(--text); text-shadow: 0 0 6px #000; }
.db-ship.hot { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn), 0 0 16px rgba(240, 192, 74, 0.35); }
.db-ship.hot .db-label::after { content: ' · main threat'; color: var(--warn); }
.db-mid { display: grid; gap: 4px; }
.db-line { font-size: 0.9rem; }
.db-line b { font-family: var(--f-mono); font-size: 1.1rem; }
.db-bar { height: 6px; background: var(--line); }
.db-bar i { display: block; height: 100%; opacity: 0.85; }
.db-by { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.db-killers { display: flex; flex-wrap: wrap; gap: 6px; }
.db-none { margin: 0; color: var(--muted); font-size: 0.85rem; }
.db-defs { display: grid; gap: 6px; }
.db-def { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; padding: 8px 10px; border-left: 3px solid var(--c); background: rgba(6, 16, 21, 0.45); font-size: 0.85rem; color: var(--muted); }
.db-def > b { color: var(--c); margin-right: 4px; }
.db-def span b { color: var(--text); font-family: var(--f-mono); margin: 0 3px; }
.db-def i { font-style: normal; color: var(--c); }
.db-chart { max-width: 520px; }
.db-hint { margin: 0; font-size: 0.8rem; color: var(--muted); }
.sf-overlay { position: fixed; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); width: min(980px, 100vw); z-index: 14; border: 1px solid var(--hud); overflow-y: auto; background: var(--panel); padding: 20px; display: grid; gap: 10px; align-content: start; }
.modal-card { position: relative; }
@media (max-width: 720px) {
  .db-row { grid-template-columns: auto 1fr; }
  .db-killers { grid-column: 1 / -1; }
}

/* end-of-game report */
.gamereport { display: grid; gap: 14px; margin: 8px 0 4px; }
.gamereport h3 { margin: 0 0 6px; font-family: var(--f-mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.gr-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.gr-card { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; padding: 10px; border: 1px solid color-mix(in srgb, var(--c) 45%, var(--line)); background: radial-gradient(ellipse at 15% 50%, color-mix(in srgb, var(--c) 14%, transparent), transparent 60%), rgba(6, 16, 21, 0.55); }
.gr-card h4 { margin: 0 0 4px; font-family: var(--f-display); text-transform: uppercase; letter-spacing: 0.06em; color: var(--c); }
.gr-card p { margin: 0; font-size: 0.88rem; line-height: 1.45; color: var(--muted); }
.gr-card p b { color: var(--text); font-family: var(--f-mono); }
.gr-lessons ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; font-size: 0.9rem; line-height: 1.45; }
.gr-lessons li::marker { color: var(--hud); }

/* battle log */
.bl-h { margin: 6px 0 0; font-family: var(--f-mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.bl-list { display: grid; gap: 6px; }
.bl-row { display: grid; grid-template-columns: 4.5em 1fr auto auto; gap: 12px; align-items: center; padding: 10px 12px; background: rgba(6, 16, 21, 0.55); border: 1px solid var(--line); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.bl-row:hover { border-color: var(--hud); }
.bl-turn { font-family: var(--f-mono); font-size: 0.8rem; color: var(--muted); }
.bl-where small { display: block; color: var(--muted); font-size: 0.8rem; }
.bl-res { font-family: var(--f-display); text-transform: uppercase; letter-spacing: 0.06em; }
.bl-res.good { color: var(--good); } .bl-res.bad { color: var(--bad); } .bl-res.warn { color: var(--warn); }
.bl-trade { font-family: var(--f-mono); font-size: 0.85rem; white-space: nowrap; }
.bl-trade small { font-family: var(--f-body, inherit); color: var(--muted); font-size: 0.72rem; margin: 0 2px 0 8px; }
@media (max-width: 720px) { .bl-row { grid-template-columns: 4em 1fr auto; } .bl-trade { grid-column: 2 / -1; } }
.gamereport .graph { max-width: 560px; }

/* motion: panels, chips, the ready End Turn, button presses, the battle title card */
.sel.enter { animation: sel-in 0.28s ease-out; }
@keyframes sel-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.chips.fresh .chip { animation: chip-in 0.35s ease-out both; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes chip-in { from { opacity: 0; transform: translateY(8px) scale(0.96); } to { opacity: 1; transform: none; } }
#endTurn.ready { animation: ready-pulse 1.8s ease-in-out infinite; }
@keyframes ready-pulse { 0%, 100% { box-shadow: 0 0 18px rgba(134, 224, 90, 0.25); } 50% { box-shadow: 0 0 34px rgba(134, 224, 90, 0.75), 0 0 0 2px rgba(134, 224, 90, 0.35); } }
.primary:active:not(:disabled), .ghost:active:not(:disabled), .chip:active, .sf-fit:active:not(:disabled) { transform: scale(0.97); }
.arena-title { position: absolute; inset: 0 0 auto; padding-top: 7%; display: grid; place-content: start center; justify-items: center; gap: 6px; pointer-events: none; text-align: center; background: radial-gradient(ellipse at 50% 50%, rgba(4, 9, 12, 0.55), transparent 70%); animation: title-in 0.7s ease-out both; transition: opacity 0.5s, transform 0.5s; }
.arena-title.gone { opacity: 0; transform: scale(1.08); }
.arena-title small { font-family: var(--f-mono); font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.arena-title b { font-family: var(--f-logo, var(--f-display)); font-style: italic; font-size: clamp(1.6rem, 5vw, 2.8rem); text-transform: uppercase; letter-spacing: 0.02em; text-shadow: 0 0 24px rgba(var(--hud-rgb), 0.45); }
.arena-title span { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; align-items: baseline; font-size: 0.95rem; }
.arena-title i { font-style: normal; font-weight: 600; }
.arena-title em { font-style: normal; font-family: var(--f-mono); color: var(--text); margin-left: 4px; }
.arena-title u { text-decoration: none; color: var(--muted); font-family: var(--f-mono); font-size: 0.75rem; }
@keyframes title-in { from { opacity: 0; transform: scale(0.9); letter-spacing: 0.2em; } to { opacity: 1; transform: none; } }

/* ship file: hologram scan on open, and stats that change flash */
.sf-view.scan::after { content: ''; position: absolute; left: 0; right: 0; height: 30%; top: -30%; pointer-events: none; background: linear-gradient(to bottom, transparent, rgba(var(--hud-rgb), 0.10) 70%, rgba(160, 240, 255, 0.55) 98%, transparent); animation: sf-scan 1.1s ease-in-out 1; }
@keyframes sf-scan { from { top: -30%; } to { top: 100%; } }
.sf-view.scan .sf-canvas { animation: sf-materialize 1.1s ease-out 1; }
@keyframes sf-materialize { 0% { opacity: 0; filter: brightness(2) saturate(0.2) hue-rotate(160deg); } 60% { opacity: 1; } 100% { filter: none; } }
.sf-row.bump { animation: sf-bump 1.2s ease-out 1; }
@keyframes sf-bump { 0% { background: rgba(134, 224, 90, 0.35); } 100% { background: transparent; } }
.sf-row.bump dd b { animation: sf-bump-text 0.6s ease-out 1; display: inline-block; }
@keyframes sf-bump-text { 0% { transform: scale(1.25); color: var(--you); } 100% { transform: none; } }

/* the speaker in the top bar, and its sound and music switches */
.icon-btn { display: inline-grid; place-items: center; padding: 6px 9px; }
.icon-btn.muted { opacity: 0.55; }
.icon-btn.muted svg path:last-child { display: none; }
.audio-pop { position: fixed; z-index: 50; width: 200px; display: grid; gap: 2px; padding: 6px; background: var(--panel); border: 1px solid var(--edge); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55); }
.audio-pop[hidden] { display: none; }
.audio-pop button { display: flex; justify-content: space-between; align-items: center; padding: 9px 10px; background: none; border: 0; color: var(--text); font: inherit; font-size: 0.9rem; cursor: pointer; }
.audio-pop button:hover { background: var(--panel-2); }
.audio-pop i, .more-menu .sw i { width: 34px; height: 18px; border-radius: 9px; background: var(--line); position: relative; transition: background 0.2s; }
.audio-pop i::after, .more-menu .sw i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform 0.2s, background 0.2s; }
.audio-pop [aria-checked="true"] i, .more-menu .sw[aria-checked="true"] i { background: color-mix(in srgb, var(--you) 45%, transparent); }
.audio-pop [aria-checked="true"] i::after, .more-menu .sw[aria-checked="true"] i::after { transform: translateX(16px); background: var(--you); }
.turn-clock { display: block; font-family: var(--f-mono); font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.turn-clock.late { color: var(--warn); animation: ready-pulse 1.6s ease-in-out infinite; }

/* Send feedback */
.fb { display: grid; gap: 10px; }
.fb textarea, .fb input { width: 100%; box-sizing: border-box; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--edge); color: var(--text); font: inherit; resize: vertical; }
.fb textarea:focus, .fb input:focus { outline: 2px solid var(--hud); outline-offset: 1px; }
.fb .small { font-size: 0.8rem; margin: 0; }
.fb-msg { margin: 0; min-height: 1.2em; color: var(--warn); font-size: 0.85rem; }

/* turns left on the current research, beside the button's label */
#research { white-space: nowrap; }
#research .rt { margin-left: 6px; padding: 1px 5px; border: 1px solid currentColor; border-radius: 8px; font-family: var(--f-mono); font-size: 0.7em; opacity: 0.85; vertical-align: 1px; }
/* the first-visit pitch in the New game dialog */
.pitch { margin: -4px 0 12px; color: var(--text); font-size: 0.98rem; line-height: 1.45; }

/* narrow phones: the speaker leaves the top bar (Sound and Music stay in More), so the buttons fit
   on one line; the narrowest also drop research's turn count */
@media (max-width: 380px) {
  #audioBtn { display: none; }
  .bar-actions { grid-template-columns: auto 1fr auto auto; gap: 5px; }
}
@media (max-width: 340px) { #research .rt { display: none; } }

/* a battle condition, explained */
.condition { cursor: pointer; }
.cond-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.cond-head h2 { margin: 2px 0 0; }
.cond-icon { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 50%; background: #2a1a05; border: 1.5px solid #f2c14e; color: #f2c14e; font-size: 1.5rem; }

/* game over: result, standings, the learning report, the graph; numbers folded away */
.modal-card:has(.go-hero) { width: min(760px, 100%); }
.go-hero { display: grid; gap: 8px; padding: 6px 0 4px; }
.go-hero .result-sub { text-transform: none; letter-spacing: 0.02em; }
.go-h { font-family: var(--f-display); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.95rem; color: var(--hud); margin: 0 0 10px; }
.go-standings { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.go-standings li { display: grid; grid-template-columns: 44px minmax(0, 1.1fr) minmax(0, 1fr) 54px; align-items: center; gap: 12px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--c); }
.go-standings li.you { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 45%, transparent); }
.go-standings li.out { opacity: 0.6; }
.go-place { font-family: var(--f-display); font-weight: 800; font-size: 1.15rem; color: var(--muted); text-align: center; }
.go-crown { color: #f2c14e; font-size: 1.6rem; line-height: 1; text-shadow: 0 0 14px rgba(242, 193, 78, 0.6); }
.go-who { display: grid; min-width: 0; }
.go-who b { color: var(--c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.go-who small { color: var(--muted); font-size: 0.78rem; }
.go-bar { position: relative; height: 10px; background: color-mix(in srgb, var(--line) 70%, transparent); border-radius: 5px; }
.go-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 5px; background: var(--c); box-shadow: 0 0 10px color-mix(in srgb, var(--c) 50%, transparent); animation: go-grow 0.9s cubic-bezier(.2, .8, .2, 1) both; }
.go-bar em { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); opacity: 0.55; }
@keyframes go-grow { from { width: 0; } }
.go-vp { display: grid; justify-items: end; line-height: 1; }
.go-vp b { font-family: var(--f-display); font-size: 1.5rem; }
.go-vp small { font-family: var(--f-mono); font-size: 0.65rem; color: var(--muted); letter-spacing: 0.1em; }
.go-none { margin: 0; }
.go-numbers summary { cursor: pointer; font-family: var(--f-display); text-transform: uppercase; letter-spacing: 0.08em; color: var(--hud); padding: 6px 0; }
.go-numbers .stats-wrap { overflow-x: auto; margin-top: 8px; }
.go-table td:first-child { color: var(--muted); font-family: inherit; white-space: nowrap; position: sticky; left: 0; background: var(--panel); }
.go-table td, .go-table td:last-child { color: var(--text); text-align: right; }
.go-table th { white-space: nowrap; text-align: right; }
.go-actions { position: sticky; bottom: -20px; margin: 0 -20px -20px; padding: 14px 20px; background: linear-gradient(transparent, var(--panel) 30%); z-index: 2; }
@media (max-width: 560px) {
  .go-standings li { grid-template-columns: 34px minmax(0, 1fr) 48px; row-gap: 8px; }
  .go-bar { grid-column: 2 / 4; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) { .go-bar i { animation: none; } }
.modal-card:has(.go-hero) #mGraph svg { max-height: 280px; width: 100%; }
/* scrolling to something (or tabbing to it) keeps it clear of the pinned buttons */
.modal[data-kind="gameover"] { scroll-padding-bottom: 96px; }
/* the dialog's sections may shrink below their content: a wide table scrolls in its box instead
   of widening the dialog */
.modal-card:has(.go-hero) > *, .go-numbers, .go-numbers .stats-wrap { min-width: 0; max-width: 100%; }
/* the end-turn button's longer labels (Reopen turn, Waiting for 2, Game over) may take two lines
   on phones rather than push the page wider */
@media (max-width: 900px) { #endTurn { white-space: normal; line-height: 1.05; min-width: 0; } }
/* an offer waiting for you (a friend's rematch): a glow, not movement */
.offer { animation: ready-pulse 1.6s ease-in-out infinite; }

/* map zoom: buttons in the map's corner (left of the side panel on wide screens); a zoomed map
   shows a hand */
.map-zoom { position: absolute; right: 418px; bottom: 22px; display: flex; gap: 6px; z-index: 2; }
.map-zoom { gap: 4px; }
.map-zoom button { min-width: 34px; min-height: 32px; padding: 2px 8px; font-size: 1rem; background: #071419; }
.map-zoom button:disabled { opacity: 0.35; }
#map { touch-action: pan-y; }
#map.zoomed { cursor: grab; }
#map.zoomed:active { cursor: grabbing; }
@media (max-width: 900px) { .map-zoom { right: 12px; bottom: 12px; } }

/* drawn icons sit on the text's baseline */
.icon { display: inline-block; vertical-align: -0.15em; flex: none; }
.db-def i { display: inline-flex; align-items: center; font-style: normal; }
.go-crown { display: inline-flex; filter: drop-shadow(0 0 8px rgba(242, 193, 78, 0.6)); }

/* the end of a game: a moment before the results (client/finale.js) */
.finale { position: fixed; inset: 0; z-index: 60; overflow: hidden; cursor: pointer; display: grid; place-items: center; animation: finale-in 0.4s ease-out both; }
.finale.out { animation: finale-out 0.45s ease-in both; }
.finale-sky { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 50%, color-mix(in srgb, var(--c) 22%, rgba(3, 7, 10, 0.92)), rgba(3, 7, 10, 0.97) 65%); }
.finale.win .finale-sky::after { content: ''; position: absolute; inset: -20%; background: repeating-linear-gradient(100deg, transparent 0 46px, rgba(255, 255, 255, 0.05) 47px, transparent 49px); animation: finale-streak 1.4s linear infinite; }
.finale-center { position: relative; text-align: center; display: grid; justify-items: center; gap: 10px; padding: 0 16px; }
.finale-title { margin: 0; font-family: var(--f-logo); font-style: italic; font-weight: 900; text-transform: uppercase; line-height: 0.9; font-size: clamp(3.4rem, 16vw, 9rem); color: var(--c); text-shadow: 0 0 40px color-mix(in srgb, var(--c) 70%, transparent), 0 0 120px color-mix(in srgb, var(--c) 40%, transparent); animation: finale-title 0.9s cubic-bezier(.15, .9, .25, 1) both 0.15s; }
.finale.lose .finale-title { animation-name: finale-title-lose; animation-duration: 1.4s; }
.finale-sub { margin: 0; font-family: var(--f-display); text-transform: uppercase; letter-spacing: 0.08em; font-size: clamp(1rem, 4vw, 1.5rem); color: var(--text); opacity: 0; animation: finale-fade 0.6s ease-out both 0.9s; }
.finale-skip { position: absolute; bottom: 7%; left: 0; right: 0; text-align: center; margin: 0; font-family: var(--f-mono); font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); opacity: 0; animation: finale-fade 0.6s ease-out both 1.8s; }
.finale-ship { position: absolute; left: -30%; height: auto; filter: drop-shadow(0 0 14px color-mix(in srgb, var(--c) 60%, transparent)); animation: finale-fly linear both; }
.finale.lose .finale-ship { animation-name: finale-drift; filter: grayscale(0.6) brightness(0.6); }
.finale-spark { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 1px; background: var(--c); box-shadow: 0 0 10px var(--c); opacity: 0; animation: finale-spark 1.3s cubic-bezier(.1, .8, .3, 1) both; }
.finale-spark:nth-child(3n) { background: #fff; }
.finale-spark:nth-child(3n + 1) { background: #86e05a; }
@keyframes finale-in { from { opacity: 0; } }
@keyframes finale-out { to { opacity: 0; transform: scale(1.04); } }
@keyframes finale-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes finale-title { 0% { opacity: 0; transform: scale(1.6); letter-spacing: 0.4em; filter: blur(12px); } 60% { opacity: 1; filter: blur(0); } 100% { transform: scale(1); letter-spacing: 0.02em; } }
@keyframes finale-title-lose { 0% { opacity: 0; transform: translateY(-30px); filter: blur(8px); } 100% { opacity: 1; transform: none; filter: blur(0); } }
@keyframes finale-fly { from { transform: translateX(0) scale(0.8); } to { transform: translateX(170vw) scale(1.15); } }
@keyframes finale-drift { from { transform: translateX(40vw) rotate(0deg); opacity: 0.8; } to { transform: translateX(70vw) translateY(30vh) rotate(25deg); opacity: 0; } }
@keyframes finale-streak { to { transform: translateX(94px); } }
@keyframes finale-spark { 0% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(var(--x), var(--y)) scale(0.4) rotate(200deg); } }

/* a new turn: a band sweeping across the map (pointer-events: none, so the map stays usable) */
.turn-banner { position: absolute; inset: 0; z-index: 3; display: grid; place-items: start center; padding-top: 14px; pointer-events: none; overflow: hidden; } /* at the top: the turn replay plays below */
.tb-band { display: flex; align-items: baseline; gap: 14px; padding: 12px 40px; background: linear-gradient(90deg, transparent, rgba(4, 12, 16, 0.88) 18%, rgba(4, 12, 16, 0.88) 82%, transparent); border-top: 1px solid color-mix(in srgb, var(--hud) 50%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--hud) 50%, transparent); animation: tb-sweep 2.2s cubic-bezier(.2, .8, .2, 1) both; white-space: nowrap; }
.tb-band small { font-family: var(--f-mono); font-size: 0.8rem; letter-spacing: 0.24em; text-transform: uppercase; color: var(--hud); }
.tb-band b { font-family: var(--f-logo); font-style: italic; font-weight: 900; font-size: clamp(2.2rem, 7vw, 3.6rem); line-height: 1; color: var(--text); text-shadow: 0 0 24px rgba(var(--hud-rgb), 0.5); }
.tb-band span { font-family: var(--f-display); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-size: 1rem; }
@keyframes tb-sweep { 0% { opacity: 0; transform: translateX(-40%) skewX(-12deg); } 18% { opacity: 1; transform: none; } 78% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateX(30%) skewX(-12deg); } }

/* the More menu, in groups: this game, sound, about the game; feedback at the foot */
.more-menu { min-width: 220px; gap: 2px; }
.mm-group { display: grid; padding: 4px 0; }
.mm-group + .mm-group { border-top: 1px solid var(--line); }
.mm-head { padding: 6px 12px 2px; font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.more-menu .sw { justify-content: space-between; }
.mm-foot button { color: var(--muted); }

/* the how-to, folded on phones for players who've played */
.howto-fold summary { cursor: pointer; font-family: var(--f-display); text-transform: uppercase; letter-spacing: 0.08em; color: var(--hud); padding: 4px 0; }
.howto-fold[open] summary { margin-bottom: 6px; }

/* who has ended their turn (games with friends) */
.roster { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 8px 2px 10px; }
.pb { display: grid; justify-items: center; gap: 3px; min-width: 44px; }
.pb i { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-style: normal; font-family: var(--f-display); font-weight: 800; font-size: 1.05rem; color: var(--c); border: 2px solid color-mix(in srgb, var(--c) 45%, transparent); background: color-mix(in srgb, var(--c) 8%, transparent); transition: background 0.3s, box-shadow 0.3s; }
.pb small { font-size: 0.72rem; color: var(--muted); max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb em { position: absolute; right: -5px; bottom: -4px; display: grid; place-items: center; min-width: 16px; height: 16px; padding: 0 2px; border-radius: 8px; font-style: normal; font-size: 0.65rem; background: var(--panel); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); color: var(--muted); gap: 1px; grid-auto-flow: column; }
.pb em u { width: 3px; height: 3px; border-radius: 50%; background: currentColor; animation: pb-think 1.2s ease-in-out infinite; }
.pb em u:nth-child(2) { animation-delay: 0.2s; }
.pb em u:nth-child(3) { animation-delay: 0.4s; }
.pb.ready i { color: #04090c; background: var(--c); border-color: var(--c); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 55%, transparent); }
.pb.ready em { background: var(--c); border-color: var(--panel); color: #04090c; font-weight: 700; }
.pb.ready small { color: var(--text); }
.pb.pop i { animation: pb-pop 0.5s cubic-bezier(.3, 1.6, .5, 1); }
.roster-note { font-size: 0.82rem; color: var(--you); }
@keyframes pb-think { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
@keyframes pb-pop { 0% { transform: scale(0.7); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .pb em u, .pb.pop i { animation: none; } }
/* wide screens: the map fills the window behind the top bar and side panel; center on what shows */
@media (min-width: 901px) { .turn-banner { inset: 92px 404px 14px 14px; } }

/* an invite: who's in, the open seats, the settings */
.invite-seats { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.invite-seats li { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 8px 12px; background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--c); }
.invite-seats li b { color: var(--text); }
.invite-seats li.human b { color: var(--c); }
.invite-seats li.open b, .invite-seats li.ai b { color: var(--muted); font-weight: 500; }
.invite-seats li.mine { border-color: var(--you); background: color-mix(in srgb, var(--you) 10%, var(--panel-2)); }
.invite-seats li.mine b { color: var(--you); font-weight: 700; }
.invite-seats small { font-family: var(--f-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.invite-facts { margin: 0; font-size: 0.85rem; color: var(--muted); }

/* the points race: someone holds the target */
.banner.race { border-color: var(--bad); color: #ffb3b3; background: rgba(239, 107, 107, 0.1); margin-bottom: 8px; }
.banner.race.good { border-color: var(--you); color: var(--you); background: color-mix(in srgb, var(--you) 10%, transparent); }

/* keyboard shortcuts (shown on devices with a mouse) */
@media (hover: none), (pointer: coarse) { .desktop-only { display: none !important; } }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; align-items: center; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--muted); }
kbd { display: inline-block; min-width: 1.6em; padding: 2px 6px; border: 1px solid var(--edge); border-bottom-width: 2px; border-radius: 4px; background: var(--panel-2); font-family: var(--f-mono); font-size: 0.85rem; text-align: center; color: var(--text); }

/* friends: Play again with, invitations, and the waiting room's Invite friends */
.invitation { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--you); background: color-mix(in srgb, var(--you) 10%, transparent); margin-bottom: 8px; }
.playwith, .lobby-friends { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.playwith .k, .lobby-friends .k { font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.lobby-friends .done { opacity: 0.7; border-color: var(--you); color: var(--you); }

#lJoinForm[hidden] { display: none; }

/* race emblems sit on the text's line */
.emblem { display: inline-block; vertical-align: -0.16em; flex: none; }
.pb .pb-race { position: absolute; left: -6px; top: -5px; display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--panel); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); color: var(--c); }
.pb.ready .pb-race { color: var(--c); }

/* a battle worth sharing (an upset or a rout) */
.share-nudge { padding: 10px 14px; border: 1px solid #f2c14e; background: rgba(242, 193, 78, 0.1); color: var(--text); animation: finale-fade 0.5s ease-out both; }
.share-nudge b { color: #f2c14e; }

/* race cards: the emblem on its own line above the name, so every card lines up */
.race-card .race-emblem { display: block; line-height: 0; color: var(--muted); margin-bottom: 2px; }
.race-card.on .race-emblem { color: var(--you); }
.race-card:hover .race-emblem { color: var(--text); }

/* the 3D map (beta, client/map3d.js) */
#map3d { position: relative; width: 100%; height: 100%; flex: 1; align-self: stretch; touch-action: none; min-height: 300px; }
@media (max-width: 900px) { #map3d { height: 62vh; } }
.map3d canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.m3-overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.m3-overlay > * { position: absolute; left: 0; top: 0; pointer-events: auto; }
.m3-planet { background: none; border: 0; padding: 0; border-radius: 50%; cursor: pointer; }
.m3-planet:focus-visible, .m3-fleet:focus-visible { outline: 2px solid var(--hud); }
.m3-name { position: absolute; left: 50%; top: calc(50% + var(--label-y, 20px)); transform: translateX(-50%); white-space: nowrap; font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.08em; color: #a9c0c6; text-shadow: 0 0 4px #000, 0 0 8px #000; pointer-events: none; transition: opacity 0.2s; }
.m3-name b { color: #f2c14e; }
.m3-planet.dim .m3-name { color: #5b7077; }
.m3-planet.on .m3-name { color: #fff; }
.m3-planet.tiny .m3-name { opacity: 0; }
.m3-fleet { display: inline-flex; align-items: center; gap: 3px; min-width: 36px; min-height: 32px; padding: 2px 4px; background: none; border: 1px solid transparent; border-radius: 6px; font-family: var(--f-mono); font-size: 0.66rem; text-shadow: 0 0 4px #000, 0 0 8px #000; cursor: pointer; }
.m3-fleet span { color: #e2eef0; }
.m3-fleet.on { border-color: #fff; background: rgba(255, 255, 255, 0.08); }
.m3-fleet.ghost { opacity: 0.5; cursor: default; }
.m3-battle { width: 32px; height: 32px; border-radius: 50%; border: 2px solid #9fe8f5; background: rgba(11, 42, 51, 0.82); z-index: 1; cursor: pointer; display: grid; place-items: center; }
.m3-battle { position: relative; color: #fff4d6; border-color: #ffb35c; background: rgba(60, 22, 8, 0.85); box-shadow: 0 0 14px rgba(255, 150, 70, 0.55); }
.m3-battle i { position: absolute; inset: -6px; border-radius: 50%; border: 2px dashed #ffcf8a; animation: spin 3s linear infinite; }
.m3-battle svg { display: block; }
.m3-battle.seen { box-shadow: none; }
.m3-battle.seen { opacity: 0.85; }
.m3-battle.seen i { animation: none; }
.m3-cond { width: 22px; height: 22px; border-radius: 50%; border: 1.2px solid #f2c14e; background: #2a1a05; color: #f2c14e; display: grid; place-items: center; padding: 0; line-height: 0; font-size: 0; cursor: pointer; }
.m3-cond svg { display: block; vertical-align: 0; }

/* a colony being founded: a ring pulsing outward in your colour */
/* (the element is positioned by a transform; the pulse is on an inner layer so scaling it doesn't
   scale the position too) */
.m3-claim { pointer-events: none !important; }
.m3-claim::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid currentColor; box-sizing: border-box; animation: m3-claim 1.6s ease-out infinite; }
@keyframes m3-claim { 0% { opacity: 0.95; transform: scale(0.9); } 100% { opacity: 0; transform: scale(1.35); } }
@media (prefers-reduced-motion: reduce) { .m3-claim::before { animation: none; opacity: 0.8; } }
.m3-points { font-family: var(--f-display); font-weight: 800; font-size: 1.15rem; text-shadow: 0 0 4px #000, 0 0 10px #000; pointer-events: none !important; }

/* the points race: an empire holding the target; its planets pulse, faster than a colony ring */
.m3-race::before { border-width: 2px; animation-duration: 1.1s; }
.m3-race:not(.mine)::before { box-shadow: 0 0 14px currentColor; }

/* the dive into a battle: a wash to black with a flash at the centre, then the battle out of it */
.dive-veil { position: fixed; inset: 0; z-index: 9; pointer-events: none; background: radial-gradient(circle at 50% 50%, rgba(255, 228, 180, 0.0), rgba(2, 5, 7, 0.0) 40%); animation: dive-in 0.52s ease-in forwards; }
.dive-veil.out { animation: dive-out 0.6s ease-out forwards; }
@keyframes dive-in { 0% { background: radial-gradient(circle at 50% 50%, rgba(255,228,180,0) 0%, rgba(2,5,7,0) 60%); } 60% { background: radial-gradient(circle at 50% 50%, rgba(255,228,180,0.55) 0%, rgba(2,5,7,0.7) 45%); } 100% { background: radial-gradient(circle at 50% 50%, rgba(255,240,215,0.9) 0%, #020507 35%); } }
@keyframes dive-out { from { opacity: 1; background: #020507; } to { opacity: 0; } }
body.dived .modal[data-kind="battle"] .arena { animation: arena-in 0.6s ease-out both; }
@keyframes arena-in { from { filter: brightness(2.2) blur(6px); transform: scale(1.06); } to { filter: none; transform: none; } }

/* fleets on the 3D map: a fleet with orders on its lane, its arrow pointing the way */
.m3-moving { border-color: color-mix(in srgb, currentColor 45%, transparent); background: rgba(4, 12, 16, 0.6); }
.m3-moving .m3-heading { transform: rotate(var(--heading, 0rad)); transition: transform 0.15s; }

/* strength as size: fleet badges scale with their value (--s, set by map3d.js) */
.m3-fleet { font-size: calc(0.66rem * var(--s, 1)); }
.m3-fleet svg { width: calc(10px * var(--s, 1)); height: calc(14px * var(--s, 1)); }

.m3-fleet .m3-emblem { width: calc(13px * var(--s, 1)); height: calc(13px * var(--s, 1)); filter: drop-shadow(0 0 2px #000); }
.vp-emblem { display: inline-flex; color: var(--me); margin-right: 2px; filter: drop-shadow(0 0 3px color-mix(in srgb, var(--me) 50%, transparent)); }
.vp-emblem:empty { display: none; }

/* phones with a notch or home indicator (and the app): dialogs keep clear of them */
.modal { padding-top: max(16px, env(safe-area-inset-top, 0px)); padding-bottom: max(16px, env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* ---------- phones and tablets (found by e2e/mobile.e2e.mjs) ---------- */
/* a dialog or the chat never grows wider than the screen to fit something inside: the inside wraps */
.modal-card, .chat { grid-template-columns: minmax(0, 1fr); }
/* research budget on a phone: label, slider and number on one line, the note below */
@media (max-width: 560px) {
  .budget { grid-template-columns: auto minmax(0, 1fr) auto; }
  .budget > :nth-child(n + 4) { grid-column: 1 / -1; }
}
.budget input[type="range"] { height: 32px; }
.tnode .path { font-size: 0.68rem; }
/* fingers: controls at least 36px (Apple asks 44; 36 keeps these rows compact) */
@media (pointer: coarse) {
  .stepper button, .ship-row .stepper button { width: 36px; height: 36px; }
  .stepper input { height: 36px; }
  .ship-open { min-height: 36px; }
  button.link { min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
}
/* a phone on its side: the desktop arrangement, compact: one row of top bar (no logo), the map full
   screen and the panel floating at the right, no page scroll */
@media (orientation: landscape) and (max-height: 520px) {
  body { height: 100%; min-height: 0; }
  .bar { position: fixed; top: 0; left: 0; right: 0; flex-wrap: nowrap; gap: 12px; padding: 4px max(10px, env(safe-area-inset-right, 0px)) 4px max(10px, env(safe-area-inset-left, 0px)); }
  .bar .logo { display: none; }
  .bar .stat .k { font-size: 0.68rem; }
  .bar .stat b { font-size: 1.15rem; }
  .bar-actions { width: auto; margin-left: auto; display: flex; gap: 6px; }
  .bar-actions button, .bar-actions .more summary { padding: 6px 10px; }
  .vp-track { width: 80px; }
  .game { position: fixed; inset: 0; }
  .mapwrap { position: absolute; inset: 0; height: auto; padding: 56px calc(min(300px, 40vw) + 16px) 6px max(6px, env(safe-area-inset-left, 0px)); }
  .panel { position: fixed; top: 56px; right: max(8px, env(safe-area-inset-right, 0px)); bottom: 8px; width: min(300px, 40vw); margin: 0; overflow-y: auto; clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut)); }
}
/* short phones (iPhone SE): no logo and tighter numbers, so turn, victory and production share a row */
@media (orientation: portrait) and (max-width: 440px) and (max-height: 760px) {
  .bar .logo { display: none; }
  .bar { gap: 4px 12px; padding-top: 6px; padding-bottom: 6px; }
  .bar .stat b { font-size: 1.25rem; }
  .vp-track { width: 64px; }
}

/* Your race themes the frame (the top bar, panels, borders and highlights), never the map.
   Veyari keep the cool crystal cyan above; Korrath forge copper; Skarn hive violet. */
:root[data-race="korrath"] {
  --hud: #e8925e; --hud-rgb: 232, 146, 94;
  --bg: #120c09; --panel: #1c1410; --panel-2: #251a14; --line: #4a3324; --muted: #b09c8e;
  --glass-rgb: 22, 14, 10;
}
:root[data-race="skarn"] {
  --hud: #c98cf2; --hud-rgb: 201, 140, 242;
  --bg: #0e0a13; --panel: #18111f; --panel-2: #21172a; --line: #3f2c4c; --muted: #a896b2;
  --glass-rgb: 16, 10, 22;
}

/* The notch and the home indicator (a phone, or the app, draws the page under both: viewport-fit=cover).
   The phone layouts above set the top bar's padding, which dropped the notch's: put it back. */
@media (max-width: 900px) {
  .bar { padding-top: calc(8px + env(safe-area-inset-top, 0px)); padding-left: max(10px, env(safe-area-inset-left, 0px)); padding-right: max(10px, env(safe-area-inset-right, 0px)); }
  body { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .chat { top: auto; bottom: max(8px, env(safe-area-inset-bottom, 0px)); }
  .map-zoom { right: max(12px, env(safe-area-inset-right, 0px)); }
}
@media (orientation: portrait) and (max-width: 440px) and (max-height: 760px) {
  .bar { padding-top: calc(6px + env(safe-area-inset-top, 0px)); }
}
@media (orientation: landscape) and (max-height: 520px) {
  .bar { padding-top: calc(4px + env(safe-area-inset-top, 0px)); }
  body { padding-bottom: 0; }
  .panel { bottom: max(8px, env(safe-area-inset-bottom, 0px)); }
}
.sf-overlay { padding-top: max(20px, env(safe-area-inset-top, 0px)); padding-bottom: max(20px, env(safe-area-inset-bottom, 0px)); }
.update-banner { bottom: max(16px, env(safe-area-inset-bottom, 0px)); }

/* ---------- a phone held upright: the panel is a bottom sheet over a full-screen map (client/sheet.js) ---------- */
.sheet-grip { display: none; }
@media (max-width: 900px) and (orientation: portrait) {
  body { height: 100%; min-height: 0; overflow: hidden; padding-bottom: 0; }
  .bar { position: fixed; top: 0; left: 0; right: 0; z-index: 6; }
  .game { position: fixed; inset: 0; }
  /* the map ends where the sheet begins (under its rounded top), so it fits what you can see */
  .mapwrap { position: absolute; inset: 0 0 auto 0; height: auto; bottom: calc(var(--sheet-h, 150px) - 16px); padding: calc(var(--bar-h, 120px) + 4px) 0 0; transition: bottom 0.25s ease; }
  #map3d { height: 100%; min-height: 0; }
  /* bottom left: your home is always at the bottom right */
  .map-zoom { bottom: 26px; right: auto; left: max(12px, env(safe-area-inset-left, 0px)); }
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; margin: 0; z-index: 5;
    height: var(--sheet-h, 150px); overflow-y: auto; overscroll-behavior: contain;
    padding: 32px max(14px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
    background: var(--glass-strong); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border: 1px solid var(--edge); border-bottom: 0; border-radius: 16px 16px 0 0; clip-path: none;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
    transition: height 0.25s ease;
  }
  body.sheet-drag .panel, body.sheet-drag .mapwrap, body.sheet-drag .sheet-grip { transition: none; }
  body[data-sheet="peek"] .panel { overflow: hidden; }
  .sheet-grip {
    display: block; position: fixed; left: 50%; transform: translateX(-50%); z-index: 6;
    bottom: calc(var(--sheet-h, 150px) - 36px); width: 120px; height: 40px; padding: 0;
    background: none; border: 0; cursor: grab; touch-action: none;
  }
  .sheet-grip i { display: block; width: 40px; height: 5px; margin: 0 auto; border-radius: 3px; background: var(--edge-strong); }
  .sheet-grip { transition: bottom 0.25s ease; }
}
