/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --pink: #ff6b9d;
    --coral: #ff85a2;
    --soft-yellow: #ffb6c1;
    --mint: #ffc0cb;
    --light-pink: #fff0f5;
    --dark-pink: #e91e63;
    --hot-pink: #ff69b4;
    --blush: #ffb7c5;
    --rose: #ff82ab;
    --white: #ffffff;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Patrick Hand', cursive;
    background: linear-gradient(135deg, var(--light-pink) 0%, var(--blush) 50%, var(--mint) 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

section {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

section.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ===== Confetti Container ===== */
#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    opacity: 0;
    animation: confetti-fall 3s ease-out forwards;
}

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

/* ===== Phase 1: Envelope ===== */
#envelope-section {
    background: linear-gradient(135deg, var(--light-pink) 0%, #ffe4ec 100%);
}

.envelope-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.envelope {
    position: relative;
    width: 320px;
    height: 220px;
    cursor: pointer;
    animation: envelope-bounce 2s ease-in-out infinite;
    transform-style: preserve-3d;
}

@keyframes envelope-bounce {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-15px) rotate(2deg); }
}

.envelope-body {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #fff5f8 0%, #ffe4ec 100%);
    border-radius: 10px;
    box-shadow: 0 10px 40px var(--shadow), 0 5px 15px rgba(255, 107, 157, 0.2);
    border: 3px solid var(--pink);
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(180deg, var(--pink) 0%, var(--coral) 100%);
    border-radius: 10px 10px 0 0;
    transform-origin: top center;
    transition: transform 0.6s ease-out;
    clip-path: polygon(0 0, 50% 100%, 100% 0);
    z-index: 2;
}

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

.envelope-seal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: var(--coral);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    box-shadow: 0 4px 15px rgba(255, 138, 128, 0.4);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.envelope-seal:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(255, 138, 128, 0.6);
}

.seal-heart {
    color: var(--white);
    font-size: 28px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.envelope-label {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Caveat', cursive;
    font-size: 32px;
    color: var(--dark-pink);
    font-weight: 600;
}

.hint-text {
    font-size: 18px;
    color: var(--pink);
    animation: fade-pulse 2s ease-in-out infinite;
}

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

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

.float-heart {
    position: absolute;
    bottom: -50px;
    left: var(--x);
    font-size: 24px;
    color: var(--pink);
    opacity: 0.6;
    animation: float-up 6s ease-in-out infinite;
    animation-delay: var(--delay);
}

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

/* ===== Phase 2: Love Letter ===== */
#letter-section {
    background: linear-gradient(135deg, var(--light-pink) 0%, var(--blush) 100%);
    padding: 40px 20px;
}

#letter-section.active {
    animation: section-fade-in 0.8s ease-out;
}

@keyframes section-fade-in {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.letter-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    max-width: 600px;
    width: 100%;
}

.letter-paper {
    position: relative;
    background: var(--white);
    padding: 40px;
    border-radius: 5px;
    box-shadow: 0 10px 40px var(--shadow), 0 1px 3px rgba(0, 0, 0, 0.05);
    transform: rotate(-1deg);
    width: 100%;
}

.letter-paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 30px;
    right: 30px;
    height: 100%;
    background: repeating-linear-gradient(
        transparent,
        transparent 31px,
        #e8e8e8 31px,
        #e8e8e8 32px
    );
    pointer-events: none;
}

.letter-content {
    position: relative;
    z-index: 1;
}

.letter-line {
    font-family: 'Caveat', cursive;
    font-size: 24px;
    line-height: 32px;
    color: #333;
    margin-bottom: 16px;
    opacity: 0;
    transform: translateY(10px);
}

.letter-line.visible {
    animation: letter-line-appear 0.6s ease-out forwards;
}

@keyframes letter-line-appear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.letter-line.signature {
    margin-top: 30px;
    font-weight: 600;
    color: var(--dark-pink);
}

