* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary-color: #ff4081;
    --secondary-color: #f50057;
    --light-pink: #ffebee;
    --dark-pink: #d81b60;
    --text-color: #333;
    --paper-color: #fffef5;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Playfair Display', serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    color: var(--text-color);
    position: relative;
    padding: 20px;
    touch-action: manipulation;
}

/* 背景和滤镜 */
.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('background.jpg') center/cover no-repeat fixed;
    opacity: 0.15;
    z-index: -1;
}

/* 音乐控制 - 改进 */
.music-control {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.music-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 6px 20px rgba(255, 64, 129, 0.4);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.music-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s;
}

.music-btn:hover::before {
    left: 100%;
}

.music-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 25px rgba(255, 64, 129, 0.6);
}

.music-btn:active {
    transform: translateY(-1px) scale(0.98);
}

.music-btn i {
    font-size: 18px;
    transition: transform 0.3s;
}

.music-btn:hover i {
    transform: scale(1.2);
}

/* 信封容器 */
.envelope-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    height: auto;
    min-height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 30px;
    margin-bottom: 20px;
    perspective: 1000px;
}

/* 信封样式 - 改进 */
.envelope {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 320px;
    cursor: pointer;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.envelope:hover {
    transform: scale(1.03) rotateY(5deg);
}

.envelope-body {
    position: relative;
    width: 100%;
    height: 100%;
}

.envelope-front {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    z-index: 2;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    transform-style: preserve-3d;
}

.envelope-front::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.15) 50%, transparent 70%);
    z-index: 1;
    animation: shine 3s infinite linear;
}

@keyframes shine {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

.heart-seal {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 70px;
    height: 70px;
    background-color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
    z-index: 3;
    animation: heartbeat 1.5s infinite ease-in-out;
    transform-style: preserve-3d;
}

.heart-seal i {
    color: var(--primary-color);
    font-size: 32px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    10% { transform: scale(1.1); }
    20% { transform: scale(1); }
    30% { transform: scale(1.15); }
    40% { transform: scale(1); }
}

.recipient {
    margin-top: 40px;
    text-align: center;
    z-index: 2;
    padding: 0 20px;
}

.recipient p {
    font-family: 'Dancing Script', cursive;
    font-size: 36px;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1.3;
}

.recipient .subtitle {
    font-size: 20px;
    margin-top: 10px;
    opacity: 0.9;
    font-family: 'Playfair Display', serif;
    font-style: italic;
}

.open-hint {
    position: absolute;
    bottom: 25px;
    text-align: center;
    z-index: 2;
    animation: float 3s infinite ease-in-out;
}

.hint-text p {
    color: white;
    font-size: 18px;
    margin-bottom: 8px;
    font-weight: 500;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

.hint-icon {
    font-size: 28px;
    color: white;
    animation: bounce 2s infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 50% solid transparent;
    border-right: 50% solid transparent;
    border-top: 160px solid var(--dark-pink);
    z-index: 1;
    transform-origin: top;
    transition: transform 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    filter: drop-shadow(0 -2px 5px rgba(0, 0, 0, 0.2));
}

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

/* 信纸样式 - 改进 */
.letter {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--paper-color);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    z-index: 0;
    transform: translateY(0) scale(0.9);
    opacity: 0;
    transition: transform 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 1s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.envelope.opened .letter {
    transform: translateY(-120px) scale(1);
    opacity: 1;
    z-index: 3;
}

.letter-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.letter-header {
    text-align: center;
    border-bottom: 2px dashed #ffb6c1;
    padding-bottom: 20px;
    margin-bottom: 25px;
    position: relative;
}

.letter-date {
    font-size: 15px;
    color: #777;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.letter-title h1 {
    font-family: 'Great Vibes', cursive;
    font-size: 46px;
    color: var(--dark-pink);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
}

.title-decoration {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.decoration-line {
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
}

.title-decoration i {
    color: var(--primary-color);
    font-size: 18px;
}

.letter-body {
    flex-grow: 1;
    padding: 0 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.salutation {
    font-size: 22px;
    margin-bottom: 25px;
    color: #555;
    font-weight: 600;
}

.recipient-name {
    color: var(--primary-color);
    font-weight: bold;
    margin: 0 5px;
}

.message {
    line-height: 1.9;
    margin-bottom: 35px;
}

.message p {
    margin-bottom: 20px;
    font-size: 18px;
    text-align: justify;
    text-indent: 2em;
}

.closing {
    margin-top: 40px;
    margin-bottom: 25px;
    text-align: right;
    position: relative;
}

.closing p {
    margin-bottom: 8px;
    font-size: 20px;
}

.signature {
    font-family: 'Pacifico', cursive;
    font-size: 38px;
    color: var(--dark-pink);
    margin-top: 15px;
    display: inline-block;
    position: relative;
}

.signature-line {
    position: absolute;
    bottom: -10px;
    right: 0;
    width: 150px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-color));
}

.letter-footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px dashed #ffb6c1;
    color: var(--primary-color);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.footer-hearts i {
    margin: 0 5px;
    font-size: 16px;
    animation: heartBeat 1.5s infinite;
}

.footer-hearts i:nth-child(2) {
    animation-delay: 0.2s;
}

.footer-hearts i:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; }
}

