/* ================================================================
 * story-base.css — 故事引擎 共享基础（暗紫玻璃 · 统一 token 驱动）
 * 由 games/css/v4-styles.css + games/css/story-voice-story.css 提炼重构，
 * 并合并各城镇 story-*.css 的引擎类（Variant A 与 Variant B 命名并存）。
 * 蓝/藏青 #0f172a/#2563eb/#2d1b4e → 品牌紫/--bg-base；容器 780→480；字号 16→14。
 * age-mode 机制保留（data-age-mode 由 JS 读写），主色收敛到品牌紫系。
 * 9 个城镇 story-*.css 仅保留 --scene-accent 等城镇差异（见各文件）。
 * 依赖：/css/design-tokens.css（须先于本文件链接）。
 * ================================================================ */

/* ===== 引擎变量（默认品牌紫 / 玻璃；可被城镇 css 覆盖 --scene-accent） ===== */
:root {
  /* 字号 */
  --story-fs-base: var(--fs-body);        /* 14px（原 16px） */
  --story-fs-title: var(--fs-title);      /* 22px */
  --story-fs-scene: var(--fs-subtitle);   /* 14px */
  --story-fs-btn: var(--fs-sm);           /* 12px */
  --story-fs-badge: var(--fs-caption);    /* 10px */
  --story-fs-status: var(--fs-xs);        /* 11px */

  /* 按钮 */
  --story-btn-min-h: 40px;
  --story-btn-pad: 10px 20px;
  --story-btn-radius: var(--radius-md);

  /* 颜色（品牌紫系 / 语义） */
  --story-primary: var(--brand-purple);
  --story-primary-light: var(--brand-purple-soft);
  --story-primary-dark: var(--brand-purple-deep);
  --story-bg: var(--bg-base);
  --story-bg-light: var(--bg-base-2);
  --story-text: var(--text-body);
  --story-text-muted: var(--text-muted);
  --story-gold: var(--accent-gold);
  --story-gold-deep: var(--accent-gold-deep);
  --story-success: var(--status-success);
  --story-success-bg: var(--status-success-bg);
  --story-success-soft: rgba(74, 222, 128, 0.12);
  --story-danger: var(--status-danger);
  --story-danger-bg: var(--status-danger-bg);
  --story-info: var(--status-info);
  --story-info-bg: var(--status-info-bg);

  /* 玻璃 / 城镇强调（默认品牌紫，城镇 css 覆盖） */
  --scene-accent: var(--brand-purple-soft);
  --story-glass-bg: var(--glass-bg);
  --story-glass-bg-2: var(--glass-bg-2);
  --story-glass-border: var(--glass-border);
  --story-glass-border-strong: var(--glass-border-strong);
  --story-blur: var(--glass-blur);
  --story-shadow: var(--shadow-card);
  --story-transition-fast: 0.2s ease;
  --story-transition-normal: 0.3s ease;
}

/* 5-8 岁模式：大字体、大按钮、高对比；主色原粉 #f472b6 → 品牌紫系占位 */
:root[data-age-mode="5-8"] {
  --story-fs-base: 22px;
  --story-fs-title: 30px;
  --story-fs-scene: 1.3rem;
  --story-fs-btn: 18px;
  --story-fs-badge: 0.85rem;
  --story-fs-status: 0.9rem;
  --story-btn-min-h: 52px;
  --story-btn-pad: 16px 28px;
  --story-btn-radius: 16px;
  --story-primary: var(--brand-purple-soft);
  --story-primary-light: var(--brand-purple-soft);
  --story-primary-dark: var(--brand-purple-deep);
  --story-bg: var(--bg-base);
  --story-bg-light: var(--bg-base-2);
  --story-text: var(--text-primary);
}
/* 9-12 岁模式：默认品牌值（保留机制） */
:root[data-age-mode="9-12"] {
  --story-bg-light: var(--bg-base-2);
}

/* ===== 全局重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--story-bg);
  color: var(--story-text);
  min-height: 100vh;
  padding: 0;
  font-size: var(--story-fs-base);
  line-height: 1.7;
}

/* ===== 页面容器 ===== */
.app-wrapper {
  max-width: 480px;            /* 原 780px → 480px */
  margin: 0 auto;
  padding: 16px 16px 100px;
  position: relative;
}

