/* ============================================================
   app.css —— 布局、组件、通用面板
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--g);
  color: var(--xh);
  font-family: var(--font-hei);
  font-size: var(--fs-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 纸张噪点 */
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; cursor: pointer; }
button:disabled { cursor: default; }

::selection { background: rgba(185, 74, 61, .18); }

/* ---------- 通用文字 ---------- */
.kai { font-family: var(--font-kai); }
.song { font-family: var(--font-song); }
.fang { font-family: var(--font-fang); }
.mute { color: var(--mute); }
.zh { color: var(--zh); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: .01em; }

/* ============================================================
   卷首
   ============================================================ */
.cover {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background:
    radial-gradient(120% 90% at 50% 0%, #FBF9F3 0%, #F2EEE5 55%, #E8E2D4 100%);
  transition: opacity .8s var(--ease), visibility .8s;
}
.cover.hide { opacity: 0; visibility: hidden; }

.cover-book {
  position: relative;
  width: min(520px, 82vw);
  padding: 64px 56px 48px;
  background: linear-gradient(160deg, #FCFAF4 0%, #F6F2E7 100%);
  border: 1px solid var(--line-strong);
  box-shadow:
    0 1px 0 rgba(255,255,255,.9) inset,
    0 24px 60px -28px rgba(37,40,38,.35),
    14px 0 0 -6px #EFE9DB,
    14px 0 0 -5px rgba(37,40,38,.14);
}
.cover-thread {
  position: absolute; left: -1px; top: 0; bottom: 0; width: 6px;
  background: repeating-linear-gradient(to bottom,
    rgba(37,40,38,.22) 0 2px, transparent 2px 18px);
}
.cover-inner { text-align: center; }
.cover-eyebrow {
  font-size: var(--fs-tiny);
  letter-spacing: .36em;
  color: var(--mute);
  margin-bottom: var(--s5);
}
.cover-title {
  font-family: var(--font-song);
  font-size: clamp(38px, 7vw, 54px);
  font-weight: 700;
  letter-spacing: .22em;
  margin: 0 0 var(--s2) .22em;
  color: var(--xh);
}
.cover-sub {
  font-family: var(--font-song);
  font-size: clamp(17px, 2.4vw, 21px);
  letter-spacing: .5em;
  color: var(--yq);
  margin: 0 0 var(--s4) .5em;
}
.cover-rule {
  width: 96px; height: 1px; margin: 0 auto var(--s3);
  background: var(--line-strong);
}
.cover-meta {
  font-size: var(--fs-small); color: var(--mute);
  letter-spacing: .16em; margin-bottom: var(--s5);
}
.cover-meta .dot { margin: 0 10px; }
.cover-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.cover-foot {
  margin-top: var(--s5);
  font-size: var(--fs-tiny);
  color: var(--mute); letter-spacing: .1em;
}
.cover-seal {
  position: absolute; right: -22px; bottom: 42px;
  width: 84px; height: 84px;
  display: grid; place-items: center;
  border: 3px solid rgba(185,74,61,.72);
  outline: 1px solid rgba(185,74,61,.3);
  outline-offset: 3px;
  color: rgba(185,74,61,.82);
  font-family: var(--font-kai);
  font-size: 27px; line-height: 1.05; letter-spacing: 2px;
  transform: rotate(-4deg);
  background: rgba(185,74,61,.045);
  box-shadow: 0 0 0 1px rgba(185,74,61,.12) inset;
}
.cover-copy {
  margin-top: var(--s4);
  font-size: var(--fs-tiny); color: var(--mute);
}
kbd {
  font-family: var(--font-hei); font-size: 11px;
  border: 1px solid var(--line-strong); border-radius: 2px;
  padding: 1px 5px; margin: 0 2px; color: var(--xh);
  background: var(--paper-2);
}

/* 主按钮 */
.btn-ghost {
  min-width: 200px;
  padding: 13px 28px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--xh);
  font-size: var(--fs-body);
  letter-spacing: .18em;
  border-radius: var(--r1);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast);
}
.btn-ghost:hover { background: rgba(51,74,77,.06); border-color: var(--yq); }
.btn-ghost.primary { border-color: var(--zh); color: var(--zh); }
.btn-ghost.primary:hover { background: rgba(185,74,61,.07); }

/* ============================================================
   顶栏
   ============================================================ */
.game { position: relative; z-index: 1; }

