/* Green phosphor terminal, matched to nathanskown.dev (same palette and fonts). */
:root {
  --g: #8dff9c;                                         /* phosphor */
  --amber: #ffb84d;
  --red: #ff5f56;
  --bg: #020402;
  --hi: color-mix(in srgb, var(--g) 55%, #ffffff);
  --fg: color-mix(in srgb, var(--g) 88%, #000000);
  --dim: color-mix(in srgb, var(--g) 66%, #000000);
  --mute: color-mix(in srgb, var(--g) 54%, #000000);
  --line: color-mix(in srgb, var(--g) 22%, #000000);
  --band: color-mix(in srgb, var(--g) 12%, #000000);
  --glow: color-mix(in srgb, var(--g) 38%, transparent);
  --panel: #030703;
  --picked: #55995e; /* darker than body text, 5.9:1 on the panel */
  --body: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --display: VT323, ui-monospace, monospace;
  --art: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overflow-y: auto; /* normally nothing scrolls here; if a screen is ever shorter than the layout, the page can still be scrolled */
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* The page stays flat so the story is easier to read. */

.app {
  height: var(--app-h, 100%);
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: 1400px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
  position: relative;
}

/* ---- top bar */
.top {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 2px 8px;
  font-size: 13px; letter-spacing: .06em;
  border-bottom: 1px solid var(--line);
}
.top .brand { color: var(--hi); font-weight: 600; text-decoration: none; }
.top .crumb a { color: var(--dim); text-decoration: none; }
.top .crumb a:hover, .top .brand:hover { color: var(--g); }
.top .crumb { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); white-space: nowrap; }
.flash-toggle { border: 1px solid var(--line); color: var(--dim); padding: 4px 8px; letter-spacing: .06em; font-size: 11px; white-space: nowrap; }
.flash-toggle[aria-pressed="false"] { color: var(--amber); border-color: var(--amber); }
.flash-toggle:focus-visible { outline: 1px solid var(--hi); outline-offset: 2px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--mute); display: block; }
body.playing .live i { background: var(--g); box-shadow: 0 0 8px var(--g); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.clock { color: var(--amber); font-family: var(--display); font-size: 22px; line-height: 1; letter-spacing: .04em; white-space: nowrap; text-shadow: 0 0 10px rgba(255,184,77,.35); }

/* ---- function keys */
.fkeys {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.fkeys::-webkit-scrollbar { display: none; }
.fkeys button {
  padding: 8px 14px; white-space: nowrap; color: var(--dim);
  border-right: 1px solid var(--line); letter-spacing: .06em; font-size: 13px;
}
.fkeys button b { color: var(--mute); font-weight: 400; }
.fkeys button:hover, .fkeys button:focus-visible { background: var(--band); color: var(--hi); outline: none; }
.fkeys button:hover b, .fkeys button:focus-visible b { color: var(--hi); }
.menu-toggle { display: none; border: 1px solid var(--line); color: var(--dim); padding: 2px 8px; letter-spacing: .08em; font-size: 12px; font-family: var(--body); }
.menu-toggle:focus-visible { outline: 1px solid var(--hi); outline-offset: 2px; }

/* ---- ticker */
.ticker { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); font-size: 12.5px; letter-spacing: .04em; overflow: hidden; }
.tick-label { background: var(--amber); color: #120c00; font-weight: 600; padding: 5px 10px; white-space: nowrap; }
.tick-track { flex: 1; min-width: 0; overflow: hidden; position: relative; }
.tick-run { display: inline-block; white-space: nowrap; padding: 5px 0; color: var(--fg); animation: tick 70s linear infinite; }
.tick-run span { padding: 0 18px; border-right: 1px solid var(--line); }
.tick-run .dn { color: var(--red); }
.tick-run .up { color: var(--g); }
@keyframes tick { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---- layout */
.grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding-top: 12px; }
.main { min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.side {
  position: fixed; inset: 0; z-index: 40; background: var(--bg);
  padding-block: max(14px, env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
  transform: translateX(100%);
}
body.show-side .side { transform: none; }
.side-close { display: block; align-self: flex-end; color: var(--hi); border: 1px solid var(--line); padding: 6px 12px; letter-spacing: .08em; }

.panel { border: 1px solid var(--line); background: var(--panel); position: relative; }
.panel-h {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--display); font-size: 19px; line-height: 1; letter-spacing: .08em;
  color: var(--hi); padding: 7px 10px 6px; border-bottom: 1px solid var(--line); background: var(--band);
}
.panel-h.sub { border-top: 1px solid var(--line); }
.panel-h .legend { font-family: var(--body); font-size: 11px; color: var(--dim); text-shadow: none; }

/* ---- scene */
.scene { flex: none; }
.art-wrap { padding: 0; overflow: hidden; }
/* The picture is 16:9. On a short desktop window it stays 16:9 and narrows
   so the command line and a full page of story stay on screen. Phones set their own cap. */
.scene-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #030703;
  overflow: hidden;
  /* Shrink on a short window, including while the phone keyboard is up (--app-h), and stay 16:9.
     34dvh alone leaves the story about one line tall at 800px, so the pager breaks every line. */
  --scene-cap: max(120px, min(34dvh, calc(var(--app-h, 100dvh) - 700px)));
  width: min(100%, calc(var(--scene-cap) * 16 / 9));
  max-height: var(--scene-cap);
  margin-inline: auto;
}
#sceneCanvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; z-index: 0; }
.scene-image {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; z-index: 1; pointer-events: none;
}
.scene-image[hidden] { display: none; }
.scene-image.is-shown { opacity: 1; z-index: 2; }
/* Desktop keeps labels on the canvas. When a picture covers that canvas, the same strip used on phones sits under the picture so the live numbers stay readable. */
.art-wrap.has-art .scene-readout.show {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px;
  max-height: 72px; overflow: auto; scrollbar-width: thin;
  padding: 6px 10px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.3;
}
.art-wrap.has-art .ro-row { display: flex; flex-wrap: wrap; column-gap: .4em; min-width: 0; }
.art-wrap.has-art .ro-row.solo { grid-column: 1 / -1; }
.art-wrap.has-art .ro-row .k { color: var(--dim); }
.art-wrap.has-art .ro-row .v { color: var(--fg); }
.art-wrap.has-art .ro-chip { display: flex; align-items: center; gap: 6px; min-width: 0; }
.art-wrap.has-art .ro-chip i { width: 8px; height: 8px; border-radius: 50%; flex: none; box-sizing: border-box; }
.art-wrap.has-art .ro-chip.off { color: var(--dim); }
.art-wrap.has-art .ro-chip.off i { border: 1px solid var(--dim); }
.art-wrap.has-art .ro-chip.on i { background: var(--g); }
@media (prefers-reduced-motion: no-preference) {
  .scene-image { transition: opacity .4s linear; }
}
.scene.person { border-color: var(--dim); }
.art { margin: 0; font-family: var(--art); line-height: 1.12; color: var(--g); white-space: pre; font-size: 13px; }
.scene.static .art { color: var(--red); animation: jitter .12s steps(2) 5; }
@keyframes jitter { 50% { transform: translateX(2px); } }
.scene.ending { border-color: var(--amber); }
.scene.ending .art { color: var(--amber); text-shadow: 0 0 2px var(--amber), 0 0 14px rgba(255,184,77,.35); }

/* ---- feed */
.feed { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.feed-scroll { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; padding: 14px 16px 8px; cursor: text; }
.out { flex: 1; min-height: 0; overflow: hidden; max-width: 78ch; }
.pager { flex: none; display: flex; align-items: center; gap: 8px; max-width: 78ch; padding-top: 6px; }
.pager[hidden] { display: none; }
.page-btn { border: 1px solid var(--line); color: var(--hi); padding: 4px 10px; min-height: 32px; letter-spacing: .06em; }
.page-btn:hover, .page-btn:focus-visible { background: var(--band); border-color: var(--dim); outline: none; }
.page-btn:disabled { visibility: hidden; }
.page-count { flex: 1; text-align: center; color: var(--dim); letter-spacing: .08em; font-size: 12px; }
.ln { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 .8em; animation: in .2s ease-out both; }
.out .ln { font-size: 15px; line-height: 1.55; }
@keyframes in { from { opacity: 0; } to { opacity: 1; } }

.ln-echo { color: var(--dim); margin-top: 1.2em; margin-bottom: .5em; }
.ln-echo::before { content: ""; }
.ln-shell { color: var(--fg); margin-bottom: .25em; }
.ln-boot { display: flex; gap: 10px; color: var(--fg); margin: 0 0 .15em; font-size: 13px; }
.ln-boot .lead { flex: 1; border-bottom: 1px dotted var(--mute); transform: translateY(-.45em); }
.ln-boot .ok { color: var(--hi); white-space: nowrap; }
.ln-boot > span:first-child { min-width: 0; }
.ln-banner { font-family: var(--display); color: var(--hi); font-size: 40px; line-height: 1; letter-spacing: .12em; margin: .3em 0 .2em; }
.ln-title { font-family: var(--display); color: var(--hi); font-size: 24px; line-height: 1.1; letter-spacing: .06em; margin: 1.1em 0 .45em; text-transform: uppercase; border-bottom: 1px solid var(--line); padding-bottom: .2em; }
.ln-text, .ln-intro { color: var(--fg); }
.ln-event { color: var(--amber); border-left: 2px solid var(--amber); padding-left: 12px; }
.ln-death { color: var(--red); border-left: 2px solid var(--red); padding-left: 12px; }
.ln-choice {
  display: block; width: 100%; text-align: left;
  color: var(--hi); margin: 0 0 .3em; padding: 4px 10px 4px calc(10px + 2.2ch); text-indent: -2.2ch;
  border: 1px solid var(--line); background: transparent; cursor: pointer;
}
.ln-choice:hover, .ln-choice:focus-visible { background: var(--band); border-color: var(--dim); outline: none; }
.ln-choice.picked { color: var(--picked); border-style: dashed; }
.ln-choice.picked:hover, .ln-choice.picked:focus-visible { color: var(--fg); border-style: dashed; }
.ln-choice:disabled { color: var(--mute); border-color: transparent; cursor: default; pointer-events: none; }
.ln-choice:disabled:hover, .ln-choice:disabled:focus-visible { background: transparent; border-color: transparent; }
.ln-note { color: var(--g); }
.ln-dim { color: var(--dim); }
.ln-ending-title { font-family: var(--display); color: var(--amber); font-size: 34px; line-height: 1; letter-spacing: .14em; text-transform: uppercase; margin: 1.2em 0 .6em; padding-top: .6em; border-top: 1px solid var(--amber); text-shadow: 0 0 12px rgba(255,184,77,.4); }
.ln-ending { color: var(--fg); }
.ln-afterword-title { font-family: var(--display); color: var(--amber); font-size: 22px; letter-spacing: .14em; margin: 1.4em 0 .5em; }
.ln-afterword { color: var(--fg); margin: 0 0 .35em; padding-left: 12px; border-left: 1px solid var(--line); font-size: .95em; }

/* tappable shortcuts above the prompt */
.chips-wrap { position: relative; flex: none; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-width: 78ch; margin: 0; padding: 0 16px 6px; background: var(--panel); position: relative; z-index: 2; }
/* Sits over the row. It does not take taps, and it is not in the tab order or the screen reader. */
.chips-hint { display: none; position: absolute; z-index: 3; top: 0; bottom: 0; width: 48px; pointer-events: none; }
.chips-hint-right { right: 0; background: linear-gradient(to right, transparent, var(--panel) 78%); }
.chips-hint-left { left: 0; background: linear-gradient(to left, transparent, var(--panel) 78%); }
.chips:empty { display: none; }
.chip {
  font-size: 12px; letter-spacing: .04em; color: var(--fg);
  border: 1px solid var(--line); padding: 5px 9px; background: var(--panel);
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.chip b { color: var(--dim); font-weight: 500; margin-right: 4px; }
.chip:hover, .chip:focus-visible { background: var(--band); border-color: var(--dim); color: var(--hi); outline: none; }
.chip.go b { color: var(--g); }
.chip .mins { color: var(--amber); margin-left: 3px; font-size: .85em; }
.map-walks { margin: 6px 0 0; color: var(--dim); font-size: 12px; line-height: 1.4; }
.map-walks:empty { display: none; }
.chip.talk b { color: var(--amber); }
.chip.alt { border-color: var(--amber); color: var(--amber); }
.chip.picked, .chip.picked b { color: var(--picked); }
.chip.picked { border-style: dashed; }
.chip.picked:hover, .chip.picked:focus-visible,
.chip.picked:hover b, .chip.picked:focus-visible b { color: var(--fg); border-style: dashed; }

/* fallback box when the clipboard isn't available */
.copybox { width: 100%; min-height: 120px; background: var(--panel); color: var(--fg); border: 1px solid var(--dim); font: 12px/1.5 var(--body); padding: 8px; margin: 0 0 .8em; }

.cmd { display: flex; align-items: baseline; gap: .6em; flex: none; margin: 0; padding: 8px 16px 12px; border-top: 1px solid var(--line); background: var(--panel); position: relative; z-index: 2; }
.prompt { color: var(--g); white-space: nowrap; }
body.playing .prompt { color: var(--amber); }
#input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--hi); font: inherit; font-size: 16px; caret-color: var(--g); padding: 0; }

/* ---- side panels */
.status { margin: 0; padding: 8px 10px 10px; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 12.5px; }
.status dt { color: var(--dim); letter-spacing: .05em; }
.status dd { margin: 0; text-align: right; color: var(--fg); }
.status dd.ok { color: var(--g); }
.status dd.warn { color: var(--amber); }
.status dd.bad { color: var(--red); }
.status .big { grid-column: 1 / -1; font-family: var(--display); font-size: 30px; line-height: 1; color: var(--amber); display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.status .big small { font-family: var(--body); font-size: 11px; color: var(--dim); letter-spacing: .05em; }

.map-wrap { padding: 8px 10px 10px; overflow: hidden; }
.map { margin: 0; font-family: var(--art); font-size: 11.5px; line-height: 1.18; color: var(--mute); white-space: pre; }
.map .node { color: var(--mute); }
.map .seen { color: var(--fg); }
.map button { font: inherit; line-height: inherit; letter-spacing: inherit; padding: 0; margin: 0; display: inline; vertical-align: baseline; color: inherit; }
.map .near { color: var(--hi); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.map .near:hover, .map button.near:focus-visible { background: var(--band); outline: 1px solid var(--hi); outline-offset: 1px; }
.map .here { background: var(--g); color: var(--bg); text-shadow: none; animation: pulse 1.6s infinite; }

.list { list-style: none; margin: 0; padding: 8px 10px 10px; font-size: 12.5px; }
.list li { padding: 2px 0; color: var(--fg); }
.list li::before { content: "▸ "; color: var(--mute); }
.list li.empty { color: var(--mute); }
.list li.empty::before { content: ""; }
.list li.note { color: var(--dim); }

/* ---- full-screen flash for the detonation */
.flash { position: fixed; inset: 0; background: #f4fff5; opacity: 0; pointer-events: none; z-index: 60; }
.flash.go { animation: flash 2.4s ease-out; }
.flash.soft { animation: flash-soft 1.4s ease-out; }
@keyframes flash { 0% { opacity: 0; } 4% { opacity: 1; } 18% { opacity: .9; } 100% { opacity: 0; } }
@keyframes flash-soft { 0% { opacity: 0; } 6% { opacity: .35; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .app, .tick-run, .ln, .live i, .map .here, .scene.static .art, .scene-image, .side { animation: none !important; transition: none !important; }
  .ticker { height: 28px; overflow: hidden; }
  .tick-track { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .tick-track::-webkit-scrollbar { display: none; }
  .tick-track:focus-visible { outline: 1px solid var(--amber); outline-offset: -2px; }
  .tick-run {
    display: block; white-space: nowrap; width: max-content; max-width: none;
    overflow: visible; text-overflow: clip; transition: none;
  }
  .flash.go, .flash.soft, .chips-hint { animation: none; transition: none; }
}
body.no-flash .flash.go, body.no-flash .flash.soft, body.no-flash .scene.static .art { animation: none; }

/* ---- narrower screens: map/status/inventory become a drawer behind 3) MAP */
@media (max-width: 960px) {
  .map { font-size: 12.5px; }
}
@media (max-width: 600px) {
  body { font-size: 13.5px; }
  .app { padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)); }
  .ticker { display: none; }
  .top {
    height: 56px; max-height: 56px; padding: 0 2px; gap: 8px; font-size: 13px;
    padding-left: max(2px, env(safe-area-inset-left, 0px));
    padding-right: max(2px, env(safe-area-inset-right, 0px));
  }
  .top .crumb, .top .live { display: none; }
  .top .brand { min-height: 44px; }
  .clock { font-size: 22px; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; height: 44px; padding: 0 10px; }
  .fkeys {
    display: none;
    position: absolute; z-index: 35; top: 56px; left: 0; right: 0;
    background: var(--bg); border-bottom: 1px solid var(--line); flex-wrap: wrap;
  }
  body.nav-open .fkeys { display: flex; }
  #scene .panel-h { padding: 3px 8px; min-height: 28px; max-height: 32px; font-size: 16px; }
  .fkeys button { padding: 7px 10px; font-size: 12px; }
  .art-wrap { height: auto; display: flex; flex-direction: column; }
  #sceneCanvas { position: absolute; inset: 0; flex: none; min-height: 0; width: 100%; height: 100%; }
  .scene-readout.show, .art-wrap.has-art .scene-readout.show {
    display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px;
    flex: 0 1 auto; max-height: 84px; overflow: auto; scrollbar-width: thin;
    padding: 6px 8px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.3;
  }
  /* A short amber wash and a 2px edge, only while more rows sit below. Not a solid band over the last line. */
  .scene-readout.more {
    background-image: linear-gradient(to bottom, transparent calc(100% - 7px), rgba(255, 184, 77, .28));
    box-shadow: inset 0 -2px 0 rgba(255, 184, 77, .95);
  }
  .scene-readout:focus-visible { outline: 1px solid var(--amber); outline-offset: -2px; }
  .ro-row { display: flex; flex-wrap: wrap; column-gap: .4em; min-width: 0; }
  .ro-row.solo { grid-column: 1 / -1; }
  .ro-row .k { color: var(--dim); }
  .ro-row .v { color: var(--fg); }
  .ro-chip { display: flex; align-items: center; gap: 6px; min-width: 0; }
  .ro-chip i { width: 8px; height: 8px; border-radius: 50%; flex: none; box-sizing: border-box; }
  .ro-chip.off { color: var(--dim); }
  .ro-chip.off i { border: 1px solid var(--dim); }
  .ro-chip.on i { background: var(--g); }
  #sceneIdx { display: none; }
  #sceneTitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .ln-banner { font-size: 32px; }
  .ln-title { font-size: 21px; }
  .ln-ending-title { font-size: 27px; }
  .feed-scroll { padding: 12px 12px 10px; }
  .chips {
    flex-wrap: nowrap; overflow-x: auto; max-width: none;
    padding: 4px 12px 6px; gap: 6px; scrollbar-width: none;
    scroll-padding-inline: 16px;
  }
  .chips::-webkit-scrollbar { display: none; }
  .chips.more ~ .chips-hint-right,
  .chips.scrolled ~ .chips-hint-left { display: block; }
  .chip, .page-btn, .fkeys button, .ln-choice, .menu-toggle { flex: none; min-width: 44px; min-height: 44px; }
  .chip { max-width: none; }
  #input { font-size: 16px; }
  .cmd { padding: 8px 12px max(10px, env(safe-area-inset-bottom, 0px)); }
  .scene-frame { --scene-cap: min(156px, max(96px, calc(var(--app-h, 100dvh) - 560px))); }
}
/* Short window or the phone keyboard (--app-h around 500px): drop the picture
   and the chip row so the prompt and several lines of story stay on screen. */
body.compact .scene-frame { display: none; }
body.compact .chips { display: none; }
@media (max-width: 600px) {
  #scene.person > .panel-h { display: none; }
  .talk-choices { max-height: 122px; overflow: auto; scrollbar-width: thin; }
  .talk-choices.more {
    -webkit-mask-image: linear-gradient(#000 0, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(#000 0, #000 calc(100% - 28px), transparent);
  }
}
body.compact .scene-readout.show,
body.compact .art-wrap.has-art .scene-readout.show {
  max-height: 40px; padding-top: 3px; padding-bottom: 3px;
}
body.compact .panel-h { padding: 4px 8px; }
body.compact .top .brand { min-height: 44px; }
/* The picture is already hidden here, so the header control that hides it is too. */
body.compact .scene-toggle,
body.compact .chips.more ~ .chips-hint,
body.compact .chips.scrolled ~ .chips-hint { display: none; }

/* Phones and touch screens: every tap target at least 44px tall (site rule) */
@media (max-width: 600px), (pointer: coarse) {
  .chip, .fkeys button, .side-close, .flash-toggle, .page-btn { min-height: 44px; display: inline-flex; align-items: center; gap: .45em; }
  .ln-choice { min-height: 44px; }
  .top .brand, .top .crumb a { display: inline-flex; align-items: center; min-height: 44px; }
}

/* Screen-reader-only heading, and a message if JavaScript is off */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.noscript { color: var(--amber); padding: 12px 16px; border: 1px solid var(--amber); margin: 0 0 12px; }

/* Phones: let the reader hide the scene. Compact mode hides this button while the picture is already gone. */
.scene-toggle { display: none; border: 1px solid var(--line); color: var(--dim); padding: 4px 8px; letter-spacing: .06em; font-size: 11px; white-space: nowrap; font-family: var(--body); text-shadow: none; }
.scene-toggle:focus-visible { outline: 1px solid var(--hi); outline-offset: 2px; }
@media (max-width: 960px) {
  .scene-toggle { display: inline-flex; align-items: center; min-height: 44px; }
  body.scene-hidden .art-wrap { display: none; }
}
@media (max-width: 600px) {
  .top .brand, .menu-toggle, .chip, .page-btn, .fkeys button, .ln-choice, .talk-choice { min-width: 44px; min-height: 44px; }
}

/* Talk: a short ID card, not a 16:9 scene panel. The facts sit beside the portrait. */
.person-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 3; }
#scene.person .art-wrap {
  display: flex; flex-direction: row; align-items: center; gap: 12px; padding: 8px 12px; height: auto;
}
#scene.person .scene-frame {
  aspect-ratio: 1 / 1; width: 80px; height: 80px; max-height: 80px; margin-inline: 0; flex: none;
}
#scene.person .scene-readout.show,
#scene.person .art-wrap.has-art .scene-readout.show {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 10px;
  flex: 1; min-width: 0; max-height: none; overflow: visible;
  padding: 0; border-top: 0; font-size: 13px; line-height: 1.35;
  background-image: none; box-shadow: none;
}
#scene.person .ro-row { display: flex; flex-wrap: wrap; column-gap: .45em; align-items: baseline; }
#scene.person .ro-row .k { margin-right: .35em; }
#scene.person .ro-row.solo { grid-column: 1 / -1; font-family: var(--display); font-size: 26px; letter-spacing: .04em; line-height: 1; }
#scene.person .ro-row.solo .k { color: var(--hi); margin-right: 0; }
@media (max-width: 600px) {
  #scene.person .scene-frame { width: 56px; height: 56px; max-height: 56px; }
  #scene.person .art-wrap { padding: 6px 8px; gap: 8px; flex-direction: row; max-height: 72px; align-items: center; }
  #scene.person .scene-readout.show { max-height: none; overflow: hidden; }
  #scene.person .ro-row { flex-wrap: nowrap; min-width: 0; }
  #scene.person .ro-row.solo { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #scene.person .ro-row:not(.solo),
  #scene.person .ro-row .v { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  #scene.person.card-tight .ro-row:not(.solo) { display: none; }
}
.talk-choices { display: none; flex: none; flex-direction: column; gap: 6px; padding: 0 12px 8px; }
.talk-choices:not([hidden]) { display: flex; }
.talk-choice {
  display: flex; align-items: center; width: 100%; min-height: 44px; box-sizing: border-box;
  text-align: left; white-space: normal; border: 1px solid var(--line); color: var(--hi);
  padding: 8px 10px; background: transparent;
}
.talk-choice.picked { color: var(--picked); border-style: dashed; }
.talk-choice:hover, .talk-choice:focus-visible { background: var(--band); border-color: var(--dim); outline: none; }
body.compact #scene.person .scene-frame { display: none; }
body.compact #scene.person .art-wrap { max-height: none; min-height: 40px; padding: 4px 8px; }
body.compact #scene.person .scene-readout.show,
body.compact #scene.person .art-wrap.has-art .scene-readout.show {
  display: flex; align-items: center; min-height: 32px; max-height: 40px; overflow: hidden; padding: 0;
}
body.compact #scene.person .ro-row:not(.solo) { display: none; }
body.compact #scene.person .ro-row.solo { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- notes: what you've learned and what's still open */
.fk-count { color: var(--amber); margin-left: .35em; }
.list.notes li { padding: 5px 0; line-height: 1.45; border-bottom: 1px dotted var(--line); }
.list.notes li:last-child { border-bottom: 0; }
.list.notes li.open::before { content: "▸ "; color: var(--amber); }
.list.notes li.done { color: var(--dim); }
.list.notes li.done::before { content: "✓ "; color: var(--g); }
.list.notes li.missed { color: var(--mute); }
.list.notes li.missed::before { content: "✗ "; color: var(--red); }
.list.notes .due { color: var(--amber); white-space: nowrap; font-size: .92em; }
.list.notes li.missed .due { color: var(--red); }

/* ---- phones: more room for the story */
@media (max-width: 600px) {
  /* Place facts sit beside the picture, not under it. */
  #scene:not(.person) .art-wrap.has-art { flex-direction: row; align-items: stretch; }
  #scene:not(.person) .art-wrap.has-art .scene-frame {
    flex: none; margin-inline: 0; height: var(--scene-cap); max-height: var(--scene-cap);
    width: calc(var(--scene-cap) * 16 / 9); max-width: 58%;
  }
  #scene:not(.person) .art-wrap.has-art .scene-readout.show {
    flex: 1; min-width: 0; grid-template-columns: 1fr; align-content: start; gap: 2px;
    max-height: var(--scene-cap); border-top: 0; border-left: 1px solid var(--line); font-size: 12px;
  }
  /* While more pages are left, the chip row and the answers wait for the last page. */
  body.pages-more .chips-wrap, body.pages-more .talk-choices { display: none; }
  /* Room for about five answers before the list scrolls. */
  .talk-choices { max-height: min(280px, calc(var(--app-h, 100dvh) * .42)); }
}
/* Keyboard up or a short window: leave the story a few lines above the answers. */
@media (max-width: 600px) {
  body.compact .talk-choices { max-height: calc(var(--app-h, 100dvh) * .3); }
}
/* If one sentence is still taller than the space left, it scrolls instead of being cut off. */
@media (max-width: 600px) {
  .out { overflow-y: auto; scrollbar-width: thin; }
}

/* ---- title card: one plain sentence, length and endings, and big buttons */
.out .ln.ln-lead { color: var(--hi); font-size: 17px; line-height: 1.5; }
/* The PLEASE HOLD banner at its intended size (".out .ln" was shrinking it to body size). */
.out .ln.ln-banner { font-size: 44px; line-height: 1; }
@media (max-width: 600px) { .out .ln.ln-banner { font-size: 38px; } }
.chips.title-chips { flex-wrap: wrap; gap: 10px; }
.chip.big { min-height: 56px; padding: 0 22px; font-size: 18px; letter-spacing: .06em; }
@media (max-width: 600px) {
  .chips.title-chips { flex-wrap: wrap; overflow-x: visible; }
  .chip.big { flex: 1 1 100%; justify-content: center; }
}

/* ---- action buttons (FILL BATHTUB, CLOSE DOOR…): amber like PLAY, with a DO key */
.chip.act b { color: var(--amber); }

/* Compact (short window or keyboard up): the room or ending readout never eats the story.
   Talk screens keep their one-line name strip (the #scene.person rules above). */
body.compact #scene:not(.person) .scene-readout.show,
body.compact #scene:not(.person) .art-wrap.has-art .scene-readout.show { display: none; }
body.compact #scene:not(.person) .art-wrap { min-height: 0; }
/* Phones: the title card is the whole first screen; the scene picture would only repeat it. */
@media (max-width: 600px) { body.on-title #scene { display: none; } }
/* Phones: 16px story text. Measured: one visible line fewer at 390x844, 375x667 and 360x740 (within ±1 of #96). */
@media (max-width: 600px) { .out .ln { font-size: 16px; } }
