/* ============================================================
   珂语 · 猫猫的生日星图书
   ============================================================ */

:root {
  --ink: #080711;
  --ink-2: #12101e;
  --ink-3: #1b1627;
  --paper: #f4ead9;
  --paper-2: #ecdec8;
  --paper-3: #e3d0b7;
  --paper-ink: #2d2230;
  --ink-soft: #6f5d67;
  --ink-faint: #9a858a;
  --plum: #6d3d54;
  --plum-deep: #3c2332;
  --rose: #bd7d8d;
  --rose-soft: #e5b9bd;
  --gold: #c9a15f;
  --gold-light: #f2ddb0;
  --gold-deep: #9a743c;
  --sage: #8a957e;
  --line: rgba(114, 78, 58, 0.18);
  --line-strong: rgba(114, 78, 58, 0.3);
  --line-light: rgba(216, 178, 110, 0.22);
  --cream: #fff8ea;
  --sans: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  --display: "STKaiti", "KaiTi", "Kaiti SC", "Songti SC", "SimSun", serif;
  --ease: cubic-bezier(0.22, 0.8, 0.22, 1);
  --ease-book: cubic-bezier(0.64, 0.02, 0.28, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

html {
  background: var(--ink);
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--paper-ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 52% 32%, #23192c 0%, #100d1a 46%, #07060d 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

::selection {
  background: rgba(201, 161, 95, 0.34);
  color: #fff;
}

.is-hidden {
  display: none !important;
}

/* ---------- ambient ---------- */

.ambient {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}

#skyCanvas,
#fxCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#fxCanvas {
  position: fixed;
  z-index: 170;
  pointer-events: none;
}

.aurora {
  position: absolute;
  width: 68vw;
  height: 68vw;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.2;
  will-change: transform;
}

.aurora-a {
  top: -34vw;
  left: -18vw;
  background: radial-gradient(circle, rgba(189, 125, 141, 0.6), rgba(189, 125, 141, 0) 68%);
  animation: auroraDrift 24s ease-in-out infinite alternate;
}

.aurora-b {
  right: -30vw;
  bottom: -38vw;
  background: radial-gradient(circle, rgba(126, 98, 150, 0.55), rgba(126, 98, 150, 0) 70%);
  animation: auroraDrift 30s ease-in-out infinite alternate-reverse;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.055;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, transparent 33%, rgba(5, 4, 10, 0.38) 74%, rgba(5, 4, 10, 0.82) 100%),
    linear-gradient(180deg, rgba(5, 4, 10, 0.12), transparent 24%, transparent 70%, rgba(5, 4, 10, 0.55));
}

/* ---------- topbar ---------- */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(18px + var(--safe-top)) clamp(18px, 3.4vw, 46px) 12px;
  pointer-events: none;
  transition: opacity 0.5s ease, filter 0.5s ease;
}

