@font-face {
  font-family: "Pacifico";
  src: url("../fonts/pacifico.woff2") format("woff2");
  font-display: swap;
}

:root {
  --plum: #4b2c4a;
  --plum-soft: rgba(75, 44, 74, 0.74);
  --coral: #f2668b;
  --coral-deep: #d94b74;
  --peach: #ffc7a1;
  --cream: #fffaf4;
  --white-glass: rgba(255, 255, 255, 0.55);
  --script: "Pacifico", "Snell Roundhand", cursive;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --hand: "Kaiti SC", "STKaiti", "KaiTi", "PingFang SC", "Noto Sans SC", sans-serif;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  /* 动效统一用这几条曲线：出场干脆，入场柔和，按钮松手时轻轻回弹 */
  --ease-out: cubic-bezier(0.22, 0.8, 0.24, 1);
  --ease-in: cubic-bezier(0.5, 0, 0.75, 0.2);
  --ease-soft: cubic-bezier(0.32, 0.72, 0, 1);
  --spring: cubic-bezier(0.3, 1.5, 0.5, 1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #2b1f33;
  color: var(--plum);
  font-family: var(--sans);
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

::selection {
  background: #ffd0dc;
  color: var(--plum);
}

#stage {
  min-height: 100%;
}

/* ---------- 天空 ---------- */

#app {
  position: relative;
  /* --app-h 由脚本按微信里真实的可视高度写入 */
  height: 100vh;
  height: 100dvh;
  height: var(--app-h, 100dvh);
  overflow: hidden;
  background: linear-gradient(180deg, #b9a7ee 0%, #d9b4e6 30%, #f7bfd3 58%, #ffd3bd 82%, #ffe2c4 100%);
}

.sky,
#stars,
.wash,
.clouds {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.sky-lit {
  z-index: 0;
  background: linear-gradient(180deg, #c7a9ef 0%, #f1b4da 32%, #ffc3c6 60%, #ffd6a8 86%, #ffe7b8 100%);
  opacity: 0;
  transition: opacity 1.6s ease;
}

body.is-lit .sky-lit { opacity: 1; }

#stars { z-index: 0; }

.moon {
  position: absolute;
  z-index: 0;
  top: calc(64px + var(--safe-top));
  left: 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  box-shadow: 8px -4px 0 0 #fff6df;
  transform: rotate(-12deg);
  filter: drop-shadow(0 0 10px rgba(255, 246, 223, 0.8));
  opacity: 0.9;
}

.clouds { z-index: 0; overflow: hidden; }

.cloud {
  position: absolute;
  left: -140px;
  width: 110px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  filter: blur(0.4px);
  animation: drift var(--speed, 60s) linear infinite;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  bottom: 10px;
  border-radius: 50%;
  background: inherit;
}

.cloud::before { left: 18px; width: 44px; height: 44px; }
.cloud::after { left: 48px; width: 36px; height: 36px; }

.c1 { top: 18%; --speed: 68s; animation-delay: -12s; }
.c2 { top: 33%; --speed: 90s; animation-delay: -55s; transform: scale(0.7); opacity: 0.75; }
.c3 { top: 84%; --speed: 76s; animation-delay: -34s; transform: scale(1.15); opacity: 0.55; }

.hills {
  position: absolute;
  z-index: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 110px;
  pointer-events: none;
}

.wash {
  z-index: 0;
  background: radial-gradient(closest-side at 50% 52%, rgba(255, 238, 200, 0.85), rgba(255, 200, 170, 0.25) 50%, transparent 78%);
  opacity: 0;
  transition: opacity 1.4s ease;
}

body.is-lit .wash { opacity: 1; }

/* ---------- 场景 ---------- */

.scene {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    calc(60px + var(--safe-top))
    22px
    calc(26px + var(--safe-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(0, 28px, 0) scale(0.985);
  transition:
    opacity 0.38s ease,
    transform 0.5s var(--ease-out),
    visibility 0s linear 0.5s;
  -webkit-overflow-scrolling: touch;
}

/* 返回时，新页面从上方落下 */
#app[data-dir="back"] .scene:not(.active):not(.leaving) { transform: translate3d(0, -28px, 0) scale(0.985); }

/* 新页面等旧页面退一半再进来，两页不会叠成一团 */
.scene.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition:
    opacity 0.55s ease 0.16s,
    transform 0.75s var(--ease-out) 0.16s,
    visibility 0s;
}

.scene.leaving {
  visibility: visible;
  opacity: 0;
  transform: translate3d(0, -22px, 0) scale(0.97);
  transition:
    opacity 0.3s ease,
    transform 0.4s var(--ease-in),
    visibility 0s linear 0.4s;
}

#app[data-dir="back"] .scene.leaving { transform: translate3d(0, 22px, 0) scale(0.97); }

/* 页面里的内容一层一层浮上来 */
.scene > div > * {
  opacity: 0;
  translate: 0 14px;
  transition: opacity 0.3s ease, translate 0.3s ease;
}

.scene.active > div > * {
  opacity: 1;
  translate: none;
  transition:
    opacity 0.6s ease var(--d, 0.2s),
    translate 0.8s var(--ease-out) var(--d, 0.2s);
}

.scene.active > div > :nth-child(1) { --d: 0.18s; }
.scene.active > div > :nth-child(2) { --d: 0.25s; }
.scene.active > div > :nth-child(3) { --d: 0.32s; }
.scene.active > div > :nth-child(4) { --d: 0.39s; }
.scene.active > div > :nth-child(5) { --d: 0.46s; }
.scene.active > div > :nth-child(6) { --d: 0.53s; }
.scene.active > div > :nth-child(n + 7) { --d: 0.6s; }

/* 打开底部卡片时，后面的页面轻轻退远一点 */
#app .scene.active { transform-origin: 50% 40%; }
#app.sheet-on .scene.active {
  transform: scale(0.955);
  opacity: 0.75;
  transition: transform 0.5s var(--ease-soft), opacity 0.5s ease;
}

.scene::-webkit-scrollbar { width: 0; height: 0; }

.door-wrap,
.end-wrap {
  margin-block: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: min(100%, 400px);
}

.stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  width: min(100%, 400px);
  margin-block: auto;
}

.eyebrow {
  display: inline-block;
  margin: 0;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--white-glass);
  color: var(--coral-deep);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  box-shadow: 0 2px 10px rgba(180, 90, 140, 0.12);
}

h1,
h2 {
  margin: 0;
  color: var(--plum);
  font-weight: 600;
}

h1 {
  margin-top: 12px;
  font-size: 38px;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-indent: 0.08em;
}

h1.script {
  margin-top: 4px;
  padding: 0 0.15em 0.08em;
  font-family: var(--script);
  font-size: 66px;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0;
  text-indent: 0;
  background: linear-gradient(180deg, #ff8aa6 10%, #e9507b 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(255, 255, 255, 0.75)) drop-shadow(0 8px 18px rgba(217, 75, 116, 0.25));
}

h1.long {
  font-size: 30px;
  letter-spacing: 0.04em;
  text-indent: 0.04em;
}

h1.script.long { font-size: 48px; }

h2 {
  font-size: 27px;
  line-height: 1.35;
  letter-spacing: 0.06em;
  text-indent: 0.06em;
}

.lead {
  margin: 8px 0 0;
  max-width: 17em;
  color: var(--plum-soft);
  font-size: 16px;
  line-height: 1.75;
  white-space: pre-line;
}

/* ---------- 小灯 ---------- */

.lantern-btn {
  -webkit-touch-callout: none;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
}

.lantern {
  position: relative;
  width: 168px;
  aspect-ratio: 160 / 240;
  transform-origin: 50% 0;
  animation: sway 5s ease-in-out infinite;
}

.lantern-svg {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.lantern-bob {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

.lantern.hop .lantern-bob { animation: hop 0.6s cubic-bezier(0.3, 1.6, 0.5, 1); }

.lantern-glow {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 42%;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 244, 205, 0.95) 0%, rgba(255, 190, 160, 0.4) 40%, transparent 70%);
  opacity: 0;
  transition: opacity 1.1s ease;
}

body.is-lit .lantern-glow {
  opacity: 1;
  animation: breathe 4s ease-in-out infinite;
}

.body-dim {
  fill: url(#lanternDim);
  stroke: rgba(255, 255, 255, 0.7);
  stroke-width: 2;
}

.body-lit {
  fill: url(#lanternLit);
  opacity: 0;
  transition: opacity 1s ease;
}

body.is-lit .body-lit { opacity: 1; }

.ribs {
  fill: none;
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 1.4;
}

.shine { fill: rgba(255, 255, 255, 0.55); }

.face path {
  fill: none;
  stroke: var(--plum);
  stroke-width: 3.2;
  stroke-linecap: round;
}

.eyes-open ellipse,
.mouth-sleep { fill: var(--plum); }

.cheek {
  fill: #ff7d9a;
  opacity: 0.38;
  transition: opacity 0.8s ease;
}

body.is-lit .cheek { opacity: 0.6; }

.eyes-open,
.eyes-happy,
.mouth-smile { opacity: 0; }

body.is-lit .eyes-closed,
body.is-lit .mouth-sleep,
body.is-lit .zzz { opacity: 0; }

body.is-lit .eyes-open,
body.is-lit .mouth-smile { opacity: 1; }

body.is-lit .eyes-open {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 4.2s ease-in-out 1.2s infinite;
}

body.is-lit .lantern.happy .eyes-open { opacity: 0; }
body.is-lit .lantern.happy .eyes-happy { opacity: 1; }

.zzz text {
  fill: #fff;
  font-family: var(--script);
  font-size: 15px;
  opacity: 0;
  animation: zz 3s ease-in-out infinite;
}

.zzz text:nth-child(2) { font-size: 12px; animation-delay: 1s; }
.zzz text:nth-child(3) { font-size: 10px; animation-delay: 2s; }

.tassel { fill: url(#heartFill); }

.floor { fill: rgba(150, 70, 120, 0.12); }
body.is-lit .floor { fill: rgba(255, 170, 120, 0.3); }

.bubble {
  position: absolute;
  z-index: 3;
  left: 72%;
  top: 2%;
  margin: 0;
  padding: 8px 14px;
  border-radius: 18px 18px 18px 4px;
  background: #fff;
  color: var(--coral-deep);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(180, 80, 120, 0.2);
  opacity: 0;
  transform: scale(0.4) translateY(10px);
  transform-origin: 0 100%;
  pointer-events: none;
}

.bubble.show { animation: pop-bubble 1.9s ease forwards; }

.light-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 9px 20px;
  border-radius: 999px;
  background: #fff;
  color: var(--coral-deep);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  box-shadow: 0 4px 0 #f6c3d2, 0 10px 22px rgba(217, 75, 116, 0.2);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.finger {
  display: inline-block;
  font-size: 15px;
  letter-spacing: 0;
  animation: poke 1.4s ease-in-out infinite;
}

body.is-lit #scene-door .light-label { opacity: 0; transform: translateY(6px); }

#light-btn::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 40%;
  width: 140px;
  height: 140px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: ping 2.4s ease-out infinite;
  pointer-events: none;
}

body.is-lit #light-btn::after { display: none; }

.lantern-btn:active .lantern-svg { transform: scale(0.96); }

.pet-btn { margin-top: 0; }

.pet-hint {
  margin: 0 0 12px;
  color: var(--plum-soft);
  font-size: 13px;
  letter-spacing: 0.1em;
  min-height: 1.5em;
}

/* ---------- 心心 ---------- */

.count {
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
  color: var(--coral-deep);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

.motes {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  justify-content: center;
  gap: 12px 20px;
  margin-top: 4px;
}

.mote {
  position: relative;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
}

.mote svg {
  width: 56px;
  height: 52px;
  overflow: visible;
  filter: drop-shadow(0 4px 8px rgba(217, 75, 116, 0.18));
  transition: transform 0.25s ease;
}

.mote use {
  fill: rgba(255, 255, 255, 0.5);
  stroke: #fff;
  stroke-width: 1.6;
  transition: fill 0.4s ease;
}

.mote:not([aria-pressed="true"]) svg {
  animation: heartbeat 2.4s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

.mote[aria-pressed="true"] use { fill: url(#heartFill); }

.mote[aria-pressed="true"] svg {
  filter: drop-shadow(0 0 10px rgba(255, 140, 160, 0.7));
}

.mote.pop svg { animation: heart-pop 0.5s cubic-bezier(0.3, 1.8, 0.5, 1); }

.mote:active svg { transform: scale(0.88); }

.card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100px;
  margin-top: 6px;
  padding: 18px 20px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--plum);
  font-size: 17px;
  line-height: 1.7;
  white-space: pre-line;
  box-shadow: 0 10px 30px rgba(170, 80, 130, 0.15);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.card.is-empty { color: rgba(75, 44, 74, 0.55); font-size: 15px; }

.card.swap { animation: rise 0.55s var(--ease-out); }

/* ---------- 按钮 ---------- */

.btn {
  min-width: 170px;
  min-height: 50px;
  margin-top: 8px;
  padding: 12px 30px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff8fab 0%, #f2668b 100%);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  box-shadow: 0 5px 0 #d14d75, 0 12px 24px rgba(217, 75, 116, 0.3);
  transition: transform 0.45s var(--spring), box-shadow 0.45s var(--spring), filter 0.2s ease;
}

.btn:active {
  transform: translateY(4px) scale(0.98);
  box-shadow: 0 1px 0 #d14d75, 0 6px 14px rgba(217, 75, 116, 0.3);
  transition-duration: 0.08s;
}

.btn-text,
.pill,
.dex-btn {
  transition: transform 0.45s var(--spring), opacity 0.2s ease, background-color 0.3s ease;
}

.btn-text:active,
.pill:active,
.dex-btn:active {
  transform: scale(0.94);
  opacity: 0.75;
  transition-duration: 0.08s;
}

.glow-btn:not([hidden]) { animation: rise 0.5s ease, wiggle 2.6s ease-in-out 0.8s infinite; }

.btn-text {
  min-height: 44px;
  padding: 8px 12px;
  color: var(--plum-soft);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-decoration: underline;
  text-decoration-color: rgba(75, 44, 74, 0.3);
  text-underline-offset: 5px;
}

/* ---------- 信 ---------- */

.paper {
  position: relative;
  width: 100%;
  margin-top: 14px;
  padding: 30px 22px 22px;
  border-radius: 18px;
  background-color: var(--cream);
  background-image: radial-gradient(rgba(242, 102, 139, 0.12) 1px, transparent 1px);
  background-size: 14px 14px;
  color: #3d2a33;
  text-align: left;
  -webkit-user-select: text;
  user-select: text;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.8) inset,
    0 18px 40px rgba(150, 60, 110, 0.22);
}

.paper::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  width: 96px;
  height: 26px;
  background: repeating-linear-gradient(45deg, rgba(255, 170, 190, 0.75) 0 8px, rgba(255, 205, 215, 0.75) 8px 16px);
  transform: translateX(-50%) rotate(-3deg);
  box-shadow: 0 2px 4px rgba(150, 60, 110, 0.1);
}

.paper-kicker {
  margin: 0;
  color: var(--coral);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  text-align: center;
}

.salute {
  margin: 16px 0 10px;
  font-family: var(--hand);
  font-size: 21px;
}

.salute .latin {
  font-family: var(--script);
  font-size: 22px;
  color: var(--coral-deep);
}

.paper .para {
  margin: 0 0 0.9em;
  font-family: var(--hand);
  font-size: 17.5px;
  line-height: 1.95;
}

.ps {
  margin: 0 0 0.8em;
  color: #8a5a6a;
  font-family: var(--hand);
  font-size: 15.5px;
  line-height: 1.7;
}

.sign-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.sign {
  margin: 0;
  font-family: var(--hand);
  font-size: 16px;
}

.seal {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ff8aa5, #d94b74);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12), 0 3px 8px rgba(217, 75, 116, 0.35);
  transform: rotate(-10deg);
}

.seal svg { width: 22px; height: 20px; fill: #ffe3ea; }

#scene-letter .lead { margin-top: 0; }

/* ---------- 结尾 ---------- */

.note {
  margin: 12px 0 0;
  max-width: 17em;
  color: rgba(75, 44, 74, 0.58);
  font-size: 13.5px;
  line-height: 1.7;
  white-space: pre-line;
}

.date-line {
  margin: 14px 0 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--coral-deep);
  font-size: 13px;
  letter-spacing: 0.14em;
}

#scene-end .btn { margin-top: 18px; }

/* ---------- 顶部 ---------- */

.pill,
.dex-btn {
  position: absolute;
  z-index: 5;
  top: calc(12px + var(--safe-top));
}

.pill,
.dex-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 13px;
  border: 1.5px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
  color: var(--plum);
  font-size: 13px;
  letter-spacing: 0.1em;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.pill { right: 12px; }

.guest-btn { padding-right: 9px; }
.guest-btn svg { width: 14px; height: 14px; opacity: 0.7; }

.mode-pill {
  border-color: rgba(75, 44, 74, 0.1);
  background: rgba(75, 44, 74, 0.68);
  color: #fff;
}

.dex-btn {
  left: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--coral-deep);
  font-weight: 600;
}

.dex-btn.ping { animation: dex-ping 0.9s cubic-bezier(0.3, 1.6, 0.5, 1); }

.dex-btn.complete {
  border-color: #ffe08a;
  background: linear-gradient(180deg, #fff6d6, #ffd98a);
  color: #a0581f;
  box-shadow: 0 0 16px rgba(255, 214, 120, 0.8);
}



/* ---------- 小灯的小表情 ---------- */

.look { transition: transform 0.3s ease-out; }

.cheek {
  transform-box: fill-box;
  transform-origin: center;
}

.lantern.shy .cheek {
  opacity: 0.95 !important;
  transform: scale(1.45, 1.35);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

body.is-lit .lantern.shy .eyes-open { opacity: 0; }
body.is-lit .lantern.shy .eyes-happy { opacity: 1; }

.pet-btn.pressing .lantern-svg {
  transform: scale(0.93);
  transition: transform 0.7s ease;
}

.secret-left {
  margin: 14px 0 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
  color: var(--coral-deep);
  font-size: 12.5px;
  letter-spacing: 0.08em;
}

.name-tap { cursor: pointer; -webkit-user-select: none; user-select: none; }
.name-tap.nudge { animation: nudge 0.45s cubic-bezier(0.3, 1.8, 0.5, 1); }

.latin-inline {
  display: inline-block;
  padding: 0 0.08em;
  font-family: var(--script);
  font-weight: 400;
  color: var(--coral-deep);
  letter-spacing: 0;
}

/* ---------- 名字 ---------- */

.letters {
  display: grid;
  grid-template-columns: repeat(4, 74px);
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.letter-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 8px 20px rgba(170, 80, 130, 0.14);
  transition: background 0.4s ease, color 0.4s ease;
  animation: float 3.2s ease-in-out var(--delay, 0s) infinite;
}

.letter-ch {
  font-family: var(--script);
  font-size: 44px;
  line-height: 1.2;
  color: var(--coral-deep);
}

.letter-word {
  margin-top: 2px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--plum-soft);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.letter-tile[aria-pressed="true"] {
  background: linear-gradient(180deg, #ff9db4, #f2668b);
  box-shadow: 0 0 18px rgba(255, 140, 170, 0.6);
}

.letter-tile[aria-pressed="true"] .letter-ch,
.letter-tile[aria-pressed="true"] .letter-word { color: #fff; opacity: 1; }

.letter-tile.pop { animation: heart-pop 0.5s cubic-bezier(0.3, 1.8, 0.5, 1); }

.card-head {
  display: block;
  margin-bottom: 4px;
  color: var(--coral-deep);
  font-size: 14px;
  letter-spacing: 0.08em;
}

.card-head .latin {
  font-family: var(--script);
  font-weight: 400;
  font-size: 18px;
}

#name-card { flex-direction: column; }

.etym {
  width: 100%;
  margin-top: 4px;
  padding: 20px 20px 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 250, 244, 0.92), rgba(255, 238, 230, 0.88));
  color: #3d2a33;
  text-align: center;
  box-shadow: 0 14px 34px rgba(150, 60, 110, 0.2);
}

.etym-kicker {
  margin: 0 0 10px;
  color: var(--coral);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.24em;
}

.etym-p {
  margin: 0 0 12px;
  font-family: var(--hand);
  font-size: 16px;
  line-height: 1.85;
  white-space: pre-line;
}

.etym-big {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1.5px dashed rgba(242, 102, 139, 0.35);
  color: var(--coral-deep);
  font-family: var(--hand);
  font-size: 18.5px;
  font-weight: 600;
  line-height: 1.8;
  white-space: pre-line;
}

.etym.swap { animation: rise 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.1); }

/* ---------- 小灯的家 ---------- */

.pet-btn .lantern { width: 138px; }

#end-title { font-size: 26px; }
#end-title .latin-inline { font-size: 34px; }

#scene-end .lead { margin-top: 4px; font-size: 15px; }

.note-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  margin-top: 16px;
  padding: 16px 18px 14px;
  border-radius: 6px 22px 22px 22px;
  background:
    linear-gradient(90deg, transparent 0 22px, rgba(242, 102, 139, 0.25) 22px 23.5px, transparent 23.5px),
    #fffaf0;
  color: #3d2a33;
  text-align: left;
  box-shadow: 0 12px 28px rgba(150, 60, 110, 0.2);
  transform: rotate(-1deg);
}

.note-card { transition: scale 0.45s var(--spring); }
.note-card:active { scale: 0.97; transition-duration: 0.1s; }
.note-card.flip { animation: note-flip 0.6s var(--ease-soft); }

.note-head {
  padding-left: 16px;
  color: var(--coral-deep);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.note-text {
  padding-left: 16px;
  font-family: var(--hand);
  font-size: 17.5px;
  line-height: 1.75;
  white-space: pre-line;
}

.note-foot {
  padding-left: 16px;
  color: rgba(75, 44, 74, 0.5);
  font-size: 12px;
}

.note-foot:empty { display: none; }

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  margin-top: 16px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 74px;
  padding: 12px 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--plum);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  box-shadow: 0 6px 16px rgba(170, 80, 130, 0.12);
  transition: transform 0.5s var(--spring), background-color 0.3s ease, box-shadow 0.3s ease;
}

.tile:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 2px 8px rgba(170, 80, 130, 0.12);
  transition-duration: 0.1s;
}

.tile-icon { font-size: 18px; line-height: 1.2; color: var(--coral-deep); }

.tile small {
  color: var(--plum-soft);
  font-size: 12px;
  font-weight: 400;
}

#scene-end .note { margin-top: 16px; font-size: 12.5px; }

/* ---------- 作业本 ---------- */

.notebook {
  position: relative;
  width: 100%;
  margin-top: 8px;
  padding: 18px 20px 20px 44px;
  border-radius: 8px 18px 18px 8px;
  background:
    linear-gradient(90deg, transparent 0 32px, rgba(242, 102, 139, 0.45) 32px 33.5px, transparent 33.5px),
    repeating-linear-gradient(180deg, transparent 0 33px, rgba(120, 150, 220, 0.28) 33px 34px),
    #fffdf6;
  background-position: 0 0, 0 14px, 0 0;
  color: #2f2a44;
  text-align: left;
  box-shadow:
    -6px 0 0 #f6b9c9 inset,
    0 16px 36px rgba(120, 60, 110, 0.22);
}

.notebook.flip { animation: page-flip 0.6s ease; }
.notebook.shake { animation: shake 0.45s ease; }

.nb-tag {
  margin: 0;
  color: rgba(47, 42, 68, 0.5);
  font-size: 12px;
  line-height: 34px;
  letter-spacing: 0.1em;
}

.nb-title {
  margin: 0;
  font-family: var(--hand);
  font-size: 19px;
  font-weight: 600;
  line-height: 34px;
}

.nb-body {
  margin: 0;
  min-height: 136px;
  font-family: var(--hand);
  font-size: 17px;
  line-height: 34px;
  white-space: pre-line;
}

.stamp-mark {
  position: absolute;
  right: 14px;
  top: 12px;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 34px;
  pointer-events: none;
  transform: rotate(-14deg);
}

.stamp-mark.aplus {
  border: 3px solid #e2455f;
  color: #e2455f;
  font-family: var(--script);
  font-size: 26px;
  background: rgba(255, 255, 255, 0.4);
}

.stamp-mark.hit { animation: stamp-hit 0.45s cubic-bezier(0.3, 1.4, 0.5, 1); }

.class-reply {
  margin: 4px 0 0;
  min-height: 3.2em;
  color: var(--plum);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-line;
}

.class-reply.swap { animation: rise 0.4s ease; }

.stamps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}

.stamp-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  border-radius: 18px;
  background: #fff;
  color: var(--plum);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 4px 0 #f6c3d2, 0 10px 20px rgba(217, 75, 116, 0.15);
  transition: transform 0.45s var(--spring), box-shadow 0.45s var(--spring);
}