/* ================================================================
   顶部工具栏（.top-bar 用于城镇页；voice-story 改用 .app-header）
   ================================================================ */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  flex-wrap: wrap;
  gap: 8px;
}
.top-bar .app-title {
  font-size: var(--story-fs-title);
  font-weight: 700;
  background: linear-gradient(135deg, #ffffff, var(--story-primary), var(--story-primary-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 2px;
}

/* 年龄切换开关 */
.age-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 24px;
  border: 1px solid rgba(139, 92, 246, 0.2);
  overflow: hidden;
}
.age-toggle .age-btn {
  padding: 6px 16px;
  border: none;
  background: transparent;
  color: var(--story-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--story-transition-fast);
  border-radius: 24px;
  font-family: inherit;
}
.age-toggle .age-btn.active {
  background: var(--story-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}
.age-toggle .age-btn:hover:not(.active) {
  color: var(--story-primary-light);
  background: rgba(139, 92, 246, 0.1);
}

/* ================================================================
   经营面板
   ================================================================ */
.status-panel {
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.12);
  border-radius: 14px;
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: var(--story-fs-status);
}
.status-panel .panel-row {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.status-panel .panel-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.status-panel .panel-icon { font-size: 1.1em; }

/* ================================================================
   场景容器（由播放器动态渲染）— 插图系统
   ================================================================ */
.scene-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: opacity var(--story-transition-normal);
  position: relative;
  min-height: 60vh;
  border-radius: 20px;
  overflow: hidden;
  padding: 16px 16px 24px;
}
.scene-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 0;
  transition: background-image 0.6s ease;
}
.scene-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(26, 10, 46, 0.75) 0%,
    rgba(124, 58, 237, 0.45) 50%,
    rgba(45, 27, 78, 0.75) 100%
  );
  backdrop-filter: blur(1px);
}
.scene-character {
  position: absolute;
  bottom: 0;
  right: 16px;
  width: 180px;
  height: 240px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom right;
  z-index: 1;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.scene-character.active { opacity: 0.85; transform: translateY(0); }
:root[data-age-mode="5-8"] .scene-character { width: 220px; height: 290px; opacity: 0.9; }
:root[data-age-mode="9-12"] .scene-character { width: 160px; height: 220px; opacity: 0.75; }

/* 内容层位于背景之上 */
.scene-title,
.bubble,
.decision-panel,
.finance-tip { position: relative; z-index: 2; }

/* ===== 场景标题（用 --scene-accent 体现城镇色） ===== */
.scene-title {
  margin-top: 24px;
  margin-bottom: 8px;
  padding: 10px 16px;
  font-size: var(--story-fs-scene);
  font-weight: 600;
  color: var(--scene-accent);
  background: rgba(139, 92, 246, 0.08);
  border-left: 3px solid var(--scene-accent);
  border-radius: 0 8px 8px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.scene-title:first-child { margin-top: 0; }
.scene-title .scene-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.2);
  font-size: 0.8em;
  font-weight: 700;
  color: var(--story-primary);
}

/* ===== 对话气泡（暗玻璃；角色色用语义 token） ===== */
.bubble {
  display: flex;
  flex-direction: column;
  padding: var(--space-3) 18px;
  border-radius: 16px;
  background: var(--story-glass-bg);
  border: 1px solid var(--story-glass-border);
  cursor: pointer;
  transition: all var(--story-transition-fast);
  position: relative;
  max-width: 85%;
  user-select: none;
}
.bubble:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); }
.bubble:active { transform: scale(0.97); }

.bubble-narrator {
  align-self: center;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.2);
  max-width: 90%;
  text-align: center;
  font-style: italic;
}
.bubble-hero {
  align-self: flex-end;
  background: rgba(192, 132, 252, 0.12);
  border: 1px solid rgba(192, 132, 252, 0.2);
  border-bottom-right-radius: 4px;
}
.bubble-male {
  align-self: flex-start;
  background: var(--story-info-bg);
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-bottom-left-radius: 4px;
}
.bubble-child {
  align-self: flex-start;
  background: var(--story-success-soft);
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-bottom-left-radius: 4px;
}
/* Variant B 角色名（城镇专属 class，统一用品牌/语义色） */
.bubble-anan { border-left: 4px solid var(--story-primary); }
.bubble-xiaozhe { border-left: 4px solid var(--story-gold); }
.bubble-miaomiao { border-left: 4px solid var(--story-primary-light); }

