/* ========================================
   THE BUILDER TRAIL — Warm/Clay terminal theme
   (adopted from the Claude Design gameplay screen)
   ======================================== */

:root {
  --paper: #e7e5df;
  --ink: #211d18;
  --backdrop: #14100c;

  --device: #0a0908;
  --panel: #100d0a;
  --panel-2: #16120d;
  --line: #221e18;
  --line-2: #2a2520;

  --text: #e9e3d6;
  --text-strong: #f4eee3;
  --muted: #9b9286;
  --muted-2: #6a6258;
  --faint: #534c44;

  --accent: #d97757;
  --accent-dim: rgba(217, 119, 87, 0.6);
  --accent-soft: rgba(217, 119, 87, 0.16);
  --accent-soft-2: rgba(217, 119, 87, 0.08);

  --gain: #6cc08a;
  --loss: #e0735a;
  --danger: #e0735a;
  --seg-off: #221e18;

  --mono: "JetBrains Mono", "SF Mono", "Cascadia Code", "Fira Code", "Consolas", monospace;
  --pixel: "Press Start 2P", "JetBrains Mono", monospace;

  --shadow: rgba(0, 0, 0, 0.42);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  background: var(--backdrop);
}

body {
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  padding: 28px;
  background:
    radial-gradient(120% 80% at 50% -8%, rgba(217, 119, 87, 0.07), transparent 52%),
    var(--backdrop);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input,
a {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

img {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* The whole game lives inside a dark "device" panel on warm paper. */
#game {
  position: relative;
  width: 100%;
  max-width: 1280px;
  margin: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--text);
  background: var(--device);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  box-shadow: 0 26px 64px var(--shadow);
  overflow: hidden;
}

/* Subtle CRT scanlines over the device. */
#game::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: repeating-linear-gradient(rgba(0, 0, 0, 0) 0 2px, rgba(0, 0, 0, 0.10) 2px 3px);
  opacity: 0.5;
}

#hud {
  flex-shrink: 0;
  z-index: 4;
}

#content {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-height: 0;
}

.dim { color: var(--muted); }

/* ============ HUD ============ */

.hud-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hud-id {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

/* Below the name/week bar: full-body character panel beside the 2x2 meter grid. */
.hud-body {
  display: flex;
  align-items: stretch;
  gap: 14px;
}

.hud-char {
  flex: none;
  width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: #161210;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  overflow: hidden;
}

/* Static full-body sprite (first frame of the idle sheet) — no animation. */
.hud-sprite {
  width: 74px;
  height: 140px;
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 444px 140px;
  image-rendering: auto;
}

.hud-sprite-builderguy { background-image: url("assets/avatars/BuilderGuy_idle.png"); }
.hud-sprite-buildergirl { background-image: url("assets/avatars/BuilderGirl_idle.png"); }

.hud-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 9px var(--accent-dim);
}

.hud-name {
  font-family: var(--pixel);
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-week {
  flex: none;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--muted);
}

/* Meters */

.meter-grid {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.meter {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 11px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
}

.meter-head {
  display: flex;
  align-items: center;
  gap: 7px;
}

.meter-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  color: var(--device);
  background: var(--muted);
}

.meter-name {
  flex: 1;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--muted);
}

.meter-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
}

.meter-segs {
  display: flex;
  gap: 3px;
  padding: 4px;
  background: #0c0a08;
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--line);
  transition: box-shadow 0.18s ease;
}

.seg {
  flex: 1;
  height: 12px;
  border-radius: 2px;
  background: var(--seg-off);
  transition: background 0.35s ease;
}

.seg.on { background: var(--accent); }
.seg.gain { background: var(--gain); }
.seg.loss { background: var(--loss); }

/* Hovered choice lights up the meters it touches (no direction). */
.meter.lit .meter-badge,
.meter.lit .meter-name { color: var(--accent); }
.meter.lit .meter-segs { box-shadow: 0 0 0 1px var(--accent), 0 0 12px var(--accent-soft); }
.meter.lit .meter-dot { opacity: 1; animation: btBlink 1s steps(2) infinite; }