.stamp-btn span { font-size: 24px; line-height: 1.2; }
.stamp-btn .aplus { color: #e2455f; font-family: var(--script); font-size: 22px; }

.stamp-btn:active {
  transform: translateY(3px) scale(0.97);
  box-shadow: 0 1px 0 #f6c3d2, 0 6px 12px rgba(217, 75, 116, 0.15);
  transition-duration: 0.08s;
}

/* ---------- 天空 ---------- */

.moon.wobble { animation: wobble 0.6s ease; }

.shoot {
  position: absolute;
  z-index: 0;
  width: 90px;
  height: 3px;
  margin-top: -1.5px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95));
  opacity: 0;
  pointer-events: none;
  transform-origin: 100% 50%;
  translate: -90px 0;
}

.shoot::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px 4px rgba(255, 246, 200, 0.9);
}

.shoot.fly { animation: shoot 3.2s ease-in-out forwards; }

.float-heart {
  position: absolute;
  width: 26px;
  height: 24px;
  margin: -12px 0 0 -13px;
  animation: float-up 1.8s ease-out forwards;
}

.float-heart svg { width: 100%; height: 100%; fill: #ff7d97; filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.9)); }

/* ---------- 提示和底部卡片 ---------- */

.toast {
  position: absolute;
  z-index: 7;
  top: calc(56px + var(--safe-top));
  left: 50%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: min(calc(100% - 32px), 340px);
  padding: 12px 16px 13px;
  border: 1.5px solid #ffe08a;
  border-radius: 18px;
  background: linear-gradient(180deg, #fffaf0, #fff1d6);
  color: var(--plum);
  text-align: center;
  box-shadow: 0 0 0 4px rgba(255, 224, 138, 0.25), 0 14px 30px rgba(160, 80, 60, 0.25);
  transform: translateX(-50%);
  cursor: pointer;
  touch-action: none;
}

.toast.show { animation: toast-in 0.6s var(--ease-out) both; }
.toast.hide { animation: toast-out 0.32s var(--ease-in) both; }

.toast-kicker {
  color: #c27a2c;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
}

.toast-title { font-size: 16px; }

.toast-text {
  color: var(--plum-soft);
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-line;
}

.sheet {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: flex-end;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(60, 30, 60, 0.32);
  opacity: 0;
  transition: opacity 0.38s ease;
}

.sheet.open .sheet-backdrop { opacity: 1; }

.sheet-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 86%;
  padding: 10px 20px calc(10px + var(--safe-bottom));
  border-radius: 28px 28px 0 0;
  background: var(--cream);
  box-shadow: 0 -10px 40px rgba(80, 30, 70, 0.3);
  translate: 0 104%;
  transition: translate 0.4s var(--ease-in), transform 0.4s var(--ease-soft);
  will-change: transform;
}

.sheet.open .sheet-panel {
  translate: none;
  transition: translate 0.55s var(--ease-soft), transform 0.4s var(--ease-soft);
}

.sheet-panel.dragging { transition: none !important; }

/* 卡片里的内容在打开时晚一拍出现，换内容时淡入 */
.sheet-title,
.sheet-body,
.sheet-close {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sheet.open .sheet-title,
.sheet.open .sheet-body,
.sheet.open .sheet-close {
  opacity: 1;
  transition: opacity 0.45s ease 0.15s;
}

.sheet-panel.swap .sheet-title,
.sheet-panel.swap .sheet-body,
.wish.swap { animation: rise 0.5s var(--ease-out); }

.sheet-grip {
  align-self: center;
  width: 40px;
  height: 5px;
  margin-bottom: 10px;
  border-radius: 999px;
  background: rgba(75, 44, 74, 0.15);
  touch-action: none;
}

.sheet-title {
  margin: 0 0 10px;
  color: var(--coral-deep);
  font-size: 18px;
  text-align: center;
  letter-spacing: 0.12em;
}

.sheet-body {
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sheet-close { align-self: center; }

.dex-intro {
  margin: 0 0 12px;
  color: var(--plum-soft);
  font-size: 13.5px;
  line-height: 1.7;
  text-align: center;
  white-space: pre-line;
}

.dex-finale,
.finale {
  margin-bottom: 14px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff3d6, #ffe0ea);
  font-family: var(--hand);
  font-size: 16.5px;
  line-height: 1.85;
  text-align: center;
  white-space: pre-line;
}

.dex-finale p,
.finale p { margin: 0; }

.finale { background: none; padding-top: 0; }

.finale-heart {
  width: 54px;
  height: 50px;
  margin: 0 auto 8px;
  display: block;
  fill: url(#heartFill);
  animation: heartbeat 2.4s ease-in-out infinite;
}

.dex-sign {
  margin-top: 10px !important;
  text-align: right;
  font-family: var(--hand);
}

.dex-sign .latin,
.sign .latin {
  font-family: var(--script);
  font-size: 1.2em;
  color: var(--coral-deep);
}

.dex-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dex-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(75, 44, 74, 0.05);
  color: rgba(75, 44, 74, 0.55);
}

.dex-item.got {
  background: #fff;
  color: var(--plum);
  box-shadow: 0 3px 10px rgba(217, 75, 116, 0.1);
}

.dex-no {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(75, 44, 74, 0.08);
  font-size: 12px;
  font-weight: 600;
}

.dex-item.got .dex-no {
  background: linear-gradient(180deg, #ffe08a, #ffbf5c);
  color: #fff;
}

.dex-words {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-line;
}

.dex-words strong { font-size: 14.5px; }

.whisper-text,
.wish-lead,
.wish-done {
  margin: 4px 0 14px;
  font-family: var(--hand);
  font-size: 18px;
  line-height: 1.85;
  text-align: center;
  white-space: pre-line;
}

.wish {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wish-field {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #f6c3d2;
  border-radius: 16px;
  background: #fff;
  color: var(--plum);
  font: 16px/1.6 var(--hand);
  resize: none;
  outline: none;
}

.wish-field:focus { border-color: var(--coral); }

.wish-note {
  margin: 10px 0 0;
  color: rgba(75, 44, 74, 0.5);
  font-size: 12px;
}

.wish-list {
  width: 100%;
  margin: 0 0 6px;
  padding: 0;
  list-style: none;
}

.wish-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px dashed rgba(242, 102, 139, 0.3);
  font-family: var(--hand);
  font-size: 16px;
  line-height: 1.6;
}

.wish-list small {
  flex: none;
  color: rgba(75, 44, 74, 0.45);
  font-family: var(--sans);
  font-size: 12px;
}

@keyframes float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -5px; }
}

@keyframes nudge {
  0% { transform: scale(1); }
  40% { transform: scale(1.12) rotate(-3deg); }
  100% { transform: scale(1); }
}

@keyframes dex-ping {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@keyframes note-flip {
  0% { transform: rotate(-1deg); }
  45% { transform: rotate(-1deg) rotateX(80deg); opacity: 0.4; }
  100% { transform: rotate(-1deg); }
}

@keyframes page-flip {
  0% { transform: none; }
  45% { transform: perspective(800px) rotateY(-70deg); transform-origin: 0 50%; opacity: 0.4; }
  100% { transform: none; }
}

@keyframes shake {
  0%, 100% { transform: none; }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

@keyframes stamp-hit {
  0% { opacity: 0; transform: rotate(-14deg) scale(2.2); }
  70% { opacity: 1; transform: rotate(-14deg) scale(0.92); }
  100% { opacity: 1; transform: rotate(-14deg) scale(1); }
}

@keyframes wobble {
  0%, 100% { transform: rotate(-12deg); }
  30% { transform: rotate(-30deg) scale(1.15); }
  60% { transform: rotate(4deg) scale(1.05); }
}

@keyframes shoot {
  0% { opacity: 0; transform: rotate(var(--rot)) scaleX(0.3); translate: -90px 0; }
  10% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--rot)) scaleX(1); translate: calc(var(--dx) - 90px) var(--dy); }
}

@keyframes float-up {
  0% { opacity: 0; transform: translateY(0) scale(0.5); }
  20% { opacity: 1; transform: translateY(-10px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-110px) scale(0.9); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -22px) scale(0.94); }
  to { opacity: 1; transform: translateX(-50%); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(-50%); }
  to { opacity: 0; transform: translate(-50%, -18px) scale(0.96); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: none; }
}

