:root {
  --ink: #2b2721;
  --ink-soft: #5b5346;
  --paper: #efe7d6;
  --paper-2: #e6dcc6;
  --seal: #9a2f24;
  --seal-soft: #c0503f;
  --gold: #8a6d3b;
  --line: #cdbfa2;
  --shadow: rgba(43, 39, 33, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #2a2620;
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", "STKaiti", "KaiTi", "楷体", serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 400px at 50% -10%, #f6efe0, transparent),
    var(--paper);
  background-color: var(--paper);
  box-shadow: 0 0 60px var(--shadow);
  position: relative;
}

/* 顶栏 */
#topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#f2ead9, #e9dfc9);
}
.seal {
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--paper);
  background: var(--seal);
  padding: 4px 12px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25);
  font-size: 18px;
}
#scene-time {
  color: var(--ink-soft);
  font-size: 14px;
  letter-spacing: 2px;
  flex: 1;
}
.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.ghost-btn:hover { border-color: var(--seal); color: var(--seal); }

/* 主区 */
#screen {
  flex: 1;
  padding: 28px 30px 40px;
  overflow-y: auto;
}

/* 开场 / 标题 */
.title-block { text-align: center; padding: 24px 6px 10px; }
.title-block h1 {
  font-size: 46px;
  letter-spacing: 12px;
  margin: 8px 0 4px;
  color: var(--ink);
}
.title-block .sub {
  color: var(--ink-soft);
  letter-spacing: 6px;
  font-size: 15px;
  margin-bottom: 18px;
}

.prose {
  line-height: 2.05;
  font-size: 17px;
  color: var(--ink);
  margin: 0 auto 22px;
  max-width: 40em;
  text-align: justify;
}
.prose p { margin: 0 0 14px; text-indent: 2em; }
.prose .lead { text-indent: 0; color: var(--ink-soft); }
.prose .say { text-indent: 0; }
.prose .say::before { content: "「"; color: var(--seal); }
.prose .say::after { content: "」"; color: var(--seal); }

.divider {
  text-align: center;
  color: var(--gold);
  letter-spacing: 8px;
  margin: 6px 0 20px;
  font-size: 13px;
}

