:root {
  color-scheme: light;
  --font-title: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-display: "LXGW WenKai", "Kaiti SC", "STKaiti", "KaiTi", serif;
  --font-body: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-ui:
    "Noto Sans SC",
    "Source Han Sans SC",
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    sans-serif;
  --page: #e8e0d5;
  --panel: #f2ece2;
  --soft-panel: #ede5d8;
  --text: #1e1b18;
  --text-strong: #141210;
  --muted: #69605a;
  --line: #c4b8ab;
  --accent: #8b1a1a;
  --accent-dark: #661010;
  --accent-soft: #d9cec2;
  --ink-soft: #2d2825;
  --button-text: #f0ebe0;
  --positive: #3d5a45;
  --negative: #8b1a1a;
  --shadow: 0 12px 28px rgba(20, 18, 16, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--page);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

button:focus-visible {
  outline: 3px solid var(--accent-soft);
  outline-offset: 3px;
}

.tap-marker {
  position: fixed;
  z-index: 80;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(139, 26, 26, 0.2);
  border-radius: 999px;
  background:
    radial-gradient(circle at 48% 46%, rgba(139, 26, 26, 0.48) 0 26%, rgba(139, 26, 26, 0.22) 27% 54%, rgba(139, 26, 26, 0) 55% 100%);
  box-shadow:
    0 0 0 4px rgba(139, 26, 26, 0.08),
    0 0 18px rgba(139, 26, 26, 0.12);
  pointer-events: none;
  mix-blend-mode: multiply;
  transform: translate(-50%, -50%) scale(0.72) rotate(-8deg);
  animation: tap-marker-fade 420ms ease-out forwards;
}

@keyframes tap-marker-fade {
  0% {
    opacity: 0.92;
    transform: translate(-50%, -50%) scale(0.72) rotate(-8deg);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.26) rotate(6deg);
  }
}

.game-shell {
  min-height: 100vh;
}

.view {
  display: none;
  min-height: 100vh;
}

.view.is-active {
  display: block;
}

[hidden] {
  display: none !important;
}

.page-inner {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 36px 20px;
}

.start-layout {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding-top: 72px;
  padding-bottom: 72px;
  position: relative;
}

.start-layout::before {
  content: "";
  position: absolute;
  inset: 32px 0;
  border: 1px solid rgba(105, 96, 90, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(20, 18, 16, 0.04), rgba(20, 18, 16, 0.01)),
    linear-gradient(135deg, rgba(139, 26, 26, 0.04), transparent 28%);
  pointer-events: none;
}

.start-layout::after {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  top: 46px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(105, 96, 90, 0.28), transparent);
  pointer-events: none;
}

.start-layout h1,
.start-layout .intro-text,
.start-layout .start-actions,
.start-layout .start-save-note {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
}

.start-layout h1 {
  margin-bottom: 20px;
  padding-bottom: 18px;
  letter-spacing: 0.04em;
}

.start-layout h1::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 84px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), rgba(139, 26, 26, 0.18));
}

.start-layout .intro-text {
  max-width: 24em;
  margin-bottom: 0;
  font-size: 1.08rem;
  letter-spacing: 0.01em;
  line-height: 1.95;
}

.summary-layout {
  position: relative;
  padding-top: 56px;
  padding-bottom: 56px;
}

.summary-layout::before {
  content: "";
  position: absolute;
  inset: 24px 0;
  border: 1px solid rgba(105, 96, 90, 0.18);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(20, 18, 16, 0.04), rgba(20, 18, 16, 0.01)),
    linear-gradient(135deg, rgba(139, 26, 26, 0.04), transparent 28%);
  pointer-events: none;
}

.summary-layout::after {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  top: 40px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(105, 96, 90, 0.26), transparent);
  pointer-events: none;
}

.summary-layout > * {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 16px;
  color: var(--text-strong);
  font-family: var(--font-title);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  color: var(--text-strong);
  font-family: var(--font-title);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.25;
}

h3 {
  margin-bottom: 12px;
  color: var(--ink-soft);
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 700;
}

