:root {
    --primary-pink: #ff6b81;
    --secondary-pink: #ff8fa3;
    --light-pink: #ffe6ea;
    --envelope-color: #ff4757;
    --envelope-inside: #ff6b81;
    --paper-color: #fff;
    --text-color: #2c3e50;
    --shadow-color: rgba(0, 0, 0, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    background-color: var(--light-pink);
    font-family: 'Noto Serif SC', serif;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
}

#heart-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 50px;
}

/* Envelope Styles */
.envelope-wrapper {
    width: 300px;
    height: 200px;
    position: relative;
    cursor: pointer;
    transition: transform 0.5s ease;
}

.envelope-wrapper:hover {
    transform: scale(1.05);
}

.envelope {
    width: 100%;
    height: 100%;
    position: relative;
    background-color: var(--envelope-color);
    box-shadow: 0 10px 20px var(--shadow-color);
    transform-style: preserve-3d;
}

.front {
    position: absolute;
    width: 0;
    height: 0;
    z-index: 3;
    border-top: 100px solid transparent;
    border-right: 150px solid var(--envelope-inside);
    border-bottom: 100px solid var(--envelope-inside);
    border-left: 150px solid var(--envelope-inside);
    top: 0;
    left: 0;
}

.front .text {
    position: absolute;
    top: 50px;
    left: -50px;
    width: 100px;
    text-align: center;
    color: white;
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 1.2rem;
    transform: rotate(-5deg);
}

.stamp {
    position: absolute;
    top: 20px;
    right: -110px;
    width: 40px;
    height: 50px;
    background: white;
    z-index: 4;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
    transform: rotate(10deg);
}

.heart-shape {
    width: 20px;
    height: 20px;
    background-color: var(--primary-pink);
    transform: rotate(-45deg);
    position: relative;
}

.heart-shape::before,
.heart-shape::after {
    content: "";
    width: 20px;
    height: 20px;
    background-color: var(--primary-pink);
    border-radius: 50%;
    position: absolute;
}

.heart-shape::before {
    top: -10px;
    left: 0;
}

.heart-shape::after {
    left: 10px;
    top: 0;
}

.top-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 150px solid transparent;
    border-right: 150px solid transparent;
    border-top: 110px solid var(--envelope-color);
    z-index: 5;
    transform-origin: top;
    transition: transform 0.6s ease 0.5s, z-index 0.2s ease 0.5s;
}

.envelope.open .top-flap {
    transform: rotateX(180deg);
    z-index: 1;
    transition: transform 0.6s ease, z-index 0.2s ease 0.2s;
}

.letter {
    position: absolute;
    top: 10px;
    left: 15px;
    width: 270px;
    height: 180px;
    background-color: var(--paper-color);
    z-index: 2;
    transition: transform 0.8s ease 1s, height 0.8s ease 1s, top 0.8s ease 1s, z-index 0.1s ease 1.5s;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.envelope.open .letter {
    transform: translateY(-50px);
    height: 400px;
    top: -200px;
    z-index: 6;
    border-radius: 10px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

.letter-content {
    opacity: 0;
    transition: opacity 0.5s ease 1.8s;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.envelope.open .letter-content {
    opacity: 1;
}

h1 {
    color: var(--primary-pink);
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

#typewriter-text {
    font-size: 1.1rem;
    line-height: 2;
    color: var(--text-color);
    margin-bottom: 2rem;
    min-height: 150px;
    text-align: left;
    padding: 0 20px;
}

.signature {
    font-weight: bold;
    color: var(--primary-pink);
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 1.4rem;
    align-self: flex-end;
    padding-right: 30px;
}

.controls {
    opacity: 1;
    transition: opacity 0.5s;
}

.controls.hide {
    opacity: 0;
    pointer-events: none;
}

button {
    background-color: var(--primary-pink);
    color: white;
    border: none;
    padding: 12px 40px;
    border-radius: 50px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(255, 107, 129, 0.4);
    font-family: 'Ma Shan Zheng', cursive;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 107, 129, 0.6);
    background-color: #ff4757;
}