:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: #fff9e9;
  background: #10162a;
  --cream: #fff9e9;
  --muted: #b8bed0;
  --gold: #ead8a5;
  --outline: rgba(231, 232, 255, .16);
  --caption-accent: #e5dcbb;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: radial-gradient(ellipse at center, #202843 0%, #0b1021 85%); }
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button:disabled { opacity: .3; cursor: default; }
button:focus-visible, a:focus-visible { outline: 3px solid #f4df9e; outline-offset: 5px; }
[hidden] { display: none !important; }
svg { display: block; }

#viewport { position: fixed; inset: 0; overflow: hidden; touch-action: pan-y pinch-zoom; }
#stage {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1920px;
  height: 1080px;
  transform: translate(-50%, -50%);
  transform-origin: center;
  overflow: hidden;
  isolation: isolate;
  background: #202a50;
}
#world { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
#world > svg { width: 100%; height: 100%; display: block; }
#stage::before, #stage::after { content: ""; position: absolute; inset-inline: 0; pointer-events: none; }
#stage::before {
  top: 0;
  height: 380px;
  z-index: 1;
  background: linear-gradient(180deg, rgba(9, 14, 35, .87), rgba(9, 14, 35, .58) 55%, rgba(9, 14, 35, 0));
}
#stage::after {
  bottom: 0;
  height: 155px;
  z-index: 1;
  background: linear-gradient(0deg, rgba(9, 14, 35, .43), transparent);
}