.intro-text {
  max-width: 680px;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 1.05rem;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.start-actions {
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  margin-top: 34px;
}

.start-actions .primary-button,
.start-actions .secondary-button {
  min-width: 144px;
  min-height: 48px;
  padding: 0 22px;
}

.start-save-note {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(105, 96, 90, 0.18);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  text-align: left;
}

.primary-button,
.secondary-button,
.text-button,
.choice-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button,
.secondary-button {
  padding: 0 18px;
  font-family: var(--font-ui);
  font-weight: 700;
}

.replay-trigger {
  min-height: 44px;
  border-radius: 9px;
  padding: 0 12px;
  border-color: rgba(105, 96, 90, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02)),
    rgba(242, 236, 226, 0.72);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.05em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.primary-button {
  background: var(--accent);
  color: var(--button-text);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.primary-button:active,
.secondary-button:active,
.status-menu summary:active,
.replay-trigger:active,
.slot-button:active,
.choice-button:active {
  transform: translateY(1px);
}

.secondary-button {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink-soft);
}

.secondary-button:hover {
  background: var(--soft-panel);
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.text-button {
  background: transparent;
  color: var(--accent);
  font-family: var(--font-ui);
  font-weight: 700;
}

.save-note,
.empty-note {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.storage-feedback {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 18px;
  width: min(560px, calc(100vw - 32px));
  transform: translateX(-50%);
  border: 1px solid rgba(105, 96, 90, 0.26);
  border-radius: 14px;
  padding: 12px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.06)),
    var(--panel);
  box-shadow: 0 16px 32px rgba(20, 18, 16, 0.12);
  color: var(--text-strong);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.storage-feedback[data-tone="error"] {
  border-color: rgba(139, 26, 26, 0.3);
  background:
    linear-gradient(180deg, rgba(139, 26, 26, 0.08), rgba(255, 255, 255, 0.08)),
    var(--panel);
}

.continue-hint {
  flex: 0 0 auto;
  padding: 8px 16px 12px;
  margin: 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-align: center;
  opacity: 0.5;
}

.game-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

.game-layout > * {
  flex: 0 0 auto;
}

.game-main {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* ── stats strip ── */

.stats-strip {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-bottom: 1px solid rgba(105, 96, 90, 0.14);
  background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(232,224,213,0.42));
}

.stats-inline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0;
  width: 100%;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 2px 7px;
  border: 1px solid rgba(105, 96, 90, 0.14);
  border-radius: 4px;
  background: rgba(20, 18, 16, 0.04);
  font-family: var(--font-ui);
}

.stat-pill dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.4;
}

.stat-pill dd {
  margin: 2px 0 0;
  color: var(--text-strong);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.2;
}

.stat-pill dd.is-positive { color: var(--positive); }
.stat-pill dd.is-negative { color: var(--negative); }

@keyframes stat-pill-flash {
  0%   { background: rgba(139,26,26,0.18); border-color: var(--accent); }
  100% { background: rgba(20,18,16,0.04); border-color: rgba(105,96,90,0.16); }
}

.stat-pill.is-changed {
  animation: stat-pill-flash 700ms ease-out;
}

.game-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(105, 96, 90, 0.14);
  padding: 8px 14px 8px;
  min-height: 0;
  overflow: visible;
}

.event-heading {
  position: relative;
  min-width: 0;
  padding: 2px 0 0;
}

.event-heading::before {
  content: "卷首";
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding: 4px 10px;
  border: 1px solid rgba(105, 96, 90, 0.22);
  border-radius: 3px;
  background: rgba(20, 18, 16, 0.04);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  box-shadow: none;
}

.event-heading .eyebrow {
  margin-bottom: 8px;
  letter-spacing: 0.05em;
  line-height: 1.46;
  color: #661010;
}

.event-heading h2 {
  position: relative;
  max-width: 100%;
  padding-bottom: 10px;
  font-size: clamp(2rem, 4vw, 2.8rem);
  letter-spacing: 0.03em;
  line-height: 1.08;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  text-wrap: balance;
}

.event-heading h2.is-compact {
  font-size: clamp(1.84rem, 3.7vw, 2.42rem);
  letter-spacing: 0.015em;
}

.event-heading h2.is-dense {
  font-size: clamp(1.56rem, 3.2vw, 2.06rem);
  letter-spacing: 0;
  line-height: 1.05;
}

.event-heading h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 52px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), rgba(139, 26, 26, 0.16));
}

.header-tools {
  display: grid;
  justify-items: end;
  gap: 6px;
  flex: 0 0 auto;
}

.status-menu {
  position: relative;
  z-index: 30;
  flex: 0 0 auto;
}

.status-menu summary,
.replay-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(105, 96, 90, 0.16);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.03)),
    rgba(242, 236, 226, 0.64);
  color: var(--accent);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.1),
    0 6px 14px rgba(20, 18, 16, 0.04);
}

.status-menu summary::before,
.replay-trigger::before {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 999px;
  background: rgba(139, 26, 26, 0.08);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  flex: 0 0 auto;
}

.status-menu summary {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 700;
  list-style: none;
  letter-spacing: 0.04em;
}

.status-menu summary:hover {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.06)),
    rgba(242, 236, 226, 0.76);
}

.status-menu summary::-webkit-details-marker {
  display: none;
}

.status-menu summary::before {
  content: "簿";
}

.status-menu summary::after {
  content: "▾";
  margin-left: 1px;
  color: var(--muted);
  font-size: 0.7rem;
}

.status-menu[open] summary::after {
  content: "▴";
}

