/* ===== 基础样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

body {
    min-height: 100vh;
    min-height: -webkit-fill-available;
    background: linear-gradient(135deg, #D4145A 0%, #8B0000 100%);
    font-family: "Microsoft YaHei", "STKaiti", sans-serif;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

html {
    height: -webkit-fill-available;
    scroll-behavior: smooth;
}

/* ===== 主容器样式 ===== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    z-index: 2;
}

/* ===== 背景层样式 ===== */
.bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.dragon-pattern {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('./images/snake-pattern.png');
    background-size: 200px;
    background-repeat: repeat;
    opacity: 0.08;
    animation: floatPattern 20s linear infinite;
}

/* ===== 标题样式 ===== */
.title-box {
    text-align: center;
    color: #FFD700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    margin-bottom: 2rem;
    position: relative;
    z-index: 4;
}

.title-box h1 {
    font-size: 4rem;
    letter-spacing: 0.5rem;
    animation: glowText 2s ease-in-out infinite alternate;
}

/* ===== 贺卡主体样式 ===== */
.card-container {
    width: 100%;
    max-width: 800px;
    margin: 2vh auto;
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.blessing-card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    border: 2px solid rgba(255, 215, 0, 0.3);
    padding: 3rem;
    box-shadow: 
        0 0 30px rgba(0, 0, 0, 0.2),
        inset 0 0 50px rgba(255, 215, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.blessing-text {
    position: relative;
    z-index: 2;
    text-align: center;
    color: #FFD700;
    font-size: 2rem;
    line-height: 1.8;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* ===== 装饰元素样式 ===== */
.lanterns {
    position: relative;
    z-index: 3;
    width: 100%;
    height: 120px;
    display: flex;
    justify-content: space-around;
}

.lantern-item {
    width: 70px;
    height: 105px;
    background: url('./images/lantern.png') no-repeat center/contain;
    filter: drop-shadow(0 0 15px rgba(255, 0, 0, 0.5));
    transform-origin: top center;
    animation: swinging 3s ease-in-out infinite;
}

/* ===== 装饰动画元素 ===== */
.lucky-items {
    position: fixed;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.red-packet {
    position: absolute;
    width: 40px;
    height: 50px;
    background: url('./images/red-packet.png') no-repeat center/contain;
    animation: falling linear infinite;
    filter: drop-shadow(0 0 5px rgba(255, 0, 0, 0.3));
}

.gold-coin {
    position: absolute;
    width: 30px;
    height: 30px;
    background: url('./images/gold-coin.png') no-repeat center/contain;
    animation: fallingCoin linear infinite;
    filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.5));
}

/* ===== 对联样式 ===== */
.couplet-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 3;
}

.couplet {
    position: fixed;
    height: 60vh;
    top: 20vh;
}

.couplet.left {
    left: 5vw;
}

.couplet.right {
    right: 5vw;
}

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

.music-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 215, 0, 0.3);
    border: 2px solid rgba(255, 215, 0, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: musicRotate 3s linear infinite;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

/* ===== 动画定义 ===== */
@keyframes falling {
    0% {
        transform: translateY(-100vh) rotate(0deg) scale(1);
    }
    100% {
        transform: translateY(100vh) rotate(360deg) scale(1);
    }
}

@keyframes spinning {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes swinging {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

@keyframes musicRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes fallingCoin {
    0% {
        transform: translateY(-100vh) rotate(0deg) scale(1);
    }
    50% {
        transform: translateY(0) rotate(180deg) scale(1.2);
    }
    100% {
        transform: translateY(100vh) rotate(360deg) scale(0.8);
    }
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    .title-box h1 {
        font-size: 2.5rem;
    }

    .blessing-text {
        font-size: 1.5rem;
    }

    .lantern-item {
        width: 50px;
        height: 75px;
    }

    .music-btn {
        width: 40px;
        height: 40px;
    }

    .red-packet {
        width: 30px;
        height: 40px;
    }

    .gold-coin {
        width: 25px;
        height: 25px;
    }
}

@media (max-width: 480px) {
    .title-box h1 {
        font-size: 2rem;
    }

    .blessing-text {
        font-size: 1.2rem;
    }

    .blessing-card {
        padding: 1.5rem;
    }

    .fu-decoration {
        width: 60px;
        height: 60px;
    }
}

/* ===== 对联纸张样式 ===== */
.couplet-paper {
    height: 100%;
    width: min(40px, 8vw);
    background: linear-gradient(to bottom, #FFE4B5, #FFE4B5);
    padding: 30px 15px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
    border: 2px solid #800000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.couplet-paper span {
    writing-mode: vertical-rl;
    text-orientation: upright;
    color: #800000;
    font-size: clamp(16px, 3vh, 24px);
    font-weight: bold;
    letter-spacing: clamp(6px, 1.5vh, 12px);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

/* ===== 底部装饰样式 ===== */
.bottom-decoration {
    margin-top: auto;
    padding: 1rem;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.time-display {
    margin: 1rem auto;
    max-width: 90%;
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.15), rgba(255, 215, 0, 0.05));
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.3),
        inset 0 -5px 15px rgba(0, 0, 0, 0.2),
        inset 0 5px 15px rgba(255, 255, 255, 0.1);
    transform: perspective(1000px) rotateX(10deg) scale(0.95);
    backdrop-filter: blur(10px);
}

.time-unit {
    color: #FFD700;
    font-size: 1.2rem;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    padding: 0.5rem 1rem;
    display: inline-block;
}

/* ===== 开始屏幕样式 ===== */
.start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.start-content {
    text-align: center;
    color: #FFD700;
    animation: pulse 2s ease-in-out infinite;
}

.start-content h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

/* ===== 装饰图标样式 ===== */
.card-decorations {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
}

.decoration-icon {
    position: absolute;
    width: 150px;
    height: 150px;
    bottom: 20px;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.3));
}

.boy-icon {
    right: -50px;
    background: url('./images/boy.png') no-repeat center/contain;
    transform: scale(0.8);
    animation: boyFloat 3s ease-in-out infinite;
}

.snake-icon {
    left: -50px;
    background: url('./images/snake2.png') no-repeat center/contain;
    transform: scale(0.8) scaleX(-1);
    animation: snakeWiggle 4s ease-in-out infinite;
}

/* ===== 额外动画效果 ===== */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes boyFloat {
    0%, 100% { transform: scale(0.8) translateY(0); }
    50% { transform: scale(0.8) translateY(-10px); }
}

@keyframes snakeWiggle {
    0%, 100% { transform: scale(0.8) scaleX(-1) rotate(-3deg); }
    50% { transform: scale(0.8) scaleX(-1) rotate(3deg); }
}

/* ===== 额外的响应式优化 ===== */
@media (max-height: 700px) {
    .container {
        padding: 1rem;
    }

    .couplet {
        height: 50vh;
        top: 25vh;
    }

    .decoration-icon {
        width: 120px;
        height: 120px;
    }
}

@media (max-width: 320px) {
    .time-unit {
        font-size: 0.9rem;
        padding: 0.3rem 0.6rem;
    }

    .start-content h2 {
        font-size: 1.5rem;
    }
}

/* ===== 横屏模式优化 ===== */
@media (orientation: landscape) and (max-height: 450px) {
    .container {
        padding: 0.5rem;
    }

    .blessing-card {
        max-height: 70vh;
        overflow-y: auto;
    }

    .couplet {
        height: 80vh;
        top: 10vh;
    }
}

/* 卡片背景装饰 */
.card-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 20px;
}

