/* --- Global Styles & Setup --- */
@import url('https://fonts.googleapis.com/css2?family=Pacifico&family=Poppins:wght@300;400;700&family=Great+Vibes&display=swap');

:root {
    --bg-dark: #2d0a1e;
    --bg-light: #6b1a40;
    --primary: #ff6eb4;
    --primary-dark: #d94f93;
    --accent: #ffcce8;
    --accent-gold: #ffb3d9;
    --text-light: #ffffff;
    --envelope-body: #fff0f7;
    --envelope-flap: #ffd6ec;
    --letter-paper: #fff5fa;
    --button-hover: #d94f93;
    --cake-bottom: #8b2252;
    --cake-middle: #b5306e;
    --cake-top: #d9548d;
    --flame-color: #ff9ecd;
    --shadow-light: rgba(0,0,0,0.15);
    --shadow-medium: rgba(0,0,0,0.25);
    --shadow-heavy: rgba(0,0,0,0.45);
    --glow: rgba(255, 110, 180, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-light), #3d0f2a);
    color: var(--text-light);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    perspective: 1000px;
}

/* Subtle background sparkle pattern */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image:
        radial-gradient(circle, rgba(255,110,180,0.08) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

.step {
    display: none;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.step.active {
    display: flex;
    opacity: 1;
    transform: scale(1);
}

.step:not(.active) {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.action-button {
    display: inline-block;
    padding: 13px 30px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-light);
    border: none;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--glow);
    letter-spacing: 0.5px;
}

.action-button:hover {
    background: linear-gradient(135deg, var(--primary-dark), #b0326e);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px var(--glow);
}

/* --- Step 1: Welcome Screen --- */
.welcome-card {
    text-align: center;
    padding: 45px 40px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 180, 220, 0.25);
    box-shadow: 0 15px 40px var(--shadow-heavy), 0 0 60px var(--glow);
    max-width: 500px;
    animation: fadeIn 1s ease-out;
}

.stars-top {
    font-size: 1.8rem;
    margin-bottom: 15px;
    animation: sparkle 2s infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.welcome-title {
    font-family: 'Great Vibes', cursive;
    font-size: 3.8rem;
    margin-bottom: 15px;
    color: var(--accent);
    text-shadow: 0 0 20px var(--glow), 2px 2px 5px var(--shadow-medium);
}

.welcome-message {
    font-size: 1.15rem;
    margin-bottom: 30px;
    line-height: 1.7;
    color: rgba(255,255,255,0.88);
}

/* --- Step 2: Envelope --- */
.envelope-container {
    text-align: center;
    animation: pulse 2s infinite;
    cursor: pointer;
}

.envelope {
    position: relative;
    width: 320px;
    height: 200px;
    filter: drop-shadow(0 8px 20px var(--glow));
}

.envelope-back {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: var(--envelope-body);
    border-radius: 10px;
    box-shadow: 0 8px 20px var(--shadow-medium);
}

.envelope-flap {
    position: absolute;
    width: 100%;
    height: 100px;
    background-color: var(--envelope-flap);
    top: 0; left: 0;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    transform-origin: top;
    transition: transform 0.55s ease-in-out;
    z-index: 2;
}

.envelope-front {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: var(--envelope-body);
    top: 0; left: 0;
    clip-path: polygon(0 100%, 100% 100%, 100% 50%, 50% 100%, 0 50%);
    z-index: 1;
}

.envelope-seal {
    position: absolute;
    width: 44px;
    height: 44px;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0iI2ZmNmViNCI+PHBhdGggZD0iTTEyIDYuMjc1Yy01LjUwMy01LjgyOC0xNC40NDUgMi41NDctNi40NDUgOS42NDcgNC44MjcgNC44MjcgOS4xMjcgMi40NTcgMTIgMi41MjEgMi44NzMtLjA2NCA3LjE3MyAyLjMwMyAxMi0yLjUyMSAxMi03LjA4IDcuNjA4LTExLjQ4NSAyLjc1NS0xMS43OTJjLTcuOTk5LTcuMzk5LTMuMzk1LTkuNzE0LTYuNDQ1LTkuNjQ3eiIvPjwvc3ZnPg==');
    background-size: cover;
    top: 78px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    filter: drop-shadow(0 0 6px var(--primary));
}

.envelope-container.open .envelope-flap {
    transform: rotateX(180deg);
}

.click-instruction {
    margin-top: 28px;
    font-size: 1.1rem;
    color: var(--accent);
    animation: bounce 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

/* --- Step 3: Letter --- */
.letter-container {
    text-align: center;
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.5s 0.4s ease, transform 0.5s 0.4s ease;
    max-width: 90vw;
}

.letter-container.show {
    opacity: 1;
    transform: translateY(0);
}

.letter {
    width: 420px;
    max-width: 100%;
    background-color: var(--letter-paper);
    color: #3d0a1e;
    padding: 35px;
    border-radius: 12px;
    box-shadow: 0 10px 30px var(--shadow-medium), 0 0 30px var(--glow);
    line-height: 1.9;
    border-top: 4px solid var(--primary);
}

.letter p {
    font-size: 1.05rem;
    margin-bottom: 16px;
}
.letter p:first-child {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--primary-dark);
}

/* --- Step 4: Grand Celebration --- */
.celebration-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.celebration-card {
    text-align: center;
    padding: 35px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 180, 220, 0.3);
    box-shadow: 0 20px 50px var(--shadow-heavy), 0 0 80px var(--glow);
    max-width: 680px;
    z-index: 10;
    animation: popIn 0.9s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.4); }
    100% { opacity: 1; transform: scale(1); }
}

