* {
    box-sizing:border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff8f5;
    font-family: Arial, sans-serif;
}

.welcome {
    text-align: center;
}

.envelope {
    position: relative;
    width: 260px;
    height: 190px;
    margin: 0 auto 35px;
    background: #f3c6d3;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

.flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: #e8aebe;
    clip-path: polygon(0 0,50% 100%,100% 0);
    z-index: 3;
    transform-origin: top center;
    transition: transform 0.8s ease;
}

.heart {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 35px;
    color: white;
    z-index: 4;
    transition: opacity 0.3s ease;
}


.letter {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 220px;
    height: 140px;
    padding: 20px;
    background: #fffdfb;
    border-radius: 5px;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1;
    opacity: 0;
    transition: transform 0.8s ease, opacity 0.5s ease;
}

.letter p {
    margin: 40px 0 0;
    color: #5c4149;
    width: 100%;
    text-align: center;
    font-family: "Marck Script", cursive;
    font-size: 18px;
}

h1 {
    margin-top: 25px;
    font-size: 28px;
    font-weight: normal;
    color: #5c4149;
}

button {
    padding: 12px 25px;
    border: none;
    border-radius: 20px;
    background: #e9aabd;
    color: white;
    font-size: 16px;
    cursor: pointer;
}

button:hover {
    background: #df91a9;
}

.envelope.open .flap {
    transform: rotateX(180deg);
}

.envelope.open .heart {
    opacity: 0;
}

.envelope.open .letter {
    opacity: 1;
    transform: translate(-50%, -85%);
}

#letterButton {
    display: none;
}

.letter-page {
    display: none;
    min-height: 100vh;
    width: 100%;
    justify-content: center;
    align-items: center;
    background: #fff8f5;
}

.letter-content {
    width: 80%;
    max-width: 700px;
    padding: 40px;
    background: #fffdfb;
    border: 3px solid #e9aabd;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.letter-content p {
    width: 100%;
    font-family: "Marck Script", cursive;
    font-size: 20px;
    line-height: 1.5;
    color: #5c4149;
}

.memories-page {
    display: none;
    min-height: 100vh;
    width: 100%;
    justify-content: center;
    align-items: center;
    background: #fdefe9;
}

.memories-content {
    width: 90%;
    max-width: 900px;
    padding: 40px;
    text-align: center;
}

.memories {
    display: flex;
    justify-content: center;
    gap: 25px;
    flex-wrap: wrap;
    margin: 30px 0;
}

.memory {
    width: 220px;
    height: 240px;
    perspective: 1000px;
    cursor: pointer;
    padding: 10px;
}

.memory-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style:preserve-3d;
    transition: transform 0.6s ease;
}

.memory.flipped .memory-inner {
    transform: rotateY(180deg);
}

.memory-front,
.memory-back {
    position: absolute;
    inset: 0;
    box-sizing: border-box;
    backface-visibility: hidden;
    border: 3px solid #e9aabd;
    border-radius: 12px;
    background: #fffdfb;
    padding: 10px;
}

.memory-front {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.memory-front p {
    margin: 0;
    font-family: "Marck Script", cursive;
    font-size: 19px;
    color: #5c4149;
}

.memory-back {
    transform: rotateY(180deg);
}

.memory-back img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.reasons-page {
    display: none;
    min-height: 100vh;
    width: 100%;
    justify-content: center;
    align-items: center;
    background: #fdefe9;
}

.reasons-content {
    width: 90%;
    max-width: 700px;
    padding: 40px;
    text-align: center;
}

.reasons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 30px 0;
}

.reason {
    width: 100%;
    height: 80px;
    perspective: 1200px;
    cursor: pointer;
}

.reason-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 1s ease-in-out;
}

.reason.flipped .reason-inner {
    transform: rotateX(180deg);
}

