:root {
    --brand-main: #E5007D;
    --brand-main-dark: #b30062;
    --brand-main-soft: #FDE4F3;
    --brand-accent: #FFD36A;
    --text-main: #333333;
    --text-muted: #666666;
    --card-bg: #FFF9FD;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    min-height: 100vh;
    color: var(--text-main);
    background:
        radial-gradient(circle at 0% 0%, #ffeef9 0, transparent 45%),
        radial-gradient(circle at 100% 0%, #ffe1f4 0, transparent 50%),
        linear-gradient(180deg, #ffe4f5 0, #f9d2ee 50%, #f5c5e8 100%);
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.envlope-wrapper {
    height: 380px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 20vh;
    position: relative;
}

.envlope-wrapper::before {
    content: "";
    position: absolute;
    width: 340px;
    height: 340px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(229,0,125,0.25), transparent 70%);
    filter: blur(8px);
    z-index: 0;
}

#envelope {
    position: relative;
    width: 280px;
    height: 180px;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    margin-left: auto;
    margin-right: auto;
    background-color: var(--brand-main);
    box-shadow:
        0 18px 45px rgba(0,0,0,.35),
        0 0 0 1px rgba(255,255,255,0.3);
    cursor: pointer;
    z-index: 1;
    transform-origin: center;
    transform: translateY(0) scale(1);
    transition: transform .25s ease, box-shadow .25s ease;
}

#envelope:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow:
        0 24px 55px rgba(0,0,0,.4),
        0 0 0 1px rgba(255,255,255,0.4);
}

.front { 
    position: absolute;
    width: 0;
    height: 0;
    z-index: 3;
}

.flap {
    border-left: 140px solid transparent;
    border-right: 140px solid transparent;
    border-bottom: 82px solid transparent;
    border-top: 100px solid var(--brand-main-dark);
    transform-origin: top;
    pointer-events: none;
}

.pocket {
    border-left: 140px solid var(--brand-main);
    border-right: 140px solid var(--brand-main);
    border-bottom: 92px solid #D60075;
    border-top: 90px solid transparent;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
}

.letter {
    position: relative;
    background-color: #fff;
    width: 90%;
    margin-left: auto;
    margin-right: auto;
    height: 90%;
    top: 5%;
    border-radius: 8px;
    box-shadow: 0 2px 26px rgba(0,0,0,.14);
    overflow: hidden;
}

.letter:after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(
        180deg, 
        rgba(255,255,255,0.00) 25%, 
        rgba(215,227,239,0.55) 55%, 
        rgba(215,227,239,0.9) 100%
    );
}

.words {
    position: absolute;
    left: 10%;
    width: 80%;
    height: 14%;
    background-color: #EEEFF0;
    border-radius: 4px;
}

.words.line1 { top: 15%; width: 24%; height: 7%; }
.words.line2 { top: 32%; }
.words.line3 { top: 52%; }
.words.line4 { top: 72%; }

.open .flap {
    transform: rotateX(180deg);
    transition: transform .4s ease, z-index .6s;
    z-index: 1;
}
.close .flap {
    transform: rotateX(0deg);
    transition: transform .4s .6s ease, z-index 1s;
    z-index: 5;
}
.close .letter {
    transform: translateY(0px); 
    transition: transform .4s ease, z-index 1s;
    z-index: 1;
}
.open .letter {
    transform: translateY(-60px);
    transition: transform .4s .6s ease, z-index .6s;
    z-index: 2;
}

