/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Caveat', cursive;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* ===== SCREENS ===== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s ease, visibility 0.8s ease;
    z-index: 0;
}

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

.screen-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    z-index: 2;
}

/* ===== HANDWRITTEN FONT ===== */
.handwritten {
    font-family: 'Caveat', cursive;
    letter-spacing: 0.5px;
}

/* ===== SCREEN 1 — ENVELOPE ===== */
#screen-1 {
    background-color: #FAFAFA;
}

.title-text {
    font-size: clamp(2.2rem, 6vw, 3.5rem);
    font-weight: 700;
    color: #2D2D2D;
    margin-bottom: 10px;
}

.subtitle-text {
    font-size: clamp(1.6rem, 4.5vw, 2.8rem);
    font-weight: 500;
    color: #2D2D2D;
    margin-top: 10px;
}

.envelope-wrapper {
    width: clamp(180px, 40vw, 280px);
    height: auto;
}

.envelope-svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 8px 20px rgba(244, 167, 185, 0.4));
}

/* Floating hearts background */
.floating-hearts {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.mini-heart {
    position: absolute;
    bottom: -30px;
    left: var(--x);
    font-size: 18px;
    color: #F4A7B9;
    opacity: 0;
    animation: floatUp 8s var(--delay) infinite ease-in;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(-100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Tap hint */
.tap-hint {
    margin-top: 30px;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    color: #aaa;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ===== SCREEN 2 — MESSAGE CARD ===== */
#screen-2 {
    background: linear-gradient(135deg, #FAFAFA 0%, #FFF0F3 100%);
}

.message-card {
    background: #D32F2F;
    border-radius: 16px;
    padding: clamp(28px, 5vw, 48px) clamp(32px, 6vw, 56px);
    max-width: 520px;
    width: 90vw;
    box-shadow: 
        0 20px 60px rgba(211, 47, 47, 0.35),
        0 8px 20px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255,255,255,0.1);
    position: relative;
    overflow: hidden;
}

.message-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.08) 0%, transparent 60%);
    pointer-events: none;
}

.card-inner {
    position: relative;
    z-index: 1;
}

.card-label {
    font-size: clamp(1.3rem, 3.5vw, 1.8rem);
    color: rgba(255,255,255,0.85);
    margin-bottom: 4px;
    font-weight: 500;
}

.card-value {
    color: #FFFFFF;
    font-weight: 700;
}

.card-message-label {
    font-size: clamp(1.3rem, 3.5vw, 1.8rem);
    color: rgba(255,255,255,0.85);
    margin-top: 20px;
    margin-bottom: 6px;
    font-weight: 600;
}

.card-message {
    font-size: clamp(1.4rem, 3.8vw, 2rem);
    color: #FFFFFF;
    line-height: 1.4;
    font-weight: 500;
}

.card-attachment {
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    color: #FFFFFF;
    margin-top: 30px;
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 2px;
    text-align: center;
    opacity: 0.9;
}

/* ===== SCREEN 3 — CELEBRATION ===== */
#screen-3 {
    background: #D32F2F;
    overflow-y: auto;
    overflow-x: hidden;
    align-items: flex-start;
    cursor: default;
}

.celebration-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 70px 20px 60px;
    width: 100%;
    max-width: 650px;
    margin: 0 auto;
}

/* Bunting Banner */
.bunting {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 100;
    pointer-events: none;
}

.bunting-string {
    position: absolute;
    top: 12px;
    left: 0;
    width: 100%;
    height: 3px;
    background: #2D2D2D;
    z-index: 1;
}

.flag {
    position: relative;
    z-index: 2;
    font-size: clamp(28px, 5vw, 42px);
    color: var(--color);
    margin: 0 clamp(2px, 1vw, 6px);
    animation: flagSwing 3s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.15s);
    transform-origin: top center;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.15));
    line-height: 1;
    top: -2px;
}

@keyframes flagSwing {
    0%, 100% { transform: rotate(-4deg); }
    50% { transform: rotate(4deg); }
}

/* Photo section */
.photo-section {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    margin-top: 10px;
}

.photo-frame {
    position: relative;
    width: clamp(200px, 55vw, 300px);
    height: clamp(200px, 55vw, 300px);
    border-radius: 12px;
    overflow: visible;
    z-index: 5;
}

.childhood-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    border: 4px solid #FFFFFF;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Stickers */
.sticker {
    position: absolute;
    z-index: 10;
    pointer-events: none;
}

.party-hat {
    top: -55px;
    left: 50%;
    transform: translateX(-50%) rotate(-5deg);
    width: 80px;
    height: 80px;
}

.lightning {
    top: 15%;
    right: -30px;
    font-size: 40px;
    animation: sparkle 1.5s ease-in-out infinite alternate;
}

.star {
    animation: sparkle 2s ease-in-out infinite alternate;
}

.star-1 {
    top: -15px;
    right: -25px;
    font-size: 28px;
    animation-delay: 0s;
}

.star-2 {
    top: 30%;
    left: -30px;
    font-size: 24px;
    animation-delay: 0.4s;
}

.star-3 {
    bottom: 10%;
    right: -28px;
    font-size: 22px;
    animation-delay: 0.8s;
}

.star-4 {
    top: 5%;
    left: -20px;
    font-size: 20px;
    animation-delay: 1.2s;
}

.star-5 {
    bottom: -10px;
    left: -25px;
    font-size: 26px;
    animation-delay: 0.6s;
}

@keyframes sparkle {
    0% { transform: scale(1) rotate(0deg); opacity: 0.7; }
    100% { transform: scale(1.25) rotate(15deg); opacity: 1; }
}