.letter-doodles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.doodle {
    position: absolute;
    font-size: 24px;
    color: var(--pink);
    opacity: 0.7;
}

.doodle-1 { top: 10px; right: 20px; animation: wiggle 3s ease-in-out infinite; }
.doodle-2 { bottom: 20px; left: 15px; animation: wiggle 3s ease-in-out infinite 0.5s; color: var(--hot-pink); }
.doodle-3 { top: 50%; right: 15px; animation: wiggle 3s ease-in-out infinite 1s; }
.doodle-4 { bottom: 50px; right: 30px; font-size: 32px; animation: wiggle 3s ease-in-out infinite 1.5s; color: var(--rose); }

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

.continue-btn {
    font-family: 'Patrick Hand', cursive;
    font-size: 22px;
    padding: 15px 40px;
    background: linear-gradient(135deg, var(--pink) 0%, var(--coral) 100%);
    color: var(--white);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(255, 107, 157, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    opacity: 0;
    animation: btn-appear 0.5s ease-out forwards;
    animation-delay: 4s;
}

.continue-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(255, 107, 157, 0.5);
}

@keyframes btn-appear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Phase 3: Scrapbook ===== */
#scrapbook-section {
    background: linear-gradient(135deg, var(--mint) 0%, var(--light-pink) 50%, var(--blush) 100%);
    padding: 40px 20px;
    min-height: 100vh;
}

#scrapbook-section.active {
    display: block;
    animation: section-fade-in 0.8s ease-out;
}

.scrapbook-title {
    font-family: 'Caveat', cursive;
    font-size: 48px;
    color: var(--dark-pink);
    text-align: center;
    margin-bottom: 40px;
    text-shadow: 2px 2px 0 var(--white);
}

.scrapbook-container {
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    padding: 20px;
}

.photo-frame {
    background: var(--white);
    padding: 15px 15px 60px 15px;
    border-radius: 5px;
    box-shadow: 0 8px 30px var(--shadow);
    transform: rotate(var(--rotate, 0deg));
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.photo-frame:hover {
    transform: rotate(0deg) scale(1.05);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.photo-inner {
    width: 100%;
    aspect-ratio: 4/3;
    overflow: hidden;
    border-radius: 3px;
    background: linear-gradient(135deg, var(--light-pink), var(--rose));
}

.photo-inner img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--light-pink);
}

.photo-placeholder {
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    font-family: 'Caveat', cursive;
    font-size: 24px;
    color: var(--dark-pink);
    background: linear-gradient(135deg, var(--light-pink), var(--rose));
}

.photo-caption {
    position: absolute;
    bottom: 20px;
    left: 15px;
    right: 15px;
    font-family: 'Caveat', cursive;
    font-size: 18px;
    color: #666;
    text-align: center;
}

.hidden-message {
    display: none;
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--coral);
    color: var(--white);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(255, 138, 128, 0.4);
    z-index: 20;
}

.photo-frame.message-revealed .hidden-message {
    display: block;
    animation: pop-in 0.3s ease-out;
}

@keyframes pop-in {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.5);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}

/* Scrapbook decorations */
.scrapbook-decorations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.sticker {
    position: absolute;
    font-size: 32px;
    opacity: 0.8;
    animation: float 4s ease-in-out infinite;
}

.sticker-1 {
    top: 5%;
    right: 5%;
    color: var(--pink);
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.sticker-1:hover {
    transform: scale(1.3) rotate(15deg);
}

.sticker-2 {
    top: 30%;
    left: 2%;
    color: var(--hot-pink);
    animation-delay: 1s;
}

.sticker-3 {
    bottom: 20%;
    right: 3%;
    color: var(--dark-pink);
    animation-delay: 2s;
}

.sticker-4 {
    bottom: 10%;
    left: 5%;
    font-family: 'Caveat', cursive;
    font-size: 28px;
    color: var(--pink);
    animation-delay: 0.5s;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
}

/* Scratch to reveal */
.scratch-container {
    margin: 40px auto;
    text-align: center;
    max-width: 320px;
}

.scratch-label {
    font-family: 'Caveat', cursive;
    font-size: 22px;
    color: var(--dark-pink);
    margin-bottom: 15px;
}

.scratch-area {
    position: relative;
    width: 280px;
    height: 80px;
    margin: 0 auto;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 20px var(--shadow);
}

#scratch-canvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
    z-index: 2;
    border-radius: 10px;
}