.status-menu-panel {
  position: absolute;
  z-index: 120;
  top: calc(100% + 10px);
  right: 0;
  width: min(430px, calc(100vw - 40px));
  max-height: min(72vh, 620px);
  border: 1px solid rgba(105, 96, 90, 0.26);
  border-radius: 18px;
  padding: 22px 18px 18px;
  background:
    linear-gradient(180deg, rgba(139, 26, 26, 0.035), rgba(255, 255, 255, 0.02) 24%),
    var(--panel);
  box-shadow: 0 18px 36px rgba(20, 18, 16, 0.12);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.status-menu-panel::before {
  content: "政局簿";
  display: block;
  margin-bottom: 14px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.status-menu-panel::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(139, 26, 26, 0.1);
  border-radius: 12px;
  pointer-events: none;
}

.replay-trigger {
  min-width: 0;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.replay-trigger::before {
  content: "回";
}

.replay-trigger:hover {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.06)),
    rgba(242, 236, 226, 0.76);
}

.replay-overlay {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 20px 20px 0;
  background: rgba(20, 18, 16, 0.24);
  overflow: hidden;
}

.replay-dialog {
  width: min(920px, 100%);
  max-height: min(72vh, 680px);
  border: 1px solid rgba(105, 96, 90, 0.26);
  border-radius: 18px 18px 0 0;
  padding: 20px 20px 16px;
  background:
    linear-gradient(180deg, rgba(139, 26, 26, 0.04), rgba(255, 255, 255, 0.04) 22%),
    var(--panel);
  box-shadow: 0 -10px 28px rgba(20, 18, 16, 0.16);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.replay-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.replay-close {
  flex: 0 0 auto;
}

.replay-list {
  max-width: none;
  max-height: min(56vh, 560px);
  overflow: auto;
  padding-right: 4px;
}

.export-dialog {
  width: min(760px, 100%);
}

.export-preview {
  max-height: min(56vh, 560px);
  overflow: auto;
  border: 1px solid rgba(105, 96, 90, 0.18);
  border-radius: 14px;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04)),
    var(--panel);
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.85;
  white-space: normal;
}

.export-sheet {
  position: relative;
}

.export-sheet-header {
  padding: 6px 4px 18px;
  border-bottom: 1px solid rgba(105, 96, 90, 0.18);
}

.export-sheet-eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.export-sheet-title {
  margin: 0;
  color: var(--text-strong);
  font-family: var(--font-title);
  font-size: 1.42rem;
  letter-spacing: 0.06em;
  line-height: 1.3;
}

.export-sheet-meta {
  margin: 12px 0 0;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.8;
}

.export-sheet-section {
  padding: 18px 4px;
  border-bottom: 1px solid rgba(105, 96, 90, 0.14);
}

.export-sheet-section:last-child {
  padding-bottom: 6px;
  border-bottom: 0;
}

.export-sheet-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.export-sheet-section-label {
  margin: 0;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.export-sheet-section-note {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.82rem;
}

.export-sheet-copy {
  display: grid;
  gap: 10px;
}

.export-sheet-copy p {
  margin: 0;
  letter-spacing: 0.01em;
}

.export-sheet-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.export-sheet-stat {
  padding: 12px 10px;
  border: 1px solid rgba(105, 96, 90, 0.16);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0)),
    rgba(237, 229, 216, 0.88);
}

.export-sheet-stat dt {
  margin: 0 0 6px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  line-height: 1.5;
}

.export-sheet-stat dd {
  margin: 0;
  color: var(--text-strong);
  font-family: var(--font-ui);
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.2;
}

.export-sheet-choices {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.export-sheet-choice {
  padding: 14px 14px 14px 18px;
  border: 1px solid rgba(105, 96, 90, 0.16);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0)),
    rgba(242, 236, 226, 0.84);
  box-shadow: 0 8px 16px rgba(20, 18, 16, 0.04);
  position: relative;
}

.export-sheet-choice::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), rgba(139, 26, 26, 0.1));
}

.export-sheet-choice-title {
  margin: 0 0 6px;
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.5;
}

.export-sheet-choice-text {
  margin: 0;
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.8;
}

.export-sheet-empty {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-body);
}

.choice-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  height: 100%;
  overflow: auto;
}

.game-main.is-choice-mode .choice-panel {
  position: relative;
  display: flex;
  min-height: 0;
  flex-direction: column;
  border: 1px solid rgba(105, 96, 90, 0.28);
  border-radius: 20px;
  padding: 30px 22px 22px;
  background:
    linear-gradient(180deg, rgba(139, 26, 26, 0.05), rgba(139, 26, 26, 0.015) 18%, rgba(255, 255, 255, 0.16) 100%),
    var(--panel);
  box-shadow: 0 14px 30px rgba(20, 18, 16, 0.08);
}

.game-main.is-choice-mode .choice-panel::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(139, 26, 26, 0.12);
  border-radius: 14px;
  pointer-events: none;
}

.story-panel {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(105, 96, 90, 0.22);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(139, 26, 26, 0.025), rgba(255, 255, 255, 0.04) 24%, rgba(232, 224, 213, 0.88) 100%),
    var(--panel);
  box-shadow: 0 8px 20px rgba(20, 18, 16, 0.04);
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 220ms ease, transform 250ms ease;
}

.story-panel * {
  -webkit-user-select: none;
  user-select: none;
}

