@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@700&family=Quicksand:wght@400;600;700&display=swap');

:root {
    --bg1: #0b1021;
    --bg2: #1a1040;
    --pink: #ff758c;
    --pink-soft: #ffb6c9;
    --lilac: #c9a7ff;
    --gold: #ffe08a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { width: 100%; overflow: hidden; }

body {
    margin: 0; height: 100vh; overflow: hidden;
    font-family: 'Quicksand', sans-serif; color: #fff;
    background: linear-gradient(160deg, var(--bg1), var(--bg2) 60%, #2a1250);
    display: flex; justify-content: center; align-items: center;
}

/* ===== Nền: cực quang mềm + sao ===== */
body::before, body::after {
    content: ''; position: fixed; z-index: -2; border-radius: 50%;
    filter: blur(90px); opacity: .35; animation: drift 14s ease-in-out infinite alternate;
}
body::before { width: 55vmax; height: 55vmax; background: #ff5f9e; top: -20vmax; left: -15vmax; }
body::after  { width: 50vmax; height: 50vmax; background: #6c5ce7; bottom: -20vmax; right: -15vmax; animation-delay: -7s; }
@keyframes drift { to { transform: translate(8vw, 6vh) scale(1.15); } }

.stars { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.star { position: absolute; background: #fff; border-radius: 50%; animation: twinkle infinite ease-in-out; }
@keyframes twinkle {
    0%, 100% { opacity: .2; transform: scale(.7); }
    50% { opacity: 1; transform: scale(1.3); box-shadow: 0 0 6px #fff; }
}
.shooting-star {
    position: fixed; width: 120px; height: 2px; z-index: -1; pointer-events: none;
    background: linear-gradient(90deg, #fff, transparent);
    transform: rotate(-35deg); opacity: 0; animation: shoot 1.4s ease-out forwards;
}
@keyframes shoot {
    0% { opacity: 1; translate: 0 0; }
    100% { opacity: 0; translate: -400px 280px; }
}

/* ===== Scenes ===== */
.scene-container { width: 100%; height: 100vh; position: relative; }
.scene {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transform: translateY(40px) scale(.95);
    transition: opacity .9s ease, transform .9s cubic-bezier(.2,.9,.3,1.2);
}
.scene.active { opacity: 1; pointer-events: auto; transform: none; }

.hint-text {
    margin-top: 28px; font-size: 15px; font-weight: 600; letter-spacing: .5px;
    color: rgba(255,255,255,.85); animation: bounce 1.2s ease-in-out infinite;
}
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ===== Scene 1: Lồng kính ===== */
.glass-dome {
    width: 170px; height: 270px; position: relative; cursor: pointer;
    border: 2px solid rgba(255,255,255,.35); border-radius: 85px 85px 14px 14px;
    background:
        linear-gradient(115deg, rgba(255,255,255,.25) 0%, transparent 25%),
        radial-gradient(ellipse at bottom, rgba(255,117,140,.4), transparent 70%);
    box-shadow: 0 0 30px rgba(255,117,140,.5), inset 0 0 25px rgba(255,255,255,.15);
    display: flex; justify-content: center; align-items: flex-end; padding-bottom: 28px;
    animation: pulse 2.4s ease-in-out infinite, hover 4s ease-in-out infinite;
    overflow: visible;
}
.glass-dome::after { /* đế */
    content: ''; position: absolute; bottom: -14px; left: -12px; right: -12px; height: 16px;
    border-radius: 10px; background: linear-gradient(#f9c6d3, #e58aa4);
    box-shadow: 0 6px 18px rgba(255,117,140,.5);
}
@keyframes pulse { 50% { box-shadow: 0 0 55px rgba(255,117,140,.9), inset 0 0 25px rgba(255,255,255,.2); } }
@keyframes hover { 50% { transform: translateY(-10px); } }
.glass-dome:active { transform: scale(.94); }

.rose {
    font-size: 84px; transform-origin: bottom center;
    filter: drop-shadow(0 0 14px #ff3b5c); animation: sway 3s ease-in-out infinite;
}
@keyframes sway { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }

.sparkle, .petal {
    position: absolute; pointer-events: none; animation-timing-function: ease-in-out;
}
.sparkle { animation: sparkle 2.2s infinite; }
@keyframes sparkle {
    0%,100% { opacity: 0; transform: scale(.3) rotate(0); }
    50% { opacity: 1; transform: scale(1.1) rotate(180deg); }
}
.petal { top: 10%; animation: petalFall linear infinite; opacity: 0; }
@keyframes petalFall {
    0% { transform: translateY(0) rotate(0); opacity: 0; }
    15% { opacity: .9; }
    100% { transform: translateY(190px) translateX(var(--dx, 20px)) rotate(360deg); opacity: 0; }
}

/* ===== Scene 2 & 3 ===== */
.greet {
    text-align: center; padding: 0 16px;
    opacity: 0; transform: scale(.7) translateY(20px);
    transition: 1.2s cubic-bezier(.2,.9,.3,1.3);
    filter: drop-shadow(0 0 14px rgba(255,117,140,.55));
}
.scene.active .greet { opacity: 1; transform: none; }
.greet-top { display: flex; justify-content: center; align-items: center; gap: 14px; }
.grad-text {
    display: inline-block; font-family: 'Dancing Script', cursive; font-size: 3.4rem; line-height: 1.3;
    background: linear-gradient(90deg, #ff9ab0, #fff, #c9a7ff, #ff9ab0); background-size: 250% auto;
    -webkit-background-clip: text; background-clip: text; color: transparent;
    -webkit-text-fill-color: transparent; animation: shine 5s linear infinite;
}
.grad-text.big { font-size: 5.2rem; line-height: 1.1; margin: 4px 0 14px; }
@keyframes shine { to { background-position: 250% center; } }
.deco { font-size: 2rem; animation: twirl 2.4s ease-in-out infinite; }
.deco:last-child { animation-delay: -1.2s; }
@keyframes twirl { 0%,100% { transform: scale(.8) rotate(-15deg); } 50% { transform: scale(1.25) rotate(15deg); } }
.name-badge {
    display: inline-flex; align-items: center; gap: 10px; padding: 8px 22px; border-radius: 40px;
    font-family: 'Dancing Script', cursive; font-size: 2.1rem; color: #fff;
    background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.35);
    backdrop-filter: blur(6px); animation: heartbeat 1.6s infinite;
}
@keyframes heartbeat { 0%,100% { transform: scale(1); } 15% { transform: scale(1.08); } 30% { transform: scale(1); } 45% { transform: scale(1.05); } }

.bouquet {
    font-size: 150px; cursor: pointer; filter: drop-shadow(0 0 22px #ff758c);
    transform-origin: bottom center; animation: bouquetSway 3s ease-in-out infinite;
}
@keyframes bouquetSway { 0%,100% { transform: rotate(-4deg) scale(1); } 50% { transform: rotate(4deg) scale(1.06); } }
.bouquet:active { transform: scale(.9); }

/* ===== Scene 4: Lá thư ===== */
.envelope {
    width: 280px; height: 180px; position: relative; cursor: pointer; border-radius: 14px;
    background: linear-gradient(160deg, #fff3f7, #fbd3df);
    box-shadow: 0 14px 35px rgba(0,0,0,.5), 0 0 25px rgba(255,117,140,.4);
    transition: transform .5s; animation: hover 3.5s ease-in-out infinite;
}
.envelope:hover { transform: translateY(-8px) rotate(-1deg); }
.envelope::before { /* nắp thư */
    content: ''; position: absolute; top: 0; left: 0; z-index: 3;
    border-left: 140px solid transparent; border-right: 140px solid transparent;
    border-top: 105px solid #f5b8cb; border-radius: 14px 14px 0 0;
    transition: transform .6s, z-index .6s; transform-origin: top;
}
.envelope.open::before { transform: rotateX(180deg); z-index: 0; }
.seal {
    position: absolute; top: 80px; left: 50%; transform: translateX(-50%); z-index: 4;
    font-size: 34px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.3));
    animation: heartbeat 1.4s infinite; transition: opacity .3s;
}
.envelope.open .seal { opacity: 0; }
.letter-paper {
    position: absolute; top: 12px; left: 12px; right: 12px; bottom: 12px; z-index: 1;
    background: repeating-linear-gradient(#fffdf8, #fffdf8 21px, #f3e3ea 22px);
    border-radius: 8px; padding: 14px; color: #5a3a46; font-size: 13px; line-height: 22px;
    overflow: hidden; transition: all .9s cubic-bezier(.2,.9,.3,1.1);
    box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.envelope.open .letter-paper {
    z-index: 5; bottom: auto; height: 260px; overflow-y: auto;
    transform: translateY(-120px); font-size: 14px;
}

/* ===== Scene 5: Vũ trụ ===== */
.universe { position: absolute; inset: 0; overflow: hidden; }
.floating-item {
    position: absolute; background: #fff; padding: 5px 5px 20px; border-radius: 6px;
    object-fit: cover; cursor: pointer;
    box-shadow: 0 6px 18px rgba(255,117,140,.5);
    animation: floatItem linear infinite;
}
.floating-item:hover { animation-play-state: paused; z-index: 100; filter: brightness(1.1) drop-shadow(0 0 16px #fff); }
.floating-heart {
    position: absolute; pointer-events: none; animation: floatHeart ease-in infinite;
    filter: drop-shadow(0 0 8px rgba(255,60,100,.8));
}
.floating-msg {
    position: absolute; font-weight: 700; pointer-events: none;
    white-space: normal; text-align: center; line-height: 1.4;
    width: max-content; max-width: min(78vw, 340px);
    padding: 6px 14px; border-radius: 20px; background: rgba(255,255,255,.08);
    backdrop-filter: blur(4px); text-shadow: 0 0 8px rgba(255,117,140,.8);
    animation: floatItem linear infinite;
}
@keyframes floatItem {
    0% { transform: translateY(110vh) rotate(var(--r, -8deg)); }
    100% { transform: translateY(-50vh) rotate(calc(var(--r, -8deg) * -1)); }
}
@keyframes floatHeart {
    0% { transform: translateY(110vh) translateX(0) scale(.7); opacity: 1; }
    50% { transform: translateY(50vh) translateX(25px) scale(1.1); }
    100% { transform: translateY(-20vh) translateX(-25px) scale(1.5); opacity: 0; }
}

/* ===== Hiệu ứng chạm ===== */
.burst {
    position: fixed; pointer-events: none; z-index: 1000; font-size: 20px;
    animation: burst .9s ease-out forwards;
}
@keyframes burst {
    0% { transform: translate(-50%,-50%) scale(.4); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1.3) rotate(var(--rot)); opacity: 0; }
}

/* ===== Nút nhạc ===== */
.music-control {
    position: fixed; bottom: 20px; right: 20px; z-index: 999; width: 46px; height: 46px;
    border-radius: 50%; display: flex; justify-content: center; align-items: center;
    cursor: pointer; font-size: 20px; backdrop-filter: blur(6px);
    background: rgba(255,117,140,.45); border: 1px solid rgba(255,255,255,.4);
    box-shadow: 0 0 14px rgba(255,117,140,.6);
}
.music-control.playing { animation: spin 4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 480px) {
    .grad-text { font-size: 2.6rem; } .grad-text.big { font-size: 4rem; }
    .envelope { transform: scale(.92); }
}