.hearts {
    position: absolute;
    top: 90px;
    left: 0;
    right: 0;
    z-index: 2;
}
.heart {
    position: absolute;
    bottom: 0;
    right: 10%;
    pointer-events: none;
}
.heart:before,
.heart:after {
    position: absolute;
    content: "";
    left: 50px;
    top: 0;
    width: 50px;
    height: 80px;
    background: #D00000;
    border-radius: 50px 50px 0 0;
    transform: rotate(-45deg);
    transform-origin: 0 100%;
    pointer-events: none;
}
.heart:after {
    left: 0;
    transform: rotate(45deg);
    transform-origin: 100% 100%;
}
.close .heart {
    opacity: 0;
    animation: none;
}
.a1 {
    left: 20%;
    transform: scale(0.6);
    opacity: 1;
    animation: slideUp 4s linear 1, sideSway 2s ease-in-out 4 alternate;
    animation-fill-mode: forwards;
    animation-delay: .7s;
}
.a2 {
    left: 55%;
    transform: scale(1);
    opacity: 1;
    animation: slideUp 5s linear 1, sideSway 4s ease-in-out 2 alternate;
    animation-fill-mode: forwards;
    animation-delay: .7s;
}
.a3 {
    left: 10%;
    transform: scale(0.8);
    opacity: 1;
    animation: slideUp 7s linear 1, sideSway 2s ease-in-out 6 alternate;
    animation-fill-mode: forwards;
    animation-delay: .7s;
}
@keyframes slideUp {     
    0% { top: 0; }
    100% { top: -600px; }
}
@keyframes sideSway {
    0% { margin-left: 0px; }
    100% { margin-left: 50px; }
}

#big-letter-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at top, rgba(0,0,0,0.45), rgba(0,0,0,0.65));
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .45s ease;
    z-index: 900;
    backdrop-filter: blur(8px);
}

#big-letter-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.big-letter {
    position: relative;
    background: radial-gradient(circle at 0% 0%, #fffdfd 0, #fff7fb 40%, #ffeaf7 100%);
    max-width: 980px;
    width: 92%;
    max-height: 86vh;
    overflow: hidden;
    border-radius: 26px;
    padding: 30px 32px 32px;
    box-shadow:
        0 26px 65px rgba(0,0,0,0.38),
        0 0 0 1px rgba(255,255,255,0.6);
    border: 1px solid #f4c6e4;
    transform-origin: center;
    opacity: 0;
    transform: translateY(30px) scale(0.96);
}


#big-letter-overlay.show .big-letter {
    animation: cardIn .6s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes cardIn {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(0.94);
    }
    60% {
        opacity: 1;
        transform: translateY(-4px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.big-letter::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    border-style: solid;
    border-width: 0 28px 28px 0;
    border-color: transparent #f6d2ea transparent transparent;
    border-radius: 0 0 0 10px;
}

.big-letter::after {
    content: "";
    position: absolute;
    inset: 12px;
    border-radius: 20px;
    pointer-events: none;
}

.big-letter-inner {
    position: relative;
    z-index: 1;
    max-height: calc(86vh - 60px);
    overflow-y: auto;
    padding-right: 12px;
}


.big-letter-header {
    text-align: center;
    margin-bottom: 18px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 15px;
    border-radius: 999px;
    background: rgba(229, 0, 125, 0.08);
    color: var(--brand-main);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.badge::before,
.badge::after {
    content: "✶";
    font-size: 10px;
}

.big-letter h1 {
    margin: 10px 0 6px;
    font-size: 26px;
    color: #E1037B;
    text-align: center;
    letter-spacing: 0.02em;
}

.title-underline {
    width: 80px;
    height: 3px;
    border-radius: 999px;
    margin: 0 auto 18px;
    background: linear-gradient(90deg, #ffd3ec, #e5007d, #ffd3ec);
    position: relative;
    overflow: hidden;
}
.title-underline::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.9), transparent);
    transform: translateX(-100%);
    animation: shine 2.4s ease-in-out infinite;
}
@keyframes shine {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
    100% { transform: translateX(100%); }
}

.big-letter .intro {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 26px;
    font-size: 15px;
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
}

.letter-row {
    display: flex;
    gap: 22px;
    align-items: center;
    margin-bottom: 22px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255,255,255,0.96);
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    position: relative;
    overflow: hidden;
    transition: transform .22s ease, box-shadow .22s ease, background .22s ease;
    opacity: 0;
    transform: translateY(10px);
}

#big-letter-overlay.show .letter-rows .letter-row {
    animation: rowIn .55s ease forwards;
}

#big-letter-overlay.show .letter-rows .letter-row:nth-child(1) { animation-delay: .10s; }
#big-letter-overlay.show .letter-rows .letter-row:nth-child(2) { animation-delay: .22s; }
#big-letter-overlay.show .letter-rows .letter-row:nth-child(3) { animation-delay: .34s; }
#big-letter-overlay.show .letter-rows .letter-row:nth-child(4) { animation-delay: .46s; }


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

