/* =========================================================
   中秋節快樂 — Mid-Autumn greeting
   Mobile-first. Dynamic viewport units + safe-area insets.
   ========================================================= */

:root {
  /* palette */
  --night-0: #04061a;       /* deepest sky */
  --night-1: #0b1238;       /* indigo */
  --night-2: #1d2566;       /* horizon blue */
  --dusk:    #3b2d63;       /* violet near the hills */
  --moon:    #fbeec8;       /* moonlight cream */
  --gold:    #efc167;       /* osmanthus gold */
  --gold-d:  #c98a2e;
  --red:     #c8252c;       /* lantern vermilion */
  --jade:    #dff1e8;
  --ink:     #3a2414;       /* letter ink */
  --text:    #f7efdd;
  --muted:   rgba(247, 239, 221, .72);

  /* type */
  --f-zh: "LXGW WenKai TC", "Kaiti TC", "BiauKai", "STKaiti", "KaiTi", "Songti TC", "Noto Serif CJK TC", "PMingLiU", serif;
  --f-en: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;

  /* safe areas (notch / home bar / landscape side insets) */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  /* scene geometry — svh = the smallest viewport, so the moon never gets clipped
     when the mobile address bar is showing */
  --topbar-h: 60px;
  --moon-size: min(60vw, 34vh, 340px);
  --moon-top: calc(var(--safe-t) + var(--topbar-h) + 8px);
  --bar-h: 64px;
}
@supports (height: 1svh) {
  :root { --moon-size: min(60vw, 34svh, 340px); }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--night-0);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;            /* removes double-tap-zoom delay on taps */
  overflow-x: hidden;                    /* fallback */
  overflow-x: clip;                      /* no horizontal scroll, without creating a scroll container */
  scroll-behavior: smooth;
  scroll-padding-top: var(--safe-t);
}
html.has-intro, html.sheet-open { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--f-zh);
  font-size: 17px;
  line-height: 1.7;
  overflow-x: hidden;
  overflow-x: clip;
  overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; touch-action: manipulation; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 6px; }

[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* =========================================================
   Backdrop (fixed). Uses lvh — the LARGEST viewport — so no
   gap appears at the bottom when the browser toolbar retracts.
   ========================================================= */
.backdrop {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 100vh;
  height: 100lvh;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% calc(var(--moon-top) + var(--moon-size) / 2), rgba(255, 222, 160, .20), rgba(255, 222, 160, 0) 55%),
    linear-gradient(180deg, var(--night-0) 0%, var(--night-1) 42%, var(--night-2) 78%, var(--dusk) 100%);
}
.sky-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* osmanthus branch, top-left */
.osmanthus {
  position: absolute;
  top: calc(var(--safe-t) - 6px);
  left: calc(var(--safe-l) - 10px);
  width: min(46vw, 250px);
  opacity: .95;
}
.osmanthus .branch { stroke: #03051a; stroke-width: 5; stroke-linecap: round; }
.osmanthus .branch.thin { stroke-width: 2.6; }
.osmanthus .leaves ellipse { fill: #050a22; }
.osmanthus .blossoms circle {
  fill: var(--gold);
  filter: drop-shadow(0 0 3px rgba(239, 193, 103, .9));
}

/* ---------- moon ---------- */
.moon-wrap {
  position: absolute;
  left: 50%;
  top: var(--moon-top);
  width: var(--moon-size);
  height: var(--moon-size);
  margin-left: calc(var(--moon-size) / -2);
  transform: translateY(28px) scale(.94);
  opacity: .35;
  transition: transform 2.6s cubic-bezier(.2, .7, .2, 1), opacity 2.6s ease;
}
.is-open .moon-wrap { transform: none; opacity: 1; }

.moon-halo {
  position: absolute;
  inset: -65%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 234, 180, .38) 0%, rgba(255, 214, 140, .14) 30%, rgba(255, 210, 140, 0) 62%);
  animation: halo 7s ease-in-out infinite alternate;
}
@keyframes halo {
  from { transform: scale(.96); opacity: .8; }
  to   { transform: scale(1.06); opacity: 1; }
}

