* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    overflow: hidden;
    background: #0a0015;
    font-family: "Microsoft YaHei", "PingFang SC", "SimHei", sans-serif;
    color: #fff;
    height: 100vh;
    width: 100vw;
    user-select: none;
}

/* ===== Canvas ===== */
#main-canvas {
    position: fixed; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1000;
}

#rose-canvas {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}

#particle-text-canvas {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* ===== Pages ===== */
.page {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden;
    transition: opacity 1s ease, visibility 1s ease;
    z-index: 10;
}
.page.active { opacity: 1; visibility: visible; }

/* ===== Page 1: Welcome ===== */
#page-1 { background: radial-gradient(ellipse at 50% 30%, #1a0030, #0a0015 60%, #050008); }

.stars-bg {
    position: absolute; inset: 0;
    background-image:
        radial-gradient(2px 2px at 20px 30px, #fff, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(2px 2px at 160px 120px, rgba(255,200,255,.9), transparent),
        radial-gradient(1px 1px at 200px 60px, #fff, transparent);
    background-size: 250px 180px;
    animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle { 0%{opacity:.4} 100%{opacity:1} }

.welcome-content { text-align: center; z-index: 10; position: relative; }

/* Unique Tag */
.unique-tag {
    font-size: clamp(12px, 2.5vw, 15px);
    color: rgba(255,215,0,.85);
    letter-spacing: 3px;
    padding: 6px 20px;
    border: 1px solid rgba(255,215,0,.25);
    border-radius: 30px;
    background: rgba(255,215,0,.06);
    display: inline-block;
    margin-bottom: 15px;
    animation: tagGlow 3s ease-in-out infinite alternate;
    backdrop-filter: blur(5px);
}
@keyframes tagGlow {
    0%{border-color:rgba(255,215,0,.2);box-shadow:0 0 10px rgba(255,215,0,.1)}
    100%{border-color:rgba(255,215,0,.5);box-shadow:0 0 25px rgba(255,215,0,.2)}
}

.sparkle-ring { margin-bottom: 5px; animation: floatY 3s ease-in-out infinite; }

.crown {
    font-size: 60px;
    filter: drop-shadow(0 0 20px rgba(255,215,0,.8));
    animation: crownPulse 2s ease-in-out infinite;
}
@keyframes crownPulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.12)} }
@keyframes floatY { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-15px)} }

