:root {
  --bg: #0f1115;
  --card: #181b22;
  --fg: #e8eaed;
  --muted: #9aa0aa;
  --accent: #4f8cff;
  --green: #3ddc84;
  --red: #ff6b6b;
  --border: #2a2f3a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
}

.brand { color: var(--fg); text-decoration: none; font-weight: 700; }

main { max-width: 920px; margin: 28px auto; padding: 0 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 28px;
}
.card.center { text-align: center; }

h1 { margin-top: 0; font-size: 26px; }
.lede { color: var(--muted); line-height: 1.5; }
/* Pre-study sound check (templates/audio_check.html). */
.audio-card { max-width: 460px; margin: 0 auto; text-align: center; }
/* Accent-tinted speaker badge above the heading. */
.audio-icon {
  width: 64px; height: 64px; margin: 2px auto 12px;
  display: grid; place-items: center; font-size: 30px;
  border-radius: 50%;
  background: rgba(79, 140, 255, 0.12);
  border: 1px solid rgba(79, 140, 255, 0.35);
}
.audio-card .lede { margin: 0 auto 8px; max-width: 36ch; }
/* Group the "keep your sound on" reminder tight under the intro paragraph,
   then leave clear space before the play button. Block-level (fit-content +
   auto margins) so it stays centered AND its bottom margin reliably spaces the
   play button below it (an inline-flex element's vertical margin would not). */
.audio-card .audio-reminder {
  display: flex; width: fit-content; margin: 0 auto 36px;
}

/* Prominent accent play button with a gentle attention pulse (stops after the
   first play — see .played). */
.audio-play {
  position: relative;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 26px;
  font-size: 16px; font-weight: 700;
  color: #fff; background: var(--accent);
  border: none; border-radius: 999px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(79, 140, 255, 0.35);
  transition: transform 0.08s ease, filter 0.15s ease;
}
.audio-play:hover { filter: brightness(1.08); }
.audio-play:active { transform: translateY(1px); }
.audio-play-icon { font-size: 13px; }
.audio-play::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  animation: audio-pulse 2s ease-out infinite;
}
.audio-play.played::after { animation: none; }
@keyframes audio-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(79, 140, 255, 0.45); }
  70%  { box-shadow: 0 0 0 14px rgba(79, 140, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 140, 255, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .audio-play::after { animation: none; }
}

.audio-check-status {
  min-height: 18px; margin: 12px 0 0; color: var(--muted); font-size: 13px;
}

/* Answer section, divided from the "listen" section above it. */
.audio-form {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--border);
}
.audio-q { font-size: 16px; font-weight: 600; color: var(--fg); }
/* Big, centered, code-style number field with an accent focus glow. */
.audio-input {
  width: 150px; padding: 14px 12px;
  background: #11141a; color: var(--fg);
  border: 1px solid var(--border); border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 30px; font-weight: 800; letter-spacing: 0.14em; text-align: center;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.audio-input::placeholder { color: #3a4150; }
.audio-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.25);
}
.audio-continue { width: 100%; max-width: 220px; margin-top: 2px; }
.form-error { color: var(--red); font-weight: 600; font-size: 14px; margin: 0; }

/* "Keep your sound on" reminder pill — shown on the sound-check page and on
   each (replay) feedback page, where the coach's feedback is spoken aloud. */
.audio-reminder {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  background: rgba(79, 140, 255, 0.12);
  border: 1px solid rgba(79, 140, 255, 0.35);
  color: var(--fg); font-size: 14px; font-weight: 600; line-height: 1.3;
}

.setup { display: flex; flex-direction: column; gap: 16px; max-width: 360px; }
.setup label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
select, input[type="number"], textarea {
  padding: 9px 10px;
  background: #11141a;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
}

/* Study forms (consent / demographics / survey) */
.consent-body { color: var(--fg); line-height: 1.55; font-size: 15px; }
.consent-body p { margin: 10px 0; }

/* Embedded consent PDF on the landing page */
.consent-doc {
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #11141a;
}
.consent-doc-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  font-size: 14px; color: var(--muted);
}
.consent-doc-head a { color: var(--accent); text-decoration: none; }
.consent-doc-head a:hover { text-decoration: underline; }
.consent-pdf { display: block; width: 100%; height: 460px; border: 0; }
.consent-doc .note { padding: 0 14px 12px; }