/* corner bracket decorations */
.story-panel::before,
.story-panel::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  border-color: rgba(139, 26, 26, 0.28);
  border-style: solid;
  pointer-events: none;
  z-index: 2;
}
.story-panel::before {
  top: 10px; left: 10px;
  border-width: 2px 0 0 2px;
  border-radius: 3px 0 0 0;
}
.story-panel::after {
  bottom: 10px; right: 10px;
  border-width: 0 2px 2px 0;
  border-radius: 0 0 3px 0;
}

.game-main.is-choice-mode .story-panel {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

/* ── speaker area ── */

.story-speaker-area {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 16px 0;
  position: relative;
  text-align: center;
}

/* decorative brackets around speaker */
.story-speaker-area::before {
  content: "「";
  display: inline;
  color: var(--muted);
  opacity: 0.5;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 200;
  margin-right: 6px;
  line-height: 1;
}

.story-speaker-area::after {
  content: "」";
  display: inline;
  color: var(--muted);
  opacity: 0.5;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 200;
  margin-left: 6px;
  line-height: 1;
}

.story-speaker-area.is-empty::before,
.story-speaker-area.is-empty::after {
  display: none;
}

/* thin decorative line below speaker */
.story-speaker-area .story-speaker::after {
  content: "";
  display: block;
  width: 40px;
  height: 2px;
  margin: 8px auto 0;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.45;
}

.story-speaker-area.is-empty .story-speaker::after {
  display: none;
}

/* ── text shell ── */

.story-text-shell {
  flex: 1 1 0;
  min-height: 0;
  padding: 14px 18px 0;
  position: relative;
  overflow: hidden;
}

/* vertical accent line on left margin */
.story-text-shell::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: linear-gradient(180deg,
    rgba(139, 26, 26, 0.22),
    rgba(139, 26, 26, 0.08) 30%,
    rgba(139, 26, 26, 0.04) 65%,
    rgba(139, 26, 26, 0.14) 100%
  );
  pointer-events: none;
}

.story-text {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0 4px 0 8px;
  overflow-y: auto;
  font-family: var(--font-body);
  font-size: 1.2rem;
  font-weight: 400;
  letter-spacing: 0.005em;
  line-height: 2.1;
  text-align: left;
  overflow-wrap: break-word;
  white-space: normal;
  hanging-punctuation: first allow-end;
}

.game-main.is-result-mode .story-text,
.game-main.is-result-mode .story-speaker {
  color: #5c1a1a;
}

.game-main.is-result-mode .story-text {
  font-weight: 700;
}

/* ── speaker label ── */

.story-speaker {
  width: 100%;
  min-height: 0;
  margin: 0;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1.3;
  text-align: center;
}

.story-speaker.is-empty {
  visibility: hidden;
  opacity: 0;
}

/* ── choice panel transitions ── */

.choice-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 20px;
  min-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 250ms ease, transform 280ms cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: none;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.game-main.is-choice-mode .choice-panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  position: relative;
  border: 1px solid rgba(105, 96, 90, 0.28);
  border-radius: 12px;
  padding: 30px 22px 22px;
  background:
    linear-gradient(180deg, rgba(20, 18, 16, 0.04), rgba(20, 18, 16, 0.01) 18%, rgba(255, 255, 255, 0.12) 100%),
    var(--panel);
  box-shadow: 0 14px 30px rgba(20, 18, 16, 0.08);
}

.game-main.is-choice-mode .choice-panel::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(139, 26, 26, 0.15);
  border-radius: 8px;
  pointer-events: none;
}

.choice-panel h3 {
  color: var(--accent);
  font-family: var(--font-title);
  font-size: 0.95rem;
  letter-spacing: 0;
  margin-bottom: 16px;
}

.game-main.is-choice-mode .choice-panel h3 {
  margin: 0 0 16px;
  color: var(--accent);
  font-size: 0;
  letter-spacing: 0;
  line-height: 1;
}

.game-main.is-choice-mode .choice-panel h3::before {
  content: "择策";
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid rgba(139, 26, 26, 0.22);
  border-radius: 3px;
  background: rgba(139, 26, 26, 0.06);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.choice-list {
  display: grid;
  gap: 14px;
}

.game-main.is-choice-mode .choice-list {
  min-height: 0;
  flex: 0 1 auto;
  gap: 16px;
  max-height: 100%;
  overflow-y: auto;
  padding-right: 4px;
  padding-bottom: 4px;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 18px,
    #000 calc(100% - 22px),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 18px,
    #000 calc(100% - 22px),
    transparent 100%
  );
}

