:root {
  color-scheme: light dark;
  --page: #f6f4f1;
  --ink: #23212a;
  --muted: #625e6e;
  --edge: #d8d4cc;
  --panel: #fffdf9;
  --accent: #6d4ec7;
  --term: #15141a;
  --term-ink: #e6e3ea;
  --term-edge: #34313d;
  --line: 1.3em;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #101014;
    --ink: #ece9f0;
    --muted: #a5a0b2;
    --edge: #33313b;
    --panel: #1a1920;
    --accent: #b9a1ff;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main { max-width: 1360px; margin: 0 auto; padding: 24px 16px 64px; display: grid; gap: 24px; min-width: 0; }
section { min-width: 0; }
h1 { margin: 0; font-size: 2rem; line-height: 1.2; }
a { color: var(--accent); }
.intro { display: grid; gap: 16px 32px; }
.lead { margin: 8px 0 0; max-width: 62ch; }
.intro .note { min-height: 0; max-width: 62ch; }
.install { display: grid; gap: 6px; align-content: start; font-size: .875rem; min-width: 0; }
.install label { color: var(--muted); }
.install-row { display: flex; gap: 8px; min-width: 0; }
.install-row input { flex: 1 1 auto; min-width: 0; font-size: 12px; }
.install-row button { flex: none; white-space: nowrap; }
footer p { margin: 0; }
footer { min-height: 0; }
@media (min-width: 1000px) { .intro { grid-template-columns: minmax(0, 1fr) 520px; } }
h2 { margin: 0 0 10px; font-size: 1.05rem; }
.note { margin: 12px 0 0; color: var(--muted); font-size: .875rem; }
.muted { color: var(--muted); font-weight: 400; }

/* The view stays on screen while any control is used. */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.controls { display: grid; gap: 20px; min-width: 0; }
.stage { order: -1; position: sticky; top: 0; z-index: 1; padding: 8px 0; background: var(--page); max-height: 62vh; overflow: auto; min-width: 0; }
.notes .note:first-child { margin-top: 0; }
.flag-note { margin: 6px 0 0; font-size: .8125rem; }
.without-mods { margin-top: 12px; }
.without-mods h2 { margin-bottom: 4px; font-size: .8125rem; }

/* Two columns only where the band's figures still fit beside the controls, with a 15 px page scrollbar. */
@media (min-width: 1250px) {
  .layout { grid-template-columns: 300px minmax(0, 1fr); gap: 24px; }
  .stage { order: 0; top: 8px; padding: 0; max-height: calc(100vh - 16px); }
}

/* Settings */
.settings { display: flex; flex-wrap: wrap; gap: 10px 24px; }
.setting { margin: 0; padding: 0; border: 0; min-width: 0; }
.setting legend { padding: 0 0 4px; font-size: .8125rem; color: var(--muted); }
.choices { display: inline-flex; border: 1px solid var(--edge); border-radius: 6px; overflow: hidden; background: var(--panel); }
.choices label { position: relative; cursor: pointer; }
.choices input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.choices span { display: block; padding: 6px 10px; font-size: .875rem; border-right: 1px solid var(--edge); }
.choices label:last-child span { border-right: 0; }
.choices input:checked + span { background: var(--accent); color: var(--page); }
.choices input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -4px; }
input[type="text"] { width: 100%; padding: 6px 8px; font: 14px/1.4 ui-monospace, Menlo, Consolas, monospace; color: inherit; background: var(--panel); border: 1px solid var(--edge); border-radius: 6px; }

