:root {
  --bg: #07060a;
  --panel: rgba(10, 9, 14, 0.88);
  --panel-solid: #100e14;
  --line: rgba(180, 48, 48, 0.38);
  --line-soft: rgba(255, 255, 255, 0.08);
  --text: #efe6d8;
  --muted: #9a9184;
  --accent: #c83a3a;
  --accent-deep: #7a1818;
  --accent2: #d4a84a;
  --ok: #4aaa78;
  --bad: #c83a3a;
  --warn: #d4890a;
  --font-display: "ZCOOL XiaoWei", "Noto Serif SC", "Songti SC", serif;
  --font-body: "Noto Serif SC", "Songti SC", "STSong", serif;
  --font-ui: "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", sans-serif;
  --radius: 12px;
  --touch: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --mobile-bar-h: calc(52px + var(--safe-top));
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
}

body {
  overflow: hidden;
  overscroll-behavior: none;
}

#app {
  position: relative;
  height: 100%;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(260px, 300px) 1fr;
  grid-template-rows: 1fr;
  isolation: isolate;
}

/* —— Atmosphere —— */
.bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 28% 18%, rgba(140, 24, 24, 0.28), transparent 52%),
    radial-gradient(ellipse at 78% 82%, rgba(24, 28, 55, 0.4), transparent 48%),
    #07060a center / cover no-repeat;
  filter: saturate(0.9) contrast(1.06);
  transition: background-image 0.7s ease, filter 0.45s ease;
  z-index: 0;
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.55) 55%, rgba(0, 0, 0, 0.82) 100%),
    radial-gradient(ellipse at center, transparent 35%, rgba(0, 0, 0, 0.45) 100%);
  pointer-events: none;
}

.grain {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.fx-layer {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.2s;
}

.fx-layer.on {
  opacity: 1;
}

.fx-layer.cs {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.32), transparent 55%);
}

.fx-layer.ok {
  background: radial-gradient(circle, rgba(80, 160, 120, 0.22), transparent 50%);
}

.fx-layer.fg {
  background: rgba(120, 20, 20, 0.3);
}

.fx-layer.cf {
  background: repeating-linear-gradient(
      0deg,
      rgba(255, 0, 0, 0.15),
      rgba(255, 0, 0, 0.15) 2px,
      transparent 2px,
      transparent 6px
    ),
    rgba(0, 0, 0, 0.45);
  animation: shake 0.35s linear;
}

.fx-layer.infect {
  box-shadow: inset 0 0 80px rgba(40, 160, 60, 0.35);
  background: rgba(20, 60, 30, 0.25);
}

.fx-layer.warn {
  box-shadow: inset 0 0 60px rgba(200, 40, 40, 0.45);
}

.fx-layer.penalty {
  background: rgba(180, 120, 20, 0.2);
}

