/* 预加载样式 */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff5f5;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}
.preloader-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
#preload-title {
    color: #ff6b6b;
    font-family: 'Comic Sans MS', cursive;
    margin-bottom: 20px;
    font-size: 2em;
}
.progress-bar {
    width: 70%;
    height: 12px;
    background: #ffe6e6;
    border-radius: 6px;
    margin-bottom: 20px;
}
.progress {
    width: 0%;
    height: 100%;
    background: #ff6b6b;
    transition: width 0.3s;
    border-radius: 6px;
}
#preload-text {
    color: #666;
    font-family: 'Comic Sans MS', cursive;
    margin-bottom: 20px;
}
#start-button {
    padding: 10px 20px;
    background: #ff6b6b;
    border: none;
    border-radius: 20px;
    color: white;
    font-family: 'Comic Sans MS', cursive;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s ease;
}
#start-button:hover {
    background: #ff5252;
}
.hidden {
    display: none;
}

/* 基础样式 */
body {
    margin: 0;
    overflow: hidden;
    font-family: 'Comic Sans MS', cursive;
}
.page-container {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    overflow: visible; /* 确保内容不会被裁剪 */
}
.page {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: absolute;
    padding: 20px;
    box-sizing: border-box;
    background: linear-gradient(135deg, #fff5f5 30%, #f0f9ff 100%);
    color: #333;
    z-index: 1;
    /* 统一的过渡效果 */
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease-out;
}

/* 内容容器 */
.content {
    max-width: 600px;
    width: 90%;
    text-align: center;
    z-index: 2;
}

/* 翻页动画状态 */
.page:not(.active) {
    transform: translateY(100%); /* 非活动页默认在屏幕下方 */
    opacity: 0; /* 非活动页默认透明，滑入时会通过 .active 的 opacity: 1 渐变 */
}

/* Page 1 特殊处理：初始位置和激活效果 */
#page1:not(.active) {
    transform: translateY(0) !important; /* 强制 page1 始终在 Y 轴 0 的位置 */
    opacity: 0 !important; /* 非激活的 page1 是透明的 */
}
#page1.active {
    transform: translateY(0) !important; /* 确保激活时也在原位 */
    animation: pageFadeIn 1s ease-out forwards; /* 使用自定义淡入动画 */
    /* opacity: 1;  由 pageFadeIn 动画处理 */
}
@keyframes pageFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 通用激活状态 */
.page.active {
    transform: translateY(0); /* 活动页面滑到中间 */
    opacity: 1; /* 活动页面完全可见 */
}

/* 通用退出状态 */
.page.exit {
    transform: translateY(-100%); /* 退出的页面向上滑走 */
    opacity: 0; /* 同时淡出 */
}


/* 文字动画 */
.text-line {
    opacity: 0;
    transform: translateX(-50px);
    margin: 10px 0;
}
.text-line:nth-child(even) {
    transform: translateX(50px);
}
.animate .text-line {
    animation: textSlideIn 0.8s ease-out forwards;
}
@keyframes textSlideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 特殊样式 */
.highlight {
    color: #ff6b6b;
    font-size: 1.3em;
}
.emphasis {
    font-weight: bold;
}

/* 图片动画 */
.falling-img {
    width: min(150px, 30vw);
    margin: 20px 0;
    animation: floatIn 2s ease-out forwards;
}
@keyframes floatIn {
    from { transform: translateX(100vw) rotate(15deg); opacity: 0; }
    to { transform: translateX(0) rotate(0); opacity: 1; }
}

/* 最终页 */
.birthday-text {
    font-size: 2.5em;
    color: #ff6b6b;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}
#signature {
    position: absolute;
    bottom: 20px;
    right: 20px;
    color: #666;
    font-size: 1.1em;
}

/* 控制按钮样式 */
#prev-page, #next-page, #audio-control {
    position: absolute;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.7);
    border: none;
    border-radius: 20px;
    color: #ff6b6b;
    font-family: 'Comic Sans MS', cursive;
    cursor: pointer;
    transition: background 0.3s ease;
    z-index: 100;
}
#prev-page {
    top: 20px;
    left: 20px;
}
#next-page {
    top: 20px;
    right: 20px;
}
#audio-control {
    top: 20px;
    right: 100px; /* 根据按钮数量和间距调整，确保不和 next-page 重叠 */
}
#prev-page:hover, #next-page:hover, #audio-control:hover {
    background: rgba(255, 255, 255, 0.9);
}