
/* === 1. CSS 变量（主题系统） === */
:root {
    /* 默认粉色主题 */
    --bg-primary: #fdf6f6;
    --bg-card: #fffbfb;
    --bg-body: #f0e6e6;
    --border: #e6d4d4;
    --text: #5c4747;
    --title: #c88a8a;
    --accent: #d59f9f;
    --btn: #e0baba;
    --btn-hover: #d59f9f;
    --success: #7cb97c;
    --warning: #e6c86e;
    --danger: #e07070;
    --border-color: var(--border);
    --text-color: var(--text);
    --title-color: var(--title);
    --danger-color: var(--danger);
    --success-color: var(--success);
    --highlight-color: var(--accent);
    --body-bg: var(--bg-body);
    --button-bg: var(--btn);
    --button-hover: var(--btn-hover);
}

[data-theme="vintage"] {
    --bg-primary: #f5f0e8; --bg-card: #faf8f0; --bg-body: #e8e0d0;
    --border: #d8d0c0; --text: #5a4a3a; --title: #a07850;
    --accent: #c09060; --btn: #d0b090; --btn-hover: #c09060;
    --success: #8a9a6a; --warning: #d0a850; --danger: #b06050;
}

[data-theme="newspaper"] {
    --bg-primary: #f8f8f8; --bg-card: #ffffff; --bg-body: #eeeeee;
    --border: #d0d0d0; --text: #333333; --title: #555555;
    --accent: #666666; --btn: #e0e0e0; --btn-hover: #d0d0d0;
    --success: #606060; --warning: #888888; --danger: #444444;
}

[data-theme="green"] {
    --bg-primary: #f0f5f0; --bg-card: #f8faf8; --bg-body: #e0e8e0;
    --border: #c8d8c8; --text: #3a4a3a; --title: #5a7a5a;
    --accent: #6a8a6a; --btn: #a0c0a0; --btn-hover: #8ab08a;
    --success: #6a9a6a; --warning: #b8a860; --danger: #a06050;
}

[data-theme="ticket"] {
    --bg-primary: #faf5e8; --bg-card: #fffcf0; --bg-body: #ede8d8;
    --border: #e0d8c0; --text: #5a5040; --title: #9a8050;
    --accent: #b09060; --btn: #d8c8a0; --btn-hover: #c8b890;
    --success: #8a9a6a; --warning: #c8a050; --danger: #a06050;
}

[data-theme="custom"] {
    --bg-primary: #fdf6f6; --bg-card: #fffbfb; --bg-body: #f0e6e6;
    --border: #e6d4d4; --text: #5c4747; --title: #c88a8a;
    --accent: #d59f9f; --btn: #e0baba; --btn-hover: #d59f9f;
}

/* === 2. 基础重置 === */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Noto Serif SC', 'KaiTi', serif;
    background: var(--bg-body);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* === 3. 游戏容器 === */
#game-container {
    width: 100%; max-width: 420px;
    height: 100vh; height: 100dvh; max-height: 900px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    box-shadow: 0 0 40px rgba(200, 138, 138, 0.2);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

@media (min-width: 500px) {
    #game-container { border-radius: 25px; height: 96vh; }
}