.bubble .role-label {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--story-text-muted);
}
.bubble .role-label .role-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.bubble-narrator .role-label { color: var(--story-primary-light); justify-content: center; }
.bubble-hero .role-label { color: var(--story-primary-light); justify-content: flex-end; }
.bubble-male .role-label { color: var(--story-info); }
.bubble-child .role-label { color: var(--story-success); }
.bubble-anan .role-label { color: var(--story-primary); }
.bubble-xiaozhe .role-label { color: var(--story-gold); }
.bubble-miaomiao .role-label { color: var(--story-primary-light); }

.bubble .content { font-size: 1em; line-height: 1.7; color: var(--story-text); }
.bubble-narrator .content { color: #d4c8e8; }

/* 播放指示器 */
.bubble .play-indicator {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.25);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--story-transition-normal);
}
.bubble:hover .play-indicator { opacity: 1; }
.bubble .play-indicator .wave {
  display: inline-flex;
  gap: 2px;
  align-items: center;
  height: 12px;
}
.bubble .play-indicator .wave span {
  display: inline-block;
  width: 3px;
  background: currentColor;
  border-radius: 2px;
  animation: wave 0.8s ease-in-out infinite;
}
.bubble .play-indicator .wave span:nth-child(1) { height: 6px; animation-delay: 0s; }
.bubble .play-indicator .wave span:nth-child(2) { height: 10px; animation-delay: 0.15s; }
.bubble .play-indicator .wave span:nth-child(3) { height: 14px; animation-delay: 0.3s; }
.bubble .play-indicator .wave span:nth-child(4) { height: 10px; animation-delay: 0.45s; }
.bubble .play-indicator .wave span:nth-child(5) { height: 6px; animation-delay: 0.6s; }
@keyframes wave { 0%, 100% { transform: scaleY(0.5); } 50% { transform: scaleY(1); } }

.bubble.playing {
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
  border-color: rgba(139, 92, 246, 0.6) !important;
}
.bubble.playing .play-indicator { opacity: 1; color: rgba(139, 92, 246, 0.8); }

/* ================================================================
   决策面板（Variant A: .decision-btn / Variant B: .choice-btn）
   ================================================================ */
.decision-panel {
  margin: 16px 0;
  padding: var(--space-4);
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 16px;
  text-align: center;
  display: none;
  position: relative;
}
.decision-panel.active { display: block; animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.decision-panel .decision-prompt,
.decision-panel .decision-title {
  font-size: var(--story-fs-title);
  color: var(--story-primary-light);
  margin-bottom: var(--space-3);
  font-weight: 600;
}
.decision-panel .decision-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: var(--space-3);
}
.decision-panel .decision-btn,
.decision-panel .choice-btn {
  padding: var(--story-btn-pad);
  min-height: var(--story-btn-min-h);
  border-radius: var(--story-btn-radius);
  border: 1px solid rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.08);
  color: var(--story-text);
  font-size: var(--story-fs-btn);
  cursor: pointer;
  transition: all var(--story-transition-fast);
  min-width: 180px;
  flex: 1;
  max-width: 320px;
  font-family: inherit;
  line-height: 1.5;
  text-align: left;
}
.decision-panel .decision-btn:hover,
.decision-panel .choice-btn:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.5);
  transform: translateY(-2px);
}
.decision-panel .decision-btn:active,
.decision-panel .choice-btn:active { transform: scale(0.97); }
.decision-panel .decision-btn.chosen {
  border-color: var(--story-primary);
  background: rgba(139, 92, 246, 0.25);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.3);
}
.decision-panel .decision-btn:disabled,
.decision-panel .choice-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.decision-panel .decision-btn .badge {
  display: inline-block;
  font-size: var(--story-fs-badge);
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.15);
  color: var(--story-primary-light);
  margin-top: 4px;
}

