@font-face {
  font-family: "WenKai";
  src: url("fonts/wenkai.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "ZhuXing";
  src: url("fonts/zhimang.woff2") format("woff2");
  font-display: swap;
}

:root {
  --cinnabar: #B22222;
  --ink: #1F1A17;
  --paper: #F3E9D2;
  --silk: #E8C66A;
  --wood: #241812;
}

* { box-sizing: border-box; }
html, body { overflow-x: hidden; overflow-y: auto; scrollbar-gutter: stable; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: "WenKai", "Songti SC", "STSong", "SimSun", serif;
  font-size: 17px;
  line-height: 1.65;
  background:
    radial-gradient(1000px 480px at 50% -10%, #5a3b2a 0%, transparent 55%),
    var(--wood);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .14;
  background: url("noise.svg");
  mix-blend-mode: multiply;
  z-index: 0;
}
button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

.stage { min-height: 100dvh; padding: 16px 0 24px; position: relative; z-index: 1; }
.sheet {
  width: min(1280px, calc(100% - 28px));
  margin: 0 auto;
  background:
    linear-gradient(180deg, rgba(255,255,255,.35), transparent 90px),
    var(--paper);
  border: 8px solid var(--silk);
  box-shadow: 0 0 0 2px #8c6a32, 0 22px 50px rgba(0,0,0,.38);
  min-height: calc(100dvh - 40px);
  position: relative;
}
.sub, .goal, .say, .tail { text-wrap: balance; }
.group { font-size: 15px; letter-spacing: .18em; color: #6a4b32; margin: 14px 0 6px; }
.warn { color: var(--cinnabar); font-size: 20px; margin: 8px 0; }
.paper, .paper-view {
  background:
    repeating-linear-gradient(90deg, transparent 0 1.7em, rgba(90,60,30,.16) 1.7em 1.72em),
    #f7f1e2;
  border: 1px solid rgba(90,60,30,.28);
  min-height: 220px;
}
.paper textarea, .writebox textarea {
  width: 100%;
  min-height: 220px;
  border: 0;
  background: transparent;
  resize: vertical;
  padding: 12px 14px;
}
.paper-view { padding: 18px 16px; text-align: left; white-space: pre-wrap; }
.name-night input {
  display: block;
  margin: 18px auto 12px;
  width: 2.2em;
  font-size: 42px;
  text-align: center;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #f4efe6;
  color: #f4efe6;
}
.route { display: flex; align-items: center; gap: 10px; width: 60%; margin-inline: auto; }
.route span { color: #8a735c; }
.route span.on { color: var(--cinnabar); }
.route i { flex: 1; height: 2px; background: #c4b29a; position: relative; }
.route i::after {
  content: "";
  position: absolute;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cinnabar);
  animation: ride 1.6s linear infinite;
}
.waitloop { animation: pulse 1.2s ease-in-out infinite; }
.stamp {
  width: 72px;
  height: 72px;
  margin: 12px auto;
  border: 4px solid var(--cinnabar);
  color: var(--cinnabar);
  font-family: "ZhuXing", "WenKai", cursive;
  font-size: 42px;
  line-height: 64px;
  animation: stamp 420ms ease-out;
}
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 8px 0; }
.compare h4 { font-size: 14px; letter-spacing: .2em; color: #6a4b32; }
.zhu-line, .heart { font-size: 30px; line-height: 1.45; }
.zhu-line { font-family: "ZhuXing", "WenKai", cursive; color: var(--cinnabar); }
.zhu-reading {
  color: #665442;
  font: 16px/1.55 "WenKai", "Songti SC", serif;
  letter-spacing: normal;
  margin: 8px 0 0;
  filter: none;
  overflow-wrap: anywhere;
}
.zhu .zhu-reading { max-width: 22em; text-align: center; margin-inline: auto; }
.glyph { position: relative; display: inline-block; }
.dot {
  position: absolute;
  width: .18em;
  height: .18em;
  border-radius: 50%;
  background: currentColor;
  right: 0;
  bottom: .08em;
}
@keyframes ride { from { left: 0; } to { left: calc(100% - 10px); } }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes stamp { from { transform: scale(1.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.silk {
  background: linear-gradient(180deg, #f3dc8d, var(--silk) 40%, #c49a3c);
  color: #3d2912;
  text-align: center;
  letter-spacing: .35em;
  padding: 8px 12px;
  font-size: 14px;
}
.bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding: 14px 16px 0;
}
.month { font-size: 20px; }
.report { color: #6a4b32; }
.months { display: flex; gap: 8px; padding: 8px 16px 0; flex-wrap: wrap; }
.months span { color: #8a735c; }
.months .now { color: var(--cinnabar); }
.hint { padding: 8px 16px 0; color: #5c4634; }
.cols {
  display: grid;
  grid-template-columns: 1.15fr 1.05fr .85fr;
  gap: 12px;
  padding: 12px;
}
.cols section {
  background: rgba(255,255,255,.28);
  border: 1px solid rgba(90,60,30,.16);
  padding: 12px;
  min-width: 0;
}
.tabs { display: none; }
.choice {
  display: block;
  width: 100%;
  text-align: left;
  background: #f7f1e2;
  border: 1px solid #d9c7a1;
  padding: 10px 12px;
  margin: 0 0 10px;
}
.doc, .ev {
  background: #f7f1e2;
  border: 1px solid #d9c7a1;
  padding: 10px 12px;
  margin: 0 0 10px;
}
.doc h3 { font-size: 16px; font-weight: 600; }
.choice[aria-pressed="true"] { border-color: var(--cinnabar); background: #f4ded2; opacity: 1; box-shadow: inset 3px 0 var(--cinnabar); }
.choice strong { display: block; font-size: 17px; font-weight: 700; }
.choice span { display: block; margin-top: 2px; font-size: 14px; color: #5c4634; }
.doc p, .choice span, .ev p { margin-top: 4px; }
.mark {
  display: inline-block;
  margin-left: 6px;
  color: var(--cinnabar);
  border: 1px solid var(--cinnabar);
  padding: 0 4px;
  font-size: 13px;
}
.tiny, .linkish {
  background: none;
  border: none;
  padding: 0;
  color: var(--cinnabar);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.shortcuts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.shortcuts button, .file-actions button, .tabs button, .seal, .ghost {
  min-height: 44px;
}
.shortcuts button {
  border: 1px solid #b08968;
  background: transparent;
  padding: 4px 8px;
  white-space: normal;
  text-align: left;
}
.writebox {
  background-image: repeating-linear-gradient(transparent, transparent 27px, rgba(90,50,20,.13) 28px);
}
textarea {
  width: 100%;
  min-height: 150px;
  border: none;
  resize: vertical;
  background: transparent;
  line-height: 28px;
  padding: 0;
}
textarea:focus { outline: none; }
.row { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 8px; }
.seal {
  background: var(--cinnabar);
  color: #f8efe0;
  border: none;
  padding: 8px 18px;
  letter-spacing: .2em;
  box-shadow: 0 4px 0 #6d1414;
}
.seal:disabled { opacity: .45; }
.ghost {
  background: transparent;
  border: 1px solid var(--ink);
  padding: 8px 14px;
}
.check { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 8px; }
.zhu-note { color: var(--cinnabar); font-family: "ZhuXing", "WenKai", cursive; font-size: 22px; }

.title-sheet, .center-sheet {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 20px 48px;
  gap: 14px;
}
.title-sheet h1 {
  font-family: "ZhuXing", "WenKai", cursive;
  font-weight: 400;
  font-size: clamp(96px, 18vw, 260px);
  line-height: .9;
  color: var(--cinnabar);
  letter-spacing: .08em;
  text-shadow: 0 2px 0 rgba(120,20,20,.12);
}
.sub { font-size: clamp(22px, 2.6vw, 34px); max-width: 14em; }
.slip {
  font-family: "ZhuXing", "WenKai", cursive;
  color: var(--cinnabar);
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1;
}
.title-actions, .end-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.night {
  min-height: 100dvh;
  background: #100c0a;
  color: #f4efe6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 22px;
  text-align: center;
  cursor: pointer;
  position: relative;
  z-index: 1;
}
.night .say { font-size: clamp(24px, 4.4vw, 40px); line-height: 1.55; max-width: min(16em, 100%); }
.night .note { margin-top: 18px; font-size: 14px; opacity: .72; max-width: 28em; }
.goal { color: var(--silk); }

.memorial {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-start;
  align-items: flex-start;
  gap: .35em;
  max-width: 100%;
  max-height: 62vh;
  overflow: auto;
  padding-bottom: 8px;
}
.memorial .col {
  writing-mode: vertical-rl;
  line-height: 1.75;
  letter-spacing: .12em;
  padding-top: 3.5em;
  max-height: 58vh;
}
.memorial .col.raise { padding-top: 0; }
.ending .memorial { justify-content: center; max-height: none; overflow: visible; }
.ending .memorial .col { padding-top: 0; }
.ending h2 { font-size: 48px; line-height: 1.2; }
.dust { letter-spacing: .4em; color: #7a5b3a; margin-top: 12px; }
.verdict, .ending, .review, .sources { padding: 18px 16px 32px; }
.zhu {
  font-family: "ZhuXing", "WenKai", cursive;
  color: var(--cinnabar);
  font-size: clamp(26px, 3.5vh, 40px);
  line-height: 1.15;
  flex: 0 0 auto;
  max-height: 70vh;
  margin: 12px auto;
  overflow: auto;
  filter: drop-shadow(0 0 0.6px rgba(178,34,34,.75));
}
.delivery, .verdict {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}
.delivery { gap: 18px; padding: 24px; }
.delivery > .silk, .verdict > .silk {
  align-self: stretch;
  margin-bottom: auto;
}
.delivery-paper {
  position: relative;
  display: grid;
  place-items: center;
  width: min(76%, 920px);
  min-height: 52dvh;
  padding: 20px 28px;
  border: 1px solid #c4a975;
  background: repeating-linear-gradient(90deg, transparent 0 2.1em, #93734d20 2.1em calc(2.1em + 1px)), #f8eed8;
  box-shadow: 0 12px 22px #51341824;
}
.delivery-paper .paper-view {
  width: min(100%, 36em);
  min-height: 0;
  background: transparent;
  border: none;
  font-size: 24px;
}
.delivery-paper .memorial { font-size: 18px; max-width: 100%; max-height: 47dvh; }
.delivery-paper .col { flex: 0 0 auto; max-height: none; }
.delivery .dust { font-size: 20px; margin: 0 auto auto; letter-spacing: .18em; }
.delivery .stamp, #accuse-body .stamp {
  position: absolute;
  inset: auto auto 10px 16px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2.4em;
  height: 2.4em;
  margin: 0;
  font-size: 28px;
  line-height: 1;
  transform: rotate(-8deg);
  animation: none;
}
.delivery[data-step="seal"] .stamp { animation: stamp 420ms ease-out; }
.delivery[data-step="transcribe"] .memorial { animation: rise 360ms ease-out; }
.delivery[data-step="box"] .delivery-paper { animation: box-set 420ms ease-out; }
@keyframes box-set { from { transform: translateY(-6px); } }

.verdict-layout {
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  align-items: center;
  gap: clamp(24px, 6vw, 90px);
  width: 100%;
  min-height: 68dvh;
  padding: 12px 18px;
}
.verdict-layout > .memorial { font-size: 20px; max-height: 65dvh; min-width: 0; }
.verdict .memorial .col { flex: 0 0 auto; max-height: none; }
.verdict .zhu { margin: 0; font-size: clamp(44px, 4vw, 56px); max-width: 53%; }
.verdict .zhu .col, .ending .zhu .col { padding-top: 0; line-height: 1.3; }
.verdict .zhu .memorial { max-height: 69dvh; }
.ending .zhu { max-height: none; overflow: visible; font-size: clamp(32px, 4vw, 54px); }
.verdict .seal { margin: 0 auto auto; }

.night.reversal {
  cursor: default;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 0%, #3b2a21, #1f1510 70%);
}
.accuse { display: grid; justify-items: center; gap: 18px; width: 100%; }
.accuse-intro { color: #f2e4ca; font-size: 17px; letter-spacing: .06em; text-wrap: balance; }
#accuse-body {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 18px;
  width: max-content;
  max-width: 100%;
  padding: 20px 22px 68px;
  border: 5px double #ae8949;
  background: repeating-linear-gradient(90deg, transparent 0 1.8em, #93734d22 1.8em calc(1.8em + 1px)), #f8edd5;
  color: var(--ink);
  box-shadow: 0 24px 60px #120b07b3;
  font-size: 22px;
}
#accuse-body .memorial { max-height: 63dvh; min-width: 0; }
#accuse-body .col:first-child { padding-top: 0; }
#accuse-body .col { flex: 0 0 auto; max-height: none; }
.accuse-line { animation: rise 370ms ease-out both; }
#reversal-ink {
  display: flex;
  flex-direction: row-reverse;
  flex: none;
  width: 1.95em;
  min-height: 5.5em;
  margin: 12px 0 0;
  font-size: 56px;
  line-height: .98;
}
#reversal-ink span { width: .98em; writing-mode: vertical-rl; white-space: nowrap; }

.settle-stage { display: grid; place-items: center; padding: 20px; }
.settle {
  width: min(100%, 560px);
  padding: 22px 32px 36px;
  background: linear-gradient(160deg, #fff3db, var(--paper));
  border: 5px double #aa8545;
  box-shadow: 0 22px 56px #180e0a88;
  gap: 12px;
}
.settle .silk { align-self: stretch; }
.settle h2 { font-size: 36px; line-height: 1.12; margin-top: 8px; }
.settle-count { font-size: 23px; line-height: 1.2; }
.settle-count strong { font-size: 54px; font-weight: 400; font-variant-numeric: tabular-nums; }
.settle-deaths { font-size: 18px; color: var(--ink); }
.settle-delta { font-size: 19px; }
.settle-delta strong { font-size: 37px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.settle-delta.more { color: var(--cinnabar); }
.settle-delta.less { color: #365638; }
.settle-reason { max-width: 26em; font-size: 18px; }
.settle .seal { margin-top: 8px; }
.ink {
  display: inline-block;
  clip-path: inset(0 0 100% 0);
  animation: brush var(--dur, 160ms) linear forwards;
  animation-delay: var(--delay, 0ms);
}
@keyframes brush { to { clip-path: inset(0 0 -2% 0); } }
.ending .you, .ending .tail { max-width: 28em; }
.chart { width: min(640px, 100%); height: auto; display: block; margin: 8px 0 16px; }
.reveal { font-size: 22px; margin-bottom: 8px; }
.round {
  border-top: 1px solid rgba(90,60,30,.2);
  padding: 12px 0;
}
.round h3 { font-size: 20px; }
.ledger { margin: 10px 0; border-left: 2px solid #b58a43; padding: 7px 12px; background: #d5b87925; }
.ledger strong { color: #594128; margin-right: .5em; }
.heart {
  font-family: "ZhuXing", "WenKai", cursive;
  color: var(--ink);
  font-size: 26px;
  line-height: 1.4;
}
.known, .prefect { color: #5c4634; }
.sources table { width: 100%; border-collapse: collapse; font-size: 15px; }
.sources td { border-top: 1px solid rgba(90,60,30,.18); vertical-align: top; padding: 8px 6px; }
.foot { margin-top: 14px; }

@media (max-width: 860px) {
  .stage { padding: 6px 0 12px; }
  .sheet { width: calc(100% - 12px); border-width: 5px; min-height: calc(100dvh - 12px); }
  .cols { display: block; }
  .cols section { display: none; }
  .cols section.on { display: block; }
  .tabs {
    display: flex;
    gap: 6px;
    padding: 10px 12px 0;
  }
  .tabs button {
    flex: 1;
    border: 1px solid #b08968;
    background: transparent;
  }
  .tabs button.on { background: var(--cinnabar); color: #f8efe0; border-color: var(--cinnabar); }
  .bar { flex-direction: column; gap: 0; }
  .compare { grid-template-columns: 1fr; }
  .delivery { gap: 16px; padding: 12px; }
  .delivery-paper { width: 100%; min-height: 52dvh; padding: 12px 8px; }
  .delivery-paper .paper-view { font-size: 20px; padding: 8px; }
  .delivery-paper .memorial { font-size: 15px; max-height: 48dvh; }
  .delivery .route { width: 100%; gap: 6px; font-size: 14px; }
  .delivery .stamp, #accuse-body .stamp { font-size: 21px; left: 8px; }
  .verdict { padding: 10px 9px 14px; }
  .verdict-layout { flex-direction: column; align-items: center; gap: 8px; min-height: 73dvh; padding: 6px 0; }
  .verdict-layout > .memorial { font-size: 15px; width: 100%; max-height: 45dvh; }
  .verdict .zhu { font-size: 28px; max-width: 100%; }
  .verdict .zhu .memorial { max-height: 37dvh; }
  .ending .zhu { font-size: 35px; }
  .night.reversal { padding: 10px; }
  .accuse { gap: 14px; }
  .accuse-intro { max-width: 19em; font-size: 15px; }
  #accuse-body { font-size: 15px; gap: 5px; padding: 10px 7px 52px; }
  #accuse-body .memorial { gap: .13em; max-height: 58dvh; }
  #accuse-body .memorial .col { line-height: 1.35; }
  #reversal-ink { font-size: 30px; }
  .settle-stage { padding: 10px; }
  .settle { padding: 14px 16px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .ink { animation: none; clip-path: none; }
  .delivery .memorial, .delivery .stamp, .delivery-paper, .accuse-line, .waitloop, .route i::after { animation: none; }
}
