:root {
  color-scheme: dark;
  --bg: #151412;
  --panel: #24211d;
  --panel-2: #312b25;
  --line: #51483e;
  --text: #f4eee7;
  --muted: #b9aca0;
  --gold: #d8b66a;
  --jade: #6fb79c;
  --rose: #d98282;
  --blue: #8fb3d9;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(216, 182, 106, 0.12), transparent 34rem),
    linear-gradient(180deg, #171614 0%, #11100f 100%);
  color: var(--text);
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px max(22px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.12;
}

.icon-button,
.primary-button,
.choice-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  font-size: 22px;
}

.status-panel,
.story-panel,
.ledger-panel details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(36, 33, 29, 0.92);
  box-shadow: var(--shadow);
}

.status-panel {
  padding: 12px;
  margin-bottom: 12px;
}

.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.status-card strong {
  color: var(--text);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 10px;
}

.stat {
  min-height: 54px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.stat span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  font-size: 20px;
}

.story-panel {
  padding: 16px;
}

.chapter-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.story-text {
  font-size: 16px;
  line-height: 1.78;
}

.story-text p {
  margin-bottom: 12px;
}

.choices-panel {
  position: sticky;
  bottom: 0;
  padding: 12px 0 4px;
  background: linear-gradient(180deg, rgba(17, 16, 15, 0), #11100f 18px);
}

#choices {
  display: grid;
  gap: 10px;
}

.choice-button {
  width: 100%;
  min-height: 72px;
  padding: 12px;
  border-radius: 8px;
  text-align: left;
  line-height: 1.45;
}

.choice-button small {
  display: block;
  margin-bottom: 5px;
  color: var(--gold);
}

.choice-button:active {
  transform: translateY(1px);
}

.ledger-panel {
  margin-top: 10px;
}

.ledger-panel details {
  padding: 10px 12px;
}

.ledger-panel summary {
  color: var(--muted);
}

pre {
  overflow: auto;
  white-space: pre-wrap;
  color: #ded4c8;
  font-size: 12px;
}

.toast-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 18px 14px max(18px, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.48);
  z-index: 10;
}

.toast {
  width: min(100%, 500px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #211e1a;
  box-shadow: var(--shadow);
}

.toast h2 {
  margin-bottom: 12px;
}

.feedback-lines {
  display: grid;
  gap: 10px;
}

.feedback-lines p {
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.feedback-lines strong {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
}

.primary-button {
  width: 100%;
  min-height: 46px;
  margin-top: 14px;
  border-radius: 8px;
  background: var(--gold);
  color: #1a150f;
  font-weight: 700;
}

@media (min-width: 760px) {
  .app-shell {
    width: min(100%, 920px);
    display: grid;
    grid-template-columns: 320px 1fr;
    grid-template-areas:
      "top top"
      "status story"
      "ledger choices";
    gap: 14px;
  }

  .topbar {
    grid-area: top;
  }

  .status-panel {
    grid-area: status;
    margin-bottom: 0;
  }

  .story-panel {
    grid-area: story;
  }

  .choices-panel {
    grid-area: choices;
    position: static;
    padding-top: 0;
    background: none;
  }

  .ledger-panel {
    grid-area: ledger;
    margin-top: 0;
  }
}