.decision-panel .decision-feedback {
  margin: 12px 0 8px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--story-success-soft);
  border: 1px solid rgba(74, 222, 128, 0.15);
  color: #86efac;
  font-size: 0.9em;
  line-height: 1.6;
  display: none;
  animation: fadeIn 0.4s ease;
}
.decision-panel .decision-feedback .feedback-label { font-weight: 600; color: var(--story-success); margin-bottom: 4px; }
.decision-panel .decision-feedback .feedback-effect { font-size: 0.85em; color: var(--story-info); margin-top: 4px; }

.decision-panel .asr-status {
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(139, 92, 246, 0.15);
  color: var(--story-text-muted);
  font-size: 0.85em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.decision-panel .mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--story-primary);
  background: rgba(139, 92, 246, 0.1);
  font-size: 1.8rem;
  cursor: pointer;
  transition: all var(--story-transition-fast);
  margin: 8px auto 0;
  position: relative;
}
.decision-panel .mic-btn:hover { background: rgba(139, 92, 246, 0.2); transform: scale(1.05); }
.decision-panel .mic-btn.pulse { animation: micPulse 1.5s ease-in-out infinite; }
.decision-panel .mic-btn.pulse::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--story-primary);
  animation: micRipple 1.5s ease-out infinite;
}
@keyframes micPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.6); } 50% { box-shadow: 0 0 20px 8px rgba(139, 92, 246, 0.2); } }
@keyframes micRipple { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.8); opacity: 0; } }
.decision-panel .fallback-hint { font-size: 0.75rem; color: var(--story-text-muted); margin-top: 6px; }

/* ===== 财商知识卡片 ===== */
.finance-tip {
  margin: 12px 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.15);
  color: #fde68a;
  font-size: 0.9em;
  line-height: 1.6;
  transition: opacity 0.5s ease;
}
.finance-tip .finance-icon { font-size: 1.2em; margin-right: 4px; }