.sub-greeting {
    font-size: 1.1rem;
    margin-bottom: 5px;
    color: var(--accent);
    letter-spacing: 1px;
}

.main-greeting {
    font-family: 'Poppins', sans-serif;
    font-size: 2.6rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    border-right: 3px solid var(--accent);
    color: var(--text-light);
    text-shadow: 0 0 20px var(--glow);
}

.main-greeting.typed {
    border-right: 3px solid transparent;
    animation: blinkCursor 0.75s step-end infinite;
}

@keyframes blinkCursor {
    from, to { border-color: transparent }
    50% { border-color: var(--accent); }
}

.recipient-name {
    font-family: 'Pacifico', cursive;
    font-size: 4.2rem;
    color: var(--accent);
    margin: 8px 0 20px;
    text-shadow: 0 0 30px var(--glow), 3px 3px 8px var(--shadow-medium);
    line-height: 1.1;
}

.final-wish {
    font-size: 1.1rem;
    margin-top: 20px;
    line-height: 1.7;
    max-width: 580px;
    margin-left: auto;
    margin-right: auto;
    color: rgba(255,255,255,0.92);
}

.signature {
    font-family: 'Great Vibes', cursive;
    font-size: 2rem;
    margin-top: 25px;
    color: var(--accent);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    text-shadow: 0 0 10px var(--glow);
}

.heart-icon {
    width: 26px;
    height: 26px;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0iI2ZmNmViNCI+PHBhdGggZD0iTTEyIDYuMjc1Yy01LjUwMy01LjgyOC0xNC40NDUgMi41NDctNi40NDUgOS42NDcgNC44MjcgNC44MjcgOS4xMjcgMi40NTcgMTIgMi41MjEgMi44NzMtLjA2NCA3LjE3MyAyLjMwMyAxMi0yLjUyMSAxMi03LjA4IDcuNjA4LTExLjQ4NSAyLjc1NS0xMS43OTJjLTcuOTk5LTcuMzk5LTMuMzk1LTkuNzE0LTYuNDQ1LTkuNjQ3eiIvPjwvc3ZnPg==');
    background-size: contain;
    background-repeat: no-repeat;
    filter: drop-shadow(0 0 4px var(--primary));
}

/* --- Cake Styling --- */
.cake-container {
    margin: 25px auto;
}

.cake {
    position: relative;
    width: 280px;
    height: 280px;
    margin: 0 auto;
}

