:root {
  --bg: #14110c;
  --bg-deep: #0d0b07;
  --card: #fbf6e9;
  --paper: #f4ecd9;
  --paper-deep: #ece0c4;
  --ink: #241c12;
  --ink-soft: #5c4d38;
  --son: #b23a2a;
  --gold: #b8860b;
  --gold-strong: #8f6708;
  --cham: #2e4a6b;
  --line: #d8c9a6;
  --line-strong: #b9a377;
  --display: "Noto Serif SC", "Source Han Serif", Palatino, serif;
  --seal: "Noto Sans SC", "Noto Serif SC", sans-serif;
  --text: "Be Vietnam Pro", "Palatino Linotype", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: #efe4c6; }
body {
  font-family: var(--text);
  overflow: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}

#lamp { position: fixed; inset: 0; z-index: 0; display: block; }

.veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 42%, transparent 18%, rgba(8, 6, 4, .28) 70%, rgba(8, 6, 4, .62) 100%),
    radial-gradient(circle at 72% 18%, rgba(217, 174, 82, .16), transparent 26%);
  mix-blend-mode: soft-light;
}
.motes { position: fixed; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.mote {
  position: absolute;
  bottom: -8vh;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 226, 170, .85), rgba(217, 174, 82, 0));
  filter: blur(.4px);
  animation: rise var(--d) linear infinite;
  animation-delay: var(--delay);
  opacity: .0;
}
@keyframes rise {
  0% { transform: translate3d(0, 0, 0); opacity: 0; }
  12% { opacity: .55; }
  100% { transform: translate3d(var(--x), -110vh, 0); opacity: 0; }
}
.bagua { animation: spin 90s linear infinite; transform-origin: 600px 40px; }
@keyframes spin { to { transform: translateX(-50%) rotate(360deg); } }
.seal { animation: pulse 4.8s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(224, 106, 80, 0)); }
  50% { filter: drop-shadow(0 0 10px rgba(224, 106, 80, .45)); }
}
body[data-reading="flipping"] .book-wrap,
body[data-reading="user_fold"] .book-wrap {
  filter: drop-shadow(0 34px 42px rgba(0,0,0,.55)) drop-shadow(0 0 22px rgba(217, 174, 82, .18));
}
.book-wrap { transition: filter .4s ease; }

.bagua {
  position: fixed;
  left: 50%;
  top: -80px;
  width: min(1100px, 140vw);
  margin-left: calc(min(1100px, 140vw) / -2);
  opacity: .22;
  pointer-events: none;
  z-index: 1;
}

.desk {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  justify-items: center;
  align-items: center;
  padding: 16px 12px 12px;
  pointer-events: none;
}

.mast, .stage, .hint, .colophon, .book-wrap, .nav { pointer-events: auto; }
.mast { text-align: center; color: #efe4c6; text-shadow: 0 8px 24px rgba(0,0,0,.45); }
.eyebrow {
  margin: 0;
  letter-spacing: .32em;
  text-transform: uppercase;
  font-size: 11px;
  color: #d9ae52;
}
.mast h1 {
  margin: 2px 0 0;
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: .28em;
  font-size: clamp(40px, 6vw, 68px);
}
.mast h1 span { color: #e06a50; }
.byline { margin: 2px 0 0; font-style: italic; color: #b7a47f; }
.hao-row { width: 72px; margin: 8px auto 0; display: grid; gap: 5px; }
.hao-row i, .haos i {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--gold);
}
.hao-row i.broken, .haos i.am {
  background: linear-gradient(90deg, var(--gold) 42%, transparent 42% 58%, var(--gold) 58%);
}

.stage {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
}
.book-wrap {
  width: min(920px, 100%);
  margin: 0 auto;
  filter: drop-shadow(0 28px 36px rgba(0,0,0,.5));
}

.page {
  color: var(--ink);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(90, 60, 20, .08), transparent 26px),
    radial-gradient(circle at 80% 12%, rgba(184, 134, 11, .08), transparent 28%),
    var(--paper);
}
.page.rightish {
  background:
    linear-gradient(270deg, rgba(90, 60, 20, .08), transparent 26px),
    var(--paper-deep);
}
.sheet {
  height: 100%;
  padding: 42px 40px 36px;
  display: flex;
  flex-direction: column;
  position: relative;
}
.sheet::before, .sheet::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--gold);
  border-style: solid;
  opacity: .7;
}
.sheet::before { top: 16px; left: 16px; border-width: 1px 0 0 1px; }
.sheet::after { right: 16px; bottom: 16px; border-width: 0 1px 1px 0; }
.kicker {
  margin: 0;
  text-align: center;
  letter-spacing: .28em;
  font-size: 11px;
  color: var(--gold-strong);
}
.sheet h2 {
  margin: 8px 0 8px;
  text-align: center;
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: .42em;
  font-size: 30px;
  color: var(--son);
}
.haos { width: 84px; margin: 0 auto 18px; display: grid; gap: 5px; }
.stanza p {
  margin: 0;
  text-align: center;
  font-size: 19px;
  line-height: 1.85;
}
.sign {
  margin-top: auto;
  text-align: right;
  font-style: italic;
  color: var(--ink-soft);
  line-height: 1.7;
}
.folio {
  margin-top: auto;
  text-align: center;
  letter-spacing: .2em;
  font-size: 12px;
  color: var(--gold-strong);
}