/* ===== 结局场景 ===== */
.ending-scene { text-align: center; padding: 20px 0; animation: fadeIn 0.6s ease; }
.ending-scene .ending-title {
  font-size: var(--story-fs-title);
  font-weight: 700;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b, #f97316);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.finance-summary { margin: 16px 0; padding: 14px 18px; background: rgba(251, 191, 36, 0.06); border: 1px solid rgba(251, 191, 36, 0.12); border-radius: 12px; }
.finance-summary .summary-title { font-size: 0.9em; font-weight: 600; color: #fbbf24; margin-bottom: 8px; }
.finance-summary .finance-item { font-size: 0.85em; color: #fde68a; padding: 4px 0; }
.decision-history { margin: 12px 0; padding: 14px 18px; background: rgba(139, 92, 246, 0.06); border: 1px solid rgba(139, 92, 246, 0.1); border-radius: 12px; }
.decision-history .summary-title { font-size: 0.9em; font-weight: 600; color: var(--story-primary-light); margin-bottom: 6px; }
.decision-history .history-item { font-size: 0.85em; color: #d4c8e8; padding: 3px 0; }
.btn-restart {
  display: block;
  margin: 24px auto;
  padding: 14px 40px;
  border-radius: 28px;
  border: 1px solid rgba(251, 191, 36, 0.4);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.15));
  color: #fbbf24;
  font-size: 1.1em;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--story-transition-fast);
  font-family: inherit;
}
.btn-restart:hover { background: linear-gradient(135deg, rgba(251, 191, 36, 0.3), rgba(245, 158, 11, 0.3)); border-color: rgba(251, 191, 36, 0.7); transform: translateY(-2px); }

/* ================================================================
   底部控制栏（#voice-bottom-bar 播放控制条，保留 id；仅改样式）
   ================================================================ */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(var(--story-blur));
  -webkit-backdrop-filter: blur(var(--story-blur));
  border-top: 1px solid rgba(139, 92, 246, 0.15);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 100;
  flex-wrap: wrap;
}
.bottom-bar .status-text {
  font-size: var(--story-fs-status);
  color: var(--story-text-muted);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 120px;
}
.bottom-bar .btn-control {
  padding: 6px 18px;
  border-radius: 20px;
  border: 1px solid rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.08);
  color: var(--story-primary-light);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--story-transition-fast);
  font-family: inherit;
  white-space: nowrap;
}
.bottom-bar .btn-control:hover { background: rgba(139, 92, 246, 0.2); border-color: rgba(139, 92, 246, 0.5); }
.bottom-bar .btn-control:disabled { opacity: 0.3; cursor: not-allowed; }
.bottom-bar .btn-play { border-color: rgba(74, 222, 128, 0.4); background: rgba(74, 222, 128, 0.1); color: #86efac; }
.bottom-bar .btn-play:hover { background: rgba(74, 222, 128, 0.2); border-color: rgba(74, 222, 128, 0.6); }
.bottom-bar .btn-play.playing { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; }
.bottom-bar .btn-bgm { border-color: rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.08); color: #fbbf24; }
.bottom-bar .btn-bgm.muted { opacity: 0.4; }

/* ===== 进度 / 结局容器（v4 能力面板、结局总结，ID 与 class 并存） ===== */
#voice-ability-panel,
#voice-ending-summary,
.ability-panel {
  background: var(--story-glass-bg);
  backdrop-filter: var(--story-blur);
  -webkit-backdrop-filter: var(--story-blur);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}
#voice-ending-summary,
.ending-summary { border-radius: var(--radius-lg); padding: 24px; }
.glass {
  background: var(--story-glass-bg);
  backdrop-filter: var(--story-blur);
  -webkit-backdrop-filter: var(--story-blur);
  border: 1px solid var(--story-glass-border);
}

/* ================================================================
   v4.0 四维能力值面板 / 开局选择 / 结局总结（原 v4-styles.css）
   ================================================================ */
.ability-bar-row { display: flex; align-items: center; margin: 4px 0; gap: 6px; font-size: 13px; }
.ability-icon { font-size: 16px; width: 24px; text-align: center; flex-shrink: 0; }
.ability-label { width: 44px; flex-shrink: 0; color: var(--story-text-muted); font-size: 12px; }
.ability-bar-bg { flex: 1; height: 12px; background: rgba(255, 255, 255, 0.08); border-radius: 6px; overflow: hidden; }
.ability-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-gold-deep));
  border-radius: 6px;
  transition: width 0.5s ease;
  animation: fillBar 0.6s ease-out;
}
.ability-value { width: 28px; text-align: right; font-weight: bold; color: var(--accent-gold); font-size: 12px; }
.ability-badge-row { margin-top: 6px; text-align: center; font-size: 13px; color: var(--accent-gold); font-weight: bold; }
.ability-level { width: 50px; text-align: right; font-size: 12px; color: var(--accent-gold); display: inline-block; animation: badgePulse 2s ease-in-out infinite; }
.radar-chart-container { text-align: center; margin: 8px 0; }
.radar-chart-container canvas { max-width: 200px; }
:root[data-age-mode="5-8"] .ability-bar-bg { height: 16px; }
:root[data-age-mode="5-8"] .ability-bar-fill { background: linear-gradient(90deg, var(--brand-purple-soft), var(--brand-purple)); }
:root[data-age-mode="5-8"] .ability-value { color: var(--brand-purple-soft); }
:root[data-age-mode="9-12"] .ability-panel { background: var(--story-glass-bg-2); }

@keyframes fillBar { from { width: 0; } }
@keyframes badgePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes drawRadar { from { opacity: 0; } to { opacity: 1; } }
.radar-chart-container canvas { animation: drawRadar 0.8s ease-out; }

/* 开局选择卡片网格 */
.opening-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px; }
.opening-card {
  background: var(--story-glass-bg-2);
  border: 2px solid var(--story-glass-border-strong);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.opening-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
.opening-card .oc-icon { font-size: 28px; margin-bottom: 4px; }
.opening-card .oc-title { font-weight: bold; font-size: 14px; color: var(--text-primary); }
.opening-card .oc-desc { font-size: 12px; color: var(--story-text-muted); margin-top: 4px; }
.opening-card .oc-effect { font-size: 11px; color: var(--accent-gold); margin-top: 4px; }
.opening-card.selected {
  border-color: var(--accent-gold);
  background: var(--story-glass-bg-2);
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.4), 0 4px 14px rgba(0, 0, 0, 0.15);
  transform: translateY(-3px);
}
.opening-card.selected .oc-title { color: var(--accent-gold); }
.opening-prompt { text-align: center; font-size: 16px; font-weight: bold; color: var(--text-primary); margin-bottom: 10px; padding: 8px 0; }

