/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Ma Shan Zheng', cursive;
    background: #0f2819;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
    font-size: 16px;
}

/* 容器样式 */
.container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    overflow: hidden;
    padding: 20px;
}

/* 圣诞树样式 */
.christmas-tree {
    position: fixed;
    bottom: 0;
    right: 5%;
    z-index: 3;
    transform: scale(1.8);
    opacity: 0.6;
    pointer-events: none;
}

.tree-star {
    position: absolute;
    top: -120px;
    left: 50%;
    transform: translateX(-50%);
    color: #FFD700;
    font-size: 30px;
    animation: twinkle 1.5s infinite alternate;
    z-index: 2;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.tree-body {
    width: 0;
    height: 0;
    border-left: 80px solid transparent;
    border-right: 80px solid transparent;
    border-bottom: 160px solid #3d8b3d;
    position: relative;
    filter: drop-shadow(0 0 15px rgba(61, 139, 61, 0.5));
}

.tree-body::before,
.tree-body::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 100px solid transparent;
    border-right: 100px solid transparent;
    border-bottom: 200px solid #3d8b3d;
    left: -100px;
    bottom: -60px;
    z-index: -1;
}

.tree-trunk {
    width: 30px;
    height: 50px;
    background: #5c4434;
    margin: 0 auto;
    position: relative;
    top: -5px;
    box-shadow: 0 0 10px rgba(92, 68, 52, 0.3);
}

/* 树的装饰容器 */
.tree-decorations {
    position: absolute;
    width: 200px;
    height: 320px;
    top: -120px;
    left: -100px;
    pointer-events: none;
    z-index: 2;
}

/* 装饰球样式 */
.tree-ball {
    position: absolute;
    font-size: 16px;
    filter: drop-shadow(0 0 5px currentColor);
    transform-origin: top center;
    animation: ballSwing 3s ease-in-out infinite;
    z-index: 3;
}

/* 其他装饰样式 */
.tree-decoration {
    position: absolute;
    font-size: 14px;
    filter: drop-shadow(0 0 5px currentColor);
    transform-origin: top center;
    animation: decorationTwinkle 1.5s infinite alternate;
    z-index: 3;
}

.tree-decoration:nth-child(2n) {
    background: #ffd700;
    box-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.tree-decoration:nth-child(3n) {
    background: #4d94ff;
    box-shadow: 0 0 5px rgba(77, 148, 255, 0.5);
}

/* 顶部装饰特殊样式 */
.tree-decoration[style*="top: 5%"],
.tree-decoration[style*="top: 8%"] {
    z-index: 4;
    filter: drop-shadow(0 0 8px currentColor);
}

/* 装饰元素样式 */
.decorations .decoration {
    position: fixed;
    font-size: 24px;
    color: #c41e3a;
    animation: float 3s infinite alternate ease-in-out;
}

.bell-left {
    left: 20px;
    top: 30%;
}

.gift-right {
    right: 20px;
    top: 40%;
}

/* 信件装饰 */
.letter-decorations {
    position: absolute;
    width: 100%;
    top: 5px;
    left: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
}

.letter-decoration {
    color: #c41e3a;
    font-size: 20px;
}

.letter-footer-decoration {
    text-align: center;
    color: #c41e3a;
    font-size: 24px;
    margin-top: 20px;
    animation: pulse 2s infinite;
}

/* 雪花容器 */
.snow-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

/* 雪花样式 */
.snowflake {
    position: fixed;
    color: white;
    pointer-events: none;
    animation: snowfall linear forwards;
    top: -20px;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
    will-change: transform;
    z-index: 1;
}

/* 雪花动画 */
@keyframes snowfall {
    0% {
        transform: translateY(0) translateX(0) rotate(0deg);
        opacity: 1;
    }
    25% {
        transform: translateY(25vh) translateX(15px) rotate(90deg);
        opacity: 0.9;
    }
    50% {
        transform: translateY(50vh) translateX(-15px) rotate(180deg);
        opacity: 0.8;
    }
    75% {
        transform: translateY(75vh) translateX(15px) rotate(270deg);
        opacity: 0.7;
    }
    100% {
        transform: translateY(100vh) translateX(0) rotate(360deg);
        opacity: 0;
    }
}

/* 生成多个不同的摇摆动画 */
@keyframes sway1 {
    0% { margin-left: 0px; }
    25% { margin-left: 10px; }
    50% { margin-left: -10px; }
    75% { margin-left: 15px; }
    100% { margin-left: 0px; }
}

@keyframes sway2 {
    0% { margin-left: 0px; }
    25% { margin-left: -15px; }
    50% { margin-left: 15px; }
    75% { margin-left: -10px; }
    100% { margin-left: 0px; }
}

@keyframes sway3 {
    0% { margin-left: 0px; }
    25% { margin-left: 15px; }
    50% { margin-left: -15px; }
    75% { margin-left: 10px; }
    100% { margin-left: 0px; }
}

/* 信件容器 */
.letter-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 800px;
    margin: 1rem auto;
    padding: clamp(1rem, 5vw, 2rem);
}

