/* 字体声明 */
@font-face {
    font-family: 'RuiHeiXiTi';
    src: url('../fonts/RuiHeiXiTi.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* 基础重置与全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'RuiHeiXiTi', 'Microsoft YaHei', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 粒子背景画布 */
#particleCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* 渐变背景 */
body {
    background: linear-gradient(135deg, #1a1a2e 0%, #2d1b4e 30%, #1e3a5f 60%, #0f3460 100%);
    background-size: 400% 400%;
    animation: gradientBG 20s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    25% { background-position: 50% 0%; }
    50% { background-position: 100% 50%; }
    75% { background-position: 50% 100%; }
    100% { background-position: 0% 50%; }
}

/* 加载动画 */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #2d1b4e 30%, #1e3a5f 60%, #0f3460 100%);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1), visibility 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
}

.loading-heart {
    width: 80px;
    height: 80px;
    margin: 0 auto 30px;
    position: relative;
    animation: loadingPulse 2s ease-in-out infinite;
}

.heart-shape {
    width: 100%;
    height: 100%;
    position: relative;
}

.heart-shape::before,
.heart-shape::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 65px;
    background: linear-gradient(135deg, #ff6b9d, #ff3838);
    border-radius: 40px 40px 0 0;
    filter: drop-shadow(0 0 10px rgba(255, 107, 157, 0.5));
}

.heart-shape::before {
    left: 40px;
    transform: rotate(-45deg);
    transform-origin: 0 100%;
}

.heart-shape::after {
    left: 0;
    transform: rotate(45deg);
    transform-origin: 100% 100%;
}

@keyframes loadingPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.9; }
}

.loading-text {
    color: #fff;
    font-size: 1.2rem;
    margin-bottom: 20px;
    letter-spacing: 3px;
    animation: loadingTextFade 2s ease-in-out infinite;
}

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

.loading-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 0 auto;
    overflow: hidden;
}

.loading-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #ff6b9d, #ff3838, #ff6b9d);
    background-size: 200% 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
    animation: loadingBarShimmer 2s ease-in-out infinite;
}

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