.moon {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 36%, rgba(196, 150, 80, .30), rgba(196, 150, 80, 0) 9%),
    radial-gradient(circle at 64% 26%, rgba(196, 150, 80, .24), rgba(196, 150, 80, 0) 7%),
    radial-gradient(circle at 72% 66%, rgba(196, 150, 80, .22), rgba(196, 150, 80, 0) 11%),
    radial-gradient(circle at 42% 76%, rgba(196, 150, 80, .20), rgba(196, 150, 80, 0) 6%),
    radial-gradient(circle at 20% 60%, rgba(196, 150, 80, .16), rgba(196, 150, 80, 0) 8%),
    radial-gradient(circle at 38% 32%, #fffbf0 0%, #fcecc4 42%, #f1d08e 78%, #e0b066 100%);
  box-shadow:
    0 0 40px 8px rgba(255, 236, 190, .55),
    0 0 120px 30px rgba(255, 206, 120, .22),
    inset -14px -16px 40px rgba(176, 120, 48, .35),
    inset 10px 12px 30px rgba(255, 255, 255, .55);
}
/* The jade rabbit's shadow on the moon */
.moon-rabbit {
  position: absolute;
  width: 58%;
  left: 20%;
  top: 27%;
  color: rgba(168, 118, 52, .30);
  --rabbit-eye: transparent;
  --rabbit-ear: transparent;
  mix-blend-mode: multiply;
}

/* ---------- clouds ---------- */
.clouds { position: absolute; inset: 0; }
.cloud {
  position: absolute;
  left: 0;
  will-change: transform;
  animation: drift linear infinite;
}
.cloud-a { top: calc(var(--moon-top) + 2%);  width: min(52vw, 300px); animation-duration: 95s;  animation-delay: -30s; opacity: .7; }
.cloud-b { top: 58%;                         width: min(64vw, 380px); animation-duration: 130s; animation-delay: -95s; opacity: .45; }
.cloud-c { top: calc(var(--moon-top) + var(--moon-size) * .62); width: min(58vw, 330px); animation-duration: 80s; animation-delay: -52s; opacity: .8; }
@keyframes drift {
  from { transform: translate3d(-70vw, 0, 0); }
  to   { transform: translate3d(115vw, 0, 0); }
}

/* =========================================================
   Released sky lanterns
   ========================================================= */
.lantern-layer {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 100vh;
  height: 100lvh;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
  contain: strict;
}
.sky-lantern { position: absolute; will-change: transform, opacity; }
.sky-lantern svg { position: relative; display: block; width: 100%; height: auto; overflow: visible; }
.sl-sway { position: relative; animation: sway 3.2s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.sl-glow {
  position: absolute;
  inset: -55% -65%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 60%, rgba(255, 184, 84, .55), rgba(255, 150, 60, .18) 38%, rgba(255, 140, 50, 0) 66%);
  animation: flicker 1.6s ease-in-out infinite alternate;
}
.sl-glyph {
  font-family: var(--f-zh);
  font-weight: 700;
  font-size: 19px;
  fill: #7a2410;
  fill-opacity: .82;
  text-anchor: middle;
}
@keyframes sway    { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
@keyframes flicker { from { opacity: .75; } 45% { opacity: 1; } to { opacity: .85; } }

/* =========================================================
   Top bar
   ========================================================= */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) calc(14px + var(--safe-r)) 0 calc(14px + var(--safe-l));
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.seal {
  display: grid;
  place-items: center;
  width: 38px;
  padding: 4px 0;
  font-size: 15px;
  line-height: 1.15;
  font-weight: 700;
  color: #fff3dc;
  background: var(--red);
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px rgba(255, 230, 200, .35);
  transform: rotate(-4deg);
  opacity: .92;
}
.music-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px 0 12px;
  border: 1px solid rgba(239, 193, 103, .45);
  border-radius: 999px;
  background: rgba(8, 12, 40, .55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 14px;
  cursor: pointer;
}
.music-icon { width: 18px; height: 18px; color: var(--gold); }
.eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.eq i { width: 3px; height: 4px; border-radius: 1px; background: var(--gold); opacity: .5; }
.music-btn[aria-pressed="true"] { border-color: var(--gold); }
.music-btn[aria-pressed="true"] .eq i { opacity: 1; animation: eq 1s ease-in-out infinite alternate; }
.music-btn[aria-pressed="true"] .eq i:nth-child(2) { animation-delay: -.4s; }
.music-btn[aria-pressed="true"] .eq i:nth-child(3) { animation-delay: -.7s; }
@keyframes eq { from { height: 3px; } to { height: 14px; } }

/* =========================================================
   Content
   ========================================================= */