/* 角色选择卡 */
.char-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}
.char-card {
  text-align: left;
  border: 1px solid var(--line);
  background: linear-gradient(#f4eddd, #ece2cd);
  border-radius: 6px;
  padding: 14px 16px;
  cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
  font-family: inherit;
  color: var(--ink);
}
.char-card:hover {
  transform: translateY(-2px);
  border-color: var(--seal);
  box-shadow: 0 6px 16px var(--shadow);
}
.char-card .cc-head {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px;
}
.char-card .cc-letter {
  color: var(--paper); background: var(--ink);
  width: 22px; height: 22px; border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; flex: none;
}
.char-card .cc-name { font-size: 18px; font-weight: 600; }
.char-card .cc-zi { color: var(--ink-soft); font-size: 13px; }
.char-card .cc-cat {
  margin-left: auto; font-size: 12px; color: var(--seal);
  border: 1px solid var(--seal-soft); border-radius: 10px; padding: 1px 8px;
}
.char-card .cc-line { color: var(--ink-soft); font-size: 14px; line-height: 1.7; }

/* 选项 */
.choices { margin-top: 8px; }
.choice-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: linear-gradient(#f4eddd, #eaded);
  background: #f4eddd;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 5px;
  padding: 13px 16px;
  margin-bottom: 11px;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  line-height: 1.6;
  transition: border-color .12s, background .12s, transform .1s;
}
.choice-btn:hover {
  border-color: var(--seal);
  border-left-color: var(--seal);
  background: #f7f1e3;
  transform: translateX(2px);
}
.choice-btn .ck { color: var(--seal); font-weight: 700; margin-right: 8px; }

/* 结局 */
.ending {
  border: 1px solid var(--gold);
  background: linear-gradient(#f6efdf, #efe4cd);
  border-radius: 8px;
  padding: 26px 28px;
  margin-top: 6px;
  box-shadow: 0 4px 20px var(--shadow);
}
.ending h2 {
  text-align: center;
  color: var(--seal);
  letter-spacing: 8px;
  font-size: 30px;
  margin: 4px 0 6px;
}
.ending .ending-tag {
  text-align: center; color: var(--gold); letter-spacing: 4px;
  font-size: 13px; margin-bottom: 18px;
}

/* 状态栏 */
#statusbar {
  border-top: 1px solid var(--line);
  background: linear-gradient(#ece2cc, #e3d7bd);
  padding: 12px 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
}
#statusbar .who { font-weight: 700; letter-spacing: 2px; margin-right: 6px; }
.stat-pill { display: inline-flex; align-items: baseline; gap: 6px; font-size: 14px; }
.stat-pill .k { color: var(--ink-soft); }
.stat-pill .v { font-weight: 700; min-width: 20px; text-align: right; }
.stat-pill.derived .k { color: var(--gold); }
.stat-pill .bar {
  width: 54px; height: 6px; border-radius: 3px;
  background: #d8cbb0; overflow: hidden; align-self: center;
}
.stat-pill .bar > i { display: block; height: 100%; background: var(--seal); }
.stat-pill.up .v { animation: flash-up .8s; }
.stat-pill.down .v { animation: flash-down .8s; }
@keyframes flash-up { 0%{color:#2e7d32; transform:scale(1.35);} 100%{color:inherit; transform:none;} }
@keyframes flash-down { 0%{color:var(--seal); transform:scale(1.35);} 100%{color:inherit; transform:none;} }

.center { text-align: center; }
.mt { margin-top: 18px; }
.primary-btn {
  background: var(--seal); color: var(--paper);
  border: none; border-radius: 5px; padding: 11px 24px;
  font-family: inherit; font-size: 16px; letter-spacing: 3px; cursor: pointer;
}
.primary-btn:hover { background: var(--seal-soft); }
.hint { color: var(--ink-soft); font-size: 13px; letter-spacing: 2px; }

/* ============ 视觉小说(绘)模式 ============ */
#screen.vn-mode { padding: 0; overflow: hidden; }

.vn {
  position: relative;
  height: 68vh;
  min-height: 460px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 背景(缺图时用季节渐变占位) */
.vn-bg {
  position: absolute; inset: 0;
  z-index: 0;
}
.vn-bg.season-spring { background: linear-gradient(160deg,#eaf0da,#cfe0c9 45%,#a9c6a6); }
.vn-bg.season-summer { background: linear-gradient(160deg,#dff0ec,#a9d8cf 45%,#6fb3a8); }
.vn-bg.season-autumn { background: linear-gradient(160deg,#f3e6cc,#e0b87e 45%,#b9793f); }
.vn-bg.season-winter { background: linear-gradient(160deg,#eef1f4,#c6cfd8 45%,#93a1b0); }
.vn-bg-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vn-bg-label {
  position: absolute; top: 12px; left: 16px;
  color: rgba(43,39,33,.45); letter-spacing: 4px; font-size: 13px;
}

/* HUD:绘模式的状态条 */
.vn-hud {
  position: absolute; top: 8px; right: 12px; z-index: 3;
  display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: flex-end;
  max-width: 78%;
  background: rgba(239,231,214,.72);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px;
  backdrop-filter: blur(2px);
}
.vn-hud .stat-pill { font-size: 12px; }
.vn-hud .stat-pill .bar { width: 38px; }

/* 立绘位 */
.vn-stage { position: absolute; inset: 0; z-index: 1; display: flex; align-items: flex-end; justify-content: flex-end; }
.vn-sprite { position: relative; margin: 0 6% 0 0; height: 82%; display: flex; align-items: flex-end; }
.sprite-ph {
  width: 190px; height: 300px;
  border: 2px dashed rgba(43,39,33,.35);
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, rgba(255,255,255,.28), rgba(154,47,36,.10));
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 14px; text-align: center;
  color: var(--ink); letter-spacing: 2px; font-size: 15px;
  writing-mode: vertical-rl; text-orientation: upright;
}
.vn-sprite-img {
  position: absolute; bottom: 0; right: 0;
  max-height: 100%; max-width: 260px; object-fit: contain;
}

/* 对话框 */
.vn-box {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
  min-height: 150px;
  margin: 0 14px 14px;
  background: rgba(244,237,221,.94);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 16px 20px 30px;
  box-shadow: 0 6px 22px var(--shadow);
  cursor: pointer;
  backdrop-filter: blur(1px);
}
.vn-name {
  display: inline-block;
  color: var(--paper); background: var(--seal);
  padding: 2px 14px; border-radius: 4px;
  font-size: 15px; letter-spacing: 2px;
  margin-bottom: 10px; min-height: 1em;
}
.vn-text { line-height: 2; font-size: 17px; color: var(--ink); min-height: 3em; }
.vn-text p { margin: 0; text-indent: 0; }
.vn-text .say::before { content: "「"; color: var(--seal); }
.vn-text .say::after { content: "」"; color: var(--seal); }
.vn-text .lead { color: var(--ink-soft); }
.vn-next {
  position: absolute; right: 18px; bottom: 8px;
  color: var(--seal); font-size: 13px; letter-spacing: 2px;
  animation: blink 1.4s infinite;
}
@keyframes blink { 0%,100%{opacity:.3;} 50%{opacity:1;} }

/* 绘模式选项浮层 */
.vn-choices {
  position: absolute; left: 0; right: 0; bottom: 0; top: 0; z-index: 5;
  display: flex; flex-direction: column; justify-content: center;
  gap: 12px; padding: 0 12%;
  background: rgba(43,39,33,.32);
}
/* hidden 属性必须能压过上面的 display:flex,否则空浮层会盖住对话框拦截点击 */
.vn-choices[hidden] { display: none; }
.vn-choices .choice-btn { background: #f4eddd; margin: 0; }

/* 结局附带的数值 & 线索簿 */
.ending-stats {
  display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center;
  margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line);
}
.clue-ledger {
  margin: 18px auto 0; max-width: 34em;
  border: 1px solid var(--line); border-radius: 6px;
  background: rgba(255,255,255,.35);
  padding: 12px 16px; font-size: 14px; line-height: 1.9; color: var(--ink-soft);
}
.clue-ledger .cl-title { text-align: center; color: var(--gold); letter-spacing: 4px; margin-bottom: 6px; }

@media (max-width: 560px) {
  .char-grid { grid-template-columns: 1fr; }
  .title-block h1 { font-size: 36px; letter-spacing: 8px; }
  #screen { padding: 20px 18px 32px; }
  .vn { height: 74vh; }
  .sprite-ph { width: 120px; height: 210px; }
  .vn-sprite-img { max-width: 150px; }
  .vn-hud { max-width: 94%; }
}
