body {
    font-family: 'Dancing Script', cursive;
    background: linear-gradient(135deg, #ffb6c1, #ffe4e1, #fff0f5, #ffddf4);
    background-size: 400% 400%;
    animation: gradient-shift 10s ease infinite;
    color: #333;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, rgba(255, 182, 193, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
}

#global-snow-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.global-snowflake {
    position: absolute;
    color: #ffb6c1;
    font-size: 20px;
    opacity: 0.9;
    animation: global-fall linear infinite;
    text-shadow: 0 0 5px rgba(255, 182, 193, 0.8), 0 0 10px rgba(255, 182, 193, 0.6);
    filter: drop-shadow(0 0 3px rgba(255, 182, 193, 0.5));
}

@keyframes global-fall {
    0% { transform: translateY(-10px) rotate(0deg) scale(1); opacity: 0.9; }
    50% { transform: translateY(50vh) rotate(180deg) scale(1.2); opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg) scale(0.8); opacity: 0; }
}

.rose-petal {
    position: absolute;
    color: #ff69b4;
    opacity: 0.8;
    animation: petal-fall linear infinite;
    text-shadow: 0 0 5px rgba(255, 105, 180, 0.8), 0 0 10px rgba(255, 105, 180, 0.6);
    filter: drop-shadow(0 0 3px rgba(255, 105, 180, 0.5));
}

@keyframes petal-fall {
    0% { transform: translateY(-10px) rotate(0deg) scale(1); opacity: 0.8; }
    50% { transform: translateY(50vh) rotate(90deg) scale(1.1); opacity: 0.9; }
    100% { transform: translateY(100vh) rotate(180deg) scale(0.9); opacity: 0; }
}

.page {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    text-align: center;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 1s ease, transform 1s ease;
    position: relative;
    z-index: 2;
}

.page.active {
    display: flex;
    opacity: 1;
    transform: scale(1);
}

.envelope {
    width: 220px;
    height: 165px;
    background: linear-gradient(135deg, #fff, #f8f8f8);
    border: 3px solid #ffb6c1;
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    margin-bottom: 20px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.8);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
}

.envelope::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, rgba(255,255,255,0.1), rgba(255,182,193,0.1));
    pointer-events: none;
}

.envelope:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 24px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.8);
}

.envelope-flap {
    width: 0;
    height: 0;
    border-left: 110px solid transparent;
    border-right: 110px solid transparent;
    border-bottom: 82.5px solid #f8f8f8;
    position: absolute;
    top: 0;
    left: 0;
    border-bottom-color: #f8f8f8;
    transition: transform 0.5s ease;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}

.envelope.open .envelope-flap {
    transform: rotateX(180deg);
}

.envelope-body {
    width: 100%;
    height: 82.5px;
    background: linear-gradient(135deg, #f8f8f8, #fff);
    position: absolute;
    bottom: 0;
    border-radius: 0 0 7px 7px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}

#snow-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.heart {
    position: absolute;
    color: #ff69b4;
    font-size: 24px;
    animation: fall linear infinite;
}

@keyframes fall {
    0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

#text-container, #text-container3 {
    font-size: 28px;
    line-height: 1.6;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #ff69b4, #ffb6c1, #ff1493);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 10px rgba(255, 105, 180, 0.5);
    animation: glow 2s ease-in-out infinite alternate;
    max-width: 80%;
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.8);
    border: 2px solid rgba(255, 182, 193, 0.5);
    border-radius: 15px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    max-height: 70vh;
}

@keyframes glow {
    from { text-shadow: 0 0 10px rgba(255, 105, 180, 0.5); }
    to { text-shadow: 0 0 20px rgba(255, 105, 180, 0.8), 0 0 30px rgba(255, 105, 180, 0.6); }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); opacity: 0.8; }
    70% { transform: scale(0.9); opacity: 0.9; }
    100% { transform: scale(1); opacity: 1; }
}

/* 移动端优化 */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    .envelope {
        width: 180px;
        height: 135px;
    }
    
    .envelope-flap {
        border-left-width: 90px;
        border-right-width: 90px;
        border-bottom-width: 67.5px;
    }
    
    .envelope-body {
        height: 67.5px;
    }
    
    #text-container, #text-container3 {
        font-size: 20px;
        max-width: 90%;
        padding: 15px;
        max-height: 60vh;
    }
    
    .paragraph {
        font-size: 18px;
    }
    
    .next-btn {
        padding: 12px 24px;
        font-size: 16px;
        min-width: 120px;
    }
    
    h2 {
        font-size: 24px;
    }
    
    button {
        padding: 12px 20px;
        font-size: 16px;
        min-height: 44px; /* 触摸友好 */
    }
    
    .global-snowflake, .heart, .rose-petal {
        font-size: 14px; /* 减少大小以优化性能 */
    }
}

#render-indicator {
    position: fixed;
    bottom: 10px;
    right: 10px;
    color: gold;
    font-size: 12px;
    font-family: 'Arial', sans-serif;
    text-shadow: 0 0 5px gold;
    animation: blink 1s infinite;
    z-index: 1000;
    pointer-events: none;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.5; }
}

.next-btn {
    padding: 15px 30px;
    background: linear-gradient(45deg, #ff69b4, #ff1493);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 20px;
    font-family: 'Dancing Script', cursive;
    box-shadow: 0 4px 15px rgba(255, 105, 180, 0.3);
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
}

.next-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(255, 105, 180, 0.5);
}

@keyframes pulse {
    0% { box-shadow: 0 4px 15px rgba(255, 105, 180, 0.3); }
    50% { box-shadow: 0 4px 20px rgba(255, 105, 180, 0.5); }
    100% { box-shadow: 0 4px 15px rgba(255, 105, 180, 0.3); }
}

h2 {
    margin-bottom: 20px;
    font-size: 32px;
    color: #ff69b4;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    animation: fadeIn 1s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

button {
    margin: 10px;
    padding: 10px 20px;
    background: linear-gradient(45deg, #ffb6c1, #ff69b4);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Dancing Script', cursive;
    font-size: 18px;
    transition: all 0.3s ease;
}

.paragraph {
    margin-bottom: 15px;
    font-size: 24px;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(45deg, #ff69b4, #ffb6c1, #ff1493);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 5px rgba(255, 105, 180, 0.3);
}