/* 信件样式 */
.letter {
    background: rgba(255, 255, 255, 0.98);
    padding: clamp(1.5rem, 5vw, 3rem);
    border-radius: clamp(10px, 2vw, 20px);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    transform: translateY(20px);
    opacity: 0;
    animation: fadeIn 1s ease-out forwards;
    width: 100%;
    position: relative;
}

.letter h1 {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 1.5em;
    color: #c41e3a;
    text-align: left;
    margin-top: 1em;
    margin-bottom: 1em;
}

.letter-content {
    font-size: clamp(1rem, 3.5vw, 1.2rem);
    line-height: 2;
    margin-bottom: clamp(1rem, 4vw, 2rem);
    text-align: justify;
    word-break: break-word;
}

.letter-content p {
    margin-bottom: 1.5em;
    text-indent: 2em;
}

.signature {
    text-align: right;
    font-size: clamp(1rem, 3.5vw, 1.2rem);
}

.date {
    margin-top: 0.5rem;
    /* color: #666; */
    font-size: clamp(0.9rem, 3vw, 1.1rem);
}

/* 动画效果 */
@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes twinkle {
    from { opacity: 0.5; }
    to { opacity: 1; }
}

@keyframes float {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* 彩灯样式 */
.tree-lights {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 2;
}

.light {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    animation: lightTwinkle 1s infinite alternate;
    z-index: 2;
    box-shadow: 0 0 8px currentColor;
}

.light:nth-child(2n) {
    animation-delay: 0.5s;
    background: #ffeb3b;
}

.light:nth-child(3n) {
    animation-delay: 0.7s;
    background: #ff5722;
}

.light:nth-child(4n) {
    animation-delay: 0.3s;
    background: #2196f3;
}

/* 装饰动画 */
@keyframes ballSwing {
    0%, 100% {
        transform: rotate(-5deg);
    }
    50% {
        transform: rotate(5deg);
    }
}

@keyframes decorationTwinkle {
    from {
        opacity: 0.7;
        transform: scale(0.95) rotate(-3deg);
    }
    to {
        opacity: 1;
        transform: scale(1.05) rotate(3deg);
    }
}

@keyframes lightTwinkle {
    from {
        opacity: 0.4;
        box-shadow: 0 0 4px currentColor;
    }
    to {
        opacity: 1;
        box-shadow: 0 0 12px currentColor;
    }
}

/* 响应式设计 - 小屏幕设备 */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .letter-container {
        margin: 0.5rem auto;
    }

    .letter {
        padding: 1.5rem;
    }

    .christmas-tree {
        transform: scale(1.2);
        right: -8%;
        bottom: 5%;
        opacity: 0.4;
    }

    .tree-ball {
        font-size: 12px;
    }

    .tree-decoration {
        font-size: 10px;
    }

    .decorations .decoration {
        font-size: 20px;
    }

    .bell-left {
        left: 10px;
    }

    .gift-right {
        right: 10px;
    }

    .light {
        width: 4px;
        height: 4px;
    }

    .music-toggle {
        width: 40px;
        height: 40px;
        font-size: 18px;
        bottom: 15px;
        left: 15px;
    }
}

/* 响应式设计 - 中等屏幕设备 */
@media (min-width: 481px) and (max-width: 768px) {
    .letter-container {
        margin: 1rem auto;
    }

    .letter {
        padding: 2rem;
    }

    .christmas-tree {
        transform: scale(1.5);
        right: 0;
        opacity: 0.5;
    }
}

/* 响应式设计 - 横屏模式优化 */
@media (max-height: 600px) and (orientation: landscape) {
    .container {
        padding: 10px;
    }

    .letter {
        padding: 1.5rem;
    }

    .letter h1 {
        margin-bottom: 1rem;
    }

    .letter-content {
        margin-bottom: 1rem;
    }

    .christmas-tree {
        transform: scale(0.8);
        right: -5%;
        bottom: 2%;
        opacity: 0.5;
    }
}
/* 音乐控制样式 */
.music-control {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
}

.music-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.music-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.music-toggle.playing {
    border-color: rgba(255, 255, 255, 0.5);
}