.brand,
.top-actions {
  pointer-events: auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: rgba(255, 244, 225, 0.82);
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  color: var(--gold);
  font-size: 13px;
  text-shadow: 0 0 18px rgba(201, 161, 95, 0.65);
  animation: markPulse 5s ease-in-out infinite;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand-copy b {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.22em;
}

.brand-copy small {
  color: rgba(255, 234, 211, 0.4);
  font-size: 7.5px;
  letter-spacing: 0.22em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn,
.qr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  border: 1px solid rgba(242, 221, 176, 0.18);
  border-radius: 999px;
  background: rgba(20, 16, 29, 0.42);
  color: rgba(255, 244, 225, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.icon-btn {
  width: 38px;
  padding: 0;
}

.qr-btn {
  padding: 0 15px;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.icon-btn:hover,
.qr-btn:hover {
  background: rgba(201, 161, 95, 0.12);
  border-color: rgba(242, 221, 176, 0.4);
  transform: translateY(-1px);
}

.sound-glyph {
  color: var(--gold-light);
  font-size: 16px;
  line-height: 1;
}

.sound-label {
  display: none;
}

.icon-btn[aria-pressed="true"] {
  border-color: rgba(201, 161, 95, 0.5);
  background: rgba(201, 161, 95, 0.14);
}

.icon-btn[aria-pressed="true"] .sound-glyph {
  animation: soundSway 1.3s ease-in-out infinite;
}

/* ---------- stage + book ---------- */

.stage {
  height: 100svh;
  padding: calc(78px + var(--safe-top)) 0 calc(16px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transition: filter 0.6s ease, opacity 0.6s ease, transform 0.6s ease;
}

.book-shell {
  width: min(1120px, 92vw);
  height: min(700px, calc(100svh - 166px));
  perspective: 2600px;
  perspective-origin: 40% 50%;
}

.book {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 7px 16px 16px 7px;
  background: var(--paper);
  box-shadow:
    0 42px 90px rgba(0, 0, 0, 0.62),
    0 12px 30px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(201, 161, 95, 0.15);
  transform-style: preserve-3d;
  touch-action: pan-y;
}

.book::before {
  content: "";
  position: absolute;
  z-index: 20;
  top: 0;
  bottom: 0;
  left: 0;
  width: 22px;
  border-radius: 7px 0 0 7px;
  background:
    linear-gradient(90deg, rgba(31, 18, 27, 0.45), rgba(31, 18, 27, 0.08) 42%, transparent 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 4px);
  pointer-events: none;
}

.book::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: 7px;
  right: -7px;
  bottom: 7px;
  width: 7px;
  border-radius: 0 12px 12px 0;
  background:
    repeating-linear-gradient(180deg, #ded0ba 0 1px, #f0e3cf 1px 3px);
  box-shadow: 3px 0 8px rgba(0, 0, 0, 0.25);
}

.page {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  padding: clamp(26px, 4vw, 52px) clamp(30px, 4.4vw, 64px) clamp(44px, 5vw, 58px);
  border-radius: 4px 12px 12px 4px;
  background:
    radial-gradient(circle at 78% 12%, rgba(193, 153, 113, 0.06), transparent 32%),
    linear-gradient(135deg, #f8f0e3 0%, #f1e3cf 48%, #ead9c1 100%);
  color: var(--paper-ink);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(10px);
  transform-origin: left center;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.page::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 14px;
  border: 1px solid rgba(109, 61, 84, 0.14);
  border-radius: 3px 8px 8px 3px;
  pointer-events: none;
}

.page::after {
  content: "";
  position: absolute;
  z-index: 0;
  top: 0;
  right: 0;
  bottom: 0;
  width: 26px;
  background: linear-gradient(90deg, transparent, rgba(74, 45, 58, 0.06));
  pointer-events: none;
}

.page.is-active {
  z-index: 2;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

.page.leave-next {
  z-index: 7;
  visibility: visible;
  pointer-events: none;
  animation: pageOutNext 0.72s var(--ease-book) forwards;
}

.page.leave-prev {
  z-index: 7;
  visibility: visible;
  pointer-events: none;
  transform-origin: right center;
  animation: pageOutPrev 0.72s var(--ease-book) forwards;
}

.page.enter-next {
  z-index: 6;
  visibility: visible;
  animation: pageInNext 0.72s var(--ease-book) both;
}

.page.enter-prev {
  z-index: 6;
  visibility: visible;
  animation: pageInPrev 0.72s var(--ease-book) both;
}

.page-scroll {
  position: relative;
  z-index: 1;
  height: 100%;
  overflow-y: auto;
  padding: 2px 6px 34px 0;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(109, 61, 84, 0.26) transparent;
}

.page-scroll::-webkit-scrollbar,
.letter-scroll::-webkit-scrollbar {
  width: 5px;
}

.page-scroll::-webkit-scrollbar-thumb,
.letter-scroll::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(109, 61, 84, 0.24);
}

.page-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.page-meta {
  position: absolute;
  z-index: 3;
  right: clamp(30px, 4.4vw, 64px);
  bottom: 20px;
  left: clamp(30px, 4.4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(109, 61, 84, 0.46);
  font-size: 8px;
  letter-spacing: 0.22em;
  line-height: 1.6;
  text-transform: uppercase;
}

.page-cover {
  border-radius: 4px 12px 12px 4px;
  background:
    radial-gradient(circle at 72% 42%, rgba(189, 125, 141, 0.18), transparent 36%),
    radial-gradient(circle at 22% 82%, rgba(107, 73, 112, 0.22), transparent 42%),
    linear-gradient(135deg, #1b1424 0%, #100d18 58%, #080710 100%);
  color: var(--gold-light);
}

.page-cover::before {
  border-color: rgba(201, 161, 95, 0.34);
}

.page-cover::after {
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.3));
}

.page-cover .page-meta {
  color: rgba(242, 221, 176, 0.46);
}

/* ---------- typography / shared ---------- */

.eyebrow {
  margin: 0;
  color: rgba(109, 61, 84, 0.58);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.3em;
  line-height: 1.7;
  text-transform: uppercase;
}

.eyebrow.gold {
  color: rgba(242, 221, 176, 0.68);
}

.chapter-head {
  max-width: 620px;
  margin-bottom: clamp(18px, 2.4vw, 28px);
}

.chapter-head h2 {
  margin: 7px 0 7px;
  color: var(--paper-ink);
  font-family: var(--serif);
  font-size: clamp(30px, 3.4vw, 42px);
  font-weight: 500;
  letter-spacing: 0.07em;
  line-height: 1.3;
}

.chapter-head > p:last-child {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.8;
}

.serif-note {
  margin: 0;
  color: var(--plum);
  font-family: var(--serif);
  font-size: clamp(17px, 1.7vw, 22px);
  line-height: 1.9;
  letter-spacing: 0.04em;
}

.hint {
  margin: 8px 0 0;
  color: var(--ink-faint);
  font-size: 10px;
  letter-spacing: 0.04em;
  line-height: 1.7;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 21px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.22s ease, background 0.25s ease, border-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-dark {
  border-color: var(--plum-deep);
  background: var(--plum-deep);
  color: var(--cream);
  box-shadow: 0 8px 22px rgba(60, 35, 50, 0.18);
}

.btn-dark:hover {
  background: var(--plum);
  border-color: var(--plum);
  box-shadow: 0 10px 26px rgba(60, 35, 50, 0.25);
}

.btn-gold {
  border-color: var(--gold);
  background: linear-gradient(120deg, #d6b477, #c39a58);
  color: #241820;
  box-shadow: 0 10px 28px rgba(201, 161, 95, 0.16);
}

.btn-gold:hover {
  background: linear-gradient(120deg, #e4c68d, #cfa564);
  box-shadow: 0 12px 32px rgba(201, 161, 95, 0.28);
}

.btn-line {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--plum);
}

.btn-line:hover {
  border-color: var(--gold);
  background: rgba(201, 161, 95, 0.08);
}

.btn-line-light {
  border-color: rgba(242, 221, 176, 0.3);
  background: transparent;
  color: var(--gold-light);
}

.btn-line-light:hover {
  border-color: rgba(242, 221, 176, 0.6);
  background: rgba(242, 221, 176, 0.08);
}

.btn:disabled {
  opacity: 0.42;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.text-btn {
  align-self: flex-start;
  padding: 2px 0;
  border: 0;
  border-bottom: 1px solid rgba(109, 61, 84, 0.26);
  background: none;
  color: var(--ink-soft);
  font-size: 10px;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.text-btn:hover {
  color: var(--plum);
  border-color: var(--plum);
}

/* ---------- pager ---------- */

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(242, 221, 176, 0.62);
  transition: opacity 0.5s ease;
}

.pager-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(242, 221, 176, 0.2);
  border-radius: 50%;
  background: rgba(20, 16, 29, 0.34);
  color: rgba(242, 221, 176, 0.72);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease, opacity 0.25s ease;
}

.pager-btn:hover {
  border-color: rgba(242, 221, 176, 0.5);
  background: rgba(201, 161, 95, 0.12);
  transform: translateY(-1px);
}

.pager-btn:disabled {
  opacity: 0.25;
  cursor: default;
  transform: none;
}

.dot-list {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.dot-btn::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(242, 221, 176, 0.26);
  transition: width 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.dot-btn:hover::before {
  background: rgba(242, 221, 176, 0.58);
}

.dot-btn.is-active::before {
  width: 16px;
  border-radius: 99px;
  background: var(--gold);
  box-shadow: 0 0 12px rgba(201, 161, 95, 0.5);
}

.pager-count {
  min-width: 54px;
  color: rgba(242, 221, 176, 0.5);
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-align: center;
}

/* ---------- cover page ---------- */

.cover-noise {
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.cover-layout {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(320px, 0.96fr);
  align-items: center;
  gap: clamp(16px, 2vw, 34px);
}

.cover-copy {
  position: relative;
  z-index: 2;
  padding-left: clamp(0px, 2vw, 26px);
}

.cover-title {
  margin: 18px 0 0;
  font-family: var(--display);
  font-weight: 400;
  line-height: 0.95;
}

.cover-title > span {
  display: block;
  color: rgba(255, 244, 225, 0.58);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.42em;
  line-height: 1.6;
  text-transform: uppercase;
}

.cover-title > strong {
  display: inline-block;
  margin-top: 8px;
  color: transparent;
  background: linear-gradient(120deg, #fff4d9 0%, #e6c88f 38%, #c99c65 72%, #f0ddae 100%);
  -webkit-background-clip: text;
  background-clip: text;
  font-size: clamp(5.1rem, 8.4vw, 8.4rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-shadow: 0 12px 50px rgba(201, 161, 95, 0.12);
}

.cover-title > em {
  display: inline-block;
  margin-left: 0.14em;
  color: var(--rose-soft);
  font-family: var(--sans);
  font-size: 0.17em;
  font-style: normal;
  vertical-align: 1.9em;
  animation: heartPulse 3.2s ease-in-out infinite;
}

.cover-sub {
  margin: 26px 0 0;
  color: rgba(255, 242, 225, 0.62);
  font-family: var(--serif);
  font-size: clamp(14px, 1.35vw, 17px);
  letter-spacing: 0.08em;
  line-height: 2;
}

.cover-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 28px;
}

.cover-hint {
  margin: 18px 0 0;
  color: rgba(255, 236, 216, 0.34);
  font-size: 9px;
  letter-spacing: 0.06em;
  line-height: 1.8;
}

.cover-atlas-wrap {
  position: relative;
  width: 100%;
  max-width: 470px;
  aspect-ratio: 1 / 1;
  justify-self: center;
}

.cover-atlas {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 0 34px rgba(201, 161, 95, 0.08));
}

.cover-atlas svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  transition: transform 0.8s var(--ease);
}

.cover-atlas:hover svg {
  transform: scale(1.018);
}

.heart-line {
  stroke-dasharray: 8 7;
  animation: heartDash 12s linear infinite;
}

.atlas-rotor {
  transform-origin: 260px 260px;
  animation: atlasSpin 90s linear infinite;
}

.heart-stars {
  animation: heartGlow 4.5s ease-in-out infinite;
}

.cover-seal {
  position: absolute;
  right: 2%;
  bottom: 6%;
  z-index: 3;
  width: 62px;
  height: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(201, 161, 95, 0.48);
  border-radius: 50%;
  color: var(--gold-light);
  transform: rotate(-8deg);
  box-shadow: 0 0 0 3px rgba(201, 161, 95, 0.06);
}

.cover-seal span {
  font-family: var(--display);
  font-size: 23px;
  line-height: 1;
}

.cover-seal small {
  margin-top: 3px;
  font-size: 6.5px;
  letter-spacing: 0.15em;
}

.cover-orbit {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  border: 1px solid rgba(201, 161, 95, 0.11);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.cover-orbit-a {
  width: 106%;
  height: 106%;
}

.cover-orbit-b {
  width: 78%;
  height: 78%;
  border-style: dashed;
}

/* generated cover stars */

.cover-star {
  position: absolute;
  z-index: 4;
  width: 5px;
  height: 5px;
  margin: -2.5px;
  border-radius: 50%;
  background: var(--gold-light);
  box-shadow: 0 0 14px 3px rgba(242, 221, 176, 0.55);
  pointer-events: none;
  animation: starPop 1s var(--ease) both;
}

.cover-star::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(242, 221, 176, 0.6), transparent);
  transform: translate(-50%, -50%);
}

/* ---------- cake page ---------- */

.cake-layout {
  display: grid;
  grid-template-columns: minmax(300px, 1.02fr) minmax(260px, 0.98fr);
  align-items: center;
  gap: clamp(20px, 3.2vw, 48px);
  min-height: 0;
}

.cake-window {
  position: relative;
  width: 100%;
  max-width: 450px;
  aspect-ratio: 1 / 1.02;
  justify-self: center;
  overflow: hidden;
  border: 1px solid rgba(201, 161, 95, 0.48);
  border-radius: 48% 48% 18px 18px / 30% 30% 18px 18px;
  background:
    radial-gradient(circle at 50% 62%, rgba(189, 125, 141, 0.2), transparent 48%),
    radial-gradient(circle at 50% 20%, rgba(201, 161, 95, 0.1), transparent 36%),
    linear-gradient(180deg, #1d1525 0%, #120e1b 58%, #090711 100%);
  box-shadow:
    inset 0 0 0 7px rgba(8, 7, 17, 0.55),
    inset 0 0 60px rgba(0, 0, 0, 0.55),
    0 22px 44px rgba(60, 35, 50, 0.22);
}

.cake-window::before {
  content: "";
  position: absolute;
  z-index: 3;
  inset: 12px;
  border: 1px solid rgba(201, 161, 95, 0.19);
  border-radius: 48% 48% 12px 12px / 30% 30% 12px 12px;
  pointer-events: none;
}

.window-glow {
  position: absolute;
  z-index: 0;
  left: 50%;
  bottom: 8%;
  width: 78%;
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 193, 133, 0.17), transparent 68%);
  filter: blur(15px);
  pointer-events: none;
}

.window-caption {
  position: absolute;
  z-index: 4;
  bottom: 18px;
  left: 0;
  right: 0;
  color: rgba(242, 221, 176, 0.42);
  font-size: 8px;
  letter-spacing: 0.22em;
  text-align: center;
  pointer-events: none;
}

.cake-svg {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  padding: 12px 12px 22px;
  overflow: visible;
}

.cake-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.cake-copy .serif-note {
  margin-bottom: 20px;
}

.cake-status {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  line-height: 1.7;
}

.hold-btn {
  position: relative;
  width: 100%;
  min-height: 56px;
  padding: 10px 18px 8px;
  overflow: hidden;
  border: 1px solid var(--plum-deep);
  border-radius: 999px;
  background: var(--plum-deep);
  color: var(--cream);
  text-align: center;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  box-shadow: 0 12px 28px rgba(60, 35, 50, 0.22);
  transition: transform 0.22s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.hold-btn:hover {
  background: var(--plum);
  transform: translateY(-1px);
}

.hold-btn.is-holding {
  box-shadow: 0 0 0 4px rgba(201, 161, 95, 0.12), 0 14px 30px rgba(60, 35, 50, 0.28);
}

.hold-btn.is-done,
.hold-btn:disabled {
  border-color: var(--gold-deep);
  background: linear-gradient(120deg, #6d3d54, #4a2a3c);
  cursor: default;
  transform: none;
  opacity: 0.88;
}

.hold-fill {
  position: absolute;
  z-index: 0;
  inset: 0;
  background: linear-gradient(90deg, rgba(201, 161, 95, 0.42), rgba(232, 194, 135, 0.35));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.05s linear;
  pointer-events: none;
}

.hold-label,
.hold-sub {
  position: relative;
  z-index: 1;
  display: block;
}

.hold-label {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  line-height: 1.5;
}

.hold-sub {
  margin-top: 2px;
  color: rgba(255, 244, 225, 0.42);
  font-size: 7px;
  letter-spacing: 0.26em;
  line-height: 1.4;
}

.cake-copy .text-btn {
  margin-top: 8px;
}

.cake-copy .btn {
  margin-top: 8px;
}

.cake-copy .hint {
  margin-top: 9px;
}

.cake-window.is-blown + .cake-copy .serif-note,
.page-cake.is-blown .serif-note {
  color: var(--gold-deep);
}

.flame {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: flameSway 0.68s ease-in-out infinite alternate;
}

.candle-b .flame {
  animation-duration: 0.56s;
  animation-delay: -0.15s;
}

.candle-c .flame {
  animation-duration: 0.78s;
  animation-delay: -0.3s;
}

.smoke {
  opacity: 0;
  fill: #e9ddd0;
  filter: blur(1.5px);
}

.page-cake.is-blown .flame {
  animation: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.page-cake.is-blown .smoke {
  animation: smokeRise 2.2s ease-out forwards;
}

.page-cake.is-blown .cat-eyes {
  animation: none;
}

.page-cake.is-blown .cake-svg {
  filter: drop-shadow(0 18px 30px rgba(255, 179, 130, 0.08));
}

.cat-eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: catBlink 6s ease-in-out infinite;
}

.cake-cat {
  cursor: pointer;
  outline: none;
}

.cake-cat:focus-visible {
  outline: none;
}

.cake-cat:focus-visible .cat-eyes {
  filter: drop-shadow(0 0 6px rgba(201, 161, 95, 0.9));
}

.cake-cat:hover .cat-eyes {
  filter: drop-shadow(0 0 5px rgba(201, 161, 95, 0.7));
}

/* ---------- care page ---------- */

.care-progress {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: -2px 0 16px;
  color: var(--ink-faint);
  font-size: 9px;
  letter-spacing: 0.12em;
  line-height: 1.6;
}

.care-progress-line {
  width: 92px;
  height: 1px;
  overflow: hidden;
  background: rgba(109, 61, 84, 0.16);
}

.care-progress-line i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--gold);
  transition: width 0.5s var(--ease);
}

.care-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 11px;
}

.care-card {
  height: 168px;
  padding: 0;
  border: 0;
  background: none;
  perspective: 900px;
  cursor: pointer;
}

.care-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.65s var(--ease);
}

.care-card:hover .care-inner {
  transform: translateY(-3px);
}

.care-card.is-flipped .care-inner {
  transform: rotateY(180deg);
}

.care-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.care-front {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.35), transparent 46%),
    linear-gradient(135deg, #f6ecdd, #e9d8c1);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.18);
}

.care-front::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(201, 161, 95, 0.2);
  border-radius: 5px;
  pointer-events: none;
}

.care-front em {
  position: absolute;
  top: 10px;
  left: 13px;
  color: rgba(109, 61, 84, 0.38);
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 8px;
  font-style: normal;
  letter-spacing: 0.12em;
}

.care-front b {
  color: var(--plum);
  font-family: var(--display);
  font-size: 36px;
  font-weight: 400;
  line-height: 1;
}

.care-front small {
  margin-top: 9px;
  color: var(--ink-soft);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.care-back {
  background:
    radial-gradient(circle at 50% 10%, rgba(201, 161, 95, 0.12), transparent 45%),
    linear-gradient(145deg, #573447, #3b2331);
  border-color: rgba(201, 161, 95, 0.3);
  color: rgba(255, 242, 225, 0.8);
  transform: rotateY(180deg);
}

.care-back i {
  margin-bottom: 8px;
  color: var(--gold-light);
  font-size: 14px;
  font-style: normal;
}

.care-back span {
  font-size: 11px;
  letter-spacing: 0.03em;
  line-height: 1.8;
  text-align: center;
}

.care-footnote {
  margin: 14px 0 0;
  color: var(--ink-faint);
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.06em;
  line-height: 1.6;
  text-align: center;
}

.care-complete {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 15px 17px;
  border: 1px dashed rgba(201, 161, 95, 0.45);
  border-radius: 9px;
  background: rgba(201, 161, 95, 0.07);
  animation: riseIn 0.6s var(--ease) both;
}

.care-complete.is-visible {
  display: flex;
}

.completion-stamp {
  color: var(--gold-deep);
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.08em;
  line-height: 1.5;
  transform: rotate(-2deg);
}

.completion-stamp small {
  font-family: var(--sans);
  font-size: 8px;
  letter-spacing: 0.12em;
}

/* ---------- fortune page ---------- */

.fortune-layout {
  display: grid;
  grid-template-columns: minmax(250px, 0.92fr) minmax(260px, 1.08fr);
  align-items: center;
  gap: clamp(22px, 4vw, 58px);
  min-height: 0;
}

.fortune-deck {
  position: relative;
  width: min(292px, 72%);
  aspect-ratio: 3 / 4;
  justify-self: center;
  perspective: 1400px;
}

.deck-card {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(109, 61, 84, 0.16);
  border-radius: 12px;
  background: linear-gradient(145deg, #efe2ce, #e3d0b7);
  box-shadow: 0 12px 24px rgba(60, 35, 50, 0.12);
}

.deck-a {
  transform: translate(9px, 8px) rotate(4deg);
}

.deck-b {
  transform: translate(-5px, 4px) rotate(-3deg);
}

.deck-c {
  transform: translate(2px, 1px) rotate(1deg);
}

.fortune-card {
  position: absolute;
  inset: 0;
  z-index: 3;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 1200px;
}

.fortune-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.85s var(--ease);
}

.fortune-card.is-flipped .fortune-inner {
  transform: rotateY(180deg);
}

.fortune-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 26px 22px;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.fortune-front {
  border: 1px solid var(--gold);
  background:
    radial-gradient(circle at 50% 28%, rgba(201, 161, 95, 0.16), transparent 38%),
    linear-gradient(145deg, #fbf3e6, #ead9c1);
  box-shadow:
    inset 0 0 0 5px rgba(201, 161, 95, 0.08),
    0 22px 44px rgba(60, 35, 50, 0.18);
}

.fortune-front::before,
.fortune-front::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(201, 161, 95, 0.16);
  border-radius: 7px;
}

.fortune-front::after {
  inset: 18px;
  opacity: 0.5;
}

.fortune-seal {
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  border: 1px solid rgba(201, 161, 95, 0.48);
  border-radius: 50%;
  color: var(--gold-deep);
  font-family: var(--display);
  font-size: 26px;
  transform: rotate(-8deg);
  box-shadow: 0 0 0 4px rgba(201, 161, 95, 0.05);
}

.fortune-front b {
  color: var(--plum);
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.12em;
}

.fortune-front small {
  margin-top: 9px;
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.16em;
}

.fortune-back {
  border: 1px solid rgba(201, 161, 95, 0.34);
  background:
    radial-gradient(circle at 50% 15%, rgba(201, 161, 95, 0.13), transparent 38%),
    linear-gradient(145deg, #5a3548, #3a2230);
  color: rgba(255, 244, 225, 0.82);
  transform: rotateY(180deg);
  text-align: center;
}

.fortune-back small {
  color: rgba(242, 221, 176, 0.52);
  font-size: 8px;
  letter-spacing: 0.24em;
}

.fortune-back strong {
  margin: 15px 0 10px;
  color: var(--gold-light);
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.fortune-back p {
  margin: 0;
  color: rgba(255, 242, 225, 0.72);
  font-size: 11px;
  letter-spacing: 0.03em;
  line-height: 1.9;
}

.lucky-row {
  display: flex;
  gap: 18px;
  margin-top: 18px;
  padding-top: 13px;
  border-top: 1px solid rgba(242, 221, 176, 0.14);
  color: rgba(255, 242, 225, 0.42);
  font-size: 8px;
  line-height: 1.7;
}

.lucky-row span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.lucky-row em {
  color: rgba(255, 242, 225, 0.76);
  font-style: normal;
}

.lucky-row i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rose-soft);
  box-shadow: 0 0 8px rgba(229, 185, 189, 0.45);
}

.fortune-sign {
  margin-top: 18px;
  color: rgba(242, 221, 176, 0.5);
  font-family: var(--display);
  font-size: 16px;
  transform: rotate(-4deg);
}

.fortune-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.fortune-copy .serif-note {
  margin-bottom: 22px;
}

.fortune-copy .hint {
  max-width: 320px;
}

/* ---------- letter page ---------- */

.letter-page {
  min-height: 0;
}

.letter-head {
  flex: 0 0 auto;
  margin-bottom: 12px;
}

.letter-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.envelope {
  position: relative;
  align-self: center;
  width: min(520px, 88%);
  aspect-ratio: 1.65 / 1;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 1200px;
  transition: opacity 0.4s ease, transform 0.5s var(--ease);
}

.envelope:hover {
  transform: translateY(-3px);
}

.env-back,
.env-front,
.env-flap {
  position: absolute;
  display: block;
}

.env-back {
  inset: 0;
  border: 1px solid rgba(109, 61, 84, 0.2);
  border-radius: 7px;
  background: linear-gradient(145deg, #e5cfb3, #d6b995);
  box-shadow: 0 22px 40px rgba(60, 35, 50, 0.2);
}

.env-address {
  position: absolute;
  z-index: 4;
  top: 63%;
  right: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--plum);
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.env-address i {
  font-family: var(--serif);
  font-size: 18px;
  font-style: normal;
  letter-spacing: 0.18em;
  text-shadow: 0 1px 0 rgba(255, 250, 240, 0.5);
}

.env-address small {
  margin-top: 5px;
  color: rgba(109, 61, 84, 0.46);
  font-size: 6.5px;
  letter-spacing: 0.22em;
}

.env-front {
  z-index: 2;
  right: 0;
  bottom: 0;
  left: 0;
  height: 66%;
  border-radius: 0 0 7px 7px;
  background: linear-gradient(155deg, #dcc3a4, #cfad86);
  clip-path: polygon(0 0, 50% 42%, 100% 0, 100% 100%, 0 100%);
}

.env-flap {
  z-index: 3;
  top: 0;
  right: 0;
  left: 0;
  height: 58%;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(160deg, #ead6ba, #d9bd99);
  clip-path: polygon(0 0, 100% 0, 50% 84%);
  transform-origin: top center;
  transition: transform 0.6s var(--ease);
}

.wax-seal {
  position: absolute;
  z-index: 4;
  top: 41%;
  left: 50%;
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 214, 190, 0.42);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #a85562, #763644 60%, #542332);
  color: #ffe9d2;
  font-family: var(--display);
  font-size: 25px;
  box-shadow:
    0 7px 14px rgba(60, 20, 32, 0.3),
    inset 0 0 0 4px rgba(255, 222, 200, 0.07);
  transform: translate(-50%, -50%) rotate(-8deg);
  transition: transform 0.5s var(--ease), opacity 0.4s ease;
}

.env-hint {
  position: absolute;
  z-index: 4;
  bottom: 13%;
  left: 0;
  right: 0;
  color: rgba(70, 40, 52, 0.52);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-align: center;
  transition: opacity 0.3s ease;
}

.letter-stage.is-opening .env-flap {
  transform: rotateX(180deg);
}

.letter-stage.is-opening .wax-seal {
  opacity: 0;
  transform: translate(-50%, -50%) rotate(-8deg) scale(1.3);
}

.letter-stage.is-opening .env-hint,
.letter-stage.is-opening .env-address {
  opacity: 0;
}

.letter-stage.is-open .envelope {
  display: none;
}

.letter-paper {
  display: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid rgba(109, 61, 84, 0.17);
  border-radius: 8px;
  background:
    radial-gradient(circle at 82% 0%, rgba(201, 161, 95, 0.08), transparent 32%),
    #fbf3e6;
  box-shadow: 0 16px 34px rgba(60, 35, 50, 0.12);
  overflow: hidden;
  position: relative;
}

.letter-stage.is-open .letter-paper {
  display: flex;
  flex-direction: column;
  animation: letterIn 0.75s var(--ease) both;
}

.letter-paper::after {
  content: "猫猫已阅";
  position: absolute;
  z-index: 2;
  right: 28px;
  bottom: 24px;
  padding: 8px 12px;
  border: 2px solid rgba(157, 73, 84, 0.4);
  border-radius: 4px;
  color: rgba(157, 73, 84, 0.52);
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.1em;
  opacity: 0;
  transform: rotate(-12deg) scale(1.4);
  pointer-events: none;
}

.letter-paper.is-stamped::after {
  animation: stampDown 0.5s var(--ease) both;
}

.letter-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 32px 30px;
  scrollbar-width: thin;
  scrollbar-color: rgba(109, 61, 84, 0.24) transparent;
}

.letter-kicker {
  margin: 0 0 7px;
  color: var(--ink-faint);
  font-size: 7.5px;
  letter-spacing: 0.26em;
}

.letter-paper h3 {
  margin: 0 0 15px;
  color: var(--plum);
  font-family: var(--display);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.07em;
  line-height: 1.35;
}

.letter-paper p {
  margin: 0 0 11px;
  color: rgba(45, 34, 48, 0.78);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.03em;
  line-height: 1.95;
}

.letter-page-hint {
  margin: 0 0 12px !important;
  color: var(--ink-faint) !important;
  font-family: var(--sans) !important;
  font-size: 8px !important;
  letter-spacing: 0.14em !important;
  line-height: 1.6 !important;
}

.letter-paper .letter-lead {
  color: var(--plum);
  font-size: 15px;
  font-weight: 600;
}

.wish-stamps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0 9px;
}

.wish-stamp {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 55px;
  padding: 6px 4px;
  border: 1px dashed rgba(109, 61, 84, 0.32);
  border-radius: 4px;
  background: rgba(255, 250, 240, 0.45);
  color: var(--plum);
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.wish-stamp:hover {
  border-color: var(--gold);
  background: rgba(201, 161, 95, 0.1);
  transform: translateY(-1px);
}

.wish-stamp.is-active {
  border-style: solid;
  border-color: var(--gold);
  background: rgba(201, 161, 95, 0.14);
}

.wish-stamp span {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1;
}

.wish-stamp small {
  color: var(--ink-soft);
  font-size: 8px;
  letter-spacing: 0.04em;
}

.wish-note {
  min-height: 20px;
  margin: 0 0 12px !important;
  color: var(--gold-deep) !important;
  font-size: 10px !important;
  line-height: 1.7 !important;
}

.letter-sign {
  margin: 4px 0 16px !important;
  color: var(--plum) !important;
  font-family: var(--display) !important;
  font-size: 18px !important;
  text-align: right;
}

.coupon-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0 18px;
}

.coupon {
  padding: 10px 9px;
  border: 1px dashed rgba(201, 161, 95, 0.48);
  border-radius: 4px;
  background: rgba(201, 161, 95, 0.06);
  text-align: center;
}

.coupon small {
  display: block;
  color: rgba(109, 61, 84, 0.42);
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 6px;
  letter-spacing: 0.12em;
}

.coupon b {
  display: block;
  margin: 4px 0 3px;
  color: var(--plum);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
}

.coupon span {
  display: block;
  color: var(--ink-faint);
  font-size: 7.5px;
  line-height: 1.5;
}

.letter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- opening ---------- */

.opening {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 42%, rgba(109, 61, 84, 0.26), transparent 48%),
    rgba(5, 4, 10, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.opening.is-leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.opening-card {
  position: relative;
  width: min(460px, 92vw);
  max-height: min(92svh, 760px);
  overflow-y: auto;
  padding: 34px 34px 28px;
  border: 1px solid rgba(201, 161, 95, 0.44);
  border-radius: 18px;
  background:
    radial-gradient(circle at 82% 0%, rgba(201, 161, 95, 0.11), transparent 34%),
    linear-gradient(145deg, #f8f0e3, #ecddc7);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.55),
    inset 0 0 0 6px rgba(255, 255, 255, 0.12);
  text-align: center;
  scrollbar-width: thin;
}

.opening-card::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(201, 161, 95, 0.2);
  border-radius: 12px;
  pointer-events: none;
}

.opening-stamp {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 218, 196, 0.5);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #a85562, #763644 62%, #542332);
  color: #ffe9d2;
  font-family: var(--display);
  font-size: 18px;
  transform: rotate(8deg);
  box-shadow: 0 8px 16px rgba(60, 20, 32, 0.25);
  z-index: 2;
}

.opening-card .eyebrow {
  margin-top: 6px;
  color: rgba(109, 61, 84, 0.52);
  font-size: 7.5px;
}

.opening-card h1 {
  margin: 9px 0 4px;
  color: var(--plum);
  font-family: var(--display);
  font-size: 44px;
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

.opening-sub {
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.06em;
  line-height: 1.8;
}

.heart-frame {
  position: relative;
  width: min(280px, 72vw);
  aspect-ratio: 1 / 1;
  margin: 6px auto 0;
  overflow: hidden;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 48%, rgba(189, 125, 141, 0.12), transparent 62%),
    rgba(255, 250, 240, 0.35);
  box-shadow: inset 0 0 30px rgba(201, 161, 95, 0.08);
}

.heart-frame::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px dashed rgba(201, 161, 95, 0.22);
  border-radius: 50%;
  pointer-events: none;
}

#heartCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.opening-status {
  min-height: 20px;
  margin: 2px 0 8px;
  color: var(--gold-deep);
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.08em;
  line-height: 1.7;
}

.opening-enter {
  width: 100%;
}

.opening-foot {
  margin: 12px 0 0;
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.14em;
}

body.is-opening .stage,
body.is-opening .topbar {
  filter: blur(10px);
  opacity: 0.22;
  pointer-events: none;
  transform: scale(0.985);
}

body.is-opening .pager {
  opacity: 0;
  pointer-events: none;
}

/* ---------- QR modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 4, 10, 0.68);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-card {
  position: relative;
  width: min(400px, 100%);
  max-height: 92svh;
  overflow-y: auto;
  padding: 32px 28px 26px;
  border: 1px solid rgba(201, 161, 95, 0.4);
  border-radius: 16px;
  background:
    radial-gradient(circle at 80% 0%, rgba(201, 161, 95, 0.1), transparent 35%),
    linear-gradient(145deg, #f8f0e3, #ecddc7);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.modal-card .eyebrow {
  color: rgba(109, 61, 84, 0.5);
  font-size: 7.5px;
}

.modal-card h2 {
  margin: 9px 0 18px;
  color: var(--plum);
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 500;
  letter-spacing: 0.07em;
  line-height: 1.45;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(109, 61, 84, 0.2);
  border-radius: 50%;
  background: transparent;
  color: rgba(109, 61, 84, 0.65);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
}

.modal-close:hover {
  background: rgba(201, 161, 95, 0.12);
  transform: rotate(90deg);
}

.qr-frame {
  position: relative;
  width: min(224px, 68vw);
  margin: 0 auto;
  padding: 11px;
  border-radius: 12px;
  background: #fffaf1;
  box-shadow: 0 14px 30px rgba(60, 35, 50, 0.18);
}

#qrCanvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  image-rendering: pixelated;
}

.qr-corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: rgba(201, 161, 95, 0.6);
  border-style: solid;
  pointer-events: none;
}

.qr-tl {
  top: -6px;
  left: -6px;
  border-width: 1.5px 0 0 1.5px;
}

.qr-tr {
  top: -6px;
  right: -6px;
  border-width: 1.5px 1.5px 0 0;
}

.qr-bl {
  bottom: -6px;
  left: -6px;
  border-width: 0 0 1.5px 1.5px;
}

.qr-br {
  right: -6px;
  bottom: -6px;
  border-width: 0 1.5px 1.5px 0;
}

.qr-note {
  margin: 16px 0 0;
  color: var(--ink-soft);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  line-height: 1.8;
}

.qr-url {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 4px 4px 4px 10px;
  border: 1px solid rgba(109, 61, 84, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.26);
}

.qr-url code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 9px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qr-url button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(109, 61, 84, 0.16);
  border-radius: 999px;
  background: transparent;
  color: var(--plum);
  font-size: 9px;
  cursor: pointer;
}

.qr-help {
  margin: 10px 0 0;
  color: var(--ink-faint);
  font-size: 8px;
  line-height: 1.7;
}

.qr-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(72px + var(--safe-bottom));
  z-index: 300;
  max-width: min(86vw, 390px);
  padding: 10px 16px;
  border: 1px solid rgba(242, 221, 176, 0.22);
  border-radius: 999px;
  background: rgba(28, 20, 35, 0.92);
  color: rgba(255, 244, 225, 0.86);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  line-height: 1.6;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 8px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

.toast.is-show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* ---------- animations ---------- */

@keyframes auroraDrift {
  from { transform: translate3d(-2%, 0, 0) scale(1); }
  to { transform: translate3d(4%, 4%, 0) scale(1.08); }
}

@keyframes markPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.16); }
}

