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

body {
    font-family: 'Nunito', sans-serif;
    /* Soft dotted background resembling a journal */
    background-color: #fdfbf7;
    background-image: radial-gradient(#d1cfc9 1px, transparent 1px);
    background-size: 20px 20px;
    color: #333;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#bg-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1; /* Above background, behind screens */
    overflow: hidden;
}
.floating-emoji {
    position: absolute;
    opacity: 0.15; /* Subtle */
    animation: floatEmoji linear infinite alternate;
}
@keyframes floatEmoji {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(20px, -40px) rotate(20deg); }
}

h1, h2, .caption, .bonus-title {
    font-family: 'Kalam', cursive;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

#message-screen {
    overflow-y: auto;
    overflow-x: hidden;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    z-index: 10;
}

.hidden { display: none !important; }

/* Scrapbook Elements */
/* Gift Box Elements */
.gift-box {
    position: relative;
    background-color: #e6ccb2;
    width: 500px;
    height: 450px;
    max-width: 95%;
    border-radius: 6px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1), inset 0 -10px 20px rgba(0,0,0,0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    transform: rotate(-1deg);
}

.box-lid {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    height: 80px;
    background-color: #d4a373;
    border-radius: 4px;
    box-shadow: 0 5px 10px rgba(0,0,0,0.15);
    z-index: 1;
}

.ribbon-vertical, .ribbon-horizontal {
    position: absolute;
    background-color: #d94848;
    z-index: 2;
}
.ribbon-vertical {
    top: -10px;
    bottom: 0;
    left: 25%;
    transform: translateX(-50%);
    width: 45px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.15);
}
.ribbon-horizontal {
    top: 60%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    height: 45px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.15);
}

.shipping-label {
    position: relative;
    z-index: 3;
    background: #fff;
    padding: 2rem 2.5rem;
    border: 2px dashed #bbb;
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    width: 320px;
    max-width: 90%;
    transform: translate(25px, -15px) rotate(2deg);
}

.shipping-label h1 {
    font-size: 2.5rem;
    color: #333;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.barcode {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2.5px;
    height: 35px;
    margin: 1.2rem auto 0.4rem auto;
    width: fit-content;
}

.barcode span {
    display: inline-block;
    height: 100%;
    background-color: #2b2b2b;
}

.tracking-number {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    font-weight: bold;
    letter-spacing: 2px;
    color: #555;
    margin-bottom: 1.5rem;
    text-align: center;
}

.paper-btn {
    background: #fff;
    border: 2px dashed #d94848;
    color: #d94848;
    padding: 10px 25px;
    font-size: 1.2rem;
    font-family: 'Kalam', cursive;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 5px;
    box-shadow: 2px 2px 0px rgba(0,0,0,0.05);
}
.paper-btn:hover {
    background: #d94848;
    color: #fff;
    transform: scale(1.05) rotate(1deg);
}

.mt-2 { margin-top: 2rem; }

/* Polaroid Photo Style */
.polaroid {
    position: relative; /* Ensure ::before aligns correctly */
    background: white;
    padding: 10px 10px 20px 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.polaroid::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%) rotate(-3deg);
    width: 75px;
    height: 22px;
    background-color: rgba(255, 235, 150, 0.5); /* Washi tape */
    backdrop-filter: blur(1px);
    border-left: 1px dashed rgba(0,0,0,0.1);
    border-right: 1px dashed rgba(0,0,0,0.1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    z-index: 10;
}

.photo-wrapper {
    width: 100%;
    overflow: hidden;
    background: #f4f4f4;
}

.polaroid img {
    width: 100%;
    display: block;
    object-fit: cover;
}

.polaroid .caption {
    margin-top: 15px;
    font-size: 1.5rem;
    color: #333;
}

/* Polaroids */
.age-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.age-img {
    position: absolute;
    max-width: 320px;
    transition: all 0.5s ease;
}

/* Idle float for 22 */
.float-idle {
    animation: floatIdle 3s ease-in-out infinite;
}

