:root {
    --primary: #fff;
    --bg-color: rgb(227,28,121);
    --bg-envelope-color: #f5edd1;
    --envelope-tab: #ecdeb8;
    --envelope-cover: #e6cfa7;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --txt-color: #444;
    --heart-color: rgb(252, 8, 231);
    --paper-color: #fefefe;
}

body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    height: 100vh;
    width: 100%;
    display: grid;
    place-items: center;
    position: relative;
}


.envelope-wrapper {
    background: var(--bg-envelope-color);
    box-shadow: 0 0 40px var(--shadow-color);
    z-index: 1;
}

.envelope-wrapper > .envelope {
    position: relative;
    width: 300px;
    height: 230px;
    background: var(--bg-envelope-color);
    border-radius: 5px;
    box-shadow: 0 0 40px var(--shadow-color);
    background-image: url('path/to/paper-texture.jpg');
    background-size: cover;
    overflow: hidden;
    transition: all 0.5s ease-in-out;
}

.envelope-wrapper.flap > .envelope {
    overflow: visible;
}

.envelope-wrapper > .envelope::before {
    content: "";
    position: absolute;
    top: 0;
    z-index: 2;
    border-top: 130px solid var(--envelope-tab);
    border-right: 150px solid transparent;
    border-left: 150px solid transparent;
    transform-origin: top;
    transition: all 0.5s ease-in-out 0.7s;
}

.envelope-wrapper > .envelope::after {
    content: "";
    position: absolute;
    z-index: 2;
    width: 0px;
    height: 0px;
    border-top: 130px solid transparent;
    border-right: 150px solid var(--envelope-cover);
    border-bottom: 100px solid var(--envelope-cover);
    border-left: 150px solid var(--envelope-cover);
}

.envelope > .letter {
    position: absolute;
    right: 20%;
    bottom: 0;
    width: 54%;
    background: var(--paper-color);
    text-align: center;
    transition: all 1s ease-in-out;
    box-shadow: 0 0 5px var(--shadow-color);
    padding: 20px 10px;
    z-index: 1;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background-image: url('path/to/paper-texture.jpg');
    background-size: cover;
    border-radius: 5px;
    height: auto;
    max-height: 100%;
    overflow-y: auto;
    opacity: 0;
    transform: scale(0.7);
    transform-origin: bottom;
    transition: opacity 1s ease, transform 1s ease;
}

.envelope-wrapper.flap > .envelope > .letter {
    opacity: 1;
    transform: scale(1.4);
    bottom: 45px;
    z-index: 3;
}

.envelope > .letter > .text {
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    color: var(--txt-color);
    text-align: left;
    font-size: 10px;
}

.heart {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 15px;
    height: 15px;
    background: var(--heart-color);
    z-index: 4;
    transform: translate(-50%, -20%) rotate(45deg);
    transition: transform 0.5s ease-in-out 1s, top 1s ease-in-out, opacity 0.5s ease-in-out;
    box-shadow: 0 1px 6px var(--shadow-color);
    cursor: pointer;
}

.heart:before, 
.heart:after {
    content: "";
    position: absolute;
    width: 15px;
    height: 15px;
    background-color: var(--heart-color);
    border-radius: 50%;
}

.heart:before {
    top: -7.5px;
}

.heart:after {
    right: 7.5px;
}

.flap > .envelope:before {
    transform: rotateX(180deg);
    z-index: 0;
}

.flap > .envelope > .letter {
    bottom: 100px;
    transform: scale(1.5);
    z-index: 3;
    transition-delay: 1s;
}

.flap > .heart {
    top: -50px; 
    opacity: 0; 
    transition-delay: 0s; 
}

.letter-number {
    position: absolute;
    color: white;
    bottom: 10px;
    right: 10px;
    font-size: 15px;
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    z-index: 4;
}

.next-letter {
    position: absolute;
    bottom: 50px; 
    right: 20px; 
    z-index: 2; 
}

.next-letter-btn {
    padding: 10px 20px;
    background-color: #c02573; 
    color: #fff;
    text-decoration: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s, transform 0.3s ease;
}

.next-letter-btn:hover {
    background-color: #d0246e; 
    transform: scale(1.1); 
}

.next-letter-btn:active {
    background-color: #b71f5a;
    transform: scale(1); 
}

.next-letter-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(230, 47, 137, 0.6); 
}