/* 事件对话气泡 / 结局总结（v4） */
.event-dialogue-bubble { background: rgba(251, 191, 36, 0.15); border-left: 4px solid var(--accent-gold); padding: 10px 14px; margin: 8px 0; border-radius: 8px; font-size: 14px; line-height: 1.5; }
.ending-summary { text-align: center; padding: 16px; }
.ending-title { font-size: 22px; font-weight: bold; color: var(--text-primary); margin-bottom: 8px; }
.ending-radar { margin: 12px auto; }
.ending-fragments { text-align: left; font-size: 14px; line-height: 1.6; color: var(--story-text-muted); }
.ending-fragments .ef-item { margin: 6px 0; padding: 6px 10px; background: var(--story-glass-bg-2); border-radius: 6px; }
.ending-abilities { margin: 12px 0; }

/* 知识标签列表（结局总结页内） */
.knowledge-tag-list { margin: 12px 0; padding: 10px 12px; background: var(--story-glass-bg-2); border-radius: 10px; border: 1px solid var(--story-glass-border-strong); }
.knowledge-tag-list .ktl-title { font-size: 14px; font-weight: bold; color: var(--text-primary); margin-bottom: 8px; text-align: center; }
.knowledge-tag-list .ktl-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin: 4px 0; background: var(--story-glass-bg); border-radius: 6px; font-size: 13px; }
.knowledge-tag-list .ktl-category { font-size: 18px; flex-shrink: 0; }
.knowledge-tag-list .ktl-label { color: var(--story-text-muted); line-height: 1.4; }

/* ===== 进度覆盖层（保留原结构，token 化） ===== */
.progress-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.3s ease;
}
.progress-overlay.active { display: flex; }
.progress-overlay .overlay-card {
  background: linear-gradient(135deg, var(--bg-base), var(--bg-base-2));
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 20px;
  padding: 30px;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.progress-overlay .overlay-title { font-size: 1.3em; font-weight: 700; color: var(--story-primary-light); margin-bottom: 8px; }
.progress-overlay .overlay-subtitle { font-size: 0.9em; color: var(--story-text-muted); margin-bottom: 20px; }
.progress-overlay .overlay-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin: 8px 0;
  border-radius: 14px;
  border: 1px solid rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.08);
  color: var(--story-text);
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--story-transition-fast);
  font-family: inherit;
}
.progress-overlay .overlay-btn:hover { background: rgba(139, 92, 246, 0.2); border-color: rgba(139, 92, 246, 0.5); transform: translateY(-2px); }
.progress-overlay .overlay-btn.primary { background: var(--story-primary); border-color: var(--story-primary); color: #fff; }
.progress-overlay .overlay-btn.primary:hover { background: var(--story-primary-dark); border-color: var(--story-primary-dark); }

/* ================================================================
   响应式（移动优先；容器已 480 居中）
   ================================================================ */
@media (max-width: 540px) {
  .app-wrapper { padding: 12px 12px 90px; }
  .top-bar .app-title { font-size: 1.3rem; }
  .bubble { max-width: 92%; padding: 12px 14px; }
  .scene-title { font-size: 0.95rem; }
  .decision-panel .decision-btn,
  .decision-panel .choice-btn { min-width: 140px; }
  .bottom-bar { gap: 8px; padding: 8px 12px; }
  .bottom-bar .status-text { max-width: 120px; font-size: 0.72rem; }
  .bottom-bar .btn-control { font-size: 0.72rem; padding: 5px 12px; }
  .status-panel { padding: 8px 12px; }
  .status-panel .panel-row { gap: 4px; }
}
@media (max-width: 380px) {
  .age-toggle .age-btn { padding: 5px 10px; font-size: 0.72rem; }
  .decision-panel .decision-btn,
  .decision-panel .choice-btn { min-width: 100%; }
}