/* ---------- 飘落和闪光 ---------- */

.petals,
.sparks {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.petals { z-index: 4; }
.sparks { z-index: 6; }

.petal {
  position: absolute;
  top: -30px;
  opacity: 0;
}

.petal.leaf {
  width: 11px;
  height: 15px;
  border-radius: 80% 10% 80% 10%;
}

.petal svg {
  display: block;
  width: var(--size, 18px);
  height: var(--size, 18px);
}

#app.burst .petal {
  animation: fall var(--dur, 5.4s) ease-in var(--delay, 0s) forwards;
}

.spark {
  position: absolute;
  width: var(--size, 10px);
  height: var(--size, 10px);
  margin: calc(var(--size, 10px) / -2) 0 0 calc(var(--size, 10px) / -2);
  background: var(--c, #fff);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: spark 0.75s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.spark.dot { border-radius: 50%; clip-path: none; }

.noscript {
  padding: 48px 24px;
  text-align: center;
}

/* ---------- 动画 ---------- */

@keyframes sway {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg); }
}

@keyframes hop {
  0% { transform: none; }
  30% { transform: translateY(-16px) scale(0.96, 1.05); }
  60% { transform: translateY(0) scale(1.06, 0.94); }
  100% { transform: none; }
}

@keyframes breathe {
  0%, 100% { opacity: 0.8; transform: translate(-50%, -50%) scale(0.95); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
}

@keyframes blink {
  0%, 90%, 100% { transform: scaleY(1); }
  94% { transform: scaleY(0.1); }
}

@keyframes zz {
  0% { opacity: 0; transform: translate(0, 6px); }
  30% { opacity: 0.95; }
  100% { opacity: 0; transform: translate(6px, -8px); }
}

@keyframes ping {
  0% { transform: translate(-50%, -50%) scale(0.85); opacity: 0.8; }
  70%, 100% { transform: translate(-50%, -50%) scale(1.25); opacity: 0; }
}

@keyframes poke {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes pop-bubble {
  0% { opacity: 0; transform: scale(0.4) translateY(10px); }
  14% { opacity: 1; transform: scale(1.08); }
  22% { transform: scale(1); }
  80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.9) translateY(-6px); }
}