#caption {
  position: absolute;
  z-index: 3;
  left: 120px;
  top: 52px;
  width: 1680px;
  min-height: 250px;
  text-align: center;
  color: var(--cream);
  pointer-events: none;
}
#speaker {
  display: inline-flex;
  align-items: center;
  gap: 15px;
  min-height: 30px;
  color: var(--caption-accent);
  font-size: 23px;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: 5px;
  text-transform: uppercase;
  text-shadow: 0 2px 12px rgba(2, 5, 18, .8);
}
#speaker::before, #speaker::after { content: ""; width: 38px; height: 1px; background: currentColor; opacity: .6; }
#speaker:empty { display: none; }
#line {
  margin: 18px auto 0;
  max-width: 1640px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 66px;
  font-weight: 500;
  line-height: 1.16;
  letter-spacing: -.5px;
  text-wrap: balance;
  text-shadow: 0 3px 3px rgba(3, 8, 25, .55), 0 4px 22px rgba(3, 8, 25, .7);
}
#caption[data-length="long"] #line { max-width: 1600px; font-size: 54px; line-height: 1.17; }
.speaker-rabbit { --caption-accent: #bbf0e4; }
.speaker-fox { --caption-accent: #ffc799; }
.speaker-bear { --caption-accent: #f7d37c; }
.speaker-both { --caption-accent: #eed2f5; }

#cover-title, #ending-title {
  position: absolute;
  z-index: 3;
  top: 98px;
  left: 140px;
  width: 1640px;
  text-align: center;
  color: var(--cream);
}
#cover-title { display: none; }
.is-cover #cover-title { display: block; }
.is-cover #caption, .is-end #caption { display: none; }
.is-cover::before { height: 510px; background: linear-gradient(180deg, rgba(11, 17, 38, .84), rgba(11, 17, 38, .47) 60%, transparent); }
.eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin: 0;
  color: #e6d8af;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 7px;
}
.eyebrow span { width: 74px; height: 1px; background: linear-gradient(90deg, transparent, #e6d8af); opacity: .7; }
.eyebrow span:last-child { transform: rotate(180deg); }
#cover-title h1 {
  margin: 21px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 112px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -3px;
  text-shadow: 0 3px 24px rgba(10, 17, 35, .5);
}
.cover-subtitle { margin: 21px 0 0; color: #eee4c9; font-size: 27px; font-weight: 400; letter-spacing: 12px; }
#start {
  position: absolute;
  top: 825px;
  left: 50%;
  display: inline-flex;
  align-items: center;
  gap: 24px;
  margin-top: 0;
  transform: translateX(-50%);
  padding: 16px 26px 16px 32px;
  border: 1px solid rgba(249, 229, 181, .55);
  border-radius: 100px;
  background: rgba(22, 32, 49, .66);
  color: #fff2cb;
  box-shadow: 0 5px 26px rgba(4, 9, 26, .18), inset 0 0 14px rgba(255, 227, 162, .025);
  font-size: 25px;
  letter-spacing: 3px;
  transition: background .2s, border-color .2s, transform .2s;
}
#start:hover { transform: translate(-50%, -2px); background: rgba(67, 65, 64, .82); border-color: #f3dfab; }
#start svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#ending-title { top: 50px; text-shadow: 0 4px 24px rgba(7, 14, 28, .45); }
.ending-stars { color: #ebd5a0; font-size: 32px; letter-spacing: 8px; }
#ending-title h2 { margin: 12px 0 15px; font: 400 110px/1.1 Georgia, "Times New Roman", serif; letter-spacing: 1px; }
#ending-title p { margin: 0; color: #ebdfbf; font-size: 23px; letter-spacing: 7px; }

#controls {
  position: fixed;
  bottom: max(41px, calc(env(safe-area-inset-bottom) + 24px));
  left: 50%;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid var(--outline);
  border-radius: 15px;
  background: rgba(15, 22, 40, .88);
  box-shadow: 0 7px 30px rgba(3, 7, 20, .25), inset 0 1px rgba(255, 255, 255, .03);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transform: translateX(-50%);
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
}
#controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #d8dbe6;
  font-size: 13px;
  line-height: 1;
  transition: background .15s, color .15s;
}
#controls button:hover:not(:disabled) { color: #fff4d6; background: rgba(246, 230, 183, .09); }
#controls button:active:not(:disabled) { background: rgba(246, 230, 183, .15); }
#controls button svg, #retry svg, .close-button svg {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.page-controls { display: flex; align-items: center; gap: 3px; }
#page-label {
  min-width: 71px;
  padding: 0 6px;
  color: #f0e7cf;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  letter-spacing: 1px;
}
.control-divider { width: 1px; height: 21px; margin: 0 5px; background: var(--outline); }
#help {
  position: fixed;
  z-index: 20;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  margin: 0;
  transform: translateX(-50%);
  color: rgba(207, 212, 229, .56);
  font-size: 10px;
  letter-spacing: .6px;
  white-space: nowrap;
  text-shadow: 0 1px 6px #0b1020;
  pointer-events: none;
  transition: opacity .25s;
}
#help span { margin: 0 8px; opacity: .65; }
.controls-hidden { cursor: none; }
.controls-hidden #controls { opacity: 0; pointer-events: none; transform: translate(-50%, 12px); }
.controls-hidden #help { opacity: 0; }
.controls-hidden #controls:focus-within { opacity: 1; pointer-events: auto; transform: translateX(-50%); }

