
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #F5F0E9;
    color: #493D3B;
    font-family: 'DM Sans', sans-serif;
    min-height: 100vh;
}

[hidden] {
    display: none !important;
}

.container {
    width: 100%;
    max-width: 700px;
    margin: auto;
    padding: 60px 20px;
    text-align: center;
}

.eyebrow {
    color: #A47E79;
    font-size: 11px;
    letter-spacing: 3px;
    margin-bottom: 20px;
}

h1, h2 {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
}

h1 {
    font-size: clamp(30px, 7vw, 42px);
}

.subtitle {
    color: #887A72;
    margin-top: 12px;
    font-size: 14px;
}

.instruction {
    color: #A47E79;
    font-size: 12px;
    margin-top: 25px;
    letter-spacing: 1px;
}


/* Envelope */

.envelope-button {
    background: none;
    border: none;
    cursor: pointer;
    margin-top: 65px;
    padding: 0;
}

.envelope {
    position: relative;
    width: 260px;
    height: 170px;
    margin: auto;
    perspective: 800px;
}

.envelope-back {
    position: absolute;
    inset: 0;
    background: #D8C9B8;
    border-radius: 4px;
}

.letter-preview {
    position: absolute;
    width: 88%;
    height: 85%;
    background: #FFFDF9;
    left: 6%;
    bottom: 5%;
    transition: transform 0.8s ease;
}

.envelope-front {
    position: absolute;
    inset: 0;
    background: #E9D5D2;
    clip-path: polygon(0 0, 50% 58%, 100% 0, 100% 100%, 0 100%);
}

.envelope-flap {
    position: absolute;
    inset: 0;
    background: #D9BFBB;
    clip-path: polygon(0 0, 100% 0, 50% 58%);
    transform-origin: top;
    transition: transform 0.7s ease;
    z-index: 2;
}

.wax-seal {
    position: absolute;
    z-index: 3;
    top: 48%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 35px;
    height: 35px;
    background: #A47E79;
    color: #FFFDF9;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 17px;
    transition: opacity 0.3s ease;
}


/* Opening animation */


/* Opening animation */

.envelope-flap {
    backface-visibility: hidden;
}

.envelope.open .envelope-flap {
    transform: rotateX(180deg);
    z-index: 0;
}

.envelope.open .wax-seal {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
}

.envelope.open .letter-preview {
    transform: translateY(-120px);
    transition: transform 0.9s ease;
}

.opening-screen {
    transition: opacity 0.6s ease;
}

.opening-screen.fade-out {
    opacity: 0;
}

.letter-screen {
    animation: fadeIn 1s ease;
}

/* Letter */

.letter-screen {
    animation: fadeIn 1s ease;
}

.letter-paper {
    background: #FFFDF9;
    text-align: left;
    padding: 45px;
    margin-top: 30px;
    border: 1px solid #E9DDD2;
    box-shadow: 0 10px 35px rgba(73, 61, 59, 0.07);
}

.letter-date {
    font-size: 11px;
    color: #A47E79;
    text-align: right;
    margin-bottom: 35px;
}

.letter-paper h2 {
    font-size: 28px;
    margin-bottom: 25px;
}

.letter-content {
    font-size: 14px;
    line-height: 2;
    color: #665751;
}

.letter-content p {
    margin-bottom: 22px;
}

.letter-photo {
    display: block;
    width: 100%;
    max-height: 380px;
    object-fit: cover;
    border-radius: 3px;
    margin: 25px auto;
}

.letter-signature {
    font-family: 'Playfair Display', serif;
    font-size: 16px;
    line-height: 1.8;
    margin-top: 35px;
}

.letter-signature span {
    font-style: italic;
    color: #A47E79;
}


/* Hidden messages */

.little-messages {
    margin-top: 65px;
}

.little-messages h2 {
    font-size: 25px;
}

.message-subtitle {
    color: #887A72;
    font-size: 13px;
    margin: 12px 0 25px;
}

.message-button {
    display: block;
    width: 100%;
    padding: 16px;
    margin: 12px 0;
    background: transparent;
    border: 1px solid #D9BFBB;
    border-radius: 4px;
    color: #795F5B;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.3s, color 0.3s;
}

.message-button:hover,
.message-button:focus {
    background: #E9D5D2;
    color: #493D3B;
}

.message-display {
    background: #FFFDF9;
    padding: 25px;
    margin-top: 20px;
    border-left: 3px solid #D9BFBB;
    font-family: 'Playfair Display', serif;
    font-size: 17px;
    line-height: 1.8;
    animation: fadeIn 0.5s ease;
}

.ending {
    color: #A47E79;
    font-size: 12px;
    margin-top: 55px;
    letter-spacing: 1px;
}


/* Music button */

.music-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #A47E79;
    color: white;
    border: none;
    border-radius: 30px;
    padding: 12px 18px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(73, 61, 59, 0.15);
}


/* Floating hearts */

.heart {
    position: fixed;
    bottom: -30px;
    color: #C99E9A;
    pointer-events: none;
    animation: floatUp 4s ease-in forwards;
    z-index: 10;
}

@keyframes floatUp {
    to {
        transform: translateY(-110vh) rotate(30deg);
        opacity: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/*stationery*/

.letter-paper {
    background: #FDFBF7;
    box-shadow:
        0 10px 35px rgba(91, 62, 53, 0.10),
        0 2px 8px rgba(91, 62, 53, 0.05);

    border: 1px solid #EAE1D8;
}

.letter-paper h1 {
    font-family: "Playfair Display", serif;
    color: #8F6865;
    letter-spacing: 1px;
}

.letter-paper p {
    font-family: "DM Sans", sans-serif;
    color: #5C4A45;
    line-height: 1.9;
    font-size: 15px;
}

.letter-photo {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 24px auto;
    border: 6px solid #FFFFFF;
    box-shadow: 0 4px 15px rgba(91, 62, 53, 0.12);
    border-radius: 2px;
}

.letter-paper .signature {
    font-family: "Playfair Display", serif;
    color: #A47E79;
    font-size: 22px;
    font-style: italic;
}


/* Hidden message animation */

#messageDisplay {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

#messageDisplay.show-message {
    opacity: 1;
    transform: translateY(0);
}

/* Mobile layout*/

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

@media (max-width: 600px) {

    .letter-screen {
        padding: 20px 14px;
    }

    .letter-paper {
        width: 100%;
        max-width: 100%;
        padding: 24px 18px;
        margin: 0 auto;
    }

    .letter-paper h1 {
        font-size: 25px;
    }

    .letter-paper p {
        font-size: 14px;
        line-height: 1.8;
        overflow-wrap: break-word;
    }

    .letter-photo {
        width: 100%;
        max-width: 100%;
        height: auto;
    }

    .letter-paper button {
        max-width: 100%;
        white-space: normal;
        padding: 10px 14px;
    }

    #messageDisplay {
        max-width: 100%;
        overflow-wrap: break-word;
    }

    #musicButton {
        font-size: 12px;
        padding: 9px 12px;
    }
}


/* Mobile readability */

@media (max-width: 480px) {
    .letter-paper p {
        font-size: 14px;
        line-height: 1.85;
    }
}


/* Mobile layout */

@media (max-width: 480px) {

    .container {
        padding: 45px 18px;
    }

    .envelope {
        width: 230px;
        height: 150px;
    }

    .letter-paper {
        padding: 28px 22px;
    }

    .letter-content {
        font-size: 13px;
    }

    .letter-photo {
        max-height: 300px;
    }

    .music-button {
        bottom: 12px;
        right: 12px;
    }
}
