:root {
    /* 更加柔和高级的配色 */
    --primary-color: #e88080; 
    --secondary-color: #fcebeb;
    --text-main: #5a4a4a;
    --text-light: #887;
    --bg-gradient: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    --font-main: 'Noto Serif SC', serif;
    --font-hand: 'Ma Shan Zheng', cursive; /* 手写体 */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-main);
    background: #fdf6f6; /* 浅粉白背景 */
    color: var(--text-main);
    overflow-x: hidden;
}

#heartCanvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }

/* 隐藏原生 audio 控件（我们用自定义按钮控制） */
#bgMusic { position: absolute; width: 0; height: 0; overflow: hidden; opacity: 0; pointer-events: none; }

/* --- 悬浮音乐播放器 --- */
.music-toggle {
    position: fixed;
    bottom: 28px;
    right: 8px;
    width: 56px;
    height: 56px;
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,250,250,0.9));
    border-radius: 50%;
    box-shadow: 0 10px 30px rgba(232,128,128,0.12), 0 3px 8px rgba(0,0,0,0.06);
    z-index: 1000;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid rgba(232,128,128,0.9);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    transform: translateX(-6px); /* 向左微调，防止超出 */
    outline: none;
}

.music-toggle:active { transform: translateY(2px) scale(0.995); }
.music-toggle:focus { box-shadow: 0 0 0 4px rgba(232,128,128,0.12); }

/* 如果右边有安全区 (刘海屏)，在 safe-area 基础上再向左偏移保证可见 */
@supports (padding: env(safe-area-inset-right)) {
    .music-toggle { right: calc(8px + env(safe-area-inset-right)); transform: translateX(-8px); }
}

.music-toggle .disc {
    width: 68%;
    height: 68%;
    background: radial-gradient(circle at 30% 30%, #222, #444 40%, #333 100%);
    border-radius: 50%;
    position: relative;
    display: flex; align-items: center; justify-content: center;
}

.music-toggle .ring {
    position: absolute; width: 100%; height: 100%; border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(232,128,128,0.06) inset;
    pointer-events: none;
}

.music-toggle .icon {
    position: absolute; width: 28px; height: 28px; display: block; fill: #fff; user-select: none;
}
.music-toggle .icon-play { transform: translateX(0); }
.music-toggle .icon-pause { display: none; }

.music-toggle.playing { box-shadow: 0 10px 30px rgba(232,128,128,0.28), 0 6px 18px rgba(200,100,120,0.12); }
.music-toggle.playing .disc { animation: spin 3s linear infinite; }
.music-toggle.playing .icon-play { display: none; }
.music-toggle.playing .icon-pause { display: block; }

/* 小的脉冲动画（正在播放时） */
.music-toggle.playing::after {
    content: '';
    position: absolute; width: 90%; height: 90%; border-radius: 50%;
    box-shadow: 0 0 30px rgba(232,128,128,0.18);
    animation: pulse 1.8s ease-out infinite;
    pointer-events: none;
}

@keyframes pulse { 0% { transform: scale(0.9); opacity: 0.6;} 70% { transform: scale(1.05); opacity: 0;} 100% { transform: scale(1.1); opacity: 0;} }

@keyframes spin { 100% { transform: rotate(360deg); } }

/* 小屏幕和刘海屏适配：确保按钮不会超出屏幕边缘 */
@media (max-width: 420px) {
    .music-toggle { right: 6px; bottom: 18px; width: 52px; height: 52px; transform: translateX(-4px); }
    .music-toggle .icon { width: 24px; height: 24px; }
}

@supports (padding: env(safe-area-inset-right)) {
    .music-toggle { right: calc(18px + env(safe-area-inset-right)); }
}

/* --- 开场页 --- */
.landing-page {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100vh;
    background: rgba(255, 240, 245, 0.95);
    display: flex; justify-content: center; align-items: center;
    z-index: 2000;
}

.landing-page .title { font-family: var(--font-hand); font-size: 3.5rem; color: var(--primary-color); }
.landing-page .subtitle { margin: 20px 0 40px; color: var(--text-light); letter-spacing: 2px; }

#startBtn {
    padding: 12px 35px;
    background: var(--primary-color);
    color: white; border: none; border-radius: 25px;
    font-size: 1.1rem; cursor: pointer;
    box-shadow: 0 5px 15px rgba(232, 128, 128, 0.4);
    transition: 0.3s;
}
#startBtn:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(232, 128, 128, 0.6); }

