@font-face { font-family: "Fredoka"; src: url("/assets/fonts/fredoka.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("/assets/fonts/nunito.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }
@font-face { font-family: "Gaegu"; src: url("/assets/fonts/gaegu-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Gaegu"; src: url("/assets/fonts/gaegu-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --sky-top: #d6e9ff;
  --sky-mid: #eef0ff;
  --sky-bottom: #ffe2ee;
  --pink: #ffc2d6;
  --pink-soft: #ffe0eb;
  --pink-deep: #ec6f9b;
  --blue: #b9dcff;
  --blue-soft: #e1f0ff;
  --blue-deep: #4f8fe0;
  --cream: #fff7ee;
  --paper: #fffdf9;
  --ink: #4b3a55;
  --muted: #8d7d97;
  --gold: #f4c46a;
  --line: rgba(75, 58, 85, .12);
  --shadow: 0 6px 18px rgba(120, 90, 140, .16), 0 2px 4px rgba(120, 90, 140, .10);
  --radius: 16px;
  --zh: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "Heiti SC", sans-serif;
  --hand: "Gaegu", "Comic Sans MS", cursive;
  --round: "Fredoka", "Nunito", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--body);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-bottom) 100%) fixed;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }

#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

.page {
  position: relative; z-index: 1;
  max-width: 760px; margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* ---------- header ---------- */
.top { text-align: center; margin: 8px 0 22px; }
.for {
  font-family: var(--hand); font-weight: 700; font-size: 1.35rem; margin: 0;
  color: var(--pink-deep); transform: rotate(-2deg); display: inline-block;
}
.for, .sub { animation: rise .9s cubic-bezier(.2, .8, .2, 1) both; }
h1 {
  font-family: var(--round); font-weight: 600; letter-spacing: -.01em;
  font-size: clamp(2.2rem, 9vw, 3.4rem); line-height: 1; margin: 6px 0 8px;
  color: var(--ink);
  text-shadow: 0 3px 0 #fff, 0 6px 18px rgba(236, 111, 155, .25);
  animation: rise .9s .08s cubic-bezier(.2, .8, .2, 1) both;
}
.sub { margin: 0; color: var(--muted); font-weight: 600; font-size: .95rem; animation-delay: .16s; }
.zh-inline { font-family: var(--zh); letter-spacing: .08em; }

/* ---------- countdown ---------- */
.countdown {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  margin: 0 auto 20px; padding: 12px 18px; width: fit-content; max-width: 100%;
  background: rgba(255, 255, 255, .7); border-radius: 999px; box-shadow: var(--shadow);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.countdown[hidden] { display: none; }
.cd-label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.cd-time { font-family: var(--round); font-weight: 600; font-size: 1.3rem; font-variant-numeric: tabular-nums; }

/* ---------- grid ---------- */
.grid {
  --cols: 4; --gap: 10px;
  display: grid; grid-template-columns: repeat(var(--cols), 1fr); grid-auto-flow: row dense; gap: var(--gap);
  grid-auto-rows: calc((min(100vw, 760px) - 32px - (var(--cols) - 1) * var(--gap)) / var(--cols));
}
.door.wide { grid-column: span 2; }
.door.big { grid-column: span 2; grid-row: span 2; }
@media (min-width: 620px) {
  .grid { --cols: 6; --gap: 12px; }
  .door.wide-lg { grid-column: span 2; }
}

.door {
  position: relative; display: block; padding: 0; border: 0; background: none; cursor: pointer;
  perspective: 700px; border-radius: var(--radius);
  animation: pop .55s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: calc(var(--i) * 28ms + .2s);
  outline-offset: 3px;
}
.door:focus-visible { outline: 3px solid var(--blue-deep); }
.slot {
  position: absolute; inset: 0; border-radius: var(--radius);
  background: radial-gradient(circle at 50% 45%, #fff 0%, #fff4d6 45%, #ffd9a8 100%);
  box-shadow: inset 0 3px 10px rgba(120, 80, 60, .25);
  display: grid; place-items: center; overflow: hidden;
}
.slot .glow { font-size: 1.4rem; color: var(--gold); filter: drop-shadow(0 0 6px rgba(244, 196, 106, .9)); opacity: .9; }
.leaf {
  position: absolute; inset: 0; border-radius: var(--radius);
  transform-origin: 0% 50%; transform-style: preserve-3d;
  transition: transform .75s cubic-bezier(.35, 1.25, .45, 1), box-shadow .3s;
  box-shadow: var(--shadow);
  display: grid; place-items: center;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.leaf::before { /* soft polka dots */
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .55) 1.6px, transparent 1.8px);
  background-size: 14px 14px; opacity: .7;
}
.leaf::after { /* inner frame */
  content: ""; position: absolute; inset: 5px; border-radius: calc(var(--radius) - 5px);
  border: 1.5px dashed rgba(255, 255, 255, .85);
}
.c-pink .leaf { background: linear-gradient(160deg, #ffd3e2, var(--pink)); }
.c-blue .leaf { background: linear-gradient(160deg, #d3e9ff, var(--blue)); }
.c-cream .leaf { background: linear-gradient(160deg, #fffaf3, #ffe9d4); }
.c-lilac .leaf { background: linear-gradient(160deg, #efe4ff, #dccbff); }
.num {
  position: relative; z-index: 1; font-family: var(--round); font-weight: 600;
  font-size: clamp(1.35rem, 6vw, 2rem); color: #fff;
  text-shadow: 0 2px 0 rgba(75, 58, 85, .22);
}
.c-cream .num { color: var(--pink-deep); text-shadow: 0 2px 0 rgba(255, 255, 255, .9); }
.door.big .num { font-size: clamp(2.6rem, 12vw, 4rem); }
.knob {
  position: absolute; right: 9px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 1px 0 rgba(0, 0, 0, .15); z-index: 1;
}
.lock {
  position: absolute; top: 7px; right: 7px; width: 15px; height: 15px; z-index: 1; opacity: .75;
  color: rgba(75, 58, 85, .55);
}
.door:not(.is-locked) .lock { display: none; }

.door.is-locked .leaf { filter: saturate(.75); }
.door.is-today:not(.is-opened) .leaf { animation: today 2.4s ease-in-out infinite; }
.door.is-today:not(.is-opened)::after {
  content: "today"; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%);
  font-family: var(--hand); font-weight: 700; font-size: .95rem; color: var(--pink-deep);
  background: #fff; padding: 0 7px; border-radius: 999px; box-shadow: var(--shadow); z-index: 2;
  white-space: nowrap;
}
.door.swing .leaf { transform: rotateY(-108deg); box-shadow: 0 0 0 rgba(0, 0, 0, 0); }
.door.is-opened .leaf { transform: rotateY(-42deg); }
.door.is-opened:hover .leaf { transform: rotateY(-55deg); }
.door.wiggle .leaf { animation: wiggle .45s ease; }
.door:not(.is-locked):not(.is-opened):hover .leaf { transform: rotateY(-12deg); }

/* ---------- bubble ---------- */
.bubble {
  position: fixed; z-index: 30; left: 50%; bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%); background: #fff; color: var(--ink);
  padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow);
  font-weight: 700; width: max-content; max-width: calc(100vw - 32px); text-align: center; animation: bubble 1.8s ease both;
}
.bubble[hidden] { display: none; }
.bubble .zh-inline { color: var(--pink-deep); }

.foot { text-align: center; font-family: var(--hand); font-size: 1.15rem; color: var(--muted); margin-top: 30px; }

/* ---------- overlay + card ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  padding: 16px; overflow-y: auto;
}
.overlay[hidden] { display: none; }
.backdrop {
  position: fixed; inset: 0; background: rgba(75, 58, 85, .35);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fade .35s ease both;
}
.card {
  position: relative; width: min(420px, 100%); margin: auto;
  background: var(--paper); border-radius: 22px;
  box-shadow: 0 24px 60px rgba(75, 58, 85, .35);
  padding: 30px 22px 26px; text-align: center;
  transform-origin: 50% 0%;
  animation: unfold .7s cubic-bezier(.2, 1.1, .3, 1) both;
}
.card::before { /* washi tape */
  content: ""; position: absolute; top: -11px; left: 50%; width: 92px; height: 24px; margin-left: -46px;
  background: repeating-linear-gradient(45deg, rgba(255, 194, 214, .85) 0 8px, rgba(255, 224, 235, .85) 8px 16px);
  transform: rotate(-3deg); border-radius: 3px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.close {
  position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: var(--pink-soft); cursor: pointer; font-size: 1.2rem; line-height: 1;
  display: grid; place-items: center; color: var(--pink-deep);
}
.closing .card { animation: fold .3s ease-in both; }
.closing .backdrop { animation: fade .3s ease reverse both; }

.date { font-family: var(--hand); font-weight: 700; color: var(--pink-deep); font-size: 1.1rem; margin: 0 0 6px; }
.word { margin-bottom: 18px; }
.zh {
  font-family: var(--zh); font-weight: 600; font-size: clamp(2.6rem, 13vw, 3.6rem); line-height: 1.15;
  letter-spacing: .06em; color: var(--ink); margin: 0;
  animation: rise .6s .25s cubic-bezier(.2, .8, .2, 1) both;
}
.zh.long { font-size: clamp(1.8rem, 9vw, 2.6rem); }
.py { font-family: var(--round); font-weight: 500; font-size: 1.15rem; color: var(--blue-deep); margin: 4px 0 2px; animation: rise .6s .35s both; }
.en { font-family: var(--hand); font-size: 1.3rem; color: var(--muted); margin: 0; animation: rise .6s .45s both; }
.say {
  margin-top: 12px; display: inline-flex; align-items: center; gap: 8px;
  border: 0; cursor: pointer; padding: 9px 16px 9px 12px; border-radius: 999px;
  background: linear-gradient(160deg, #d3e9ff, var(--blue)); color: #24538f; font-weight: 800; font-size: .95rem;
  box-shadow: 0 3px 0 #8fc0f2; transition: transform .1s; animation: rise .6s .55s both;
}
.say:active { transform: translateY(2px); box-shadow: 0 1px 0 #8fc0f2; }
.say svg { width: 22px; height: 22px; }
.say .wave { opacity: .25; transition: opacity .2s; }
.say.playing .wave { animation: wave 1s ease-in-out infinite; }
.say.playing .wave.w2 { animation-delay: .2s; }

.divider { display: flex; align-items: center; gap: 10px; margin: 4px 0 18px; color: var(--pink); }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 2px dotted var(--pink); }

.body { animation: rise .6s .5s both; }
.label {
  display: inline-block; font-family: var(--hand); font-weight: 700; font-size: 1.05rem;
  color: #fff; background: var(--pink-deep); padding: 1px 12px 2px; border-radius: 999px;
  transform: rotate(-2deg); margin-bottom: 10px;
}
.text { font-size: 1.12rem; line-height: 1.55; margin: 0 0 10px; }
.text:last-child { margin-bottom: 0; }

/* certificate */
.cert {
  position: relative; background: #fffaf0; border: 3px double #e6c27d; border-radius: 10px;
  padding: 18px 14px 16px; box-shadow: inset 0 0 0 6px #fffaf0, inset 0 0 0 7px #f1dcae;
}
.cert h3 { font-family: var(--round); font-weight: 600; margin: 0 0 8px; font-size: 1.2rem; color: #b07d2a; letter-spacing: .02em; }
.cert .to { font-size: .85rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin: 0; }
.cert .name { font-family: var(--hand); font-weight: 700; font-size: 2.1rem; margin: 0 0 6px; }
.seal {
  position: absolute; right: -10px; bottom: -14px; width: 58px; height: 58px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff9fbf, var(--pink-deep)); color: #fff;
  font-family: var(--zh); font-weight: 700; font-size: 1.5rem; display: grid; place-items: center;
  box-shadow: 0 4px 10px rgba(236, 111, 155, .45); transform: rotate(12deg);
  animation: stamp .5s 1s cubic-bezier(.2, 1.6, .4, 1) both;
}
.sign {
  margin: 14px auto 0; display: block; width: 85%; border: 0; border-bottom: 2px solid var(--ink);
  background: none; cursor: pointer; padding: 4px 0 2px; min-height: 46px;
  font-family: var(--hand); font-size: 1.05rem; color: var(--muted);
}
.sign .ink { font-weight: 700; font-size: 1.7rem; color: var(--blue-deep); display: inline-block; clip-path: inset(0 100% 0 0); animation: write 1.1s ease forwards; }
.sign-caption { font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* meter */
.meter { width: 100%; max-width: 280px; display: block; margin: 0 auto; cursor: pointer; border: 0; background: none; padding: 0; }
.meter svg { width: 100%; height: auto; overflow: visible; }
.needle { transform-origin: 140px 140px; transform: rotate(-62deg); transition: transform 1.2s cubic-bezier(.3, 1.6, .5, 1); }
.meter.flipped .needle { transform: rotate(62deg); }
.meter-labels { display: flex; justify-content: space-between; font-family: var(--hand); font-weight: 700; font-size: 1.2rem; margin-top: -4px; }
.meter-labels .a { color: #d9534f; }
.meter-labels .b { color: var(--pink-deep); opacity: .35; transition: opacity .6s .6s; }
.meter.flipped + .meter-labels .b { opacity: 1; }
.meter.flipped + .meter-labels .a { opacity: .35; }

/* tickets & vouchers */
.ticket {
  display: flex; text-align: left; border-radius: 14px; overflow: hidden; filter: drop-shadow(0 4px 10px rgba(120, 90, 140, .18));
  -webkit-mask: radial-gradient(circle 11px at 72% 0, transparent 98%, #000) top / 100% 51% no-repeat,
                radial-gradient(circle 11px at 72% 100%, transparent 98%, #000) bottom / 100% 51% no-repeat;
          mask: radial-gradient(circle 11px at 72% 0, transparent 98%, #000) top / 100% 51% no-repeat,
                radial-gradient(circle 11px at 72% 100%, transparent 98%, #000) bottom / 100% 51% no-repeat;
  animation: slide .7s .6s cubic-bezier(.2, 1.2, .3, 1) both;
}
.ticket .main { flex: 0 0 72%; padding: 16px 14px 14px 16px; background: linear-gradient(160deg, #ffd3e2, var(--pink)); }
.ticket .stub {
  flex: 1; background: linear-gradient(160deg, #d3e9ff, var(--blue)); border-left: 2px dashed rgba(255, 255, 255, .9);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px 4px;
  font-family: var(--round); font-weight: 600; color: #24538f; text-align: center; font-size: .78rem; line-height: 1.1;
}
.ticket .stub b { font-size: 1.5rem; }
.ticket.voucher .main { background: linear-gradient(160deg, #fffaf3, #ffe2c4); }
.ticket.voucher .stub { background: linear-gradient(160deg, #ffd3e2, var(--pink)); color: #9b2f57; }
.ticket h3 { font-family: var(--round); font-weight: 600; letter-spacing: .12em; margin: 0 0 6px; font-size: 1.05rem; text-transform: uppercase; }
.ticket p { margin: 0; line-height: 1.4; font-weight: 600; word-break: keep-all; }
.ticket .fine { margin-top: 8px; font-size: .72rem; opacity: .7; text-transform: uppercase; letter-spacing: .08em; }
.barcode { height: 22px; width: 70%; margin-top: 4px; background: repeating-linear-gradient(90deg, #24538f 0 2px, transparent 2px 4px, #24538f 4px 5px, transparent 5px 8px); opacity: .55; }

/* reviews */
.review-title { font-family: var(--round); font-weight: 600; font-size: 1.05rem; margin: 0 0 12px; }
.review { text-align: left; background: var(--blue-soft); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; animation: slide .6s both; }
.review:nth-child(3) { background: var(--pink-soft); }
.review .t { font-weight: 800; margin: 0; }
.stars { color: var(--gold); font-size: 1.25rem; letter-spacing: 2px; }
.stars span { display: inline-block; animation: stamp .35s cubic-bezier(.2, 1.6, .4, 1) both; }
.stars .off { color: rgba(75, 58, 85, .22); }
.review .q { font-family: var(--hand); font-size: 1.2rem; margin: 2px 0 0; }

/* gift */
.gift-box { position: relative; padding-top: 6px; }
.gift-note { font-family: var(--hand); font-weight: 700; font-size: 1.35rem; margin: 0 0 12px; }
.code-wrap {
  background: repeating-linear-gradient(-45deg, #fff 0 10px, #fff6fa 10px 20px);
  border: 2px dashed var(--pink-deep); border-radius: 14px; padding: 14px 10px;
  animation: stamp .6s .7s cubic-bezier(.2, 1.4, .4, 1) both;
}
.code-store { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 800; margin: 0 0 4px; }
.code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: clamp(1rem, 5vw, 1.3rem); font-weight: 700;
  word-break: break-all; user-select: all; -webkit-user-select: all; margin: 0 0 10px; color: var(--ink);
}
.copy {
  border: 0; cursor: pointer; border-radius: 999px; padding: 9px 18px; font-weight: 800;
  background: var(--pink-deep); color: #fff; box-shadow: 0 3px 0 #c34f7a;
}
.copy:active { transform: translateY(2px); box-shadow: 0 1px 0 #c34f7a; }
.soon { font-family: var(--hand); font-size: 1.2rem; color: var(--muted); margin: 0; }
.confetti { position: fixed; top: 38%; left: 50%; width: 9px; height: 13px; border-radius: 2px; z-index: 40; pointer-events: none; animation: confetti 1.6s cubic-bezier(.15, .7, .4, 1) forwards; }

/* song */
.listen {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; text-decoration: none;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 800;
}
.listen small { opacity: .75; font-weight: 600; }

/* final */
.card.kind-final { background: linear-gradient(180deg, #fffdf9, #fff4f8); }
.final p { font-family: var(--hand); font-size: 1.45rem; line-height: 1.45; margin: 0 0 14px; opacity: 0; animation: rise 1.1s cubic-bezier(.2, .8, .2, 1) forwards; }
.final .sig { font-weight: 700; color: var(--pink-deep); font-size: 1.7rem; text-align: right; margin-right: 8px; }
.sparkle { position: absolute; color: var(--pink); pointer-events: none; animation: float 4s ease-in-out infinite; font-size: 1rem; }

/* ---------- keyframes ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.6) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes unfold { 0% { opacity: 0; transform: perspective(900px) rotateX(-75deg) translateY(30px) scale(.9); } 60% { opacity: 1; } 100% { transform: perspective(900px) rotateX(0) translateY(0) scale(1); } }
@keyframes fold { to { opacity: 0; transform: perspective(900px) rotateX(25deg) translateY(20px) scale(.92); } }
@keyframes today { 0%, 100% { box-shadow: var(--shadow), 0 0 0 0 rgba(236, 111, 155, .0); } 50% { box-shadow: var(--shadow), 0 0 0 6px rgba(236, 111, 155, .28); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-6deg); } 40% { transform: rotate(5deg); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(2deg); } }
@keyframes bubble { 0% { opacity: 0; transform: translate(-50%, 12px) scale(.9); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1); } 82% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, 6px); } }
@keyframes wave { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes stamp { from { opacity: 0; transform: scale(1.8) rotate(-8deg); } to { opacity: 1; } }
@keyframes write { to { clip-path: inset(0 0 0 0); } }
@keyframes slide { from { opacity: 0; transform: translateX(-16px) rotate(-1deg); } to { opacity: 1; transform: none; } }
@keyframes confetti { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
@keyframes float { 0%, 100% { transform: translateY(0) scale(1); opacity: .5; } 50% { transform: translateY(-12px) scale(1.15); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
  .final p { opacity: 1; }
}