.reason-front,
.reason-back {
    position: absolute;
    inset: 0;
    box-sizing: border-box;
    backface-visibility: hidden;
    padding: 15px 25px;
    background: #fffdfb;
    border: 2px solid #e9aabd;
    border-radius: 15px;

    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.reason-front span {
    font-family: "Marck Script", cursive;
    font-size: 28px;
    color: #e9aabd;
}

.reason-back {
    transform: rotateX(180deg);
}

.reason-back p {
    margin: 0;
    font-family: "Marck Script", cursive;
    font-size: 19px;
    color: #5c4149;
}

.final-page {
    display: none;
    min-height: 100vh;
    width: 100%;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    background: #f8dfe3;
    padding: 50px 0;
    box-sizing: border-box;
}

.final-content {
    width: 85%;
    max-width: 700px;
    padding: 45px 55px;
    box-sizing: border-box;

    background: #fff8ee;
    border: 1px solid #e8c8b8;
    border-radius: 7px;

    text-align: center;

    box-shadow: 0 8px 25px rgba(120, 70, 70, 0.12);
}

.final-decor {
    font-family: "Marck Script", cursive;
    color: #d995aa;
    font-size: 22px;
}

.final-date {
    margin: 18px 0 5px;
    font-family: "Marck Script", cursive;
    font-size: 18px;
    color: #9b727d;
}

.final-content h2 {
    margin: 5px 0 18px;
    font-family: "Marck Script", cursive;
    font-size: 32px;
    font-weight: normal;
    color: #5c4149;
}

.final-line {
    margin-bottom: 30px;
    color: #d995aa;
    font-size: 14px;
}

.final-letter {
    text-align: left;
}

.final-letter p {
    margin: 0 0 18px;
    font-family: "Marck Script", cursive;
    font-size: 21px;
    line-height: 1.5;
    color: #5c4149;
}

.final-decor.bottom {
    margin-top: 25px;
}

.final-thanks {
    margin: 25px 0 0;
    font-family: "Marck Script", cursive;
    font-size: 27px;
    color: #8f5c6b;
}


.hearts {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.hearts span {
    position: absolute;
    bottom: -50px;
    font-size: 25px;
    color: #e9aabd;
    opacity: 0.5;
    animation: floatHeart 8s linear infinite;
}

.hearts span:nth-child(1) {
    left: 10%;
    animation-delay: 0s;
}

.hearts span:nth-child(2) {
    left: 25%;
    animation-delay: 2s;
}

.hearts span:nth-child(3) {
    left: 40%;
    animation-delay: 4s;
}

.hearts span:nth-child(4) {
    left: 55%;
    animation-delay: 1s;
}

.hearts span:nth-child(5) {
    left: 70%;
    animation-delay: 3s;
}

.hearts span:nth-child(6) {
    left: 82%;
    animation-delay: 5s;
}

.hearts span:nth-child(7) {
    left: 92%;
    animation-delay: 6s;
}

@keyframes floatHeart {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }

    20% {
        opacity: 0.5;
    }

    80% {
        opacity: 0.5;
    }

    100% {
        transform: translateY(-110vh) rotate(20deg);
        opacity: 0;
    }
}

.welcome,
.letter-page,
.memories-page,
.reasons-page,
.final-page {
    position: relative;
    z-index: 1;
}

.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 2;
}

.stars span {
    position: absolute;
    top: -40px;
    color: #d995aa;
    opacity: 0.65;
    text-shadow: 0 0 6px rgba(217,149,170, 0.5);
    animation: fallingStars 9s linear infinite;
}

.stars span:nth-child(1) {
    left: 8%;
    font-size: 20px;
    animation-delay: 0s;
}

.stars span:nth-child(2) {
    left: 18%;
    font-size: 14px;
    animation-delay: 2s;
}

.stars span:nth-child(3) {
    left: 30%;
    font-size: 24px;
    animation-delay: 4s;
}

.stars span:nth-child(4) {
    left: 43%;
    font-size: 17px;
    animation-delay: 1s;
}

.stars span:nth-child(5) {
    left: 57%;
    font-size: 22px;
    animation-delay: 5s;
}

.stars span:nth-child(6) {
    left: 68%;
    font-size: 15px;
    animation-delay: 3s;
}

.stars span:nth-child(7) {
    left: 78%;
    font-size: 25px;
    animation-delay: 6s;
}

.stars span:nth-child(8) {
    left: 87%;
    font-size: 16px;
    animation-delay: 2.5s;
}

.stars span:nth-child(9) {
    left: 94%;
    font-size: 21px;
    animation-delay: 4.5s;
}

.stars span:nth-child(10) {
    left: 52%;
    font-size: 13px;
    animation-delay: 7s;
}

@keyframes fallingStars {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }

    15% {
        opacity: 0.45;
    }

    80% {
        opacity: 0.45;
    }

    100% {
        transform: translateY(110vh) rotate(180deg);
        opacity: 0;
    }
}

.final-content,
.final-thanks {
    position: relative;
    z-index: 1;
}

.final-content {
    position: relative;
}

.corner {
    position: absolute;
    font-family: sans-serif;
    font-size: 22px;
    color: #d995aa;
    line-height: 1;
}

.corner-top-left {
    top: -11px;
    left: -7px;
}

.corner-top-right {
    top: -11px;
    right: -11px;
}

.corner-bottom-left {
    bottom: -11px;
    left: -8px;
}

.corner-bottom-right {
    bottom: -11px;
    right: -11px;
}