/* === 全局变量和基础样式 === */
:root {
    --main-pink: #ff9a9e;
    --light-pink: #fad0c4;
    --paper-bg: #fffdf2;
    --text-color: #555;
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}

html, body {
    margin: 0; padding: 0;
    font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    background-image: linear-gradient(to top, #fad0c4 0%, #ffd1ff 100%);
    min-height: 100%; color: var(--text-color); overflow-x: hidden;
}

/* === 背景泡泡动画 === */
.bg-bubbles {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1; overflow: hidden; margin: 0; padding: 0;
}
.bg-bubbles li {
    position: absolute; display: block; list-style: none;
    width: 40px; height: 40px; background-color: rgba(255, 255, 255, 0.3);
    bottom: -150px; border-radius: 50%;
    animation: square 25s infinite linear;
}
.bg-bubbles li:nth-child(1) { left: 10%; width: 80px; height: 80px; animation-duration: 10s; }
.bg-bubbles li:nth-child(2) { left: 20%; width: 20px; height: 20px; animation-duration: 12s; animation-delay: 2s; }
.bg-bubbles li:nth-child(3) { left: 25%; width: 50px; height: 50px; animation-delay: 4s; }
.bg-bubbles li:nth-child(4) { left: 40%; width: 60px; height: 60px; animation-duration: 22s; background-color: rgba(255, 255, 255, 0.25); }
.bg-bubbles li:nth-child(5) { left: 70%; width: 40px; height: 40px; animation-duration: 15s; }
.bg-bubbles li:nth-child(6) { left: 85%; width: 90px; height: 90px; animation-delay: 3s; background-color: rgba(255, 255, 255, 0.2); }
@keyframes square {
    0% { transform: translateY(0); }
    100% { transform: translateY(-1200px) rotate(600deg); }
}

/* === 1. 封面页样式 === */
#cover-page { height: 100vh; height: 100svh; display: flex; justify-content: center; align-items: center; }
.cover-content {
    background: rgba(255, 255, 255, 0.9); padding: 40px; border-radius: 30px;
    text-align: center; box-shadow: var(--shadow); max-width: 85%; box-sizing: border-box;
}
.dog-heart-container { margin-bottom: 15px; }
.cover-heart-gif { width: 120px; height: auto; }
.cover-content h1 {
    font-size: 1.6rem; color: var(--main-pink); margin-bottom: 10px;
    background: linear-gradient(to right, #ff9a9e, #fecfef);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.subtitle { font-size: 1rem; color: #888; letter-spacing: 2px; }

/* === 按钮样式 === */
button {
    padding: 15px 30px; border: none; border-radius: 50px; font-size: 1rem;
    font-weight: bold; cursor: pointer; transition: all 0.3s ease; -webkit-tap-highlight-color: transparent;
    font-family: inherit; 
    
    white-space: nowrap;
    display: flex; justify-content: center; align-items: center;
    gap: 5px; 
    /* 注意：这里的 margin: 0 auto 会导致 flex 布局里的右对齐失效，所以下面我们在 .text-btn 里覆盖了它 */
    margin: 0 auto;
}
#enter-btn {
    background: linear-gradient(to right, #ff9a9e, #fecfef); color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 129, 0.3);
}
#enter-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(255, 107, 129, 0.5); }

/* === 2. 过渡动画层样式 === */
#loading-layer {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: transparent; z-index: 999; display: flex; justify-content: center; align-items: center;
}
.loading-content { text-align: center; }
.claw-img {
    max-width: 220px; height: auto; filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.8));
    animation: float 3s ease-in-out infinite; 
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}
.loading-text {
    color: #ff7e95; font-size: 1.2rem; font-weight: bold; margin-top: 30px;
    animation: blink 1.5s infinite; text-shadow: 0 2px 4px rgba(255,255,255,0.5);
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* === 3. 主内容区与纸条 === */
#main-content { padding: 30px 20px; min-height: 100vh; box-sizing: border-box; }

.paper-wrapper {
    width: 100%; max-width: 480px; margin: 60px auto 0; 
    display: flex; justify-content: center; align-items: center;
    min-height: 300px; perspective: 1000px;
}

/* 纸团状态 */
.paper-note.crumpled {
    width: 70px; height: 70px; background-color: #fffdf2;
    border-radius: 48% 52% 53% 47% / 53% 46% 54% 47%;
    box-shadow: inset 10px 10px 20px rgba(0,0,0,0.15), inset -5px -5px 15px rgba(255,255,255,0.5), 0 10px 20px rgba(0,0,0,0.2);
    background-image: radial-gradient(circle at 30% 30%, transparent 0%, rgba(0,0,0,0.05) 100%);
    transform: scale(0.8) rotate(-25deg) translateZ(-100px);
    opacity: 0; overflow: hidden; padding: 0;
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 展开状态 */
.paper-note.unfold {
    width: 100%; height: auto; border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    background-image: linear-gradient(#f1f1f1 1px, transparent 1px);
    background-size: 100% 2rem;
    transform: scale(1) rotate(0deg) translateZ(0);
    opacity: 1; 
    padding: 30px 30px 110px 30px; 
    overflow: hidden; box-sizing: border-box; position: relative;
}

/* 文字 */
.note-text {
    font-size: 1rem; color: #444; white-space: pre-wrap; line-height: 1.8;
    margin-bottom: 20px; font-family: inherit; 
    opacity: 0; transition: opacity 1s ease 0.8s;
}

/* 图片容器 */
.note-img-container {
    text-align: center; margin: 20px 0; 
    opacity: 0; transition: opacity 1s ease 0.8s;
}
.note-img {
    max-width: 85%; height: auto; display: inline-block;
    border-radius: 8px; border: 5px solid #fff; box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.note-date {
    text-align: right; font-size: 0.9rem; color: var(--main-pink);
    margin-top: 25px; font-style: italic; font-weight: bold;
    opacity: 0; transition: opacity 1s ease 0.8s;
}

/* 右下角小狗 */
.paper-author-img {
    position: absolute; bottom: 10px; right: 20px;
    width: 80px; height: auto; mix-blend-mode: multiply; pointer-events: none; 
    opacity: 0; transition: opacity 1s ease 0.8s;
}

/* 展开后显示内容 */
.paper-note.unfold .note-text, 
.paper-note.unfold .note-img-container,
.paper-note.unfold .note-date,
.paper-note.unfold .paper-author-img { opacity: 1; }

/* 底部按钮区 */
.actions {
    width: 100%; max-width: 480px; margin: 0 auto; margin-top: 60px; 
    display: flex; justify-content: space-between; 
    opacity: 0; transform: translateY(20px); pointer-events: none; 
    transition: all 1s ease;
}
.actions.show { opacity: 1; transform: translateY(0); pointer-events: auto; }

.secondary-btn {
    background: rgba(255,255,255,0.95); color: var(--main-pink);
    border: 2px solid var(--main-pink); padding: 12px 0;
    width: 45%; text-align: center; border-radius: 50px; font-weight: bold;
    
    white-space: nowrap;
    display: flex; justify-content: center; align-items: center;
}
.secondary-btn:hover { background: #fff; box-shadow: 0 5px 15px rgba(255, 154, 158, 0.2); }

/* === 历史记录侧边栏 === */
#history-section {
    background: rgba(255,255,255,0.98); 
    position: fixed; bottom: 0; left: 0; width: 100%; height: 60vh;
    border-radius: 25px 25px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,0.15);
    padding: 25px; box-sizing: border-box;
    transform: translateY(110%); transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); z-index: 1000;
    display: flex; flex-direction: column;
}
#history-section.show { transform: translateY(0); }

/* 【修改】确保 Header 占满宽度并两端对齐 */
.history-header {
    display: flex; 
    justify-content: space-between; /* 左右分开 */
    align-items: center;
    margin-bottom: 0; padding-bottom: 10px; border-bottom: 2px solid #eee;
    flex-shrink: 0;
    width: 100%;
}
.history-header h3 { margin: 0; color: var(--main-pink); }

/* 【修改】重置关闭按钮的 margin，防止它被全局样式居中 */
.text-btn { 
    background: none; border: none; color: #999; font-size: 1rem; padding: 5px 10px;
    margin: 0; /* 关键：取消自动居中 */
}

/* 横向滚动容器 */
#history-list {
    flex-grow: 1; display: flex; overflow-x: auto; overflow-y: hidden;
    align-items: flex-start;
    padding: 20px 30px 60px 30px;
    scroll-snap-type: x mandatory; 
    -webkit-overflow-scrolling: touch;
}

/* 历史卡片 */
.history-card {
    align-self: flex-start;
    flex: 0 0 80%; min-width: 280px; margin-right: 20px;
    background: #fff; 
    padding: 25px; 
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08); 
    border: 1px solid #f9f9f9;
    
    display: flex; flex-direction: column; justify-content: center;
    text-align: center;
    
    box-sizing: border-box;
    scroll-snap-align: center;
}
.history-card:last-child { margin-right: 0; }

/* 历史文字 */
.history-text {
    font-size: 0.95rem; line-height: 1.6; color: #555;
    white-space: pre-wrap; 
    font-family: inherit; 
    text-align: center; 
}

/* 历史日期 */
.history-date { 
    text-align: center; 
    font-size: 0.85rem; color: #bbb; 
    margin-top: 20px; 
}

/* 历史图片 */
.history-img-container { text-align: center; margin-top: 15px; }
.history-img {
    max-height: 150px; width: auto; max-width: 100%;
    border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}