.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: 68px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--s4);
  background: rgba(247, 244, 236, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.hud-left { display: flex; align-items: baseline; gap: 14px; min-width: 210px; }
.hud-date {
  font-family: var(--font-song);
  font-size: var(--fs-small);
  letter-spacing: .1em;
  color: var(--xh);
}
.hud-chap { font-size: var(--fs-tiny); color: var(--mute); letter-spacing: .14em; }

.hud-stats { display: flex; gap: var(--s3); flex: 1; justify-content: center; }
.stat { display: flex; flex-direction: column; gap: 3px; min-width: 84px; }
.stat-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.stat-label { font-size: 11px; letter-spacing: .16em; color: var(--mute); }
.stat-val {
  font-family: var(--font-num); font-size: 13px; font-variant-numeric: tabular-nums;
  color: var(--xh); letter-spacing: .02em;
}
.stat-bar { height: 2px; background: var(--line); position: relative; overflow: hidden; }
.stat-bar i {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--yq);
  transition: width .8s var(--ease), background .4s;
}
.stat.warn .stat-bar i { background: var(--zh); }
.stat.warn .stat-val { color: var(--zh); }
.stat.good .stat-bar i { background: var(--cl); }

.hud-right { display: flex; gap: 6px; min-width: 240px; justify-content: flex-end; }
.hud-btn {
  font-size: var(--fs-tiny);
  letter-spacing: .14em;
  padding: 8px 12px;
  color: var(--yq);
  border: 1px solid transparent;
  border-radius: var(--r1);
  transition: all var(--t-fast);
  min-height: 34px;
}
.hud-btn:hover { border-color: var(--line-strong); background: rgba(51,74,77,.05); }

/* ============================================================
   舞台与纸页
   ============================================================ */
.stage {
  min-height: 100vh;
  padding: 104px var(--s4) 96px;
  display: flex; justify-content: center;
  position: relative;
}

.page {
  width: min(860px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r1);
  box-shadow: 0 20px 50px -40px rgba(37,40,38,.6);
  position: relative;
  display: flex; flex-direction: column;
}

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px var(--s4);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-tiny);
  letter-spacing: .18em;
  color: var(--mute);
}
.page-place { font-family: var(--font-song); color: var(--yq); }
.page-weather::before { content: '　'; }

.page-body {
  padding: 36px 44px 28px;
  min-height: 220px;
}

.page-choices {
  padding: 0 44px 24px;
  display: flex; flex-direction: column; gap: 10px;
}

.page-foot {
  padding: 12px var(--s4);
  border-top: 1px solid var(--line-2);
  display: flex; justify-content: space-between; align-items: center;
  font-size: var(--fs-tiny);
  color: var(--mute);
  letter-spacing: .1em;
}

@media (max-width: 720px) {
  .stage { padding: 88px 12px 92px; }
  .page-body { padding: 24px 20px 20px; }
  .page-choices { padding: 0 20px 20px; }
  .hud { padding: 0 12px; height: 60px; }
  .hud-stats { gap: 10px; }
  .stat { min-width: 62px; }
  .hud-left, .hud-right { min-width: auto; }
  .hud-dark, .hud-chap { display: none; }
}

/* ---------- 文字行 ---------- */
.line {
  margin: 0 0 1.05em;
  font-size: var(--fs-body);
  line-height: 2.02;
  letter-spacing: .012em;
}
.line.narr {
  font-family: var(--font-song);
  color: var(--xh);
  text-indent: 2em;
}
.line.say { display: flex; gap: 14px; }
.line.say .who {
  flex: 0 0 auto;
  font-family: var(--font-hei);
  font-size: 13px;
  letter-spacing: .1em;
  color: var(--yq);
  padding-top: .55em;
  min-width: 4.2em;
  opacity: .85;
}
.line.say .what {
  flex: 1;
  font-family: var(--font-song);
  color: var(--xh);
}
.line.inner {
  font-family: var(--font-kai);
  color: #55564F;
  font-size: 17.5px;
  padding-left: 2em;
  border-left: 2px solid var(--line);
  margin-left: 2px;
}
.line.doc {
  font-family: var(--font-fang);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--yq);
  padding: 16px 20px;
  font-size: 17px;
  line-height: 1.9;
  color: #2E312F;
  white-space: pre-wrap;
  text-indent: 0;
}
.line.quote {
  font-family: var(--font-song);
  background: rgba(168,146,121,.08);
  border-left: 2px solid var(--jin);
  padding: 14px 18px;
  font-size: 17px;
  text-indent: 0;
}
.line.hand {
  font-family: var(--font-kai);
  font-size: 19px;
  color: #3B3D3A;
  text-indent: 0;
  padding-left: 1em;
}
.line.sys {
  font-size: var(--fs-small);
  color: var(--mute);
  text-align: center;
  text-indent: 0;
  letter-spacing: .1em;
  margin: 1.6em 0;
}
.line.sys::before, .line.sys::after {
  content: ''; display: inline-block; vertical-align: middle;
  width: 26px; height: 1px; background: var(--line-strong); margin: 0 12px;
}
.line .em { color: var(--zh); }