main { position: relative; z-index: 2; }

/* ---------- hero: fills the dynamic viewport exactly ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    calc(var(--moon-top) + var(--moon-size) + 18px)
    calc(20px + var(--safe-r))
    calc(var(--bar-h) + var(--safe-b) + 14px)
    calc(20px + var(--safe-l));
  text-align: center;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.hero-copy { position: relative; z-index: 2; }
.title {
  margin: 0;
  font-weight: 700;
  font-size: clamp(2.7rem, 13vw, 4.6rem);
  line-height: 1.1;
  letter-spacing: .08em;
  padding-left: .08em;               /* balance the trailing letter-spacing */
  background: linear-gradient(180deg, #fff8e2 8%, #f6d58a 52%, #d59538 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(255, 206, 120, .35));
}
.subtitle {
  margin: 10px 0 0;
  font-size: clamp(1.1rem, 5vw, 1.35rem);
  letter-spacing: .3em;
  padding-left: .3em;
  color: var(--moon);
}
.en-line {
  margin: 2px 0 0;
  font-family: var(--f-en);
  font-style: italic;
  font-size: clamp(1.05rem, 4.6vw, 1.3rem);
  color: var(--muted);
}
.hint {
  display: inline-flex;
  flex-direction: column;
  margin: 22px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(247, 239, 221, .78);
  transition: opacity .8s ease;
}
.hint span { font-family: var(--f-en); font-style: italic; font-size: 14px; color: rgba(247, 239, 221, .55); }
.hint.is-dim { opacity: .35; }

/* vertical line of Su Shi at the right edge */
.poem {
  position: absolute;
  z-index: 1;
  top: calc(var(--moon-top) + 6px);
  right: calc(12px + var(--safe-r));
  margin: 0;
  writing-mode: vertical-rl;
  font-size: 15px;
  letter-spacing: .35em;
  color: rgba(251, 238, 200, .55);
}
@media (max-width: 359px) { .poem { display: none; } }

/* hills + jade rabbit */
.hills {
  --hills-h: clamp(90px, 18vh, 170px);
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--hills-h);
  z-index: 1;
}
.hills-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.jade-rabbit {
  position: absolute;
  right: calc(15% - 34px);
  bottom: calc(var(--hills-h) * .5);
  width: 68px;
  padding: 0;
  border: 0;
  background: none;
  color: #eef7f2;
  cursor: pointer;
  filter: drop-shadow(0 0 10px rgba(223, 241, 232, .55));
}
.jade-rabbit svg { display: block; width: 100%; height: auto; }
.jade-rabbit.hop { animation: hop .7s cubic-bezier(.3, .7, .4, 1); }
@keyframes hop {
  0%   { transform: translateY(0) scaleY(1); }
  15%  { transform: translateY(0) scale(1.06, .9); }
  45%  { transform: translateY(-34px) rotate(-6deg); }
  75%  { transform: translateY(0) scale(1.05, .92); }
  100% { transform: none; }
}

.scroll-cue {
  position: relative;
  z-index: 2;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 14px 0;
  font-size: 13px;
  line-height: 1.2;
  text-decoration: none;
  color: rgba(247, 239, 221, .6);
}
.scroll-cue span { animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(4px); } }

