:root {
  --bg: #070808;
  --ink: #f6eedf;
  --muted: #b9ad9b;
  --soft: rgba(246, 238, 223, 0.74);
  --line: rgba(191, 143, 72, 0.2);
  --gold: #bd8b3c;
  --gold-soft: #d6b06d;
  --amber-muted: #a87935;
  --cyan: #8fbdb5;
  --paper: #d8c094;
  --paper-deep: #b89359;
  --audio-intensity: 0;
  --scroll-progress: 0;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% calc(20% + (var(--scroll-progress) * 50%)), rgba(170, 121, 52, calc(0.05 + var(--audio-intensity) * 0.08)), transparent 24rem),
    linear-gradient(180deg, #0b0b0c 0%, var(--bg) 48%, #0a0d0d 100%);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.72;
  overflow-x: hidden;
  transition: background 900ms ease, color 900ms ease;
}

body.book-mode {
  color: #2b1d0f;
  background:
    radial-gradient(circle at 50% calc(20% + (var(--scroll-progress) * 50%)), rgba(158, 107, 42, calc(0.08 + var(--audio-intensity) * 0.08)), transparent 23rem),
    linear-gradient(180deg, #24170c 0%, #8d6a3f 18%, #d2b985 50%, #9e743f 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(143, 189, 181, 0.045), transparent 24%, transparent 76%, rgba(177, 135, 77, 0.055)),
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.035), transparent 34rem);
  opacity: 0.9;
  transition: opacity 900ms ease, background 900ms ease;
}

body.book-mode::before {
  background:
    linear-gradient(90deg, rgba(62, 31, 8, 0.24), transparent 18%, transparent 82%, rgba(62, 31, 8, 0.24)),
    repeating-linear-gradient(0deg, rgba(82, 47, 16, 0.055) 0 1px, transparent 1px 5px),
    radial-gradient(circle at 50% 24%, rgba(255, 236, 177, 0.18), transparent 32rem);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

#essence-canvas,
.ambient-grain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#essence-canvas {
  z-index: 1;
  opacity: 0.82;
}

.ambient-grain {
  z-index: 2;
  opacity: 0.12;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, transparent, #000 15%, #000 86%, transparent);
}

body.book-mode .ambient-grain {
  opacity: 0.24;
  background-image:
    repeating-linear-gradient(12deg, rgba(87, 49, 17, 0.08) 0 1px, transparent 1px 9px),
    radial-gradient(circle at 30% 20%, rgba(75, 42, 15, 0.12), transparent 18rem);
}

.audio-player {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 20;
  display: grid;
  width: min(940px, calc(100% - 28px));
  gap: 10px;
  padding: 12px 14px;
  transform: translateX(-50%);
  border: 1px solid rgba(189, 139, 60, 0.24);
  border-radius: 8px;
  background: rgba(11, 10, 10, 0.82);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.3), 0 0 24px rgba(171, 121, 50, calc(0.04 + var(--audio-intensity) * 0.12));
  backdrop-filter: blur(18px);
}

body.book-mode .audio-player {
  border-color: rgba(62, 36, 13, 0.34);
  background: rgba(46, 28, 13, 0.78);
}

.player-main,
.player-secondary {
  display: grid;
  align-items: center;
  gap: 14px;
}

.player-main {
  grid-template-columns: auto minmax(0, 1fr) minmax(190px, 260px);
}

.player-secondary {
  grid-template-columns: minmax(120px, 1fr) 150px;
}