/* === 4. 头部 === */
header {
    background: linear-gradient(135deg, var(--bg-card) 0%, #fff5f5 100%);
    padding: 10px 15px;
    border-bottom: 1.5px solid var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.header-top { display: flex; justify-content: space-between; align-items: center; }

.header-title {
    font-size: 15px; color: var(--title); font-weight: 700;
    display: flex; align-items: center; gap: 5px;
}

.settings-btn {
    background: none; border: none; font-size: 18px;
    cursor: pointer; padding: 5px; border-radius: 50%;
    transition: background 0.3s;
}
.settings-btn:hover { background: rgba(200,138,138,0.1); }

.status-bar {
    display: flex; justify-content: space-around; align-items: center;
    margin-top: 8px; font-size: 11px; padding: 0 5px;
}

.status-item {
    display: flex; align-items: center; gap: 3px;
    background: white; padding: 3px 8px;
    border-radius: 10px; border: 1px solid var(--border);
}
.status-item.warning { border-color: var(--warning); background: #fffef5; }
.status-item.danger { border-color: var(--danger); background: #fff5f5; }

/* === 5. 主内容区 === */
#main-content {
    flex: 1; overflow-y: auto; padding: 12px;
    position: relative; z-index: 5; scroll-behavior: smooth;
}
#main-content::-webkit-scrollbar { width: 0; }

/* === 6. 卡片系统 === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 14px; margin-bottom: 10px;
    box-shadow: 0 3px 12px rgba(200, 138, 138, 0.06);
    animation: cardFadeIn 0.4s ease-out backwards;
}

.card:nth-child(1) { animation-delay: 0.03s; }
.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.09s; }
.card:nth-child(4) { animation-delay: 0.12s; }
.card:nth-child(5) { animation-delay: 0.15s; }

.card-title {
    display: flex; align-items: center; gap: 6px;
    color: var(--title); font-weight: bold; font-size: 13px;
    margin-bottom: 10px; padding-bottom: 8px;
    border-bottom: 1px dashed var(--border);
}
.card-title .icon { font-size: 15px; }

.diary-card {
    background: linear-gradient(135deg, #faf3e0, #fdf8e8);
    border-color: #dcd3b2;
}
.diary-card .card-title { color: #a08050; border-bottom-color: #dcd3b2; }

/* 可折叠卡片 */
.collapsible-header {
    display: flex; justify-content: space-between;
    align-items: center; cursor: pointer; user-select: none;
}
.collapsible-header .toggle-icon { transition: transform 0.3s; font-size: 12px; }
.collapsible-header.collapsed .toggle-icon { transform: rotate(-90deg); }
.collapsible-content {
    max-height: 800px;
    overflow-y: auto;
    transition: max-height 0.3s ease-out;
}.collapsible-content.collapsed { max-height: 0; }

/* === 7. 按钮系统 === */
.btn {
    background: linear-gradient(135deg, var(--btn), var(--accent));
    color: white; border: none; border-radius: 10px;
    padding: 10px 16px; font-size: 13px;
    font-family: 'Noto Serif SC', serif; font-weight: bold;
    cursor: pointer; transition: all 0.3s ease;
    box-shadow: 0 3px 12px rgba(200, 138, 138, 0.2);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(200, 138, 138, 0.3); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn.secondary {
    background: white; color: var(--title);
    border: 1.5px solid var(--border);
    box-shadow: 0 2px 8px rgba(200, 138, 138, 0.08);
}
.btn.secondary:hover { background: #fff5f5; border-color: var(--accent); }

.btn.small { padding: 6px 10px; font-size: 11px; border-radius: 8px; }

.btn.glow { animation: btnGlow 2s ease-in-out infinite; }

.btn.loading { pointer-events: none; opacity: 0.7; }
.btn.loading::after { content: '...'; animation: dots 1s infinite; }

.btn-group { display: flex; gap: 8px; margin-top: 12px; }
.btn-group .btn { flex: 1; }

/* === 8. 表单元素 === */
.input-group { margin-bottom: 10px; }
.input-group label {
    display: block; font-size: 11px; color: var(--title);
    margin-bottom: 4px; font-weight: bold;
}

.input-field, .textarea-field {
    width: 100%; padding: 9px 11px;
    border: 1.5px solid var(--border); border-radius: 8px;
    background: white; color: var(--text);
    font-family: 'Noto Serif SC', serif; font-size: 12px;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.input-field:focus, .textarea-field:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(200, 138, 138, 0.12);
}
.textarea-field { min-height: 60px; resize: vertical; }

/* === 9. 进度条 === */
.progress-bar {
    width: 100%; height: 6px; background: #f0e0e0;
    border-radius: 10px; overflow: hidden; margin: 3px 0;
}
.progress-bar .fill {
    height: 100%; border-radius: 10px; transition: width 0.6s ease-out;
}
.progress-bar .fill.love, .progress-bar .fill.danger { background: linear-gradient(90deg, #f5a0a0, #e07070); }
.progress-bar .fill.harmony, .progress-bar .fill.skill { background: linear-gradient(90deg, #a0d0a0, #70b070); }
.progress-bar .fill.warning { background: linear-gradient(90deg, #f5d0a0, #e0a070); }
.progress-bar .fill.mood { background: linear-gradient(90deg, #f0c0f0, #d090d0); }

/* === 10. 底部导航 === */
footer {
    background: linear-gradient(180deg, var(--bg-card), #fff5f5);
    border-top: 1.5px solid var(--border);
    display: flex; height: 54px; flex-shrink: 0;
    position: relative; z-index: 10;
    padding-bottom: env(safe-area-inset-bottom);
}

.tab-item {
    flex: 1; display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    color: #c0a8a8; font-size: 9px;
    cursor: pointer; transition: all 0.3s; position: relative;
}
.tab-item:hover, .tab-item.active { color: var(--title); }
.tab-item.active::before {
    content: ''; position: absolute; top: 0; left: 50%;
    transform: translateX(-50%); width: 24px; height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--btn));
    border-radius: 0 0 2px 2px;
}
.tab-item .tab-icon { font-size: 17px; margin-bottom: 1px; }

/* === 11. 弹窗系统 === */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(92, 71, 71, 0.5);
    display: none; justify-content: center; align-items: center; z-index: 200;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-primary);
    width: 92%; max-width: 360px; max-height: 85vh;
    border-radius: 18px; border: 2px solid var(--border);
    box-shadow: 0 8px 35px rgba(0, 0, 0, 0.12);
    overflow: hidden; display: flex; flex-direction: column;
}

.modal-header {
    background: linear-gradient(135deg, var(--accent), var(--btn));
    color: white; padding: 12px; text-align: center;
    font-size: 14px; font-weight: bold; flex-shrink: 0;
}

.modal-body {
    padding: 15px; overflow-y: auto; flex: 1;
    font-size: 13px; line-height: 1.8;
}

.modal-footer {
    padding: 10px 15px; border-top: 1px solid var(--border);
    display: flex; gap: 8px; flex-shrink: 0;
}
.modal-footer .btn { flex: 1; }

/* === 12. 加载动画 === */
#loading-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(253, 246, 246, 0.95);
    display: none; flex-direction: column;
    justify-content: center; align-items: center; z-index: 100;
}
#loading-overlay.active { display: flex; }

.loader-heart { font-size: 26px; animation: loaderHeart 1s ease-in-out infinite; }
.loading-text { margin-top: 12px; color: var(--title); font-size: 12px; }

/* === 13. 操作网格 === */
.action-grid, .map-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px;
}

.action-item, .map-item {
    background: white; border: 1.5px solid var(--border);
    border-radius: 10px; padding: 10px 6px; text-align: center;
    cursor: pointer; transition: all 0.3s;
}
.action-item:hover, .map-item:hover {
    border-color: var(--accent); transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(200, 138, 138, 0.12);
}
.action-item.disabled, .map-item.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.action-item .action-icon, .map-item .map-icon { font-size: 20px; margin-bottom: 3px; }
.action-item .action-name, .map-item .map-name { font-size: 10px; color: var(--text); }
.action-item .action-cost, .map-item .map-cost { font-size: 9px; color: #999; margin-top: 2px; }

/* === 14. 人物头像 === */
.person-avatar {
    width: 50px; height: 50px; border-radius: 50%;
    background: linear-gradient(135deg, #fff0f0, #ffe0e0);
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; flex-shrink: 0; cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden; vertical-align: middle; align-self: center;
}
.person-avatar:hover { transform: scale(1.05); box-shadow: 0 3px 12px rgba(200, 138, 138, 0.25); }
.person-avatar img { width: 100%; height: 100%; object-fit: cover; }

.person-card {
    display: flex; align-items: center; gap: 10px; padding: 10px;
    background: white; border: 1px solid var(--border);
    border-radius: 10px; margin-bottom: 8px;
}
.person-info { flex: 1; }
.person-name { font-size: 13px; font-weight: bold; color: var(--title); }
.person-desc { font-size: 10px; color: #888; margin-top: 2px; }
.person-mood { font-size: 11px; margin-top: 3px; }

/* === 15. 标签 === */
.skill-tag, .trait-tag, .achievement-badge {
    display: inline-block; padding: 3px 8px;
    border-radius: 10px; font-size: 10px; margin: 2px 4px 2px 0;
}
.skill-tag { background: #f0f5ff; color: #6080c0; }
.trait-tag { background: #fff0f5; color: var(--title); }
.achievement-badge {
    display: inline-flex; align-items: center; gap: 4px;
    background: linear-gradient(135deg, #fff8e0, #fff0c0);
    border: 1px solid #e0d0a0; color: #a08030;
}
.achievement-badge.locked { background: #f5f5f5; border-color: #e0e0e0; color: #aaa; }

.value-change {
    display: inline-block; padding: 1px 6px;
    border-radius: 8px; font-size: 10px; font-weight: bold; margin-left: 4px;
}
.value-change.up { background: #e8f5e8; color: var(--success); }
.value-change.down { background: #f5e8e8; color: var(--danger); }

/* === 16. 背包物品 === */
.bag-item {
    display: flex; align-items: center; gap: 8px; padding: 8px;
    background: white; border: 1px solid #f0e0e0;
    border-radius: 8px; margin-bottom: 6px; font-size: 11px;
}
.bag-item .item-icon { font-size: 18px; }
.bag-item .item-info { flex: 1; }
.bag-item .item-name { font-weight: bold; color: var(--text); }
.bag-item .item-desc { font-size: 10px; color: #999; margin-top: 1px; }

/* === 17. 八卦列表 === */
.gossip-item {
    padding: 8px 0; border-bottom: 1px dashed #f0e0e0;
    display: flex; gap: 6px; font-size: 11px; line-height: 1.5;
}
.gossip-item:last-child { border-bottom: none; }
.gossip-icon { font-size: 12px; flex-shrink: 0; }

/* === 18. 生理周期 === */
.cycle-indicator { display: flex; gap: 2px; margin: 8px 0; }
.cycle-day { flex: 1; height: 6px; border-radius: 3px; background: #f0e0e0; }
.cycle-day.period { background: #f0a0a0; }
.cycle-day.ovulation { background: #f0c0d0; }
.cycle-day.safe { background: #c0e0c0; }
.cycle-day.current { box-shadow: 0 0 0 2px var(--title); }

/* === 19. 开始页/选择卡片 === */
.start-choice { text-align: center; padding: 12px 0; }
.start-choice .welcome-text {
    font-size: 12px; color: var(--text);
    margin-bottom: 18px; line-height: 1.9;
}

.choice-card, .style-option {
    background: white; border: 2px solid var(--border);
    border-radius: 15px; padding: 18px 15px; margin-bottom: 10px;
    cursor: pointer; transition: all 0.3s;
}
.choice-card:hover, .style-option:hover {
    border-color: var(--accent); transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(200, 138, 138, 0.15);
}
.choice-card.selected, .style-option.selected {
    border-color: var(--accent);
    background: linear-gradient(135deg, #fff8f8, #fff0f0);
}

.choice-card .choice-icon { font-size: 32px; margin-bottom: 8px; }
.choice-card .choice-title { font-size: 15px; color: var(--title); font-weight: bold; margin-bottom: 5px; }
.choice-card .choice-desc { font-size: 10px; color: #999; line-height: 1.5; }

/* === 20. 主题编辑器 === */
.theme-editor { display: none; padding: 15px; background: var(--bg-card); border-radius: 10px; margin-top: 10px; }
.theme-editor.active { display: block; }

.color-picker-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 0; border-bottom: 1px dashed var(--border);
}
.color-picker-item:last-child { border-bottom: none; }
.color-picker-label { font-size: 11px; color: var(--text); }
.color-picker-input { width: 50px; height: 30px; border: 1px solid var(--border); border-radius: 5px; cursor: pointer; }

/* === 21. 流式显示 === */
#streaming-card {
    background: linear-gradient(135deg, #fff8f5, #fff0f0);
    border: 2px solid var(--accent); position: relative; overflow: hidden;
}
#streaming-card::before {
    content: ''; position: absolute; top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 2s infinite;
}

.typing-cursor { animation: blink 0.8s infinite; color: var(--accent); font-weight: bold; }
.stream-timer { font-size: 10px; color: #999; background: rgba(255,255,255,0.8); padding: 2px 8px; border-radius: 10px; }

/* === 22. 欢迎弹窗 === */
.welcome-content { font-size: 12px; line-height: 1.9; }
.welcome-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.welcome-item:last-child { border-bottom: none; }
.welcome-icon { font-size: 20px; flex-shrink: 0; }
.welcome-text strong { color: var(--title); display: block; margin-bottom: 3px; }
.welcome-text span { color: #888; font-size: 11px; }

.beta-badge {
    display: inline-block; background: linear-gradient(135deg, #ff9a56, #ff6b6b);
    color: white; padding: 3px 10px; border-radius: 12px;
    font-size: 10px; font-weight: bold; margin-left: 8px;
    animation: pulse 2s infinite;
}

/* === 23. 离线提示 === */
.offline-banner {
    position: fixed; top: 0; left: 0; right: 0;
    background: linear-gradient(90deg, #ff6b6b, #ff8e53);
    color: white; text-align: center; padding: 8px;
    font-size: 12px; z-index: 999;
    transform: translateY(-100%); transition: transform 0.3s;
}
.offline-banner.show { transform: translateY(0); }

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* === 24. 花瓣动画 === */
.petals-container {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; overflow: hidden; z-index: 0;
}
.petals-container.hidden { display: none; }

.petal {
    position: absolute; top: -20px; opacity: 0.4;
    animation: petalFall linear infinite; font-size: 16px;
}
.petal:nth-child(1) { left: 10%; animation-duration: 12s; }
.petal:nth-child(2) { left: 30%; animation-duration: 15s; animation-delay: 2s; }
.petal:nth-child(3) { left: 50%; animation-duration: 13s; animation-delay: 4s; }
.petal:nth-child(4) { left: 70%; animation-duration: 14s; animation-delay: 1s; }
.petal:nth-child(5) { left: 90%; animation-duration: 11s; animation-delay: 3s; }

/* === 25. 动画关键帧 === */
@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes btnGlow {
    0%, 100% { box-shadow: 0 3px 12px rgba(200, 138, 138, 0.2); }
    50% { box-shadow: 0 3px 20px rgba(200, 138, 138, 0.45), 0 0 25px rgba(230, 180, 180, 0.25); }
}

@keyframes loaderHeart {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}

@keyframes sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.2); }
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.1); }
    30% { transform: scale(1); }
    45% { transform: scale(1.08); }
}

@keyframes petalFall {
    0% { top: -20px; transform: translateX(0) rotate(0deg); opacity: 0; }
    10% { opacity: 0.4; }
    90% { opacity: 0.4; }
    100% { top: 100%; transform: translateX(30px) rotate(360deg); opacity: 0; }
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* === 26. 工具类 === */
.hidden { display: none !important; }
.heartbeat { animation: heartbeat 1.2s ease-in-out infinite; }
.sparkle { animation: sparkle 2s ease-in-out infinite; }