#toc-dialog {
  width: min(920px, calc(100vw - 40px));
  max-height: min(790px, calc(100dvh - 72px));
  padding: 34px;
  overflow: auto;
  border: 1px solid rgba(233, 229, 210, .17);
  border-radius: 22px;
  background: #182138;
  color: var(--cream);
  box-shadow: 0 24px 100px rgba(0, 0, 0, .55);
  scrollbar-color: #586076 transparent;
  scrollbar-width: thin;
}
#toc-dialog::backdrop { background: rgba(5, 9, 22, .76); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.dialog-eyebrow { margin: 0 0 11px; color: #bea97c; font-size: 10px; letter-spacing: 3px; }
.dialog-heading h2 { margin: 0; font-size: 27px; font-weight: 500; letter-spacing: 3px; }
.dialog-description { margin: 10px 0 0; color: #aeb6ca; font-size: 13px; }
.close-button { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border: 1px solid var(--outline); border-radius: 50%; color: #d9deeb; background: rgba(255, 255, 255, .025); }
.close-button:hover { background: rgba(255, 255, 255, .09); color: white; }
#toc-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
#toc-list h3 { grid-column: 1 / -1; margin: 18px 0 4px; color: #ccb98e; font-size: 13px; font-weight: 500; letter-spacing: 2px; }
#toc-list button {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 74px;
  padding: 14px 16px;
  border: 1px solid rgba(225, 231, 248, .09);
  border-radius: 10px;
  background: rgba(255, 255, 255, .025);
  color: #dce2ef;
  text-align: left;
  font-size: 13px;
  line-height: 1.45;
  transition: background .15s, border-color .15s;
}
#toc-list button:hover { background: rgba(255, 255, 255, .065); border-color: rgba(235, 216, 169, .4); }
#toc-list button[aria-current="true"], #toc-list button[aria-current="page"], #toc-list button.is-current { border-color: rgba(238, 211, 151, .6); background: rgba(238, 211, 151, .085); color: #fff1ce; }
#toc-list .toc-number, #toc-list .page-number { flex: 0 0 24px; color: #b6a681; font-size: 11px; font-variant-numeric: tabular-nums; padding-top: 2px; }
#toc-list .toc-text { display: block; min-width: 0; }
#toc-list .toc-speaker { display: block; margin-bottom: 4px; color: #a6b2cb; font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
#toc-list .toc-line { font-family: Georgia, "Times New Roman", serif; font-size: 15px; }
.dialog-footnote { margin: 24px 0 0; color: #8f9ab0; font-size: 11px; line-height: 1.7; text-align: center; }

#loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 44%, #26324f 0%, #10182d 55%, #0c1223 100%);
}
.loading-card { width: min(350px, 100%); text-align: center; }
.loading-moon {
  position: relative;
  width: 68px;
  height: 68px;
  margin: 0 auto 34px;
  overflow: hidden;
  border-radius: 50%;
  background: #eee6c2;
  box-shadow: 0 0 45px 6px rgba(236, 222, 164, .16), inset -9px -6px 16px rgba(179, 170, 126, .25);
  animation: moon-breathe 3s ease-in-out infinite;
}
.loading-moon::before, .loading-moon::after, .loading-moon span { content: ""; position: absolute; border-radius: 50%; background: rgba(170, 172, 133, .13); }
.loading-moon::before { width: 19px; height: 20px; left: 13px; top: 15px; }
.loading-moon::after { width: 12px; height: 12px; right: 14px; bottom: 15px; }
.loading-moon span { width: 8px; height: 8px; left: 15px; bottom: 13px; }
.loading-eyebrow { margin: 0 0 12px; color: #cdbf97; font-size: 10px; letter-spacing: 3px; }
.loading-card h2 { margin: 0; font-size: 25px; font-weight: 400; letter-spacing: 5px; }
#load-status { min-height: 20px; margin: 19px 0 23px; color: #aeb7ca; font-size: 12px; line-height: 1.6; }
#load-progress { display: block; width: 100%; height: 3px; overflow: hidden; border: 0; border-radius: 3px; background: rgba(230, 224, 201, .12); accent-color: #decd9e; }
#load-progress::-webkit-progress-bar { background: rgba(230, 224, 201, .12); border-radius: 3px; }
#load-progress::-webkit-progress-value { border-radius: 3px; background: #decd9e; transition: width .25s; }
#load-progress::-moz-progress-bar { background: #decd9e; border-radius: 3px; }
#load-error { margin-top: 24px; color: #d6bdad; font-size: 12px; line-height: 1.7; }
#retry { display: inline-flex; align-items: center; gap: 9px; margin-top: 8px; padding: 10px 18px; border: 1px solid rgba(238, 211, 151, .35); border-radius: 8px; background: rgba(238, 211, 151, .06); color: #f0dfba; font-size: 13px; }
#retry:hover { background: rgba(238, 211, 151, .13); }
#boot-error { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; background: #10182d; text-align: center; }
#boot-error h1 { font-size: 23px; font-weight: 500; }
#boot-error p { color: #b8c1d4; font-size: 14px; line-height: 1.8; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; padding: 0; margin: -1px; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@keyframes moon-breathe { 0%, 100% { opacity: .8; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }

@media (max-width: 700px) {
  #controls { bottom: max(23px, calc(env(safe-area-inset-bottom) + 12px)); gap: 2px; padding: 5px 6px; border-radius: 12px; }
  #controls button { width: 36px; height: 36px; padding: 0; }
  #controls button span { display: none; }
  #page-label { min-width: 64px; font-size: 12px; }
  .control-divider { margin: 0 4px; }
  #help { display: none; }
  #toc-dialog { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); padding: 24px 18px; border-radius: 16px; }
  #toc-list { grid-template-columns: 1fr; gap: 7px; }
  #toc-list button { min-height: 66px; }
  .dialog-heading { margin-bottom: 22px; }
  .dialog-heading h2 { font-size: 23px; }
  .dialog-footnote { text-align: left; }
}
@media (max-height: 480px) and (orientation: landscape) {
  #controls { bottom: max(8px, env(safe-area-inset-bottom)); padding: 4px 7px; }
  #controls button { height: 32px; }
  #help { display: none; }
  #toc-dialog { max-height: calc(100dvh - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Each original book page is a complete new illustration and dialogue block. */
#caption { top: 36px; left: 100px; width: 1720px; min-height: 0; }
#caption-lines { display: flex; flex-direction: column; gap: 10px; }
.caption-row { color: #fff9e9; }
.caption-role {
  display: block; color: var(--caption-accent); font-size: 23px;
  font-weight: 650; letter-spacing: 4px; text-transform: uppercase;
}
.caption-text {
  margin: 14px 0 0; font: 500 64px/1.14 Georgia, "Times New Roman", serif;
  text-wrap: balance; letter-spacing: -.3px;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .58);
}
#caption[data-length="long"] .caption-text { font-size: 51px; }
#caption:not([data-count="1"]) .caption-row {
  display: grid; grid-template-columns: 210px 1fr; gap: 24px;
  align-items: baseline; text-align: left;
}
#caption:not([data-count="1"]) .caption-role {
  font-size: 22px; letter-spacing: 1.5px; text-align: right; padding-top: 9px;
}
#caption:not([data-count="1"]) .caption-text { margin: 0; font-size: 52px; line-height: 1.14; text-wrap: pretty; }
#caption[data-count="4"] .caption-text { font-size: 46px; }
#caption[data-count="4"] .caption-role { font-size: 21px; }
.is-paper { background: #f6f1e5 !important; }
.is-paper::before { height: 380px !important; background: linear-gradient(#f6f1e5 10%, rgba(246,241,229,.96) 60%, transparent) !important; }
.is-paper::after { background: none !important; }
.is-paper .caption-row { color: #3b394d; --caption-accent: #706957; }
.is-paper .caption-text { text-shadow: 0 1px 5px #fff8e9; }
.is-paper .caption-role { color: #77715e; }
.is-paper .speaker-rabbit { --caption-accent: #3a827a; }
.is-paper .speaker-fox { --caption-accent: #a35432; }
.is-paper .speaker-bear { --caption-accent: #84602c; }
.is-paper .speaker-both { --caption-accent: #796388; }
.is-paper .caption-role { color: var(--caption-accent); }
#stage::before { height: 370px; background: linear-gradient(180deg, rgba(12,20,43,.98), rgba(12,20,43,.86) 65%, rgba(12,20,43,0)); }
#stage.is-cover::before { height: 410px; }
#stage[data-page="page-09"]::before { height: 260px; background: linear-gradient(#0c142bdd, transparent); }
#cover-title { top: 62px; }
#cover-title h1 { font-size: 106px; }
#start { top: 858px; }