/* Cake */
.cake-container {
    position: absolute;
    left: -200px;
    bottom: -10px;
    width: 90px;
    z-index: 6;
}

.cake-body {
    position: relative;
}

.cake-svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

/* Walking legs */
.cake-legs {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: -8px;
    position: relative;
    z-index: -1;
}

.cake-leg {
    width: 10px;
    height: 18px;
    background: #B71C1C;
    border-radius: 0 0 5px 5px;
    transform-origin: top center;
    position: relative;
}

.cake-foot {
    position: absolute;
    bottom: -4px;
    left: -3px;
    width: 16px;
    height: 7px;
    background: #8B1515;
    border-radius: 8px 8px 3px 3px;
}

/* Walking animation for legs */
.walking .leg-left {
    animation: stepLeft 0.4s ease-in-out infinite;
}

.walking .leg-right {
    animation: stepRight 0.4s ease-in-out infinite;
}

@keyframes stepLeft {
    0%, 100% { transform: rotate(20deg) translateY(0); }
    50% { transform: rotate(-20deg) translateY(-4px); }
}

@keyframes stepRight {
    0%, 100% { transform: rotate(-20deg) translateY(-4px); }
    50% { transform: rotate(20deg) translateY(0); }
}

/* Cake waddle while walking */
.walking .cake-body {
    animation: cakeWaddle 0.4s ease-in-out infinite;
}

@keyframes cakeWaddle {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

/* Legs disappear when arrived */
.cake-container.arrived .cake-legs {
    animation: legsVanish 0.5s ease forwards;
}

.cake-container.arrived .cake-body {
    animation: none;
    transform: rotate(0deg);
}

@keyframes legsVanish {
    0% { opacity: 1; height: 18px; }
    100% { opacity: 0; height: 0; }
}

/* ===== BIRTHDAY MESSAGE ===== */
.birthday-message {
    text-align: center;
    padding: 10px 15px 40px;
    max-width: 550px;
}

.message-line {
    font-size: clamp(1.6rem, 4.5vw, 2.4rem);
    color: #FFFFFF;
    font-weight: 700;
    margin-bottom: 16px;
}

.line-end {
    margin-top: 20px;
    margin-bottom: 6px;
}

.message-body {
    font-size: clamp(1.2rem, 3.2vw, 1.7rem);
    color: rgba(255, 255, 255, 0.93);
    line-height: 1.55;
    margin-bottom: 14px;
    font-weight: 500;
}

/* ===== ANIMATIONS ===== */

/* Float animation — organic lazy drift (figure-8 style) */
.float-animation {
    animation: floatDrift 6s ease-in-out infinite;
}

@keyframes floatDrift {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(6px, -10px); }
    50%  { transform: translate(0, -12px); }
    75%  { transform: translate(-6px, -5px); }
    100% { transform: translate(0, 0); }
}

/* Pop-in — spring/bounce scale */
.pop-in {
    animation: popIn 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    60% {
        transform: scale(1.08);
        opacity: 1;
    }
    80% {
        transform: scale(0.96);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Combine pop-in + float */
.pop-in.float-animation {
    animation: 
        popIn 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards,
        floatDrift 6s ease-in-out 0.7s infinite;
}

/* Fade in text */
.fade-in-text {
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
}

.delay-1 {
    animation-delay: 0.4s;
}

.delay-2 {
    animation-delay: 0.8s;
}

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

/* Walking cake — JS-driven, no CSS slide animation here */

/* ===== CONFETTI ===== */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    top: -10px;
    width: 10px;
    height: 10px;
    opacity: 0;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
    }
    85% {
        opacity: 0.8;
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg) scale(0.5);
    }
}

/* ===== SCREEN 3 MESSAGE ANIMATIONS ===== */
#screen-3 .birthday-message .message-line,
#screen-3 .birthday-message .message-body {
    opacity: 0;
    transform: translateY(20px);
}

#screen-3.active .birthday-message .message-line,
#screen-3.active .birthday-message .message-body {
    animation: fadeInUp 0.6s ease forwards;
}

#screen-3.active .birthday-message .line-1 { animation-delay: 0.8s; }
#screen-3.active .birthday-message .message-body:nth-child(2) { animation-delay: 1.1s; }
#screen-3.active .birthday-message .message-body:nth-child(3) { animation-delay: 1.4s; }
#screen-3.active .birthday-message .message-body:nth-child(4) { animation-delay: 1.7s; }
#screen-3.active .birthday-message .message-body:nth-child(5) { animation-delay: 2.0s; }
#screen-3.active .birthday-message .message-body:nth-child(6) { animation-delay: 2.3s; }
#screen-3.active .birthday-message .line-end:nth-child(7) { animation-delay: 2.6s; }
#screen-3.active .birthday-message .line-end:nth-child(8) { animation-delay: 2.9s; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .message-card {
        padding: 24px 28px;
        border-radius: 14px;
    }

    .cake-container {
        bottom: 0;
        width: 70px;
    }

    .photo-frame {
        width: 200px;
        height: 200px;
    }

    .party-hat {
        width: 65px;
        height: 65px;
        top: -45px;
    }

    .lightning {
        font-size: 30px;
        right: -22px;
    }

    .celebration-content {
        padding-top: 55px;
    }
}

@media (min-width: 768px) {
    .photo-section {
        margin-bottom: 40px;
    }

    .birthday-message {
        padding: 20px 30px 50px;
    }
}

/* Smooth scrollbar for screen 3 */
#screen-3::-webkit-scrollbar {
    width: 4px;
}

#screen-3::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
}

#screen-3::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
}