@keyframes heartbeat {
  0%, 60%, 100% { transform: scale(1); }
  70% { transform: scale(1.1); }
  80% { transform: scale(0.98); }
  90% { transform: scale(1.06); }
}

@keyframes heart-pop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes wiggle {
  0%, 84%, 100% { transform: rotate(0); }
  88% { transform: rotate(-4deg); }
  92% { transform: rotate(4deg); }
  96% { transform: rotate(-2deg); }
}

@keyframes drift {
  from { translate: 0 0; }
  to { translate: 680px 0; }
}

@keyframes fall {
  0% { opacity: 0; transform: translate3d(0, -6vh, 0) rotate(0deg); }
  10% { opacity: 0.95; }
  100% { opacity: 0; transform: translate3d(var(--drift, 16px), 100vh, 0) rotate(var(--spin, 200deg)); }
}

@keyframes spark {
  0% { opacity: 1; transform: translate(0, 0) scale(0.4) rotate(0); }
  60% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx, 0), var(--dy, 0)) scale(1) rotate(90deg); }
}

@media (hover: hover) {
  .btn:hover { filter: brightness(1.05); }
  .mote:hover svg { transform: scale(1.06); }
}

@media (min-width: 900px) and (min-height: 700px) {
  body { background: radial-gradient(circle at 50% 30%, #4a3556, #221829); }

  #stage {
    min-height: 100vh;
    display: grid;
    place-items: center;
  }

  #app {
    width: 400px;
    height: min(844px, calc(100vh - 48px));
    border-radius: 40px;
    box-shadow:
      0 0 0 10px #1c1522,
      0 0 0 11px rgba(255, 255, 255, 0.1),
      0 40px 90px rgba(0, 0, 0, 0.55);
  }
}