.plate {
    width: 300px;
    height: 22px;
    background: linear-gradient(135deg, #e8c4d8, #f0d0e0);
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50%;
    box-shadow: 0 5px 10px var(--shadow-medium);
}

.layer {
    position: absolute;
    height: 58px;
    border-radius: 50% / 25%;
    left: 50%;
    transform: translateX(-50%);
}
.layer-bottom { bottom: 45px; background: linear-gradient(135deg, var(--cake-bottom), #6a1a40); width: 280px; }
.layer-middle { bottom: 85px; background: linear-gradient(135deg, var(--cake-middle), #8a2456); width: 258px; }
.layer-top    { bottom: 125px; background: linear-gradient(135deg, var(--cake-top), #b8406a); width: 236px; }

.icing {
    position: absolute;
    width: 236px;
    height: 32px;
    background: linear-gradient(135deg, #ffe0f0, #ffffff);
    bottom: 163px;
    border-radius: 50% / 25%;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 10px rgba(255,110,180,0.3);
}

.drip {
    position: absolute;
    width: 22px;
    height: 32px;
    background: #ffe0f0;
    border-radius: 50%;
    top: -14px;
}
.drip1 { left: 42px; }
.drip2 { left: 130px; height: 42px; }
.drip3 { left: 210px; }

.candle {
    position: absolute;
    width: 13px;
    height: 58px;
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    bottom: 188px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 6px 6px 0 0;
    box-shadow: 0 0 8px var(--glow);
}

.flame {
    position: absolute;
    width: 14px;
    height: 20px;
    background: radial-gradient(ellipse, #fff8b0, #ffcce8, var(--primary));
    top: -20px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: flicker 1.1s infinite;
    box-shadow: 0 0 10px #ffcce8, 0 0 20px var(--primary), 0 0 35px var(--glow);
    transition: all 0.2s ease-out;
}

.candle:hover .flame {
    opacity: 0;
    transform: scale(0.2) translateY(5px);
    box-shadow: none;
}

@keyframes flicker {
    0%, 100% { transform: scaleY(1) rotate(0deg); opacity: 1; }
    25%  { transform: scaleY(0.88) rotate(2deg); opacity: 0.9; }
    50%  { transform: scaleY(1.12) rotate(-2deg); opacity: 1; }
    75%  { transform: scaleY(0.94) rotate(1deg); opacity: 0.95; }
}

/* --- Balloons --- */
.balloons-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}

.balloon {
    position: absolute;
    width: 58px;
    height: 78px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    bottom: -100px;
    opacity: 0.75;
    animation: rise 13s linear forwards;
    z-index: 5;
}

.balloon::before {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: inherit;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    border-radius: 0 50% 50% 50%;
}

.balloon::after {
    content: '';
    position: absolute;
    width: 1.5px;
    height: 68px;
    background-color: rgba(255,255,255,0.7);
    left: 50%;
    top: 78px;
    transform: translateX(-50%);
}

@keyframes rise {
    0%   { transform: translateY(0) scale(0.8); opacity: 0; }
    5%   { opacity: 0.75; transform: translateY(0) scale(1); }
    100% { transform: translateY(-120vh) scale(1); opacity: 0; }
}

/* --- Confetti --- */
.confetti-cannon-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 8;
}

.confetti {
    position: absolute;
    width: 8px;
    height: 8px;
    opacity: 0;
    animation: confettiFall 3.5s ease-out forwards;
    transform-origin: center;
}

@keyframes confettiFall {
    0%   { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* --- Fireworks --- */
.fireworks-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.firework {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    animation: launch 4s ease-out forwards;
    opacity: 0;
}

.firework::after {
    content: '';
    position: absolute;
    width: 100%; height: 100%;
    background-color: inherit;
    border-radius: 50%;
    transform: scale(0);
    animation: explode 0.8s ease-out 3s forwards;
    opacity: 0;
}

@keyframes launch {
    0%   { transform: translateY(0) translateX(0); opacity: 0; }
    10%  { opacity: 1; }
    70%  { transform: translateY(-70vh) translateX(50px); opacity: 1; }
    100% { transform: translateY(-80vh) translateX(60px); opacity: 0; }
}

@keyframes explode {
    0%   { transform: scale(0); opacity: 1; }
    100% { transform: scale(22); opacity: 0; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .welcome-title   { font-size: 2.6rem; }
    .welcome-message { font-size: 1rem; }
    .letter p        { font-size: 0.98rem; }
    .main-greeting   { font-size: 2rem; }
    .recipient-name  { font-size: 3.2rem; }
    .final-wish      { font-size: 1rem; }
    .signature       { font-size: 1.5rem; }
    .cake            { transform: scale(0.8); }
    .letter          { width: 90%; padding: 22px; }
    .envelope        { transform: scale(0.8); }
}

@media (max-width: 480px) {
    .welcome-title  { font-size: 2rem; }
    .action-button  { padding: 10px 20px; font-size: 1rem; }
    .main-greeting  { font-size: 1.7rem; }
    .recipient-name { font-size: 2.6rem; }
    .final-wish     { font-size: 0.9rem; }
    .signature      { font-size: 1.2rem; }
    .cake           { transform: scale(0.68); }
    .envelope       { transform: scale(0.72); }
}