/* Low meter quietly pulses a warning. */
.meter.low .meter-badge,
.meter.low .meter-name { color: var(--loss); }
.meter.low .meter-segs { box-shadow: 0 0 0 1px #6a2c20; animation: btDanger 1.3s ease-in-out infinite; }

/* On commit, the changed meter flashes and shakes. */
.meter.flash-up .meter-badge,
.meter.flash-up .meter-name { color: var(--gain); }
.meter.flash-down .meter-badge,
.meter.flash-down .meter-name { color: var(--loss); }
.meter.flash-up,
.meter.flash-down { animation: btShake 0.42s ease; }

/* Project / ship-credits row */

.project-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
}

.proj-arrow { color: var(--accent); }
.proj-name { color: var(--text-strong); font-weight: 500; }
.proj-name.dim { color: var(--muted); }

.proj-size {
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--muted);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 1px 6px;
}

.prog-bar {
  flex: 1;
  display: flex;
  gap: 2px;
  max-width: 340px;
}

.prog {
  flex: 1;
  height: 7px;
  border-radius: 1px;
  background: var(--seg-off);
}

.prog.on { background: var(--accent); }

.proj-pct { font-size: 9px; color: var(--muted-2); }
.proj-weeks { font-size: 10px; font-weight: 700; letter-spacing: 0.5px; color: var(--accent); white-space: nowrap; }
.proj-spacer { flex: 1; }
.proj-ship-label { font-size: 9px; letter-spacing: 1px; color: var(--muted-2); }

.credits { display: flex; gap: 3px; }

.credit {
  width: 9px;
  height: 14px;
  border-radius: 1px;
  background: var(--seg-off);
}

.credit.on { background: var(--accent); }

/* ============ DECISION / OUTCOME CARD ============ */

.decision-card {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(0, 600px);
  gap: 26px;
  align-items: stretch;
  animation: fadeIn 0.24s ease;
}

.decision-main {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 18px;
  min-width: 0;
  padding-top: 4px;
}

.card-kicker {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--accent);
}

.card-title {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.12;
  color: var(--text-strong);
  text-wrap: pretty;
}

.card-body {
  font-size: 15px;
  line-height: 1.6;
  color: #a39a8d;
  text-wrap: pretty;
}

.card-controls { margin-top: 4px; }

.choices {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.dchoice {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  color: inherit;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.dchoice:hover,
.dchoice:focus,
.dchoice.focused {
  outline: none;
  border-color: var(--accent);
  background: var(--accent-soft-2);
  transform: translateY(-1px);
}

.dchoice-index {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}

.dchoice-label {
  flex: 1;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text-strong);
}

.dchoice-affects {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--muted);
}

.affects-tag { color: var(--faint); letter-spacing: 1px; }

.dchoice-arrow { font-size: 18px; color: var(--faint); }

.choice-hintline {
  margin-top: 14px;
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--faint);
}

.btn-continue {
  width: 100%;
  padding: 17px;
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn-continue:hover,
.btn-continue:focus {
  outline: none;
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.memory-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  font-size: 11px;
  color: var(--muted);
}

/* The scene slot beside the card. */
.decision-scene {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  animation: btPop 0.25s ease;
  /* Fixed 4:3 slot — identical framing on desktop + mobile (art authored at 1200x900). */
  aspect-ratio: 4 / 3;
  align-self: start;
}

.decision-scene::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(130% 95% at 50% 36%, transparent 52%, rgba(8, 7, 6, 0.52) 100%);
}

.decision-scene .pixel-scene,
.decision-scene .scene-placeholder,
.decision-scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: none;
  border-radius: 0;
  background: #0c130b;
}

.decision-scene .scene-mood {
  width: 100%;
  height: 100%;
  min-height: 280px;
}

/* Direct-image scene frame (project select + shipped) — full art, object-fit cover. */
.ui-scene {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scene-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 100% at 50% 38%, transparent 62%, rgba(8, 7, 6, 0.4) 100%);
}