@media (max-height: 700px) {
  .scene { padding-top: calc(54px + var(--safe-top)); }
  .stack { gap: 10px; }
  h1 { font-size: 32px; }
  h1.script { font-size: 54px; }
  .lantern { width: 132px; }
  .lead { font-size: 15px; }
  .motes { gap: 6px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .petal,
  .spark,
  .shoot,
  .cloud { display: none; }
}

/* ---------- 门口的暗号 ---------- */

.gate {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(40px + var(--safe-top)) 24px calc(18px + var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  transition: opacity 0.6s ease, transform 0.7s var(--ease-in), filter 0.6s ease;
}

.known .gate { display: none; }

.gate-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 340px);
  margin-block: auto;
  text-align: center;
}

.gate-wrap > * {
  opacity: 0;
  translate: 0 14px;
}

.gate.ready .gate-wrap > * {
  opacity: 1;
  translate: none;
  transition: opacity 0.7s ease var(--d, 0s), translate 0.9s var(--ease-out) var(--d, 0s);
}

.gate-wrap > :nth-child(2) { --d: 0.08s; }
.gate-wrap > :nth-child(3) { --d: 0.16s; }
.gate-wrap > :nth-child(4) { --d: 0.24s; }
.gate-wrap > :nth-child(5) { --d: 0.32s; }
.gate-wrap > :nth-child(6) { --d: 0.36s; }
.gate-wrap > :nth-child(7) { --d: 0.42s; }