.fx-layer.transit {
  background: #000;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

/* —— Mobile top bar (hidden on desktop) —— */
.mobile-bar {
  display: none;
}

.hud-scrim {
  display: none;
}

.icon-btn {
  appearance: none;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(12, 10, 16, 0.75);
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.06em;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.icon-btn:active {
  border-color: var(--accent);
  background: rgba(60, 16, 16, 0.75);
}

/* —— Side panel —— */
.side {
  position: relative;
  z-index: 2;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  padding-left: calc(16px + var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: 14px;
  backdrop-filter: blur(14px) saturate(1.1);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.side-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.side-close {
  display: none;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid rgba(200, 58, 58, 0.45);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
}

.brand {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.18em;
  color: var(--accent);
  text-shadow: 0 0 24px rgba(200, 58, 58, 0.25);
}

.brand small {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-family: var(--font-ui);
}

.panel-title {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.2em;
  margin-top: 4px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 13px;
}

.stat-grid div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 3px;
}

.stat-grid span:last-child {
  color: var(--accent2);
  font-variant-numeric: tabular-nums;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar {
  font-size: 12px;
}

.bar .track {
  margin-top: 5px;
  height: 9px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 99px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.bar .fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.4s ease;
}

.bar.hp .fill {
  background: linear-gradient(90deg, #6a1414, #e05555);
}

.bar.san .fill {
  background: linear-gradient(90deg, #243a68, #7aabef);
}

.bar.inf .fill {
  background: linear-gradient(90deg, #1a4a24, #62d872);
}

.bar.anchor .fill {
  background: linear-gradient(90deg, #5a1212, #ff5050);
}

.meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
  padding-bottom: 8px;
}

.meta b {
  color: var(--text);
  font-weight: 600;
}

/* —— Main stage —— */
.main {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: 1fr auto;
  min-width: 0;
  min-height: 0;
}

.stage {
  padding: 28px 40px 12px;
  padding-right: calc(40px + var(--safe-right));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.scene-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 3.2vw, 32px);
  font-weight: 500;
  margin: 0 0 16px;
  letter-spacing: 0.06em;
  line-height: 1.35;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.85), 0 0 40px rgba(120, 20, 20, 0.2);
}

.narrative {
  max-width: 44rem;
  font-family: var(--font-body);
  font-size: clamp(15px, 1.7vw, 17px);
  font-weight: 500;
  line-height: 1.9;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.75);
}

.narrative p {
  margin: 0 0 1em;
}

.check-toast {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: rgba(8, 6, 10, 0.78);
  border-radius: var(--radius);
  max-width: 440px;
  display: none;
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.check-toast.show {
  display: block;
  animation: toastIn 0.28s ease;
}

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

.check-toast .grade {
  font-family: var(--font-display);
  font-size: 22px;
  margin-bottom: 4px;
  letter-spacing: 0.08em;
}

.check-toast .grade.CS {
  color: #f0e6a8;
}
.check-toast .grade.OK {
  color: var(--ok);
}
.check-toast .grade.FG {
  color: var(--warn);
}
.check-toast .grade.CF {
  color: var(--bad);
}

.check-toast .dice {
  font-family: var(--font-display);
  font-size: 44px;
  line-height: 1;
  margin: 6px 0 8px;
  color: #f2e6c0;
  text-shadow: 0 0 18px rgba(212, 160, 23, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.check-toast .dice::before {
  content: "";
  width: 36px;
  height: 36px;
  background: url("../assets/ui/dice.svg") center / contain no-repeat;
  flex-shrink: 0;
}

.check-toast .dice.spin {
  animation: dicePulse 0.12s linear infinite;
}

@keyframes dicePulse {
  from {
    opacity: 0.45;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1.04);
  }
}

.choices {
  padding: 14px 40px calc(24px + var(--safe-bottom));
  padding-right: calc(40px + var(--safe-right));
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.62) 28%);
  max-height: min(42vh, 360px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.choice-btn {
  appearance: none;
  border: 1px solid rgba(196, 60, 60, 0.42);
  background: rgba(10, 8, 14, 0.78);
  color: var(--text);
  text-align: left;
  padding: 14px 16px;
  min-height: var(--touch);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 15px;
  line-height: 1.45;
  transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}

.choice-btn:hover:not(:disabled):not(.locked) {
  border-color: var(--accent);
  background: rgba(48, 12, 14, 0.88);
  transform: translateX(4px);
  box-shadow: 0 6px 22px rgba(120, 20, 20, 0.25);
}

.choice-btn:active:not(:disabled):not(.locked) {
  transform: scale(0.99);
}

.choice-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.choice-btn .sub {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
}

.choice-btn .sub.ok {
  color: #8fbf9a;
}

.choice-btn .sub.risk {
  color: #e07070;
}

.meta .danger b {
  color: var(--bad);
}

.meta .warn b {
  color: var(--warn);
}

.choice-btn.locked {
  opacity: 0.55;
  border-color: rgba(255, 255, 255, 0.12);
  cursor: not-allowed;
  transform: none;
}

.choice-btn.locked:hover {
  transform: none;
  background: rgba(10, 8, 14, 0.78);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}

.shop-panel {
  display: none;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(8, 6, 10, 0.78);
  border-radius: var(--radius);
  max-width: 640px;
  backdrop-filter: blur(10px);
}

.shop-panel.open {
  display: block;
}

.shop-panel h3 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: normal;
  letter-spacing: 0.12em;
}

.shop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shop-actions button {
  appearance: none;
  border: 1px solid rgba(212, 160, 23, 0.38);
  background: rgba(22, 16, 8, 0.85);
  color: var(--text);
  padding: 10px 12px;
  min-height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

.shop-actions button:hover {
  border-color: var(--accent2);
}

.shop-actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.shop-actions button .price {
  color: var(--accent2);
}

.shop-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.shop-tabs button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  min-height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}

.shop-tabs button.active {
  color: var(--text);
  border-color: var(--accent2);
  background: rgba(212, 160, 23, 0.12);
}

.top-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.top-tools button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  min-height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}

.top-tools button:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.35);
}

.end-banner {
  display: none;
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  background: rgba(8, 6, 10, 0.82);
  border-radius: var(--radius);
  max-width: 640px;
  backdrop-filter: blur(10px);
}

.end-banner.show {
  display: block;
}

.end-banner strong {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.12em;
  color: var(--accent2);
}

.continue-hint {
  margin-top: 10px;
  color: var(--accent2);
  font-size: 13px;
  letter-spacing: 0.12em;
  animation: blink 1.2s ease-in-out infinite;
}

.continue-hint.hidden {
  display: none;
}

@keyframes blink {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.progress-box {
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(40, 12, 12, 0.35), rgba(0, 0, 0, 0.3));
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.progress-label #progress-arc {
  color: var(--accent2);
}

.progress-track {
  height: 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent), var(--accent2));
  transition: width 0.4s ease;
}

/* —— Modal —— */
.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.72);
  display: grid;
  place-items: end center;
  padding: 0;
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(520px, 100%);
  max-height: min(88dvh, 720px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(18px + var(--safe-bottom));
  box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.5);
  animation: sheetUp 0.28s ease;
}

@keyframes sheetUp {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 24px;
  letter-spacing: 0.12em;
}