/* The terminal */
.terminal {
  position: relative;
  background: var(--term);
  color: var(--term-ink);
  border: 1px solid var(--term-edge);
  border-radius: 8px;
  font: 13px/var(--line) ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace;
  overflow: hidden;
  min-width: 0;
  font-variant-emoji: text;
}
.ruler { position: absolute; visibility: hidden; white-space: pre; pointer-events: none; }
.upper { display: grid; grid-template-columns: minmax(0, 1fr); border-bottom: 1px solid var(--term-edge); }
.transcript { margin: 0; padding: 12px; min-height: 96px; max-height: 420px; overflow: auto; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
.pane { border-top: 1px solid var(--term-edge); min-width: 0; padding: 0 12px 12px; }
.pane-title { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.tab { min-height: 28px; padding: 2px 8px; font: inherit; color: inherit; background: transparent; border: 1px solid transparent; border-radius: 4px; opacity: .65; }
.tab[aria-pressed="true"] { background: transparent; color: inherit; border-color: var(--term-edge); opacity: 1; }
.tab:hover { border-color: var(--term-edge); }
.close { margin-left: auto; }
.example { opacity: .6; font-size: .85em; padding-left: 8px; }
.link { color: #8ab4ff; }
button.plain { min-height: 0; padding: 0; font: inherit; color: inherit; background: none; border: 0; opacity: .65; text-decoration: underline; }
.command { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8125rem; }
.pane-body { min-width: 0; overflow: hidden; }
#board { max-height: 420px; overflow: auto; }
.band { padding: 8px 12px 0; overflow-x: auto; }
.prompt { margin: 8px 12px 0; padding: 4px 8px; border: 1px solid var(--term-edge); border-radius: 4px; }
.caret { display: inline-block; width: 1ch; height: 1.1em; vertical-align: text-bottom; background: var(--term-ink); opacity: .7; }
.hint { padding: 4px 12px 10px; opacity: .6; white-space: pre; overflow-x: auto; }

@media (min-width: 960px) {
  .upper:has(.pane:not([hidden])) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .pane { border-top: 0; border-left: 1px solid var(--term-edge); }
  .transcript { min-height: 180px; }
}

/* The band needs 940 px at 13 px: this keeps its figures on screen from about 934 px up, with classic scrollbars. */
@media (max-width: 1319px) {
  .terminal { font-size: 12px; }
}

/* A short screen keeps the band in sight from the top: the footer says the same. */
@media (max-height: 760px) {
  .intro .note { display: none; }
}

/* On a phone the band comes first after the text, so a slider's change is in sight, and the Road scrolls below. */
@media (max-width: 959px) {
  .terminal:not(.one-line) { display: flex; flex-direction: column; }
  .upper { display: contents; }
  .transcript { order: 1; max-height: 96px; border-bottom: 1px solid var(--term-edge); }
  .band { order: 2; }
  .prompt { order: 3; }
  .hint { order: 4; }
  .pane { order: 5; }
}

.one-line { padding: 8px 12px; white-space: pre; overflow-x: auto; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .95em; }

.howto { margin-top: 8px; font-size: .875rem; color: var(--muted); }
.howto summary { cursor: pointer; color: var(--accent); }
.howto summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.howto ol { margin: 8px 0; padding-left: 20px; }
.howto li { margin-bottom: 6px; }
.howto p { margin: 0 0 6px; }
.howto code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .95em; color: var(--ink); }
.howto pre { margin: 4px 0 0; padding: 6px 8px; background: var(--panel); border: 1px solid var(--edge); border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* What the stand-in engine draws */
.box { display: flex; min-width: 0; }
.column { flex-direction: column; }
.row { flex-direction: row; }
/* A row's fixed text keeps its width, and the truncating text beside it gives way. */
.row > .text:not(.truncate) { flex-shrink: 0; }
.text { white-space: pre-wrap; min-width: 0; }
.truncate { white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.dim { opacity: .6; }
.bold { font-weight: 700; }
.cells, .picture { display: block; image-rendering: pixelated; flex-shrink: 0; align-self: flex-start; }

/* The session */
.primary { width: 100%; background: var(--accent); color: var(--page); border-color: var(--accent); font-weight: 600; }
.meters { display: grid; gap: 8px; margin-top: 12px; }
.meter { min-width: 0; }
.meters label { font-variant-emoji: text; display: flex; justify-content: space-between; font-size: .875rem; color: var(--muted); }
.meters output { color: var(--ink); font-variant-numeric: tabular-nums; }
.meters input { width: 100%; accent-color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
button { padding: 6px 10px; min-height: 36px; font: inherit; font-size: .875rem; color: inherit; background: var(--panel); border: 1px solid var(--edge); border-radius: 6px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button[aria-pressed="true"] { background: var(--accent); color: var(--page); border-color: var(--accent); }