.pattern-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        rgba(255, 215, 0, 0.05) 0%,
        rgba(255, 0, 0, 0.05) 100%
    );
    opacity: 0.1;
}

/* 福字装饰优化 - 设备自适应 */
.fu-decoration {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 450px;
    height: 450px;
    opacity: 0.6;
    pointer-events: none;
    z-index: 1;
    filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.3));
}

.fu-character {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 360px;
    font-family: "STKaiti", "楷体", "SimKai", serif;
    color: #FFF;
    background: linear-gradient(45deg, 
        #FFD700 0%,
        #FFF 45%,
        #FFD700 55%,
        #FF4500 100%
    );
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 
        0 0 50px rgba(255, 255, 255, 0.8),
        0 0 100px rgba(255, 215, 0, 0.7),
        0 0 150px rgba(255, 165, 0, 0.6);
    -webkit-text-stroke: 2px rgba(255, 215, 0, 0.9);
    animation: fuFloat 8s ease-in-out infinite;
    transform-origin: center center;
    /* 默认电脑端效果 */
    filter: brightness(1.2) contrast(1.2);
}

.fu-character::before {
    content: "福";
    display: block;
    transform: rotate(-15deg);
}

/* 主要内容层 */
.blessing-content {
    position: relative;
    z-index: 2;
}