/* Instructions page */
.instructions h2 {
  font-size: 18px; margin: 24px 0 8px; border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.instructions p, .instructions li { line-height: 1.55; }
/* Put each sentence on its own line with a gap between them. We wrap sentences
   in block spans rather than styling <br>: Chrome ignores display/height on
   <br>, so the only reliable way is a real block box. Margin between adjacent
   blocks (each has content, so it can't self-collapse) gives the gap. */
.instructions .ln { display: block; }
.instructions .ln + .ln { margin-top: 0.6em; }
.rules { padding-left: 22px; }
.rules > li { margin: 8px 0; }
.rules ul { margin: 6px 0; }

/* Study roadmap (the "what to expect" panel). */
.roadmap { padding-left: 22px; }
.roadmap > li { margin: 10px 0; line-height: 1.5; }
.roadmap > li::marker { color: var(--accent); font-weight: 700; }
table.actions-table { width: 100%; border-collapse: collapse; margin: 8px 0; }
table.actions-table th, table.actions-table td {
  border: 1px solid var(--border); padding: 8px 12px; text-align: left;
  vertical-align: top; font-size: 14px;
}
table.actions-table th { color: var(--muted); font-weight: 600; }
table.actions-table code {
  background: #11141a; border: 1px solid var(--border); border-radius: 6px;
  padding: 1px 6px; font-size: 13px;
}
.instructions .ff-legend { justify-content: flex-start; margin: 8px 0 0; }

/* Instructions carousel (one page at a time) */
#instr-carousel { margin: 10px 0 4px; }
.instr-panel { min-height: 300px; }
.instr-panel h2 { margin-top: 4px; }

/* Enlarged building icons */
.building-demos {
  display: flex; flex-wrap: wrap; gap: 18px; margin: 14px 0;
  justify-content: center;
}
.building-demos figure {
  margin: 0; flex: 1 1 200px; max-width: 240px; text-align: center;
}
.building-demos.four figure { flex-basis: 170px; max-width: 200px; }
.building-icon {
  width: 150px; height: 150px; margin: 0 auto 10px;
  background: #f4f1ea; border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden;
}
.building-icon svg { display: block; width: 100%; height: 100%; }
.building-demos figcaption { font-size: 14px; color: #c3c9d4;
  line-height: 1.5; }
.building-demos figcaption b {
  display: inline-block; margin-bottom: 3px; font-size: 15px; color: var(--fg);
}

/* "Reading a building" — annotated icon beside numbered callouts */
.callout-figure {
  display: flex; flex-wrap: wrap; gap: 22px; align-items: center;
  margin: 14px 0;
}
.building-icon.annotated {
  width: 220px; height: 200px; background: #f4f1ea; flex: 0 0 auto;
}
.callouts { list-style: none; padding: 0; margin: 0; flex: 1 1 300px;
  display: flex; flex-direction: column; gap: 12px; }
.callouts li { line-height: 1.45; font-size: 14px; }
.callouts .cnum {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 13px; font-weight: 700; margin-right: 6px;
  vertical-align: middle;
}

label.checkbox {
  flex-direction: row; align-items: center; gap: 10px; font-size: 15px;
}
label.checkbox input { width: 18px; height: 18px; }
.survey { display: flex; flex-direction: column; gap: 18px; max-width: 640px; }
.survey label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
fieldset.likert {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
}
fieldset.likert legend { padding: 0 6px; font-size: 15px; }
fieldset.likert label {
  display: inline-flex; flex-direction: row; align-items: center; gap: 4px;
  margin-right: 14px; font-size: 14px;
}
.likert-ends { display: block; color: var(--muted); font-size: 12px;
  margin-top: 6px; }

/* Grouped post-task survey: a titled panel per topic (team / coach), each with
   labeled 5-point (or 6-point, +N/A) Likert rows. */
.survey-panel { border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.survey-panel > h2 { margin: 2px 0 6px; font-size: 18px; }
.survey-panel > .note { margin: 0 0 8px; }
fieldset.likert-q { border: none; padding: 0; margin: 6px 0 0; }
fieldset.likert-q:not(:last-of-type) {
  border-bottom: 1px solid var(--border); padding-bottom: 12px;
}
fieldset.likert-q + fieldset.likert-q { margin-top: 12px; }
fieldset.likert-q legend { padding: 0; font-size: 14px; font-weight: 400;
  line-height: 1.55; letter-spacing: 0.01em; margin-bottom: 10px; }
.likert-opts { display: flex; flex-wrap: wrap; gap: 8px; }
/* Each choice is a small card: the radio above its word label, stacked and
   centered; they share the row and wrap on narrow screens. */
.likert-opts .likert-opt {
  flex: 1 1 0; min-width: 88px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 6px;
  font-size: 12px; text-align: center; line-height: 1.25; cursor: pointer;
}
.likert-opts .likert-opt:hover { border-color: var(--accent); }
.likert-opts .likert-opt:has(input:checked) {
  border-color: var(--accent); background: rgba(90, 150, 255, 0.12);
}
.likert-opts .likert-opt.na { color: var(--muted); }
/* Open-ended coach questions (survey page 3): a clear prompt above a full-width
   text box, evenly spaced. The prompt is wrapped in its own .q-text span so the
   inline <b> doesn't split the flex-column label into stacked lines. */
.survey-comment { gap: 8px; margin-top: 16px; }
.survey-comment:first-of-type { margin-top: 0; }
.q-text { color: var(--fg); font-size: 14px; font-weight: 400;
  line-height: 1.55; letter-spacing: 0.01em; }
.survey-comment textarea {
  resize: vertical; min-height: 84px;
  /* A more visible contour than the default subtle --border. */
  border: 1px solid #3d4556;
}
.survey-comment textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.2);
}