/* ============ PROJECT SELECT (two-column, mirrors gameplay) ============ */

.select-card {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(0, 600px);
  gap: 26px;
  align-items: stretch;
  animation: fadeIn 0.24s ease;
}

.select-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.select-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: 1px;
}

.select-ship { display: inline-flex; align-items: center; gap: 8px; }

.select-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 8px;
}

.select-kicker {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 3px 8px;
}

.select-title { font-size: 22px; font-weight: 700; color: var(--text-strong); }

.select-desc {
  font-size: 13px;
  line-height: 1.6;
  color: #8c8478;
  margin-bottom: 20px;
}

.prows { display: flex; flex-direction: column; gap: 12px; }

.prow {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  text-align: left;
  padding: 15px 17px;
  color: inherit;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.prow:hover,
.prow:focus,
.prow.focused {
  outline: none;
  border-color: var(--accent);
  background: var(--accent-soft-2);
  transform: translateY(-1px);
}

.prow-index {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: #1c1410;
  border: 1px solid #34241c;
  border-radius: 6px;
}

.prow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.prow-name { font-size: 15px; font-weight: 700; color: var(--text-strong); }
.prow-desc { font-size: 12px; color: #8c8478; line-height: 1.4; }

.prow-tags { display: flex; gap: 7px; flex: none; flex-wrap: wrap; justify-content: flex-end; }

.ptag {
  font-size: 10px;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 5px;
  padding: 3px 8px;
  white-space: nowrap;
}

.ptag.dim { color: var(--muted); background: #16120d; }
.ptag.small { color: var(--gain); background: #13201a; }
.ptag.medium { color: #d98a5a; background: #241813; }
.ptag.large { color: #e2b04a; background: #221c10; }

.select-scene {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  aspect-ratio: 4 / 3;
  align-self: start;
}

/* ============ SHIPPED CELEBRATION OVERLAY ============ */

.shipped-card {
  width: min(560px, 94vw);
  background: #0d0b09;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: btPop 0.3s ease;
}

.shipped-scene {
  position: relative;
  width: 100%;
  aspect-ratio: 1140 / 825;
}

.shipped-body { padding: 24px 28px 26px; text-align: center; }

.ship-credit-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
  padding: 6px 13px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  white-space: nowrap;
}

.scb-label { font-size: 10px; letter-spacing: 2px; color: var(--accent); }
.scb-count { font-size: 10px; color: #cbbfb0; }

.shipped-headline {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: 10px;
}

.shipped-copy {
  font-size: 13px;
  line-height: 1.6;
  color: #8c8478;
  max-width: 420px;
  margin: 0 auto 20px;
}

/* ============ SHARED SCREEN PRIMITIVES ============ */

.screen {
  width: 100%;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  animation: fadeIn 0.24s ease;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.title {
  font-size: 46px;
  line-height: 1.02;
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: 16px;
}

/* Terminal/CLI wordmark — mono with a blinking block cursor (not a serif). */
.title-cursor {
  display: inline-block;
  margin-left: 4px;
  color: var(--accent);
  animation: btBlink 1.05s steps(2) infinite;
}

.intro-hook { color: var(--text-strong); margin-top: 12px; }

.subtitle {
  font-size: 15px;
  line-height: 1.7;
  color: #a39a8d;
  margin-bottom: 24px;
}

.screen-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-strong);
  margin-bottom: 14px;
}

.screen-subtitle {
  max-width: 460px;
  margin: 0 auto 24px;
  color: #a39a8d;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 34px;
  align-items: center;
  text-align: left;
  width: 100%;
}

.intro-copy { max-width: 460px; }
.intro-text { color: #a39a8d; margin-bottom: 28px; }
.intro-text p + p { margin-top: 12px; }

.intro-line {
  opacity: 0;
  animation: introReveal 0.5s ease forwards;
}

.hero-art,
.ending-art {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.4);
}

.hero-art .pixel-scene,
.ending-art .pixel-scene,
.hero-art canvas,
.ending-art canvas {
  display: block;
  width: 100%;
  border: none;
  border-radius: 16px;
}

/* Buttons */

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 12px 18px;
  color: var(--text-strong);
  text-decoration: none;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn-secondary {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--line-2);
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-primary:focus,
.btn-secondary:focus {
  outline: none;
  transform: translateY(-1px);
}

.btn-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 20px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--muted);
  background: #0c0a08;
  border: 1px solid var(--line-2);
  border-radius: 5px;
}

/* Name + character + tool setup */

.setup,
.tool-select {
  max-width: 820px;
  margin: auto;
}

.name-input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 12px 0 24px;
}

.resource-label {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
}

.name-input {
  width: min(260px, 66vw);
  padding: 12px 14px;
  color: var(--accent);
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  outline: none;
  caret-color: var(--accent);
}

.name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.name-input::placeholder { color: var(--faint); }

.character-grid,
.tool-grid {
  display: grid;
  gap: 11px;
  width: 100%;
}

.character-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 520px;
  margin: 0 auto 24px;
}

.tool-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 780px;
}