.scratch-message {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    font-family: 'Caveat', cursive;
    font-size: 18px;
    color: var(--dark-pink);
    background: var(--white);
    border-radius: 10px;
}

/* Message tracker */
.message-tracker {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.message-tracker p {
    font-family: 'Caveat', cursive;
    font-size: 20px;
    color: var(--dark-pink);
    margin-bottom: 10px;
}

.tracker-hearts {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.tracker-heart {
    font-size: 28px;
    color: var(--pink);
    transition: transform 0.3s ease, color 0.3s ease;
}

.tracker-heart.found {
    color: var(--dark-pink);
    animation: heart-pop 0.5s ease-out;
}

@keyframes heart-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

/* Final surprise */
.final-surprise {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.final-surprise.active {
    display: flex;
    animation: fade-in 0.5s ease-out;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.final-content {
    background: var(--white);
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: scale-in 0.5s ease-out;
}

@keyframes scale-in {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.final-content h2 {
    font-family: 'Caveat', cursive;
    font-size: 36px;
    color: var(--dark-pink);
    margin-bottom: 20px;
}

.final-content p {
    font-size: 20px;
    color: #666;
    margin-bottom: 15px;
}

.final-message {
    font-family: 'Caveat', cursive;
    font-size: 28px !important;
    color: var(--pink) !important;
}

.final-content .continue-btn {
    opacity: 1;
    animation: none;
    margin-top: 20px;
}

/* Photo Modal */
.photo-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.photo-modal.active {
    display: flex;
    animation: fade-in 0.3s ease-out;
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background: var(--white);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    animation: scale-in 0.3s ease-out;
}

.modal-content img {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 5px;
}

.modal-close {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 40px;
    height: 40px;
    background: var(--pink);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.modal-close:hover {
    transform: scale(1.1);
}

.modal-caption {
    font-family: 'Caveat', cursive;
    font-size: 24px;
    color: #666;
    margin-top: 15px;
}

.modal-hidden-message {
    font-family: 'Patrick Hand', cursive;
    font-size: 18px;
    color: var(--dark-pink);
    margin-top: 10px;
    padding: 10px 20px;
    background: var(--light-pink);
    border-radius: 20px;
    display: inline-block;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .envelope {
        width: 260px;
        height: 180px;
    }

    .envelope-label {
        font-size: 26px;
    }

    .letter-paper {
        padding: 30px 20px;
    }

    .letter-line {
        font-size: 20px;
        line-height: 28px;
    }

    .scrapbook-title {
        font-size: 36px;
    }

    .photo-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 20px;
    }

    .sticker-1, .sticker-2, .sticker-3, .sticker-4 {
        display: none;
    }

    .final-content {
        padding: 30px;
        margin: 20px;
    }

    .final-content h2 {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .envelope {
        width: 220px;
        height: 150px;
    }

    .envelope-seal {
        width: 50px;
        height: 50px;
    }

    .seal-heart {
        font-size: 22px;
    }

    .envelope-label {
        font-size: 22px;
        bottom: 20px;
    }

    .letter-line {
        font-size: 18px;
        line-height: 26px;
    }

    .continue-btn {
        font-size: 18px;
        padding: 12px 30px;
    }

    .scratch-area {
        width: 250px;
    }

    #scratch-canvas {
        width: 250px;
    }
}