/* 音乐控制按钮 */
.music-control {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.music-control:hover {
    transform: scale(1.1) rotate(5deg);
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.music-control:active {
    transform: scale(0.95);
}

.music-control.playing {
    background: rgba(255, 107, 157, 0.3);
    border-color: rgba(255, 107, 157, 0.5);
    box-shadow: 0 0 30px rgba(255, 107, 157, 0.3);
}

.music-control.playing i {
    display: none;
}

.music-control.playing .music-visualizer {
    display: flex;
}

.music-visualizer {
    display: none;
    align-items: flex-end;
    gap: 2px;
    height: 18px;
}

.music-visualizer span {
    width: 3px;
    background: linear-gradient(to top, #ff6b9d, #ff3838);
    border-radius: 2px;
    animation: musicBar 0.8s ease-in-out infinite;
    box-shadow: 0 0 5px rgba(255, 107, 157, 0.5);
}

.music-visualizer span:nth-child(1) { height: 8px; animation-delay: 0s; }
.music-visualizer span:nth-child(2) { height: 14px; animation-delay: 0.2s; }
.music-visualizer span:nth-child(3) { height: 10px; animation-delay: 0.4s; }
.music-visualizer span:nth-child(4) { height: 16px; animation-delay: 0.6s; }

@keyframes musicBar {
    0%, 100% { height: 4px; }
    50% { height: 18px; }
}

.music-control i {
    color: #fff;
    font-size: 18px;
    transition: transform 0.3s ease;
}

.music-control:not(.playing):hover i {
    transform: scale(1.1);
}

/* 音量控制 */
.music-volume {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 10px 15px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.music-control:hover .music-volume {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: #ff6b9d;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 107, 157, 0.5);
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #ff6b9d;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(255, 107, 157, 0.5);
}

/* 通用Section样式 */
.section {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

/* 开场页样式 */
.opening {
    background: linear-gradient(135deg, #1a1a2e 0%, #2d1b4e 30%, #1e3a5f 60%, #0f3460 100%);
    z-index: 1;
    position: relative;
    overflow: hidden;
}

.opening::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255, 107, 157, 0.15) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    animation: openingGlow 8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes openingGlow {
    0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
}

/* 文字发光动画 */
.glow-text {
    animation: textGlow 3s ease-in-out infinite alternate;
}

@keyframes textGlow {
    from {
        text-shadow: 0 0 10px rgba(255, 107, 157, 0.6), 0 0 20px rgba(255, 107, 157, 0.4), 0 0 30px rgba(255, 107, 157, 0.2);
    }
    to {
        text-shadow: 0 0 20px rgba(255, 107, 157, 0.8), 0 0 30px rgba(255, 107, 157, 0.6), 0 0 40px rgba(255, 107, 157, 0.4), 0 0 50px rgba(255, 56, 56, 0.2);
    }
}

/* 渐入动画 */
.fade-in-text {
    opacity: 0;
    animation: fadeIn 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    animation-delay: 0.5s;
}

.fade-in-text:nth-child(3) {
    animation-delay: 1s;
}

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

.heart-animation {
    margin-bottom: 40px;
    position: relative;
}

.heart {
    width: 120px;
    height: 120px;
    position: relative;
    animation: heartbeat 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(255, 56, 56, 0.4));
}

.heart::before,
.heart::after {
    content: '';
    position: absolute;
    width: 60px;
    height: 95px;
    background: linear-gradient(135deg, #ff6b9d, #ff3838);
    border-radius: 60px 60px 0 0;
}

.heart::before {
    left: 60px;
    transform: rotate(-45deg);
    transform-origin: 0 100%;
}

.heart::after {
    left: 0;
    transform: rotate(45deg);
    transform-origin: 100% 100%;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.15); }
    30% { transform: scale(1); }
    45% { transform: scale(1.1); }
    60% { transform: scale(1); }
}

.title {
    font-size: 3rem;
    color: #fff;
    text-shadow: 0 0 30px rgba(255, 107, 157, 0.5), 0 0 60px rgba(255, 107, 157, 0.3);
    margin-bottom: 25px;
    text-align: center;
    letter-spacing: 5px;
    font-weight: 600;
}

.subtitle {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 50px;
    letter-spacing: 3px;
    text-shadow: 0 0 20px rgba(255, 107, 157, 0.3);
}

.btn-start {
    padding: 18px 50px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.85));
    border-radius: 50px;
    font-size: 1.2rem;
    color: #ff6b6b;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2), 0 0 40px rgba(255, 107, 157, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

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

.btn-start:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), 0 0 60px rgba(255, 107, 157, 0.3);
}

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

.btn-start:active {
    transform: translateY(-2px) scale(0.98);
}

/* 故事线容器样式 */
.story-container {
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
    display: none;
}

.timeline {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background: rgba(255,255,255,0.3);
    transform: translateX(-50%);
}