/* ---------- lantern riddles ---------- */
.riddles {
  position: relative;
  padding: calc(var(--safe-t) + var(--topbar-h) - 8px) calc(16px + var(--safe-r)) 56px calc(16px + var(--safe-l));
  background: linear-gradient(180deg, #0a0e2e 0%, rgba(10, 14, 46, .88) 60%, rgba(10, 14, 46, .6) 100%);
}
.riddle-rope {
  height: 3px;
  margin: 0 -16px;
  background: linear-gradient(90deg, transparent, #8b1b20 12%, #b8302f 50%, #8b1b20 88%, transparent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.riddle-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-width: 520px;
  margin: 0 auto;
  align-items: start;
}
.riddle-lantern {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.rl-swing {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: 50% 0;
  animation: rl-sway 4.5s ease-in-out infinite alternate;
}
.riddle-lantern:nth-child(2) .rl-swing { animation-delay: -1.2s; animation-duration: 5.2s; }
.riddle-lantern:nth-child(3) .rl-swing { animation-delay: -2.6s; animation-duration: 4.8s; }
.riddle-lantern:nth-child(4) .rl-swing { animation-delay: -.6s;  animation-duration: 5.6s; }
@keyframes rl-sway { from { transform: rotate(-3.5deg); } to { transform: rotate(3.5deg); } }

.rl-string { width: 2px; height: 26px; background: #b8302f; }
.riddle-lantern:nth-child(2) .rl-string { height: 54px; }
.riddle-lantern:nth-child(3) .rl-string { height: 38px; }
.riddle-lantern:nth-child(4) .rl-string { height: 64px; }

.rl-body { position: relative; width: min(20vw, 96px); }
.rl-body svg { position: relative; display: block; width: 100%; height: auto; }
.rl-glow {
  position: absolute;
  inset: -20% -40% 10%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(255, 120, 70, .45), rgba(255, 90, 50, 0) 65%);
  transition: opacity .4s ease, transform .4s ease;
}
.rl-glyph {
  font-family: var(--f-zh);
  font-weight: 700;
  font-size: 34px;
  fill: #ffd98a;
  text-anchor: middle;
}
.rl-glyph.is-long { font-size: 24px; }
.riddle-lantern:active .rl-body { transform: scale(.96); }
.riddle-lantern.is-solved .rl-glow {
  background: radial-gradient(circle at 50% 45%, rgba(255, 214, 120, .7), rgba(255, 190, 90, 0) 66%);
  transform: scale(1.15);
}
.riddle-lantern.is-solved .rl-glyph { fill: #fff4cf; }

.riddles-copy { max-width: 520px; margin: 26px auto 0; text-align: center; }
.section-title {
  margin: 0;
  font-size: clamp(1.9rem, 8vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: .2em;
  padding-left: .2em;
  color: var(--moon);
}
.section-en { margin: 0; font-family: var(--f-en); font-style: italic; font-size: 1.1rem; color: var(--muted); }
.section-lead { margin: 14px 0 0; text-wrap: balance; color: rgba(247, 239, 221, .85); }
.section-lead span { font-family: var(--f-en); font-style: italic; color: var(--muted); }
.riddle-score { min-height: 1.7em; margin: 10px 0 0; font-size: 15px; color: var(--gold); }

/* ---------- greeting letter ---------- */
.greeting {
  padding: 56px calc(18px + var(--safe-r)) 24px calc(18px + var(--safe-l));
  background: rgba(10, 14, 46, .6);
}
.letter {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
  padding: 34px 26px 28px;
  color: var(--ink);
  border-radius: 6px;
  background:
    radial-gradient(circle at 85% 12%, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 40%),
    linear-gradient(175deg, #fbf3de 0%, #f3e3bd 100%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45), 0 0 60px rgba(255, 214, 140, .12);
}
.letter::before {                       /* inner vermilion rule, like a printed card */
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(200, 37, 44, .35);
  border-radius: 3px;
  pointer-events: none;
}
.letter-title { margin: 0 0 14px; font-size: 1.35rem; letter-spacing: .12em; color: #7c1d1f; }
.letter-zh { margin: 0 0 12px; text-wrap: pretty; font-size: 1.08rem; line-height: 1.95; }
.letter-en { margin: 16px 0 0; font-family: var(--f-en); font-size: 1.12rem; line-height: 1.55; color: #5a4430; }
.signature {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 24px;
  text-align: right;
}
.sig-zh { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: .12em; }
.sig-en { margin: 0; font-family: var(--f-en); font-style: italic; font-size: 1.05rem; color: #5a4430; }
.stamp {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  font-size: 28px;
  font-weight: 700;
  color: #fff1e0;
  background: #b21f26;
  border-radius: 5px;
  box-shadow: inset 0 0 0 3px rgba(255, 230, 210, .28);
  transform: rotate(-6deg);
}

.greeting .share-btn { display: flex; width: fit-content; max-width: 100%; margin: 26px auto 0; }

.footer {
  padding: 18px 16px calc(var(--bar-h) + var(--safe-b) + 36px);
  text-align: center;
  font-size: 14px;
  letter-spacing: .3em;
  color: rgba(247, 239, 221, .45);
  background: rgba(10, 14, 46, .6);
}
.footer p { margin: 0; }

/* =========================================================
   Buttons & action bar
   ========================================================= */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .08em;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: transform .15s ease, background-color .2s ease;
}
.btn:active { transform: scale(.96); }
.btn .sub { font-family: var(--f-en); font-style: italic; font-weight: 500; letter-spacing: 0; font-size: 15px; opacity: .8; }
.btn-primary {
  color: #3d1f06;
  background: linear-gradient(180deg, #ffe2a0 0%, #f0b95a 60%, #d9923a 100%);
  box-shadow: 0 6px 22px rgba(240, 175, 80, .35), inset 0 1px 0 rgba(255, 255, 255, .6);
}
.btn-ghost {
  color: var(--moon);
  background: rgba(8, 12, 40, .55);
  border-color: rgba(239, 193, 103, .45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.btn.wide { width: 100%; }

.actionbar {
  position: fixed;
  z-index: 5;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px calc(16px + var(--safe-r)) calc(10px + var(--safe-b)) calc(16px + var(--safe-l));
  background: linear-gradient(180deg, rgba(4, 6, 26, 0), rgba(4, 6, 26, .75) 55%);
  transition: transform .35s ease, opacity .35s ease;
}
.actionbar #releaseBtn { flex: 1 1 auto; max-width: 260px; }
.actionbar #releaseBtn svg { width: 22px; height: auto; flex: none; }
.actionbar #chooseBtn { flex: none; }
.count {
  position: absolute;
  top: -6px;
  right: 10px;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 12px;
  font-family: var(--f-en);
  font-size: 14px;
  font-weight: 600;
  line-height: 24px;
  letter-spacing: 0;
  color: #fff;
  background: var(--red);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}
.sheet-open .actionbar, .has-intro .actionbar { transform: translateY(110%); opacity: 0; }

/* =========================================================
   Toasts
   ========================================================= */
.wish-toast {
  position: fixed;
  z-index: 7;
  left: 50%;
  top: calc(var(--moon-top) + var(--moon-size) * .5);
  width: min(88vw, 420px);
  padding: 16px 20px 14px;
  text-align: center;
  border-radius: 16px;
  background: rgba(6, 9, 32, .72);
  border: 1px solid rgba(239, 193, 103, .4);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .4), 0 0 40px rgba(255, 190, 90, .15);
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .45s ease, transform .45s ease;
}
.wish-toast.show { opacity: 1; transform: translate(-50%, 0); }
.wish-zh {
  margin: 0;
  font-size: clamp(1.4rem, 7vw, 1.9rem);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: .08em;
  color: #ffe3a3;
}
.wish-en { margin: 4px 0 0; font-family: var(--f-en); font-style: italic; font-size: 1.05rem; line-height: 1.4; color: var(--muted); }

.mini-toast {
  position: fixed;
  z-index: 8;
  left: 50%;
  bottom: calc(var(--bar-h) + var(--safe-b) + 20px);
  max-width: 86vw;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 15px;
  text-align: center;
  background: rgba(6, 9, 32, .85);
  border: 1px solid rgba(239, 193, 103, .35);
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
.mini-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   Bottom sheets (<dialog>)
   ========================================================= */
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 22px 22px 0 0;
  color: var(--text);
  background: linear-gradient(180deg, #151c52 0%, #0b1036 100%);
  box-shadow: 0 -10px 50px rgba(0, 0, 0, .5);
  overflow: auto;
  overscroll-behavior: contain;
}
.sheet[open] { animation: sheet-up .38s cubic-bezier(.2, .8, .2, 1); }
.sheet::backdrop { background: rgba(2, 3, 16, .62); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet-inner {
  position: relative;
  padding: 26px calc(22px + var(--safe-r)) calc(22px + var(--safe-b)) calc(22px + var(--safe-l));
  border-top: 1px solid rgba(239, 193, 103, .35);
  border-radius: inherit;
}
.sheet-close {
  position: absolute;
  top: 10px;
  right: calc(10px + var(--safe-r));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .06);
  cursor: pointer;
}
.sheet-close svg { width: 20px; height: 20px; }

.riddle-kind { margin: 0; font-size: 15px; color: var(--gold); letter-spacing: .1em; }
.riddle-q {
  margin: 6px 44px 0 0;
  font-size: clamp(1.5rem, 7vw, 2rem);
  line-height: 1.45;
  letter-spacing: .06em;
  color: var(--moon);
}
.riddle-en { margin: 6px 0 0; font-family: var(--f-en); font-style: italic; font-size: 1.05rem; line-height: 1.45; color: var(--muted); }

.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; }
.choice {
  min-height: 64px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid rgba(239, 193, 103, .35);
  background: rgba(255, 255, 255, .04);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--moon);
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease, transform .15s ease;
}
.choice:active { transform: scale(.95); }
.choice.is-right { background: rgba(239, 193, 103, .25); border-color: var(--gold); color: #fff4cf; }
.choice.is-wrong { animation: shake .4s ease; opacity: .45; }
.choice:disabled { cursor: default; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.answer {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(239, 193, 103, .1);
  border: 1px solid rgba(239, 193, 103, .3);
}
.answer-char { margin: 0; font-size: 1.6rem; font-weight: 700; color: #ffe3a3; letter-spacing: .1em; }
.answer-why { margin: 6px 0 0; }
.answer-en { margin: 6px 0 0; font-family: var(--f-en); font-style: italic; font-size: 1.05rem; line-height: 1.45; color: var(--muted); }

.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet-actions .btn { flex: 1; }

.sheet-title { margin: 0 44px 0 0; font-size: 1.4rem; line-height: 1.4; color: var(--moon); letter-spacing: .06em; }
.sheet-en { margin: 2px 0 0; font-family: var(--f-en); font-style: italic; font-size: 1.05rem; color: var(--muted); }
.wish-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 14px; }
.wish-chip {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(239, 193, 103, .3);
  background: rgba(255, 255, 255, .04);
  text-align: left;
  cursor: pointer;
}
.wish-chip:active { background: rgba(239, 193, 103, .18); }
.wish-chip b { font-size: 1.1rem; line-height: 1.35; color: #ffe3a3; letter-spacing: .04em; }
.wish-chip small { font-family: var(--f-en); font-style: italic; font-size: .92rem; line-height: 1.3; color: var(--muted); }
.wish-chip.long { grid-column: 1 / -1; }

@media (min-width: 700px) {
  .sheet { margin: auto; border-radius: 22px; }
}

/* =========================================================
   Opening envelope
   ========================================================= */
.intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-t)) calc(24px + var(--safe-r)) calc(24px + var(--safe-b)) calc(24px + var(--safe-l));
  background: radial-gradient(circle at 50% 40%, rgba(22, 30, 86, .82), rgba(3, 4, 18, .95) 70%);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: opacity .9s ease, visibility .9s;
}
.intro.is-leaving { opacity: 0; visibility: hidden; }
.intro-card { max-width: 340px; text-align: center; }
.intro-moon {
  width: 92px;
  height: 92px;
  margin: 0 auto 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #fffbf0, #f6dca0 60%, #e2b066);
  box-shadow: 0 0 40px 10px rgba(255, 226, 160, .35);
}
.intro-from { margin: 0; font-size: 15px; letter-spacing: .3em; padding-left: .3em; color: var(--gold); }
.intro-title { margin: 8px 0 0; font-size: 1.7rem; line-height: 1.4; letter-spacing: .08em; color: var(--moon); }
.intro-en { margin: 6px 0 0; font-family: var(--f-en); font-style: italic; font-size: 1.1rem; color: var(--muted); }
.intro-open { margin-top: 28px; min-width: 220px; }
.intro-music {
  display: block;
  margin: 12px auto 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  background: none;
  font-size: 15px;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: rgba(239, 193, 103, .5);
  text-underline-offset: 4px;
  cursor: pointer;
}
.intro-music span { font-family: var(--f-en); font-style: italic; }

/* =========================================================
   Wider screens
   ========================================================= */
@media (min-width: 700px) {
  .poem { right: calc(50% - 300px); font-size: 17px; }
  .jade-rabbit { width: 84px; right: calc(22% - 42px); }
  .rl-body { width: 96px; }
}

/* Short landscape phones: keep the hero legible */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --moon-size: min(38vh, 200px); --topbar-h: 52px; }
  @supports (height: 1svh) { :root { --moon-size: min(38svh, 200px); } }
  .poem, .osmanthus { display: none; }
  .title { font-size: 2.6rem; }
  .subtitle { margin-top: 4px; }
  .hint { margin-top: 10px; }
  .cloud { width: min(34vw, 260px); }
}

/* =========================================================
   Reduced motion
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .moon-wrap { transition: none; }
  .cloud { animation: none; }
  .cloud-a { transform: translateX(8vw); }
  .cloud-b { transform: translateX(40vw); }
  .cloud-c { transform: translateX(50vw); }
}