@keyframes floatIdle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

/* Violent pop when needle hits */
.explode-pop {
    animation: explodePop 0.1s ease-out forwards;
}

@keyframes explodePop {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.4); filter: brightness(1.5); }
    100% { transform: scale(0); filter: brightness(1); opacity: 0; }
}

/* Fly up animation for 23 */
.fly-up-bounce {
    animation: flyUpBounce 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes flyUpBounce {
    0% { transform: translateY(100vh) scale(0.5) rotate(-10deg); opacity: 0; }
    50% { transform: translateY(-30px) scale(1.05) rotate(5deg); opacity: 1; }
    80% { transform: translateY(10px) scale(0.98) rotate(-2deg); opacity: 1; }
    100% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
}

/* Needle animation */
.needle {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 5;
    /* starts top right offscreen */
    transform: translate(100vw, -100vh);
}

.needle.throw {
    transition: transform 0.4s cubic-bezier(0.2, 0, 1, 1);
    transform: translate(25px, -35px); /* Hits the top right of balloon center */
}

.needle.fall {
    transition: transform 0.8s ease-in;
    transform: translate(-50vw, 100vh) rotate(-90deg); /* Falls away rapidly */
}

/* Balloon particle pop effect */
.particles-container {
    position: absolute;
    width: 200px;
    height: 200px;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    opacity: 0;
}

.particle.pop {
    animation: explode 0.6s ease-out forwards;
}

@keyframes explode {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* Confetti Party Blast */
.confetti-piece {
    position: absolute;
    opacity: 0;
}
.confetti-piece.party-blast {
    animation: confettiBlast 3s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes confettiBlast {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    20% { transform: translate(var(--tx), var(--ty)) rotate(calc(var(--rot) / 2)); opacity: 1; }
    100% { transform: translate(calc(var(--tx) * 1.5), calc(var(--ty) + 600px)) rotate(var(--rot)); opacity: 0; }
}

/* Greeting Board */
.board-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
    max-width: 800px;
    margin-bottom: 2rem;
}
.board-container .polaroid { position: relative; max-width: 200px; margin: 10px; }
.board-container .polaroid img { max-width: 100%; }

.rot-left { 
    --target-rot: rotate(-5deg); 
    --start-rot: rotate(-25deg); 
    transform: var(--target-rot); 
}
.rot-right { 
    --target-rot: rotate(4deg); 
    --start-rot: rotate(20deg); 
    transform: var(--target-rot); 
}
.rot-left-more { 
    --target-rot: rotate(-8deg); 
    --start-rot: rotate(-30deg); 
    transform: var(--target-rot); 
}

.happy-bday { max-width: 300px !important; z-index: 1; }
.happy-bday::before { transform: translateX(-50%) rotate(-6deg); }

.flork-cake { 
    max-width: 180px !important; 
    z-index: 2; 
    margin: 10px -25px !important; 
}
.flork-cake::before { transform: translateX(-50%) rotate(4deg); }

.balloons { max-width: 150px !important; z-index: 1; }
.balloons::before { transform: translateX(-50%) rotate(-2deg); }

.bonus-pict::before { transform: translateX(-50%) rotate(5deg); }

/* Greeting Screen Staggered Animations */
#greeting .polaroid {
    opacity: 0;
}
#greeting #next-btn-1 {
    opacity: 0;
}

#greeting.active .happy-bday {
    animation: dropInCard 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 2.5s;
}
#greeting.active .flork-cake {
    animation: dropInCard 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 1.5s;
}
#greeting.active .balloons {
    animation: dropInCard 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 0.5s;
}
#greeting.active #next-btn-1 {
    animation: fadeInBtn 1s ease forwards;
    animation-delay: 3.8s;
}

@keyframes dropInCard {
    0% {
        transform: translateY(-80vh) scale(1.3) var(--start-rot);
        opacity: 0;
        box-shadow: 0 30px 60px rgba(0,0,0,0.3);
    }
    100% {
        transform: translateY(0) var(--target-rot);
        opacity: 1;
    }
}