.letter-row::before {
    content: "";
    position: absolute;
    left: 0;
    top: 18px;
    bottom: 18px;
    width: 3px;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffd3ec, #e5007d);
    opacity: 0.7;
}
.letter-row.reverse::before {
    left: auto;
    right: 0;
}

.letter-row:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 26px rgba(0,0,0,0.16);
    background: rgba(255,255,255,0.99);
}

.letter-row.reverse {
    flex-direction: row-reverse;
}

.letter-row img {
    width: 38%;
    max-width: 260px;
    border-radius: 15px;
    object-fit: cover;
    box-shadow: 0 8px 22px rgba(0,0,0,0.18);
}

.letter-text {
    flex: 1;
    font-size: 15px;
    color: #434343;
    text-align: left;
    line-height: 1.6;
}

.letter-footer {
    margin-top: 28px;
    text-align: center;
    padding-top: 24px;
    border-top: 1px dashed #F3C7E5;
}

.stamp {
    width: 150px;
    height: 150px;
    margin: 0 auto 14px;
    border-radius: 50%;
    position: relative;
    transform: rotate(-10deg);
    opacity: 0.92;

    border: 4px solid rgba(229, 0, 125, 0.9);
    box-shadow:
        0 0 0 3px rgba(229, 0, 125, 0.25),
        0 10px 22px rgba(0, 0, 0, 0.4);

    background:
        radial-gradient(circle at 30% 30%, rgba(255,255,255,0.35), transparent 55%),
        radial-gradient(circle at 80% 80%, rgba(0,0,0,0.06), transparent 60%),
        #fffdfc;

    display: flex;
    align-items: center;
    justify-content: center;
}

.stamp::before {
    content: "";
    position: absolute;
    inset: 9px;
    border-radius: 50%;
    border: 2px solid rgba(229, 0, 125, 0.55);
    box-shadow:
        0 0 0 1px rgba(229, 0, 125, 0.25),
        0 0 8px rgba(229, 0, 125, 0.4);
    opacity: 0.95;
}

.stamp::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(229,0,125,0.20) 0, transparent 55%),
        radial-gradient(circle at 70% 40%, rgba(229,0,125,0.18) 0, transparent 60%),
        radial-gradient(circle at 30% 80%, rgba(229,0,125,0.16) 0, transparent 65%);
    mix-blend-mode: multiply;
    opacity: 0.9;
}

.stamp img {
    max-width: 72%;
    max-height: 72%;
    display: block;

    filter:
        grayscale(1)
        contrast(2.4)
        brightness(0.3);
    mix-blend-mode: multiply;
    opacity: 0.9;
}

.stamp img {
    max-width: 70%;
    max-height: 70%;
    display: block;
    filter: contrast(1.05) saturate(1.1);
}

.letter-footer .thankyou {
    font-size: 20px;
    font-weight: 700;
    color: var(--brand-main);
    margin-bottom: 6px;
}

.letter-footer .note {
    color: var(--text-muted);
    font-size: 15px;
    max-width: 560px;
    margin: 0 auto;
}

@media (max-width: 700px) {
    .letter-row,
    .letter-row.reverse {
        flex-direction: column;
    }

    .letter-row img {
        width: 100%;
        max-width: none;
    }

    .letter-text {
        text-align: left;
    }

    .big-letter {
        padding: 22px 16px 24px;
    }
}

#confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1000;
}

.confetti {
    position: absolute;
    width: 8px;
    height: 16px;
    border-radius: 2px;
    opacity: 0.9;
    animation: confFall linear forwards;
}
@keyframes confFall {
    0% {
        transform: translateY(-100vh) rotateZ(0deg);
    }
    100% {
        transform: translateY(100vh) rotateZ(360deg);
    }
}

.big-letter-inner {
    scrollbar-width: thin;
    scrollbar-color: #E5007D rgba(255,255,255,0.4);
}

.big-letter-inner::-webkit-scrollbar {
    width: 8px;
}

.big-letter-inner::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.big-letter-inner::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #ffb6de, #E5007D);
    border-radius: 10px;
    border: 2px solid rgba(255,255,255,0.8);
}

.big-letter-inner::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #ff8fcb, #c80068);
}

.letter-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--brand-main);
    margin-bottom: 12px;
}