/* 动画效果 */
@keyframes patternFloat {
    from { transform: translate(0, 0) rotate(0deg); }
    to { transform: translate(-200px, -200px) rotate(360deg); }
}

@keyframes fuFloat {
    0%, 100% {
        transform: rotate(-8deg) scale(1) translateY(0);
        opacity: 0.6;
    }
    50% {
        transform: rotate(8deg) scale(1.15) translateY(-10px);
        opacity: 0.7;
    }
}

/* 添加光晕效果 */
.blessing-card::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150%;
    height: 150%;
    background: radial-gradient(
        circle at center,
        rgba(255, 215, 0, 0.15) 0%,
        rgba(255, 215, 0, 0) 70%
    );
    pointer-events: none;
    animation: glowPulse 4s ease-in-out infinite;
}

/* 光晕动画 */
@keyframes glowPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.15;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.2;
    }
}

/* 添加边框发光效果 */
.blessing-card::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 20px;
    background: linear-gradient(45deg, 
        rgba(255, 215, 0, 0.2),
        rgba(255, 0, 0, 0.2),
        rgba(255, 215, 0, 0.2)
    );
    z-index: -1;
    animation: borderGlow 3s ease-in-out infinite;
}

/* 边框发光动画 */
@keyframes borderGlow {
    0%, 100% {
        opacity: 0.2;
    }
    50% {
        opacity: 0.4;
    }
}

/* 添加背景光晕效果 */
.fu-decoration::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140%;
    height: 140%;
    background: radial-gradient(
        circle at center,
        rgba(255, 255, 255, 0.3) 0%,
        rgba(255, 215, 0, 0.2) 30%,
        rgba(255, 69, 0, 0.1) 50%,
        transparent 70%
    );
    animation: glowPulse 4s ease-in-out infinite;
    filter: blur(10px);
}

/* 添加额外的装饰效果 */
.fu-decoration::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 120%;
    height: 120%;
    background: linear-gradient(
        45deg,
        transparent 45%,
        rgba(255, 215, 0, 0.1) 48%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 215, 0, 0.1) 52%,
        transparent 55%
    );
    animation: shineEffect 4s ease-in-out infinite;
}

/* 闪光效果动画 */
@keyframes shineEffect {
    0%, 100% {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(45deg) scale(1);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(45deg) scale(1.2);
    }
}

/* [继续...] */

/* 移动端优化 */
@media (max-width: 768px) {
    .fu-decoration {
        width: 300px;
        height: 300px;
    }
    
    .fu-character {
        font-size: 240px;
        /* 移动端降低亮度 */
        filter: brightness(1.0) contrast(1.1);
        text-shadow: 
            0 0 30px rgba(255, 255, 255, 0.7),
            0 0 60px rgba(255, 215, 0, 0.6),
            0 0 90px rgba(255, 165, 0, 0.5);
    }
}

@media (max-width: 480px) {
    .fu-decoration {
        width: 240px;
        height: 240px;
    }
    
    .fu-character {
        font-size: 180px;
        /* 小屏幕进一步调整 */
        filter: brightness(0.9) contrast(1.0);
        text-shadow: 
            0 0 20px rgba(255, 255, 255, 0.6),
            0 0 40px rgba(255, 215, 0, 0.5),
            0 0 60px rgba(255, 165, 0, 0.4);
    }
}

/* 针对高分辨率屏幕优化 */
@media (min-width: 1200px) and (min-resolution: 120dpi) {
    .fu-character {
        /* 高分屏增强效果 */
        filter: brightness(1.3) contrast(1.3);
        text-shadow: 
            0 0 60px rgba(255, 255, 255, 0.9),
            0 0 120px rgba(255, 215, 0, 0.8),
            0 0 180px rgba(255, 165, 0, 0.7);
    }
}