/* Knowledge-check quiz */
/* A plain <div>/<p> question box — not <fieldset>/<legend>, whose special
   border-anchored caption clips a prompt that wraps to two lines (display/table/
   float workarounds all misbehave with the flex options). A <p> just wraps. */
.quiz-q {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px;
}
.quiz-q .quiz-prompt {
  margin: 0 0 8px; font-size: 15px; font-weight: 600; line-height: 1.4;
}
label.quiz-opt {
  display: flex; flex-direction: row; align-items: flex-start; gap: 10px;
  margin: 8px 0; font-size: 14px; cursor: pointer;
}
label.quiz-opt input { width: 16px; height: 16px; margin-top: 2px;
  flex: 0 0 auto; }

/* Quiz results (correct answers + pass/fail) */
.quiz-banner {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px;
  font-size: 15px; line-height: 1.5;
}
.quiz-banner.pass { border-color: var(--green); color: var(--green); }
.quiz-banner.fail { border-color: var(--red); color: var(--red); }
.quiz-banner b { color: var(--fg); }
.quiz-review { list-style: none; padding: 0; margin: 18px 0 0; }
.quiz-review-q {
  border: 1px solid var(--border); border-left-width: 4px; border-radius: 10px;
  padding: 12px 16px; margin: 12px 0;
}
.quiz-review-q.ok { border-left-color: var(--green); }
.quiz-review-q.bad { border-left-color: var(--red); }
.quiz-review-q .quiz-prompt {
  margin: 0 0 8px; font-size: 15px; font-weight: 600; line-height: 1.4;
}
.quiz-review-q .ans { margin: 4px 0; font-size: 14px; line-height: 1.45; }
.quiz-review-q .ans .mark { font-weight: 700; margin-right: 6px; }
.quiz-review-q .ans.correct { color: var(--green); }
.quiz-review-q .ans.wrong { color: var(--red); }

.primary, button.primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px 18px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.primary:hover { filter: brightness(1.08); }

/* Dev-only flow-jump bar (ALLOW_DEV_JUMP). Deliberately loud so it can't be
   mistaken for study UI; never shown in a deployed study. */