@keyframes soundSway {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(7deg); }
}

@keyframes heartPulse {
  0%, 100% { transform: scale(1); opacity: 0.78; }
  50% { transform: scale(1.16); opacity: 1; }
}

@keyframes atlasSpin {
  to { transform: rotate(360deg); }
}

@keyframes heartDash {
  to { stroke-dashoffset: -160; }
}

@keyframes heartGlow {
  0%, 100% { opacity: 0.66; }
  50% { opacity: 1; }
}

@keyframes pageOutNext {
  0% { transform: rotateY(0deg) translateZ(0); opacity: 1; }
  72% { opacity: 1; }
  100% { transform: rotateY(-86deg) translateZ(18px); opacity: 0; }
}

@keyframes pageOutPrev {
  0% { transform: rotateY(0deg) translateZ(0); opacity: 1; }
  72% { opacity: 1; }
  100% { transform: rotateY(86deg) translateZ(18px); opacity: 0; }
}

@keyframes pageInNext {
  0% { transform: translateX(2.4%) scale(0.996); }
  100% { transform: translateX(0) scale(1); }
}

@keyframes pageInPrev {
  0% { transform: translateX(-2.4%) scale(0.996); }
  100% { transform: translateX(0) scale(1); }
}

@keyframes flameSway {
  0% { translate: -1.2px 0; opacity: 0.88; }
  50% { translate: 1px -0.6px; opacity: 1; }
  100% { translate: 1.6px 0.3px; opacity: 0.94; }
}

