:root {
  --paper: #f7f3ea;
  --paper-2: #fffdf8;
  --ink: #23211c;
  --ink-soft: #4a443c;
  --muted: #8c8479;
  --line: #ded6c7;
  --accent: #a4472c;
  --owner: #4b6478;
  --serif: "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "SimSun", Georgia, serif;
  --sans: "Noto Sans CJK SC", "Source Han Sans SC", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #fdfaf4 0%, transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.95;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

main {
  max-width: 660px;
  margin: 0 auto;
  padding: 1rem 1.4rem 5rem;
}

/* ---------- 顶栏 ---------- */
.topbar {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.1rem 1.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sans);
  font-size: .86rem;
}
.mark {
  text-decoration: none;
  letter-spacing: .14em;
  color: var(--ink);
  font-weight: 600;
}
.topbar nav a { color: var(--muted); text-decoration: none; letter-spacing: .04em; }
.topbar nav a:hover { color: var(--ink); }

/* ---------- 按钮 ---------- */
.btn-primary, .btn-ghost {
  display: inline-block;
  font-family: var(--sans);
  font-size: .95rem;
  padding: .72rem 1.6rem;
  border-radius: 999px;
  text-decoration: none;
  transition: .18s ease;
}
.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
}
.btn-primary:hover { background: #000; transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover { border-color: var(--muted); }

/* ---------- 落地页 ---------- */
.intro { text-align: center; padding: 3rem 0 2rem; }

.kicker {
  font-family: var(--sans);
  font-size: .78rem;
  letter-spacing: .22em;
  color: var(--muted);
  text-transform: uppercase;
  margin: 0 0 1.6rem;
}

.intro h1 {
  font-size: 2.6rem;
  line-height: 1.38;
  letter-spacing: .01em;
  margin: 0 0 2rem;
  font-weight: 500;
}

.lede { color: var(--ink-soft); }
.lede p { margin: .9rem 0; }
.lede .strong { color: var(--accent); font-weight: 600; }

.intro .btn-primary { margin-top: 2.4rem; }

.note {
  font-family: var(--sans);
  font-size: .8rem;
  line-height: 1.8;
  color: var(--muted);
  max-width: 26em;
  margin: 3rem auto 0;
}

.how {
  margin-top: 4rem;
  padding-top: 2.4rem;
  border-top: 1px solid var(--line);
}
.how h2 {
  font-family: var(--sans);
  font-size: .8rem;
  letter-spacing: .2em;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  margin: 0 0 1.2rem;
}
.how ol { padding-left: 1.2rem; margin: 0; }
.how li { margin: .9rem 0; color: var(--ink-soft); font-size: .96rem; }
.how b { color: var(--ink); }

/* ---------- 故事页 ---------- */
.story { padding-top: 1.5rem; }

.birthcard {
  text-align: center;
  padding-bottom: 1.8rem;
  border-bottom: 1px solid var(--line);
}
.breed {
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.birthcard .meta {
  font-family: var(--sans);
  font-size: .82rem;
  color: var(--muted);
  margin-top: .5rem;
  letter-spacing: .04em;
}

.ageblock { margin-top: 2.4rem; }

.age {
  display: flex;
  align-items: center;
  gap: .9rem;
  margin-bottom: .9rem;
}
.age span {
  font-family: var(--sans);
  font-size: .76rem;
  letter-spacing: .16em;
  color: var(--muted);
  white-space: nowrap;
}
.age::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.ev {
  margin: .95rem 0;
  animation: rise .5s ease both;
  /* 进场动画带 translateY(6px)，不设 scroll-margin 的话
     锚点滚动会算早了 6px，元素最后停在视口上方一点点 */
  scroll-margin-top: 2.5rem;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.ev.setup {
  margin-top: 1.6rem;
  color: var(--ink);
  font-size: 1.02rem;
}
.ev.you {
  color: var(--accent);
  font-weight: 600;
  padding-left: 1.1rem;
  position: relative;
}
.ev.you::before {
  content: "▸";
  position: absolute;
  left: 0;
}
.ev.result {
  margin-left: 1.1rem;
  padding-left: 1.1rem;
  border-left: 2px solid var(--line);
  color: var(--ink-soft);
}
.ev.owner {
  margin-left: 1.1rem;
  padding-left: 1.1rem;
  border-left: 2px solid #ccd7de;
  color: var(--owner);
}
.ev.life { color: var(--ink-soft); }

/* ---------- 选择 ---------- */
.choice {
  scroll-margin-top: 2.5rem;
  margin-top: 3.2rem;
  padding-top: 2.2rem;
  border-top: 1px dashed var(--line);
}
.choice .q {
  font-size: 1.12rem;
  margin: 0 0 .4rem;
  color: var(--ink);
}
.progress {
  font-family: var(--sans);
  font-size: .76rem;
  letter-spacing: .14em;
  color: var(--muted);
  margin: 0 0 1.3rem;
}
.options { display: grid; gap: .65rem; }
.opt {
  display: block;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-2);
  text-decoration: none;
  color: var(--ink);
  font-size: .98rem;
  line-height: 1.7;
  transition: .18s ease;
}
.opt:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(120, 100, 80, .10);
}
.hint {
  font-family: var(--sans);
  font-size: .78rem;
  color: var(--muted);
  margin-top: 1.6rem;
  line-height: 1.9;
}
.hint a { color: var(--muted); }

/* ---------- 死亡报告 ---------- */
.report {
  scroll-margin-top: 2rem;
  margin-top: 3.4rem;
  padding-top: 2.4rem;
  border-top: 1px solid var(--ink);
}
.report h2 {
  font-size: 3.4rem;
  line-height: 1;
  margin: .6rem 0 .4rem;
  font-weight: 600;
}
.report h2 small {
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: .3rem;
}
.cause { font-size: 1.05rem; margin: .3rem 0 .2rem; }
.pct { font-family: var(--sans); font-size: .84rem; color: var(--muted); margin: 0; }

.att { margin: 2rem 0 1.6rem; }
.att-label {
  font-family: var(--sans);
  font-size: .76rem;
  letter-spacing: .14em;
  color: var(--muted);
  margin-bottom: .5rem;
}
.bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.att-num {
  font-family: var(--sans);
  font-size: .78rem;
  color: var(--muted);
  margin-top: .4rem;
}

.epitaph {
  font-size: 1.12rem;
  color: var(--ink);
  margin: 1.8rem 0 2.4rem;
  padding-left: 1rem;
  border-left: 3px solid var(--accent);
}

.report h3 {
  font-family: var(--sans);
  font-size: .78rem;
  letter-spacing: .18em;
  color: var(--muted);
  font-weight: 500;
  margin: 2.2rem 0 .8rem;
  text-transform: uppercase;
}
.plist { list-style: none; padding: 0; margin: 0; }
.plist li {
  font-size: 1rem;
  color: var(--ink-soft);
  padding: .55rem 0;
  border-bottom: 1px solid rgba(222, 214, 199, .6);
  line-height: 1.8;
}
.pl-age {
  font-family: var(--sans);
  font-size: .74rem;
  color: var(--muted);
  margin-right: .7rem;
  letter-spacing: .06em;
}
.owner-list li { color: var(--owner); }

.actions {
  display: flex;
  gap: .7rem;
  flex-wrap: wrap;
  margin-top: 2.6rem;
}

/* ---------- 分享 ---------- */
.sharewrap { text-align: center; padding-top: 2rem; }
.shareimg {
  width: 100%;
  max-width: 420px;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(90, 75, 55, .14);
  margin: 1rem 0 2rem;
}
.sharewrap .actions { justify-content: center; }

/* ---------- 关于 ---------- */
.about { max-width: 640px; }
.about h1 { font-size: 2rem; font-weight: 500; margin: 1rem 0 2rem; }
.about h2 {
  font-family: var(--sans);
  font-size: .82rem;
  letter-spacing: .16em;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  margin: 2.6rem 0 .9rem;
}
.about p, .about li { font-size: .96rem; color: var(--ink-soft); }
.about ul { padding-left: 1.2rem; }
.about li { margin: .4rem 0; }
.about b { color: var(--ink); }
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  line-height: 1.7;
  color: var(--ink-soft);
}
.dim { color: var(--muted); font-size: .88rem; }