.gate h1 { margin-top: 10px; font-size: clamp(28px, 4.6dvh, 36px); }
.gate .lead { margin-top: 4px; font-size: 15px; line-height: 1.7; }

.gate-lantern {
  position: relative;
  margin-top: clamp(4px, 1.4dvh, 12px);
}

.gate .lantern { width: clamp(64px, 12dvh, 98px); }
.gate .lantern-glow { width: 190px; height: 190px; }

/* 暗号对了：小灯先睁一下眼 */
.gate .lantern .body-lit,
.gate .lantern .lantern-glow,
.gate .lantern .eyes-open,
.gate .lantern .mouth-smile,
.gate .lantern .eyes-closed,
.gate .lantern .zzz { transition: opacity 0.7s ease; }

.gate .lantern.peek .body-lit,
.gate .lantern.peek .lantern-glow,
.gate .lantern.peek .eyes-open,
.gate .lantern.peek .mouth-smile { opacity: 1; }

.gate .lantern.peek .eyes-closed,
.gate .lantern.peek .zzz { opacity: 0; }

.gate .lantern.peek .lantern-bob { animation: hop 0.6s var(--spring) 0.15s; }

.lantern.shake-head .lantern-bob { animation: head-shake 0.5s ease; }

.code-slots {
  display: flex;
  gap: 16px;
  margin-top: clamp(6px, 1.6dvh, 14px);
}

.slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 46px;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: inset 0 2px 6px rgba(150, 70, 120, 0.08);
  transition: background-color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

/* 每输一位，格子里冒出一颗小心 */
.slot::after {
  content: "";
  width: 18px;
  height: 17px;
  background: var(--coral);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'%3E%3Cpath d='M12 21.5C5 16.5 0 12.4 0 7 0 3.1 3 0 6.7 0 9 0 10.9 1.2 12 3 13.1 1.2 15 0 17.3 0 21 0 24 3.1 24 7c0 5.4-5 9.5-12 14.5z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'%3E%3Cpath d='M12 21.5C5 16.5 0 12.4 0 7 0 3.1 3 0 6.7 0 9 0 10.9 1.2 12 3 13.1 1.2 15 0 17.3 0 21 0 24 3.1 24 7c0 5.4-5 9.5-12 14.5z'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0;
  transform: scale(0.3);
  transition: opacity 0.2s ease, transform 0.35s var(--spring);
}

.slot.filled { background: rgba(255, 255, 255, 0.78); }
.slot.filled::after { opacity: 1; transform: none; }
.slot.pop { animation: slot-pop 0.36s var(--spring); }

.code-slots.miss { animation: shake 0.45s ease; }
.code-slots.miss .slot { border-color: rgba(242, 102, 139, 0.75); }

