:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --border: #dde1e7;
  --text: #1d232b;
  --muted: #6a7482;
  --accent: #2f6fdb;
  --accent-2: #e8793a;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --err: #c93434;
  --pc-line: rgba(47, 111, 219, .14);
  --fault-line: rgba(201, 52, 52, .16);
  --m-pc: rgba(47, 111, 219, .25);
  --m-s: rgba(232, 121, 58, .28);
  --m-u: rgba(31, 138, 76, .25);
  --m-w: rgba(183, 121, 31, .35);
  --syn-kw: #7a3fc4;
  --syn-dir: #b0357a;
  --syn-reg: #1f6f8b;
  --syn-num: #a0521d;
  --syn-str: #2d7d32;
  --syn-lbl: #2f6fdb;
  --syn-cmt: #8a94a3;
  --blk-0: hsl(212 80% 55% / .20);
  --blk-1: hsl(28 90% 55% / .22);
  --blk-2: hsl(145 60% 42% / .20);
  --blk-3: hsl(275 60% 60% / .20);
  --blk-4: hsl(48 95% 50% / .26);
  --blk-5: hsl(330 70% 60% / .20);
  --blk-6: hsl(185 70% 42% / .22);
  --blk-7: hsl(90 60% 45% / .22);
  --blk-sys: hsl(220 10% 50% / .16);
  /* actions of bases and rockets (progress bars, on the map and in the panel) */
  --task-mining: #3fbf6f;
  --task-manufacturing: #4a8dff;
  --task-building: #f0a030;
  --task-upgrading: #b77cff;
  --task-reloading: #ff5a5a;
  --task-docking: #9aa8c8;
  --task-transfer: #2fc6c6;
  /* items */
  --item-mineral: hsl(28 45% 52%);
  --item-laser: hsl(0 75% 58%);
  --item-booster: hsl(205 80% 55%);
  /* memory map regions */
  --mm-vec: hsl(0 75% 60% / .30);
  --mm-cfg: hsl(28 90% 55% / .30);
  --mm-data: hsl(48 95% 50% / .34);
  --mm-reserved: hsl(220 10% 50% / .22);
  --mm-msg: hsl(330 70% 60% / .28);
  --mm-prog: hsl(145 60% 45% / .30);
  --mm-free: transparent;
  --mm-ustack: hsl(185 70% 45% / .32);
  --mm-sstack: hsl(265 65% 62% / .32);
  --mm-bank: hsl(220 30% 55% / .14);
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --paper: #ffffff;
  --ink: #000000;
  --desk: #d6d8db;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #3b3f45;
    --bg: #111418;
    --panel: #181c22;
    --panel-2: #1f242b;
    --border: #2b323b;
    --text: #d9dee5;
    --muted: #8591a0;
    --accent: #5b9bff;
    --accent-2: #f08c4f;
    --ok: #4cc47f;
    --warn: #e0b04f;
    --err: #ff6b6b;
    --pc-line: rgba(91, 155, 255, .16);
    --fault-line: rgba(255, 107, 107, .18);
    --m-pc: rgba(91, 155, 255, .35);
    --m-s: rgba(240, 140, 79, .35);
    --m-u: rgba(76, 196, 127, .3);
    --m-w: rgba(224, 176, 79, .4);
    --syn-kw: #c49bff;
    --syn-dir: #ff8ac4;
    --syn-reg: #6fd0e8;
    --syn-num: #f0b27a;
    --syn-str: #9ad48f;
    --syn-lbl: #7fb2ff;
    --syn-cmt: #6b7686;
    --blk-0: hsl(212 80% 60% / .28);
    --blk-1: hsl(28 90% 58% / .28);
    --blk-2: hsl(145 55% 50% / .26);
    --blk-3: hsl(275 60% 68% / .28);
    --blk-4: hsl(48 90% 55% / .26);
    --blk-5: hsl(330 70% 65% / .26);
    --blk-6: hsl(185 65% 50% / .26);
    --blk-7: hsl(90 55% 52% / .26);
    --blk-sys: hsl(220 10% 60% / .16);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --desk: #3b3f45;
  --bg: #111418; --panel: #181c22; --panel-2: #1f242b; --border: #2b323b; --text: #d9dee5;
  --muted: #8591a0; --accent: #5b9bff; --accent-2: #f08c4f; --ok: #4cc47f; --warn: #e0b04f;
  --err: #ff6b6b; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--sans);
  display: flex;
  flex-direction: column;
}

button, select, input { font: inherit; color: inherit; }
button, select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
input[type="text"], input:not([type]), input[type="number"], input[type="password"], input[type="search"] {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }

/* --- top bar -------------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 16px;
  height: 48px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .02em; color: var(--accent); }
.brand { color: var(--text); }
.brand svg { color: var(--accent); }
.tabs { display: flex; gap: 4px; height: 100%; }
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0 14px;
  height: 100%;
  color: var(--muted);
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.topbar-right { margin-left: auto; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 12px; }

main { flex: 1; min-height: 0; display: flex; }
.tab-page { display: none; flex: 1; min-width: 0; flex-direction: column; }
.tab-page.active { display: flex; }

/* --- badges and panels ---------------------------------------------------------------- */
.check { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.badge.running { color: var(--ok); border-color: var(--ok); }
.badge.waiting { color: var(--accent); border-color: var(--accent); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.faulted { color: var(--err); border-color: var(--err); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.panel h3 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.hint { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: .8; }
.sub-h { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.count { font-size: 11px; color: var(--err); }

/* --- programs -------------------------------------------------------------------------- */
.lang-tabs { display: flex; gap: 2px; margin: 16px 0 12px; border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none; }
.lang-tabs::-webkit-scrollbar { display: none; }
.lang-tab { background: none; border: none; border-radius: 0; border-bottom: 2px solid transparent; color: var(--muted);
  padding: 6px 12px; white-space: nowrap; flex: none; }
.lang-tab:hover { color: var(--text); }
.lang-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.lang-tab.soon { opacity: .75; }
.lang-tab .soon-tag { margin-left: 6px; font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--warn); }
.soon-panel { max-width: 720px; }
#lang-c { grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); }
.soon-panel .badge { text-transform: none; letter-spacing: 0; }
.programs-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 12px; align-items: start; }
.programs-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.programs-toolbar .grow { flex: 1; }
.programs-toolbar select { margin-left: 4px; max-width: 260px; }
.program-drop { border: 2px dashed transparent; border-radius: 8px; min-height: 80px; }
.program-drop.dragging { border-color: var(--accent); background: var(--panel-2); }
.programs-table { width: 100%; }
.programs-table .row-actions { min-width: 0; white-space: nowrap; }
.programs-table .mono { font-family: var(--mono); }
a.button { display: inline-block; padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel-2); color: var(--text); text-decoration: none; }
a.button:hover { border-color: var(--accent); text-decoration: none; }
a.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.sdk-steps { padding-left: 20px; line-height: 1.6; }
.sdk-steps li { margin-bottom: 6px; }
.sdk-steps code, [id^="sdk-panel"] code { font: 12px var(--mono); background: var(--panel-2); padding: 1px 4px; border-radius: 3px;
  word-break: break-word; }
@media (max-width: 900px) {
  .programs-grid, #lang-c { grid-template-columns: minmax(0, 1fr); }
  .programs-table th:nth-child(4), .programs-table td:nth-child(4) { display: none; }
}

/* --- manual ---------------------------------------------------------------------------- */
.manual-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
/* the sidebar is a sheet of the same paper: serif text, bold sans headings, black rules */
.manual-toc {
  border-right: 2.5px solid var(--ink);
  overflow-y: auto;
  padding: 18px 16px;
  font: 14.5px/1.35 var(--paper-serif);
  background: var(--paper);
  color: var(--ink);
  color-scheme: light;
}
.toc-title { font: bold 20px var(--paper-sans); margin: 0 0 10px; padding-bottom: 4px; border-bottom: 2.5px solid var(--ink); }
.manual-toc input { width: 100%; margin-bottom: 12px; background: var(--paper); color: var(--ink); border: 1px solid var(--ink);
  border-radius: 0; padding: 4px 8px; font: 14px var(--paper-serif); }
.manual-toc input::placeholder { color: #666; font-style: italic; }
.manual-toc a { display: block; color: var(--ink); text-decoration: none; padding: 1px 4px; }
.manual-toc a:hover { text-decoration: underline; }
.manual-toc a.h3 { padding-left: 18px; }
.toc-chapter { margin-top: 6px; }
.toc-chapter summary { display: flex; align-items: baseline; cursor: pointer; list-style: none; }
.toc-chapter summary::-webkit-details-marker { display: none; }
.toc-chapter summary::before { content: "▸"; width: 14px; flex: none; font-size: 11px; text-align: center; }
.toc-chapter[open] summary::before { content: "▾"; }
.toc-chapter summary a { flex: 1; font: bold 14px var(--paper-sans); }
/* the manual as sheets of paper, laid out like the Motorola 6809 programmer's reference:
   black on white, nothing else; links are underlined with dots, code sits in a black frame, and
   only code has colors (red and blue, at full strength) */
.manual { overflow-y: auto; padding: 28px 24px 80px; background: var(--paper); color: var(--ink); }
.manual-layout, .tut-layout {
  --paper-serif: "Times New Roman", Times, "Liberation Serif", "Nimbus Roman", serif;
  --paper-sans: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
  --paper-mono: "Courier New", Courier, "Liberation Mono", "Nimbus Mono PS", monospace;
  --code-red: #e00000;     /* constants, numbers, strings, preprocessor */
  --code-blue: #0000f0;    /* keywords, types, the game's functions */
}
.sheet {
  position: relative; width: min(816px, 100%); min-height: 1000px; margin: 0 auto 28px; padding: 64px 72px 96px;
  background: var(--paper); color: var(--ink); border: 1px solid var(--ink);
  font: 16px/1.42 var(--paper-serif); text-align: justify; hyphens: auto; color-scheme: light;
}
.sheet-foot { position: absolute; left: 72px; right: 72px; bottom: 36px; padding-top: 4px; border-top: 2.5px solid var(--ink);
  font: bold 13px var(--paper-sans); text-align: center; }
.sheet h1, .sheet h2, .sheet h3, .sheet h4 { font-family: var(--paper-sans); font-weight: bold; color: var(--ink);
  text-align: left; hyphens: manual; scroll-margin-top: 12px; }
.sheet h1 { font-size: 32px; line-height: 1.15; margin: 0 0 24px; }
.sheet.cover { display: flex; flex-direction: column; justify-content: space-between; min-height: 1056px; }
.sheet.cover h1 { font-size: 40px; margin: 0; }
.cover-foot { font: 15px var(--paper-serif); margin: 0; }
.sheet h2 { font-size: 34px; line-height: 1.15; margin: 0 0 28px; padding-bottom: 8px; border-bottom: 2.5px solid var(--ink); }
.sheet h2[data-num]::before { content: attr(data-num) "\2002"; }
.sheet h3 { font-size: 22px; margin: 34px 0 10px; }
.sheet h3[data-num]::before { content: attr(data-num) "\2002"; font-size: .8em; }
.sheet h2 + h3, .sheet h2 + p + h3 { margin-top: 18px; }
.sheet h4 { font-size: 17px; margin: 22px 0 6px; }
.sheet p { margin: 0 0 12px; }
.sheet ul, .sheet ol { margin: 0 0 12px; padding-left: 28px; }
.sheet li { margin-bottom: 3px; }
.sheet img { display: block; max-width: 100%; height: auto; margin: 14px auto 18px; }
.sheet blockquote { margin: 8px 0 14px; padding: 6px 14px; border-left: 4px solid var(--ink); }
.sheet blockquote.warn { border: 2.5px solid var(--ink); }
.sheet blockquote p:last-child { margin-bottom: 0; }
.sheet a { color: inherit; text-decoration: underline dotted 1px; text-underline-offset: 2px; }
.sheet a:hover { text-decoration-style: solid; }
.sheet strong, .sheet b { font-weight: bold; }
/* code: inline in black Courier, blocks in a black frame; the colors are the code's alone */
.sheet code { font: 14.5px var(--paper-mono); color: var(--ink); }
.sheet pre { margin: 6px 0 14px; padding: 8px 12px; border: 1.5px solid var(--ink); background: var(--paper);
  font: 13.5px/1.38 var(--paper-mono); text-align: left; overflow-x: auto; }
.sheet pre code { font: inherit; color: var(--ink); }
.tok-com { font-style: italic; }
.tok-kw { color: var(--code-blue); font-weight: bold; }
.tok-type { color: var(--code-blue); }
.tok-api { color: var(--code-blue); font-weight: bold; }
.tok-str, .tok-num, .tok-const, .tok-pre { color: var(--code-red); }
/* tables: black rules, a bold sans header over a double-weight line, serif cells */
.sheet table { border-collapse: collapse; margin: 6px 0 16px; font: 14.5px/1.3 var(--paper-serif); text-align: left; }
.sheet th, .sheet td { border: 1px solid var(--ink); padding: 3px 8px; vertical-align: top; }
.sheet thead th, .sheet table:not(:has(thead)) tr:first-child th { font: bold 12.5px/1.2 var(--paper-sans);
  text-transform: uppercase; border-bottom: 2.5px solid var(--ink); vertical-align: bottom; }
.sheet th { background: none; }
/* the contents sheet */
.contents-title { font: bold 34px/1.15 var(--paper-sans); margin: 0 0 22px; padding-bottom: 8px; border-bottom: 2.5px solid var(--ink); }
.contents-chapter { margin: 0 0 11px; text-align: left; }
.sheet .contents-name { display: block; font: bold 16px var(--paper-sans); text-decoration: none; color: var(--ink); white-space: pre; }
.sheet .contents-sections a { font: 13px/1.5 var(--paper-sans); color: var(--ink); margin-right: 12px; white-space: nowrap; display: inline-block; }
.contents-sections { padding-left: 24px; }
/* cheat sheets: one landscape page each, three columns of small print */
.sheet.cheat { width: min(1056px, 100%); min-height: 816px; padding: 36px 44px 64px; font-size: 12px; line-height: 1.3; text-align: left; }
.sheet.cheat .sheet-foot { left: 44px; right: 44px; bottom: 22px; }
.sheet.cheat h2 { font-size: 26px; margin-bottom: 14px; padding-bottom: 5px; }
.sheet.cheat .cheat-body { columns: 3 300px; column-gap: 26px; column-rule: 1px solid var(--ink); }
.sheet.cheat h4 { font-size: 13px; margin: 12px 0 4px; padding-bottom: 2px; border-bottom: 1.5px solid var(--ink);
  text-transform: uppercase; letter-spacing: .04em; break-after: avoid; }
.sheet.cheat .cheat-body > :first-child { margin-top: 0; }
.cheat-cont { margin: 0 0 14px; padding-bottom: 5px; border-bottom: 2.5px solid var(--ink); font: bold 15px var(--paper-sans); }
.sheet.cheat p { margin: 0 0 6px; }
.sheet.cheat ul, .sheet.cheat ol { margin: 0 0 6px; padding-left: 18px; }
.sheet.cheat li { margin-bottom: 1px; }
.sheet.cheat code { font-size: 11px; }
.sheet.cheat pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 3px 0 7px; padding: 4px 7px; font-size: 10.5px; line-height: 1.3; break-inside: avoid; }
.sheet.cheat table { width: 100%; margin: 3px 0 7px; font-size: 12px; line-height: 1.25; break-inside: avoid; }
.sheet.cheat th, .sheet.cheat td { padding: 1px 4px; }
.sheet.cheat thead th { font-size: 10.5px; }
.manual-note-btn { margin-left: 8px; padding: 0 6px; font: 12px var(--mono); line-height: 18px; vertical-align: middle;
  color: var(--muted); background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
.manual-note-btn:hover, .manual-note-btn.active { color: var(--accent); border-color: var(--accent); }
.manual-note { margin: 4px 0 12px; font-family: var(--sans, inherit); line-height: 1.4; }
.manual .flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { outline: 3px solid var(--ink); outline-offset: 3px; } 100% { outline: 3px solid transparent; outline-offset: 3px; } }

/* --- map placeholder ------------------------------------------------------------------- */

/* --- narrow screens -------------------------------------------------------------------- */
@media (max-width: 980px) {
  .manual-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .manual-toc { border-right: none; border-bottom: 2.5px solid var(--ink); max-height: 34vh; }
  .manual { padding: 16px 12px; }
  .topbar { gap: 12px; }
}

/* --- shared bits ---------------------------------------------------------------------- */
.strong { font-weight: 600; }
button.danger { background: var(--err); border-color: var(--err); color: #fff; }
.head-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.info-card + .info-card { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.pin-btn.active { background: var(--accent); border-color: var(--accent); }
button.admin-delete { font-size: 11px; line-height: 20px; padding: 0 6px; background: none;
  border: 1px solid var(--err); }
button.admin-delete:hover { background: color-mix(in srgb, var(--err) 12%, transparent); }
.danger-text { color: var(--err); }
button.wide { width: 100%; padding: 8px 12px; }
#toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, .2); z-index: 50; max-width: 90vw;
}
#toast.error { color: var(--err); }
.form-error { color: var(--err); font-size: 13px; min-height: 18px; margin: 4px 0; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 13px; }
.field > span { color: var(--muted); }
.field input { padding: 7px 10px; border-radius: 6px; }
.pill { font-size: 11px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--border); color: var(--muted); }
.pill-accent { color: var(--accent); border-color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); display: inline-block; }
.note { background: var(--panel-2); border-left: 3px solid var(--warn); padding: 6px 8px; margin: 6px 0; border-radius: 4px; }
.icon-btn { padding: 0 7px; line-height: 22px; }