.cover, .back {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  color: #efe4c6;
  background:
    radial-gradient(circle at 50% 18%, rgba(217, 174, 82, .2), transparent 26%),
    linear-gradient(165deg, #3a2a18, #1a140e 62%);
  box-shadow:
    inset 0 0 0 12px rgba(184, 134, 11, .45),
    inset 0 0 0 16px #1a140e,
    inset 0 0 0 17px rgba(178, 58, 42, .7);
}
.seal {
  width: 86px;
  height: 86px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border: 3px solid var(--son);
  color: #e06a50;
  border-radius: 8px;
  font-family: var(--seal);
  font-weight: 700;
  font-size: 34px;
  letter-spacing: .08em;
  transform: rotate(-8deg);
  background: rgba(178, 58, 42, .08);
  box-shadow: inset 0 0 0 4px rgba(178, 58, 42, .35);
}
.cover strong, .back strong {
  display: block;
  font-family: var(--display);
  font-size: 64px;
  font-weight: 600;
  letter-spacing: .34em;
}
.cover span, .back span {
  display: block;
  margin-top: 12px;
  font-style: italic;
  letter-spacing: .12em;
  color: #d9ae52;
}
.que-mark { margin-top: 22px; font-size: 28px; letter-spacing: .4em; color: #d9ae52; }

.nav {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #57492e;
  background: rgba(20, 17, 12, .45);
  color: #d9ae52;
  font-size: 28px;
  cursor: pointer;
}
.nav:disabled { opacity: .28; cursor: default; }
.tools { display: flex; gap: 8px; pointer-events: auto; }
.tool {
  border: 1px solid #57492e;
  background: rgba(20, 17, 12, .4);
  color: #d9ae52;
  border-radius: 999px;
  padding: 6px 14px;
  font-family: var(--text);
  letter-spacing: .08em;
  cursor: pointer;
}
.tool.on { background: #b23a2a; color: #f4ecd9; border-color: #b23a2a; }
body.vertical .stanza p { writing-mode: vertical-rl; text-orientation: mixed; display: inline-block; margin: 0 8px; font-size: 18px; line-height: 1.7; }
body.vertical .stanza { display: flex; justify-content: center; flex-wrap: wrap; height: 68%; }
.oracle {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(8, 6, 4, .55);
  pointer-events: auto;
}
.oracle[hidden] { display: none; }
.slip {
  width: min(420px, 92vw);
  padding: 28px 24px;
  text-align: center;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-strong);
  box-shadow: 0 24px 50px rgba(0,0,0,.4);
}
.slip strong { display: block; margin: 10px 0; font-family: var(--display); font-size: 28px; letter-spacing: .2em; color: var(--son); }
.slip p { line-height: 1.7; }
.slip button { margin-top: 8px; }
.hint, .colophon {
  margin: 0;
  color: #b7a47f;
  font-size: 13px;
  letter-spacing: .04em;
}
.colophon { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; opacity: .7; }
.stf__parent { margin: 0 auto; }
.stf__block { background: transparent !important; }

@media (max-width: 760px) {
  body { overflow: auto; }
  .sheet { padding: 32px 20px 28px; }
  .stanza p { font-size: 16px; }
  .cover strong { font-size: 42px; }
  .bagua { display: none; }
}
