:root {
  --blue: #1aa3e8;
  --blue-dark: #0b7fc0;
  --red: #e8352e;
  --yellow: #f7c814;
  --pink: #ff6fa8;
  --pink-light: #ff9cc6;
  --mint: #2ec4b6;
  --ink: #1f2340;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

/* No double-tap zoom on mobile (pinch-zoom still works) */
html, body { touch-action: manipulation; }

/* Rapid tapping should not select text or open the long-press menu */
#intro, .hero, .stage, .cake, .balloon, #flyer, .controls, .pop-count {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Fredoka', system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #7fd0ff 0%, #bfe8ff 40%, #ffe3f1 100%) fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

main { position: relative; z-index: 5; padding: 0 16px 120px; }

/* ================= Intro door ================= */
#intro {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: radial-gradient(circle at 50% 65%, #d6f0ff 0%, #6cc4f5 70%, #3aa6e6 100%);
  cursor: pointer; text-align: center; padding: 16px;
  transition: opacity .9s ease, visibility .9s;
}
#intro.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.intro-top { font-size: clamp(1.1rem, 4.5vw, 1.6rem); margin: 0; color: #fff; text-shadow: 0 2px 0 var(--blue-dark); }
.intro-hint { margin: 0; font-size: 1.1rem; color: #fff; font-weight: 600; animation: pulse 1.6s ease-in-out infinite; }

.door-scene { perspective: 1100px; position: relative; }
.door-frame {
  position: relative;
  width: min(210px, 50vw); aspect-ratio: 1 / 2;
  border-radius: 10px 10px 0 0;
  box-shadow: 0 0 0 10px #d94f8a, 0 0 0 13px var(--ink);
  background: #fff;
  transform-style: preserve-3d;
}
.door-light {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 4rem;
  border-radius: 8px 8px 0 0;
  background: radial-gradient(circle, #fff 0%, #fff7c2 45%, #ffd36b 100%);
  box-shadow: inset 0 0 40px #ffcf40;
}
.door {
  position: absolute; inset: 0;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(160deg, #ff8cbc, #ff5c9d);
  border: 3px solid var(--ink);
  transform-origin: left center;
  transition: transform 1.4s cubic-bezier(.6, .05, .3, 1);
  animation: doorWiggle 2.4s ease-in-out infinite;
  backface-visibility: hidden;
}
.door .panel { position: absolute; left: 14%; right: 14%; border: 3px solid #d94f8a; border-radius: 6px; background: rgba(255,255,255,.12); }
.door .p1 { top: 7%; height: 36%; }
.door .p2 { bottom: 6%; height: 40%; }
.door .knob {
  position: absolute; right: 9%; top: 50%; width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6b0, var(--yellow) 60%, #c79700);
  border: 2px solid var(--ink);
}
.door-shadow { width: 120%; height: 18px; margin: 10px -10% 0; border-radius: 50%; background: rgba(0,0,0,.18); filter: blur(4px); }
#intro.open .door { animation: none; transform: rotateY(-112deg); }
#intro.open .door-light { animation: glow .9s ease-out forwards; }

@keyframes doorWiggle {
  0%, 80%, 100% { transform: rotateY(0); }
  85% { transform: rotateY(-8deg); }
  90% { transform: rotateY(-2deg); }
  95% { transform: rotateY(-6deg); }
}
@keyframes glow { to { box-shadow: inset 0 0 80px #ffcf40, 0 0 120px 60px #fff6c8; } }
@keyframes pulse { 50% { transform: scale(1.06); opacity: .8; } }

/* ================= Sky decoration ================= */
#sky { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.cloud {
  position: absolute; left: -260px;
  width: var(--w, 180px); height: calc(var(--w, 180px) * .32);
  background: #fff; border-radius: 999px; opacity: .9;
  animation: drift linear infinite;
}
.cloud::before, .cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 46%; height: 140%; left: 14%; top: -70%; }
.cloud::after { width: 34%; height: 110%; right: 16%; top: -48%; }
@keyframes drift { to { transform: translateX(calc(100vw + 520px)); } }

.twinkle {
  position: absolute; color: #fff; font-size: var(--size, 14px);
  animation: twinkle var(--d, 2s) ease-in-out infinite;
  text-shadow: 0 0 8px #fff;
}
@keyframes twinkle { 0%, 100% { opacity: .15; transform: scale(.6) rotate(0); } 50% { opacity: 1; transform: scale(1.1) rotate(45deg); } }

/* ================= Balloons ================= */
#balloons { position: fixed; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.balloon {
  position: absolute; bottom: -160px;
  width: calc(62px * var(--s, 1)); height: calc(150px * var(--s, 1));
  pointer-events: auto; cursor: crosshair;
  animation: rise linear forwards;
}
.balloon .sway { width: 100%; height: 100%; animation: sway 3s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.balloon .b-body {
  position: relative; width: 100%; height: 52%;
  border-radius: 50% 50% 48% 52% / 58% 58% 42% 42%;
  background: radial-gradient(circle at 32% 28%, rgba(255,255,255,.75) 0 7%, transparent 8%), radial-gradient(circle at 40% 35%, var(--c), color-mix(in srgb, var(--c) 70%, #000) 100%);
  box-shadow: inset -6px -8px 0 rgba(0,0,0,.08);
}
.balloon .b-body::after {
  content: ''; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%);
  border: 7px solid transparent; border-bottom-color: color-mix(in srgb, var(--c) 75%, #000); border-top: 0;
}
.balloon .string { position: absolute; left: 50%; top: 54%; width: 2px; height: 46%; background: rgba(31,35,64,.45); transform-origin: top; animation: string 1.4s ease-in-out infinite alternate; }
@keyframes rise { to { transform: translateY(calc(-100vh - 200px)); } }
@keyframes sway { from { transform: rotate(-6deg) translateX(-8px); } to { transform: rotate(6deg) translateX(8px); } }
@keyframes string { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }

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

/* ================= Hero ================= */
.hero { text-align: center; padding-top: clamp(28px, 7vh, 70px); position: relative; }
.date-badge {
  display: inline-flex; flex-direction: column; align-items: center; width: 76px;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px; overflow: hidden;
  box-shadow: 0 6px 0 var(--ink); transform: rotate(-6deg);
  animation: badge 3s ease-in-out infinite;
}
.date-badge .month { width: 100%; background: var(--red); color: #fff; font-weight: 700; letter-spacing: .1em; padding: 2px 0; }
.date-badge .day { font-size: 2.1rem; font-weight: 700; line-height: 1.2; }
@keyframes badge { 50% { transform: rotate(6deg) translateY(-4px); } }

h1 {
  margin: 18px 0 0; line-height: 1.02;
  font-size: clamp(2.6rem, 11vw, 6rem); font-weight: 700;
}
h1 .line { display: block; white-space: nowrap; }
h1 .line.name { font-size: 1.18em; }
.letter {
  display: inline-block; color: var(--col);
  text-shadow: 3px 3px 0 #fff, -3px -3px 0 #fff, 3px -3px 0 #fff, -3px 3px 0 #fff, 0 3px 0 #fff, 0 -3px 0 #fff, 3px 0 0 #fff, -3px 0 0 #fff, 0 9px 0 rgba(31,35,64,.25);
  animation: hop 1.8s ease-in-out infinite;
  animation-delay: calc(var(--i) * .08s);
  cursor: pointer; user-select: none;
}
.letter.space { width: .3em; }
.letter.boing { animation: boing .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes hop { 0%, 60%, 100% { transform: translateY(0) rotate(0); } 30% { transform: translateY(-14px) rotate(-6deg); } }
@keyframes boing { 0% { transform: scale(1); } 30% { transform: scale(1.5, .6); } 60% { transform: scale(.8, 1.3) translateY(-20px); } 100% { transform: scale(1); } }

.zh { margin: 10px 0 0; font-size: clamp(1.3rem, 5vw, 2rem); font-weight: 600; color: var(--red); letter-spacing: .15em; }

/* ================= Doraemon stage ================= */
.stage { position: relative; display: flex; flex-direction: column; align-items: center; margin-top: 70px; }
.dora-wrap {
  width: min(280px, 68vw); cursor: pointer; outline: none;
  animation: float 3.2s ease-in-out infinite;
  filter: drop-shadow(0 18px 12px rgba(11,127,192,.25));
}
.dora-wrap.jump { animation: jump .7s cubic-bezier(.3, 1.4, .5, 1); }
.dora-wrap:focus-visible { outline: 3px dashed var(--pink); outline-offset: 8px; border-radius: 20px; }
@keyframes float { 50% { transform: translateY(-14px); } }
@keyframes jump { 0% { transform: translateY(0) scale(1); } 20% { transform: translateY(6px) scale(1.08, .9); } 50% { transform: translateY(-60px) scale(.95, 1.06) rotate(-6deg); } 100% { transform: translateY(0) scale(1); } }

.dora { width: 100%; height: auto; display: block; overflow: visible; }
.dora .eyes { transform-box: fill-box; transform-origin: 50% 60%; animation: blink 4s infinite; }
.dora .pupils { transform-box: fill-box; transform-origin: center; animation: look 6s ease-in-out infinite; }
.dora .arm-r { transform-box: fill-box; transform-origin: 8% 92%; animation: wave 1.2s ease-in-out infinite alternate; }
.dora .blade { transform-box: fill-box; transform-origin: center; animation: spin .18s linear infinite alternate; }
.dora .pocket { cursor: pointer; transition: fill .2s; }
.dora .pocket:hover { fill: #fff6c2; }
.dora .bell { transform-box: fill-box; transform-origin: 50% 0; }
.dora-wrap.jump .bell, .dora .bell.ring { animation: ring .5s ease-in-out 2; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.08); } }
@keyframes look { 0%, 40%, 100% { transform: translateX(0); } 50%, 65% { transform: translateX(-5px); } 75%, 90% { transform: translateX(4px) translateY(-2px); } }
@keyframes wave { from { transform: rotate(-14deg); } to { transform: rotate(18deg); } }
@keyframes spin { from { transform: scaleX(1); } to { transform: scaleX(.12); } }
@keyframes ring { 25% { transform: rotate(18deg); } 75% { transform: rotate(-18deg); } }

.bubble {
  position: absolute; top: -10px; left: 50%; z-index: 4;
  max-width: min(300px, 80vw);
  background: #fff; border: 3px solid var(--ink); border-radius: 22px;
  padding: 10px 16px; font-weight: 600; font-size: 1.05rem; text-align: center;
  box-shadow: 0 5px 0 var(--ink);
  transform: translate(-10%, -100%) scale(0); transform-origin: 20% 100%;
  transition: transform .35s cubic-bezier(.3, 1.6, .5, 1);
}
.bubble::after {
  content: ''; position: absolute; left: 20%; bottom: -14px;
  border: 12px solid transparent; border-top-color: var(--ink); border-bottom: 0;
}
.bubble.show { transform: translate(-10%, -100%) scale(1); }
.hint { margin: 8px 0 0; font-size: .95rem; opacity: .7; }

.gadget { position: fixed; z-index: 55; font-size: 2.4rem; pointer-events: none; will-change: transform; }
.gadget img { width: 54px; display: block; }

/* ================= Flying Doraemon ================= */
#flyer {
  position: fixed; top: 14vh; left: 0; z-index: 4; width: 96px;
  transform: translateX(-160px);
  animation: fly 16s linear infinite; animation-delay: 6s;
  cursor: pointer;
}
#flyer .flyer-bob { animation: bob 1.6s ease-in-out infinite; }
#flyer .dora .arm-r { animation-duration: .6s; }
@keyframes fly {
  0% { transform: translateX(-160px) rotate(8deg); }
  45% { transform: translateX(calc(100vw + 160px)) rotate(8deg); }
  45.01%, 100% { transform: translateX(calc(100vw + 160px)) rotate(8deg); opacity: 0; }
}
@keyframes bob { 50% { transform: translateY(26px) rotate(-6deg); } }

/* ================= Cake ================= */
.cake-section { text-align: center; margin-top: 70px; }
.cake-section h2 { font-size: clamp(1.4rem, 5.5vw, 2.2rem); margin: 0; }
.cake-section .sub { margin: 6px 0 0; opacity: .75; }

.cake { position: relative; width: 300px; max-width: 100%; margin: 40px auto 26px; display: flex; flex-direction: column; align-items: center; }
.candles { display: flex; gap: 20px; align-items: flex-end; height: 92px; position: relative; z-index: 2; margin-bottom: -4px; }
.candle {
  position: relative; width: 14px; height: 52px; cursor: pointer;
  border: 2.5px solid var(--ink); border-radius: 4px 4px 2px 2px;
  background: repeating-linear-gradient(135deg, var(--blue) 0 6px, #fff 6px 12px);
}
.candle::before { content: ''; position: absolute; left: 50%; top: -9px; width: 2px; height: 8px; background: var(--ink); transform: translateX(-50%); }
.candle::after { content: ''; position: absolute; left: -12px; right: -12px; top: -46px; bottom: 0; } /* bigger tap area */
.flame {
  position: absolute; left: 50%; bottom: calc(100% + 7px);
  width: 18px; height: 30px; margin-left: -9px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 50% 72%, #fff 0 14%, #ffe066 32%, #ff9f1c 72%, #ff5e1c);
  box-shadow: 0 0 20px 8px rgba(255, 209, 102, .55);
  transform-origin: 50% 90%;
  animation: flicker .14s ease-in-out infinite alternate;
  transition: transform .3s, opacity .3s;
}
.candle:nth-child(2n) .flame { animation-duration: .17s; }
.candle.out .flame { animation: none; transform: scale(0); opacity: 0; }
@keyframes flicker { from { transform: rotate(-4deg) scaleY(1); } to { transform: rotate(4deg) scaleY(1.12) scaleX(.92); } }

.smoke {
  position: absolute; left: 50%; bottom: calc(100% + 6px);
  width: 12px; height: 12px; margin-left: -6px; border-radius: 50%;
  background: rgba(120, 120, 140, .5);
  animation: smoke 1.4s ease-out forwards; pointer-events: none;
}
@keyframes smoke { to { transform: translate(var(--sx, 10px), -70px) scale(3.5); opacity: 0; } }

.tier { position: relative; border: 3px solid var(--ink); border-radius: 16px 16px 8px 8px; }
.tier.top {
  width: 210px; height: 74px; background: #fff4e8;
  display: grid; place-items: center; z-index: 1;
}
.tier.top::before, .tier.bottom::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 40px; border-radius: 13px 13px 0 0;
  background:
    radial-gradient(circle at 14px 22px, var(--icing) 11px, transparent 12px) 0 0 / 30px 40px repeat-x,
    linear-gradient(var(--icing), var(--icing)) 0 0 / 100% 20px no-repeat;
}
.tier.top { --icing: var(--pink-light); }
.tier.bottom { --icing: #fff; width: 280px; height: 92px; background: var(--blue); margin-top: -3px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 14px; }
.cake-text { position: relative; margin-top: 22px; font-size: 1.6rem; font-weight: 700; color: var(--pink); text-shadow: 2px 2px 0 #fff; }
.bells { display: flex; gap: 22px; position: relative; }
.bells i {
  width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--ink);
  background: radial-gradient(circle at 50% 70%, var(--ink) 0 2.5px, transparent 3px), linear-gradient(transparent 38%, var(--ink) 38% 46%, transparent 46%), var(--yellow);
}
.plate { width: 330px; max-width: 110%; height: 24px; margin-top: -10px; border: 3px solid var(--ink); border-radius: 50%; background: #eef8ff; }

/* ================= Card ================= */
.card-wrap { display: flex; justify-content: center; margin-top: 60px; }
.card-wrap[hidden] { display: none; }
.card {
  position: relative; width: min(560px, 100%);
  background: #fff; border: 3px solid var(--ink); border-radius: 26px;
  padding: 44px 26px 26px; box-shadow: 0 10px 0 var(--ink);
  animation: cardIn .9s cubic-bezier(.3, 1.5, .5, 1);
  background-image: radial-gradient(circle, rgba(26,163,232,.09) 2px, transparent 2.5px);
  background-size: 22px 22px;
}
.card h2 { margin: 0 0 10px; color: var(--blue-dark); font-size: 1.7rem; }
#typed { font-size: 1.15rem; line-height: 1.6; min-height: 7em; white-space: pre-line; margin: 0; }
#typed::after { content: '▍'; color: var(--pink); animation: caret .8s steps(1) infinite; }
#typed.done::after { content: none; }
.sign { text-align: right; font-weight: 600; font-size: 1.15rem; color: var(--pink); min-height: 1.6em; }
.card-bell {
  position: absolute; top: -30px; left: 50%; width: 56px; height: 56px; margin-left: -28px;
  border-radius: 50%; border: 3px solid var(--ink);
  background: radial-gradient(circle at 50% 70%, var(--ink) 0 5px, transparent 6px), linear-gradient(transparent 36%, var(--ink) 36% 43%, transparent 43%), radial-gradient(circle at 35% 30%, #fff6b0, var(--yellow) 55%);
  animation: ring 1s ease-in-out infinite;
}
@keyframes cardIn { from { transform: translateY(60px) scale(.6) rotate(-6deg); opacity: 0; } }
@keyframes caret { 50% { opacity: 0; } }

/* ================= Buttons & misc ================= */
.btn {
  font: inherit; font-weight: 600; font-size: 1rem;
  padding: 10px 16px; border-radius: 999px; cursor: pointer;
  background: #fff; color: var(--ink);
  border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  transition: transform .1s, box-shadow .1s, background .2s;
}
.btn:hover { background: #fff6c2; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.small { font-size: .9rem; padding: 7px 14px; }
.btn[aria-pressed="true"] { background: var(--yellow); }

.controls {
  position: fixed; left: 50%; bottom: 14px; z-index: 70; transform: translateX(-50%);
  display: flex; gap: 8px; max-width: calc(100vw - 16px);
}
.controls .btn { white-space: nowrap; font-size: .92rem; padding: 9px 13px; }

.pop-count {
  position: fixed; top: 12px; right: 12px; z-index: 70;
  background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 4px 12px; font-weight: 700;
  box-shadow: 0 3px 0 var(--ink);
}
.pop-count.bump { animation: boing .4s; }

.rain { position: fixed; top: -90px; z-index: 56; pointer-events: none; animation: fall linear forwards; }
.rain img { width: 100%; display: block; }
@keyframes fall { to { transform: translateY(calc(100vh + 180px)) rotate(var(--r, 360deg)); } }

footer { text-align: center; margin-top: 70px; opacity: .6; font-size: .9rem; }

@media (max-width: 480px) {
  .controls .btn { font-size: .8rem; padding: 8px 10px; }
  .candles { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .letter, .dora-wrap, .cloud, .twinkle, .date-badge { animation-duration: 6s !important; }
}