.modal-close {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 40px;
  cursor: pointer;
}

.modal-tip {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.save-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.save-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.28);
}

.save-row .info {
  font-size: 13px;
  line-height: 1.45;
}

.save-row .info b {
  color: var(--accent2);
}

.save-row .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.save-row button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(20, 18, 28, 0.95);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 40px;
  cursor: pointer;
  font-size: 13px;
  flex: 1;
}

.save-row button:hover {
  border-color: var(--accent2);
}

.modal-card-codex {
  width: min(720px, 100%);
  max-height: min(90dvh, 860px);
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.codex-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px 10px 14px;
  background: rgba(0, 0, 0, 0.32);
  min-height: 148px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.codex-card.locked {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(8, 6, 10, 0.55);
}

.codex-card.unlocked {
  border-color: rgba(212, 168, 74, 0.35);
  box-shadow: inset 0 0 0 1px rgba(212, 168, 74, 0.08);
}

.codex-mark {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1;
  color: var(--accent2);
  margin-bottom: 2px;
}

.codex-card.locked .codex-mark {
  color: var(--muted);
  opacity: 0.7;
}

.codex-kind {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.codex-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text);
}

.codex-card.locked .codex-title {
  letter-spacing: 0.2em;
  color: var(--muted);
}

.codex-hint {
  margin: 0;
  font-size: 11px;
  color: var(--accent2);
  opacity: 0.85;
}

.codex-card.locked .codex-hint {
  color: var(--muted);
  opacity: 0.6;
}

.codex-blurb {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  flex: 1;
}

.codex-time {
  margin-top: 6px;
  font-size: 10px;
  color: rgba(232, 226, 214, 0.45);
}

/* —— Desktop modal centered —— */
@media (min-width: 861px) {
  .modal {
    place-items: center;
    padding: 16px;
  }

  .modal-card {
    border-radius: 14px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 18px;
    animation: none;
  }

  .save-row {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .save-row button {
    flex: none;
  }
}

/* —— Mobile / tablet —— */
@media (max-width: 860px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--mobile-bar-h) 1fr;
  }

  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    position: relative;
    z-index: 6;
    padding: calc(8px + var(--safe-top)) 12px 8px;
    padding-left: calc(12px + var(--safe-left));
    padding-right: calc(12px + var(--safe-right));
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(12, 8, 12, 0.92), rgba(8, 6, 10, 0.78));
    backdrop-filter: blur(14px);
  }

  .mobile-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .mobile-logo {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    object-fit: cover;
    border: 1px solid rgba(200, 58, 58, 0.4);
    flex-shrink: 0;
  }

  .mobile-brand-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .mobile-title {
    font-family: var(--font-display);
    font-size: 16px;
    letter-spacing: 0.16em;
    color: var(--accent);
  }

  .mobile-progress {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 48vw;
  }

  .mobile-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
  }

  .hud-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 24;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  body.hud-open .hud-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .side {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(88vw, 340px);
    z-index: 25;
    border-right: none;
    border-left: 1px solid var(--line);
    padding-top: calc(16px + var(--safe-top));
    padding-bottom: calc(20px + var(--safe-bottom));
    transform: translateX(104%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: -16px 0 48px rgba(0, 0, 0, 0.45);
  }

  body.hud-open .side {
    transform: translateX(0);
  }

  .side-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .brand {
    font-size: 20px;
  }

  .main {
    grid-row: 2;
    min-height: 0;
  }

  .stage {
    padding: 16px 16px 8px;
    padding-left: calc(16px + var(--safe-left));
    padding-right: calc(16px + var(--safe-right));
  }

  .scene-title {
    font-size: 20px;
    margin-bottom: 12px;
  }

  .narrative {
    font-size: 15.5px;
    line-height: 1.85;
  }

  .choices {
    padding: 10px 14px calc(14px + var(--safe-bottom));
    padding-left: calc(14px + var(--safe-left));
    padding-right: calc(14px + var(--safe-right));
    max-height: none;
    gap: 8px;
  }

  .choice-btn {
    font-size: 14.5px;
    padding: 13px 14px;
  }

  .choice-btn:hover:not(:disabled):not(.locked) {
    transform: none;
  }

  .check-toast {
    max-width: none;
  }

  .shop-panel {
    max-width: none;
  }

  .shop-actions button {
    flex: 1 1 calc(50% - 8px);
  }
}

/* —— Narrow phones —— */
@media (max-width: 400px) {
  .mobile-title {
    letter-spacing: 0.1em;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .narrative {
    font-size: 15px;
  }
}

/* —— Short landscape phones —— */
@media (max-width: 860px) and (max-height: 480px) {
  :root {
    --mobile-bar-h: calc(44px + var(--safe-top));
  }

  .mobile-bar {
    padding-top: calc(4px + var(--safe-top));
    padding-bottom: 4px;
  }

  .mobile-brand {
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
  }

  .choices {
    max-height: 38vh;
  }

  .stage {
    padding-top: 10px;
  }
}

/* —— Prefer reduced motion —— */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
