:root {
  /* dark theme (default) */
  --bg: #0a0d19;
  --card: rgba(20, 25, 44, .9);
  --ink: #e6e9f5;
  --muted: #8f98b4;
  --faint: #5d6684;
  --line: rgba(255, 255, 255, .07);
  --accent: #7686ff;
  --you: #7686ff;
  --foe: #d27030;
  --accent-ink: #ffffff;
  --accent-soft: rgba(118, 134, 255, .16);
  --good: #3fcf8e;
  --good-soft: rgba(63, 207, 142, .14);
  --bad: #ff5f64;
  --bad-soft: rgba(255, 95, 100, .14);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, .14);
  --am: #b27dff;
  --am-soft: rgba(178, 125, 255, .16);
  --metal: #8b97b0;
  --crystal: #3fb6e6;
  --deut: #2fc48a;
  --energy: #f5b041;
  --soft: rgba(255, 255, 255, .07);
  --inner: rgba(255, 255, 255, .045);
  --seg-bg: rgba(255, 255, 255, .05);
  --seg-on: #262e4d;
  --alert-ink: #ffb8ba;
  --info-ink: #c5ccff;
  --warn-ink: #ffd89a;
  --help-ink: #c3c9dc;
  --grabber: rgba(255, 255, 255, .2);
  --scrim: rgba(2, 4, 10, .62);
  --toast: #262d4b;
  --tabs-bg: rgba(10, 13, 25, .92);
  --slider-end: #3a4270;
  --thumb: #e6e9f5;
  --threat-bar: linear-gradient(90deg, #173b2c 0 10%, #3d3217 10% 33%, #45261d 33% 66%, #4a1c22 66%);
  --radius: 0;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 6px 18px rgba(0, 0, 0, .35);
  --backdrop: none;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f5fb;
  --card: #ffffff;
  --ink: #1b2033;
  --muted: #6b7389;
  --faint: #a3a9ba;
  --line: #e6e9f2;
  --accent: #5b6cff;
  --you: #4f5fe8;
  --foe: #d1661c;
  --accent-soft: #eef0ff;
  --good: #1a9f6b;
  --good-soft: #e5f7ef;
  --bad: #e5484d;
  --bad-soft: #fdecec;
  --warn: #e38b0b;
  --warn-soft: #fff4e0;
  --am: #9b5cf6;
  --am-soft: #f3ecff;
  --soft: #eceff6;
  --inner: #f3f5fb;
  --seg-bg: #e8ebf4;
  --seg-on: #ffffff;
  --alert-ink: #8e1f23;
  --info-ink: #2d3a9e;
  --warn-ink: #7a4a05;
  --help-ink: #3b4258;
  --grabber: #d5d9e5;
  --scrim: rgba(20, 24, 40, .35);
  --toast: #1b2033;
  --tabs-bg: #ffffff;
  --slider-end: #b9c2ff;
  --thumb: #ffffff;
  --threat-bar: linear-gradient(90deg, #dff5ea 0 10%, #fff1d6 10% 33%, #ffe0d9 33% 66%, #fbd0d2 66%);
  --shadow: 0 1px 2px rgba(27, 32, 51, .05), 0 4px 14px rgba(27, 32, 51, .05);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background-color: var(--bg); color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
/* phones: no long-press callouts, text selection or tap flash on game UI (text fields still work); no double-tap zoom */
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
body { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
/* iOS zooms into text fields under 16px: keep them at 16px there */
@supports (-webkit-touch-callout: none) { input, textarea, select { font-size: 16px; } }
input { font: inherit; color: inherit; }
body { background-image: var(--stars, none), radial-gradient(ellipse 80% 50% at 15% 0%, rgba(91, 108, 255, .10), transparent 70%), radial-gradient(ellipse 70% 45% at 100% 85%, rgba(155, 92, 246, .08), transparent 70%); background-repeat: repeat, no-repeat, no-repeat; }
:root[data-theme="light"] body { background-image: none; }
#app { display: flex; flex-direction: column; height: 100%; max-width: 560px; margin: 0 auto; padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); box-sizing: border-box; }

/* ---------- top bar */
#topbar { display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 16px 6px; }
.planet-chip { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-align: left; }
.planet-chip .globe { width: 34px; height: 34px; flex: none; }
.planet-chip b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.planet-chip small { color: var(--muted); font-size: 12px; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 0; display: grid; place-items: center; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.icon-btn svg { width: 20px; height: 20px; }
.gov-btn { border-color: var(--gc); padding: 0; }
.gov-btn img { width: 30px; height: 30px; image-rendering: pixelated; display: block; }
.badge { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 0; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }

/* ---------- resources */
#resbar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; padding: 6px 16px 10px; }
.res { background: var(--card); border: 1px solid var(--line); border-radius: 0; padding: 6px 4px; text-align: center; box-shadow: var(--shadow); min-width: 0; }
.res .v { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.res .l { font-size: 10px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 4px; }
.res.full .v, .res.neg .v { color: var(--bad); }
.res { position: relative; overflow: hidden; }
.res .l { font-variant-numeric: tabular-nums; white-space: nowrap; }
.res-fill { position: absolute; left: 6px; right: 6px; bottom: 3px; height: 3px; border-radius: 0; background: var(--soft); overflow: hidden; }
.res-fill > i { display: block; height: 100%; background: var(--accent); border-radius: 0; }
.res.full .res-fill > i { background: var(--bad); }
/* refined materials: a compact second row */
.res-row2 { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.res.mini.dim { opacity: .5; }
.res.mini { display: flex; align-items: center; gap: 5px; padding: 4px 6px 7px; text-align: left; }
.res.mini .res-ic { width: 18px; height: 18px; margin: 0; flex: none; }
.res.mini > span { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.res.mini .v { font-size: 12px; }
.res.mini .l { font-size: 9.5px; justify-content: flex-start; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 0; flex: none; }
.dot.m { background: var(--metal); } .dot.c { background: var(--crystal); } .dot.d { background: var(--deut); }
.dot.e { background: var(--energy); } .dot.am { background: var(--am); }

/* ---------- main & tabs */
#main { flex: 1; overflow-y: auto; padding: 4px 16px 24px; -webkit-overflow-scrolling: touch; }
#tabs { display: grid; grid-template-columns: repeat(6, 1fr); background: var(--tabs-bg); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 0; color: var(--faint); font-size: 10px; font-weight: 600; position: relative; }
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--accent); }
.tab.locked { opacity: 0.5; }
/* galaxy star map */
.starmap { position: relative; aspect-ratio: 100 / 64; margin-bottom: 10px; border: 1px solid var(--line); background: radial-gradient(circle at 20% 60%, rgba(229, 72, 77, 0.08), transparent 45%), radial-gradient(circle at 55% 20%, rgba(127, 211, 78, 0.07), transparent 45%), radial-gradient(circle at 88% 45%, rgba(142, 78, 198, 0.12), transparent 45%), #070a18; overflow: hidden; }
.sm-in { position: absolute; left: 5%; right: 7%; top: 7%; bottom: 13%; }
.sm-in svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sm-in line { stroke: #2a3358; stroke-width: 0.35; vector-effect: non-scaling-stroke; }
.star { position: absolute; transform: translate(-6px, -6px); display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 0; background: none; border: 0; color: #8d96b8; font-size: 9px; line-height: 1.1; white-space: nowrap; }
.star.left { align-items: flex-end; transform: translate(calc(-100% + 6px), -6px); }
/* systems are round dots (the user's choice, like the roulette wheel): grey, or a commander's colour */
.star i { display: block; position: relative; width: 12px; height: 12px; border-radius: 50%; background: #56607e; }
.star.uniq i::after { content: ""; position: absolute; left: 4px; top: 4px; width: 4px; height: 4px; border-radius: 50%; background: #fff3b6; box-shadow: 0 0 0 1px #05070f; }   /* a unique world is here */
.star i.held { background: var(--c); box-shadow: 0 0 7px var(--c); }
.star.on { color: #fff; font-weight: 700; z-index: 2; }
.star.on i { outline: 2px solid #fff; outline-offset: 2px; border-radius: 50%; }
.pips { letter-spacing: 1px; color: var(--warn, #e8a33d); } .pips em { font-style: normal; color: var(--line); }
.clan { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 6px; border: 1px solid var(--line); }
.clan i { width: 9px; height: 9px; flex: none; }
.news-row { padding: 6px 2px; border-bottom: 1px solid var(--line); } .news-row:last-of-type { border-bottom: 0; }
.power-row { display: flex; align-items: center; gap: 8px; padding: 5px 2px; border-bottom: 1px solid var(--line); } .power-row:last-child { border-bottom: 0; }
.power-row .rank { width: 16px; color: var(--faint); font-size: 12px; text-align: right; }
.power-row .clan { border: 0; padding: 0; }
.pill.faint { opacity: 0.55; }
/* online: join screen, connection banner, other commanders */
.join { max-width: 420px; margin: 0 auto; padding: 24px 4px; }
.join h1 { margin: 12px 0 4px; font-size: 34px; letter-spacing: 1px; }
.join label { display: block; margin: 10px 0 4px; }
.join .field { width: 100%; box-sizing: border-box; }
.join label.check, .check { display: flex; align-items: center; gap: 8px; margin: 12px 0 2px; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.card form label { display: block; margin: 10px 0 4px; }
.card form .field { width: 100%; box-sizing: border-box; }
#netbar { display: none; position: fixed; left: 0; right: 0; top: 0; z-index: 30; padding: calc(4px + env(safe-area-inset-top)) 12px 4px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 700; text-align: center; }
body.offline #netbar, body.mismatch #netbar { display: block; }
.pos-badge.rival { background: #f2f4ff; color: #10142a; }
.pos-badge.me { color: #10142a; }
/* daily event options */
.daily-opt { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; padding: 12px 14px; margin-top: 8px; background: var(--card); border: 1px solid var(--accent); }
.daily-opt b { font-size: 15px; }
.daily-opt .small { color: var(--good); }
.daily-opt:active { background: var(--accent-soft); }
/* governments */
.gov-card { border-left: 3px solid var(--gc); }
.col-swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 6px; margin-top: 12px; }
.col-swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 5px 0 4px; border: 2px solid transparent; }
.col-swatch i { display: block; width: 34px; height: 34px; background: var(--sc); border: 2px solid; border-color: rgba(255, 255, 255, .45) rgba(0, 0, 0, .55) rgba(0, 0, 0, .55) rgba(255, 255, 255, .45); }
.col-swatch small { font-size: 11px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-swatch.on { border-color: var(--sc); background: var(--soft); } .col-swatch.on small { color: var(--ink); font-weight: 700; }
.col-swatch.taken { opacity: .38; } .col-swatch.taken i { background-image: repeating-linear-gradient(45deg, transparent 0 5px, rgba(0, 0, 0, .55) 5px 8px); }
.swatch-dot { display: inline-block; width: 10px; height: 10px; margin-right: 6px; }
.gov-card .perks { margin: 8px 0 6px 18px; padding: 0; font-size: 13px; line-height: 1.45; }
.gov-preview { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gov-preview .art.sm { width: 40px; height: 40px; }
.gov-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--gc); border: 1px solid var(--gc); padding: 1px 7px 1px 2px; }
.reqs { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 0 2px; }
.req { font-size: 11px; padding: 1px 5px; border: 1px solid var(--line); }
.req.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.req.no { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.tt-row.locked img { filter: grayscale(0.85) brightness(0.75); }
.tt-cat { margin: 20px 4px 2px; padding-top: 12px; border-top: 2px solid var(--line); }
.tt-cat b { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tt-tier { margin: 12px 4px 6px; }
#sheet .seg button { padding-left: 2px; padding-right: 2px; }
.gov-tag img { width: 18px; height: 18px; image-rendering: pixelated; }
.tab.on::before { content: ""; position: absolute; top: 2px; width: 44px; height: 30px; border-radius: 0; background: var(--accent-soft); z-index: -1; }
.tab .badge { top: 0; right: 10px; }
.tab { z-index: 0; }

h2 { font-size: 22px; margin: 10px 2px 12px; letter-spacing: -.3px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 4px 8px; font-weight: 700; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 0; box-shadow: var(--shadow); padding: 14px; margin-bottom: 10px; }
.card.tight { padding: 10px 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 10px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- segmented & chips */
.seg { display: flex; background: var(--seg-bg); border-radius: 0; padding: 4px; margin: 6px 0 12px; }
.seg button { flex: 1; padding: 8px 4px; border-radius: 0; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--seg-on); color: var(--ink); box-shadow: var(--shadow); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 7px 12px; border-radius: 0; background: var(--soft); font-weight: 600; font-size: 13px; color: var(--muted); }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chip:disabled { opacity: .4; }
.pos-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.speeds { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; } .speeds .chip { text-align: center; padding-left: 0; padding-right: 0; }
.pos-grid .chip { text-align: center; padding: 8px 0; border-radius: 0; }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; }
.btn.block { width: 100%; }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.am { background: var(--am-soft); color: var(--am); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 0; }
.btn:disabled, .btn.off { opacity: .45; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- pixel art, framed like a 2000s browser game */
.art { width: 80px; height: 80px; flex: none; image-rendering: pixelated; image-rendering: crisp-edges;
  border: 2px solid; border-color: #6d7a9c #10131d #10131d #6d7a9c; border-radius: 0;
  box-shadow: 0 0 0 1px #0a0c14, 0 3px 8px rgba(10, 12, 20, .35); background: #0a0c16; }
.art.sm { width: 48px; height: 48px; }
.art.xl { width: 200px; height: 200px; }
.art-hero { display: flex; justify-content: center; margin: 2px 0 12px; }
.banner { display: block; width: 100%; aspect-ratio: 128 / 48; image-rendering: pixelated; margin: 4px 0 12px;
  border: 2px solid; border-color: #6d7a9c #10131d #10131d #6d7a9c; border-radius: 0; box-shadow: 0 0 0 1px #0a0c14, 0 4px 12px rgba(10, 12, 20, .3); background: #0a0c16; }
.res-ic { display: block; width: 24px; height: 24px; margin: 0 auto 2px; image-rendering: pixelated; }
.unit-ic { width: 20px; height: 20px; image-rendering: pixelated; border-radius: 0; }
.dot { width: 12px; height: 12px; border-radius: 0; image-rendering: pixelated; }
.globe-art { width: 40px; height: 40px; flex: none; image-rendering: pixelated; border-radius: 0; }
.hero .globe-art { width: 96px; height: 96px; border-radius: 0; border: 2px solid; border-color: #6d7a9c #10131d #10131d #6d7a9c; }
.planet-chip .globe-art { width: 40px; height: 40px; }

/* ---------- build menus: status strip, category chips, icon grid */
.strip { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin: -2px 4px 10px; }
.strip b { color: var(--ink); }
.cat-chips { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 4px; padding: 2px 16px 6px; scrollbar-width: none; }
.cat-chips::-webkit-scrollbar { display: none; }
.cat-chips .chip { white-space: nowrap; flex: none; }
.chip .cnt { opacity: .65; font-size: 11px; margin-left: 2px; }
.cat-head { display: flex; flex-direction: column; margin: 14px 4px 8px; }
.cat-head b { font-size: 15px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gtile { background: var(--card); border: 1px solid var(--line); border-radius: 0; box-shadow: var(--shadow); padding: 6px 6px 8px; display: flex; flex-direction: column; gap: 5px; text-align: center; min-width: 0; }
.gtile:active { transform: scale(.97); }
.gt-art { position: relative; display: block; aspect-ratio: 1; border-radius: 0; overflow: hidden;
  border: 2px solid; border-color: #6d7a9c #10131d #10131d #6d7a9c; background: #0a0c16; }
.gt-art img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.gtile.locked .gt-art img { filter: grayscale(1) brightness(.5); }
.gt-lock { position: absolute; inset: 0; display: grid; place-items: center; color: #dfe4f2; }
.gt-lock svg { width: 26px; height: 26px; }
.gt-lvl { position: absolute; right: 3px; bottom: 3px; background: rgba(8, 10, 18, .82); color: #fff; font-size: 11px; font-weight: 800; padding: 1px 5px; border-radius: 0; font-variant-numeric: tabular-nums; }
/* ready to build / upgrade / train: a 7x7 pixel orb (ui_orb) that glows in three hard steps (period = READY_PULSE_MS in ui.js) */
.gt-art img.gt-orb { position: absolute; right: 4px; top: 4px; width: 14px; height: 14px; image-rendering: pixelated; animation: orbGlow 2.4s infinite; }
@keyframes orbGlow { 0% { filter: brightness(.85); } 33% { filter: brightness(1.12); } 66% { filter: brightness(1.4); } 100% { filter: brightness(.85); } }
.gt-orb { animation-timing-function: steps(1, end); }
@media (prefers-reduced-motion: reduce) { .gt-orb { animation: none; } }
.gt-name { font-size: 12px; font-weight: 700; line-height: 1.2; min-height: 2.4em; display: flex; align-items: center; justify-content: center; }
.gt-sub { font-size: 11px; color: var(--muted); margin-top: -2px; }
.gtile .bar { margin: 0; height: 5px; }
.gtile.busy { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }

/* ---------- detail sheet */
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.statgrid > div { background: var(--inner); border-radius: 0; padding: 7px 9px; min-width: 0; }
.statgrid small { display: block; color: var(--muted); font-size: 11px; }
.statgrid b { font-size: 14px; font-variant-numeric: tabular-nums; }
.statgrid b.up, .statgrid .up { color: var(--good); }
.statgrid:has(> div:nth-child(2):last-child) { grid-template-columns: 1fr 1fr; }
.statgrid:has(> div:only-child) { grid-template-columns: 1fr; }
.cost small { font-weight: 600; }
.req-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); color: var(--bad); font-size: 13.5px; }
.req-row:first-child { border-top: 0; }
.req-row.ok { color: var(--good); }
.req-row .grow { color: var(--ink); }
.unlocks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.unl { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 600; text-align: center; line-height: 1.15; }
.unl img { width: 52px; height: 52px; image-rendering: pixelated; border-radius: 0; border: 2px solid; border-color: #6d7a9c #10131d #10131d #6d7a9c; filter: grayscale(1) brightness(.6); }
.unl.ok img { filter: none; }
.unl small { color: var(--muted); font-size: 10px; }

/* ---------- item cards (buildings, units, research) */
.item { display: flex; gap: 12px; }
.tile { width: 48px; height: 48px; border-radius: 0; display: grid; place-items: center; flex: none; color: #fff; }
.tile svg { width: 26px; height: 26px; }
.item .title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lvl { font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 0; padding: 1px 7px; }
.desc { color: var(--muted); font-size: 13px; margin: 2px 0 6px; }
.costs { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cost { display: inline-flex; align-items: center; gap: 4px; }
.cost.short { color: var(--bad); }
.meta { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 8px; }
.meta .t { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 4px; }
.req { font-size: 12.5px; color: var(--warn); margin-top: 6px; }
.stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin: 4px 0; }
.stats b { color: var(--ink); font-weight: 600; }
.locked { opacity: .6; }
.link { color: var(--accent); font-weight: 600; }

.stepper { display: flex; align-items: center; background: var(--soft); border-radius: 0; height: 38px; }
.stepper button { width: 34px; height: 38px; font-size: 18px; font-weight: 700; color: var(--muted); }
.stepper input { width: 58px; border: 0; background: transparent; text-align: center; font-weight: 700; outline: none; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ---------- range slider (resource settings) */
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 6px 0 0; }
.slider::-webkit-slider-runnable-track { height: 8px; border-radius: 0; background: linear-gradient(90deg, var(--accent), var(--slider-end)); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -8px; border-radius: 0; background: var(--thumb); border: 3px solid var(--accent); box-shadow: var(--shadow); }
.slider::-moz-range-track { height: 8px; border-radius: 0; background: var(--accent); }
.slider::-moz-range-thumb { width: 20px; height: 20px; border-radius: 0; background: #fff; border: 3px solid var(--accent); }

/* ---------- progress */
.bar { height: 8px; border-radius: 0; background: var(--soft); overflow: hidden; margin: 8px 0 4px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 0; transition: width .9s linear; }
.bar.am > i { background: var(--am); }
.bar.threat { height: 12px; border-radius: 0; position: relative; background: var(--threat-bar); }
.bar.threat > i { background: transparent; border-right: 3px solid var(--ink); border-radius: 0; }
.queue-item { padding: 10px 0; border-top: 1px solid var(--line); }
.queue-item:first-child { border-top: 0; padding-top: 0; }
.queue-list { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.queue-list:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.q-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.q-row .unit-ic { width: 28px; height: 28px; flex: none; }
.q-row .grow { min-width: 0; }
.q-x { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 0; border: 1px solid var(--line); background: transparent; color: var(--muted); }
.q-x:active { background: var(--bad); color: #fff; border-color: var(--bad); }
.q-x svg { width: 16px; height: 16px; }

/* ---------- planet hero */
.hero { display: flex; gap: 14px; align-items: center; }
.globe { border-radius: 0; box-shadow: inset -8px -8px 18px rgba(0,0,0,.25), inset 4px 4px 10px rgba(255,255,255,.35); }
.hero .globe { width: 76px; height: 76px; flex: none; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.kv > div { background: var(--inner); border-radius: 0; padding: 8px 10px; }
.kv small { display: block; color: var(--muted); font-size: 11px; }
.kv b { font-variant-numeric: tabular-nums; }

/* ---------- alerts */
.alert { border-radius: 0; padding: 14px; margin-bottom: 10px; background: var(--bad-soft); color: var(--alert-ink); }
.alert b { color: var(--bad); }
.alert.info { background: var(--accent-soft); color: var(--info-ink); }
.alert.info b, .alert.warn b { color: inherit; }
.alert.warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; border-radius: 0; padding: 2px 9px; background: var(--soft); color: var(--muted); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.acc { background: var(--accent-soft); color: var(--accent); }
.pill.am { background: var(--am-soft); color: var(--am); }

/* ---------- lists */
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.list-row:first-child { border-top: 0; }
.pos-badge { width: 34px; height: 34px; border-radius: 0; display: grid; place-items: center; font-weight: 800; background: var(--soft); color: var(--muted); flex: none; font-size: 14px; }
.pos-badge.me { background: var(--accent); color: #fff; }
.pos-badge.npc { background: #262d4a; color: #c5ccdf; }
.pos-badge.lib { background: var(--good-soft); color: var(--good); }
.unread { width: 8px; height: 8px; border-radius: 0; background: var(--accent); flex: none; }

/* ---------- fleet movements */
.route { display: flex; align-items: center; gap: 8px; margin: 12px 0 6px; }
.rt-end { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 62px; flex: none; }
.rt-end img { width: 36px; height: 36px; image-rendering: pixelated; border-radius: 0; }
.rt-end small { font-size: 10.5px; color: var(--muted); text-align: center; line-height: 1.15; max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-track { position: relative; flex: 1; height: 4px; margin-bottom: 16px; border-radius: 0;
  background: repeating-linear-gradient(90deg, var(--faint) 0 4px, transparent 4px 8px); }
.rt-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 0; opacity: .55; }
.rt-ship { position: absolute; top: 50%; width: 24px; height: 24px; margin: -12px 0 0 -12px; color: var(--ink); transform: rotate(90deg); transition: left .9s linear; }
.rt-ship.back { transform: rotate(-90deg); }
.rt-ship img { width: 24px; height: 24px; image-rendering: pixelated; display: block; }
.timeline { margin-top: 4px; }
.tl-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 12.5px; border-top: 1px solid var(--line); }
.tl-row:first-child { border-top: 0; }
.tl-dot { width: 8px; height: 8px; border-radius: 0; border: 2px solid var(--accent); flex: none; }
.tl-row.done { color: var(--muted); }
.tl-row.done .tl-dot { background: var(--accent); }
.ship-chips { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12.5px; font-weight: 600; }
.ship-chips .cost { gap: 6px; }

/* ---------- black market */
.casino-card { border-color: rgba(255, 79, 216, .25); box-shadow: 0 0 24px rgba(155, 92, 246, .12), var(--shadow); }
.reels { display: flex; gap: 10px; justify-content: center; margin: 14px 0 10px; }
.reel { width: 80px; height: 80px; display: grid; place-items: center; border-radius: 0; background: #07080f;
  border: 2px solid; border-color: #6d7a9c #10131d #10131d #6d7a9c; box-shadow: inset 0 8px 14px rgba(0, 0, 0, .7), inset 0 -8px 14px rgba(0, 0, 0, .7); }
.reel img { width: 48px; height: 48px; image-rendering: pixelated; }
.reel.win { box-shadow: 0 0 0 2px var(--good), 0 0 18px rgba(63, 207, 142, .45); }
.casino-msg { text-align: center; min-height: 42px; margin-bottom: 10px; }
.casino-msg b { font-size: 16px; letter-spacing: .5px; }
.casino-msg b.up { color: var(--good); }
.wheel-wrap { position: relative; width: 250px; height: 250px; margin: 16px auto 12px; }
.wheel { position: absolute; inset: 0; border-radius: 50%; border: 6px solid #d6a22c; box-shadow: 0 0 0 2px #6a460d, 0 0 26px rgba(255, 79, 216, .25); }
.seg-ic.boxed { border-radius: 50%; }
.seg-ic { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; image-rendering: pixelated; }
.wheel-hub { position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3b6, #a47019 70%); box-shadow: 0 2px 6px rgba(0, 0, 0, .5); }
.wheel-pointer { position: absolute; left: 50%; top: -8px; margin-left: -10px; width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent; border-top: 20px solid #ff4fd8; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .6)); }
.payouts { margin-top: 12px; }
.payouts summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13px; }
.pay-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.pay-syms { display: flex; gap: 2px; align-items: center; width: 62px; flex: none; }
.pay-syms img { width: 18px; height: 18px; image-rendering: pixelated; }
.swatch { width: 10px; height: 10px; border-radius: 0; display: inline-block; margin-right: 3px; }

/* ---------- odds */
.odds { display: grid; gap: 6px; }
.odd { display: grid; grid-template-columns: 116px 1fr 40px; align-items: center; gap: 8px; font-size: 12.5px; }
.odd .track { height: 8px; background: var(--soft); border-radius: 0; overflow: hidden; }
.odd .track i { display: block; height: 100%; border-radius: 0; }
.odd.good i { background: var(--good); } .odd.neutral i { background: var(--faint); } .odd.danger i { background: var(--bad); } .odd.am i { background: var(--am); }

.stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; margin: 10px 0 8px; }
.stage i { display: block; height: 10px; background: var(--soft); }
.stage i b { display: block; height: 100%; background: var(--good); }
.stage.warn i b { background: var(--warn); } .stage.bad i b { background: var(--bad); }
.stage small { display: block; margin-top: 4px; text-align: center; font-size: 11px; color: var(--faint); }
.stage.past small { color: var(--muted); } .stage.on small { color: var(--ink); font-weight: 700; }
.depths { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.depth { display: block; padding: 9px 4px 8px; text-align: center; background: var(--soft); border: 2px solid transparent; }
.depth.on { border-color: var(--accent); }
.depth b { display: block; font-size: 16px; } .depth small { display: block; margin: 1px 0 5px; font-size: 11px; color: var(--muted); }
.outlook { display: flex; height: 12px; margin: 12px 0 6px; background: var(--soft); }
.outlook i { display: block; height: 100%; }
.outlook .good, .dot-k.good { background: var(--good); } .outlook .am, .dot-k.am { background: var(--am); } .outlook .neutral, .dot-k.neutral { background: var(--faint); } .outlook .danger, .dot-k.danger { background: var(--bad); }
.outlook-key { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); }
.outlook-key b { color: var(--ink); } .dot-k { display: inline-block; width: 8px; height: 8px; margin-right: 5px; }
.threat-after { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; padding-top: 10px; border-top: 1px solid var(--soft); }

/* ---------- battle report */
.bt { width: 100%; border-collapse: collapse; font-size: 13px; }
.bt td, .bt th { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.bt th { color: var(--muted); font-weight: 600; font-size: 11.5px; }
.bt td:first-child, .bt th:first-child { text-align: left; }
.bt .loss { color: var(--bad); }

/* ---------- sheet */
#scrim { position: fixed; inset: 0; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 88%; overflow-y: auto; background-color: var(--bg); background-image: var(--stars, none); border-radius: 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, .35); padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); transform: translateY(105%); transition: transform .25s cubic-bezier(.2,.8,.2,1); z-index: 11; }
body.sheet-open #scrim { opacity: 1; pointer-events: auto; }
body.sheet-open #sheet { transform: none; }
.grabber { width: 40px; height: 5px; border-radius: 0; background: var(--grabber); margin: 4px auto 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { margin: 6px 2px; font-size: 20px; }
textarea, .field { width: 100%; border: 1px solid var(--line); border-radius: 0; padding: 10px 12px; background: var(--card); color: var(--ink); font: inherit; font-size: 14px; }
textarea { min-height: 110px; font-family: ui-monospace, monospace; font-size: 11px; }

/* ---------- toasts */
#toasts { position: fixed; left: 0; right: 0; top: calc(10px + env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 20; padding: 0 16px; }
.toast { background: var(--toast); color: #fff; padding: 10px 14px; border-radius: 0; font-size: 13.5px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.18); max-width: 520px; animation: tin .25s ease-out; pointer-events: auto; }
.toast.good { background: #127a52; } .toast.bad { background: #c9353a; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all .3s; }
@keyframes tin { from { opacity: 0; transform: translateY(-10px); } }

.empty { text-align: center; color: var(--muted); padding: 24px 12px; font-size: 14px; }
.help p { margin: 6px 0 10px; color: var(--help-ink); }
.tour-head { margin: 10px 4px 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tour-row { display: flex; align-items: center; gap: 12px; padding: 7px 4px; }
.tour-ic { flex: none; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; background: var(--soft); color: var(--accent); }
.tour-ic svg { width: 20px; height: 20px; } .tour-ic img, .tour-ic canvas { width: 26px; height: 26px; image-rendering: pixelated; }
.tour-steps { margin: 12px 0 10px; padding-left: 22px; line-height: 1.5; } .tour-steps li { margin: 6px 0; }

/* ---------- enemy unit lists */
.unit-link { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 0; text-align: left; }
.unit-link b { font-weight: 800; }

/* ---------- quest chapters */
.quest.claimed { opacity: .55; }
.chapter-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 6px; border-radius: 0; background: var(--card); border: 1px solid var(--line); font-size: 13.5px; }
.chapter-row.done span:first-child { color: var(--good); font-weight: 800; }
.chapter-row.locked { opacity: .55; }
.chapter-bonus { border-color: rgba(214, 162, 44, .45); box-shadow: 0 0 18px rgba(214, 162, 44, .12), var(--shadow); }

/* ---------- battle replay (reports) */
.replay { margin-bottom: 10px; }
.rp-top { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px 6px; }
.rp-field { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: start; min-height: 132px; padding: 10px 8px 12px; overflow: hidden;
  background: #070914; border: 2px solid; border-color: #6d7a9c #10131d #10131d #6d7a9c; }
.rp-side { min-width: 0; }
.rp-name { font-size: 11px; font-weight: 700; color: #c9d1ea; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-name i, .tl-legend i { display: inline-block; width: 9px; height: 9px; margin-right: 5px; vertical-align: -1px; }
i.you { background: var(--you); } i.foe { background: var(--foe); }
.rp-side[data-side="foe"] .rp-name { text-align: right; }
.rp-units { display: flex; flex-wrap: wrap; gap: 4px; }
.rp-side[data-side="foe"] .rp-units { justify-content: flex-end; }
.rp-unit { position: relative; width: 38px; text-align: center; }
.rp-unit img { display: block; width: 34px; height: 34px; margin: 0 auto; image-rendering: pixelated; border: 1px solid #262c44; }
.rp-unit b { display: block; font-size: 10px; color: #e8ecf8; font-variant-numeric: tabular-nums; }
.rp-vs { align-self: center; font-weight: 800; font-size: 11px; color: #5b6488; }
.rp-enter[data-side="you"] .rp-unit { animation: rp-in-l .5s ease-out both; }
.rp-enter[data-side="foe"] .rp-unit { animation: rp-in-r .5s ease-out both; }
@keyframes rp-in-l { from { transform: translateX(-70px); opacity: 0; } }
@keyframes rp-in-r { from { transform: translateX(70px); opacity: 0; } }
.rp-shot { position: absolute; left: -2px; top: -2px; width: 4px; height: 4px; z-index: 2; pointer-events: none; transition: transform .45s linear; }
.rp-shot.you { background: var(--you); box-shadow: 0 0 6px var(--you); }
.rp-shot.foe { background: var(--foe); box-shadow: 0 0 6px var(--foe); }
.rp-hit img { animation: rp-hit .3s steps(2); }
@keyframes rp-hit { 50% { filter: brightness(2.4); transform: translateX(2px); } }
.rp-hurt b { color: #ff8a80; }
.rp-dead img { filter: grayscale(1) brightness(.35); opacity: .5; transition: filter .5s, opacity .5s; }
.rp-boom { position: absolute; left: 2px; top: 0; width: 34px; height: 34px; border: 0 !important; image-rendering: pixelated; pointer-events: none; animation: rp-boom .7s steps(7) forwards; }
@keyframes rp-boom { from { transform: scale(.3); opacity: 1; } 70% { opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
.rp-banner { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; pointer-events: none; opacity: 0; font-weight: 900; letter-spacing: 3px; text-shadow: 0 2px 0 #000, 0 0 12px rgba(0,0,0,.8); }
.rp-banner.start { color: #fff; font-size: 18px; animation: rp-flash 1.1s ease-out; }
.rp-banner.phase { font-size: 18px; animation: rp-flash 1.3s ease-out; }
.rp-banner.final { font-size: 30px; background: rgba(5, 7, 15, .6); animation: rp-pop .5s cubic-bezier(.2, 1.6, .4, 1) forwards; }
.rp-banner.victory { color: #3ddc84; } .rp-banner.defeat { color: #ff5f64; } .rp-banner.draw { color: #f5b041; }
@keyframes rp-flash { 0% { opacity: 0; transform: scale(1.5); } 20% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes rp-pop { 0% { opacity: 0; transform: scale(2.4); } 100% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .rp-field *, .rp-banner { animation-duration: .01s !important; transition: none !important; } }
/* ---------- battle timeline */
.tl-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.tl-row { display: grid; grid-template-columns: 70px 1fr; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.tl-row:nth-child(2) { border-top: 0; }
.tl-label { font-size: 11px; color: var(--muted); }
.tl-bar { display: flex; align-items: center; gap: 6px; height: 12px; margin: 2px 0; }
.tl-bar i { display: block; height: 8px; min-width: 0; }
.tl-bar.you i { background: var(--you); } .tl-bar.foe i { background: var(--foe); }
.tl-bar span { font-size: 11px; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-extra { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* ---------- contracts (mini-games) */
.ct-hud { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; margin: 0 2px 6px; }
.ct-canvas { display: block; width: 100%; aspect-ratio: 320 / 200; image-rendering: pixelated; touch-action: none; background: #070914;
  border: 2px solid; border-color: #6d7a9c #10131d #10131d #6d7a9c; }

/* ================================================================ PIXEL STYLE
   Everything below applies only when <html data-style="pixel"> (Settings > Interface style). Deleting this
   block, the font files and the switch in ui.js restores the classic look everywhere. */
@font-face { font-family: "Jersey 15"; src: url("jersey15.ttf") format("truetype"); font-weight: 400; font-display: swap; }
:root[data-style="pixel"] {
  --pxfont: "Jersey 15", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --px-line: #46528a;          /* panel frame */
  --px-in: #080b18;            /* inner line of the double frame */
  --px-drop: #03050c;          /* hard shadow */
  --card: #121731;
  --line: #2a3258;
  --soft: #1c2342;
  --inner: #0c1024;
  --seg-bg: #0c1024;
  --seg-on: #2b3670;
  --tabs-bg: #0b0f20;
  --toast: #262d4b;
  --shadow: none;
}
:root[data-style="pixel"][data-theme="light"] {
  --px-line: #6f79a6; --px-in: #ffffff; --px-drop: #b4bbd4;
  --card: #ffffff; --line: #cfd5e6; --soft: #e6eaf4; --inner: #f1f3fa; --seg-bg: #e3e7f2; --seg-on: #ffffff; --tabs-bg: #ffffff;
}
/* ---- type: titles, buttons, tabs and labels in the pixel font; numbers and running text stay as they were */
:root[data-style="pixel"] :is(h1, h2, h3, .btn, .chip, .tab, .seg button, .gt-name, .cat-head b, .tour-head, .depth b, .planet-chip b, .item .title,
  .stage small, .toast, .list-row b, .card > .row b, .sheet-head h2, .link) { font-family: var(--pxfont); font-weight: 400; font-synthesis: none; letter-spacing: .3px; }
:root[data-style="pixel"] h2 { font-size: 30px; letter-spacing: .5px; }
:root[data-style="pixel"] .sheet-head h2 { font-size: 27px; }
:root[data-style="pixel"] h3 { font-size: 17px; letter-spacing: 1px; color: var(--ink); display: flex; align-items: center; gap: 7px; }
:root[data-style="pixel"] h3::before { content: ""; width: 6px; height: 6px; flex: none; background: var(--accent); box-shadow: 2px 2px 0 var(--px-drop); }
:root[data-style="pixel"] .join h1 { font-size: 52px; letter-spacing: 2px; text-shadow: 3px 3px 0 var(--px-drop); }
:root[data-style="pixel"] .tab { font-size: 14px; gap: 0; }
:root[data-style="pixel"] .chip { font-size: 16px; padding: 5px 11px; }
:root[data-style="pixel"] .chip .cnt { font-family: system-ui, sans-serif; font-size: 11px; }
:root[data-style="pixel"] .gt-name { font-size: 16px; line-height: 1.05; }
:root[data-style="pixel"] .planet-chip b { font-size: 21px; line-height: 1.1; }
:root[data-style="pixel"] .item .title { font-size: 19px; }
:root[data-style="pixel"] :is(.list-row b, .card > .row b) { font-size: 18px; }
:root[data-style="pixel"] .cat-head b { font-size: 21px; }
:root[data-style="pixel"] .depth b { font-size: 20px; }
:root[data-style="pixel"] .stage small { font-size: 13px; }
:root[data-style="pixel"] .tour-head { font-size: 14px; }
:root[data-style="pixel"] .link { font-size: 16px; }
/* ---- the frame: a 2px line, a darker line inside it, and a hard drop shadow; corners stay square */
:root[data-style="pixel"] :is(.card, .gtile, .res, .icon-btn, .chapter-row, .daily-opt, .starmap, .depth, .alert) {
  border: 2px solid var(--px-line); box-shadow: inset 0 0 0 2px var(--px-in), 3px 3px 0 var(--px-drop); }
:root[data-style="pixel"] .card { padding: 15px; margin-bottom: 13px; }
:root[data-style="pixel"] .card.tight { padding: 11px 13px; }
:root[data-style="pixel"] .res { padding: 7px 4px; }
:root[data-style="pixel"] .res.mini { padding: 5px 7px 8px; }
:root[data-style="pixel"] .res-fill { left: 5px; right: 5px; bottom: 4px; }
:root[data-style="pixel"] #resbar { gap: 7px; }
:root[data-style="pixel"] .res-row2 { gap: 7px; }
:root[data-style="pixel"] .grid { gap: 12px; }
:root[data-style="pixel"] .gtile { padding: 8px 8px 9px; }
:root[data-style="pixel"] .gtile.busy { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--px-in), 3px 3px 0 var(--px-drop); }
:root[data-style="pixel"] .gov-card { border-left: 6px solid var(--gc); }
:root[data-style="pixel"] .casino-card { border-color: #a04bd6; }
:root[data-style="pixel"] .chapter-bonus { border-color: #d6a22c; }
:root[data-style="pixel"] .alert { border-color: var(--bad); }
:root[data-style="pixel"] .alert.info { border-color: var(--accent); }
:root[data-style="pixel"] .alert.warn { border-color: var(--warn); }
:root[data-style="pixel"] .depth.on, :root[data-style="pixel"] .daily-opt { border-color: var(--accent); }
/* cells inside a panel: a single thin frame */
:root[data-style="pixel"] :is(.kv > div, .statgrid > div, .tour-ic, .stepper, .clan, .req) { border: 2px solid var(--line); }
:root[data-style="pixel"] .power-row .clan { border: 0; }
:root[data-style="pixel"] :is(textarea, .field) { border: 2px solid var(--px-line); box-shadow: inset 2px 2px 0 var(--px-in); background: var(--inner); }
:root[data-style="pixel"] :is(.list-row, .queue-item, .tl-row, .news-row, .power-row, .req-row) { border-top-width: 2px; border-top-style: dotted; }
:root[data-style="pixel"] :is(.news-row, .power-row) { border-bottom-width: 2px; border-bottom-style: dotted; border-top: 0; }
/* ---- buttons: a lit top edge, a dark bottom edge, a hard shadow; they sink when pressed */
:root[data-style="pixel"] .btn { border: 2px solid var(--px-drop); letter-spacing: .6px; font-size: 19px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .3), inset 0 -3px 0 rgba(0, 0, 0, .28), 3px 3px 0 var(--px-drop); }
:root[data-style="pixel"] .btn:active { transform: translate(2px, 2px); box-shadow: inset 0 2px 0 rgba(0, 0, 0, .25), 1px 1px 0 var(--px-drop); }
:root[data-style="pixel"] .btn.soft { background: #232c5c; color: #c3ccff; border-color: var(--accent); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .08), 3px 3px 0 var(--px-drop); }
:root[data-style="pixel"] .btn.ghost { background: var(--soft); border-color: var(--px-line); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .06), 3px 3px 0 var(--px-drop); }
:root[data-style="pixel"] .btn.danger { background: #3a1820; color: #ff8a8e; border-color: var(--bad); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .06), 3px 3px 0 var(--px-drop); }
:root[data-style="pixel"] .btn.am { background: #2c1d4a; color: #cfaaff; border-color: var(--am); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .06), 3px 3px 0 var(--px-drop); }
:root[data-style="pixel"] .btn.sm { font-size: 16px; }
:root[data-style="pixel"][data-theme="light"] .btn.soft { background: #e4e8ff; color: #3a49c8; }
:root[data-style="pixel"][data-theme="light"] .btn.danger { background: #fde4e5; color: #c9353a; }
:root[data-style="pixel"][data-theme="light"] .btn.am { background: #efe4ff; color: #7a3fd6; }
:root[data-style="pixel"] .btn-row { gap: 10px; margin-top: 12px; }
:root[data-style="pixel"] .icon-btn:active, :root[data-style="pixel"] .gtile:active { transform: translate(2px, 2px); box-shadow: inset 0 0 0 2px var(--px-in), 1px 1px 0 var(--px-drop); }
/* ---- chips, segments, pills, badges */
:root[data-style="pixel"] .chip { border: 2px solid var(--px-line); background: var(--inner); }
:root[data-style="pixel"] .chip.on { border-color: var(--px-drop); background: var(--accent); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .3), inset 0 -2px 0 rgba(0, 0, 0, .25); }
:root[data-style="pixel"] .seg { border: 2px solid var(--px-line); padding: 3px; gap: 3px; box-shadow: 3px 3px 0 var(--px-drop); }
:root[data-style="pixel"] .seg button { font-size: 16.5px; border: 2px solid transparent; padding: 7px 2px; white-space: nowrap; }
:root[data-style="pixel"] .seg button.on { border-color: var(--accent); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .12); }
:root[data-style="pixel"] .pill { border: 2px solid currentColor; padding: 0 7px; }
:root[data-style="pixel"] .badge { border: 2px solid var(--px-drop); height: 20px; min-width: 20px; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: 0; }
:root[data-style="pixel"] .lvl { border: 2px solid var(--accent); }
:root[data-style="pixel"] .gt-lvl { border: 2px solid #6d7a9c; background: #080a12; }
/* ---- bars: framed, filled in blocks */
:root[data-style="pixel"] .bar { height: 12px; border: 2px solid var(--px-line); background: var(--px-in); }
:root[data-style="pixel"] .gtile .bar { height: 9px; }
:root[data-style="pixel"] :is(.bar > i, .odd .track i, .stage i b) { background-image: repeating-linear-gradient(90deg, transparent 0 6px, rgba(0, 0, 0, .38) 6px 8px); }
:root[data-style="pixel"] .odd .track { height: 10px; border: 2px solid var(--line); background: var(--px-in); }
:root[data-style="pixel"] .stage i { height: 12px; border: 2px solid var(--px-line); background: var(--px-in); }
:root[data-style="pixel"] .outlook { height: 14px; border: 2px solid var(--px-line); }
:root[data-style="pixel"] .res-fill { height: 4px; background: var(--px-in); }
/* ---- shell: bottom bar, sheet, toasts */
:root[data-style="pixel"] #tabs { border-top: 2px solid var(--px-line); box-shadow: inset 0 2px 0 var(--px-in); padding-top: 8px; }
:root[data-style="pixel"] .tab.on::before { top: 0; bottom: 0; left: 3px; right: 3px; width: auto; height: auto; border: 2px solid var(--accent); background: var(--accent-soft); }
:root[data-style="pixel"] .tab .badge { top: -3px; right: 6px; }
:root[data-style="pixel"] #sheet { border-top: 2px solid var(--px-line); box-shadow: 0 -2px 0 var(--px-in), 0 -4px 0 var(--px-line); }
:root[data-style="pixel"] .grabber { height: 4px; background: var(--px-line); }
:root[data-style="pixel"] .toast { border: 2px solid var(--px-drop); box-shadow: 3px 3px 0 var(--px-drop); font-size: 18px; line-height: 1.15; }
:root[data-style="pixel"] .tile { border: 2px solid var(--px-drop); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .22), inset 0 -2px 0 rgba(0, 0, 0, .25); }
:root[data-style="pixel"] .check input { width: 22px; height: 22px; }
:root[data-style="pixel"] .gov-btn { border-color: var(--gc); }
:root[data-style="pixel"] #topbar { gap: 7px; }
:root[data-style="pixel"] #sheet .seg button { font-size: 15px; }
:root[data-style="pixel"] .tt-cat b { font-size: 22px; }
:root[data-style="pixel"] .tt-tier { font-size: 15px; color: var(--muted); }
/* numbers keep the normal font, and the first row of a list has no separator */
:root[data-style="pixel"] :is(.num, .num b, .list-row .right b, .costs, .cost, .speeds .chip) { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: 0; font-size: inherit; }
:root[data-style="pixel"] :is(.list-row, .queue-item, .tl-row, .req-row):first-child { border-top: 0; }
:root[data-style="pixel"] :is(.lvl, .item .title .lvl, .list-row b .lvl, .tt-cat b .lvl) { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 12px; font-weight: 700; letter-spacing: 0; }
/* long names in the powers and commanders lists are cut, never overlapped */
.power-row .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.power-row .clan { flex: none; max-width: 58%; overflow: hidden; white-space: nowrap; }

/* ---- v7.9: the guide */
.help-topics { margin: 2px 0 4px; }
.help ul { margin: -4px 0 10px 18px; padding: 0; color: var(--help-ink); }
.help li { margin: 2px 0; }
.hscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.htable { border-collapse: collapse; width: 100%; margin: 2px 0 12px; font-size: 12.5px; }
.htable th, .htable td { text-align: left; padding: 5px 10px 5px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.htable th { color: var(--muted); font-weight: 600; white-space: nowrap; }
/* ---- v7.9: five buttons in the top bar */
#topbar { gap: 5px; }
#topbar .icon-btn { width: 36px; height: 36px; }
#topbar .planet-chip { gap: 6px; }
#topbar .planet-chip .globe-art { width: 28px; height: 28px; }
#topbar .planet-chip small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root[data-style="pixel"] #topbar { gap: 5px; }
:root[data-style="pixel"] #topbar .planet-chip b { font-size: 19px; }
/* ---- v7.9: Dominion grid (one column per planet, the first column stays in place) */
.kv.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.kv.k3 small, .kv.k3 b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.egrid-wrap { margin: 0 -16px; }
.egrid { border-collapse: separate; border-spacing: 0; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.egrid th, .egrid td { padding: 5px 7px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; white-space: nowrap; }
.egrid td { min-width: 64px; max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
.egrid th.lab { position: sticky; left: 0; z-index: 2; background: var(--bg); text-align: left; font-weight: 600; padding-left: 16px; min-width: 92px; max-width: 118px; overflow: hidden; text-overflow: ellipsis; box-shadow: 1px 0 0 var(--line); }
.egrid td:last-child, .egrid th:last-child { padding-right: 16px; }
.egrid-ic { width: 15px; height: 15px; vertical-align: -3px; margin-right: 5px; image-rendering: pixelated; }
.egrid .ph { text-align: center; vertical-align: bottom; font-weight: 600; min-width: 64px; max-width: 92px; overflow: hidden; }
.egrid .ph b { display: block; overflow: hidden; text-overflow: ellipsis; }
.egrid .ph .globe-art { display: block; margin: 0 auto 4px; }
.egrid small { display: block; color: var(--muted); font-size: 10.5px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.egrid tr.sec th, .egrid tr.sec td { background: var(--seg-on); color: var(--muted); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding-top: 7px; padding-bottom: 7px; }
.egrid tr.sec th.lab { color: var(--accent); font-size: 12px; }
.egrid tr.sub th, .egrid tr.sub td { color: var(--muted); font-size: 11px; padding-top: 9px; padding-bottom: 3px; border-bottom: 0; }
.egrid td.cur, .egrid th.ph.cur { background: var(--accent-soft); }
.egrid tr.sec td.cur { color: var(--ink); }
.egrid .tot { border-left: 1px solid var(--line); font-weight: 700; }
.egrid .fly { color: var(--muted); }
.egrid .zero { color: var(--faint); }
.egrid .up { color: var(--good); }
.egrid .neg b { color: var(--bad); }
.egrid .full b { color: var(--warn); }
.egrid [data-act], .kv > div[data-act] { cursor: pointer; }
