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

body {
    font-family: Arial, sans-serif;
    background-color: darkgray;
    height: 100vh;
}

/* Form layout: stack fields vertically and add a border */
form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 2px solid #2b6cb0;
    padding: 16px;
    border-radius: 8px;
    background-color: #ffffff;
    max-width: 480px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #2f2f2f;
    height: 100vh;
}

h1 {
    color: white;
    background-color: #2b6cb0;
    text-align: center;
    padding: 20px;
}

/* Form layout */
form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 2px solid #2b6cb0;
    padding: 16px;
    border-radius: 8px;
    background-color: #ffffff;
    max-width: 480px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

form label { display: block; font-weight: 600; color: #333333; }
form input[type="text"], form textarea { width: 100%; padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; }
form button { width: 100%; padding: 10px 16px; border: none; background-color: #2b6cb0; color: #fff; border-radius: 4px; cursor: pointer; }

/* Card layout */
.card-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    perspective: 1400px;
    z-index: 100;
}

.card {
    width: 640px;
    height: 520px; /* increased height for a taller card */
    position: relative;
}

/* COVER: single page that flips open */
.card-cover {
    position: absolute;
    inset: 0;
    transform-origin: left center;
    transition: transform 1s cubic-bezier(.2,.8,.2,1);
    backface-visibility: hidden;
    border-radius: 12px;
    z-index: 3;
    box-shadow: 0 8px 24px rgba(11,35,60,0.18);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 28px;
    background: linear-gradient(135deg,#fff7ed 0%, #fff1f2 100%);
    color: #2b6cb0;
}

.card.is-open .card-cover { transform: rotateY(-160deg); }

/* SPREAD: two pages side-by-side */
.card-spread {
    position: absolute;
    inset: 0;
    display: flex;
    z-index: 1;
    border-radius: 12px;
    overflow: hidden;
}

.page { width: 50%; height: 100%; padding: 28px; box-sizing: border-box; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.page-left { background: linear-gradient(180deg,#fffef6 0%, #fff7ed 100%); border-right: 1px solid rgba(0,0,0,0.06); position: relative; }
.page-right { background: linear-gradient(180deg,#ffffff 0%, #f7fbff 100%); position: relative; }

/* Metal Cake Stand - Stacked design */
.cake-stand {
    width: 240px;
    height: 120px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    z-index: 2;
}

/* Top plate (largest) */
.cake-stand::before {
    content: '';
    position: absolute;
    bottom: 52px;
    width: 220px;
    height: 20px;
    background: linear-gradient(180deg, #e8e8e8 0%, #b0b0b0 50%, #909090 100%);
    border-radius: 50%;
    box-shadow: 
        0 6px 12px rgba(0,0,0,0.3),
        inset 0 1px 2px rgba(255,255,255,0.5),
        0 0 15px rgba(255,255,255,0.1) inset;
}

/* Middle plate (medium) */
.cake-stand::after {
    content: '';
    position: absolute;
    bottom: 34px;
    width: 160px;
    height: 18px;
    background: linear-gradient(180deg, #d8d8d8 0%, #a0a0a0 50%, #808080 100%);
    border-radius: 50%;
    box-shadow: 
        0 4px 8px rgba(0,0,0,0.25),
        inset 0 1px 2px rgba(255,255,255,0.4);
    z-index: 1;
}

/* Base stand (small) - using border styling */
.cake-stand {
    background: linear-gradient(180deg, #c8c8c8 0%, #909090 50%, #707070 100%);
    border-radius: 50%;
    width: 100px;
    height: 16px;
    box-shadow: 
        0 3px 6px rgba(0,0,0,0.3),
        inset 0 1px 2px rgba(255,255,255,0.3);
    margin-top: auto;
    transform: translateY(100px);
    opacity: 0;
    transition: opacity 0.5s ease-in;
}

.cake-stand.show {
    opacity: 1;
}

/* Cake styling - 140px height total */
.cake {
    width: 200px;
    height: 140px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: -10px;
    z-index: 3;
    transform: translateY(-115px) rotate(180deg);
    opacity: 0;
    transition: opacity 0.5s ease-in;
}

.cake.show {
    opacity: 1;
}

/* Birthday Messages */
.birthday-messages {
    position: absolute;
    top: -50px;
    width: 200px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.5s ease-in;
    z-index: 4;
}

.birthday-messages.show {
    opacity: 1;
}

.message {
    position: absolute;
    font-size: 1.4rem;
    font-weight: bold;
    color: #2b6cb0;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.message.active {
    opacity: 1;
}

.cake-layer-1 {
    width: 200px;
    height: 60px;
    background: linear-gradient(180deg, #a0522d, #8b4513);
    border-radius: 8px 8px 0 0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.cake-layer-2 {
    width: 200px;
    height: 50px;
    background: linear-gradient(180deg, #b8632d, #9a5523);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.cake-frosting {
    width: 200px;
    height: 30px;
    background: linear-gradient(180deg, #fff8dc, #fffacd);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Candles */
.candles-container {
    width: 200px;
    height: 40px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 30px;
    transform: rotate(180deg);
}

.candle {
    width: 6px;
    height: 35px;
    background: #ff6b6b;
    border-radius: 3px;
    position: relative;
}

.candle .flame {
    position: absolute;
    bottom: 35px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 12px;
    background: radial-gradient(circle at 30% 30%, #fff3a7, #ffd166);
    border-radius: 50%;
    animation: flameFlicker 1s infinite;
}

@keyframes flameFlicker {
    0%, 100% { transform: translateX(-50%) scale(1); opacity: 1; }
    50% { transform: translateX(-50%) scale(1.1); opacity: 0.8; }
}

/* Balloons */
.balloon { width:28px; height:38px; background: #ff7fb2; border-radius: 50% 50% 50% 50%; position:absolute; bottom:20px; opacity:0; transform: translateY(20px) scale(0.8); }
.balloon .string { position:absolute; width:1px; height:28px; background: rgba(0,0,0,0.06); bottom: -8px; left:50%; transform: translateX(-50%); }
.balloon.b1 { left: 18%; background: #ff6b6b; }
.balloon.b2 { left: 36%; background: #ffd166; }
.balloon.b3 { left: 54%; background: #6be3ff; }
.balloon.b4 { left: 72%; background: #9b8cff; }

@keyframes floatUp {
    0% { transform: translateY(20px) scale(0.8) translateX(0); opacity: 0 }
    10% { opacity: 1 }
    60% { transform: translateY(-260px) scale(1.02) translateX(-6px); opacity: 1 }
    90% { transform: translateY(-480px) scale(1.04) translateX(6px); opacity: 0.9 }
    100% { transform: translateY(-720px) scale(1.06) translateX(12px); opacity: 0 }
}

@keyframes balloonFloat {
    0% { transform: translateY(20px) scale(0.8) translateX(0); opacity: 0 }
    10% { opacity: 1 }
    60% { transform: translateY(-260px) scale(1.02) translateX(-6px); opacity: 1 }
    85% { transform: translateY(-600px) scale(1.04) translateX(6px); opacity: 1 }
    92% { transform: translateY(-650px) scale(0); opacity: 0 }
    100% { transform: translateY(-650px) scale(0); opacity: 0 }
}

/* animations applied when JS adds trigger classes */
.balloon.float.b1 { animation: balloonFloat 4.2s 0.1s forwards; }
.balloon.float.b2 { animation: balloonFloat 4.4s 0.3s forwards; }
.balloon.float.b3 { animation: balloonFloat 4.6s 0.45s forwards; }
.balloon.float.b4 { animation: balloonFloat 4.8s 0.6s forwards; }

/* Fireworks: small bursts */
.firework { position:absolute; width:10px; height:10px; border-radius:50%; background: #ffd166; opacity:0; left:50%; top:30%; transform: translate(-50%, -50%) scale(0.2); }
.firework.f1 { left: 28%; top: 24%; background:#ff6b6b }
.firework.f2 { left: 42%; top: 18%; background:#ffd166 }
.firework.f3 { left: 62%; top: 20%; background:#6be3ff }

@keyframes burst { 0% { opacity:1; transform: translate(-50%,-50%) scale(0.2); } 40% { transform: translate(-50%,-50%) scale(1.4); opacity:1 } 100% { transform: translate(-50%,-50%) scale(2.8); opacity:0 } }

/* fireworks trigger class */
.firework.animate.f1 { animation: burst 0.9s 0.2s forwards; }
.firework.animate.f2 { animation: burst 0.9s 0.5s forwards; }
.firework.animate.f3 { animation: burst 0.9s 0.8s forwards; }

/* Side fireworks that shoot from the sides of the card */
.side-firework { position:absolute; width:12px; height:12px; border-radius:50%; opacity:0; top:50%; transform: translate(-50%, -50%) scale(0.2); }
.side-firework.sf1 { left: 5%; background:#ff6b6b; }
.side-firework.sf2 { left: 5%; top: 35%; background:#ffd166; }
.side-firework.sf3 { left: 5%; top: 65%; background:#6be3ff; }
.side-firework.sf4 { right: 5%; left: auto; background:#ff6b6b; }
.side-firework.sf5 { right: 5%; left: auto; top: 35%; background:#ffd166; }
.side-firework.sf6 { right: 5%; left: auto; top: 65%; background:#6be3ff; }

@keyframes shootLeft {
    0% { opacity:1; transform: translate(-50%, -50%) scale(0.2); }
    40% { transform: translate(-50%, -50%) scale(1.4); opacity:1 }
    100% { transform: translate(-200%, -50%) scale(2.8); opacity:0 }
}

@keyframes shootRight {
    0% { opacity:1; transform: translate(50%, -50%) scale(0.2); }
    40% { transform: translate(50%, -50%) scale(1.4); opacity:1 }
    100% { transform: translate(200%, -50%) scale(2.8); opacity:0 }
}

.side-firework.sf1.animate { animation: shootLeft 1.2s 0.3s forwards; }
.side-firework.sf2.animate { animation: shootLeft 1.2s 0.5s forwards; }
.side-firework.sf3.animate { animation: shootLeft 1.2s 0.7s forwards; }
.side-firework.sf4.animate { animation: shootRight 1.2s 0.3s forwards; }
.side-firework.sf5.animate { animation: shootRight 1.2s 0.5s forwards; }
.side-firework.sf6.animate { animation: shootRight 1.2s 0.7s forwards; }

/* confetti small bits (kept for backward compatibility) */
.confetti { position: absolute; width: 8px; height: 10px; border-radius: 2px; opacity: 0; transform: translateY(0); }
.confetti.c1 { left:20%; background:#ff6b6b }
.confetti.c2 { left:30%; background:#ffd166 }
.confetti.c3 { left:40%; background:#6be3ff }

@keyframes confettiDrop { 0% { transform: translateY(0); opacity:0 } 20% { opacity:1 } 100% { transform: translateY(-140px) rotate(180deg); opacity:0 } }

/* confetti trigger class */
.confetti.animate.c1 { animation: confettiDrop 2.6s 0.9s forwards; }
.confetti.animate.c2 { animation: confettiDrop 2.8s 1.0s forwards; }
.confetti.animate.c3 { animation: confettiDrop 3s 1.1s forwards; }

/* small helpers */
.page-left h3 { color:#2b6cb0; font-size:1.2rem; margin-bottom:8px; }
.page-right p { color:#21324a; font-size:1.15rem; }

/* edit button */
.card .edit-btn { margin-top: 12px; padding: 8px 12px; border: none; background-color: #2b6cb0; color: white; border-radius: 6px; cursor: pointer; }

/* responsive */
@media (max-width: 900px) { .card { width: 92vw; height: 78vh; } }
    }

    @keyframes confettiFloat {
        0% { transform: translateY(20px) rotate(0deg); opacity: 1 }
        50% { transform: translateY(-40px) rotate(180deg); opacity: 0.9 }
        100% { transform: translateY(-120px) rotate(360deg); opacity: 0 }
    }

    /* Centering tweaks: ensure card remains centered on desktop */
    @media (min-width: 900px) {
        .card-container {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
    }
}

.card-front small {
    color: #0b3b66;
}

.card-back p {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
}

.card .edit-btn {
    margin-top: 10px;
    padding: 8px 12px;
    border: none;
    background-color: #2b6cb0;
    color: white;
    border-radius: 6px;
    cursor: pointer;
}

h1 {
    color: white;
    background-color: blue;
    text-align: center;
    padding: 20px;
}