/* dialogs */
dialog.modal {
  border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; width: min(420px, calc(100vw - 32px));
  background: var(--panel); color: var(--text); box-shadow: 0 16px 48px rgba(0, 0, 0, .35);
}
dialog.modal::backdrop { background: rgba(5, 8, 14, .55); }
dialog.modal h3 { margin: 0 0 6px; font-size: 16px; }
dialog.modal p { margin: 0 0 8px; font-size: 13px; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* --- user menu ------------------------------------------------------------------------ */
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; background: none; border-color: transparent; padding: 3px 8px; color: var(--text); font-size: 13px; }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.caret { color: var(--muted); font-size: 10px; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; z-index: 30;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); display: flex; flex-direction: column;
}
.dropdown-head { padding: 6px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; color: var(--text); font-size: 13px; }
.dropdown button { background: none; border: none; text-align: left; padding: 7px 10px; border-radius: 5px; font-size: 13px; }
.dropdown button:hover { background: var(--panel-2); }
.dropdown hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }

/* --- login ---------------------------------------------------------------------------- */
body.login-page { align-items: center; justify-content: center; background: #05070c; }
#stars { position: fixed; inset: 0; width: 100%; height: 100%; }
.login-card {
  position: relative; width: min(380px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px 24px 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); flex: none; display: block;
}
.login-brand { font-size: 22px; }
.login-card h2 { font-size: 17px; margin: 14px 0 4px; }
.login-card p { margin: 6px 0; }
.switch-row { text-align: center; margin-top: 12px !important; }
a { color: var(--accent); }

/* --- world map ------------------------------------------------------------------------ */
.map-layout { flex: 1; display: flex; min-height: 0; }
.map-view { position: relative; flex: 1; min-width: 0; overflow: hidden; background: #05070c; }
#map-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#map-canvas.dragging { cursor: grabbing; }
.map-controls { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.map-controls button, .map-controls .check {
  background: rgba(20, 26, 38, .85); border: 1px solid rgba(160, 180, 255, .25); color: #dfe6ff; border-radius: 6px;
  padding: 3px 9px; font-size: 12px;
}
.map-controls .check { color: #b9c3e0; }
.map-hover {
  position: absolute; pointer-events: none; background: rgba(20, 26, 38, .92); color: #e6ecff;
  border: 1px solid rgba(160, 180, 255, .3); border-radius: 5px; padding: 2px 8px; font-size: 12px; white-space: nowrap;
}
.map-status { position: absolute; bottom: 8px; left: 10px; color: #8d99bb; font-family: var(--mono); pointer-events: none; }
.map-resize { width: 6px; flex-shrink: 0; cursor: col-resize; background: var(--border); opacity: .5; touch-action: none; }
.map-resize:hover, .map-resize.active { background: var(--accent); opacity: 1; }
.map-side { width: 340px; flex-shrink: 0; overflow-y: auto; padding: 12px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.info-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.info-head h3 { margin: 0 0 6px; }
.info-head .base-name { text-transform: none; letter-spacing: normal; color: var(--text); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 6px 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { font-size: 12px; padding: 1px 8px; border: 1px solid var(--border); border-radius: 10px; text-decoration: none; }
.chip:hover { border-color: var(--accent); }
.base-switch { width: 100%; margin: 2px 0 4px; }
.base-pick { display: flex; gap: 6px; }
.base-pick select { flex: 1; min-width: 0; }
.base-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.base-log { max-height: 180px; overflow-y: auto; font-family: var(--mono); font-size: 11.5px; background: var(--panel-2); border-radius: 4px; padding: 4px 6px; }
.log-row { display: flex; gap: 8px; }
.log-row span:first-child { flex-shrink: 0; }

/* --- leaderboard and admin ------------------------------------------------------------ */
.page-narrow { width: min(720px, 100%); margin: 0 auto; padding: 24px 16px; overflow-y: auto; }
.page-wide { width: 100%; max-width: 1280px; margin: 0 auto; padding: 16px; overflow-y: auto; }
.page-narrow h2 { margin: 0 0 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
.table th { white-space: nowrap; text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; border-bottom: 1px solid var(--border); padding: 6px 8px; }
.table td { border-bottom: 1px solid var(--border); padding: 6px 8px; vertical-align: middle; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.me td { background: var(--pc-line); }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.admin-settings { grid-column: 1 / -1; }
.inline-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inline-form input:not([type="checkbox"]) { width: 150px; }
/* a table cell of buttons: it stays a table cell (display: flex would take it out of the row) */
.row-actions { text-align: right; }   /* the buttons wrap when the table is narrow */
.row-actions > * { margin: 2px 0 2px 4px; vertical-align: middle; }
.row-actions button { font-size: 12px; padding: 2px 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.stat { background: var(--panel-2); border-radius: 6px; padding: 6px 10px; }
.danger-zone { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-top: 14px; padding: 10px; border: 1px solid var(--err); border-radius: 8px; }
.danger-zone button { flex-shrink: 0; }
.settings-group { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 12px; padding: 8px 12px 12px; }
.settings-group legend { padding: 0 6px; font-weight: 600; font-size: 13px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px 16px; }
.setting { display: flex; flex-direction: column; gap: 3px; font-size: 13px; padding: 4px 6px; border-radius: 6px; }
.setting.changed { background: var(--m-w); }
.setting-top { display: flex; justify-content: space-between; gap: 8px; }
.setting input[type="number"] { width: 100%; }
.setting input[type="checkbox"] { align-self: flex-start; }
.setting select { width: 100%; }
.applies { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.applies-reset { color: var(--warn); }
.settings-buttons { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 900px) {
  .admin-grid { grid-template-columns: 1fr; }
  .map-layout { flex-direction: column; }
  .map-resize { display: none; }
  .map-side { width: auto !important; border-left: none; border-top: 1px solid var(--border); max-height: 45vh; }
  .map-view { min-height: 50vh; }
  .table { display: block; overflow-x: auto; }
}

/* --- base panel: actions, inventory, production --- */
.task { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.task-bar { height: 6px; border-radius: 3px; background: var(--panel-2); border: 1px solid var(--border); overflow: hidden; }
.task-fill { height: 100%; }
.inv-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; margin: 4px 0; }
.slot {
  aspect-ratio: 1; border: 1px dashed var(--border); border-radius: 4px;
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,.4); user-select: none;
}
.slot[class*="item-"] { border-style: solid; border-color: rgba(0,0,0,.25); }
.slot.item-mineral { background: var(--item-mineral); }
.slot.item-laser { background: var(--item-laser); }
.slot.item-booster { background: var(--item-booster); }
.slot.locked { outline: 2px solid var(--lock, var(--accent)); outline-offset: 1px; }
.slot.locked:not([class*="item-"]) {   /* an empty slot waiting for the result */
  border-style: solid; border-color: transparent;
  background: repeating-linear-gradient(135deg, transparent 0 4px, var(--panel-2) 4px 8px);
}
.slot.locked::after { content: "🔒"; position: absolute; font-size: 8px; transform: translate(9px, -9px); }
.slot { position: relative; }
.slot.reloading { opacity: .7; }
.slot-reload {   /* a laser reloading: its bar fills up along the slot's bottom edge */
  position: absolute; left: 2px; right: 2px; bottom: 2px; height: 3px;
  border-radius: 2px; background: rgba(0,0,0,.45); overflow: hidden;
}

/* only the info column gives way on a narrow panel: cut with "…" (the full text is its tooltip) */
.mem-map td.info { max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; }
.mem-map td.addr { font-family: var(--mono); white-space: nowrap; }
.mem-map td.sw { width: 10px; padding: 0; }
.mem-map tr { cursor: pointer; }
.mem-map tr:hover td { background: var(--panel-2); }
.mem-map tr.mm-sub td:nth-child(3) { padding-left: 18px; }
.mem-map tr.mm-func td:nth-child(3) { padding-left: 4px; font-weight: 600; }
.mem-map tr.mm-child td:nth-child(3) { padding-left: 32px; }
.mm-arrow { display: inline-block; width: 14px; text-align: center; color: var(--muted); }
.mm-arrow:hover { color: var(--text); }

/* --- map: asset menu --- */
.split-btn { position: relative; display: inline-flex; }
.split-btn #map-home { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split-btn #map-assets-btn { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: none; padding: 3px 6px; }
.asset-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; width: 320px; max-width: calc(100vw - 32px);
  max-height: 60vh; overflow-y: auto; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.35); padding: 6px;
}
.asset-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 4px 6px; font-weight: 600; font-size: 13px; }
.asset-head select { font-size: 12px; }
.asset-list { display: flex; flex-direction: column; gap: 2px; }
.map-controls .asset-menu button.asset {
  display: flex; align-items: center; gap: 8px; text-align: left; width: 100%;
  background: none; border: 1px solid transparent; border-radius: 6px; padding: 5px 6px; color: inherit; cursor: pointer;
}
.map-controls .asset-menu button.asset:hover { background: var(--panel-2); border-color: var(--border); }
.asset-icon { color: var(--accent-2); width: 14px; text-align: center; }
.asset-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.asset-text > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-text > span + span { overflow-wrap: anywhere; }
.asset-task { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* --- DEV tab --- */
.dev-page { width: min(900px, 100%); }
.dev-page .panel { margin-bottom: 12px; }
.dev-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0; flex-wrap: wrap; }
.dev-abort { border-collapse: collapse; margin: 4px 0 8px; }
.dev-abort td { padding: 2px 12px 2px 0; vertical-align: top; }
.dev-item { padding: 8px 0; border-top: 1px solid var(--border); }
.dev-item:first-of-type { border-top: none; }
.dev-item-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.dev-note { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.dev-note textarea { width: 100%; resize: vertical; font: inherit; font-size: 14px; line-height: 1.45; padding: 6px 8px;
  min-height: calc(2 * 1.45em + 14px); overflow-y: auto;
  border: 1px solid var(--border); border-radius: 5px; background: var(--panel-2); color: var(--text); }
.pill-ok { color: var(--ok); border-color: var(--ok); }
.pill-warn { color: var(--warn); border-color: var(--warn); }
.pill-err { color: var(--err); border-color: var(--err); }

/* --- map: flags and beacons --- */
.flags { margin: 6px 0; }
details.flags { display: block; }   /* each view on its own line */
.flags summary { cursor: pointer; color: var(--muted); }
.log-details > summary { cursor: pointer; }
.flag-row { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin: 4px 0; }
.flag-title { font-family: var(--mono); min-width: 74px; }
.flag { font-family: var(--mono); font-size: 11px; padding: 0 5px; border-radius: 3px; border: 1px solid var(--border); color: var(--muted); }
.flag.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.flag.unused { opacity: .45; }
#beacon-panel h3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#beacon-filter { font-size: 12px; max-width: 60%; text-transform: none; letter-spacing: 0; }
.beacon-log { max-height: 260px; overflow-y: auto; }
.beacon-row { display: grid; grid-template-columns: auto auto 1fr; gap: 6px; }
.beacon-row a { white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.beacon-row.game span:last-child { color: var(--err); }

.dev-history { margin-top: 4px; }
.dev-history summary { cursor: pointer; }
.dev-history-row { border-left: 2px solid var(--border); padding: 2px 0 2px 8px; margin: 4px 0; }
.dev-history-text { white-space: pre-wrap; font-size: 13px; }
.dev-decisions { width: 100%; border-collapse: collapse; font-size: 13px; }
.dev-decisions th { text-align: left; color: var(--muted); font-weight: normal; border-bottom: 1px solid var(--border); padding: 4px 6px; }
.dev-decisions td { border-bottom: 1px solid var(--border); padding: 4px 6px; vertical-align: top; }
.dev-decisions .nowrap { white-space: nowrap; }

/* --- phones ---------------------------------------------------------------------------- */
.toc-toggle { display: none; background: var(--paper); color: var(--ink); border: 1px solid var(--ink); border-radius: 0;
  font: 14px var(--paper-serif); }
.toc-bar { display: flex; gap: 6px; }
.toc-bar input { flex: 1; min-width: 0; }
@media (max-width: 700px) {
  .topbar { gap: 6px; padding: 0 6px; }
  .brand-name, #conn, #user-name, .user-btn .caret { display: none; }
  .tabs { flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 0 10px; white-space: nowrap; flex: none; }
  .topbar-right { margin-left: 0; flex: none; }
  .user-btn { padding: 3px 4px; }
  .panel { min-width: 0; }
  .panel, .admin-grid > * { max-width: 100%; }
  .table, .manual table, .dev-decisions { display: block; overflow-x: auto; max-width: 100%; }
  .sheet { padding: 28px 16px 72px; min-height: 0 !important; margin-bottom: 16px; text-align: left; font-size: 15px; }
  .sheet.cheat { padding: 24px 12px 56px; font-size: 13px; }
  .sheet-foot { left: 16px; right: 16px; bottom: 24px; }
  .sheet h2 { font-size: 27px; }
  .sheet.cover { min-height: 70vh !important; }
  .manual code { overflow-wrap: anywhere; }
  .manual pre code { overflow-wrap: normal; }
  /* the manual's contents fold away behind a button */
  .toc-toggle { display: block; flex: none; }
  .manual-toc { max-height: none; }

  .manual-toc:not(.open) #manual-toc { display: none; }
  .manual-toc.open { max-height: 60vh; }
  .toc-bar input { margin-bottom: 0; }
  .manual-toc { padding: 8px; }
  .toc-title { display: none; }
  /* bigger touch targets */
  button, select { min-height: 34px; }
  .map-toolbar button, .map-toolbar label { min-height: 34px; }
}

/* the map catching up after it was hidden: a short blur and a loading bar */
.map-catchup { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); background: rgba(5, 7, 12, 0.35); pointer-events: none; }
.catchup-bar { width: min(220px, 50%); height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.catchup-bar span { display: block; height: 100%; width: 0; background: var(--accent); animation: catchup var(--catchup-ms, 750ms) ease-out forwards; }
@keyframes catchup { to { width: 100%; } }

/* the last instructions a computer ran (map panels) */
.recent-list { font: 12px/1.45 var(--mono); padding: 2px 0 4px; }
.recent-row { display: flex; gap: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-row .recent-addr { color: var(--muted); min-width: 5.5ch; }
.recent-row .recent-event { color: var(--accent-2); }
.recent-row.last { color: var(--accent); }

/* registers and live memory of a computer (map panels) */
.regs-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px 8px; padding: 2px 0 4px; font-size: 12px; }
.reg-cell { display: flex; justify-content: space-between; gap: 4px; }
.reg-cell .mono, .mem-dump { font-family: var(--mono); }
.mem-bar { display: flex; gap: 4px; align-items: center; margin: 2px 0 4px; }
.mem-bar input { width: 7ch; font: 12px var(--mono); }
.mem-dump { font-size: 11.5px; line-height: 1.45; overflow-x: auto; }
.mem-row { display: flex; gap: 10px; white-space: pre; }

/* map: the Ranges menu */
.range-menu { width: 260px; }
.range-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; font-size: 13px; cursor: pointer; }
.range-row .muted { margin-left: auto; }
.range-swatch { width: 14px; height: 14px; border-radius: 50%; border: 2px dashed; flex: none; }
.map-controls .split-btn #map-ranges-btn { border-radius: 6px; }

/* the Settings tab */
.visual-grid { display: grid; gap: 8px; margin: 10px 0 14px; }
.visual-row { display: grid; grid-template-columns: 90px 1fr 56px; align-items: center; gap: 10px; }
.visual-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.visual-value { text-align: right; color: var(--muted); font-family: var(--mono); }

/* the starter boost in the base panel */
.boost-bubble { display: inline-block; padding: 1px 8px; border-radius: 999px; font-weight: 600; font-size: 12px;
  color: #fff; background: hsl(var(--boost-hue, 130) 60% 38%); }

/* --- pages (slots): the Programs tab's page chips and the map's page view --- */
.page-chips { white-space: normal; }
.page-chip, .page-slot {
  --kind: var(--muted);
  border: 1px solid var(--kind);
  background: color-mix(in srgb, var(--kind) 16%, transparent);
  border-radius: 4px;
}
.page-chip { display: inline-block; padding: 0 5px; margin: 1px 3px 1px 0; font: 11px/1.6 var(--mono, monospace); }
.page-chip small { color: var(--muted); }
.kind-elf { --kind: var(--accent); }
.kind-bin { --kind: #1a9b9b; }
.kind-bas, .kind-lua, .kind-py { --kind: #8a52c9; }
.kind-ram { --kind: var(--warn); }
.kind-data { --kind: var(--muted); }
.kind-empty { --kind: var(--border); background: transparent; border-style: dashed; }
.kind-conflict { --kind: var(--err); background: color-mix(in srgb, var(--err) 30%, transparent); }
.warn-text { color: var(--warn); }

.page-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 4px; margin-top: 4px; }
.page-slot { display: block; padding: 2px 4px; min-width: 0; font: 10px/1.35 var(--mono, monospace); }
a.page-slot { color: inherit; text-decoration: none; cursor: pointer; }
a.page-slot:hover { outline: 1px solid var(--accent, currentColor); }
.page-slot .slot-head { display: flex; justify-content: space-between; gap: 4px; color: var(--muted); }
.page-slot .slot-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-slot .slot-hash { color: var(--muted); }
.page-slot .slot-hash.live { font-style: italic; }
.page-legend { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.page-legend .page-chip { font-size: 10px; }

/* --- stats ------------------------------------------------------------------------------ */
/* chart series in a fixed order (the dataviz reference palette); players have their own color */
:root {
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
  --player-mix: 72%;   /* player colors are made for the dark map: darker on a light page */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --player-mix: 100%;
  }
}
:root[data-theme="dark"] {
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --player-mix: 100%;
}
.stats-wrap h2 { margin: 8px 0 0; }
.stats-bars { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); margin: 8px 0 12px; }
.stats-bars .lang-tabs { margin: 0; border-bottom: none; }
.seg-group { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin-bottom: 6px; }
.seg { border: none; border-radius: 0; background: var(--panel); padding: 3px 10px; font-size: 12px; }
.seg + .seg { border-left: 1px solid var(--border); }
.seg.active { background: var(--accent); color: #fff; }
#stats-page { transition: opacity .15s; }
#stats-page.loading { opacity: .6; }
.stats-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; margin-bottom: 12px; }
.stat-tile { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.stat-tile:hover { border-color: var(--accent); }
.stat-tile.charted { box-shadow: inset 3px 0 0 var(--accent); }
.stat-tile-value { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-tile-label { font-size: 11.5px; color: var(--muted); }
.stats-groups, .stats-pick { margin-bottom: 12px; }
.stats-pick summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.stat-chips { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.stat-chip-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.stat-chip-row > .small { min-width: 120px; }
.stat-chip { font-size: 12px; padding: 1px 9px; border-radius: 10px; background: var(--panel); }
.stat-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.stat-chip.colored.on { background: var(--c); border-color: transparent;
  color: #10131a; }
.stat-chip.colored:not(.on) { box-shadow: inset 4px 0 0 var(--c); }
.viz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 10px; }
.viz-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px 4px; min-width: 0; }
.viz-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.viz-title { font-size: 13px; font-weight: 600; }
.viz-now { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12px; margin-top: 2px; }
.viz-key { display: inline-flex; align-items: center; gap: 5px; }
.viz-key-val { color: var(--muted); font-variant-numeric: tabular-nums; }
.viz-swatch { display: inline-block; width: 14px; height: 2px; border-radius: 1px; background: var(--c); flex: none; }
.viz-swatch.player { background: color-mix(in oklab, var(--c) var(--player-mix), #000); height: 3px; }
.viz-plot { position: relative; height: 170px; margin-top: 4px; touch-action: pan-y; }
.viz-plot svg { display: block; overflow: visible; }
.viz-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 20px; }
.viz-note { margin: 2px 0 4px; }
.viz-grid line.viz-grid, .viz-card line.viz-grid { stroke: var(--border); stroke-width: 1; }
.viz-card line.viz-axis { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.viz-card text.viz-tick { fill: var(--muted); font-size: 10.5px; font-family: var(--sans); }
.viz-card .viz-event line { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 3 3; }
.viz-card .viz-event-label { fill: var(--warn); font-size: 10px; }
.viz-card .viz-line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-card .viz-line.player, .viz-card .viz-dot.player { stroke: color-mix(in oklab, var(--c) var(--player-mix), #000); }
.viz-card .viz-dot { fill: var(--panel); stroke: var(--c); stroke-width: 2; }
.viz-card .viz-line.goal { stroke-width: 1.5; stroke-dasharray: 6 4; opacity: .85; }
.viz-swatch.goal { background: repeating-linear-gradient(90deg, var(--c) 0 5px, transparent 5px 8px); }
.viz-card .viz-dot.player { fill: var(--panel); }
.viz-card line.viz-cross { stroke: var(--muted); stroke-width: 1; }
.viz-tip { position: absolute; top: 4px; z-index: 2; pointer-events: none; background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 8px; font-size: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); white-space: nowrap; }
.viz-tip-time { color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.viz-tip-row { display: flex; align-items: center; gap: 6px; }
.viz-tip-row strong { min-width: 48px; font-variant-numeric: tabular-nums; }
/* a player's name on their color (player colors are all light: dark text reads on each) */
.player-pill { display: inline-block; padding: 0 8px; border-radius: 10px; background: var(--c, var(--panel-2));
  color: #10131a; font-weight: 500; line-height: 20px; }
/* the player color picker (Settings) */
.color-current { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, 34px); gap: 6px; }
.color-swatch { width: 34px; height: 34px; padding: 0; border-radius: 8px; background: var(--c); border: 2px solid transparent; }
.color-swatch.big { display: inline-block; width: 28px; height: 28px; }
.color-swatch:hover { border-color: var(--text); }
.color-swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--panel) inset; }
.color-taken { margin-top: 10px; line-height: 26px; }

/* the CPU pie (Server Stats) */
.cpu-card { margin-bottom: 10px; }
.cpu-body { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.cpu-plot { position: relative; flex: none; }
.cpu-plot .viz-tip { top: 0; left: calc(var(--size, 180px) + 8px); }
.cpu-slice { fill: var(--c); stroke: var(--panel); stroke-width: 2; }
.cpu-slice:hover { filter: brightness(1.15); }
.cpu-center { fill: var(--text); font-size: 18px; font-weight: 600; font-family: var(--sans); }
.cpu-legend { display: grid; grid-template-columns: auto 1fr auto auto; gap: 3px 10px; font-size: 13px; min-width: 0; flex: 1; }
.cpu-key { display: contents; }
.cpu-key strong { text-align: right; font-variant-numeric: tabular-nums; }
.cpu-key .muted { text-align: right; font-variant-numeric: tabular-nums; }
.cpu-swatch { width: 10px; height: 10px; border-radius: 2px; background: var(--c); align-self: center; }
.cpu-details summary { cursor: pointer; font-size: 13px; color: var(--muted); }

.settings-search { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.settings-search input { flex: 1; min-width: 0; }

/* what bases and rockets are doing (a donut each) */
:root { --task-flying: #e87ba4; --task-scanning: #d9c84a; --task-other: #8a7fd6;
  --action-idle: color-mix(in oklab, var(--muted) 60%, var(--panel)); }
.donut-empty { fill: none; stroke: var(--panel-2); }
.cpu-key.zero { opacity: .5; }
.pie-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 10px; margin-bottom: 10px; }
.pie-row .cpu-card { margin-bottom: 0; }
.actions-card { margin-bottom: 12px; }
.pie-row .actions-card { margin-bottom: 0; }
.actions-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 8px; }
.actions-col { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.actions-title { font-size: 13px; font-weight: 600; }
.actions-col .cpu-legend { width: 100%; }

/* a Route_To being planned: sections running left to right (its time is not known yet) */
.task-fill.endless { width: 100%; background: repeating-linear-gradient(90deg, var(--c) 0 25%, transparent 25% 50%);
  background-size: 50% 100%; animation: task-endless 1s linear infinite; }
@keyframes task-endless { from { background-position: 0 0; } to { background-position: 100% 0; } }
@media (prefers-reduced-motion: reduce) { .task-fill.endless { animation: none; opacity: .7; } }

/* printing the manual: the sheets alone, one per page; cheat sheets on landscape pages */
@page { size: letter; margin: 0; }
@page cheat { size: letter landscape; margin: 0; }
@media print {
  html, body { height: auto; display: block; }
  .topbar, .manual-toc, .manual-note-btn, .manual-note { display: none !important; }
  .manual-layout { display: block; }
  .manual { overflow: visible; padding: 0; }
  .sheet { width: 8.5in; min-height: 11in; margin: 0; border: none; break-after: page; }
  .sheet.cheat { page: cheat; width: 11in; min-height: 8.5in; }
}

/* --- tutorials ------------------------------------------------------------------------- */
/* the manual's paper: the list is its contents sidebar, a tutorial is one wide sheet; the code
   is the exception with modern colors, as in an editor */
.tut-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.tut-list { border-right: 2.5px solid var(--ink); overflow-y: auto; padding: 18px 16px; background: var(--paper);
  color: var(--ink); font: 14.5px/1.35 var(--paper-serif); color-scheme: light; }
.tut-list-title { font: bold 20px var(--paper-sans); margin: 0 0 10px; padding-bottom: 4px; border-bottom: 2.5px solid var(--ink); }
.tut-item { display: flex; gap: 8px; width: 100%; text-align: left; background: none; border: none; border-radius: 0;
  padding: 2px 4px; color: var(--ink); font: inherit; cursor: pointer; }
.tut-item:hover .tut-name { text-decoration: underline; }
.tut-item.active { font-weight: bold; }
.tut-num { min-width: 1.2em; text-align: right; font-family: var(--paper-sans); }
.tut-page { overflow-y: auto; padding: 28px 24px 80px; background: var(--paper); color: var(--ink); }
.sheet.tut-sheet { width: min(1100px, 100%); min-height: 0; padding: 48px 56px 56px; text-align: left; }
.sheet.tut-sheet h2 { margin-bottom: 0; }
.tut-langs { display: flex; gap: 0; margin: 0 0 18px; border-bottom: 1.5px solid var(--ink); overflow-x: auto; }
.tut-lang { background: none; border: none; border-radius: 0; border-bottom: 4px solid transparent; margin-bottom: -1.5px;
  padding: 10px 16px 6px; color: var(--ink); font: 15px var(--paper-sans); cursor: pointer; }
.tut-lang:hover { text-decoration: underline; }
.tut-lang.active { font-weight: bold; border-bottom-color: var(--ink); }
.tut-intro { margin: 0 0 22px !important; }
/* the gif and the code, one below the other, each in a black frame with room inside */
.tut-frame { margin: 0 0 18px; padding: 12px; border: 1.5px solid var(--ink); background: var(--paper); }
.tut-media { position: relative; line-height: 0; }
.sheet .tut-media img { width: 100%; margin: 0; }
.tut-media-note { position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; font: 11px/1.4 var(--paper-sans);
  background: rgba(0, 0, 0, .65); color: #ddd; }
.tut-code { display: flex; overflow-x: auto; background: #fafafa; border: 1px solid #e3e5e8;
  font: 13.5px/1.5 var(--mono); font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
.sheet .tut-code pre { margin: 0; padding: 12px 0; border: none; background: none; font: inherit; overflow: visible; }
.sheet .tut-code code { font: inherit; color: #383a42; }
.sheet .tut-code .tut-gutter { flex: none; min-width: 3.2em; padding: 12px 10px 12px 6px; text-align: right; color: #a0a4ab;
  border-right: 1px solid #e3e5e8; user-select: none; }
.sheet .tut-code .tut-source { flex: 1; padding: 12px 16px; }
/* the colors of an editor's light theme (One Light) */
.tut-code .tok-com { color: #a0a1a7; font-style: italic; }
.tut-code .tok-kw { color: #a626a4; font-weight: normal; }
.tut-code .tok-type { color: #c18401; }
.tut-code .tok-api { color: #4078f2; font-weight: normal; }
.tut-code .tok-str { color: #50a14f; }
.tut-code .tok-num, .tut-code .tok-const { color: #986801; }
.tut-code .tok-pre { color: #a626a4; }
.tut-file + .tut-file { margin-top: 14px; }
.tut-file-head { margin: 0 0 6px; font: 13px var(--paper-sans); }
.tut-file-name { font: bold 13px var(--mono); }
.tut-rules-title { margin-top: 30px !important; }
.sheet .tut-rules li { margin-bottom: 9px; }
.tut-refs { display: block; font: 13px var(--paper-sans); }
@media (max-width: 900px) {
  .tut-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .tut-list { border-right: none; border-bottom: 2.5px solid var(--ink); max-height: 30vh; }
  .tut-page { padding: 16px 12px; }
  .sheet.tut-sheet { padding: 24px 16px 32px; }
  .tut-frame { padding: 6px; }
}