/* 故事滚动容器样式 */
.story-scroller {
    background: linear-gradient(135deg, #1a1a2e 0%, #2d1b4e 30%, #1e3a5f 60%, #0f3460 100%);
    display: none;
    overflow: hidden;
    position: relative;
}

.story-scroller::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(255, 107, 157, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.story-pages-wrapper {
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.story-page {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.story-page-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

/* 标题页 */
.story-title-page {
    text-align: center;
}

.story-main-title {
    font-size: 3rem;
    color: #fff;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(255, 107, 157, 0.8);
    animation: fadeInUp 1s ease;
}

.story-subtitle {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    animation: fadeInUp 1s ease 0.3s both;
}

/* 文字在上 */
.story-text-top {
    justify-content: flex-start;
    padding-top: 10vh;
}

.story-text-top .story-text {
    font-size: 1.4rem;
    color: #fff;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

.story-text-top .story-image {
    max-width: 80%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* 文字在下 */
.story-text-bottom {
    justify-content: flex-end;
    padding-bottom: 10vh;
}

.story-text-bottom .story-image {
    max-width: 80%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    margin-bottom: 30px;
}

.story-text-bottom .story-text {
    font-size: 1.4rem;
    color: #fff;
    text-align: center;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

/* 文字居中 */
.story-text-center {
    position: relative;
}

.story-text-center .story-image {
    max-width: 80%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 15px;
}

.story-text-center .story-center-text {
    font-size: 2rem;
    color: #fff;
    position: absolute;
    bottom: 15%;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.7);
}

/* 全屏图片 */
.story-full-image {
    position: relative;
    padding: 0;
}

.story-full-image .story-bg-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-full-image .story-overlay-text {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2rem;
    color: #fff;
    text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.8);
    text-align: center;
    width: 90%;
}

/* 多行文字 */
.story-multi-text .story-image {
    max-width: 60%;
    max-height: 40vh;
    object-fit: contain;
    margin-bottom: 20px;
}

.story-text-group {
    text-align: center;
}

.story-text-line {
    font-size: 1.3rem;
    color: #fff;
    margin: 8px 0;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

/* 爱的宣言 */
.story-declaration {
    background: radial-gradient(ellipse at center, rgba(255, 56, 56, 0.2) 0%, transparent 70%);
}

.story-declaration-text {
    font-size: 2.5rem;
    color: #fff;
    text-align: center;
    text-shadow: 0 0 30px rgba(255, 107, 157, 0.8);
    animation: pulse 2s ease-in-out infinite;
}

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

/* 进度条 */
.story-progress-bar {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 200px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    z-index: 100;
}

.story-progress-fill {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: linear-gradient(to top, #ff6b9d, #ff3838);
    border-radius: 3px;
    transition: height 0.3s ease;
}

.story-progress-text {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    white-space: nowrap;
}

/* 响应式 */
@media (max-width: 768px) {
    .story-main-title {
        font-size: 2rem;
    }

    .story-subtitle {
        font-size: 1.2rem;
    }

    .story-text,
    .story-text-line {
        font-size: 1.1rem;
    }

    .story-center-text,
    .story-overlay-text {
        font-size: 1.5rem;
    }

    .story-declaration-text {
        font-size: 1.8rem;
    }

    .story-page-content {
        padding: 20px;
    }

    .story-progress-bar {
        height: 150px;
        right: 10px;
    }

    .story-left-img,
    .story-right-img {
        flex-direction: column;
    }

    .story-left-img .story-split-image,
    .story-right-img .story-split-image,
    .story-left-img .story-split-text,
    .story-right-img .story-split-text {
        width: 100%;
        height: 50%;
    }

    .story-multi-image .story-image-pair {
        flex-direction: column;
        max-width: 90%;
    }

    .story-multi-image .story-image-pair img {
        max-width: 100%;
    }

    .story-center-img-container {
        max-width: 80%;
    }

    .story-page-dots {
        right: 15px;
        gap: 8px;
    }

    .story-dot {
        width: 6px;
        height: 6px;
    }
}

/* 3D爱心终页样式 */
.final-page {
    background: linear-gradient(135deg, #0c0c1d 0%, #1a1a2e 30%, #2d1b4e 60%, #0c0c1d 100%);
    display: none;
    overflow: hidden;
}

.final-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(255, 107, 157, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

#heartCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: grab;
}

#heartCanvas:active {
    cursor: grabbing;
}

.final-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    text-align: center;
    color: #fff;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    transition: opacity 0.4s ease;
}

.final-overlay.hide {
    opacity: 0;
}

.final-title {
    font-size: 4.5rem;
    font-weight: bold;
    margin: 0;
    background: linear-gradient(135deg, #ff6b9d, #ff3838, #ff6b9d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 30px rgba(255, 56, 56, 0.6));
    animation: titlePulse 3s ease-in-out infinite;
    letter-spacing: 10px;
}

@keyframes titlePulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 30px rgba(255, 56, 56, 0.6)); }
    50% { transform: scale(1.05); filter: drop-shadow(0 0 40px rgba(255, 56, 56, 0.8)); }
}

.final-timer {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    padding: 25px 40px;
    animation: fadeInUp 1s ease 0.5s both;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.timer-label {
    display: block;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 15px;
    letter-spacing: 3px;
    text-shadow: 0 0 10px rgba(255, 107, 157, 0.3);
}

.timer-digits {
    display: flex;
    gap: 25px;
    justify-content: center;
}

.timer-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
    transition: transform 0.3s ease;
}

.timer-unit:hover {
    transform: translateY(-5px);
}

.timer-unit span {
    font-size: 3rem;
    font-weight: bold;
    color: #ff6b9d;
    line-height: 1;
    text-shadow: 0 0 20px rgba(255, 107, 157, 0.6);
    transition: transform 0.3s ease;
}

.timer-unit span:hover {
    transform: scale(1.05);
}

.timer-unit small {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 8px;
    letter-spacing: 2px;
    text-shadow: 0 0 5px rgba(255, 107, 157, 0.3);
}

.final-subtitle {
    font-size: 1.8rem;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    letter-spacing: 5px;
    text-shadow: 0 0 20px rgba(255, 107, 157, 0.4);
    animation: fadeInUp 1s ease 0.8s both;
}

.final-hearts {
    display: flex;
    gap: 20px;
    animation: fadeInUp 1s ease 1s both;
}

.float-heart {
    font-size: 1.8rem;
    color: #ff6b9d;
    animation: floatHeart 4s ease-in-out infinite;
    text-shadow: 0 0 15px rgba(255, 107, 157, 0.6);
    transition: transform 0.3s ease;
}

.float-heart:hover {
    transform: scale(1.2);
}

.float-heart:nth-child(2) {
    animation-delay: 0.5s;
    font-size: 1.5rem;
}

.float-heart:nth-child(3) {
    animation-delay: 1s;
    font-size: 2rem;
}

@keyframes floatHeart {
    0%, 100% { transform: translateY(0) scale(1) rotate(0deg); opacity: 0.8; }
    25% { transform: translateY(-10px) scale(1.1) rotate(5deg); opacity: 0.9; }
    50% { transform: translateY(-20px) scale(1.2) rotate(0deg); opacity: 1; }
    75% { transform: translateY(-10px) scale(1.1) rotate(-5deg); opacity: 0.9; }
}

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

/* 响应式设计 */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
        letter-spacing: 3px;
    }

    .subtitle {
        font-size: 1rem;
        letter-spacing: 2px;
    }

    .btn-start {
        padding: 15px 35px;
        font-size: 1rem;
    }

    .heart {
        width: 100px;
        height: 100px;
    }

    .heart::before,
    .heart::after {
        width: 50px;
        height: 80px;
    }

    .heart::before {
        left: 50px;
    }

    .final-title {
        font-size: 3rem;
        letter-spacing: 5px;
    }

    .timer-digits {
        gap: 15px;
    }

    .timer-unit {
        min-width: 55px;
    }

    .timer-unit span {
        font-size: 2.2rem;
    }

    .timer-unit small {
        font-size: 0.8rem;
    }

    .final-subtitle {
        font-size: 1.2rem;
        letter-spacing: 2px;
    }

    .final-timer {
        padding: 15px 25px;
    }

    .music-control {
        width: 40px;
        height: 40px;
        top: 15px;
        right: 15px;
    }

    .loading-heart {
        width: 60px;
        height: 60px;
    }

    .heart-shape::before,
    .heart-shape::after {
        width: 30px;
        height: 50px;
    }

    .heart-shape::before {
        left: 30px;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.6rem;
        padding: 0 20px;
        letter-spacing: 2px;
    }

    .subtitle {
        font-size: 0.9rem;
        padding: 0 20px;
    }

    .btn-start {
        padding: 12px 28px;
        font-size: 0.9rem;
    }

    .heart {
        width: 80px;
        height: 80px;
    }

    .heart::before,
    .heart::after {
        width: 40px;
        height: 65px;
    }

    .heart::before {
        left: 40px;
    }

    .final-title {
        font-size: 2.5rem;
        letter-spacing: 3px;
    }

    .timer-digits {
        gap: 10px;
    }

    .timer-unit {
        min-width: 50px;
    }

    .timer-unit span {
        font-size: 1.8rem;
    }

    .timer-unit small {
        font-size: 0.75rem;
    }

    .final-subtitle {
        font-size: 1.2rem;
    }

    .final-timer {
        padding: 15px 25px;
    }

    .timer-digits {
        gap: 12px;
    }

    .timer-unit {
        min-width: 50px;
    }

    .timer-unit span {
        font-size: 1.5rem;
    }

    .timer-unit small {
        font-size: 0.7rem;
    }

    .music-volume {
        display: none;
    }

    .story-page-dots {
        right: 10px;
        gap: 6px;
    }

    .story-dot {
        width: 5px;
        height: 5px;
    }
}

/* 触摸优化 */
@media (hover: none) and (pointer: coarse) {
    .btn-start {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .music-control {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
}

/* 安全区域适配 */
@supports (padding-top: env(safe-area-inset-top)) {
    .music-control {
        top: calc(15px + env(safe-area-inset-top));
        right: calc(15px + env(safe-area-inset-right));
    }
}

/* 开场页装饰 */
.opening-decoration {
    position: absolute;
    bottom: 40px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 20px;
    opacity: 0;
    animation: fadeIn 2s ease-in-out forwards;
    animation-delay: 1.5s;
}

.decoration-heart {
    font-size: 1.5rem;
    color: rgba(255, 107, 157, 0.6);
    animation: floatHeartSimple 4s ease-in-out infinite;
    text-shadow: 0 0 10px rgba(255, 107, 157, 0.4);
}

.decoration-heart:nth-child(2) {
    animation-delay: 0.5s;
    font-size: 1.2rem;
}

.decoration-heart:nth-child(3) {
    animation-delay: 1s;
    font-size: 1.8rem;
}

@keyframes floatHeartSimple {
    0%, 100% { transform: translateY(0) scale(1); opacity: 0.6; }
    50% { transform: translateY(-15px) scale(1.2); opacity: 1; }
}

/* ==================== 树生长动画样式 ==================== */
.tree-growth-section {
    background: linear-gradient(135deg, #1a1a2e 0%, #2d1b4e 30%, #1e3a5f 60%, #0f3460 100%);
    display: none;
    overflow: hidden;
    position: relative;
}

.tree-growth-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(255, 107, 157, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.tree-growth-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.tree-canvas-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#treeCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: pointer;
}

.tree-text-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 40px 30px 30px;
    background: linear-gradient(transparent, rgba(12, 12, 29, 0.6) 30%, rgba(12, 12, 29, 0.85));
    z-index: 10;
    pointer-events: none;
}

#treeText {
    display: none;
    text-align: center;
    padding: 20px;
    max-width: 700px;
    margin: 0 auto;
}

.tree-text-line {
    font-size: 1.4rem;
    color: rgba(255, 255, 255, 0.95);
    margin: 12px 0;
    letter-spacing: 2px;
    font-weight: 400;
    line-height: 2;
    will-change: opacity, transform;
    position: relative;
}

.tree-text-line.tree-text-accent {
    font-size: 1.6rem;
    font-weight: 600;
    color: #ff6b9d;
    text-shadow: 0 0 12px rgba(255, 107, 157, 0.5), 0 0 25px rgba(255, 107, 157, 0.25);
    letter-spacing: 3px;
    animation: accentGlow 3s ease-in-out infinite alternate;
}

@keyframes accentGlow {
    0% {
        text-shadow: 0 0 12px rgba(255, 107, 157, 0.5), 0 0 25px rgba(255, 107, 157, 0.25);
    }
    100% {
        text-shadow: 0 0 18px rgba(255, 56, 56, 0.6), 0 0 35px rgba(255, 107, 157, 0.35);
    }
}

.tree-text-line.tree-text-sub {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 1.5px;
    font-style: italic;
}

.tree-text-line .tree-char {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px) scale(0.8);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.tree-text-line .tree-char.tree-char-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.tree-text-line.tree-text-accent .tree-char {
    transform: translateY(8px) scale(0.9);
}

.tree-text-line.tree-text-accent .tree-char.tree-char-visible {
    transform: translateY(0) scale(1);
}

#treeTimer {
    display: none;
    text-align: center;
    padding: 18px 30px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    margin-top: 25px;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 2px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.tree-digit {
    font-size: 1.8rem;
    font-weight: bold;
    color: #ff6b9d;
    margin: 0 5px;
    text-shadow: 0 0 15px rgba(255, 107, 157, 0.6);
    transition: transform 0.3s ease;
}

.tree-digit:hover {
    transform: scale(1.1);
}

.tree-hint {
    position: absolute;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    text-align: center;
    animation: treeHintPulse 2s ease-in-out infinite;
    z-index: 20;
    pointer-events: none;
    text-shadow: 0 0 20px rgba(255, 107, 157, 0.5);
    transition: opacity 0.5s ease;
    /* left/top 由 JS 动态设置到爱心下方 */
}

@keyframes treeHintPulse {
    0%, 100% { opacity: 0.6; transform: translateX(-50%) translateY(0); }
    50% { opacity: 1; transform: translateX(-50%) translateY(-5px); }
}

.tree-hint i {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 8px;
    animation: treeHintBounce 1.5s ease-in-out infinite;
}

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

.tree-skip-btn {
    position: absolute;
    bottom: 30px;
    right: 30px;
    padding: 12px 25px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 30px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.tree-skip-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

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

/* 响应式 - 树动画 */
@media (max-width: 768px) {
    .tree-text-line {
        font-size: 1.15rem;
        letter-spacing: 1.5px;
    }

    .tree-text-line.tree-text-accent {
        font-size: 1.3rem;
    }

    .tree-text-line.tree-text-sub {
        font-size: 1rem;
    }

    #treeTimer {
        font-size: 1rem;
        padding: 15px 25px;
    }

    .tree-digit {
        font-size: 1.5rem;
    }

    .tree-skip-btn {
        bottom: 20px;
        right: 20px;
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .tree-text-line {
        font-size: 1rem;
        letter-spacing: 1px;
    }

    .tree-text-line.tree-text-accent {
        font-size: 1.15rem;
    }

    .tree-text-line.tree-text-sub {
        font-size: 0.9rem;
    }
    
    .tree-digit {
        font-size: 1.3rem;
    }
    
    .tree-skip-btn {
        bottom: 15px;
        right: 15px;
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}

/* ==================== 左右分栏布局 ==================== */
.story-left-img,
.story-right-img {
    flex-direction: row;
    padding: 0;
}

.story-left-img .story-split-image,
.story-right-img .story-split-image {
    width: 50%;
    height: 100%;
    overflow: hidden;
}

.story-left-img .story-split-image img,
.story-right-img .story-split-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-left-img .story-split-text,
.story-right-img .story-split-text {
    width: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.story-left-img .story-split-text .story-text,
.story-right-img .story-split-text .story-text {
    font-size: 1.3rem;
    color: #fff;
    line-height: 2;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

/* 中心图片布局 */
.story-center-img {
    position: relative;
}

.story-center-img-container {
    max-width: 60%;
    max-height: 60vh;
    overflow: hidden;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.story-center-img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-center-img .story-center-text {
    margin-top: 30px;
    font-size: 2rem;
    color: #fff;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.7);
}

/* 多图布局 */
.story-multi-image .story-image-pair {
    display: flex;
    gap: 20px;
    max-width: 80%;
    max-height: 50vh;
    margin-bottom: 20px;
}

.story-multi-image .story-image-pair img {
    flex: 1;
    max-width: 50%;
    max-height: 50vh;
    object-fit: cover;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* 多图对角布局 - 仅限标记了 layout:diagonal 的页面 */
.story-multi-image-diagonal .story-image-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 20px;
    width: 75%;
    max-height: 60vh;
}

.story-multi-image-diagonal .story-image-pair img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.story-multi-image-diagonal .story-image-pair img:first-child {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    align-self: start;
}

.story-multi-image-diagonal .story-image-pair img:last-child {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    align-self: end;
}

.story-multi-image .story-text {
    font-size: 1.3rem;
    color: #fff;
    text-align: center;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

/* 纯文字布局 */
.story-text-only {
    background: radial-gradient(ellipse at center, rgba(255, 107, 157, 0.1) 0%, transparent 70%);
}

.story-text-only .story-text-group {
    max-width: 600px;
    text-align: center;
    margin: 0 auto;
}

.story-text-only .story-text-line {
    font-size: 1.5rem;
    color: #fff;
    margin: 15px 0;
    text-shadow: 0 0 15px rgba(255, 107, 157, 0.6);
    letter-spacing: 2px;
    line-height: 1.8;
    white-space: nowrap;
}

/* 最后一页特殊样式 */
.story-final-text {
    background: radial-gradient(ellipse at center, rgba(255, 107, 157, 0.2) 0%, rgba(255, 56, 56, 0.05) 50%, transparent 80%);
}

.story-final-text .story-text-group {
    max-width: none;
}

.story-final-text .story-text-line {
    font-size: 1.8rem;
    animation: textFadeIn 1s ease forwards;
    opacity: 0;
}

.story-final-text .story-text-line:nth-child(1) { animation-delay: 0.3s; }
.story-final-text .story-text-line:nth-child(2) { animation-delay: 0.8s; }

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

.story-final-text .story-text-line:last-child {
    font-size: 2.2rem;
    color: #ff6b9d;
    animation: heartbeat 1.5s ease-in-out infinite, textFadeIn 1s ease forwards;
    animation-delay: 1.3s, 1.3s;
}

.story-continue-btn {
    margin-top: 40px;
    padding: 15px 40px;
    background: linear-gradient(135deg, rgba(255, 107, 157, 0.9), rgba(255, 56, 56, 0.9));
    border: none;
    border-radius: 50px;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    letter-spacing: 3px;
    transition: all 0.3s ease;
    animation: textFadeIn 1s ease forwards;
    animation-delay: 2s;
    opacity: 0;
    box-shadow: 0 4px 20px rgba(255, 107, 157, 0.4);
}

.story-continue-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 30px rgba(255, 107, 157, 0.6);
}

.story-continue-btn:active {
    transform: scale(0.98);
}

/* ==================== 页面指示器圆点 ==================== */
.story-page-dots {
    position: fixed;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.story-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.story-dot:hover {
    background: rgba(255, 255, 255, 0.6);
    transform: scale(1.3);
}

.story-dot.active {
    background: #ff6b9d;
    box-shadow: 0 0 10px rgba(255, 107, 157, 0.6);
    transform: scale(1.3);
}

/* ==================== 懒加载图片 ==================== */
.lazy-img {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.lazy-img.loaded {
    opacity: 1;
}

/* ==================== 页面入场动画 ==================== */
.story-page-content {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.story-page-content.animate-in {
    opacity: 1;
    transform: translateY(0);
}

.story-page:first-child .story-page-content {
    opacity: 1;
    transform: translateY(0);
}

/* ==================== 额外优化样式 ==================== */

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 选中文本样式 */
::selection {
    background: rgba(255, 107, 157, 0.3);
    color: #fff;
}

/* 焦点样式 */
:focus-visible {
    outline: 2px solid rgba(255, 107, 157, 0.5);
    outline-offset: 2px;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 107, 157, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 107, 157, 0.7);
}

/* 按钮通用样式 */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    margin: 0;
}

/* 链接样式 */
a {
    color: inherit;
    text-decoration: none;
}

/* 工具提示样式 */
[title] {
    position: relative;
}

[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 0.85rem;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

/* 动画性能优化 */
.heart,
.float-heart,
.decoration-heart,
.music-visualizer span,
.tree-digit,
.timer-unit {
    will-change: transform;
}

/* 减少动画 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