.player-button {
  position: relative;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(232, 193, 118, 0.35);
  border-radius: 50%;
  color: #161008;
  background: linear-gradient(135deg, #e2c686, var(--gold-soft) 58%, var(--amber-muted));
  box-shadow: 0 0 calc(12px + var(--audio-intensity) * 12px) rgba(172, 122, 52, 0.46);
}

.play-icon {
  display: block;
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 14px solid currentColor;
}

.player-button.is-playing .play-icon {
  width: 14px;
  height: 17px;
  margin-left: 0;
  border: 0;
  background:
    linear-gradient(90deg, currentColor 0 5px, transparent 5px 9px, currentColor 9px 14px);
}

.track-info {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.track-info strong {
  overflow: hidden;
  color: #fff3dc;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.86rem;
  letter-spacing: 0.07em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.track-info span,
.track-picker,
.volume-control {
  color: var(--muted);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.74rem;
}

.track-picker,
.volume-control {
  display: grid;
  gap: 4px;
}

.track-picker select {
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(214, 176, 109, 0.24);
  border-radius: 8px;
  color: #f5ead5;
  background: rgba(255, 255, 255, 0.08);
  padding: 0 10px;
}

.track-meter {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.track-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--gold-soft), var(--amber-muted));
  box-shadow: 0 0 10px rgba(172, 122, 52, 0.46);
}

.volume-control input {
  width: 100%;
  accent-color: var(--gold-soft);
}

.site-shell {
  position: relative;
  z-index: 4;
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 150px 0 130px;
}

body.book-mode .site-shell {
  width: min(900px, calc(100% - 28px));
}

.opening {
  display: grid;
  min-height: 72vh;
  place-items: center;
  text-align: center;
}

.opening > * {
  max-width: 760px;
}

.kicker {
  margin: 0 0 14px;
  color: var(--gold-soft);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

body.book-mode .kicker {
  color: #805419;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 22px;
  font-size: clamp(3rem, 10vw, 8rem);
  font-weight: 500;
  line-height: 0.96;
  text-shadow: 0 0 calc(14px + var(--audio-intensity) * 9px) rgba(175, 124, 49, 0.24);
}

.opening p:last-child {
  color: var(--soft);
  font-size: clamp(1rem, 2vw, 1.22rem);
}

body.book-mode .opening {
  min-height: 26vh;
}

body.book-mode .opening p:last-child {
  color: rgba(43, 29, 15, 0.72);
}

.reader {
  display: grid;
  justify-items: center;
  gap: 28px;
  padding-bottom: 20vh;
}

.text-passage,
.text-callout,
.chapter-title,
.chapter-index,
.choice-gate,
.book-unlock,
.quote-divider,
.checkout-panel,
.site-footer {
  width: min(100%, 760px);
  text-align: center;
}

body.book-mode .text-passage,
body.book-mode .text-callout,
body.book-mode .chapter-title,
body.book-mode .chapter-index,
body.book-mode .choice-gate,
body.book-mode .quote-divider,
body.book-mode .checkout-panel {
  width: min(100%, 720px);
}

.text-passage {
  padding: 8px 0;
  animation: riseIn 700ms ease both;
}

.text-passage p {
  margin-bottom: 0;
  color: rgba(246, 238, 223, 0.84);
  font-size: clamp(1.08rem, 2.15vw, 1.32rem);
}

.text-passage.chapter-answer p {
  color: var(--gold-soft);
  font-weight: 700;
}

body.book-mode .text-passage p {
  color: rgba(43, 29, 15, 0.88);
}

body.book-mode .text-passage.chapter-answer p {
  color: var(--gold-soft);
}

.text-callout {
  padding: 18px 22px;
  border-left: 2px solid rgba(214, 176, 109, 0.58);
  border-right: 2px solid rgba(214, 176, 109, 0.22);
  background: linear-gradient(90deg, rgba(214, 176, 109, 0.08), rgba(214, 176, 109, 0.025));
  animation: riseIn 700ms ease both;
}

.text-callout p {
  margin: 0;
  color: rgba(247, 232, 196, 0.94);
  font-size: clamp(1.12rem, 2.25vw, 1.42rem);
  font-weight: 700;
  line-height: 1.55;
}

.quote-divider {
  padding: 56px 0 48px;
  color: rgba(214, 176, 109, 0.62);
  font-size: clamp(2.4rem, 9vw, 6rem);
  line-height: 1;
  text-shadow: 0 0 18px rgba(172, 122, 52, 0.2);
}

.chapter-index {
  margin: 50px auto 22px;
  text-align: left;
  animation: riseIn 700ms ease both;
}

.chapter-index h2 {
  margin: 0 auto 28px;
  max-width: 680px;
  text-align: center;
  font-size: clamp(1.65rem, 4.2vw, 3rem);
  font-weight: 500;
  line-height: 1.12;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.chapter-card {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 100%;
  padding: 20px;
  border: 1px solid rgba(214, 176, 109, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.chapter-card h3 {
  margin: 0;
  color: var(--gold-soft);
  font-size: clamp(1.05rem, 2.1vw, 1.32rem);
  line-height: 1.25;
}

.chapter-card ul {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 18px;
}

.chapter-card li {
  color: rgba(246, 238, 223, 0.82);
  font-size: clamp(0.95rem, 1.8vw, 1.04rem);
  line-height: 1.42;
}

body.book-mode.light-mode .chapter-index h2 {
  color: #2b1d0f;
}

body.book-mode.light-mode .chapter-card {
  border-color: rgba(76, 45, 14, 0.2);
  background: rgba(62, 36, 13, 0.055);
}

body.book-mode.light-mode .chapter-card h3 {
  color: #805419;
}

body.book-mode.light-mode .chapter-card li {
  color: rgba(43, 29, 15, 0.82);
}

.site-footer {
  margin: 76px auto 0;
  padding: 34px 20px 14px;
  border-top: 1px solid rgba(214, 176, 109, 0.25);
  color: rgba(246, 238, 223, 0.78);
  animation: riseIn 700ms ease both;
}

.site-footer p {
  margin: 0 0 12px;
  font-size: clamp(1rem, 1.8vw, 1.16rem);
}

.site-footer p:first-child {
  color: var(--gold-soft);
  font-weight: 700;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--gold-soft);
}

.chapter-title {
  padding: 72px 0 18px;
  animation: glowIn 800ms ease both;
}

.chapter-title h2 {
  margin: 0;
  font-size: clamp(2.05rem, 5.7vw, 4.8rem);
  font-weight: 500;
  line-height: 1.03;
  text-shadow: 0 0 18px rgba(175, 124, 49, 0.18);
}

body.book-mode .chapter-title h2 {
  color: #2b1d0f;
  text-shadow: 0 1px 0 rgba(255, 238, 191, 0.45);
}

.choice-gate,
.book-unlock {
  display: grid;
  justify-items: center;
  gap: 18px;
  margin: 32px 0 78px;
  padding: 34px 18px 38px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, transparent, rgba(172, 122, 52, 0.055), transparent);
  animation: glowIn 800ms ease both;
}

body.book-mode .choice-gate,
body.book-mode .book-unlock {
  border-color: rgba(76, 45, 14, 0.22);
  background: linear-gradient(90deg, transparent, rgba(72, 42, 13, 0.08), transparent);
}

.choice-gate p,
.book-unlock > p {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--ink);
  font-size: clamp(1.22rem, 2.8vw, 1.9rem);
  line-height: 1.38;
}

body.book-mode .choice-gate p,
body.book-mode .book-unlock > p {
  color: #2b1d0f;
}

.choice-button,
.checkout-button,
.fixed-checkout a {
  position: relative;
  overflow: hidden;
  min-height: 50px;
  border: 1px solid rgba(255, 224, 146, 0.54);
  border-radius: 8px;
  color: #191006;
  background:
    linear-gradient(135deg, #fff1bc 0%, #f4d877 32%, #d6a743 66%, #9f6b1f 100%);
  box-shadow:
    0 0 16px rgba(255, 214, 112, calc(0.22 + var(--audio-intensity) * 0.16)),
    0 8px 26px rgba(101, 62, 10, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.48);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-decoration: none;
  text-shadow: 0 1px 0 rgba(255, 244, 199, 0.44);
  text-transform: uppercase;
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}

.choice-button {
  min-width: min(100%, 290px);
  padding: 0 24px;
}

.checkout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: min(100%, 360px);
  padding: 0 22px;
}

.choice-button:hover,
.choice-button:focus-visible,
.checkout-button:hover,
.checkout-button:focus-visible,
.fixed-checkout a:hover,
.fixed-checkout a:focus-visible {
  filter: brightness(1.14) saturate(1.14);
  transform: translateY(-2px);
}

.choice-button:focus-visible,
.checkout-button:focus-visible,
.fixed-checkout a:focus-visible,
.player-button:focus-visible,
.track-picker select:focus-visible,
.volume-control input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.choice-gate.is-open .choice-button,
.book-unlock.is-open .choice-button {
  color: rgba(246, 238, 223, 0.88);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

body.book-mode .choice-gate.is-open .choice-button,
body.book-mode .book-unlock.is-open .choice-button {
  color: #3d260f;
  background: rgba(62, 36, 13, 0.08);
}

.choice-status {
  display: none;
  color: var(--cyan);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.choice-gate.is-open .choice-status,
.book-unlock.is-open .choice-status {
  display: inline;
}

.book-stage {
  position: relative;
  width: min(100%, 430px);
  height: 330px;
  perspective: 900px;
}

.book {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 176px;
  height: 248px;
  animation: bookFloat 3s ease-in-out infinite;
  transform-style: preserve-3d;
}

.book-cover,
.book-pages {
  position: absolute;
  inset: 0;
  border-radius: 8px;
}

.book-pages {
  background:
    repeating-linear-gradient(90deg, #e7d6aa 0 2px, #c9aa70 2px 4px),
    linear-gradient(135deg, #efdcb0, #b88c4a);
  opacity: 0;
  transform: translate(10px, 7px) scale(0.92);
  transition: opacity 500ms ease 800ms;
}

.book-cover {
  border: 2px solid rgba(74, 38, 12, 0.75);
  background:
    linear-gradient(90deg, rgba(255, 218, 138, 0.12), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.2)),
    radial-gradient(circle at 50% 35%, rgba(228, 179, 88, 0.16), transparent 44%),
    linear-gradient(135deg, #6f351a, #2a150d 58%, #7c411e);
  box-shadow: inset 0 0 28px rgba(236, 178, 82, 0.12), 0 18px 38px rgba(0, 0, 0, 0.34);
  transform-origin: left center;
  transition: transform 900ms ease 640ms;
}

.left-cover {
  transform-origin: right center;
  opacity: 0;
}

.right-cover {
  display: grid;
  place-items: center;
  padding: 30px 22px;
}

.book-title {
  max-width: 116px;
  color: #e5c77d;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.1;
  text-transform: uppercase;
  text-shadow: 0 1px 0 #1d0e08;
}

.lock {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 44px;
  height: 52px;
  transform: translate(-50%, -50%);
}

.lock-shackle {
  position: absolute;
  left: 8px;
  top: 0;
  width: 28px;
  height: 28px;
  border: 5px solid #d5ad5f;
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
}

.lock-body {
  position: absolute;
  left: 3px;
  bottom: 0;
  width: 38px;
  height: 30px;
  border-radius: 7px;
  background: linear-gradient(135deg, #f1d189, #a87935);
}

.floating-key {
  position: absolute;
  right: 18px;
  top: 132px;
  z-index: 3;
  width: 90px;
  height: 42px;
  animation: keyFloat 3s ease-in-out infinite;
  transition: transform 900ms ease;
}

.key-bow {
  position: absolute;
  left: 0;
  top: 5px;
  width: 32px;
  height: 32px;
  border: 7px solid #c79a4f;
  border-radius: 50%;
}

.key-stem {
  position: absolute;
  left: 28px;
  top: 18px;
  width: 48px;
  height: 7px;
  border-radius: 999px;
  background: #c79a4f;
}

.key-bit {
  position: absolute;
  right: 2px;
  top: 18px;
  width: 16px;
  height: 18px;
  border-right: 6px solid #c79a4f;
  border-bottom: 6px solid #c79a4f;
}

.book-unlock.is-unlocking .floating-key {
  animation: none;
  transform: translate(-128px, 8px) rotate(180deg);
}

.book-unlock.is-unlocking .lock-shackle {
  animation: unlockShackle 500ms ease 780ms forwards;
}

.book-unlock.is-unlocking .right-cover,
.book-unlock.has-opened .right-cover {
  transform: rotateY(-118deg);
}

.book-unlock.is-unlocking .book-pages,
.book-unlock.has-opened .book-pages {
  opacity: 1;
}

.book-unlock.has-opened .floating-key,
.book-unlock.has-opened .lock {
  opacity: 0;
}

.checkout-panel {
  padding: 40px 0 80px;
}

.fixed-checkout {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 18;
  transform: translateX(-50%);
}

.fixed-checkout[hidden] {
  display: none;
}

.fixed-checkout a {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-color: rgba(255, 235, 158, 0.84);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.68), transparent 32%),
    linear-gradient(135deg, #fff7c9 0%, #ffd84f 34%, #e0a82e 65%, #b67213 100%);
  box-shadow:
    0 0 16px rgba(255, 218, 82, 0.5),
    0 0 34px rgba(255, 182, 42, calc(0.36 + var(--audio-intensity) * 0.22)),
    0 12px 34px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
  animation: ctaPulse 1.9s ease-in-out infinite;
  white-space: nowrap;
}

.checkout-button::before,
.fixed-checkout a::before {
  content: "";
  position: absolute;
  top: -60%;
  bottom: -60%;
  left: -45%;
  width: 38%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.68), transparent);
  transform: rotate(18deg);
  animation: ctaShine 2.6s ease-in-out infinite;
}

.checkout-button {
  animation: ctaPulse 2.4s ease-in-out infinite;
}

.theme-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 19;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(232, 193, 118, 0.32);
  border-radius: 50%;
  color: #1c1308;
  background: linear-gradient(135deg, #e8d29b, var(--gold-soft));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.theme-toggle[hidden] {
  display: none;
}

.theme-toggle span {
  font-size: 1.25rem;
  line-height: 1;
}

body.book-mode {
  color: var(--ink);
  background:
    radial-gradient(circle at 50% calc(20% + (var(--scroll-progress) * 50%)), rgba(170, 121, 52, calc(0.05 + var(--audio-intensity) * 0.08)), transparent 24rem),
    linear-gradient(180deg, #0b0b0c 0%, var(--bg) 48%, #0a0d0d 100%);
}

body.book-mode::before {
  background:
    linear-gradient(90deg, rgba(143, 189, 181, 0.045), transparent 24%, transparent 76%, rgba(177, 135, 77, 0.055)),
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.035), transparent 34rem);
}

body.book-mode.light-mode {
  color: #2b1d0f;
  background:
    radial-gradient(circle at 50% calc(20% + (var(--scroll-progress) * 50%)), rgba(158, 107, 42, calc(0.08 + var(--audio-intensity) * 0.08)), transparent 23rem),
    linear-gradient(180deg, #24170c 0%, #8d6a3f 18%, #d2b985 50%, #9e743f 100%);
}

body.book-mode.light-mode::before {
  background:
    linear-gradient(90deg, rgba(62, 31, 8, 0.24), transparent 18%, transparent 82%, rgba(62, 31, 8, 0.24)),
    repeating-linear-gradient(0deg, rgba(82, 47, 16, 0.055) 0 1px, transparent 1px 5px),
    radial-gradient(circle at 50% 24%, rgba(255, 236, 177, 0.18), transparent 32rem);
}

body.book-mode .kicker,
body.book-mode .chapter-title h2,
body.book-mode .choice-gate p,
body.book-mode .book-unlock > p {
  color: var(--ink);
}

body.book-mode .text-passage p {
  color: rgba(246, 238, 223, 0.84);
}

body.book-mode.light-mode .kicker {
  color: #805419;
}

body.book-mode.light-mode .chapter-title h2,
body.book-mode.light-mode .choice-gate p,
body.book-mode.light-mode .book-unlock > p {
  color: #2b1d0f;
}

body.book-mode.light-mode .text-passage p {
  color: rgba(43, 29, 15, 0.88);
}

body.book-mode.light-mode .text-passage.chapter-answer p {
  color: #8a5a13;
}

body.book-mode.light-mode .text-callout {
  border-left-color: rgba(76, 45, 14, 0.4);
  background: linear-gradient(90deg, rgba(76, 45, 14, 0.09), rgba(76, 45, 14, 0.025));
}

body.book-mode.light-mode .text-callout p {
  color: rgba(43, 29, 15, 0.94);
}

body.book-mode.light-mode .site-footer {
  border-top-color: rgba(76, 45, 14, 0.22);
  color: rgba(43, 29, 15, 0.82);
}

body.book-mode.light-mode .site-footer p:first-child,
body.book-mode.light-mode .site-footer a:hover,
body.book-mode.light-mode .site-footer a:focus-visible {
  color: #8a5a13;
}

@keyframes keyFloat {
  0%, 100% {
    transform: translateY(-6px) rotate(-4deg);
  }
  50% {
    transform: translateY(8px) rotate(4deg);
  }
}

@keyframes bookFloat {
  0%, 100% {
    transform: translate(-50%, -50%) rotateX(7deg) rotateZ(-1.2deg);
  }
  50% {
    transform: translate(-50%, calc(-50% + 14px)) rotateX(7deg) rotateZ(1.2deg);
  }
}

@keyframes unlockShackle {
  to {
    transform: translate(8px, -8px) rotate(28deg);
  }
}

@keyframes ctaPulse {
  0%, 100% {
    box-shadow:
      0 0 14px rgba(255, 218, 82, 0.42),
      0 0 26px rgba(255, 182, 42, 0.3),
      0 10px 28px rgba(0, 0, 0, 0.22),
      inset 0 1px 0 rgba(255, 255, 255, 0.7);
  }
  50% {
    box-shadow:
      0 0 24px rgba(255, 230, 122, 0.78),
      0 0 48px rgba(255, 185, 36, 0.56),
      0 14px 34px rgba(0, 0, 0, 0.28),
      inset 0 1px 0 rgba(255, 255, 255, 0.86);
  }
}

@keyframes ctaShine {
  0%, 38% {
    left: -48%;
    opacity: 0;
  }
  52% {
    opacity: 1;
  }
  76%, 100% {
    left: 115%;
    opacity: 0;
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes glowIn {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 760px) {
  .audio-player {
    top: 8px;
    width: min(100% - 16px, 940px);
    grid-template-columns: 38px minmax(0, 1fr) 104px 68px;
    gap: 6px 8px;
    padding: 8px 10px;
  }

  .player-main,
  .player-secondary {
    display: contents;
  }

  .player-main {
    grid-template-columns: unset;
  }

  .player-secondary {
    grid-template-columns: unset;
  }

  .player-button {
    width: 38px;
    height: 38px;
  }

  .play-icon {
    border-top-width: 8px;
    border-bottom-width: 8px;
    border-left-width: 12px;
  }

  .player-button.is-playing .play-icon {
    width: 12px;
    height: 15px;
    background:
      linear-gradient(90deg, currentColor 0 4px, transparent 4px 8px, currentColor 8px 12px);
  }

  .track-info strong {
    font-size: 0.72rem;
  }

  .track-info span {
    display: none;
  }

  .track-info {
    align-self: center;
    grid-column: 2;
    grid-row: 1;
  }

  .track-picker,
  .volume-control {
    align-self: center;
    font-size: 0;
  }

  .track-picker select {
    min-height: 31px;
    padding: 0 8px;
    font-size: 0.68rem;
  }

  .track-picker {
    grid-column: 3;
    grid-row: 1;
  }

  .volume-control {
    grid-column: 4;
    grid-row: 1;
  }

  .volume-control input {
    width: 68px;
    height: 20px;
  }

  .track-meter {
    grid-column: 1 / -1;
    grid-row: 2;
    height: 3px;
  }

  .site-shell {
    width: min(100% - 24px, 980px);
    padding-top: 92px;
  }

  .opening {
    min-height: 58vh;
  }

  body.book-mode .opening {
    min-height: 20vh;
  }

  .reader {
    gap: 22px;
  }

  .chapter-grid {
    grid-template-columns: 1fr;
  }

  .chapter-card {
    padding: 17px;
  }

  .book-stage {
    height: 280px;
  }

  .book {
    width: 148px;
    height: 214px;
  }

  .floating-key {
    right: 0;
    width: 74px;
    transform: scale(0.85);
  }

  .book-unlock.is-unlocking .floating-key {
    transform: translate(-96px, 6px) rotate(180deg) scale(0.85);
  }

  .choice-gate,
  .book-unlock {
    margin-bottom: 58px;
    padding-inline: 12px;
  }

  .fixed-checkout {
    bottom: 10px;
    width: min(100% - 20px, 420px);
  }

  .fixed-checkout a {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    font-size: 0.68rem;
    white-space: normal;
  }

  .theme-toggle {
    right: 12px;
    bottom: 58px;
    width: 42px;
    height: 42px;
  }
}

@media (max-width: 420px) {
  .track-picker select {
    max-width: 100%;
  }

  .audio-player {
    grid-template-columns: 36px minmax(0, 1fr) 94px 58px;
  }

  .volume-control input {
    width: 58px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