.choice-button {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  width: 100%;
  min-height: 56px;
  padding: 16px 18px;
  border-color: var(--line);
  background: var(--soft-panel);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.65;
  text-align: left;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.choice-button__label {
  display: block;
  flex: 1 1 auto;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.choice-button__note {
  display: inline-block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.84em;
  line-height: 1.55;
}

.choice-button:hover {
  border-color: var(--accent);
  background: rgba(139, 26, 26, 0.06);
}

.choice-button:active {
  border-color: var(--accent);
  background: rgba(139, 26, 26, 0.14);
}

.game-main.is-choice-mode .choice-button {
  min-height: 64px;
  height: auto;
  border-color: rgba(105, 96, 90, 0.28);
  border-radius: 8px;
  padding: 16px 18px 16px 20px;
  background:
    linear-gradient(180deg, rgba(20, 18, 16, 0.03), rgba(20, 18, 16, 0)),
    var(--panel);
  box-shadow: none;
  font-size: 0.99rem;
  line-height: 1.7;
  position: relative;
  color: var(--text-strong);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.game-main.is-choice-mode .choice-button:hover {
  border-color: var(--accent);
  background:
    linear-gradient(180deg, rgba(139, 26, 26, 0.06), rgba(20, 18, 16, 0.01)),
    var(--panel);
  transform: none;
}

.game-main.is-choice-mode .choice-button:active {
  border-color: var(--accent);
  background:
    linear-gradient(180deg, rgba(139, 26, 26, 0.1), rgba(20, 18, 16, 0.02)),
    var(--soft-panel);
}

.game-main.is-choice-mode .choice-button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: rgba(139, 26, 26, 0.25);
}

.game-main.is-choice-mode .choice-button:hover::before {
  background: var(--accent);
}

/* 灰色禁用选项（不满足条件的黑暗路线） */
.choice-button--locked,
.choice-button--locked:hover,
.choice-button--locked:active,
.game-main.is-choice-mode .choice-button--locked,
.game-main.is-choice-mode .choice-button--locked:hover,
.game-main.is-choice-mode .choice-button--locked:active {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(0.6);
  background: var(--soft-panel);
  border-color: transparent;
  transform: none;
  box-shadow: none;
}
.choice-button--locked .choice-button__label {
  color: var(--muted);
}
.choice-button--locked::before,
.game-main.is-choice-mode .choice-button--locked::before {
  background: rgba(128, 128, 128, 0.2) !important;
}
.choice-button__hint {
  display: block;
  font-size: 0.72em;
  opacity: 0.55;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.4;
}

.stats-panel {
  margin: 0;
}

.stats-header {
  margin-bottom: 14px;
}

.stats-header p {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stats-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin: 0;
}

.status-menu .stats-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.status-menu .stat-item {
  flex-direction: column;
  justify-content: flex-start;
  gap: 4px;
  border: 1px solid rgba(105, 96, 90, 0.16);
  border-bottom: 1px solid rgba(105, 96, 90, 0.16);
  border-radius: 12px;
  padding: 10px 8px;
  background: rgba(255, 255, 255, 0.18);
}

.status-menu .stats-list dt,
.status-menu .stats-list dd {
  text-align: center;
}

.status-menu .stats-list dt {
  font-family: var(--font-ui);
  font-size: 0.8rem;
}

.status-menu .stats-list dd {
  font-family: var(--font-ui);
  font-size: 1rem;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 0;
}

.stats-list dt {
  color: var(--muted);
  font-family: var(--font-ui);
}

.stats-list dd {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 800;
}

.summary-layout .eyebrow {
  margin-bottom: 10px;
}

.summary-layout .intro-text,
.summary-layout .stats-list,
.summary-layout .summary-section,
.summary-layout .action-row {
  width: min(700px, 100%);
}

.summary-layout h2 {
  position: relative;
  margin-bottom: 18px;
  padding-bottom: 16px;
  letter-spacing: 0.05em;
}

.summary-layout h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 84px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), rgba(139, 26, 26, 0.18));
}

.summary-layout .intro-text {
  margin-bottom: 24px;
  max-width: 36em;
  letter-spacing: 0.01em;
  line-height: 1.9;
}

.summary-layout .stats-list {
  border: 1px solid rgba(105, 96, 90, 0.2);
  border-radius: 16px;
  padding: 14px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.02)),
    var(--panel);
}

.summary-layout .stat-item {
  padding: 10px 0;
}

.summary-section {
  margin-top: 30px;
  border-top: 1px solid rgba(105, 96, 90, 0.18);
  padding-top: 22px;
}

.history-list {
  display: grid;
  gap: 12px;
  max-width: 680px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--panel);
}

.history-item p {
  margin-bottom: 0;
}

.history-meta {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.summary-layout .summary-section h3 {
  margin-bottom: 14px;
  color: var(--text-strong);
  font-family: var(--font-title);
  font-size: 1.02rem;
  letter-spacing: 0.08em;
}

.slot-button,
.replay-trigger {
  font-family: var(--font-ui);
}

.stats-list dd.is-positive,
.effect-chip.is-positive {
  color: var(--positive);
}

.stats-list dd.is-negative,
.effect-chip.is-negative {
  color: var(--negative);
}

.effect-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px 8px;
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
}

.save-slots {
  border-top: 1px solid rgba(105, 96, 90, 0.18);
  margin-top: 18px;
  padding-top: 16px;
}

.save-slots h3 {
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 0.95rem;
}

.save-slot-list {
  display: grid;
  gap: 8px;
}

.save-slot-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 2px;
}

