/* Retro-flavoured but flat: early-2000s fonts and link styling, no bevels, generous whitespace.
   Palette still comes from the game: space #000020, Milky Way #000060, console orange and green, amber caption text. */
:root {
  --space: #000020; --milky: #000060; --hud-orange: #f08000; --amber: #ffd17b;
  color-scheme: light;
  --bg: #eef1f6; --page: #ffffff; --fg: #1a1a22; --muted: #55586a; --line: #c4c9d6; --accent: #a04000; --link: #0000cc; --visited: #660099; --heading: #000060;
  --code: #f0f2f7; --panel: #f3f5f9; --hi: #ffffff; --lo: #404040; --mid: #9aa0b4;
  --note-bg: #eaf5ea; --note-line: #1f7a3c; --remake-bg: #e6e8fa; --remake-line: #2b3fd0; --warn-bg: #fff0d8; --warn-line: #c25a00;
  --title-a: #000080; --title-b: #1084d0; --title-fg: #ffffff; --on-accent: #fff; --stars: 0;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000020; --page: #0a0a3a; --fg: #dcdcdc; --muted: #9a9ab8; --line: #3a3a78; --accent: #ffa43c; --link: #6ab0ff; --visited: #c49aff; --heading: #ffd17b;
  --code: #14143c; --panel: #10104a; --hi: #6a6a80; --lo: #000010; --mid: #6a6a98;
  --note-bg: #04200f; --note-line: #00c040; --remake-bg: #000050; --remake-line: #7f9bff; --warn-bg: #2a1400; --warn-line: #f08000;
  --title-a: #000060; --title-b: #3a3a90; --title-fg: #ffd17b; --on-accent: #000020; --stars: 1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000020; --page: #0a0a3a; --fg: #dcdcdc; --muted: #9a9ab8; --line: #3a3a78; --accent: #ffa43c; --link: #6ab0ff; --visited: #c49aff; --heading: #ffd17b;
    --code: #14143c; --panel: #10104a; --hi: #6a6a80; --lo: #000010; --mid: #6a6a98;
    --note-bg: #04200f; --note-line: #00c040; --remake-bg: #000050; --remake-line: #7f9bff; --warn-bg: #2a1400; --warn-line: #f08000;
    --title-a: #000060; --title-b: #3a3a90; --title-fg: #ffd17b; --on-accent: #000020; --stars: 1;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 56px; }
body { background: var(--bg); color: var(--fg); font: 14px/1.6 Verdana, Tahoma, Geneva, "DejaVu Sans", sans-serif; margin: 0; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: url(img/stars.svg) 0 0 / 320px 320px; opacity: calc(var(--stars) * .6); image-rendering: pixelated; }
a { color: var(--link); }
a:visited { color: var(--visited); }
a:hover { color: var(--accent); }

.site-nav {
  position: sticky; top: 0; z-index: 20; background: var(--space); border-bottom: 2px solid var(--hud-orange);
  display: flex; flex-wrap: wrap; gap: 2px 14px; align-items: center; padding: 7px 24px; font-size: 13px;
}
.site-nav .brand { font-weight: 700; font-size: 15px; color: var(--amber); margin-right: auto; text-decoration: none; font-family: "Trebuchet MS", Verdana, sans-serif; }
.site-nav a, .site-nav a:visited { color: #9cc8ff; }
.site-nav a:hover { color: #fff; }
.site-nav a[aria-current] { color: var(--amber); font-weight: 700; }
.site-nav .brand, .site-nav .brand:visited { color: var(--amber); }
.site-nav a:focus-visible, .theme-toggle:focus-visible { outline: 1px dotted #fff; outline-offset: 2px; }
.theme-toggle { font: inherit; color: #9cc8ff; background: transparent; border: 1px solid #4a5a9a; border-radius: 3px; padding: 2px 6px; cursor: pointer; display: inline-flex; line-height: 0; }
.theme-toggle:hover { border-color: #fff; color: #fff; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: inline; }
}

.hero { max-width: 1060px; box-sizing: content-box; margin: 0 auto; padding: 44px 32px 0; }
.hero h1 { margin: 0; font: 700 30px/1.25 "Trebuchet MS", Verdana, sans-serif; color: var(--heading); }
.hero .lede { margin: 12px 0 0; max-width: 46em; font-size: 15px; color: var(--muted); }

.layout { display: grid; grid-template-columns: 220px minmax(0, 52em); gap: 48px; justify-content: start; max-width: 1060px; box-sizing: content-box; margin: 28px auto 0; padding: 0 32px 64px; align-items: start; }
.toc { position: sticky; top: 56px; max-height: calc(100vh - 80px); overflow-y: auto; font-size: 12.5px; line-height: 1.5; padding: 4px 4px 12px 0; color: var(--fg); }
.toc h2 { font: 700 15px "Trebuchet MS", Verdana, sans-serif; color: var(--heading); margin: 0 0 12px; padding: 0 0 6px; border-bottom: 1px solid var(--line); }
.toc ol, .toc ul { list-style: none; margin: 0; padding: 0; }
.toc ol > li { margin: 10px 0 0; }
.toc ol > li > a { font-weight: 700; }
.toc ul { margin: 3px 0 4px 12px; padding-left: 0; }
.toc ul li { margin: 5px 0; }
.toc ul li::before { content: "\25AA\00a0"; color: var(--mid); }
.toc a.active { color: var(--accent); font-weight: 700; text-decoration: none; }
.toc-mobile { display: none; }
main { min-width: 0; background: var(--page); border: 1px solid var(--line); padding: 36px 52px 40px; }

h1 { font: 700 26px/1.3 "Trebuchet MS", Verdana, sans-serif; margin: 0 0 10px; color: var(--heading); }
.lede { margin: 0 0 16px; }
h2, h3, h4 { color: var(--heading); font-family: "Trebuchet MS", Verdana, sans-serif; }
h2 { font-size: 22px; margin: 56px 0 14px; padding: 0 0 6px; border-bottom: 2px solid var(--line); line-height: 1.3; }
h2 .num { margin-right: 6px; }
h2 .num::after { content: "."; }
h3 { font-size: 17px; margin: 34px 0 8px; line-height: 1.3; }
h4 { font-size: 14px; margin: 22px 0 4px; }
h2 a.anchor, h3 a.anchor { color: inherit; text-decoration: none; margin-left: 6px; font-weight: 400; opacity: 0; font-size: .8em; }
h2:hover a.anchor, h3:hover a.anchor { opacity: 1; }
.totop { margin: 40px 0 0; font-size: 12px; text-align: right; }
p { margin: 0 0 14px; }
ul, ol { padding-left: 26px; margin: 0 0 14px; }
ul { list-style: square; }
li { margin: 2px 0; }
code, kbd { font-family: "Courier New", Courier, monospace; font-size: 1.05em; }
code { background: var(--code); padding: 1px 4px; border-radius: 2px; overflow-wrap: anywhere; }
kbd { background: var(--panel); color: var(--fg); border: 1px solid var(--mid); border-radius: 3px; padding: 0 5px; white-space: nowrap; font-size: 1em; }
a.term { text-decoration: underline dotted; color: inherit; }
a.term:hover { color: var(--accent); }

figure { margin: 22px 0; }
figure img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); background: #000; }
figure.small img { max-width: 560px; }
figure.strip img { image-rendering: pixelated; }
figcaption { font-size: 12px; color: var(--muted); margin-top: 6px; font-style: italic; }
.figrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.figrow figure { margin: 8px 0; }

.note, .remake, .warn { border: 1px solid var(--note-line); border-left-width: 4px; background: var(--note-bg); padding: 12px 18px 4px; margin: 24px 0; }
.note::before, .remake::before, .warn::before { display: block; font: 700 12px "Trebuchet MS", Verdana, sans-serif; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 6px; color: var(--note-line); }
.remake { border-color: var(--remake-line); background: var(--remake-bg); }
.warn { border-color: var(--warn-line); background: var(--warn-bg); }
.remake::before { content: "In this remake"; color: var(--remake-line); }
.note::before { content: "Note"; }
.warn::before { content: "Careful!"; color: var(--warn-line); }
.note > :first-child, .remake > :first-child, .warn > :first-child { margin-top: 0; }
.note > :last-child, .remake > :last-child, .warn > :last-child { margin-bottom: 0; }

.table-wrap { overflow-x: auto; margin: 20px 0; }
table { border-collapse: collapse; width: 100%; font-size: 13px; border: 1px solid var(--line); }
th, td { border: 1px solid var(--line); padding: 7px 12px; text-align: left; vertical-align: top; }
th { background: var(--panel); color: var(--heading); }
tr:nth-child(even) td { background: var(--panel); }
td.n, th.n { text-align: right; }
table.ships td img { display: block; width: 120px; height: auto; background: #000; border: 1px solid var(--line); }
table.ships td:first-child, table.ships th:first-child { width: 128px; }
table.ships td.name { font-weight: 700; }
caption { text-align: left; font-size: 12px; color: var(--muted); padding-bottom: 3px; }

.steps { counter-reset: step; list-style: none; padding-left: 0; }
.steps > li { counter-increment: step; position: relative; padding-left: 34px; margin: 10px 0; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-weight: 700; text-align: center; line-height: 22px; font-size: 12px; }
/* quick-link boxes: a plain bulleted list */
.cards { margin: 18px 0 8px; padding-left: 26px; }
.card { display: list-item; list-style: square; margin: 7px 0; }
.card h3, .card h4 { display: inline; margin: 0; font-size: 14px; border: 0; }
.card h4 a { font-weight: 700; }
.card p { display: inline; margin: 0; }
.card p::before { content: " \2013  "; }
dl.glossary dt { font-weight: 700; margin-top: 20px; scroll-margin-top: 44px; }
dl.glossary dt:target { background: var(--note-bg); border-left: 3px solid var(--accent); padding: 2px 8px; margin-left: -11px; }
dl.glossary dd { margin: 4px 0 0 20px; }
.pagenav { display: flex; justify-content: space-between; gap: 12px; margin: 40px 0 0; font-size: 13px; }
footer { border-top: 1px solid var(--line); margin-top: 48px; padding-top: 16px; color: var(--muted); font-size: 12px; text-align: center; }
footer .updated { font-weight: 700; }

@media (max-width: 1000px) {
  .site-nav { position: static; padding: 7px 16px; }
  .hero { padding: 28px 16px 0; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; margin-top: 18px; padding: 0 0 40px; }
  .toc { display: none; }
  .toc-mobile { display: block; border: 1px solid var(--line); background: var(--panel); margin: 0 0 22px; padding: 8px 14px; }
  .toc-mobile summary { cursor: pointer; font-weight: 700; }
  .toc-mobile ol, .toc-mobile ul { list-style: none; padding-left: 0; margin: 8px 0; }
  .toc-mobile li { margin: 4px 0; }
  .toc-mobile ul { padding-left: 14px; font-size: 13px; }
  main { padding: 22px 18px 28px; border-width: 1px 0; }
  h2 { font-size: 20px; margin-top: 44px; }
  h1, .hero h1 { font-size: 23px; }
  figure.small img { max-width: 100%; }
  html { scroll-padding-top: 8px; }
}
@media print {
  :root, :root:not([data-theme="light"]), :root[data-theme="dark"] { --bg: #fff; --page: #fff; --fg: #000; --muted: #444; --line: #bbb; --accent: #000; --link: #000; --visited: #000; --heading: #000; --code: #eee; --panel: #f4f4f4; --note-bg: #f4f4f4; --note-line: #555; --remake-bg: #f4f4f4; --remake-line: #555; --warn-bg: #f4f4f4; --warn-line: #555; --title-a: #fff; --title-b: #fff; --title-fg: #000; --on-accent: #fff; --stars: 0; color-scheme: light; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  body::before { display: none; }
  .site-nav, .toc, .toc-mobile, .pagenav, .totop, h2 a.anchor, h3 a.anchor { display: none !important; }
  .hero { max-width: none; margin: 0; padding: 0; }
  .hero-in { border: 0; background: none; padding: 0 0 8pt; }
  .hero h1 { background: none; color: #000; padding: 0; }
  .hero .lede { border: 0; padding: 0; color: #444; background: none; }
  .layout { display: block; padding: 0; max-width: none; }
  main { border: 0; padding: 0; }
  h2 { background: none; color: #000; margin: 24pt 0 6pt; padding: 0; border-bottom: 1px solid #000; break-after: avoid; }
  h3 { break-after: avoid; }
  figure, table tr, .card, .note, .remake, .warn { break-inside: avoid; }
  figure img { max-width: 85%; }
  .note::before, .remake::before, .warn::before { background: none; color: #000; }
  a { color: inherit; text-decoration: none; }
  a.term { text-decoration: none; }
  .table-wrap { overflow: visible; }
}