.code-slots.ok .slot {
  border-color: #ffe08a;
  background: linear-gradient(180deg, #fff7dc, #ffe7c2);
  box-shadow: 0 0 16px rgba(255, 214, 140, 0.8);
  animation: slot-glow 0.6s var(--spring) both;
}

.code-slots.ok .slot::after { background: linear-gradient(180deg, #ff8fab, #e9507b); }
.code-slots.ok .slot:nth-child(2) { animation-delay: 0.08s; }
.code-slots.ok .slot:nth-child(3) { animation-delay: 0.16s; }
.code-slots.ok .slot:nth-child(4) { animation-delay: 0.24s; }

.gate-hint {
  min-height: 1.6em;
  margin: 10px 0 0;
  color: var(--plum-soft);
  font-size: 13.5px;
  letter-spacing: 0.06em;
}

.gate-hint[data-tone="miss"] { color: var(--coral-deep); }
.gate-hint[data-tone="ok"] { color: var(--coral-deep); font-weight: 600; }
.gate-hint.swap { animation: rise 0.45s var(--ease-out); }

.keypad {
  --key: clamp(46px, 8.4dvh, 64px);
  display: grid;
  grid-template-columns: repeat(3, var(--key));
  grid-auto-rows: var(--key);
  justify-content: center;
  gap: clamp(8px, 1.5dvh, 14px) 24px;
  margin-top: clamp(8px, 2dvh, 18px);
}

.key {
  display: grid;
  place-items: center;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  color: var(--plum);
  font-size: calc(var(--key) * 0.4);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 6px 16px rgba(170, 80, 130, 0.12);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: transform 0.45s var(--spring), background-color 0.35s ease, box-shadow 0.35s ease;
}

.key:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.25), 0 2px 8px rgba(170, 80, 130, 0.12);
  transition-duration: 0.07s;
}

.key-del {
  border-color: transparent;
  background: none;
  box-shadow: none;
  color: var(--plum-soft);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.key-del svg { width: 26px; height: 26px; }

/* 进门：门口轻轻散开，后面的小灯接着出来 */
.gate.leaving {
  opacity: 0;
  transform: scale(1.06);
  filter: blur(6px);
  pointer-events: none;
}

@keyframes slot-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes slot-glow {
  0% { transform: scale(1); }
  45% { transform: scale(1.16) translateY(-4px); }
  100% { transform: scale(1); }
}

@keyframes head-shake {
  0%, 100% { transform: none; }
  20% { transform: rotate(-7deg); }
  45% { transform: rotate(6deg); }
  70% { transform: rotate(-3deg); }
}

/* 微信里的 iPhone SE / 小屏安卓，可视高度只有 560~620 */
@media (max-height: 620px) {
  .scene { padding-top: calc(50px + var(--safe-top)); padding-bottom: calc(18px + var(--safe-bottom)); }
  .stack { gap: 8px; }
  h2 { font-size: 22px; }
  .lantern { width: 112px; }
  .pet-btn .lantern { width: 112px; }
  .letter-tile { height: 86px; }
  .letter-ch { font-size: 38px; }
  .note-card { margin-top: 12px; padding: 12px 16px 10px; }
  .note-text { font-size: 16.5px; line-height: 1.65; }
  .tiles { margin-top: 12px; gap: 8px; }
  .tile { min-height: 64px; padding: 10px 12px; }
  .nb-body { min-height: 102px; }
  .toast { top: calc(50px + var(--safe-top)); }
}

@media (max-height: 660px) {
  .gate { padding-top: calc(30px + var(--safe-top)); }
  .gate .lead { line-height: 1.55; }
  .gate .lantern { width: clamp(52px, 9.5dvh, 70px); }
  .keypad { --key: clamp(44px, 7.6dvh, 54px); }
  .slot { width: 38px; height: 42px; }
  .gate-hint { margin-top: 6px; }
}

/* 很窄的安卓机 */
@media (max-width: 350px) {
  .letters { grid-template-columns: repeat(4, 64px); gap: 8px; }
  .letter-tile { height: 88px; border-radius: 18px; }
  .letter-ch { font-size: 36px; }
  .scene { padding-inline: 16px; }
}