.save-slot-plan,
.save-slot-page-indicator {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.save-slot-pager {
  display: flex;
  align-items: center;
  gap: 6px;
}

.save-slot-login {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0;
  padding: 10px 12px;
  border: 1px solid rgba(105, 96, 90, 0.18);
  border-radius: 8px;
  background: rgba(139, 26, 26, 0.04);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.save-slot {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--soft-panel);
}

.save-slot.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.save-slot-copy {
  min-width: 0;
}

.save-slot-title,
.save-slot-meta {
  margin-bottom: 0;
}

.save-slot-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.save-slot-current {
  border: 1px solid var(--accent-soft);
  border-radius: 8px;
  padding: 0 6px;
  color: var(--accent);
  background: var(--panel);
  font-size: 0.75rem;
  line-height: 1.8;
}

.save-slot-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-slot-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 6px;
}

.slot-button {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: normal;
}

.slot-button:hover {
  border-color: var(--accent);
  background: var(--soft-panel);
  color: var(--accent);
}

.slot-button:active {
  border-color: var(--accent);
  background: rgba(139, 26, 26, 0.1);
  color: var(--accent);
}

.slot-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

@media (max-width: 640px) {
  .save-slot-toolbar,
  .save-slot-pager,
  .save-slot-login {
    align-items: stretch;
    flex-direction: column;
  }

  .save-slot-pager {
    gap: 8px;
  }

  .save-slot-page-indicator {
    text-align: center;
  }
}

.status-actions {
  display: grid;
  gap: 12px;
  border-top: 1px solid rgba(105, 96, 90, 0.18);
  margin-top: 18px;
  padding-top: 16px;
}

.status-actions .save-note {
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .page-inner {
    padding: 24px 16px 32px;
  }

  .start-layout {
    padding-top: 56px;
    padding-bottom: 56px;
  }

  .start-layout::before {
    inset: 18px 0;
    border-radius: 6px;
  }

  .start-layout::after {
    left: 16px;
    right: 16px;
    top: 30px;
  }

  h1 {
    font-size: 2rem;
  }

  .start-layout h1 {
    margin-bottom: 18px;
    padding-bottom: 16px;
  }

  .start-layout .intro-text {
    font-size: 1.02rem;
    line-height: 1.9;
  }

  .start-actions {
    margin-top: 28px;
  }

  .game-layout {
    height: 100dvh;
    min-height: 100dvh;
    gap: 0;
    padding: 0;
  }

  .stats-strip {
    padding: 4px 10px;
  }

  .stats-inline {
    gap: 4px;
  }

  .stat-pill {
    padding: 5px 1px 6px;
    border-radius: 3px;
  }

  .stat-pill dt {
    font-size: 0.64rem;
  }

  .stat-pill dd {
    font-size: 0.82rem;
  }

  .game-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 8px;
    border-bottom: 1px solid rgba(105, 96, 90, 0.14);
  }

  .event-heading {
    width: 100%;
    min-width: 0;
    padding-right: 118px;
    padding-top: 0;
  }

  .event-heading::before {
    margin-bottom: 8px;
    padding: 4px 9px;
  }

  .event-heading .eyebrow {
    margin-bottom: 6px;
    font-size: 0.94rem;
    line-height: 1.42;
  }

  .event-heading h2 {
    padding-bottom: 6px;
    font-size: clamp(1.2rem, 6vw, 1.6rem);
    line-height: 1.15;
  }

  .event-heading h2::after {
    display: none;
  }

  .event-heading h2.is-compact {
    font-size: clamp(1.1rem, 5.5vw, 1.4rem);
    line-height: 1.12;
  }

  .event-heading h2.is-dense {
    font-size: clamp(1rem, 5vw, 1.2rem);
    line-height: 1.08;
    letter-spacing: -0.01em;
  }

  .status-menu {
    margin-left: 0;
  }

  .status-menu-panel {
    right: 0;
    width: calc(100vw - 24px);
    max-height: min(74vh, 560px);
  }

  .status-menu .stats-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .status-menu .stat-item {
    padding: 8px 6px;
  }

  .status-menu .stats-list dt {
    font-size: 0.76rem;
  }

  .status-menu .stats-list dd {
    font-size: 0.94rem;
  }

  .game-main {
    min-height: 0;
  }

  .story-panel {
    padding: 0;
    overflow: hidden;
    border-radius: 14px;
  }

  .story-panel::before {
    top: 8px; left: 8px;
    width: 22px; height: 22px;
  }

  .story-panel::after {
    bottom: 8px; right: 8px;
    width: 22px; height: 22px;
  }

  .story-speaker-area {
    padding: 14px 12px 0;
  }

  .story-speaker-area::before,
  .story-speaker-area::after {
    font-size: 1.3rem;
  }

  .story-speaker-area .story-speaker::after {
    margin-top: 6px;
    width: 32px;
  }

  .story-speaker {
    font-size: 1.2rem;
    letter-spacing: 0.06em;
  }

  .story-text-shell {
    padding: 10px 14px 0;
  }

  .story-text-shell::before {
    left: 9px;
  }

  .story-text {
    font-size: 1.2rem;
    line-height: 2.1;
    padding: 0 2px 0 6px;
  }

  .header-tools {
    position: absolute;
    top: 20px;
    right: 12px;
    width: auto;
    justify-items: end;
    gap: 6px;
  }

  .header-tools .status-menu,
  .header-tools .replay-trigger {
    width: auto;
  }

  .header-tools .status-menu summary {
    min-height: 38px;
    padding: 0 10px;
    justify-content: center;
  }

  .header-tools .replay-trigger {
    min-height: 38px;
    min-width: 0;
    padding: 0 10px;
    text-align: center;
  }

  .choice-panel {
    padding: 16px;
    border-radius: 14px;
  }

  .game-main.is-choice-mode .choice-panel {
    border-radius: 10px;
    padding: 24px 16px 16px;
  }

  .game-main.is-choice-mode .choice-panel h3 {
    margin-bottom: 14px;
    font-size: 0;
  }

  .game-main.is-choice-mode .choice-list {
    gap: 14px;
    padding-right: 2px;
    -webkit-mask-image: linear-gradient(
      to bottom,
      transparent 0,
      #000 14px,
      #000 calc(100% - 18px),
      transparent 100%
    );
    mask-image: linear-gradient(
      to bottom,
      transparent 0,
      #000 14px,
      #000 calc(100% - 18px),
      transparent 100%
    );
  }

  .game-main.is-choice-mode .choice-button {
    min-height: 60px;
    padding: 16px 16px 16px 18px;
    font-size: 1.02rem;
  }

  .choice-button {
    min-height: 54px;
    padding: 14px 15px;
  }

  .stats-list {
    grid-template-columns: 1fr;
  }

  .summary-layout {
    padding-top: 42px;
    padding-bottom: 42px;
  }

  .summary-layout::before {
    inset: 14px 0;
    border-radius: 8px;
  }

  .summary-layout::after {
    left: 16px;
    right: 16px;
    top: 24px;
  }

  .summary-layout h2 {
    margin-bottom: 16px;
    padding-bottom: 14px;
  }

  .summary-layout .intro-text {
    margin-bottom: 20px;
    font-size: 1rem;
    line-height: 1.86;
  }

  .storage-feedback {
    bottom: 14px;
    width: calc(100vw - 24px);
    padding: 11px 14px;
    font-size: 0.86rem;
  }

  .replay-overlay {
    padding: 12px 12px 0;
  }

  .replay-dialog {
    width: 100%;
    max-height: min(78vh, 78dvh, 640px);
    padding: 18px 14px 14px;
    border-radius: 16px 16px 0 0;
  }

  .replay-header {
    flex-direction: column;
  }

  .overlay-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .export-preview {
    max-height: min(62vh, 62dvh);
    padding: 14px;
    font-size: 0.94rem;
    line-height: 1.8;
  }

  .export-sheet-title {
    font-size: 1.28rem;
  }

  .export-sheet-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .export-sheet-section-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