/* ===== Name Title ===== */
.title-name {
    font-size: clamp(80px, 20vw, 170px);
    font-weight: 900;
    color: #ffd93d;
    text-shadow:
        0 0 20px rgba(255,107,157,.9),
        0 0 50px rgba(255,107,157,.5),
        0 0 100px rgba(196,77,255,.4),
        0 2px 0 rgba(180,80,0,.3);
    animation: titleColor 4s ease-in-out infinite, floatY 4s ease-in-out infinite;
    letter-spacing: 12px;
    line-height: 1.2;
    margin-bottom: 8px;
}
@keyframes titleColor {
    0%,100%{color:#ffd93d; text-shadow:0 0 20px rgba(255,107,157,.9),0 0 50px rgba(255,107,157,.5),0 0 100px rgba(196,77,255,.4)}
    33%{color:#ff8fab; text-shadow:0 0 20px rgba(255,217,61,.9),0 0 50px rgba(255,217,61,.5),0 0 100px rgba(255,107,157,.4)}
    66%{color:#f9c; text-shadow:0 0 20px rgba(196,77,255,.9),0 0 50px rgba(255,107,157,.5),0 0 100px rgba(255,217,61,.4)}
}

/* ===== Divider ===== */
.divider-line {
    display: flex; align-items: center; justify-content: center;
    gap: 15px; margin: 8px 0 12px;
}
.divider-line::before, .divider-line::after {
    content: ''; width: 80px; height: 2px;
    background: linear-gradient(90deg, transparent, #ff6b9d, transparent);
    animation: lineGlow 2s ease-in-out infinite alternate;
}
.diamond { font-size: 24px; animation: spin 4s linear infinite; }
@keyframes spin { to{transform:rotate(360deg)} }
@keyframes lineGlow { 0%{opacity:.3;width:60px} 100%{opacity:1;width:100px} }

/* ===== Subtitle ===== */
.subtitle-anim { font-size: clamp(28px, 6vw, 50px); margin-bottom: 15px; }
.word {
    display: inline-block;
    animation: wordFadeUp 1s ease forwards;
    animation-delay: var(--d); opacity: 0;
    color: #ffd93d;
    text-shadow: 0 0 15px rgba(255,107,157,.6);
}
@keyframes wordFadeUp {
    0%{opacity:0;transform:translateY(30px) scale(.5)}
    100%{opacity:1;transform:translateY(0) scale(1)}
}

/* ===== Blessing ===== */
.blessing-text { display:flex; flex-direction:column; gap:6px; margin-bottom:20px; }
.line {
    display: block; font-size: clamp(18px,4vw,26px);
    opacity: 0; animation: lineAppear 1s ease forwards;
    color: #ffd93d; text-shadow: 0 0 15px rgba(255,217,61,.5);
}
.line-1 { animation-delay: 1.5s; font-size: clamp(22px, 5vw, 32px); }
@keyframes lineAppear {
    0%{opacity:0;transform:translateY(20px);filter:blur(10px)}
    100%{opacity:1;transform:translateY(0);filter:blur(0)}
}

/* ===== Floating Emojis ===== */
.floating-emojis { margin-bottom:25px; height:50px; position:relative; }
.float-emoji {
    position:absolute; left:50%; font-size:28px;
    animation: emojiFloat 3s ease-in-out infinite;
    animation-delay: var(--delay);
    transform: translateX(var(--x));
}
@keyframes emojiFloat {
    0%,100%{transform:translateX(var(--x)) translateY(0) rotate(0deg)}
    33%{transform:translateX(var(--x)) translateY(-20px) rotate(10deg)}
    66%{transform:translateX(var(--x)) translateY(-10px) rotate(-10deg)}
}

/* ===== Magic Button ===== */
.magic-btn {
    position: relative; padding: 14px 36px; border: none; border-radius: 50px;
    background: linear-gradient(135deg, #ff6b9d, #c44dff);
    color: #fff; font-size: clamp(16px,3vw,20px);
    font-family: inherit; cursor: pointer; overflow: hidden;
    transition: all .3s ease;
    box-shadow: 0 5px 25px rgba(196,77,255,.4);
    z-index: 50;
}
.magic-btn:hover { transform:translateY(-3px) scale(1.05); box-shadow:0 10px 40px rgba(196,77,255,.6); }
.magic-btn:active { transform:translateY(0) scale(.98); }
.btn-glow {
    position:absolute; top:-50%;left:-50%; width:200%;height:200%;
    background: conic-gradient(from 0deg, transparent, rgba(255,255,255,.3), transparent, transparent);
    animation: btnSpin 3s linear infinite;
}
@keyframes btnSpin { to{transform:rotate(360deg)} }

/* ===== Page 2: Letter ===== */
#page-2 { background: radial-gradient(ellipse at 50% 50%, #1a0030, #0a0015 70%); }
.wishes-content { text-align:center; z-index:10; }

.envelope {
    width: min(360px,85vw); height: 260px;
    position: relative; margin: 0 auto; cursor: pointer;
    perspective: 800px;
    animation: envelopeIn 1s ease forwards;
}
@keyframes envelopeIn {
    0%{opacity:0;transform:scale(.5) rotateY(90deg)}
    100%{opacity:1;transform:scale(1) rotateY(0)}
}
.envelope-back {
    position:absolute; inset:0;
    background: linear-gradient(145deg, #e84393, #fd79a8);
    border-radius: 10px;
    z-index: 1;
}
.envelope-top {
    position:absolute; top:0;left:0; width:100%;height:50%;
    background: linear-gradient(135deg, #e84393, #fd79a8);
    clip-path: polygon(0 0, 50% 100%, 100% 0);
    z-index: 3; transform-origin: top center;
    transition: transform .8s ease;
}
.envelope.open .envelope-top { transform: rotateX(180deg); }

.letter {
    position:absolute; bottom:0;left:5%; width:90%;height:95%;
    background: linear-gradient(145deg, #fff8f8, #fff0f5);
    border-radius:10px; z-index:2;
    transition: transform .8s ease .3s;
    box-shadow: 0 5px 30px rgba(0,0,0,.2);
}
.envelope.open .letter { transform: translateY(-70px); }

.letter-content { padding:25px 20px; color:#4a2040; text-align:left; }
.letter-title { font-size:20px; color:#c44dff; margin-bottom:15px; text-align:center; opacity:0; }
.letter-line { font-size:15px; line-height:2.2; opacity:0; color:#5a3050; }
.signature { text-align:right; color:#ff6b9d; font-size:16px; margin-top:10px; }
.envelope.open .letter-title, .envelope.open .letter-line {
    animation: letterReveal .6s ease forwards;
}
.envelope.open .letter-title { animation-delay:.8s; }
.envelope.open .letter-line { animation-delay: calc(.8s + var(--ld)); }
@keyframes letterReveal { 0%{opacity:0;transform:translateY(10px)} 100%{opacity:1;transform:translateY(0)} }

/* ===== Page 3: Magic Effects ===== */
#page-3 {
    background: radial-gradient(ellipse at 50% 30%, #0d0025, #050010);
    cursor: crosshair;
}
.magic-page { position:relative; width:100%; height:100%; display:flex; flex-direction:column; align-items:center; justify-content:center; z-index:10; }

.typewriter-box {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 20px; padding: 30px 35px;
    backdrop-filter: blur(15px);
    max-width: min(460px, 88vw);
    text-align: center;
    position: relative; z-index: 10;
    box-shadow: 0 10px 50px rgba(196,77,255,.15);
}
.tw-icon { font-size:50px; margin-bottom:15px; animation: floatY 3s ease-in-out infinite; }
.typewriter {
    font-size: clamp(18px,4vw,24px); color:rgba(255,255,255,.9);
    line-height: 2; min-height: 120px; text-align:left;
}
.tw-cursor {
    display:inline-block; color:#ff6b9d; font-weight:bold;
    animation: blink 1s step-end infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

.tap-hint {
    margin-top:25px; font-size:14px; color:rgba(255,255,255,.45);
    animation: fadeInOut 3s ease-in-out infinite;
    z-index: 10;
}
@keyframes fadeInOut { 0%,100%{opacity:.3} 50%{opacity:.7} }

.next-btn { margin-top:20px; z-index:10; }

/* Shooting Stars */
.shooting-star {
    position: fixed; width: 80px; height: 2px;
    background: linear-gradient(90deg, rgba(255,255,255,.8), transparent);
    border-radius: 2px; pointer-events: none; z-index: 5;
    animation: shoot 1s linear forwards;
}
.shooting-star::before {
    content:''; position:absolute; left:0;top:-2px;
    width:6px;height:6px; border-radius:50%;
    background:#fff; box-shadow: 0 0 10px #fff, 0 0 20px #c44dff;
}
@keyframes shoot {
    0%{transform:translateX(0) translateY(0); opacity:1}
    100%{transform:translateX(300px) translateY(200px); opacity:0}
}

/* ===== Page 4: Finale ===== */
#page-4 { background: radial-gradient(ellipse at 50% 40%, #1a0030, #0a0015 70%); }
.finale-content { text-align:center; z-index:10; position:relative; }

.big-heart-container { margin-bottom:10px; }
.big-heart {
    font-size:80px;
    animation: heartBeat 1.2s ease-in-out infinite;
    filter: drop-shadow(0 0 30px rgba(255,100,150,.6));
}
@keyframes heartBeat {
    0%,100%{transform:scale(1)} 15%{transform:scale(1.15)}
    30%{transform:scale(1)} 45%{transform:scale(1.1)}
}

.finale-title {
    font-size: clamp(50px,10vw,90px); font-weight:900;
    color: #ffd93d;
    text-shadow: 0 0 20px rgba(255,107,157,.8), 0 0 50px rgba(196,77,255,.4);
    animation: titleColor 4s ease-in-out infinite;
    margin-bottom:5px;
}
.finale-subtitle {
    font-size: clamp(22px,5vw,36px);
    color: rgba(255,255,255,.9); margin-bottom:25px;
    animation: glow 2s ease-in-out infinite alternate;
}
@keyframes glow {
    0%{text-shadow:0 0 10px rgba(255,107,157,.3)}
    100%{text-shadow:0 0 30px rgba(255,107,157,.6),0 0 60px rgba(196,77,255,.3)}
}

.wishes-grid {
    display:grid; grid-template-columns:repeat(3,1fr);
    gap:12px; max-width:380px; margin:0 auto 25px;
}
.wish-card {
    background:rgba(255,255,255,.05);
    border:1px solid rgba(255,255,255,.1);
    border-radius:15px; padding:14px 8px;
    backdrop-filter:blur(10px);
    opacity:0; animation: cardPop .6s ease forwards;
    animation-delay: calc(var(--ci) * .15s);
    transition: transform .3s, box-shadow .3s;
}
.wish-card:hover {
    transform:translateY(-5px) scale(1.05);
    box-shadow:0 10px 30px rgba(196,77,255,.2);
    border-color:rgba(255,107,157,.3);
}
.wish-card span { font-size:32px; display:block; margin-bottom:5px; }
.wish-card p { font-size:14px; color:rgba(255,255,255,.8); }
@keyframes cardPop {
    0%{opacity:0;transform:translateY(30px) scale(.8)}
    100%{opacity:1;transform:translateY(0) scale(1)}
}

/* ===== Petals ===== */
.falling-petals { position:fixed; inset:0; pointer-events:none; z-index:998; }
.petal {
    position:absolute; border-radius:50% 0 50% 50%; opacity:.7;
    animation: petalFall linear infinite;
}
@keyframes petalFall {
    0%{transform:translateY(-10vh) rotate(0) translateX(0);opacity:.8}
    25%{transform:translateY(25vh) rotate(90deg) translateX(30px)}
    50%{transform:translateY(50vh) rotate(180deg) translateX(-20px);opacity:.6}
    75%{transform:translateY(75vh) rotate(270deg) translateX(25px)}
    100%{transform:translateY(110vh) rotate(360deg) translateX(-10px);opacity:0}
}

/* ===== Bottom Nav ===== */
.bottom-nav {
    position:fixed; bottom:25px; left:50%; transform:translateX(-50%);
    display:flex; gap:12px; z-index:2000;
    padding:8px 20px; background:rgba(255,255,255,.08);
    border-radius:20px; backdrop-filter:blur(15px);
    border:1px solid rgba(255,255,255,.1);
}
.nav-dot {
    width:12px;height:12px; border-radius:50%;
    border:2px solid rgba(255,255,255,.4);
    background:transparent; cursor:pointer; transition:all .3s;
}
.nav-dot.active {
    background:#ff6b9d; border-color:#ff6b9d;
    box-shadow:0 0 10px rgba(255,107,157,.5); transform:scale(1.2);
}
.nav-dot:hover:not(.active) { border-color:rgba(255,255,255,.8); background:rgba(255,255,255,.2); }

/* ===== Cursor Trail ===== */
.trail-dot {
    position:fixed; width:8px;height:8px; border-radius:50%;
    pointer-events:none; z-index:9999;
    animation: trailFade .6s ease forwards;
}
@keyframes trailFade { 0%{transform:scale(1);opacity:.8} 100%{transform:scale(0);opacity:0} }

/* ===== Confetti ===== */
.confetti {
    position:fixed; z-index:9998; pointer-events:none;
    animation: confettiFall linear forwards;
}
@keyframes confettiFall {
    0%{transform:translateY(-10vh) rotate(0);opacity:1}
    100%{transform:translateY(110vh) rotate(720deg);opacity:0}
}

/* ===== Click Ripple ===== */
.click-ripple {
    position:fixed; border-radius:50%; pointer-events:none; z-index:999;
    border: 2px solid rgba(255,107,157,.6);
    animation: rippleOut .8s ease forwards;
}
@keyframes rippleOut {
    0%{width:0;height:0;opacity:1}
    100%{width:150px;height:150px;opacity:0;margin:-75px 0 0 -75px}
}

/* ===== Responsive ===== */
@media (max-width:480px) {
    .floating-emojis { transform:scale(.8); }
    .wishes-grid { gap:8px; }
    .wish-card { padding:10px 5px; }
    .wish-card span { font-size:24px; }
    .wish-card p { font-size:12px; }
    .typewriter-box { padding:20px; }
}