.letter-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 50px;
    padding: 14px 28px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 6px 15px rgba(255, 64, 129, 0.3);
    font-weight: 500;
    min-width: 140px;
    justify-content: center;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(255, 64, 129, 0.5);
}

.btn:active {
    transform: translateY(-1px);
}

.btn i {
    font-size: 18px;
}

.btn-close {
    background: linear-gradient(135deg, #6a11cb, #2575fc);
}

.btn-print {
    background: linear-gradient(135deg, #00b09b, #96c93d);
}

/* 花瓣效果 */
.petals-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.petal {
    position: absolute;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #ff9ec0, var(--primary-color));
    border-radius: 50% 0 50% 50%;
    opacity: 0.8;
    animation: fall linear infinite;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(360deg);
    }
}

/* 移动端触摸提示 */
.mobile-touch-hint {
    display: none;
    margin-top: 20px;
    text-align: center;
    animation: pulse 2s infinite;
}

.touch-icon {
    font-size: 36px;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.mobile-touch-hint p {
    color: #666;
    font-size: 16px;
    font-weight: 500;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* 说明文字 */
.instructions {
    margin-top: 25px;
    margin-bottom: 15px;
    text-align: center;
    color: #666;
    font-size: 16px;
    padding: 0 15px;
}

/* 响应式设计 - 改进 */
@media (max-width: 768px) {
    body {
        padding: 15px;
        justify-content: flex-start;
        padding-top: 80px;
    }
    
    .music-control {
        top: 15px;
        right: 15px;
    }
    
    .music-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .music-text {
        display: none;
    }
    
    .music-btn:hover .music-text {
        display: inline;
    }
    
    .envelope-container {
        margin-top: 20px;
        min-height: 400px;
    }
    
    .envelope {
        max-width: 90%;
        height: 280px;
    }
    
    .envelope:hover {
        transform: scale(1.02);
    }
    
    .heart-seal {
        width: 55px;
        height: 55px;
        top: 15px;
        right: 15px;
    }
    
    .heart-seal i {
        font-size: 26px;
    }
    
    .recipient {
        margin-top: 30px;
    }
    
    .recipient p {
        font-size: 28px;
    }
    
    .recipient .subtitle {
        font-size: 16px;
    }
    
    .open-hint {
        bottom: 20px;
    }
    
    .hint-text p {
        font-size: 16px;
    }
    
    .hint-icon {
        font-size: 24px;
    }
    
    .envelope-flap {
        border-top: 140px solid var(--dark-pink);
    }
    
    .letter {
        padding: 20px;
    }
    
    .envelope.opened .letter {
        transform: translateY(-80px) scale(1);
    }
    
    .letter-title h1 {
        font-size: 36px;
    }
    
    .salutation {
        font-size: 20px;
    }
    
    .message p {
        font-size: 16px;
        text-indent: 1.5em;
        line-height: 1.7;
    }
    
    .signature {
        font-size: 32px;
    }
    
    .signature-line {
        width: 120px;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 15px;
        min-width: 120px;
    }
    
    .mobile-touch-hint {
        display: block;
    }
    
    .instructions {
        font-size: 14px;
        margin-top: 20px;
    }
}

@media (max-width: 480px) {
    .envelope {
        height: 250px;
    }
    
    .envelope-flap {
        border-top: 125px solid var(--dark-pink);
    }
    
    .recipient p {
        font-size: 24px;
    }
    
    .letter-title h1 {
        font-size: 32px;
    }
    
    .letter-actions {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .btn {
        width: 100%;
        max-width: 250px;
    }
}

/* 打印样式 */
@media print {
    .music-control,
    .mobile-touch-hint,
    .instructions,
    .letter-actions,
    .petals-container,
    .background-overlay {
        display: none !important;
    }
    
    .envelope-container,
    .envelope,
    .letter {
        position: static;
        width: 100%;
        height: auto;
        box-shadow: none;
        transform: none !important;
        opacity: 1 !important;
        margin: 0;
    }
    
    .letter {
        padding: 20px;
        border: 1px solid #ddd;
    }
    
    body {
        background: white !important;
        padding: 20px;
    }
}