@keyframes smokeRise {
  0% { opacity: 0; transform: translateY(5px) scale(0.8); }
  18% { opacity: 0.38; }
  100% { opacity: 0; transform: translateY(-30px) scale(1.3); }
}

@keyframes catBlink {
  0%, 44%, 50%, 100% { transform: scaleY(1); }
  47% { transform: scaleY(0.08); }
}

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

@keyframes letterIn {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes stampDown {
  0% { opacity: 0; transform: rotate(-12deg) scale(1.6); }
  65% { opacity: 0.7; transform: rotate(-12deg) scale(0.96); }
  100% { opacity: 1; transform: rotate(-12deg) scale(1); }
}

@keyframes starPop {
  0% { opacity: 0; transform: scale(0.2); }
  55% { opacity: 1; transform: scale(1.4); }
  100% { opacity: 0.8; transform: scale(1); }
}

/* ---------- responsive ---------- */

@media (hover: none) and (pointer: coarse) {
  .qr-btn {
    display: none;
  }
}

@media (max-width: 900px) {
  .stage {
    padding-top: calc(68px + var(--safe-top));
    padding-bottom: calc(10px + var(--safe-bottom));
    gap: 9px;
  }

  .book-shell {
    width: 94vw;
    height: calc(100svh - 132px);
    perspective: 2200px;
  }

  .page {
    padding: 24px 24px 40px;
  }

  .page::before {
    inset: 9px;
  }

  .page-meta {
    right: 24px;
    bottom: 14px;
    left: 24px;
    font-size: 7px;
  }

  .cover-layout {
    grid-template-columns: 1fr;
    align-content: center;
    justify-items: center;
    gap: 0;
    text-align: center;
  }

  .cover-copy {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-left: 0;
  }

  .cover-title > strong {
    font-size: clamp(4.2rem, 16vw, 6.4rem);
  }

  .cover-sub {
    margin-top: 16px;
    font-size: 13px;
  }

  .cover-actions {
    justify-content: center;
    margin-top: 18px;
  }

  .cover-hint {
    display: none;
  }

  .cover-atlas-wrap {
    width: min(48vw, 260px);
    margin-top: -4px;
  }

  .cover-seal {
    right: 0;
    bottom: 2%;
    width: 48px;
    height: 48px;
  }

  .cover-seal span {
    font-size: 19px;
  }

  .cake-layout {
    grid-template-columns: 1fr;
    gap: 8px;
    text-align: center;
  }

  .cake-window {
    width: min(70vw, 330px);
    max-width: none;
  }

  .cake-copy {
    align-items: center;
  }

  .cake-copy .serif-note {
    margin: 2px 0 9px;
    font-size: 15px;
    line-height: 1.7;
  }

  .cake-copy .hold-btn {
    width: min(100%, 330px);
  }

  .cake-copy .hint {
    display: none;
  }

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

  .care-card {
    height: 114px;
  }

  .care-front b {
    font-size: 29px;
  }

  .care-front small {
    margin-top: 6px;
    font-size: 9px;
  }

  .care-back span {
    font-size: 10px;
    line-height: 1.7;
  }

  .care-complete {
    margin-top: 12px;
    padding: 11px 12px;
  }

  .completion-stamp {
    font-size: 12px;
  }

  .fortune-layout {
    grid-template-columns: 1fr;
    gap: 8px;
    text-align: center;
  }

  .fortune-deck {
    width: min(47vw, 230px);
    margin: 0 auto;
  }

  .fortune-copy {
    align-items: center;
  }

  .fortune-copy .serif-note {
    display: none;
  }

  .fortune-copy .btn {
    margin-top: 4px;
  }

  .letter-head {
    text-align: center;
  }

  .letter-head .eyebrow {
    justify-content: center;
  }

  .letter-scroll {
    padding: 20px 18px 24px;
  }

  .letter-paper h3 {
    font-size: 25px;
  }

  .letter-paper p {
    font-size: 12px;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: calc(12px + var(--safe-top)) 14px 8px;
  }

  .brand {
    gap: 7px;
  }

  .brand-copy b {
    font-size: 9px;
    letter-spacing: 0.14em;
  }

  .brand-copy small {
    font-size: 6.5px;
    letter-spacing: 0.12em;
  }

  .brand-mark {
    font-size: 11px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }

  .qr-btn {
    display: none;
  }

  .stage {
    padding-top: calc(58px + var(--safe-top));
    padding-bottom: calc(8px + var(--safe-bottom));
    gap: 8px;
  }

  .book-shell {
    width: 94vw;
    height: calc(100svh - 112px);
  }

  .book::before {
    width: 12px;
  }

  .page {
    padding: 18px 17px 34px;
  }

  .page::before {
    inset: 7px;
  }

  .page-meta {
    right: 17px;
    bottom: 10px;
    left: 17px;
    font-size: 6.5px;
    letter-spacing: 0.16em;
  }

  .page-scroll {
    padding-right: 3px;
    padding-bottom: 24px;
  }

  .eyebrow {
    font-size: 7px;
    letter-spacing: 0.2em;
  }

  .chapter-head {
    margin-bottom: 12px;
    text-align: center;
  }

  .chapter-head h2 {
    margin: 5px 0 5px;
    font-size: 27px;
  }

  .chapter-head > p:last-child {
    font-size: 10px;
    line-height: 1.7;
  }

  .cover-atlas-wrap {
    width: min(54vw, 225px);
  }

  .cover-title > strong {
    font-size: clamp(3.8rem, 19vw, 5.2rem);
  }

  .cover-title > span {
    font-size: 8px;
  }

  .cover-sub {
    font-size: 12px;
    line-height: 1.8;
  }

  .cover-actions {
    flex-direction: column;
    width: min(100%, 260px);
  }

  .cover-actions .btn {
    width: 100%;
  }

  .cover-seal {
    width: 42px;
    height: 42px;
  }

  .cover-seal span {
    font-size: 17px;
  }

  .cover-seal small {
    font-size: 5px;
  }

  .cake-window {
    width: min(76vw, 300px);
  }

  .cake-copy .serif-note {
    font-size: 13px;
  }

  .cake-status {
    margin-bottom: 8px;
    font-size: 9px;
  }

  .hold-btn {
    min-height: 50px;
    padding: 8px 14px 6px;
  }

  .hold-label {
    font-size: 10.5px;
  }

  .hold-sub {
    font-size: 6px;
  }

  .care-progress {
    justify-content: center;
    margin: 0 0 10px;
    font-size: 8px;
  }

  .care-card {
    height: 132px;
  }

  .care-front b {
    font-size: 25px;
  }

  .care-front em {
    top: 7px;
    left: 9px;
    font-size: 6.5px;
  }

  .care-front small {
    font-size: 8px;
  }

  .care-back {
    padding: 8px;
  }

  .care-back i {
    margin-bottom: 4px;
    font-size: 11px;
  }

  .care-back span {
    font-size: 9px;
    line-height: 1.65;
  }

  .care-complete {
    flex-direction: column;
    gap: 9px;
    padding: 10px;
    text-align: center;
  }

  .care-complete .btn {
    width: 100%;
  }

  .fortune-deck {
    width: min(68vw, 260px);
  }

  .fortune-back {
    padding: 18px 14px;
  }

  .fortune-back strong {
    font-size: 19px;
    margin: 10px 0 7px;
  }

  .fortune-back p {
    font-size: 9.5px;
    line-height: 1.7;
  }

  .lucky-row {
    gap: 10px;
    margin-top: 12px;
    padding-top: 9px;
    font-size: 7px;
  }

  .fortune-sign {
    margin-top: 10px;
    font-size: 13px;
  }

  .fortune-copy .btn {
    width: min(100%, 250px);
  }

  .fortune-copy .hint {
    font-size: 8px;
  }

  .letter-head {
    margin-bottom: 8px;
  }

  .letter-head h2 {
    font-size: 25px;
  }

  .envelope {
    width: 100%;
    aspect-ratio: 1.55 / 1;
  }

  .wax-seal {
    width: 48px;
    height: 48px;
    font-size: 21px;
  }

  .letter-paper h3 {
    font-size: 22px;
  }

  .letter-paper p {
    font-size: 11px;
    line-height: 1.9;
  }

  .wish-stamps {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    margin-top: 13px;
  }

  .wish-stamp {
    min-height: 46px;
    padding: 4px 2px;
  }

  .wish-stamp span {
    font-size: 15px;
  }

  .wish-stamp small {
    font-size: 7px;
  }

  .coupon-row {
    grid-template-columns: 1fr;
    gap: 5px;
    margin: 12px 0 14px;
  }

  .coupon {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
    padding: 7px 8px;
    text-align: left;
  }

  .coupon small {
    display: none;
  }

  .coupon b {
    margin: 0;
    font-size: 11px;
  }

  .coupon span {
    font-size: 7px;
  }

  .letter-actions {
    flex-direction: column;
  }

  .letter-actions .btn {
    width: 100%;
  }

  .pager {
    gap: 7px;
  }

  .pager-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .dot-list {
    gap: 0;
  }

  .dot-btn {
    width: 21px;
    height: 22px;
  }

  .dot-btn::before {
    width: 3px;
    height: 3px;
  }

  .dot-btn.is-active::before {
    width: 11px;
  }

  .pager-count {
    min-width: 42px;
    font-size: 8px;
  }

  .opening {
    padding: 12px;
  }

  .opening-card {
    width: min(100%, 390px);
    padding: 30px 20px 22px;
  }

  .opening-card h1 {
    font-size: 37px;
  }

  .heart-frame {
    width: min(245px, 67vw);
  }

  .opening-sub {
    font-size: 11px;
  }

  .opening-status {
    font-size: 11px;
  }

  .modal-card {
    padding: 28px 18px 22px;
  }

  .modal-card h2 {
    font-size: 23px;
  }

  .qr-actions {
    flex-direction: column;
  }

  .qr-actions .btn {
    width: 100%;
  }
}

@media (min-width: 901px) and (max-height: 790px) {
  .stage {
    padding-top: calc(68px + var(--safe-top));
    padding-bottom: 10px;
  }

  .book-shell {
    height: calc(100svh - 148px);
  }

  .chapter-head {
    margin-bottom: 14px;
  }

  .chapter-head h2 {
    font-size: 33px;
  }

  .cover-title > strong {
    font-size: clamp(4.4rem, 7.4vw, 6.8rem);
  }

  .cake-window {
    max-width: 380px;
  }

  .care-card {
    height: 126px;
  }

  .fortune-deck {
    width: min(248px, 68%);
  }
}

@media (max-height: 680px) and (max-width: 900px) {
  .stage {
    padding-top: calc(54px + var(--safe-top));
  }

  .book-shell {
    height: calc(100svh - 104px);
  }

  .chapter-head h2 {
    font-size: 24px;
  }

  .cake-window {
    width: min(58vw, 235px);
  }

  .cover-atlas-wrap {
    width: min(42vw, 175px);
  }

  .cover-sub {
    display: none;
  }

  .cover-actions {
    margin-top: 10px;
  }

  .care-card {
    height: 94px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .page {
    transform: none;
  }
}
