:root {
  --bg: #ece6db;
  --paper: #f6f2ea;
  --ink: #1f1c18;
  --muted: #7d756a;
  --line: #d3cabb;
  --accent: #9a3a24;
  --serif: "Noto Serif TC", "Songti TC", serif;
  --sans: "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --paper: #1c1a17;
    --ink: #e8e2d6;
    --muted: #8f877b;
    --line: #34302a;
    --accent: #d06a4f;
  }
}
/* 死亡畫面：整頁沉入黑 */
body[data-mode="dead"] {
  --bg: #0b0a09;
  --paper: #121110;
  --ink: #d9d3c8;
  --muted: #6f685f;
  --line: #26231f;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.95 var(--serif);
  transition: background-color 2.4s ease, color 2.4s ease;
}
/* 紙張顆粒 */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── 頂部狀態列 ───────────────────── */
header {
  position: sticky; top: 0; z-index: 2;
  padding: 10px 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  transition: background-color 2.4s ease;
}
header:empty { display: none; }
header > * { max-width: 680px; margin-left: auto; margin-right: auto; }

.timeline {
  display: flex; gap: 4px;
  list-style: none; padding: 0; margin-bottom: 10px;
}
.timeline li {
  flex: 1; height: 3px;
  background: var(--line);
  transition: background-color .6s;
}
.timeline li.done { background: var(--muted); }
.timeline li.now { background: var(--ink); }

.bar-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px;
  font-size: 13px; color: var(--muted);
}
.meter { display: flex; align-items: center; gap: 8px; }
.meter i {
  position: relative; display: block;
  width: 72px; height: 4px;
  background: var(--line);
}
.meter i::after {
  content: ""; position: absolute; inset: 0 auto 0 0;
  width: var(--v);
  background: var(--ink);
  transition: width .8s ease;
}
.meter b { font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 2ch; }
.meter.low i::after { background: var(--accent); }
.meter.low b { color: var(--accent); }
.chip {
  padding: 1px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
}

.family {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  list-style: none; padding: 0; margin-top: 8px; margin-bottom: 0;
  font-size: 13px;
}
.family li { position: relative; padding-left: 12px; }
.family li::before {
  content: ""; position: absolute; left: 0; top: .62em;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink);
}
.family li.me { font-weight: 600; }
.family li.hurt::before { background: var(--accent); }
.family li.gone { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--muted); }
.family li.gone::before { background: transparent; border: 1px solid var(--muted); }

/* ── 場景 ─────────────────────────── */
main { max-width: 680px; margin: 0 auto; padding: 48px 16px 120px; position: relative; }
.scene { min-height: 60vh; }

.reveal {
  opacity: 0;
  transform: translateY(6px);
  animation: rise .9s ease forwards;
  animation-delay: calc(var(--i, 0) * .45s);
}
@keyframes rise { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; transform: none; }
  body { transition: none; }
}

.date {
  margin: 0 0 6px;
  font: 500 13px/1.6 var(--sans);
  letter-spacing: .18em;
  color: var(--muted);
}
h1, h2 { font-weight: 700; letter-spacing: .02em; }
h1 { font-size: clamp(26px, 6vw, 36px); line-height: 1.35; margin: 0 0 28px; }
h2 { font-size: clamp(24px, 5vw, 30px); line-height: 1.4; margin: 0 0 24px; }
h1 .big { font-variant-numeric: tabular-nums; border-bottom: 2px solid var(--ink); }
.scene p { margin: 0 0 1.1em; }

.news {
  margin: 1.4em 0;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  background: var(--paper);
  font-weight: 600;
}
.assume {
  display: block;
  margin-top: 10px;
  font: 12px/1.6 var(--sans);
  color: var(--muted);
}
.death {
  margin-top: 22vh !important;
  font-size: 22px;
  text-align: center;
  letter-spacing: .1em;
  animation-duration: 3s !important;
}

/* ── 身分證 ───────────────────────── */
.idcard {
  position: relative;
  margin: 8px 0 28px;
  padding: 22px 22px 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--line), 0 18px 40px -28px rgba(0, 0, 0, .45);
}
.idcard::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--ink);
}
.idcard .who { font-size: 24px; font-weight: 700; margin: 0 0 14px; }
.idcard dl {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 20px; margin: 0 0 18px;
}
.idcard dl .wide { grid-column: 1 / -1; }
.idcard dt { font: 11px/1.4 var(--sans); letter-spacing: .16em; color: var(--muted); }
.idcard dd { margin: 0; font-size: 16px; }
.fam-title {
  margin: 0 0 6px !important;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  font: 13px/1.6 var(--sans); color: var(--muted);
}
.fam-list, .memorial { list-style: none; padding: 0; margin: 0; }
.fam-list li, .memorial li {
  display: flex; align-items: baseline; gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}
.fam-list li:last-child, .memorial li:last-child { border-bottom: 0; }
.fam-list span, .memorial span { width: 4.5em; flex: none; font: 13px var(--sans); color: var(--muted); }
.fam-list em, .memorial em { margin-left: auto; font: 13px var(--sans); font-style: normal; color: var(--muted); }

/* ── 結局 ─────────────────────────── */
.memorial { margin: 0 0 32px; }
.memorial li { font-size: 18px; }
.tally {
  margin: 32px 0;
  padding: 20px 22px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}
.tally b { font-size: 1.15em; font-variant-numeric: tabular-nums; }
.tally p:last-child { margin-bottom: 0; }

/* ── 數據註記 ─────────────────────── */
.data {
  margin: 32px 0 8px;
  font: 14px/1.7 var(--sans);
  color: var(--muted);
}
.data summary {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer; list-style: none;
  padding: 4px 0;
  border-bottom: 1px dotted var(--muted);
}
.data summary::-webkit-details-marker { display: none; }
.data summary::before { content: "＋"; font-size: 12px; }
.data[open] summary::before { content: "－"; }
.data ul {
  list-style: none; margin: 12px 0 0; padding: 4px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.data li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.data li:last-child { border-bottom: 0; }
.data .k { display: block; font-size: 12px; letter-spacing: .08em; }
.data .v { display: block; font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums; }
.data small { display: block; font-size: 12px; }
.data .meta { opacity: .8; }
.data a { color: inherit; text-underline-offset: 2px; }

/* ── 選項 ─────────────────────────── */
.choices { display: flex; flex-direction: column; gap: 10px; margin-top: 36px; }
button {
  position: relative;
  font: 17px/1.5 var(--serif);
  text-align: left;
  padding: 16px 44px 16px 20px;
  background: var(--ink); color: var(--bg);
  border: 1px solid var(--ink);
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease, background-color 2.4s, color 2.4s;
}
button::after {
  content: "→"; position: absolute; right: 18px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--sans); opacity: .6;
  transition: right .2s ease;
}
button:hover::after { right: 14px; opacity: 1; }
button:active { transform: scale(.99); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button.ghost { background: transparent; color: var(--ink); }
.choices button + button:not(.ghost) { background: transparent; color: var(--ink); }