.tool-grid .tool-card:last-child { grid-column: 1 / -1; }

.character-card,
.tool-card,
.choice-card {
  position: relative;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.character-card:hover,
.tool-card:hover,
.choice-card:hover,
.character-card:focus,
.tool-card:focus,
.choice-card:focus,
.tool-card.focused,
.choice-card.focused {
  outline: none;
  border-color: var(--accent);
  background: var(--accent-soft-2);
  transform: translateY(-1px);
}

.character-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 200px;
  padding: 16px 12px;
}

.character-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.char-sprite {
  image-rendering: pixelated;
  animation: avatarAnim 1.7s steps(6) infinite;
}

.char-name { font-size: 13px; font-weight: 700; color: var(--text-strong); }
.char-desc { font-size: 11px; line-height: 1.35; color: var(--muted); max-width: 180px; }

@keyframes avatarAnim {
  from { background-position: 0 0; }
  to { background-position: var(--sprite-shift) 0; }
}

.tool-card {
  min-height: 150px;
  padding: 18px 16px 16px;
  text-align: left;
}

.tool-card .choice-key { position: absolute; top: 12px; right: 12px; }
.tool-name { font-size: 18px; font-weight: 700; color: var(--text-strong); margin-bottom: 2px; }
.tool-tagline { font-size: 12px; color: var(--accent); margin-bottom: 10px; }
.tool-special { font-size: 12px; color: #a39a8d; margin-bottom: 12px; }
.tool-stats { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 11px; }

.green { color: var(--gain); }
.yellow { color: #e2b04a; }
.red { color: var(--loss); }

/* Project-select reuses the legacy card layout, restyled warm. */
.event.shell-card {
  width: 100%;
  max-width: 760px;
  margin: auto;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  animation: fadeIn 0.24s ease;
}

.event-scene {
  margin-bottom: 16px;
  border-radius: 12px;
  overflow: hidden;
}

.event-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.event-type {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 5px;
  color: var(--accent);
  background: var(--accent-soft);
}

.event-title { font-size: 20px; font-weight: 700; color: var(--text-strong); }
.event-text { font-size: 15px; line-height: 1.7; color: #a39a8d; margin-bottom: 14px; }

.choices { display: grid; gap: 11px; }

.choice-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  padding: 14px;
  text-align: left;
}

.choice-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: #0c0a08;
  border: 1px solid var(--line-2);
  border-radius: 6px;
}

.choice-main { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.choice-label { font-weight: 500; line-height: 1.35; color: var(--text-strong); }
.choice-hint { font-size: 12px; color: var(--muted); }
.choice-effects { display: flex; flex-wrap: wrap; gap: 5px; }

.effect-chip {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(155, 146, 134, 0.1);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  white-space: nowrap;
}

.effect-chip.small { color: var(--gain); }
.effect-chip.medium { color: var(--accent); }
.effect-chip.large { color: #e2b04a; }

/* Endings */

.ending {
  width: 100%;
  max-width: 640px;
  margin: auto;
  text-align: center;
  animation: fadeIn 0.24s ease;
}

.ending-badge {
  margin: 18px 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--muted);
}

.ending-badge.win { color: var(--gain); }
.ending-badge.lose { color: var(--loss); }

.ending-title {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-strong);
  margin-bottom: 12px;
}

.ending-cause {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 16px;
  padding: 7px 13px;
  border: 1px solid var(--loss);
  border-radius: 8px;
  background: rgba(224, 115, 90, 0.12);
  color: var(--loss);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.ending-cause-x { font-size: 11px; opacity: 0.85; }

.ending-description { color: #a39a8d; margin-bottom: 20px; }

.ending-stats {
  width: min(100%, 520px);
  margin: 0 auto 18px;
  border-top: 1px solid var(--line-2);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.stat-row span { color: var(--muted); }
.stat-row strong { color: var(--text-strong); }

.ship-list {
  width: min(100%, 520px);
  margin: 0 auto 24px;
  list-style: none;
  text-align: left;
}

.ship-list li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  color: #a39a8d;
}

.ending-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

/* ============ PIXEL SCENES (shared) ============ */

.pixel-scene,
.scene-placeholder {
  display: block;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  background: #0c130b;
  border-radius: 12px;
  object-fit: cover;
}

.scene-mood {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 200px;
  padding: 18px;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(9, 8, 7, 0.96), rgba(42, 30, 24, 0.86)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 8px);
}

.scene-mood-line {
  position: absolute;
  top: 18px;
  left: 18px;
  width: 60px;
  height: 1px;
  background: rgba(236, 230, 218, 0.4);
}

.scene-mood-caption {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}

/* Full-screen scene overlay for big story beats. */
.scene-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(8, 7, 6, 0.82);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.22s ease;
}

.scene-overlay.hidden { display: none; }

.scene-card {
  width: min(900px, 96vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--device);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  box-shadow: 0 30px 110px rgba(0, 0, 0, 0.6);
  animation: btPop 0.26s ease;
}

.scene-card .pixel-scene,
.scene-card .scene-placeholder {
  border-radius: 12px;
}

.scene-caption { font-size: 18px; font-weight: 700; color: var(--text-strong); text-align: center; }
.scene-dismiss { font-size: 12px; color: var(--muted); }

/* ============ ANIMATIONS ============ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes introReveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes btBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.12; } }
@keyframes btDanger { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes btPop { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes btShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-2px); }
  40% { transform: translateX(2px); }
  60% { transform: translateX(-1px); }
  80% { transform: translateX(1px); }
}

/* ============ RESPONSIVE ============ */

@media (max-width: 1180px) {
  body { padding: 0; }

  #game {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .decision-card,
  .select-card {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .decision-main { gap: 16px; }

  .card-title,
  .select-title { font-size: 24px; }

  .decision-scene,
  .select-scene {
    min-height: 180px;
    order: 2;
  }

  .intro {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 18px;
  }

  .intro-copy { max-width: 560px; margin: 0 auto; }
  .title { font-size: 36px; }
}

@media (max-width: 560px) {
  body { font-size: 13px; }

  #game { padding: 12px; gap: 12px; }

  .meter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .hud-body { gap: 10px; }

  .hud-char { width: 84px; padding: 4px; }

  .hud-sprite {
    width: 50px;
    height: 94px;
    background-size: 300px 94px;
  }

  .seg { height: 9px; }

  .project-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .prog-bar { order: 5; flex-basis: 100%; max-width: none; }

  .character-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-grid { grid-template-columns: 1fr; }
  .tool-grid .tool-card:last-child { grid-column: auto; }

  .card-title { font-size: 22px; }
  .dchoice-label { font-size: 15px; }
  .ending-title { font-size: 28px; }
  .btn-key { display: none; }
}
