:root {
  --paper: #efe6d2; --paper-2: #e6dac2; --paper-3: #dcceaf; --ink: #2a2119; --ink-2: #5a4d3f; --muted: #8a7d6b;
  --zhu: #9b2423; --zhu-2: #b8332f; --dian: #2f4a6b; --zhe: #a66b2c; --qing: #5f7a4f; --gold: #c9a227;
  --line: #cdbd9a; --card: rgba(248, 242, 229, .96);
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --kai: "Ma Shan Zheng", "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif SC", serif;
  --mono: "SF Mono", Menlo, Consolas, monospace;
  --col: 640px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font-family: var(--serif); background: var(--paper); color: var(--ink); line-height: 1.75; font-size: 16px; overflow: hidden; }
a { color: var(--zhu); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-family: var(--kai); font-weight: 400; }
p { margin: 0 0 .6em; }
button { font-family: inherit; font-size: inherit; cursor: pointer; color: var(--ink); }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: var(--mono); font-size: 12px; letter-spacing: .04em; }
.mt { margin-top: 14px; }
.label { font-size: 12px; color: var(--muted); letter-spacing: .14em; margin: 0 0 2px; }
.tag-h, .tag-d { display: inline-block; font-size: 12px; padding: 0 6px; border-radius: 2px; margin-right: 5px; line-height: 1.6; vertical-align: 1px; font-family: var(--kai); }
.tag-h { background: var(--dian); color: #fff; } .tag-d { background: var(--zhe); color: #fff; }

/* ===== 舞台 ===== */
.stage-bg { position: fixed; inset: 0; z-index: 0; background: var(--paper-2); }
.stage-bg svg { width: 100%; height: 100%; display: block; animation: fadein .6s ease; }
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
.stage-fx { position: fixed; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(rgba(42,33,25,.06), rgba(42,33,25,.22) 70%, rgba(42,33,25,.42)); }
.screen { position: relative; z-index: 2; display: flex; flex-direction: column; height: 100vh; height: 100dvh; width: 100%; }
.bg-space { flex: 0 0 auto; height: 12vh; width: min(var(--col), 100% - 24px); margin: 0 auto; display: flex; align-items: flex-end; justify-content: flex-end; }
.scene-cap { font-family: var(--kai); color: #fff; text-shadow: 0 1px 6px rgba(42,33,25,.9); font-size: 14px; letter-spacing: .06em; padding-bottom: 6px; }
.panel { flex: 1 1 auto; min-height: 0; overflow: auto; width: min(var(--col), 100% - 24px); margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 16px 40px rgba(42,33,25,.25); padding: 14px 18px; -webkit-overflow-scrolling: touch; }
.actions { flex: 0 0 auto; width: min(var(--col), 100% - 24px); margin: 8px auto; margin-bottom: max(10px, env(safe-area-inset-bottom)); }
.advance { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }

/* 按钮 */
.primary { background: var(--zhu); color: #fff; border: 0; padding: 9px 26px; border-radius: 4px; letter-spacing: .2em; font-family: var(--kai); font-size: 19px; box-shadow: 0 4px 14px rgba(155,36,35,.35); }
.primary:hover { background: var(--zhu-2); }
.primary.big { font-size: 22px; padding: 12px 40px; }
.ghost { background: var(--card); border: 1px solid var(--ink-2); color: var(--ink); padding: 9px 20px; border-radius: 4px; font-family: var(--kai); font-size: 18px; letter-spacing: .1em; }
.ghost:hover { background: #fff; }
.tb { background: var(--card); border: 1px solid var(--line); padding: 6px 11px; border-radius: 4px; font-size: 14px; }
.tb.on, .speeds button.on, .seg button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.speeds { display: flex; } .speeds button { background: var(--card); border: 1px solid var(--line); padding: 6px 10px; font-size: 13px; margin-left: -1px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { background: #fff; border: 1px solid var(--line); padding: 5px 10px; border-radius: 3px; font-size: 13px; }
select { font-family: inherit; font-size: 14px; padding: 6px 10px; background: #fff; border: 1px solid var(--line); border-radius: 3px; color: var(--ink); max-width: 100%; }

/* ===== 首页 ===== */
#home { align-items: center; justify-content: center; }
.home-center { text-align: center; padding: 34px 40px 30px; width: min(620px, 100% - 24px); background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 16px 40px rgba(42,33,25,.28); outline: 1px solid var(--line); outline-offset: -7px; }
.kicker { font-size: 12.5px; color: var(--ink-2); letter-spacing: .16em; margin: 0; }
.home-center h1 { font-size: clamp(56px, 9vw, 88px); letter-spacing: .2em; margin: 4px 0 4px; padding-left: .2em; }
.home-center h1::after { content: ""; display: block; width: 56px; height: 3px; background: var(--zhu); margin: 2px auto 14px; }
.lede { font-size: 15.5px; max-width: 32em; margin: 0 auto 20px; text-align: left; line-height: 1.95; color: var(--ink-2); }
.home-links { margin-top: 16px; display: flex; gap: 10px; justify-content: center; align-items: center; color: var(--muted); }
.home-links button { background: none; border: 0; font-family: var(--kai); font-size: 17px; color: var(--ink-2); letter-spacing: .1em; padding: 2px 4px; border-bottom: 1px solid transparent; }
.home-links button:hover { border-bottom-color: var(--zhu); color: var(--zhu); }

/* ===== 弹层 ===== */
.modal { position: fixed; inset: 0; background: rgba(42,33,25,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 14px; }
.modal-box { background: var(--card); max-width: 720px; width: 100%; max-height: 92vh; max-height: 92dvh; overflow: auto; border-radius: 6px; padding: 18px 22px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.modal-head h2 { font-size: 28px; }
.modal-box h4 { font-size: 18px; color: var(--zhu); margin: 10px 0 2px; }
.modal-box .x { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--muted); padding: 4px 8px; }
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.role { text-align: left; background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--ink-2); border-radius: 4px; padding: 12px 14px; display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; transition: transform .12s, box-shadow .12s; }
.role:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(42,33,25,.15); }
.role[data-role="official"] { border-left-color: var(--zhu); } .role[data-role="folk"] { border-left-color: var(--qing); } .role[data-role="merchant"] { border-left-color: var(--dian); }
.role-ic { width: 44px; height: 44px; display: block; } .role-ic svg { width: 100%; height: 100%; }
.role b { font-family: var(--kai); font-weight: 400; font-size: 22px; letter-spacing: .1em; display: block; }
.role p { font-size: 13px; color: var(--ink-2); margin: 0; line-height: 1.65; }
.fine { margin-top: 12px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 4px; padding: 6px 12px; }
.fine summary { cursor: pointer; font-family: var(--kai); font-size: 16px; }
.fine-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 10px 0 4px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.warn { font-size: 12.5px; color: var(--muted); margin: 12px 0 0; padding-top: 8px; border-top: 1px dashed var(--line); }
.shrine-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.shrine-item { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--zhu); padding: 10px 12px; border-radius: 3px; font-size: 13px; }
.shrine-item b { display: block; font-size: 19px; font-family: var(--kai); font-weight: 400; }
.shrine-item .yrs { color: var(--muted); font-size: 12px; }
.shrine-empty { color: var(--muted); margin-top: 8px; }

/* ===== 户帖 ===== */
.hutie { padding: 0; }
.hutie-head { background: var(--zhu); color: #fff; display: flex; justify-content: space-between; align-items: center; padding: 8px 18px; letter-spacing: .4em; font-family: var(--kai); font-size: 20px; }
.hutie-body { padding: 14px 18px 16px; }
.hutie h2 { font-size: 40px; margin: 0 0 6px; }
.intro { font-size: 16px; line-height: 1.85; }
.kv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 14px; margin: 12px 0; }
.kv-grid div { border-top: 1px solid var(--line); padding-top: 5px; }
.kv-grid b { display: block; font-size: 14px; }
.hutie-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 6px 0 10px; }
.hutie-cols h4 { font-size: 17px; margin-bottom: 6px; }
.pmap { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
.pmap span { background: var(--paper-2); font-size: 12px; text-align: center; padding: 6px 1px; border-radius: 2px; color: var(--muted); font-family: var(--kai); }
.pmap span.me { background: var(--zhu); color: #fff; }
.pmap span.blank { background: transparent; }
.companions { display: grid; grid-template-columns: 1fr; gap: 6px; }
.comp { background: var(--paper-2); padding: 6px 9px; border-radius: 3px; font-size: 12.5px; line-height: 1.5; }
.comp b { font-family: var(--kai); font-weight: 400; font-size: 15px; margin-right: 6px; }
.comp .st { color: var(--zhu); }
.comp.dead { opacity: .6; } .comp.dead .st { color: var(--muted); }

/* ===== 年谱 · 状态栏 ===== */
.hud { flex: 0 0 auto; width: min(var(--col), 100% - 24px); margin: 10px auto 0; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px 6px; box-shadow: 0 6px 20px rgba(42,33,25,.2); }
.hud-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.hud-l { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.nian { font-family: var(--kai); font-size: 24px; color: var(--zhu); white-space: nowrap; }
.gz { font-family: var(--kai); font-size: 14px; color: var(--muted); }
.hud-l b { font-family: var(--kai); font-weight: 400; font-size: 24px; white-space: nowrap; }
.who { color: var(--ink-2); font-size: 13px; }
.hud-r { display: flex; gap: 6px; }
.hud-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 6px 0 6px; }
.hud-stats .st { font-size: 12px; color: var(--muted); }
.hud-stats .st b { display: block; font-family: var(--kai); font-weight: 400; font-size: 18px; color: var(--ink); line-height: 1.1; }
.hud-stats .st i { display: block; height: 4px; background: var(--paper-3); border-radius: 1px; overflow: hidden; margin-top: 3px; }
.hud-stats .st i b { display: block; height: 100%; background: var(--zhu); font-size: 0; }
.strip { display: flex; gap: 2px; align-items: flex-end; height: 10px; }
.strip i { flex: 1; height: 7px; background: var(--paper-3); border-radius: 1px; position: relative; min-width: 2px; }
.strip i.now { outline: 2px solid var(--ink); outline-offset: 1px; height: 10px; }
.strip i.frame::after { content: ""; position: absolute; right: -2px; top: -5px; bottom: -5px; width: 2px; background: var(--ink); }
.small-strip { height: 14px; margin: 8px 0; } .small-strip i { height: 10px; }

/* ===== 年谱 · 卷轴 ===== */
.chron { list-style: none; margin: 0; padding: 0; }
.yg { padding: 6px 0 8px; border-top: 1px solid var(--line); }
.yg:first-child { border-top: 0; }
.yg .yh { font-family: var(--kai); color: var(--zhu); font-size: 17px; letter-spacing: .08em; margin-bottom: 2px; }
.yg .yh small { color: var(--muted); font-size: 12px; margin-left: 8px; font-family: var(--serif); }
.yg.now .yh { font-size: 20px; }
.yg.now { background: #fff; margin: -14px -18px 6px; padding: 12px 18px 10px; border-bottom: 2px solid var(--zhu); }
.ev { font-size: 15px; line-height: 1.7; padding: 3px 0; color: var(--ink-2); }
.yg.now .ev { font-size: 17px; color: var(--ink); line-height: 1.8; }
.ev.quiet { color: var(--muted); } .ev.bad { color: #7a1f1f; } .ev.good { color: #2e5a2e; } .ev.choice { color: var(--dian); } .ev.death { color: var(--zhu); font-weight: 700; font-size: 18px; }
.yg.now .ev.bad { color: #8a1f1f; }
.ev.history, .ev.drama { background: var(--paper-2); border: 1px solid var(--line); border-left: 4px solid var(--dian); padding: 7px 11px; border-radius: 3px; margin: 5px 0; font-size: 13.5px; color: var(--ink-2); }
.ev.drama { border-left-color: var(--zhe); }
.ev.history b, .ev.drama b { font-family: var(--kai); font-weight: 400; font-size: 16px; color: var(--ink); margin-right: 5px; }
.yg.now .ev.history, .yg.now .ev.drama { font-size: 14.5px; }
.chron-end { text-align: center; color: var(--muted); font-size: 12px; padding: 10px 0 4px; font-family: var(--kai); }

/* ===== 年谱 · 操作 ===== */
.choice-box { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--zhu); border-radius: 6px; padding: 10px 14px 12px; margin-bottom: 8px; box-shadow: 0 10px 30px rgba(42,33,25,.25); }
.choice-head { margin-bottom: 8px; }
.choice-head b { font-family: var(--kai); font-weight: 400; font-size: 21px; display: block; letter-spacing: .04em; }
.choice-head span { font-size: 13.5px; color: var(--ink-2); }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 7px; max-height: 38vh; overflow: auto; }
.opt { text-align: left; background: #fff; border: 1px solid var(--line); padding: 8px 11px; border-radius: 4px; display: grid; gap: 1px; align-content: start; }
.opt:hover { border-color: var(--zhu); background: #fff8ee; box-shadow: 0 4px 14px rgba(155,36,35,.15); }
.opt b { font-size: 18px; font-family: var(--kai); font-weight: 400; letter-spacing: .06em; } .opt span { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
#btn-next { min-width: 200px; }

/* ===== 终卷 ===== */
.endpage h2 { font-size: 32px; margin-bottom: 8px; }
.end-grid { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: start; }
.tomb { text-align: center; border: 2px solid var(--ink); padding: 20px 10px; background: var(--paper-2); }
.tomb .head { font-family: var(--kai); font-size: 30px; letter-spacing: .26em; writing-mode: vertical-rl; margin: 0 auto; height: 330px; white-space: nowrap; }
.tomb .yrs { font-size: 12px; color: var(--muted); margin-top: 8px; }
.tomb .line { font-size: 14px; margin-top: 2px; font-family: var(--kai); }
.summary { font-size: 16px; line-height: 1.9; }
.companion-end { font-size: 13px; }
.companion-end div { border-top: 1px dashed var(--line); padding: 5px 0; }
.companion-end b { font-family: var(--kai); font-weight: 400; font-size: 16px; }
textarea { width: 100%; font-family: inherit; font-size: 14px; padding: 8px; border: 1px solid var(--line); background: #fff; border-radius: 3px; min-height: 56px; }

/* ===== 抽屉（户帖详情） ===== */
.drawer h3 { font-size: 24px; margin-bottom: 4px; }
.drawer-grid { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: start; }
.portrait { width: 72px; height: 90px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.portrait svg { width: 100%; height: 100%; display: block; }
dl { margin: 0; } dl dt { font-size: 11px; color: var(--muted); letter-spacing: .1em; } dl dd { margin: 0 0 3px; font-size: 13.5px; }
.drawer-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
.family div { font-size: 13.5px; border-top: 1px dashed var(--line); padding: 3px 0; }
.family div:first-child { border-top: 0; }
.family .gone { color: var(--muted); text-decoration: line-through; }
.facts-dl { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; font-size: 12.5px; }
.facts-dl dt { color: var(--muted); font-size: 12px; padding-top: 2px; } .facts-dl dd { margin: 0; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 8px 16px; border-radius: 3px; font-size: 14px; z-index: 60; }

/* ===== 响应式 ===== */
@media (min-width: 1500px) { :root { --col: 720px; } body { font-size: 17px; } .ev { font-size: 16px; } .yg.now .ev { font-size: 18px; } }
@media (max-width: 700px) {
  .stage-bg { height: 44vh; height: 44dvh; }
  .stage-fx { height: 44vh; height: 44dvh; background: linear-gradient(rgba(42,33,25,.05), rgba(42,33,25,.3)); }
  .bg-space { height: 0; }
  #home .home-center { padding: 22px 18px 20px; margin-top: 28vh; }
  .home-center h1 { font-size: 56px; } .lede { font-size: 14.5px; }
  #life .hud { margin-top: 8px; padding: 6px 10px 5px; }
  .nian, .hud-l b { font-size: 20px; } .gz, .who { display: none; }
  .hud-stats { gap: 5px; } .hud-stats .st { font-size: 11px; } .hud-stats .st b { font-size: 15px; }
  #life .bg-space, #birthcard .bg-space, #end .bg-space { height: 16vh; }
  .panel { padding: 12px 14px; }
  .yg.now { margin: -12px -14px 6px; padding: 10px 14px 8px; }
  .ev { font-size: 14px; } .yg.now .ev { font-size: 16px; }
  .opts { grid-template-columns: 1fr 1fr; }
  .primary.big { font-size: 19px; padding: 10px 24px; } #btn-next { min-width: 140px; }
  .role-grid { grid-template-columns: 1fr; } .fine-grid { grid-template-columns: 1fr; }
  .kv-grid { grid-template-columns: 1fr 1fr; } .hutie-cols { grid-template-columns: 1fr; }
  .end-grid { grid-template-columns: 1fr; } .tomb .head { height: auto; font-size: 26px; writing-mode: horizontal-tb; }
  .drawer-cols { grid-template-columns: 1fr; } .shrine-list { grid-template-columns: 1fr; }
}