/* ── desktop enhancements ── */

@media (min-width: 768px) {
  .page-inner {
    padding: 24px 20px;
  }

  .game-layout {
    max-width: 640px;
    margin: 0 auto;
    border-left: 1px solid rgba(105, 96, 90, 0.08);
    border-right: 1px solid rgba(105, 96, 90, 0.08);
    box-shadow: 0 0 40px rgba(20, 18, 16, 0.04);
  }

  .stats-strip {
    padding: 8px 18px;
  }

  .stat-pill dt {
    font-size: 0.76rem;
  }

  .stat-pill dd {
    font-size: 1rem;
  }

  .game-header {
    padding: 10px 18px 10px;
  }

  .event-heading h2 {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
  }

  .event-heading h2.is-compact {
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
  }

  .event-heading h2.is-dense {
    font-size: clamp(1.1rem, 2.2vw, 1.5rem);
  }

  .story-speaker {
    font-size: 1.5rem;
  }

  .story-speaker-area {
    padding: 18px 16px 0;
  }

  .story-text {
    font-size: 1.3rem;
    line-height: 2.2;
  }

  .story-text-shell {
    padding: 16px 20px 0;
  }

  .game-main.is-choice-mode .choice-button {
    font-size: 1.05rem;
    min-height: 64px;
  }
}

/* ── achievement toast ── */

.achievement-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 12px 28px;
  background: linear-gradient(135deg, #1a1410 0%, #2d2520 100%);
  color: #c4a86a;
  font-family: var(--font-display);
  font-size: 1.05rem;
  border: 1px solid rgba(180, 150, 90, 0.3);
  border-radius: 6px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  z-index: 2000;
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}

.achievement-toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── collection overlays ── */

.collection-dialog {
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
}

.collection-progress {
  margin: 0 0 16px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.92rem;
  text-align: center;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding-top: 4px;
}

.collection-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.collection-card.is-locked {
  background: rgba(196, 184, 171, 0.14);
  border-color: rgba(196, 184, 171, 0.25);
  filter: grayscale(1);
  opacity: 0.55;
}