/* ---------- 选项 ---------- */
.choice {
  position: relative;
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%;
  padding: 15px 18px;
  text-align: left;
  border: 1px solid var(--line-strong);
  border-radius: var(--r1);
  background: rgba(255,255,255,.4);
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              transform .12s var(--ease);
  min-height: 48px;
}
.choice:hover:not(:disabled) {
  background: rgba(51,74,77,.055);
  border-color: var(--yq);
}
.choice:active:not(:disabled) { transform: translateY(1px); }
.choice:disabled { opacity: .38; }

.choice .idx {
  flex: 0 0 auto;
  font-family: var(--font-num);
  font-size: 13px;
  color: var(--mute);
  padding-top: .35em;
  min-width: 1.4em;
}
.choice .body { flex: 1; }
.choice .txt {
  font-size: 17px;
  line-height: 1.65;
  color: var(--xh);
}
.choice .hint {
  margin-top: 5px;
  font-size: var(--fs-tiny);
  color: var(--mute);
  letter-spacing: .04em;
}
.choice .cost {
  flex: 0 0 auto;
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--yq);
  border: 1px solid var(--line-strong);
  padding: 2px 6px;
  border-radius: 2px;
  margin-top: 2px;
}

/* 盖章类选项 */
.choice.seal {
  border-color: rgba(185,74,61,.5);
  background: rgba(185,74,61,.028);
}
.choice.seal:hover:not(:disabled) {
  border-color: var(--zh);
  background: rgba(185,74,61,.06);
}
.choice.seal .idx { color: var(--zh); }
.choice.seal .cost { border-color: rgba(185,74,61,.4); color: var(--zh); }

/* ============================================================
   底栏
   ============================================================ */
.dock {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--s4);
  background: rgba(247,244,236,.94);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  font-size: var(--fs-tiny);
  letter-spacing: .14em;
  color: var(--mute);
}
.dock-label { margin-right: 6px; }
.dock-day { color: var(--xh); font-family: var(--font-num); }
.dock-mid { flex: 1; text-align: center; letter-spacing: .2em; }
.dock-right { display: flex; align-items: center; gap: var(--s2); }
.dock-intel { color: var(--yq); font-family: var(--font-num); }
.dock-btn {
  font-size: var(--fs-tiny); letter-spacing: .14em;
  padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: var(--r1);
  min-height: 32px;
}
.dock-btn:hover { border-color: var(--yq); background: rgba(51,74,77,.05); }

/* ============================================================
   覆盖层与面板
   ============================================================ */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(37,40,38,.42);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s4);
  animation: fadeIn .24s var(--ease);
}
.overlay-panel {
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--r2);
  width: min(1080px, 100%);
  max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 40px 80px -40px rgba(0,0,0,.5);
  animation: riseIn .32s var(--ease);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px var(--s3);
  border-bottom: 1px solid var(--line);
}
.panel-title {
  font-family: var(--font-song);
  font-size: var(--fs-h2);
  letter-spacing: .2em;
  color: var(--xh);
}
.panel-sub { font-size: var(--fs-tiny); color: var(--mute); letter-spacing: .14em; margin-top: 2px; }
.panel-close { font-size: var(--fs-tiny); color: var(--mute); padding: 6px 10px; letter-spacing: .1em; }
.panel-close:hover { color: var(--zh); }
.panel-body { padding: var(--s3); overflow: auto; flex: 1; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 var(--s3); }
.tab {
  padding: 11px 16px;
  font-size: var(--fs-small);
  color: var(--mute);
  letter-spacing: .1em;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.on { color: var(--xh); border-bottom-color: var(--zh); }
.tab:hover { color: var(--xh); }

/* ============================================================
   提示
   ============================================================ */
.toast-wrap {
  position: fixed; z-index: 90;
  left: 50%; bottom: 78px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(37,40,38,.9);
  color: #F7F4EC;
  font-size: var(--fs-small);
  letter-spacing: .08em;
  padding: 9px 18px;
  border-radius: var(--r1);
  animation: toastIn .3s var(--ease);
  max-width: 76vw;
}
.toast.out { animation: toastOut .4s var(--ease) forwards; }
.toast.warn { background: rgba(185,74,61,.94); }

/* ============================================================
   结局
   ============================================================ */
.end-wrap { max-width: 720px; margin: 0 auto; text-align: center; padding: var(--s5) 0; }
.end-num { font-size: var(--fs-tiny); letter-spacing: .5em; color: var(--mute); margin-bottom: var(--s3); }
.end-title {
  font-family: var(--font-song);
  font-size: 40px; letter-spacing: .3em;
  margin: 0 0 var(--s4) .3em;
}
.end-body { text-align: left; }
