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

body {
    margin: 0;
    background: #fce4ec;
    font-family: "Poppins", sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
    cursor: pointer;
}

.container {
    text-align: center;
    width: 100%;
    max-width: 500px;
    position: relative;
}

/* Hearts Container */
.hearts-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.heart {
    position: absolute;
    width: 30px;
    height: 30px;
    opacity: 0;
    animation: heartAppear 0.6s ease-out forwards,
        heartFadeOut 1.5s ease-in 3.5s forwards;
    pointer-events: none;
}

.heart img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Heart sizes variations */
.heart.size-small {
    width: 20px;
    height: 20px;
}

.heart.size-medium {
    width: 30px;
    height: 30px;
}

.heart.size-large {
    width: 40px;
    height: 40px;
}

.heart.size-xlarge {
    width: 50px;
    height: 50px;
}

@keyframes heartAppear {
    0% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(360deg);
    }
}

@keyframes heartFadeOut {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.3) translateY(-50px) rotate(-180deg);
    }
}

/* Mailbox Styles */
.mailbox-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.mailbox {
    position: relative;
    display: inline-block;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.mailbox-img {
    width: 160px;
    max-width: 80vw;
    height: auto;
    display: block;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.mailbox-img.closed {
    opacity: 1;
    animation: floating 2s infinite ease-in-out;
}

.mailbox-img.open {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
}

.mailbox.opened .mailbox-img.closed {
    opacity: 0;
}

.mailbox.opened .mailbox-img.open {
    opacity: 1;
    animation: mailboxOpen 0.5s ease-out;
}

.mailbox:active {
    transform: scale(0.95);
}

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

@keyframes mailboxOpen {
    0% {
        transform: scale(0.95);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}
/* Letter Styles */
.letter {
    width: 100%;
    max-width: 400px;
    background: white;
    border-radius: 20px;
    padding: 30px 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
    opacity: 0;
    transform: translateY(-50px) scale(0.8);
    transition: opacity 0.6s ease, transform 0.6s ease;
    display: none;
    margin: 0 auto;
    position: relative;
    z-index: 10;

    /* sửa */
    overflow: visible;
    max-height: none;
}

.envelope-icon {
    font-size: 40px;
    text-align: center;
    margin-bottom: 15px;
    line-height: 1;
}

.message {
    /* white-space: pre-line; */
    font-size: 16px;
    color: #333;
    line-height: 1.8;
    text-align: left;
    font-weight: 400;
}

.letter.show {
    display: block;
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: letterFlyOut 1s ease-out;
}

@keyframes letterFlyOut {
    0% {
        transform: translateY(-100px) scale(0.3) rotate(-10deg);
        opacity: 0;
    }
    50% {
        transform: translateY(-20px) scale(0.9) rotate(5deg);
        opacity: 0.8;
    }
    100% {
        transform: translateY(0) scale(1) rotate(0deg);
        opacity: 1;
    }
}

.letter-content h2 {
    margin-top: 0;
    color: #e65aa8;
    font-weight: bold;
    text-align: center;
    font-size: 24px;
}

.letter-content p {
    font-size: 15px;
    color: #444;
    line-height: 1.6;
    text-align: left;
}

.sign {
    display: block;
    margin-top: 15px;
    font-weight: bold;
    color: #d1348b;
    text-align: right;
    font-size: 14px;
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    .mailbox-img {
        width: 180px;
    }

    .letter {
        padding: 25px 20px;
        max-width: 90vw;
        border-radius: 18px;
    }

    .envelope-icon {
        font-size: 35px;
        margin-bottom: 12px;
    }

    .message {
        font-size: 15px;
        line-height: 1.7;
    }

    .letter-content h2 {
        font-size: 20px;
    }

    .letter-content p {
        font-size: 14px;
        line-height: 1.5;
    }

    .sign {
        font-size: 13px;
    }
}

@media (max-width: 360px) {
    .mailbox-img {
        width: 120px;
    }

    .letter {
        padding: 20px 18px;
        border-radius: 15px;
    }

    .envelope-icon {
        font-size: 30px;
        margin-bottom: 10px;
    }

    .message {
        font-size: 14px;
        line-height: 1.6;
    }

    .letter-content h2 {
        font-size: 18px;
    }

    .letter-content p {
        font-size: 13px;
    }
}

/* Prevent text selection on tap */
.mailbox {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
