:root {
  --ink: #2e2419;
  --muted: #6d5c4a;
  --paper: #f4e4c5;
  --paper-dark: #dcc296;
  --river: #1f6673;
  --river-light: #56a5ad;
  --accent: #b75d2a;
  --accent-dark: #7f3719;
  --shadow: rgba(46, 36, 25, 0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Georgia, "Noto Serif TC", "Microsoft JhengHei", serif;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.22), transparent 24rem),
    linear-gradient(145deg, rgba(31,102,115,.85), rgba(58,76,62,.9)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='80' viewBox='0 0 160 80'%3E%3Cpath d='M0 40 C40 10 80 70 160 35 L160 80 L0 80 Z' fill='%23000000' opacity='.08'/%3E%3C/svg%3E");
}

.game-shell {
  width: min(1360px, 97vw);
  height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 8px 0;
}

.hero-card, .game-card {
  width: 100%;
  border: 2px solid rgba(46, 36, 25, .35);
  border-radius: 24px;
  background: linear-gradient(180deg, var(--paper), #efd5a3);
  box-shadow: 0 24px 70px var(--shadow);
}

.hero-card {
  max-width: 820px;
  padding: clamp(28px, 6vw, 64px);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-card > * {
  position: relative;
  z-index: 1;
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: auto -10% -80px -10%;
  height: 170px;
  background: repeating-linear-gradient(90deg, #865b32 0 42px, #6e4828 42px 47px);
  transform: rotate(-2deg);
  opacity: .35;
  pointer-events: none;
  z-index: 0;
}

.eyebrow, .chapter-kicker {
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 18px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.08;
}

.intro {
  max-width: 650px;
  margin: 0 auto 20px;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.8;
}

.notice {
  margin: 24px auto;
  max-width: 680px;
  padding: 14px 18px;
  border: 1px dashed rgba(127, 55, 25, .5);
  border-radius: 14px;
  color: #553d27;
  background: rgba(255,255,255,.28);
  line-height: 1.6;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

button:hover { transform: translateY(-2px); }
button:active { transform: translateY(0); }

.primary-btn {
  padding: 14px 30px;
  color: #fff9ea;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  box-shadow: 0 10px 24px rgba(127, 55, 25, .28);
  font-size: 1.05rem;
}

.game-card {
  display: grid;
  grid-template-columns: 270px 1fr;
  height: calc(100vh - 16px);
  max-height: 920px;
  overflow: hidden;
}

.status-panel {
  padding: 20px;
  background: rgba(46, 36, 25, .08);
  border-right: 2px solid rgba(46, 36, 25, .18);
  overflow: auto;
}

.status-panel h2 {
  margin: 0 0 20px;
  font-size: 1.35rem;
}

.mode-switch {
  margin-bottom: 14px;
}

.mode-switch label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
}

.mode-switch select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(46, 36, 25, .22);
  background: rgba(255,255,255,.68);
  color: var(--ink);
  font-family: inherit;
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid rgba(46, 36, 25, .16);
}

.stat strong {
  min-width: 44px;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  background: var(--river);
  text-align: center;
}

.river-progress { margin: 28px 0; }
.river-label { margin-bottom: 8px; color: var(--muted); font-weight: 700; }
.river-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(31,102,115,.18);
}
#river-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--river), var(--river-light));
  transition: width .35s ease;
}

.ghost-btn {
  width: 100%;
  padding: 12px 16px;
  color: var(--accent-dark);
  border: 1px solid rgba(127, 55, 25, .35);
  background: transparent;
}

.timeline-panel,
.codex-panel {
  margin-top: 14px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255,255,255,.38);
  border: 1px solid rgba(46, 36, 25, .15);
}

.timeline-panel h3,
.codex-panel h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

#timeline-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

#timeline-list li {
  font-size: .93rem;
  color: #4f3f2c;
  opacity: .58;
}

#timeline-list li.active {
  opacity: 1;
  color: var(--accent-dark);
  font-weight: 700;
}

.codex-item {
  margin-bottom: 8px;
  border: 1px solid rgba(46, 36, 25, .18);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255,255,255,.54);
}

.codex-item summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 700;
  color: #4c3824;
}

.codex-item p {
  margin: 0;
  padding: 0 12px 10px;
  color: #5a4733;
  line-height: 1.6;
  font-size: .93rem;
}

.story-context {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-left: 4px solid rgba(127, 55, 25, .52);
  border-radius: 8px;
  background: rgba(255,255,255,.44);
  color: #5a4733;
  line-height: 1.55;
}

.story-panel {
  padding: clamp(16px, 2.6vw, 28px);
  display: flex;
  flex-direction: column;
  overflow: auto;
}

#chapter-title { font-size: clamp(1.8rem, 4vw, 3rem); }
#chapter-text {
  color: #443321;
  font-size: 1.05rem;
  line-height: 1.68;
  white-space: pre-line;
}

.choices {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding-top: 12px;
}

.choice-btn {
  width: 100%;
  padding: 12px 14px;
  color: var(--ink);
  border: 1px solid rgba(46, 36, 25, .25);
  border-radius: 12px;
  background: rgba(255,255,255,.42);
  text-align: left;
  font-size: .96rem;
}

.choice-btn:hover { background: rgba(255,255,255,.7); }

.choice-meta {
  display: block;
  margin-top: 8px;
  color: #7a5e45;
  font-size: .88rem;
  font-weight: 700;
}

.log {
  min-height: 24px;
  margin-top: 12px;
  color: var(--accent-dark);
  font-size: .95rem;
  font-weight: 700;
}

.chapter-illustration img#chapter-illustration {
  max-height: 400px !important;
  margin-bottom: 10px !important;
}

.hidden { display: none; }

@media (max-width: 760px) {
  body { overflow: auto; }
  .game-shell {
    width: min(100%, 98vw);
    height: auto;
    min-height: 100vh;
    padding: 6px 0;
  }
  .game-card {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
  }
  .status-panel {
    border-right: 0;
    border-bottom: 2px solid rgba(46, 36, 25, .18);
    padding: 14px;
  }

  .story-panel {
    padding: 14px;
  }

  .chapter-illustration img#chapter-illustration {
    max-height: 300px !important;
  }
}