/* ---------- 页脚 ---------- */
.foot {
  max-width: 660px;
  margin: 4rem auto 0;
  padding: 2rem 1.4rem 3rem;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: .76rem;
  line-height: 1.9;
  color: var(--muted);
}
.foot a { color: var(--muted); }
.foot p { margin: .3rem 0; }

@media (max-width: 640px) {
  body { font-size: 16.5px; }
  .intro h1 { font-size: 2rem; }
  .report h2 { font-size: 2.8rem; }
  main { padding: .5rem 1.1rem 4rem; }
}

/* ---------- 翻页的一拍 ---------- */
.opt { transition: opacity .45s ease, transform .45s ease, border-color .45s ease; }
.opt.dimmed { opacity: .18; }
.opt.picked {
  opacity: 1;
  border-color: var(--accent);
  background: #fff;
  transform: translateY(-2px);
}
body.turning .choice .q,
body.turning .progress { opacity: .35; transition: opacity .4s ease; }

/* 落地的结果慢一点出来，不要和翻页抢 */
.just-landed {
  animation: land 1.1s cubic-bezier(.22, .61, .36, 1) both;
}
@keyframes land {
  0%   { opacity: 0; transform: translateY(10px); filter: blur(1px); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: none; filter: none; }
}

/* ═══════════ 计时播放器 ═══════════ */
.player { padding-top: .5rem; padding-bottom: 5.5rem; }

