:root {
  color-scheme: dark;
  --night: #061126;
  --night-soft: #102d4d;
  --jade: #76b7ae;
  --gold: #f6d68c;
  --gold-soft: #ffedbd;
  --ivory: #fff8e8;
  --ink: #07101f;
}

* { box-sizing: border-box; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
html, body { margin: 0; min-height: 100%; background: #030915; }
body {
  color: var(--ivory);
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { color: inherit; font: inherit; -webkit-tap-highlight-color: transparent; }

.moon-page {
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 20%, #174669 0, #08162c 38%, #020712 100%);
}

.story {
  position: relative;
  width: min(100vw, 500px);
  height: 100svh;
  min-height: 620px;
  overflow: hidden;
  isolation: isolate;
  background: #07152c;
}

.sky {
  position: absolute;
  inset: 0;
  z-index: -9;
  overflow: hidden;
  background: #060c1c;
}

.sky-photo {
  position: absolute;
  left: 50%;
  top: 45%;
  width: max(220%, 160svh);
  max-width: none;
  height: auto;
  transform: translate(-50%, -50%) rotate(-58deg);
  filter: brightness(.76) saturate(.72);
}
.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 12%, rgba(106, 133, 182, .12), transparent 32%),
    linear-gradient(180deg, rgba(5, 16, 40, .1), rgba(4, 15, 34, .22) 38%, rgba(3, 12, 27, .72) 85%, #040d1c);
}

.moon-wrap {
  position: absolute;
  z-index: -5;
  top: max(6svh, 40px);
  left: 50%;
  width: clamp(168px, 49vw, 226px);
  aspect-ratio: 1;
  transform: translateX(-50%);
  opacity: .98;
  transition: transform 2s cubic-bezier(.2,.7,.2,1), opacity 1.2s;
}
.moon-halo {
  position: absolute;
  inset: -40%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(221, 234, 255, .17), rgba(203, 223, 255, .05) 44%, transparent 70%);
}
.moon {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 50%;
  mix-blend-mode: screen;
  box-shadow: 0 0 18px rgba(220, 231, 255, .12);
}
.moon-photo { position: absolute; width: 147.2%; max-width: none; height: auto; left: -26.7%; top: -3.1%; filter: brightness(.94); }

.osmanthus {
  position: absolute;
  z-index: -3;
  top: -22px;
  left: -42px;
  width: 170px;
  height: 300px;
  overflow: visible;
  opacity: .76;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.2));
  transform-origin: 0 100%;
  animation: branchSway 7s ease-in-out infinite alternate;
}
.osmanthus path { fill: none; stroke: #7d8063; stroke-width: 3; stroke-linecap: round; }
.osmanthus .leaves { fill: #487366; }
.osmanthus .flowers { fill: #f1cb72; filter: drop-shadow(0 0 3px rgba(255, 217, 119, .55)); }

.cloud { position: absolute; z-index: -2; height: 68px; border-radius: 50%; opacity: .25; filter: blur(1px); }
.cloud::before, .cloud::after { content: ""; position: absolute; border-radius: 50%; background: inherit; }
.cloud-one { top: 29%; left: -35%; width: 72%; background: #8eb5bc; animation: cloudDrift 20s linear infinite; }
.cloud-one::before { width: 48%; height: 110%; left: 23%; top: -36%; }
.cloud-one::after { width: 40%; height: 90%; right: 8%; top: -20%; }
.cloud-two { top: 38%; right: -45%; width: 62%; background: #98adb2; animation: cloudDriftReverse 25s linear infinite; }
.cloud-two::before { width: 55%; height: 125%; left: 14%; top: -44%; }
.cloud-two::after { width: 36%; height: 82%; right: 5%; top: -17%; }
.cloud-three { top: 73%; left: -20%; width: 94%; height: 90px; background: #0b2941; opacity: .72; filter: blur(8px); animation: cloudDrift 30s linear infinite reverse; }

.brand {
  position: absolute;
  z-index: 8;
  top: calc(env(safe-area-inset-top) + 18px);
  left: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(255, 241, 204, .72);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .2em;
}
.brand b { width: 24px; height: 1px; background: currentColor; opacity: .55; }
.story.is-playing .brand { display: none; }

.characters-stage {
  position: absolute; z-index: 3; left: 50%;
  bottom: max(65px, 7.5%);
  width: min(83%, calc(59svh * .666667));
  aspect-ratio: 2 / 3; transform: translateX(-50%); pointer-events: none;
}
.walk-layer, .walker, .walker img, .scene-frame { position: absolute; inset: 0; width: 100%; height: 100%; }
.walk-layer { z-index: 2; }
.walk-poster, #walkCanvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#walkCanvas { visibility: hidden; }
.video-ready #walkCanvas { visibility: visible; }
.video-ready .walk-poster { visibility: hidden; }
#walkVideo { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.walker { will-change: transform; }
.walker img, .scene-frame { object-fit: contain; }
.walker-left .walk-a { clip-path: inset(0 50.4% 0 0); }
.walker-right .walk-a { clip-path: inset(0 0 0 49.6%); }
.walker-left .walk-b { clip-path: inset(0 48.4% 0 0); }
.walker-right .walk-b { clip-path: inset(0 0 0 51.6%); }
.walker-left { transform: translateX(-10%); }
.walker-right { transform: translateX(10%); }
.walk-b, .scene-frame { opacity: 0; }
.scene-frame { z-index: 3; }
#acceptFrame { z-index: 4; }
#turnFrame { z-index: 5; }
#frontFrame { z-index: 6; }
.story.is-paused *, .story.is-paused *::before, .story.is-paused *::after { animation-play-state: paused !important; }
.lantern-glow {
  position: absolute;
  z-index: 1;
  left: 43%;
  top: 58%;
  width: 35%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 195, 84, .42), rgba(255, 166, 61, .12) 43%, transparent 70%);
  mix-blend-mode: screen;
  animation: lanternPulse 2.4s ease-in-out infinite alternate;
}
.ground-light { position: absolute; z-index: 0; left: 12%; right: 12%; bottom: 5%; height: 9%; border-radius: 50%; background: rgba(105, 174, 166, .17); filter: blur(14px); }

.story-copy {
  position: absolute;
  z-index: 6;
  top: 23%;
  left: 28px;
  right: 28px;
  text-align: center;
  text-shadow: 0 2px 18px rgba(1, 7, 19, .75);
  pointer-events: none;
  opacity: 0;
  transform: translateY(12px);
}
.story-copy { visibility: hidden; }
.story.is-playing.has-greeting .story-copy { visibility: visible; opacity: 1; transform: translateY(0); transition: opacity 1.2s, transform 1.2s; }
.story-copy.is-changing { opacity: 0; transform: translateY(-8px); transition: .35s ease; }
.copy-kicker { margin: 0 0 6px; color: var(--gold); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 10px; letter-spacing: .38em; text-indent: .38em; }
.story-copy h1 { margin: 0; color: #fff6dc; font-size: clamp(34px, 10vw, 48px); font-weight: 500; letter-spacing: .18em; text-indent: .18em; line-height: 1.2; }
.copy-line { margin: 9px 0 0; color: rgba(255, 249, 231, .84); font-size: clamp(13px, 3.8vw, 16px); letter-spacing: .12em; line-height: 1.75; }

.progress {
  position: absolute;
  z-index: 10;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  left: 50%;
  display: flex;
  gap: 7px;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity .5s;
}
.story.is-playing .progress { opacity: 1; }
.progress button { position: relative; width: 25px; height: 28px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.progress button::after { content: ""; position: absolute; inset: 13px 4px; background: rgba(255,255,255,.28); border-radius: 2px; }
.progress button.is-active::after { background: var(--gold); inset-inline: 0; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.progress { pointer-events: none; }
.story.is-playing .progress { pointer-events: auto; }

.controls { position: absolute; z-index: 15; top: calc(env(safe-area-inset-top) + 14px); right: 13px; display: flex; gap: 6px; }
.music-button { position: absolute; z-index: 26; top: calc(env(safe-area-inset-top) + 14px); right: 93px; }
.music-button[aria-pressed="false"] { opacity: .55; text-decoration: line-through; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; background: rgba(4, 17, 35, .35); color: rgba(255,255,255,.76); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 12px; backdrop-filter: blur(8px); cursor: pointer; }

.tap-field { position: absolute; z-index: 4; inset: 0; width: 100%; border: 0; background: transparent; cursor: pointer; }
.tap-hint { position: absolute; z-index: 7; right: 0; bottom: calc(env(safe-area-inset-bottom) + 48px); left: 0; margin: 0; text-align: center; color: rgba(255, 242, 207, .56); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 10px; letter-spacing: .15em; pointer-events: none; animation: hint 2.4s ease-in-out infinite; }

.wish-lantern { position: absolute; z-index: 2; bottom: -50px; width: 22px; height: 31px; border-radius: 5px 5px 8px 8px; background: linear-gradient(90deg, #d47a43, #ffd288 50%, #d47a43); border: 1px solid rgba(255, 220, 140, .8); box-shadow: 0 0 18px rgba(255, 175, 72, .7); pointer-events: none; animation: lanternRise var(--rise-time, 8s) ease-in forwards; }
.wish-lantern::after { content: ""; position: absolute; left: 4px; right: 4px; bottom: -4px; height: 5px; border-radius: 50%; background: #f9ae4d; box-shadow: 0 0 10px #ffc46b; }

.opening {
  position: absolute;
  z-index: 25;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px 28px calc(env(safe-area-inset-bottom) + 42px);
  text-align: center;
  background:
    radial-gradient(circle at 50% 27%, rgba(242, 209, 133, .16), transparent 24%),
    linear-gradient(180deg, rgba(4, 20, 41, .08), rgba(3, 12, 25, .42) 60%, rgba(3, 10, 23, .87));
  transition: opacity 1s, visibility 1s, transform 1s;
}
.opening.is-gone { opacity: 0; visibility: hidden; transform: scale(1.03); pointer-events: none; }
.opening-date { margin: 0 0 22px; color: rgba(255, 231, 174, .62); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 10px; letter-spacing: .28em; }
.opening-seal { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 16px; border: 1px solid rgba(239, 197, 107, .72); color: #f6d68c; font-size: 23px; transform: rotate(45deg); }
.opening-seal::first-line { transform: rotate(-45deg); }
.opening h2 { margin: 0; color: #fff2cc; font-size: clamp(44px, 13vw, 62px); font-weight: 500; letter-spacing: .18em; text-indent: .18em; text-shadow: 0 4px 28px rgba(0,0,0,.5); }
.opening .start-button { margin-top: 32px; }
.start-button { min-width: 172px; height: 49px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 10px 0 24px; border: 1px solid rgba(255, 225, 159, .48); border-radius: 999px; background: linear-gradient(135deg, rgba(47, 111, 103, .83), rgba(23, 77, 78, .9)); box-shadow: 0 12px 40px rgba(0, 0, 0, .28), inset 0 1px rgba(255,255,255,.13); cursor: pointer; }
.start-button span { font-size: 14px; letter-spacing: .16em; }
.start-button i { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; background: var(--gold); color: #14343a; font-family: ui-sans-serif, system-ui, sans-serif; font-style: normal; }
.opening small { margin-top: 13px; color: rgba(255,255,255,.35); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 10px; letter-spacing: .12em; }
.credits-link { position: absolute; bottom: max(12px, env(safe-area-inset-bottom)); right: 14px; display: grid; place-items: center; width: 32px; height: 32px; color: #8795aa; text-decoration: none; font: 16px ui-sans-serif, system-ui, sans-serif; }

.finale {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 28px;
  text-align: center;
  background: linear-gradient(180deg, rgba(5, 25, 45, .66), rgba(3, 13, 27, .85));
  backdrop-filter: blur(6px);
  animation: finaleIn 1.2s ease both;
}
.finale-moon { color: #f6d68c; font-size: 38px; line-height: 1; transform: rotate(-18deg); filter: drop-shadow(0 0 16px rgba(255,221,145,.65)); }
.finale > p:first-of-type { margin: 17px 0 9px; color: #d9bd7d; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 10px; letter-spacing: .3em; }
.finale h2 { margin: 0; color: #fff3d0; font-size: clamp(31px, 9vw, 44px); font-weight: 500; letter-spacing: .08em; }
.finale-rule { display: flex; align-items: center; gap: 10px; margin: 22px 0 17px; color: #d6b66b; }
.finale-rule i { display: block; width: 48px; height: 1px; background: currentColor; opacity: .45; }
.finale-rule b { font-size: 9px; font-weight: 400; }
.finale-wish { margin: 0; color: rgba(255, 248, 226, .78); font-size: 15px; letter-spacing: .14em; line-height: 2; }
.finale button { margin-top: 30px; padding: 9px 17px; border: 1px solid rgba(255, 226, 164, .35); border-radius: 999px; background: rgba(255,255,255,.06); color: rgba(255, 245, 217, .72); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 11px; letter-spacing: .12em; cursor: pointer; }

.petals { position: absolute; z-index: 7; inset: 0; overflow: hidden; pointer-events: none; }
.petals i { position: absolute; top: -14px; left: var(--x); width: 6px; height: 8px; border-radius: 70% 10% 70% 10%; background: #e7bf61; box-shadow: 0 0 5px rgba(255, 220, 129, .52); opacity: .8; animation: petalFall var(--dur) linear var(--delay) infinite; }

.grain { position: absolute; z-index: 30; inset: 0; pointer-events: none; opacity: .15; mix-blend-mode: soft-light; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E"); }
.is-hidden { display: none !important; }

@keyframes twinkle { to { opacity: .52; filter: brightness(1.35); } }
@keyframes halo { to { transform: scale(1.09); opacity: .78; } }
@keyframes branchSway { to { transform: rotate(2.5deg); } }
@keyframes cloudDrift { from { transform: translateX(-15%); } to { transform: translateX(75%); } }
@keyframes cloudDriftReverse { from { transform: translateX(30%); } to { transform: translateX(-90%); } }
@keyframes stepBob { 0% { transform: translateY(0) rotate(-.15deg); } 50% { transform: translateY(-3px); } 100% { transform: translateY(0) rotate(.15deg); } }
@keyframes breathe { from { transform: scale(1); } to { transform: scale(1.006); } }
@keyframes lanternPulse { to { transform: translate(-50%, -50%) scale(1.12); opacity: .72; } }
@keyframes hint { 50% { opacity: .42; transform: translateY(-3px); } }
@keyframes petalFall { 0% { transform: translate3d(0,-4vh,0) rotate(0); } 100% { transform: translate3d(34px,105vh,0) rotate(560deg); } }
@keyframes lanternRise { 0% { transform: translate3d(0,0,0) scale(.8); opacity: 0; } 8% { opacity: .95; } 100% { transform: translate3d(var(--drift, 30px), -112vh, 0) scale(.48); opacity: 0; } }
@keyframes finaleIn { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 700px) {
  .story { height: min(920px, 96svh); border: 1px solid rgba(255,255,255,.08); border-radius: 32px; box-shadow: 0 34px 110px rgba(0,0,0,.62); }
}

@media (max-height: 700px) {
  .moon-wrap { top: 3.5%; width: 154px; }
  .story-copy { top: 27%; }
  .characters-stage { width: min(78%, calc(55svh * .666667)); bottom: 55px; }
}

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

/* Keep the photographic moon, final greeting and faces in separate clear zones. */
.moon-wrap { width: min(35%, 158px); top: 5.5%; }
.story-copy h1 { font-size: clamp(25px, 7vw, 34px); line-height: 1.4; letter-spacing: .1em; text-indent: .1em; }
.story-copy h1 span { display: block; }
.copy-line { font-size: clamp(12px, 3.3vw, 15px); letter-spacing: .06em; }
.finale { inset: calc(env(safe-area-inset-top) + 14px) 13px auto auto; padding: 0; background: none; backdrop-filter: none; }
.finale-moon, .finale-rule { display: none; }
.finale h2 { font-size: clamp(25px, 7vw, 36px); text-shadow: 0 2px 18px #07152c; }
.finale > p:first-of-type { margin-top: 16px; }
.finale-wish { margin-top: 10px; font-size: 13px; line-height: 1.8; }
.finale button { margin: 0; padding: 0; font-size: 16px; letter-spacing: 0; }
.start-button:disabled { opacity: .55; cursor: wait; }
@media (max-height: 700px) {
  .moon-wrap { top: 6%; width: 100px; }
  .story-copy { top: 23%; }
  .story-copy h1 { font-size: 24px; }
  .copy-line { font-size: 12px; }
}