@keyframes fadeInBtn {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Letter Paper */
.letter-paper {
    background: #fff;
    width: 90%;
    max-width: 600px;
    padding: 3rem;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
    background-image: repeating-linear-gradient(transparent, transparent 29px, #e0e0e0 30px);
    background-attachment: local;
    line-height: 30px;
    font-family: 'Caveat', cursive;
    font-size: 1.5rem;
    color: #2b2b2b;
    position: relative;
    min-height: 400px;
    border-radius: 2px;
}
/* Pin */
.letter-paper::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    background: #d94848;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2), inset -2px -2px 4px rgba(0,0,0,0.2);
}

.typewriter-text {
    min-height: 250px;
    margin-top: 10px;
    white-space: pre-wrap;
}

.from-text {
    text-align: right;
    margin-top: 20px;
    opacity: 0;
    transition: opacity 1s ease;
    font-weight: 700;
}

/* Bonus Screen */
.bonus-pict {
    width: 90%;
    max-width: 600px;
    transform: rotate(3deg);
    position: relative;
}
.bonus-pict img { 
    width: 100%;
    height: auto;
}
.bonus-title {
    margin-top: 2rem;
    font-size: 2.5rem;
    color: #d94848;
    text-shadow: 1px 1px 0px rgba(0,0,0,0.1);
}

/* Closing Screen */
.closing-title {
    font-size: 3.5rem;
    color: #333;
    text-align: center;
    margin-bottom: 2rem;
    line-height: 1.2;
    z-index: 10;
}

#closing-balloons {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 2;
}

.closing-balloon {
    position: absolute;
    bottom: -120px;
    width: 60px;
    height: 75px;
    border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
    animation: floatUp 8s linear infinite;
    pointer-events: none;
}

.closing-balloon::after {
    content: "";
    position: absolute;
    bottom: -6px;
    left: 28px;
    width: 4px;
    height: 8px;
    background: inherit;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.closing-balloon-string {
    position: absolute;
    bottom: -35px;
    left: 29px;
    width: 1.5px;
    height: 30px;
    background: rgba(0,0,0,0.15);
}

@keyframes floatUp {
    0% {
        transform: translateY(0) rotate(0deg) scale(var(--scale, 1));
        opacity: 0;
    }
    10% {
        opacity: 0.85;
    }
    90% {
        opacity: 0.85;
    }
    100% {
        transform: translateY(-115vh) rotate(30deg) scale(var(--scale, 1));
        opacity: 0;
    }
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .gift-box {
        width: 90%;
        height: 380px;
    }
    .box-lid { height: 50px; }
    .ribbon-vertical { width: 35px; }
    .ribbon-horizontal { height: 35px; }
    .shipping-label {
        padding: 1.5rem 1rem;
        width: 260px;
        transform: translate(10px, -10px) rotate(2deg);
    }
    .shipping-label h1 {
        font-size: 1.8rem;
        line-height: 1.2;
    }
    .barcode {
        height: 25px;
        margin: 0.8rem auto 0.2rem auto;
    }
    
    .board-container { gap: 10px; }
    .happy-bday { max-width: 240px !important; }
    .flork-cake { max-width: 160px !important; margin: 10px !important; }
    .balloons { max-width: 130px !important; }
    
    .letter-paper {
        width: 95%;
        padding: 1.5rem 1.2rem;
        font-size: 1.15rem;
        line-height: 24px;
        background-image: repeating-linear-gradient(transparent, transparent 23px, #e0e0e0 24px);
        background-position: 0 10px;
        min-height: auto;
    }
    .typewriter-text { min-height: 120px; }
    
    .from-text { margin-top: 10px; }
    
    .bonus-title { font-size: 2rem; }
    
    .closing-title { font-size: 2.2rem; padding: 0 1rem; }
    .closing-subtitle { font-size: 1.2rem; }
    
    #message-screen {
        justify-content: center; /* Keep centered since it fits now! */
        padding: 1rem 0;
    }
}