.phead { text-align: center; padding-bottom: 1rem; }
.pbreed { font-size: 1.35rem; font-weight: 600; letter-spacing: .02em; }
.pmeta { font-family: var(--sans); font-size: .78rem; color: var(--muted); margin-top: .3rem; letter-spacing: .05em; }

/* 年份与年内进度：粘在顶上，眼睛随时知道过了多久 */
.pclock {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .7rem 0 .55rem;
  margin-bottom: .6rem;
  /* 必须不透明：半透明时正文会从下面透上来，糊成一片 */
  background: var(--paper);
  box-shadow: 0 1px 0 var(--line);
}
.page {
  font-family: var(--sans);
  font-size: .82rem;
  letter-spacing: .1em;
  color: var(--ink);
  min-width: 3.4em;
}
.pbar {
  flex: 1;
  height: 2px;
  background: var(--line);
  border-radius: 1px;
  overflow: hidden;
}
.pbar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .12s linear;
}
.prate {
  font-family: var(--sans);
  font-size: .72rem;
  color: var(--muted);
  min-width: 6.2em;
  text-align: right;
  letter-spacing: .04em;
}

/* 事件的出场：从下方浮上来，慢一点，像真的在发生 */
.pv {
  margin: .95rem 0;
  animation: pvin .9s cubic-bezier(.22, .61, .36, 1) both;
}
@keyframes pvin {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.pv.setup { margin-top: 1.5rem; color: var(--ink); font-size: 1.02rem; }
.pv.you { color: var(--accent); font-weight: 600; padding-left: 1.1rem; position: relative; }
.pv.you::before { content: "▸"; position: absolute; left: 0; }
.pv.result { margin-left: 1.1rem; padding-left: 1.1rem; border-left: 2px solid var(--line); color: var(--ink-soft); }
.pv.owner { margin-left: 1.1rem; padding-left: 1.1rem; border-left: 2px solid #ccd7de; color: var(--owner); }
.pv.life { color: var(--ink-soft); }

/* 选择 */
.pchoice {
  margin-top: 2.4rem;
  padding-top: 1.8rem;
  border-top: 1px dashed var(--line);
  animation: pvin .6s ease both;
}
.pq { font-size: 1.12rem; margin: 0 0 1.1rem; }
.popts { display: grid; gap: .65rem; }
.popt {
  font: inherit;
  font-family: var(--serif);
  text-align: left;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-2);
  color: var(--ink);
  font-size: .98rem;
  line-height: 1.7;
  cursor: pointer;
  transition: .2s ease;
}
.popt:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(120,100,80,.10); }
.popt.dim { opacity: .25; }
.popt.picked { border-color: var(--accent); background: #fff; opacity: 1; }

/* 控件：永远贴在视口底部 */
.pctrl {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(660px, 100%);
  bottom: 0;
  display: flex;
  gap: .4rem;
  justify-content: center;
  padding: .8rem 1.4rem 1rem;
  background: var(--paper);
  box-shadow: 0 -1px 0 var(--line);
}
.pctl {
  font-family: var(--sans);
  font-size: .76rem;
  letter-spacing: .06em;
  padding: .38rem .8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: .16s ease;
}
.pctl:hover { border-color: var(--muted); color: var(--ink); }
.pctl.on { border-color: var(--ink); color: var(--ink); background: var(--paper-2); }

/* 死亡的那一屏 */
.veil {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1d1b18;
  color: var(--paper);
  opacity: 0;
  transition: opacity .85s ease;
}
.veil.on { opacity: 1; }
.veil .veil-in { text-align: center; }
.veil p { font-family: var(--sans); font-size: .82rem; letter-spacing: .3em; color: #8d867a; margin: .6rem 0; }
.veil strong { font-size: 4.2rem; font-weight: 600; letter-spacing: .02em; }

/* 落地页的节奏选择 */
.pacepick {
  font-family: var(--sans);
  font-size: .76rem;
  color: var(--muted);
  margin-top: 1rem;
  letter-spacing: .08em;
}
.pacepick a {
  margin-left: .5rem;
  padding: .1rem .5rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
}
.pacepick a.on { color: var(--ink); background: var(--paper-2); border: 1px solid var(--line); }

/* hidden 属性会被上面的 display:flex 覆盖 —— 必须显式压回来，
   否则遮罩从一开局就盖在全屏上，整个页面点不动 */
.veil[hidden],
.pchoice[hidden] { display: none !important; }

/* ═══════════ 播放页：整屏布局，事件区自己滚 ═══════════ */
/* 顶栏 + 主区要用 flex 分配高度。
   早先给 main 写死 100dvh，忽略了上面 62px 的顶栏，整块超出视口，
   底部正好被固定控件盖住 —— 最后一个选项就是这么被切掉的 */
body.playing {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.playing .foot { display: none; }
/* body 变成 flex 列之后，topbar 的 margin:0 auto 会让它缩成内容宽，
   两个链接贴在一起。显式给宽度 */
body.playing .topbar {
  flex: 0 0 auto;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  padding: .9rem 1.4rem;
}
body.playing main {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  /* 底部要留出固定控件的高度，否则最后一个选项会被挡住 */
  padding: .5rem 1.4rem 4.4rem;
  max-width: 700px;
  overflow: hidden;
}
body.playing .player {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-bottom: 0;
}
body.playing .phead { flex: 0 0 auto; padding-bottom: .6rem; }
body.playing .pbreed { font-size: 1.15rem; }

/* 时钟不再 sticky：它现在在列首，本来就不会滚走 */
body.playing .pclock {
  position: static;
  flex: 0 0 auto;
  box-shadow: 0 1px 0 var(--line);
  margin-bottom: .2rem;
}

/* 事件区：固定高度、内部滚动、自动吸底 */
body.playing .pfeed {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding: .4rem .2rem 0;
  scroll-behavior: smooth;
  /* 上方留白给渐隐，读起来不像被切断 */
  mask-image: linear-gradient(to bottom, transparent 0, #000 18px, #000 calc(100% - 10px), transparent 100%);
}

/* 选项现在在滚动区里，跟着内容走，不会被控件挡住 */
body.playing .pchoice {
  margin: 1.2rem 0 0;
  padding: .9rem 0 1.2rem;
  border-top: 1px dashed var(--line);
  background: var(--paper);
}

body.playing .phint { display: none; }

/* 控制条已经 fixed，这里只需给底部留出空间 */
body.playing .pctrl { z-index: 8; }

/* ---------- 数据栏 ---------- */
.pname {
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: .04em;
  line-height: 1.2;
}
.powner {
  font-family: var(--sans);
  font-size: .76rem;
  color: var(--ink-soft);
  margin-top: .45rem;
  letter-spacing: .04em;
}
.powner::before { content: "主人 · "; color: var(--muted); }
body.playing .pname { font-size: 1.5rem; }

.dogname {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: .04em;
  margin-bottom: .2rem;
}
.dossier {
  margin-top: 1.1rem;
  border-top: 1px solid var(--line);
  padding-top: .9rem;
  font-family: var(--sans);
  font-size: .82rem;
}
.drow { display: flex; gap: 1rem; align-items: baseline; }
.drow > span { color: var(--muted); letter-spacing: .14em; flex: 0 0 auto; }
.drow b { font-weight: 600; color: var(--ink); }
.drow em { font-style: normal; color: var(--muted); margin-left: .35rem; margin-right: .8rem; }