.hidden { display: none; }
.main-container { max-width: 1000px; margin: 0 auto; padding: 20px; }

/* --- 头部 --- */
.hero { height: 70vh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.hero-title { font-size: 4rem; font-family: var(--font-hand); margin-bottom: 20px; color: #444; }
.hero-title .highlight { color: var(--primary-color); }
.hero-text { font-size: 1.2rem; color: var(--text-light); letter-spacing: 3px; }

/* --- 计时器 (新设计) --- */
.timer-section { text-align: center; margin-bottom: 4rem; }
.timer-section h2 { font-family: var(--font-hand); font-size: 2rem; margin-bottom: 2rem; color: var(--text-main); }

.timer-container {
    display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 15px;
}

.timer-box {
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(10px);
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    display: flex; flex-direction: column; align-items: center;
    min-width: 80px;
}

.timer-box .time-num { font-size: 2.5rem; font-weight: bold; color: var(--primary-color); line-height: 1; }
.timer-box .time-label { font-size: 0.9rem; margin-top: 5px; color: var(--text-light); }
.timer-separator { font-size: 2rem; align-self: center; color: #ccc; margin-bottom: 20px; }

/* 移动端小时分钟稍微小一点 */
.timer-box.sm .time-num { font-size: 2rem; }

/* --- 瀑布流 --- */
.timeline h2 { text-align: center; font-family: var(--font-hand); font-size: 2.2rem; margin-bottom: 2rem; }

.memory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    grid-auto-flow: dense; /* 关键：自动填补空隙 */
}

.memory-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    transition: transform 0.3s;
    cursor: zoom-in;
    background: #fff;
}
.memory-item:hover { transform: translateY(-5px); box-shadow: 0 15px 30px rgba(0,0,0,0.15); z-index: 10; }

.memory-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 格子布局控制 */
.memory-item.wide { grid-column: span 2; }
.memory-item.tall { grid-row: span 2; }

/* 拍立得样式 */
.memory-item.polaroid {
    padding: 10px 10px 50px 10px;
    background: white;
}
.memory-item.polaroid img { border-radius: 5px; border: 1px solid #eee; }
.memory-item figcaption {
    position: absolute; bottom: 10px; left: 0; width: 100%;
    text-align: center; font-family: var(--font-hand); color: #666; font-size: 1.2rem;
}

/* --- 情书 --- */
.letter-section { margin: 6rem 0; display: flex; justify-content: center; perspective: 1000px; }
.envelope {
    background: #fff; width: 100%; max-width: 600px; padding: 40px;
    border-radius: 5px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    position: relative;
    border: 1px solid #eaeaea;
}
.envelope::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 10px;
    background: repeating-linear-gradient(45deg, #e88080 0, #e88080 10px, #fff 10px, #fff 20px, #80bae8 20px, #80bae8 30px, #fff 30px, #fff 40px);
}
.stamp { position: absolute; top: 30px; right: 30px; font-size: 3rem; transform: rotate(20deg); opacity: 0.2; }
.letter-content h3 { font-family: var(--font-hand); margin-bottom: 20px; color: var(--primary-color); }
.letter-content p { line-height: 2; color: #666; font-size: 1.05rem; font-family: var(--font-hand); }
.signature { text-align: right; margin-top: 30px; font-family: var(--font-hand); font-size: 1.5rem; }

/* --- 灯箱 --- */
.lightbox {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); z-index: 3000;
    display: none; justify-content: center; align-items: center;
}
.lightbox.active { display: flex; animation: fadeIn 0.3s; }
.lightbox-content { max-width: 90%; max-height: 90vh; border-radius: 5px; box-shadow: 0 0 20px rgba(0,0,0,0.5); }
.close-lightbox {
    position: absolute; top: 20px; right: 30px;
    font-size: 40px; color: white; cursor: pointer;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .hero-title { font-size: 2.5rem; }
    .timer-box { padding: 10px; min-width: 60px; }
    .timer-box .time-num { font-size: 1.5rem; }
    .memory-item.wide, .memory-item.tall { grid-column: span 1; grid-row: span 1; }
    .envelope { padding: 25px; }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }