/*
 * OpenTripSplit "indie pixel" theme, tuned for keratoconus.
 *
 * Keratoconus blurs, ghosts and haloes text, and makes glare painful, so:
 * - no pure white or pure black: peak contrast is about 13-14:1, not 21:1
 * - every text colour is >= 7:1 (WCAG AAA) on --bg, --surface, --notice
 *   and --chip; borders >= 3:1. theme_test.go enforces this.
 * - the pixel font is only used large (headings, buttons, the simulator's
 *   terminal); body text uses
 *   Atkinson Hyperlegible Next, designed for low vision
 * - no textures, scanlines, glow, blur or text shadows; the only motion is
 *   the button press, plus the simulator page: coins crossing, typed
 *   terminal text, short slides and pulses (Animate.css, typewriter-effect,
 *   view transitions; never flashing or shaking).
 *   prefers-reduced-motion turns all of it off
 * - meaning is never carried by colour alone
 */

@font-face {
  font-family: "Pixelify Sans";
  src: url("fonts/pixelify-sans-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Pixelify Sans";
  src: url("fonts/pixelify-sans-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* Parchment (light) palette. */
:root {
  color-scheme: light;
  --bg: #F1E8D2;
  --surface: #FAF4E4;
  --notice: #F7E7BE;
  --chip: #F3EAD3;
  --border: #6B5B45;
  --lip: #6B5B45;
  --text: #2B2420;
  --muted: #4A4035;
  --accent: #244A70;
  --on-accent: #FAF4E4;
  --pos: #1F521F;
  --neg: #713608;
  --danger: #86251C;
  --on-danger: #FAF4E4;
  --link: #1A4475;
  --on-link: #FAF4E4;
  --focus: #244A70;
  /* The simulator's terminal is dark in both themes. */
  --term-bg: #17161C;
  --term-text: #E6E1D3;
  --term-dim: #B8B1A0;
  --term-prompt: #F2C14E;
  --term-ok: #9AD48F;
  --term-fail: #F4978E;
}

/* Night (dark) palette: used when the device prefers dark and the user
   hasn't picked light, or when the user picked dark. Keep both blocks
   identical (theme_test.go checks). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1C1B22;
    --surface: #26242E;
    --notice: #262329;
    --chip: #24222A;
    --border: #7D7793;
    --lip: #0F0E13;
    --text: #E6E1D3;
    --muted: #B8B1A0;
    --accent: #F2C14E;
    --on-accent: #1C1B22;
    --pos: #9AD48F;
    --neg: #F2A65A;
    --danger: #F4978E;
    --on-danger: #1C1B22;
    --link: #9CCFF2;
    --on-link: #1C1B22;
    --focus: #F2C14E;
    --term-bg: #17161C;
    --term-text: #E6E1D3;
    --term-dim: #B8B1A0;
    --term-prompt: #F2C14E;
    --term-ok: #9AD48F;
    --term-fail: #F4978E;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1C1B22;
  --surface: #26242E;
  --notice: #262329;
  --chip: #24222A;
  --border: #7D7793;
  --lip: #0F0E13;
  --text: #E6E1D3;
  --muted: #B8B1A0;
  --accent: #F2C14E;
  --on-accent: #1C1B22;
  --pos: #9AD48F;
  --neg: #F2A65A;
  --danger: #F4978E;
  --on-danger: #1C1B22;
  --link: #9CCFF2;
  --on-link: #1C1B22;
  --focus: #F2C14E;
  --term-bg: #17161C;
  --term-text: #E6E1D3;
  --term-dim: #B8B1A0;
  --term-prompt: #F2C14E;
  --term-ok: #9AD48F;
  --term-fail: #F4978E;
}

/* Text size. Everything below is in rem/em, so the layout scales. */
html { font-size: 112.5%; }               /* 18px */
html[data-size="large"] { font-size: 125%; } /* 20px */
html[data-size="huge"] { font-size: 150%; }  /* 24px */

:root {
  --bw: 3px; /* pixel border width */
  --pixel: "Pixelify Sans", ui-monospace, monospace;
  --body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", Verdana, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  line-height: 1.6;
  letter-spacing: 0.01em;
  overflow-wrap: break-word;
}

a { color: var(--link); text-decoration-thickness: 2px; text-underline-offset: 3px; }
:focus-visible { outline: 3px dashed var(--focus); outline-offset: 3px; }

h1, h2, h3, .brand, button, .button, .badge, summary {
  font-family: var(--pixel);
  letter-spacing: 0.02em;
}
h1 { font-size: 2rem; font-weight: 700; line-height: 1.2; margin: 0.75rem 0 1rem; }
h2 { font-size: 1.4rem; font-weight: 700; line-height: 1.25; margin: 0 0 0.75rem; }
h3 { font-size: 1.15rem; font-weight: 700; margin: 1.5rem 0 0.5rem; }
h1 .muted, h1 .small { font-family: var(--body); font-size: 1rem; font-weight: 400; }
p { max-width: 70ch; }
code { font-family: ui-monospace, monospace; font-size: 0.9em; overflow-wrap: anywhere; }

/* Pixel icons: 12px art drawn at whole multiples where possible. */
.icon {
  width: 1.5em; height: 1.5em;
  image-rendering: pixelated;
  vertical-align: -0.3em;
  margin-right: 0.35em;
  object-fit: contain;
}

/* Header: the brand and main links on the left; the user menu (account,
   display settings, log out) on the right. Header links and the menu's
   name use the brand's pixel lettering. */
.top {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: calc(var(--bw) + 1px) solid var(--border);
}
.top nav { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; align-items: center; }
.brand, .top nav a {
  font-family: var(--pixel); font-size: 1.4rem; font-weight: 700; letter-spacing: 0.02em;
  color: var(--text); text-decoration: none; display: inline-flex; align-items: center;
}
.top nav a:hover {
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px;
}
.brand .icon { width: 2em; height: 2em; }
main { max-width: 60rem; margin: 0 auto; padding: 1rem; }
footer {
  max-width: 60rem; margin: 2rem auto; padding: 1rem;
  color: var(--muted); font-size: 0.9rem;
  border-top: var(--bw) solid var(--border);
}
/* The user menu: the name opens a panel that drops down from the right
   edge. margin-left: auto keeps it on the right even when the header wraps. */
.user-menu { position: relative; margin-left: auto; }
.user-menu > summary {
  list-style: none; margin: 0; display: inline-flex; align-items: center; gap: 0.4em;
  font-size: 1.4rem; font-weight: 700; color: var(--text);
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary::after { content: "▼"; content: "▼" / ""; font-size: 0.6em; }
.user-menu[open] > summary::after { content: "▲"; content: "▲" / ""; }
.user-menu > summary:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.menu-panel {
  position: absolute; right: var(--bw); top: calc(100% + 0.75rem); z-index: 10;
  width: max-content; min-width: 16rem; max-width: calc(100vw - 2rem);
  display: grid; gap: 0.75rem;
  background: var(--surface);
  padding: 1rem 1.25rem;
  box-shadow:
    0 calc(-1 * var(--bw)) 0 0 var(--border),
    0 var(--bw) 0 0 var(--border),
    calc(-1 * var(--bw)) 0 0 0 var(--border),
    var(--bw) 0 0 0 var(--border);
}
.menu-panel form { margin: 0; }
/* Account and Log out are full-width buttons above and below the settings. */
.menu-panel .logout button { width: calc(100% - 2 * var(--bw)); }
.prefs { display: grid; gap: 0.6rem; }
.prefs button { justify-self: start; }

.dev-banner {
  background: var(--danger); color: var(--on-danger);
  text-align: center; font-weight: 700; padding: 0.35rem 1rem;
}

/* Pixel boxes: a border drawn with four hard shadows leaves the corners
   notched, like a sprite. */
.card {
  background: var(--surface);
  padding: 1rem 1.25rem;
  margin: var(--bw) var(--bw) 1.5rem;
  box-shadow:
    0 calc(-1 * var(--bw)) 0 0 var(--border),
    0 var(--bw) 0 0 var(--border),
    calc(-1 * var(--bw)) 0 0 0 var(--border),
    var(--bw) 0 0 0 var(--border);
}
.narrow { max-width: 34rem; margin: 2rem auto; }
.columns { display: grid; gap: 0 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(17rem, 100%), 1fr)); }
.title-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.stack { display: grid; gap: 0.75rem; margin: 1rem 0; }

.muted { color: var(--muted); }
.small { font-size: 0.9rem; font-weight: 400; }
.hint { color: var(--muted); font-size: 0.95rem; }
.error { color: var(--danger); font-weight: 700; }
.error::before { content: "✖ "; }
.notice {
  background: var(--notice); color: var(--text);
  padding: 0.6rem 0.9rem;
  border-left: calc(var(--bw) * 2) solid var(--border);
}
.badge {
  display: inline-block; font-size: 0.8rem; font-weight: 700; line-height: 1.4;
  padding: 0 0.45rem; margin-left: 0.25rem; vertical-align: 0.15em;
  background: var(--chip); color: var(--text); border: 2px solid var(--border);
}
/* The "Beta" tag beside the brand: accent-filled so it reads as a label,
   not a nav link. */
.badge.beta { background: var(--accent); color: var(--on-accent); border-color: var(--accent); margin-left: 0.5rem; }
.nowrap { white-space: nowrap; }

.list { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.list li { padding: 0.5rem 0; border-bottom: 2px solid var(--border); }
.list li:last-child { border-bottom: 0; }

/* High-score board (balances). */
.scores-card { container-type: inline-size; }
.scores-head, .scores li {
  display: grid;
  grid-template-columns: 4.5em minmax(0, 1fr) auto;
  grid-template-areas: "rank player score";
  column-gap: 0.75rem;
  align-items: center;
}
.rank { grid-area: rank; }
.player { grid-area: player; }
.score { grid-area: score; }
/* When the card is narrow (phones, big text), each entry takes two lines:
   rank and name on top, score right-aligned underneath, so names never get
   squeezed to a couple of letters. */
@container (max-width: 24rem) {
  .scores li {
    grid-template-columns: 3.4em minmax(0, 1fr);
    grid-template-areas: "rank player" ". score";
    row-gap: 0.15rem;
    /* Top-align, with the rank's line box the same height as the name's,
       so the rank sits on the name's first line however many lines it wraps to. */
    align-items: start;
  }
  .scores-head { grid-template-columns: 3.4em minmax(0, 1fr) auto; grid-template-areas: "rank player score"; }
  .leader { display: none; }
  .player { align-items: flex-start; }
  .rank, .player-name { line-height: 1.6rem; }
}
/* Scores, ranks and labels use the body font: in the pixel font "5" and
   "S" look alike, which is the last thing a balance should do. The arcade
   feel comes from ranks, the star, dot leaders and signed points instead. */
.scores-head {
  font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  padding-bottom: 0.3rem; border-bottom: var(--bw) solid var(--border);
}
.scores-head span:last-child { text-align: right; }
.scores { list-style: none; margin: 0; padding: 0; }
.scores li { padding: 0.55rem 0; border-bottom: 2px solid var(--border); min-height: 3.5rem; }
.scores li:last-child { border-bottom: 0; }
.rank { white-space: nowrap; font-weight: 700; font-size: 1.05rem; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.scores .top .rank { color: var(--accent); }
.scores .top .rank::after { content: " ★"; }
/* last baseline: when a long name wraps, the dots lead from its last line. */
.player { display: flex; align-items: flex-end; align-items: last baseline; min-width: 0; }
.player-name { overflow-wrap: anywhere; }
/* Arcade dot leader between name and score; chunky 3px dots, not hairlines. */
.leader { flex: 1; min-width: 1.25rem; margin-left: 0.5rem; border-bottom: var(--bw) dotted var(--border); transform: translateY(-0.3em); }
.score { display: grid; justify-items: end; text-align: right; }
.points { font-weight: 700; font-size: 1.4rem; line-height: 1.15; letter-spacing: 0.04em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.score .small { white-space: nowrap; }

/* Heading on the left, the balance (▲ owed or ▼ owing) on the right of the
   same line. */
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.25rem 1rem; margin-bottom: 0.75rem; }
.card-head h2 { margin: 0; }
/* A rule under the heading and total, as thick as the high-score board's,
   sets them apart from the payments below. */
.my-balance .card-head { padding-bottom: 0.5rem; border-bottom: var(--bw) solid var(--border); }

/* Rows with actions: text on the left, actions anchored in a right-hand
   column, so buttons line up down the list however long the text is.
   Every row gets the same minimum height whether or not it has a button. */
.rows li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) fit-content(50%);
  column-gap: 1rem;
  align-items: center;
  min-height: 3.5rem;
}
.row-act {
  display: flex; flex-wrap: wrap; gap: 0.25rem 1rem;
  justify-content: flex-end; align-items: center;
  text-align: right;
}
.row-act form { margin: 0; }
.row-act button.small { min-width: 7.5em; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 2px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { font-size: 0.9rem; color: var(--muted); font-weight: 700; }
.num { text-align: right; white-space: nowrap; }
.pos { color: var(--pos); font-weight: 700; }
.neg { color: var(--neg); font-weight: 700; }

.row-actions { white-space: nowrap; text-align: right; }
.who { min-width: 8em; }
/* The wrapper scrolls sideways if the columns can't fit, so the table
   itself can stay a real table and stretch to the card's full width. */
.table-wrap { overflow-x: auto; }
/* A little more air per expense than other tables, so rows stay apart. */
.expenses td { padding-top: 0.75rem; padding-bottom: 0.75rem; }
/* Body font, like the balances: the pixel font's "5" and "S" look alike. */
.expense-amount { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
/* The description reads like a quest-log entry: a "!" quest marker and
   the title in the pixel font, at the h3 size where it stays legible. */
.quest { font-family: var(--pixel); font-size: 1.15rem; font-weight: 700; line-height: 1.35; letter-spacing: 0.02em; }
.quest::before {
  content: "!"; content: "!" / "";
  display: inline-grid; place-items: center; width: 1.3em; height: 1.3em; margin-right: 0.5em;
  font-size: 0.85em; vertical-align: 0.1em;
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 0 0 2px var(--border);
}

/* The split type: its name in uppercase. */
.split-tag { white-space: nowrap; font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }

/* A card drawn as an RPG scroll: parchment between two rolled ends. Each
   roll has a line where the sheet curls in and a knob poking out at both
   sides (box-shadows shrunk by a negative spread). The side margin leaves
   room for the overhang. */
.card.scroll {
  position: relative;
  background: var(--notice);
  margin: 1.5rem 1.25rem 2.25rem;
  padding: 1.75rem 1.5rem;
}
.card.scroll::before, .card.scroll::after {
  content: "";
  position: absolute; left: -0.75rem; right: -0.75rem; height: 1.25rem;
  background: linear-gradient(var(--chip) 0 60%, var(--border) 60% calc(60% + var(--bw)), var(--chip) 0);
  box-shadow:
    0 calc(-1 * var(--bw)) 0 0 var(--border),
    0 var(--bw) 0 0 var(--border),
    calc(-1 * var(--bw)) 0 0 0 var(--border),
    var(--bw) 0 0 0 var(--border),
    -0.75rem 0 0 -0.3rem var(--border),
    0.75rem 0 0 -0.3rem var(--border);
}
.card.scroll::before { top: -0.6rem; }
.card.scroll::after { bottom: -0.6rem; transform: scaleY(-1); }

/* Forms. */
form.inline { display: inline; margin: 0 0 0 0.75rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(11rem, 100%), 1fr)); align-items: end; }
.form > label, .form > .grid, .form > div { margin-bottom: 1rem; }
/* A button in a form grid keeps its natural width and sits on the same
   baseline as the inputs beside it. */
.grid > button { justify-self: start; }
label { display: grid; gap: 0.3rem; font-weight: 700; }
label.check { display: flex; gap: 0.6rem; align-items: center; padding: 0.3rem 0; font-weight: 400; }
label.row { display: grid; grid-template-columns: minmax(0, 1fr) 8rem auto; gap: 0.75rem; align-items: center; padding: 0.3rem 0; font-weight: 400; }
/* min-inline-size: 0 stops fieldsets from growing past their card. */
fieldset { border: var(--bw) solid var(--border); padding: 0.75rem 1rem; margin: 0 0 1rem; min-inline-size: 0; }
/* Legends are instructions, not headings, so they stay in the body font. */
legend { font-size: 1rem; font-weight: 700; padding: 0 0.4rem; }
fieldset.provider { display: grid; gap: 0.75rem; }
fieldset.provider p { margin: 0; }

input, select {
  font: inherit; font-weight: 400; color: var(--text); background: var(--bg);
  border: var(--bw) solid var(--border); border-radius: 0;
  padding: 0.45rem 0.6rem; min-height: 2.75rem; min-width: 0; width: 100%;
}
input[type="checkbox"] { width: 1.4rem; height: 1.4rem; min-height: 0; accent-color: var(--accent); }
input.copy { font-family: ui-monospace, monospace; font-size: 0.9rem; }

/* Buttons: notched pixel border plus a hard "lip" underneath. Pressing
   pushes the button down onto the lip. */
button, .button {
  font-size: 1.05rem; font-weight: 700; line-height: 1.2;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4em;
  min-height: 2.75rem; padding: 0.5rem 1.1rem; margin: var(--bw) var(--bw) calc(var(--bw) * 2);
  cursor: pointer; text-decoration: none; text-align: center;
  background: var(--accent); color: var(--on-accent); border: 0;
  box-shadow:
    0 calc(-1 * var(--bw)) 0 0 var(--border),
    0 var(--bw) 0 0 var(--border),
    calc(-1 * var(--bw)) 0 0 0 var(--border),
    var(--bw) 0 0 0 var(--border),
    0 calc(var(--bw) * 2) 0 0 var(--lip);
  transition: transform 60ms steps(1), box-shadow 60ms steps(1);
}
button:active, .button:active {
  transform: translateY(var(--bw));
  box-shadow:
    0 calc(-1 * var(--bw)) 0 0 var(--border),
    0 var(--bw) 0 0 var(--border),
    calc(-1 * var(--bw)) 0 0 0 var(--border),
    var(--bw) 0 0 0 var(--border);
}
button.secondary, .button.secondary { background: var(--surface); color: var(--text); }
button.danger { background: var(--danger); color: var(--on-danger); }
/* Blue in both themes (the accent is gold at night), for links that need
   to stand apart from the main action, like Account in the user menu. */
.button.info, button.info { background: var(--link); color: var(--on-link); }
button.small { font-size: 0.95rem; min-height: 2.2rem; padding: 0.25rem 0.75rem; }
button.wide { width: calc(100% - 2 * var(--bw)); }
button::before, .button::before { content: "▶"; font-size: 0.7em; }
button.secondary::before, .button.secondary::before, button.small::before { content: none; }

/* Text-style buttons (Delete, Make owner, Log out). */
button.link {
  font-family: var(--body); font-size: 1rem; font-weight: 400; letter-spacing: 0.01em;
  background: none; color: var(--link); box-shadow: none; padding: 0; margin: 0; min-height: 0;
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px;
}
button.link::before { content: none; }
button.link:active { transform: none; box-shadow: none; }
button.link.danger { color: var(--danger); background: none; }

.danger-zone { box-shadow:
  0 calc(-1 * var(--bw)) 0 0 var(--danger),
  0 var(--bw) 0 0 var(--danger),
  calc(-1 * var(--bw)) 0 0 0 var(--danger),
  var(--bw) 0 0 0 var(--danger); }
details summary { cursor: pointer; margin: 0.75rem 0; color: var(--link); font-weight: 700; }
/* Collapsible cards: the whole heading is the toggle, with a pixel arrow
   at the right that points down when the card is open. */
details.fold > summary { list-style: none; display: flex; align-items: center; gap: 0.75rem; margin: 0; color: var(--text); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { margin: 0; }
details.fold > summary::after { content: "▶"; content: "▶" / ""; margin-left: auto; font-size: 0.9rem; }
details.fold[open] > summary { margin-bottom: 0.75rem; }
details.fold[open] > summary::after { content: "▼"; content: "▼" / ""; }
.dev-login { border-top: var(--bw) dashed var(--border); margin-top: 1.25rem; padding-top: 0.5rem; }

/* Simulator (simulator.html). Art and motion come from vendored
   libraries: pixelarticons sprites (drawn through CSS masks so they take
   the theme's colors), the app's coin icon, Animate.css classes the server
   picks, typewriter-effect in the terminal, and htmx view transitions,
   which slide each player's row to its new rank. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
#sim-stage { --animate-duration: 600ms; }
.sim-controls { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: center; margin-bottom: 0.75rem; }

/* Pixelarticons are drawn on a 24px grid; 72px and 48px keep every pixel
   a whole number of screen pixels. */
.sprite {
  display: inline-block; flex: none; width: 72px; height: 72px;
  background: currentColor;
  mask: url("sprites/human.svg") center / contain no-repeat;
}
.sprite.human-up { mask-image: url("sprites/human-arms-up.svg"); }
.sprite.store { mask-image: url("sprites/store.svg"); }
.sprite.terminal-icon { width: 24px; height: 24px; mask-image: url("sprites/terminal.svg"); }

/* The transfer window: a dialog with a title bar, like a file copy. */
.card.sim-window { padding: 0; }
.sim-window-bar {
  padding: 0.35rem 0.9rem;
  font-family: var(--pixel); font-weight: 700; font-size: 1.1rem;
  background: var(--accent); color: var(--on-accent);
}
.sim-transfer { display: flex; align-items: flex-start; gap: 0.5rem; padding: 1rem 1rem 0; }
.sim-actor { margin: 0; display: grid; justify-items: center; gap: 0.25rem; width: 7.5rem; text-align: center; }
.sim-actor figcaption { font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.sim-transfer .sim-actor:last-child .sprite { color: var(--accent); }
.sim-party { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem 0.5rem; padding: 1rem 1rem 0; }
.sim-party .sprite { width: 48px; height: 48px; }
.sim-caption { max-width: none; margin: 0; padding: 0.75rem 1rem 0; }
.sim-progress { display: grid; gap: 0.3rem; padding: 0.5rem 1rem 1rem; }
.sim-progress progress { width: 100%; height: 1.25rem; accent-color: var(--accent); }

/* Coins hop from one sprite to the other in a stream, in a few chunky
   steps rather than smoothly. cqw is the lane's width. */
.sim-lane { position: relative; flex: 1; min-width: 4rem; height: 72px; container-type: inline-size; }
.sim-lane .coin {
  position: absolute; left: 0; top: 24px; width: 36px; height: 36px; margin: 0;
  image-rendering: pixelated; opacity: 0;
  animation: sim-coin 1.5s steps(5) both;
}
.sim-lane .c2 { animation-delay: 0.5s; }
.sim-lane .c3 { animation-delay: 1s; }
.sim-lane.loop .coin { animation-iteration-count: infinite; }
@keyframes sim-coin {
  0% { transform: translate(0, 0); opacity: 0; }
  12% { opacity: 1; }
  50% { transform: translate(calc(50cqw - 18px), -20px); }
  88% { opacity: 1; }
  100% { transform: translate(calc(100cqw - 36px), 0); opacity: 0; }
}

.sim-banner {
  max-width: none; margin: 0 var(--bw) 1.5rem; padding: 0.75rem 1rem;
  font-family: var(--pixel); font-size: 1.6rem; font-weight: 700; text-align: center;
  background: var(--accent); color: var(--on-accent);
}
.sim-banner.fail { background: var(--danger); color: var(--on-danger); }

/* The terminal logs each step as if it were loading a game asset. */
.terminal {
  margin: var(--bw) var(--bw) 1.5rem;
  background: var(--term-bg); color: var(--term-text);
  box-shadow:
    0 calc(-1 * var(--bw)) 0 0 var(--border),
    0 var(--bw) 0 0 var(--border),
    calc(-1 * var(--bw)) 0 0 0 var(--border),
    var(--bw) 0 0 0 var(--border);
}
.terminal-bar {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.9rem;
  font-family: var(--pixel); color: var(--term-dim);
  border-bottom: var(--bw) solid var(--term-dim);
}
.terminal-lines {
  font-family: var(--pixel); font-size: 1.1rem; line-height: 1.5; letter-spacing: 0.03em;
  padding: 0.75rem 1rem; height: 18rem; overflow-y: auto;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.terminal-block + .terminal-block { margin-top: 0.6rem; }
/* Hidden until sim.js starts typing it, so the full text never flashes
   first. sim-noscript.css shows it when JavaScript is off. */
.terminal-block[data-type]:not([data-typed]) { display: none; }
.terminal-line.prompt { color: var(--term-prompt); font-weight: 700; }
.terminal-line.ok { color: var(--term-ok); }
.terminal-line.fail { color: var(--term-fail); font-weight: 700; }
.Typewriter__cursor { color: var(--term-prompt); animation: term-blink 1s steps(1) infinite; }
@keyframes term-blink { 50% { opacity: 0; } }

.sim-delta { font-weight: 700; }
/* The Expenses or Payments row added at the current step. */
.sim-new { background: var(--notice); }
/* On the scroll the paper is already --notice, so mark the row with a bar. */
.scroll .sim-new { background: var(--surface); }
.scroll .sim-new td:first-child { box-shadow: inset calc(var(--bw) * 2) 0 0 0 var(--accent); padding-left: 0.75rem; }
.badge.pass { color: var(--pos); }
.badge.fail { color: var(--danger); }
.sim-checks li { display: flex; flex-wrap: wrap; gap: 0.25rem 0.6rem; align-items: baseline; }
.sim-checks .badge { margin-left: 0; }
/* One name per player (at most 8, see sim.MaxPeople). They have to be
   classes: the CSP blocks inline styles. */
.vt-p1 { view-transition-name: sim-p1; }
.vt-p2 { view-transition-name: sim-p2; }
.vt-p3 { view-transition-name: sim-p3; }
.vt-p4 { view-transition-name: sim-p4; }
.vt-p5 { view-transition-name: sim-p5; }
.vt-p6 { view-transition-name: sim-p6; }
.vt-p7 { view-transition-name: sim-p7; }
.vt-p8 { view-transition-name: sim-p8; }
::view-transition-group(*) { animation-duration: 450ms; }
/* No crossfade: the page and each row's contents swap at once; only the
   rows' slide to their new rank is animated. */
::view-transition-old(*) { display: none; }
::view-transition-new(*) { animation: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  button:active, .button:active { transform: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  /* One coin, parked halfway. */
  .sim-lane .coin { animation: none; }
  .sim-lane .c1 { opacity: 1; left: calc(50% - 18px); }
  .Typewriter__cursor { animation: none; }
}

/* Narrow screens (phones, or large text): tables become stacked rows. */
@media (max-width: 40rem) {
  h1 { font-size: 1.6rem; }
  label.row { grid-template-columns: minmax(0, 1fr) 6.5rem auto; }
  form.inline { margin-left: 0.5rem; }

  .expenses thead { display: none; }
  .expenses, .expenses tbody, .expenses tr, .expenses td,
  .history, .history tbody, .history tr, .history td { display: block; }
  .expenses tr, .history tr { padding: 0.6rem 0; border-bottom: 2px solid var(--border); }
  .expenses tr:last-child, .history tr:last-child { border-bottom: 0; }
  .expenses td, .history td { border: 0; padding: 0.1rem 0; text-align: left; white-space: normal; min-width: 0; }
  .expenses td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
}