.collection-card.is-unlocked {
  background: var(--panel);
  border-color: var(--accent-soft);
}

.collection-card--bad.is-unlocked {
  border-color: rgba(139, 26, 26, 0.28);
  background: linear-gradient(160deg, rgba(139, 26, 26, 0.04), var(--panel));
}

.collection-card--neutral.is-unlocked {
  border-color: rgba(90, 110, 130, 0.25);
  background: linear-gradient(160deg, rgba(90, 110, 130, 0.03), var(--panel));
}

.collection-card--dark.is-unlocked {
  border-color: rgba(30, 27, 24, 0.35);
  background: linear-gradient(160deg, rgba(30, 27, 24, 0.06), var(--panel));
}

.collection-card__icon {
  font-size: 1.5rem;
  line-height: 1;
}

.collection-card__name {
  margin: 0;
  color: var(--text-strong);
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.collection-card.is-locked .collection-card__name {
  color: var(--muted);
}

.collection-card__desc {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  line-height: 1.5;
}

.collection-card.is-unlocked {
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease, filter 0.2s ease;
}

.collection-card.is-unlocked:hover,
.collection-card.is-unlocked:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(20, 18, 16, 0.1);
}

.ending-stat {

.ending-stat {
  margin: 2px 0 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.76rem;
  opacity: 0.75;
}

/* ── ending replay ── */

.ending-replay-dialog {
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
}

.ending-replay-content {
  padding: 0 4px;
  line-height: 2;
}

.ending-replay-line {
  margin: 0 0 0.5em;
  padding: 6px 0;
  font-size: 1.05rem;
}

.ending-replay-line strong {
  display: inline-block;
  min-width: 5em;
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ── return-to-title button ── */

.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* ── achievement detail ── */

.achievement-detail-dialog {
  max-width: 520px;
}

.achievement-detail-content {
  padding: 4px 4px 0;
}

.achievement-detail-story {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 2;
  color: var(--text);
}

/* ── premium gate ── */

.premium-gate-dialog {
  max-width: 520px;
  max-height: min(88vh, 88dvh, 760px);
}

.premium-gate-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 4px 0;
}

.premium-gate-intro {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
}

.premium-gate-features {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.premium-gate-features li {
  padding: 10px 14px;
  border: 1px solid rgba(196, 184, 171, 0.4);
  border-radius: 6px;
  background: rgba(242, 236, 226, 0.5);
  font-size: 0.95rem;
  line-height: 1.5;
}

.premium-gate-features li strong {
  color: var(--text-strong);
}

.premium-gate-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.premium-gate-price {
  margin: 0;
  color: var(--accent);
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
}

.premium-gate-price-label {
  margin: -6px 0 4px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.premium-pay-button {
  width: 100%;
  min-height: 48px;
  font-size: 1.1rem;
}

.premium-login-button {
  width: 100%;
  min-height: 44px;
}

.premium-qr-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.premium-qr-image {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.premium-qr-hint {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  text-align: center;
  line-height: 1.7;
}

.premium-redeem-toggle {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.premium-redeem-toggle summary {
  cursor: pointer;
  color: var(--muted);
  padding: 4px 0;
}

.premium-redeem-toggle .premium-gate-code-row {
  margin-top: 10px;
}

.premium-gate-label {
  margin: 0;
  color: var(--text-strong);
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
}

.premium-gate-code-row {
  display: flex;
  gap: 10px;
}

.premium-gate-input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.premium-gate-input:focus {
  outline: 2px solid var(--accent-soft);
  outline-offset: 1px;
  border-color: var(--accent);
}

.premium-gate-feedback {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.88rem;
}

.premium-gate-feedback[data-tone="error"] {
  color: var(--negative);
}

.premium-gate-feedback[data-tone="success"] {
  color: var(--positive);
}

.premium-gate-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.premium-gate-qr-row {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
}

.premium-gate-qr {
  margin: 0;
  text-align: center;
}

.premium-gate-qr img {
  display: block;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.premium-gate-qr figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.85rem;
}

/* ── premium badge (title screen) ── */

.premium-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #c4a86a, #d4b97a);
  color: #3d2e0a;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

@media (max-width: 540px) {
  .collection-grid {
    grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
    gap: 10px;
  }

  .collection-dialog {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 0;
  }

  .ending-replay-dialog {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 0;
  }

  .premium-gate-dialog {
    max-width: 100%;
    max-height: calc(100dvh - 16px);
    border-radius: 0;
    padding: 16px 12px max(16px, env(safe-area-inset-bottom, 0));
  }

  .premium-gate-body {
    gap: 10px;
    padding: 0;
  }

  .premium-gate-features {
    gap: 6px;
  }

  .premium-gate-features li {
    padding: 8px 10px;
    font-size: 0.9rem;
    line-height: 1.45;
  }

  .premium-gate-price {
    font-size: 1.72rem;
  }

  .premium-qr-hint {
    font-size: 0.8rem;
    line-height: 1.6;
  }

  .premium-gate-code-row {
    flex-direction: column;
    gap: 8px;
  }
}