.dev-nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  padding: 7px 14px; font-size: 12.5px;
  background: repeating-linear-gradient(45deg, #2a2205, #2a2205 10px,
    #241d05 10px, #241d05 20px);
  border-bottom: 1px solid #6b5a12;
}
.dev-nav-label { color: #ffcf4d; font-weight: 700; letter-spacing: 0.02em; }
.dev-nav a { color: #ffe08a; text-decoration: none; padding: 2px 6px;
  border-radius: 5px; }
.dev-nav a:hover { background: rgba(255, 207, 77, 0.18); text-decoration: none; }
/* Grayed-out state for a disabled primary button (e.g. survey Submit before the
   last panel / all answers given). */
.primary:disabled,
.primary:disabled:hover {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

/* Game */
.frame-wrap { text-align: center; margin: 8px 0 16px; }
/* The SVG stage: a responsive square viewport. The full board is rendered into
   the inner .ff-pan layer, which JS scales (zoom) + translates (pan) so only a
   VIEW_CELLS window shows; the user drags to pan. */
.ff-stage {
  position: relative;
  width: 100%;
  max-width: 720px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  background: #f4f1ea;
  border: 1px solid var(--border);
}
.ff-stage.pannable { cursor: grab; touch-action: none; }
.ff-stage.pannable.grabbing { cursor: grabbing; }
/* The board is panned/zoomed via the SVG's own viewBox (see game.js
   applyTransform), NOT a CSS transform on this wrapper — a CSS transform
   promotes it to a compositing layer, which makes Chromium/WebKit ghost the
   SVG <text> (stray fire-return numbers floating in empty space). So: no
   transform / will-change here. */
.ff-pan {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.ff-stage svg { display: block; width: 100%; height: 100%; }

/* Minimap: a scaled copy of the whole board in the corner with a "you are here"
   rectangle. Shown only when the board is zoomed (panning is possible). */
.ff-minimap {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26%;
  max-width: 150px;
  aspect-ratio: 1 / 1;
  display: none;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 6px;
  box-shadow: 0 1px 7px rgba(0, 0, 0, 0.4);
  background: #f4f1ea;
  cursor: pointer;
  z-index: 5;
}
.ff-minimap-board { position: absolute; inset: 0; opacity: 0.92; }
/* The minimap's SVG must not eat pointer events — clicks go to the container. */
.ff-minimap-board svg { pointer-events: none; }
.ff-minimap-view {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #ff3b30;
  background: rgba(255, 59, 48, 0.14);
  pointer-events: none;
}

/* Zoom controls (corner, over the board). */
.ff-zoom {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 5;
}
.ff-zoom-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: rgba(24, 27, 34, 0.78);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
}
.ff-zoom-btn:hover { background: rgba(24, 27, 34, 0.95); }

/* --- Follow view mode (toggle button) ----------------------------------- */
/* Pan-mode controls off in follow mode; the view toggle off in pan mode. */
.ff-stage.mode-follow #minimap,
.ff-stage.mode-follow #zoom-ctrl { display: none !important; }
.ff-stage.mode-pan .ff-view-toggle { display: none; }

/* Small, semi-transparent button (top-right) to switch which view fills the
   board. Kept compact and see-through so it barely covers the map. It names
   the view it switches *to* (led by ⇄), so it reads as an action. */
.ff-view-toggle {
  position: absolute; top: 8px; right: 8px; z-index: 5;
  padding: 4px 9px; border-radius: 7px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(24, 27, 34, 0.5); color: rgba(255, 255, 255, 0.92);
  font-size: 12px; font-weight: 600; line-height: 1;
  backdrop-filter: blur(2px);
}
.ff-view-toggle:hover {
  background: rgba(24, 27, 34, 0.8); border-color: var(--accent);
}

/* Static illustration of the map controls in the instructions (not interactive:
   reuses the real .ff-minimap / .ff-zoom classes so it matches the live game).
   The main board is scaled+offset to mimic a zoomed-in view that the minimap's
   red box corresponds to. */
.map-demo-figure { margin: 10px 0 0; text-align: center; }
.map-demo-figure figcaption {
  margin-top: 8px; font-size: 15px; color: var(--fg); line-height: 1.55;
}
.map-demo-hint {
  margin: 9px auto 0;
  max-width: 380px;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
  color: var(--accent);
}
.map-demo-hint.done { color: var(--green); }
.map-demo {
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  background: #f4f1ea;
  border: 1px solid var(--border);
}
/* Panned/zoomed via the SVG viewBox in instructions.js (JS sets the initial
   window on load), not a CSS transform — a CSS transform composites the board
   and Chromium/WebKit then ghost the SVG <text> into empty space. */
.map-demo-board {
  position: absolute;
  inset: 0;
}
.map-demo svg { display: block; width: 100%; height: 100%; }
/* Interactive demo: same grab cursor as the live game when it can be panned. */
.map-demo.pannable { cursor: grab; touch-action: none; }
.map-demo.pannable.grabbing { cursor: grabbing; }
/* Static (non-interactive) example map — used in follow view mode, where there
   is no pan/zoom to demo. Same framing as .map-demo, minus the interactivity. */
.static-map {
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  background: #f4f1ea;
  border: 1px solid var(--border);
}
.static-map svg { display: block; width: 100%; height: 100%; }

/* Follow-mode view comparison: two example boards (first-person + bird's-eye)
   side by side, same size, wrapping on narrow screens. */
.view-compare {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}
.view-compare-item { flex: 1 1 220px; max-width: 280px; }
.view-compare-item .static-map { max-width: none; }
.view-compare-cap {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  text-align: center;
}

/* Legend mapping icons -> meaning so the scene is self-explanatory. Items are
   grouped by kind (agents / building material / building status / actions),
   one group per row. */
.ff-legend {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  font-size: 13px; color: var(--muted);
  margin: 0 auto 16px; max-width: 720px;
}
.ff-legend-group {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px;
}
.ff-legend span { display: inline-flex; align-items: center; gap: 5px; }
.ff-legend .ic { font-size: 16px; line-height: 1; }
/* Twemoji <img> icons (match the board); img.ic overrides the font sizing. */
.ff-legend img.ic { width: 18px; height: 18px; }

/* Inline Twemoji glyph in prose — same art as the board, sized to the text. */
img.ff-emoji {
  height: 1.15em; width: 1.15em; vertical-align: -0.2em;
  object-fit: contain;
}
.ff-legend .bar {
  display: inline-block; width: 7px; height: 14px; border-radius: 4px;
}
.ff-legend .bar.health { background: #2fa84f; }
.ff-legend .bar.fire { background: #ff5a1f; }

/* Burn-speed note under the legend: building materials -> fast/slow burn. */
.ff-burn-note {
  text-align: center; font-size: 13px; color: var(--muted);
  max-width: 720px; margin: -6px auto 16px; line-height: 1.5;
}
.ff-burn-note .ic {
  width: 18px; height: 18px; vertical-align: -0.35em;
}

.hud {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 36px;
  color: var(--muted); font-size: 14px; margin-bottom: 14px;
}
.hud b { color: var(--fg); }
/* Saved / Burned building tallies: a label followed by the identity icons. */
.hud-tally { display: inline-flex; align-items: center; gap: 6px; }
.bld-list { display: inline-flex; align-items: center; gap: 3px; }
.bld-list img.bld-ic { width: 18px; height: 18px; }
.bld-none { color: var(--muted); }

.options { display: flex; flex-wrap: wrap; gap: 10px; }
.option {
  background: #222734;
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
}
.option:hover { border-color: var(--accent); }

/* Banner marking the pre-Game-1 warm-up so it's never mistaken for the real
   game. */
.practice-banner {
  background: rgba(255, 200, 60, 0.12);
  border: 1px solid rgba(255, 200, 60, 0.5);
  color: #ffd766;
  border-radius: 10px;
  padding: 11px 14px;
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.5;
}
.practice-banner b { color: #ffe08a; }

/* Game-over overlay: an absolute scrim over the (frozen) board, so the outcome
   and the Next button land right on the game screen instead of below the fold.
   Lives inside .ff-stage (position: relative), above the minimap/zoom controls.
   Win/lose accent comes from the .win / .lose modifier (added by game.js). */
.game-over {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 17, 21, 0.62);
  backdrop-filter: blur(2px);
  animation: game-over-in 0.28s ease-out;
}
@keyframes game-over-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.game-over-card {
  max-width: 88%;
  padding: 22px 26px;
  border-radius: 12px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  animation: game-over-pop 0.28s ease-out;
}
@keyframes game-over-pop {
  from { transform: translateY(8px) scale(0.96); }
  to { transform: none; }
}
.result-title {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.result-text { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.practice-result-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
}
.game-over-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.game-over-actions form { margin: 0; }
.game-over-actions .option,
.game-over-actions .primary { min-height: 42px; margin: 0; }
/* Game-over summary bullets: inline-block so the list centers as a block
   within the centered card, while its items stay left-aligned. */
.result-stats {
  display: inline-block;
  text-align: left;
  margin: 0;
  padding-left: 1.2em;
  font-size: 15px;
  color: var(--fg);
  line-height: 1.65;
}
.result-stats li { margin: 3px 0; }
.result-stats .stat-label { color: var(--muted); margin-right: 6px; }
/* The actual numbers: a bold, tabular monospace so results read crisp and
   stand out from the muted labels. */
.result-stats .stat-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.game-over-card .primary { margin: 0; }
/* Win vs. lose accents (neutral copy: "Success!" / "Game Over"). */
.game-over.win .game-over-card { border-top-color: var(--green); }
.game-over.win .result-title { color: var(--green); }
.game-over.lose .game-over-card { border-top-color: var(--red); }
.game-over.lose .result-title { color: var(--red); }
/* Hide utility — !important so it always wins over element display rules
   (e.g. .fb-card-choices/.reflect set display:flex and are declared later, and
   a hidden table row must beat its table-row display). Everything toggles
   visibility by adding/removing this class, never via inline display. */
.hidden { display: none !important; }

/* Two-column game: board + HUD on the left, chat log + action buttons right. */
/* Study progress in the header: a left-to-right checklist of the whole
   experiment (done ✓ / current / upcoming), so the participant always knows how
   far along they are and what's left. Sits where the old step strip was. */
.exp-progress { min-width: 0; }
.exp-progress-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-flow: row wrap;
  align-items: center; justify-content: flex-end;
  gap: 2px 14px;
}
.exp-step {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; line-height: 1.2; white-space: nowrap;
}
.exp-step-mark { flex: 0 0 auto; width: 14px; text-align: center; font-size: 12px; }
.exp-step.done .exp-step-mark::before { content: "✓"; color: var(--green); }
.exp-step.current .exp-step-mark::before { content: "●"; color: var(--accent); }
.exp-step.upcoming .exp-step-mark::before { content: "○"; color: var(--muted); }
.exp-step.done .exp-step-label { color: var(--muted); }
.exp-step.current .exp-step-label { color: var(--accent); font-weight: 700; }
.exp-step.upcoming .exp-step-label { color: var(--muted); opacity: 0.7; }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.game-main { min-width: 0; }
.game-side { display: flex; flex-direction: column; gap: 14px; }

/* Chat log of the player's chosen actions (read-only — buttons drive it). */
.chat {
  border: 1px solid var(--border); border-radius: 10px;
  background: #11141a; display: flex; flex-direction: column; overflow: hidden;
}
.chat-head {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--muted);
}
.chat-log {
  padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
  /* Fixed height (not min..max) so the box never resizes as messages arrive —
     it stays this tall from the start and simply scrolls once it fills. */
  height: 360px; overflow-y: auto;
  /* Always reserve the scrollbar's width so text doesn't reflow (and re-wrap)
     the moment the log overflows and the scrollbar appears. */
  scrollbar-gutter: stable;
}
.chat-msg {
  padding: 8px 11px; border-radius: 10px; font-size: 14px; line-height: 1.4;
  max-width: 90%;
}
.chat-msg.you {
  align-self: flex-end; background: var(--accent); color: #fff;
  border-bottom-right-radius: 3px;
}
.chat-msg.robot {
  align-self: flex-start; background: #1f2530; color: var(--fg);
  border-bottom-left-radius: 3px;
}
/* Avatar prefix makes the sender obvious at a glance (paired with the side the
   bubble sits on): firefighter for you, robot for the teammate. */
.chat-msg.you::before { content: "🧑‍🚒 "; }
.chat-msg.robot::before { content: "🤖 "; }
/* Coach messages (feedback page): left-aligned like the robot, but with a
   mentor avatar and an accent stripe so the three voices — you / robot /
   coach — are distinguishable at a glance. */
.chat-msg.coach {
  align-self: flex-start; background: #1a2230; color: var(--fg);
  border-bottom-left-radius: 3px; border-left: 3px solid var(--accent);
}
.chat-msg.coach::before { content: "🧑‍🏫 "; }
.chat-msg.system {
  align-self: center; background: transparent; color: var(--muted);
  font-size: 12px; font-style: italic; padding: 2px 4px;
  /* Centered prompt: use the full log width (not the 90% bubble cap) so short
     prompts fit on one line, and rebalance rather than orphan a single word. */
  max-width: 100%; text-align: center; text-wrap: pretty;
}
/* The "waiting for your move" prompt flashes while the player is idle (removed
   by game.js as soon as they pick an action), to nudge them to act. */
.chat-msg.system.flash {
  color: #ff3b30; font-style: normal; font-weight: 800; font-size: 15px;
  animation: ff-chat-flash 1.1s ease-in-out infinite;
}
@keyframes ff-chat-flash {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* Feedback-page chat: sits under the did/should carousel; the coach greets,
   the robot acknowledges feedback about it, and the coach closes with a
   mandatory reflection question answered in the composer below. */
.feedback-chat { margin: 20px 0 8px; }
/* Paused indicator: a normal-flow strip above the board (covers no play area)
   plus a matching glow on the coach box, so it's clear the replay has stopped
   and the answer goes in that box. Amber = "your turn to act". */
.pause-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 14px; padding: 10px 14px;
  border: 1px solid #d99a2b; border-radius: 10px;
  background: rgba(217, 154, 43, 0.14); color: #f0c070;
  font-weight: 700; font-size: 14px;
}
.pause-dot { font-size: 16px; animation: pause-blink 1.1s ease-in-out infinite; }
@keyframes pause-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
/* Draw the eye to where the answer goes while paused. */
.feedback-chat.awaiting {
  border-radius: 10px;
  animation: awaiting-glow 1.4s ease-in-out infinite;
}
@keyframes awaiting-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 154, 43, 0.0); }
  50% { box-shadow: 0 0 0 3px rgba(217, 154, 43, 0.45); }
}
@media (prefers-reduced-motion: reduce) {
  .pause-dot, .feedback-chat.awaiting { animation: none; }
  .feedback-chat.awaiting { box-shadow: 0 0 0 3px rgba(217, 154, 43, 0.45); }
}
.reflect {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.reflect-input {
  flex: 1; resize: vertical; min-height: 46px; font: inherit;
  background: #0d0f14; color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.reflect-send { flex: 0 0 auto; align-self: stretch; }
.reflect.answered { opacity: 0.6; }

/* Replay coach feedback: each flagged moment is one bordered card (header +
   per-teammate suggestions), so it's clear where one piece of feedback starts
   and ends — distinct from the plain chat lines around it. */
.fb-card {
  align-self: stretch;
  border: 1px solid var(--accent); border-left-width: 4px;
  border-radius: 10px; background: rgba(79, 140, 255, 0.08);
  padding: 9px 12px; margin: 5px 0;
  display: flex; flex-direction: column; gap: 5px;
}
.fb-card-head {
  font-weight: 700; font-size: 12px; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.03em;
}
/* Feedback laid out as a table: [row label] · You · Robot · your response.
   Row 1 = "what the team did" + the question/answer buttons; row 2 = "what the
   team should do" + resume button (revealed only after answering). Fixed You /
   Robot columns let the participant read did-vs-should down each column. */
/* Fixed layout + explicit column widths (via the <colgroup>) so every feedback
   table has the *same* column sizes — they never reflow when labels differ or
   the chat box scrollbar appears. Long text wraps inside its column instead of
   forcing a horizontal scrollbar. */
.fb-table { display: table; width: 100%; table-layout: fixed;
            border-collapse: collapse; font-size: 14px; line-height: 1.4; }
.fb-table col.fb-col-label { width: 18%; }
.fb-table col.fb-col-you { width: 20%; }
.fb-table col.fb-col-robot { width: 20%; }
.fb-table col.fb-col-resp { width: 42%; }
.fb-table th, .fb-table td {
  border: 1px solid var(--border); padding: 7px 10px;
  text-align: left; vertical-align: top; overflow-wrap: anywhere;
}
.fb-table thead th, .fb-table .fb-rowhead {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.03em;
}
.fb-table .fb-corner { border: none; background: transparent; }
/* Landmark icon = the same Twemoji <img> the game/legend use (not an OS emoji,
   so it matches the board). */
.fb-table .fb-icon {
  width: 18px; height: 18px; vertical-align: -4px; margin-left: 3px;
}
/* You / Robot header icons: the same board icons, sized to the header text. */
.fb-table .fb-hd-icon { width: 16px; height: 16px; vertical-align: -3px; }
/* The coach's "was this the best move?" question + Yes / No / I-don't-know
   buttons, in a row within the (fixed-width) response cell; wrap only if it
   truly can't fit. */
.fb-card-q { font-size: 14px; line-height: 1.35; }
.fb-card-choices {
  display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap;
}
.fb-card-choices .fb-choice { white-space: nowrap; }
.fb-choice {
  flex: 1 1 0; min-width: 72px; padding: 8px 10px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px;
  background: #222734; color: var(--fg); font-size: 13px;
}
.fb-choice:hover:not(:disabled) { border-color: var(--accent); }
.fb-choice.chosen {
  border-color: var(--accent); background: rgba(79, 140, 255, 0.15);
  font-weight: 700;
}
.fb-choice:disabled:not(.chosen) { opacity: 0.5; cursor: default; }
/* The "Got it — resume" button: same choice-button shape/spacing, but filled
   with the accent so it reads as the go-forward action of the pause. */
.fb-resume {
  background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 700;
}
.fb-resume:hover:not(:disabled) { filter: brightness(1.08); }
.fb-resume:disabled { opacity: 0.5; cursor: default; }
/* In the feedback table the resume button fills its cell so it's an obvious
   full-width go-forward action. */
.fb-table .fb-resume-cell .fb-resume { width: 100%; }

/* Robot feedback card: same layout as the human's, but green instead of blue
   (border + header text + accents) so it's obvious the coach is talking about
   the robot's move, not the participant's own. */
.fb-card.fb-robot {
  border-color: var(--green);
  background: rgba(61, 220, 132, 0.08);
}
.fb-card.fb-robot .fb-card-head { color: var(--green); }
.fb-card.fb-robot .fb-choice:hover:not(:disabled) { border-color: var(--green); }
.fb-card.fb-robot .fb-choice.chosen {
  border-color: var(--green); background: rgba(61, 220, 132, 0.15);
}
.fb-card.fb-robot .fb-resume {
  background: var(--green); border-color: var(--green); color: #06231a;
}

/* In the side panel the action buttons stack full-width. */
.game-side .options { flex-direction: column; }
.game-side .option {
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 9px;
}
/* Building icon on the "Go to the …" buttons (matches the board icon). */
.option-icon { width: 22px; height: 22px; flex: 0 0 auto; }
/* "Think" is a meta control (pause the game), not an in-world action. It keeps
   the same fill/text color as the real action buttons (so an available Think
   never reads as grayed out); a dashed outline + a little top gap set it apart
   instead. Disabled dimming is inherited from .option:disabled. */
.game-side .option.think-option {
  margin-top: 4px; border-style: dashed;
}
.control-hint { color: var(--muted); font-size: 13px; margin: 2px 0 0; }

@media (max-width: 760px) {
  .game-layout { grid-template-columns: 1fr; }
  .game-side { order: 2; }
}

/* Static "screenshot" of the game screen in the instructions. Reuses the real
   .chat / .options / .option classes so it matches the live UI, but is a
   picture (pointer-events: none) — the buttons/board don't do anything. */
.ui-demo-figure { margin: 16px 0 6px; }
.ui-demo {
  display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 12px;
  align-items: start;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; background: #0e1116;
  pointer-events: none;  /* it's an illustration, not the real controls */
  /* Narrow + center the mock so the board (and its icons) render a bit
     smaller, while the chat/buttons column keeps its readable width. */
  max-width: 600px; margin: 0 auto;
}
.ui-demo-board {
  border-radius: 8px; overflow: hidden; background: #11141a;
}
.ui-demo-board svg { display: block; width: 100%; height: auto; }
/* Tighten the reused chat log so the mock isn't taller than it needs to be. */
.ui-demo .chat-log { height: auto; min-height: 0; max-height: none; }
.ui-demo .option { font-size: 13px; padding: 8px 11px; }
.ui-demo-figure figcaption {
  font-size: 14px; color: var(--muted); margin-top: 8px;
}
@media (max-width: 620px) {
  .ui-demo { grid-template-columns: 1fr; }
}

/* Feedback panels */
.panels { display: flex; flex-direction: column; gap: 22px; margin: 18px 0; }
.panel { border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.panel-head { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.did-should { display: flex; gap: 16px; flex-wrap: wrap; }
.did-should figure { margin: 0; flex: 1 1 320px; display: flex;
  flex-direction: column; }
.did-should .ff-stage { max-width: none;
  border-top-left-radius: 0; border-top-right-radius: 0; border-top: none; }
/* Prominent banner naming each render, sitting flush on top of the scene. */
.fig-title {
  font-size: 16px; font-weight: 800; text-align: center; letter-spacing: .2px;
  color: #fff; padding: 9px 12px;
  border-radius: 10px 10px 0 0;
}
.fig-title.did { background: var(--red); }
.fig-title.should { background: var(--green); }
/* Symmetric per-teammate action list under each render. */
figcaption { font-size: 14px; margin-top: 10px; }
figcaption .actor { display: flex; align-items: baseline; gap: 8px;
  margin: 4px 0; }
figcaption .actor .who { color: var(--muted); font-weight: 600;
  min-width: 78px; }
figcaption .actor b { color: var(--fg); }
figcaption.did .actor .who { color: var(--red); }
figcaption.should .actor .who { color: var(--green); }

/* Feedback carousel (one panel at a time) */
.carousel-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 16px;
}
.carousel-nav .position {
  color: var(--muted);
  font-size: 14px;
  min-width: 120px;
  text-align: center;
}
.option:disabled { opacity: 0.4; cursor: not-allowed; }
.option:disabled:hover { border-color: var(--border); }

.actions { margin-top: 22px; }
.primary.disabled { pointer-events: none; opacity: 0.45; }
.lock-hint { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* Train */
.spinner {
  width: 46px; height: 46px; margin: 22px auto;
  border: 5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.messages { list-style: none; padding: 0; color: var(--muted); }

/* Progress bar (coaching + training) */
.progress {
  width: 100%;
  max-width: 460px;
  height: 12px;
  margin: 16px auto 6px;
  background: #11141a;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}
/* Phases with no known total (e.g. "starting…") animate a sliding stripe. */
.progress.indeterminate .progress-bar {
  width: 40% !important;
  animation: indeterminate 1.1s ease-in-out infinite;
}
@keyframes indeterminate {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}
.progress-count { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

/* Summary */
table.summary { width: 100%; border-collapse: collapse; margin: 16px 0; }
table.summary th, table.summary td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: center;
}
table.summary th:first-child { text-align: left; color: var(--muted); }
.note { color: var(--muted); font-size: 14px; }
.note .msg { color: var(--fg); }
