:root {
  --ink: #201c17;
  --ink-soft: #665e52;
  --paper: #eee6d4;
  --paper-deep: #dfd1b6;
  --paper-light: #f8f2e5;
  --red: #9f2d25;
  --red-dark: #742019;
  --gold: #b38a42;
  --line: rgba(55, 45, 33, .17);
  --shadow: 0 22px 55px rgba(17, 12, 7, .24);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #17130f; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(179, 138, 66, .12), transparent 28%),
    radial-gradient(circle at 85% 80%, rgba(159, 45, 37, .1), transparent 30%),
    #17130f;
}

button { font: inherit; }

.glossary-term {
  color: var(--red-dark);
  border-bottom: 1px dashed currentColor;
  cursor: help;
}

.glossary-dialog {
  width: min(calc(100% - 28px), 560px);
  margin: auto auto max(14px, env(safe-area-inset-bottom));
  padding: 12px 22px 22px;
  color: var(--ink);
  background: var(--paper-light);
  border: 0;
  box-shadow: 0 18px 60px rgba(12, 9, 5, .42);
}

.glossary-dialog::backdrop { background: rgba(17, 13, 9, .58); }

.glossary-handle {
  width: 42px;
  height: 3px;
  margin: 0 auto 18px;
  background: var(--line);
}

.glossary-label {
  color: var(--red);
  font-size: 12px;
  letter-spacing: .15em;
}

.glossary-dialog h2 {
  margin: 8px 0 10px;
  font-size: 30px;
  font-weight: 500;
}

.glossary-dialog p {
  margin: 0 0 20px;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.8;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  background:
    linear-gradient(rgba(255,255,255,.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(70,50,25,.025) 1px, transparent 1px),
    var(--paper);
  background-size: 22px 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.app-shell.vn-shell {
  width: min(100%, 1180px);
  background: #100d0a;
}

.vn-screen {
  position: relative;
  min-height: 100svh;
  padding: 0;
  overflow: hidden;
  isolation: isolate;
  color: #fff8e9;
  background: #17120d;
}

.vn-background,
.vn-atmosphere,
.vn-stage {
  position: absolute;
  inset: 0;
}

.vn-background {
  z-index: -4;
  background:
    radial-gradient(circle at 50% 38%, #5b4631, #17110c 72%);
  background-position: center;
  background-size: cover;
  transform: scale(1.015);
}

.vn-atmosphere {
  z-index: -3;
  background:
    linear-gradient(180deg, rgba(10, 8, 6, .7), transparent 24%, transparent 58%, rgba(8, 6, 4, .82) 100%),
    linear-gradient(90deg, rgba(8, 6, 4, .34), transparent 35%, transparent 65%, rgba(8, 6, 4, .34));
  pointer-events: none;
}

.vn-header {
  position: absolute;
  z-index: 6;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: max(22px, env(safe-area-inset-top)) 30px 30px;
  background: linear-gradient(180deg, rgba(10, 8, 6, .75), transparent);
  text-shadow: 0 2px 12px #000;
}

.vn-header h1 {
  margin: 6px 0 0;
  font-size: clamp(24px, 3.4vw, 42px);
  font-weight: 500;
  line-height: 1.1;
}

.vn-era {
  color: #e6bd73;
  font-size: 11px;
  letter-spacing: .18em;
}

.vn-chapter {
  display: grid;
  align-content: start;
  justify-items: end;
  gap: 6px;
  color: rgba(255, 248, 233, .72);
  font-size: 11px;
  letter-spacing: .08em;
  white-space: nowrap;
}

.vn-chapter strong { color: #fff8e9; font-weight: 400; }

.vn-stage {
  z-index: -1;
  pointer-events: none;
}

.vn-character {
  position: absolute;
  bottom: 128px;
  width: auto;
  height: min(78svh, 900px);
  max-width: 54%;
  object-fit: contain;
  object-position: bottom;
  filter: drop-shadow(0 18px 22px rgba(0, 0, 0, .62));
  transform-origin: bottom center;
  transition: opacity .32s ease, filter .32s ease, transform .32s ease;
}

.vn-character-left { left: -1.5%; }
.vn-character-right { right: -1.5%; }
.vn-character-left.is-solo { left: 4%; }
.vn-character-right.is-solo { right: 4%; }
.vn-character.is-speaking { opacity: 1; transform: scale(1.025); }
.vn-character.is-listening { opacity: .6; filter: brightness(.6) saturate(.72) drop-shadow(0 18px 22px rgba(0, 0, 0, .65)); }

.vn-dialogue {
  position: absolute;
  z-index: 8;
  left: 30px;
  right: 30px;
  bottom: max(24px, env(safe-area-inset-bottom));
  min-height: 148px;
  padding: 24px 28px 17px;
  color: #292119;
  background:
    linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),
    rgba(247, 239, 220, .94);
  background-size: 100% 26px;
  border: 1px solid rgba(224, 195, 139, .72);
  box-shadow: 0 18px 55px rgba(0, 0, 0, .48), inset 0 0 28px rgba(120, 79, 27, .08);
  backdrop-filter: blur(12px);
}

.vn-dialogue::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(126, 82, 37, .13);
  pointer-events: none;
}

.vn-speaker {
  position: relative;
  z-index: 1;
  display: inline-block;
  margin: -42px 0 12px -10px;
  padding: 8px 18px;
  color: #fff7e7;
  background: #7e2b22;
  border: 1px solid rgba(230, 189, 115, .7);
  box-shadow: 0 7px 18px rgba(31, 15, 8, .25);
  font-size: 14px;
  letter-spacing: .1em;
}

.vn-dialogue p {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(15px, 1.7vw, 18px);
  line-height: 1.85;
}

.vn-dialogue-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 29px;
  margin-top: 10px;
}

.vn-story-progress { display: flex; gap: 4px; flex: 1; }
.vn-story-progress span { width: 18px; height: 2px; background: rgba(55, 45, 33, .18); }
.vn-story-progress span.read { background: var(--red); }
.vn-story-count, .vn-waiting { color: #7a6c5d; font: 11px Georgia, serif; }
.vn-waiting { letter-spacing: .15em; }

.vn-next {
  padding: 5px 0 5px 18px;
  color: var(--red-dark);
  background: transparent;
  border: 0;
  cursor: pointer;
  letter-spacing: .12em;
}

.vn-next b { margin-left: 7px; font: 24px/0 Georgia, serif; vertical-align: -2px; }

.vn-choice-panel {
  position: absolute;
  z-index: 12;
  top: 47%;
  left: 50%;
  width: min(calc(100% - 54px), 650px);
  padding: 24px;
  color: #2b2118;
  background: rgba(244, 235, 215, .96);
  border: 1px solid rgba(225, 186, 111, .78);
  box-shadow: 0 24px 75px rgba(0, 0, 0, .66);
  transform: translate(-50%, -50%);
  animation: choice-in .32s ease-out both;
  backdrop-filter: blur(16px);
}

@keyframes choice-in {
  from { opacity: 0; transform: translate(-50%, -45%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.vn-choice-kicker {
  color: var(--red);
  font-size: 11px;
  letter-spacing: .18em;
  text-align: center;
}

.vn-choice-panel h2 {
  margin: 8px 0 18px;
  font-size: clamp(23px, 4vw, 34px);
  font-weight: 500;
  text-align: center;
}

.vn-choices { display: grid; gap: 9px; }

.vn-choice-button {
  position: relative;
  width: 100%;
  padding: 13px 45px 13px 16px;
  color: #2b2118;
  background: rgba(255, 252, 243, .7);
  border: 1px solid rgba(73, 57, 39, .2);
  cursor: pointer;
  text-align: left;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.vn-choice-button::after {
  content: "→";
  position: absolute;
  top: 50%;
  right: 17px;
  color: var(--red);
  transform: translateY(-50%);
}

.vn-choice-button:hover { background: #fffaf0; border-color: var(--red); transform: translateX(3px); }
.vn-choice-button span { font-size: 16px; line-height: 1.5; }
.vn-choice-button small { display: block; margin-top: 3px; color: #74685a; font-size: 11px; line-height: 1.5; }

.vn-screen.is-choosing::after {
  content: "";
  position: absolute;
  z-index: 10;
  inset: 0;
  background: rgba(8, 6, 4, .32);
  pointer-events: none;
}

.vn-screen.is-choosing .vn-dialogue { opacity: .82; }

.vn-status {
  position: absolute;
  z-index: 7;
  top: 108px;
  left: 30px;
  right: 30px;
  pointer-events: none;
}

.vn-status .meters {
  width: min(410px, 48%);
  margin: 0 0 0 auto;
  padding: 8px 12px;
  color: #fff;
  background: rgba(8, 6, 4, .38);
  border: 1px solid rgba(255, 242, 215, .1);
  backdrop-filter: blur(8px);
}

.vn-status .meter-label, .vn-status .meter-value { color: rgba(255, 248, 233, .72); }
.vn-status .meter-track { background: rgba(255, 255, 255, .17); }

.screen {
  width: 100%;
  min-height: 100vh;
  padding: max(22px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
  animation: page-in .42s ease-out both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.start-screen {
  display: grid;
  align-content: space-between;
  position: relative;
  background:
    linear-gradient(180deg, rgba(18,15,12,.08), transparent 42%),
    var(--paper);
}

.start-screen::before {
  content: "IF";
  position: absolute;
  right: -26px;
  top: 13%;
  font: 500 190px/1 Georgia, serif;
  color: rgba(116, 32, 25, .055);
  transform: rotate(-8deg);
  pointer-events: none;
}

.brand { letter-spacing: .16em; color: var(--red-dark); font-size: 14px; }

.seal {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 2px solid var(--red);
  color: var(--red);
  font-weight: 500;
  line-height: 1.05;
  transform: rotate(-4deg);
  margin: 18px 0 42px;
}

.hero { position: relative; z-index: 1; padding-top: 7vh; }

.hero h1 {
  margin: 0;
  font-size: clamp(54px, 15vw, 92px);
  line-height: .94;
  letter-spacing: -.08em;
  font-weight: 500;
}

.hero h1 span { color: var(--red); font-family: Georgia, serif; }

.hero-copy {
  margin: 30px 0 0;
  max-width: 430px;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1.9;
  overflow-wrap: anywhere;
}

.start-actions { position: relative; z-index: 1; }

.start-note {
  display: flex;
  gap: 14px;
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.6;
}

.start-note::before { content: "卷一"; color: var(--red); white-space: nowrap; }

.primary-button, .secondary-button, .choice-button {
  width: 100%;
  border: 0;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, color .16s ease;
}

.primary-button {
  padding: 17px 20px;
  background: var(--red);
  color: #fff7e9;
  font-size: 17px;
  letter-spacing: .14em;
  box-shadow: 0 10px 22px rgba(116,32,25,.2);
}

.primary-button:hover { background: var(--red-dark); }
.primary-button:active, .choice-button:active { transform: scale(.985); }

.secondary-button {
  padding: 13px 18px;
  margin-top: 10px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.era-label { color: var(--red); font-size: 13px; letter-spacing: .12em; }
.node-count { color: var(--ink-soft); font-size: 12px; }

.chapter-track {
  height: 2px;
  background: rgba(55,45,33,.13);
  margin: 0 0 24px;
}

.chapter-track span {
  display: block;
  height: 100%;
  background: var(--red);
  transition: width .45s ease;
}

.year {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--red-dark);
  font-size: 13px;
  letter-spacing: .08em;
}

.year::after { content: ""; height: 1px; background: var(--line); flex: 1; }

.event-title {
  margin: 13px 0 16px;
  font-size: clamp(30px, 8vw, 46px);
  line-height: 1.18;
  font-weight: 500;
}

.event-art {
  position: relative;
  margin: 18px -22px 4px;
  overflow: hidden;
  background: #251f19;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.event-art img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

.event-art figcaption {
  position: absolute;
  right: 10px;
  bottom: 9px;
  padding: 5px 8px;
  color: rgba(255,255,255,.8);
  background: rgba(20,16,12,.62);
  font-size: 10px;
  letter-spacing: .08em;
}

.event-scene {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.95;
}

.story-page {
  min-height: 194px;
  padding: 20px 0 8px;
  animation: page-in .32s ease-out both;
}

.story-speaker {
  margin-bottom: 11px;
  color: var(--red-dark);
  font-size: 12px;
  letter-spacing: .1em;
}

.story-progress {
  display: flex;
  gap: 6px;
  margin-top: 19px;
}

.story-progress span {
  width: 24px;
  height: 2px;
  background: rgba(55,45,33,.14);
}

.story-progress span.read { background: var(--red); }
.story-count { margin-top: 7px; color: var(--ink-soft); font-size: 11px; }
.story-next { margin: 10px 0 2px; }

.whisper {
  margin: 22px 0;
  padding: 15px 17px;
  border-left: 3px solid var(--gold);
  background: rgba(255,255,255,.28);
  color: #4d4439;
  line-height: 1.75;
  font-size: 14px;
}

.choice-heading {
  margin: 28px 0 12px;
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: .12em;
}

.choices { display: grid; gap: 10px; }

.choice-button {
  position: relative;
  padding: 16px 44px 16px 17px;
  text-align: left;
  color: var(--ink);
  background: rgba(248,242,229,.66);
  border: 1px solid var(--line);
  line-height: 1.55;
}

.choice-button::after {
  content: "→";
  position: absolute;
  right: 17px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--red);
}

.choice-button:hover {
  border-color: rgba(159,45,37,.45);
  background: rgba(255,255,255,.58);
}

.choice-button small {
  display: block;
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 12px;
}

.meters {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin-top: 24px;
}

.meter { text-align: center; }
.meter-label { display: block; color: var(--ink-soft); font-size: 11px; }
.meter-track { height: 3px; margin: 6px 0; background: rgba(55,45,33,.12); }
.meter-fill { height: 100%; background: var(--gold); transition: width .5s ease; }
.meter-value { font: 12px Georgia, serif; color: var(--ink-soft); }

.result-mark {
  display: inline-block;
  padding: 5px 9px;
  margin-bottom: 13px;
  color: var(--red);
  border: 1px solid rgba(159,45,37,.34);
  font-size: 12px;
  letter-spacing: .1em;
}

.result-title { margin: 0 0 16px; font-size: clamp(29px, 8vw, 44px); font-weight: 500; }
.result-copy { font-size: 17px; line-height: 1.95; color: #3d362e; }

.echo-box {
  margin: 24px 0;
  padding: 18px;
  background: #28221b;
  color: #eee3cf;
}

.echo-label { color: #d2ad68; font-size: 12px; letter-spacing: .15em; }
.echo-box p { margin: 9px 0 0; line-height: 1.75; font-size: 14px; }

.delta-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 17px 0 27px; }
.delta { padding: 6px 9px; background: rgba(255,255,255,.35); font-size: 12px; }
.delta.up { color: #4d6a3e; }
.delta.down { color: var(--red-dark); }

.timeline-screen { background: var(--paper-light); }
.timeline-title { margin: 10px 0 8px; font-size: 34px; font-weight: 500; }
.timeline-intro { margin: 0 0 26px; color: var(--ink-soft); line-height: 1.7; }

.timeline { position: relative; margin-left: 8px; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.timeline-item { position: relative; margin-bottom: 21px; }
.timeline-item::before { content: ""; position: absolute; left: -26px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--paper-light); border: 2px solid var(--red); }
.timeline-item time { color: var(--red); font-size: 12px; }
.timeline-item h3 { margin: 4px 0 5px; font-size: 17px; font-weight: 500; }
.timeline-item p { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.6; }

.ending-screen {
  background:
    linear-gradient(180deg, rgba(159,45,37,.055), transparent 30%),
    var(--paper);
}

.ending-kicker { color: var(--red); font-size: 13px; letter-spacing: .16em; }
.ending-title { margin: 12px 0 8px; font-size: clamp(38px, 11vw, 66px); line-height: 1.12; font-weight: 500; }
.ending-subtitle { margin: 0 0 27px; color: var(--ink-soft); font-size: 16px; }

.chronicle {
  padding: 22px;
  background: rgba(248,242,229,.76);
  border-top: 4px double var(--line);
  border-bottom: 4px double var(--line);
  line-height: 2;
  font-size: 15px;
}

.ending-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 22px 0;
}

.ending-stat { text-align: center; padding: 11px 3px; background: rgba(255,255,255,.26); }
.ending-stat strong { display: block; font: 22px Georgia, serif; color: var(--red-dark); }
.ending-stat span { font-size: 11px; color: var(--ink-soft); }

.ending-quote { margin: 24px 6px; color: var(--ink-soft); font-style: italic; text-align: center; line-height: 1.8; }

.footer-actions { display: grid; gap: 8px; }

@media (max-width: 430px) {
  .screen { padding-left: 18px; padding-right: 18px; }
  .hero-copy { font-size: 16px; }
  .meters { gap: 3px; }
  .meter-label { font-size: 10px; }
  .ending-stat strong { font-size: 18px; }
  .ending-stat span { font-size: 10px; }

  .vn-screen { min-height: 100svh; padding: 0; }
  .vn-header { padding: max(16px, env(safe-area-inset-top)) 16px 24px; }
  .vn-header h1 { font-size: 24px; max-width: 260px; }
  .vn-era { font-size: 9px; }
  .vn-chapter { font-size: 9px; }
  .vn-status { display: none; }
  .vn-character { bottom: 205px; height: min(61svh, 570px); max-width: 68%; }
  .vn-character-left { left: -20%; }
  .vn-character-right { right: -20%; }
  .vn-character-left.is-solo { left: 3%; }
  .vn-character-right.is-solo { right: 3%; }
  .vn-dialogue { left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); min-height: 185px; padding: 22px 17px 12px; }
  .vn-speaker { margin-left: -5px; font-size: 12px; }
  .vn-dialogue p { font-size: 15px; line-height: 1.72; }
  .vn-choice-panel { top: 43%; width: calc(100% - 24px); padding: 17px 14px; }
  .vn-choice-panel h2 { margin-bottom: 12px; }
  .vn-choice-button { padding-top: 10px; padding-bottom: 10px; }
  .vn-choice-button span { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
