/* ===== 全局少儿风格主题 ===== */
:root {
  --primary: #ff8a3d;
  --primary-dark: #f06c1f;
  --secondary: #4fc3f7;
  --accent: #ffd54f;
  --success: #66bb6a;
  --error: #ef5350;
  --bg: #fff8e7;
  --bg-card: #ffffff;
  --text: #3d2817;
  --text-light: #795548;
  --border: #ffe0b2;
  --shadow: 0 4px 14px rgba(255, 138, 61, 0.25);
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: "PingFang SC", "Microsoft YaHei", "Comic Sans MS", "Hiragino Sans GB", sans-serif;
  background: linear-gradient(180deg, #fff3d6 0%, #ffe0b2 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 16px;
}

/* 顶部导航 */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(90deg, #ff8a3d, #ffb74d);
  color: white;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left .logo { font-size: 20px; font-weight: bold; }
.header-right { display: flex; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,0.25);
  color: white; font-size: 18px;
  cursor: pointer; transition: transform 0.15s;
}
.icon-btn:active { transform: scale(0.9); }

/* 视图切换 */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 首页 */
.hero { text-align: center; padding: 28px 16px 16px; }
.hero h1 {
  font-size: 28px; color: var(--primary-dark);
  text-shadow: 2px 2px 0 #fff, 4px 4px 0 rgba(255,138,61,0.2);
  margin-bottom: 6px;
}
.hero .subtitle { color: var(--text-light); font-size: 15px; }

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  padding: 12px 16px 40px;
}
.lesson-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 3px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.lesson-card:active { transform: scale(0.96); }
.lesson-card .num {
  display: inline-block;
  width: 36px; height: 36px; line-height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; font-weight: bold; font-size: 16px;
  margin-bottom: 8px;
}
.lesson-card .title { font-size: 14px; font-weight: bold; color: var(--text); }
.lesson-card .lock { position: absolute; top: 6px; right: 8px; font-size: 14px; }

/* 课程标题栏 */
.lesson-title-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--bg-card);
  box-shadow: var(--shadow);
}
.back-btn {
  border: none; background: var(--border);
  padding: 6px 12px; border-radius: 20px;
  color: var(--primary-dark); font-size: 14px; cursor: pointer;
}
.lesson-title-bar h2 { flex: 1; font-size: 17px; color: var(--primary-dark); }
.progress-indicator { display: flex; gap: 4px; }
.progress-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #e0e0e0; transition: background 0.2s;
}
.progress-dot.active { background: var(--success); }

/* 标签栏 */
.tab-bar {
  display: flex;
  background: var(--bg-card);
  padding: 0 16px;
  border-bottom: 2px solid var(--border);
}
.tab {
  flex: 1; padding: 12px 4px;
  border: none; background: none;
  font-size: 14px; color: var(--text-light);
  cursor: pointer; position: relative;
  transition: color 0.2s;
}
.tab.active { color: var(--primary); font-weight: bold; }
.tab.active::after {
  content: ''; position: absolute;
  bottom: -2px; left: 20%; right: 20%;
  height: 3px; background: var(--primary); border-radius: 2px;
}

.tab-content { display: none; padding: 12px; }
.tab-content.active { display: block; animation: fadeIn 0.3s; }

/* 动画讲课区 */
.animation-stage {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.character-area {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 140px;
}
.character { text-align: center; flex: 0 0 auto; }
.char-svg { width: 90px; height: 110px; }
.char-name { font-size: 13px; color: var(--text-light); margin-top: 2px; font-weight: bold; }

.dialogue-box {
  flex: 1;
  background: #fffdf5;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  position: relative;
  min-height: 70px;
  box-shadow: 2px 2px 0 var(--border);
}
.dialogue-speaker {
  font-size: 12px; color: var(--primary); font-weight: bold; margin-bottom: 4px;
}
.dialogue-text {
  font-size: 15px; line-height: 1.6; color: var(--text);
  min-height: 40px;
}
.dialogue-box.teacher { border-color: var(--secondary); }
.dialogue-box.teacher .dialogue-speaker { color: var(--secondary); }
.dialogue-box.student { border-color: var(--primary); }
.dialogue-box.student .dialogue-speaker { color: var(--primary); }

/* 角色说话动画 */
.character.speaking .char-svg { animation: bounce 0.4s ease infinite alternate; }
@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-6px); }
}
.character.idle .char-svg { animation: nod 2.5s ease-in-out infinite; }
@keyframes nod {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-3deg); }
}

/* 演示区 */
.demo-area {
  background: linear-gradient(135deg, #fff8e7, #ffe8cc);
  border-radius: 12px;
  padding: 12px;
  min-height: 200px;
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--border);
}
.demo-placeholder { color: var(--text-light); font-size: 14px; text-align: center; }

/* 控制按钮 */
.animation-controls, .quiz-nav {
  display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center; padding: 8px;
}
.ctrl-btn {
  border: none; background: var(--bg-card);
  color: var(--text); padding: 10px 18px;
  border-radius: 24px; font-size: 14px;
  cursor: pointer; box-shadow: var(--shadow);
  transition: all 0.15s; border: 2px solid var(--border);
}
.ctrl-btn:active { transform: scale(0.95); }
.ctrl-btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; border-color: var(--primary-dark);
}
.ctrl-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.auto-play {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-light);
}

/* 答题区 */
.quiz-header {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-card); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.quiz-label { font-weight: bold; color: var(--primary); font-size: 15px; }
.quiz-counter { color: var(--text-light); font-size: 13px; }

.quiz-question {
  background: var(--bg-card); border-radius: 12px;
  padding: 14px; margin-bottom: 10px;
  font-size: 15px; line-height: 1.6;
  box-shadow: var(--shadow);
}
.quiz-question .q-title {
  display: inline-block; background: var(--primary);
  color: white; padding: 2px 10px; border-radius: 10px;
  font-size: 12px; margin-right: 8px;
}

.quiz-board {
  background: var(--bg-card); border-radius: 12px;
  padding: 12px; margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex; justify-content: center;
}
.quiz-feedback {
  min-height: 30px; text-align: center;
  font-size: 15px; font-weight: bold;
  padding: 4px; border-radius: 10px;
  margin-bottom: 8px;
}
.quiz-feedback.correct { color: var(--success); background: #e8f5e9; }
.quiz-feedback.wrong { color: var(--error); background: #ffebee; }

/* 口诀卡片 */
.mnemonic-modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000; align-items: center; justify-content: center;
}
.mnemonic-modal.show { display: flex; animation: fadeIn 0.3s; }
.mnemonic-card {
  background: linear-gradient(135deg, #fff9e6, #ffe8b3);
  border-radius: 20px; padding: 28px 24px;
  max-width: 90%; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  border: 4px solid var(--accent);
  animation: pop 0.4s;
}
@keyframes pop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.mnemonic-card h3 { color: var(--primary-dark); margin-bottom: 16px; font-size: 20px; }
.mnemonic-text {
  font-size: 18px; line-height: 2;
  color: var(--text); margin-bottom: 20px;
  white-space: pre-line;
}

/* Toast */
.toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.8); color: white;
  padding: 10px 20px; border-radius: 20px;
  font-size: 14px; z-index: 2000;
  opacity: 0; transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* 表扬动画 */
.praise {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 60px; z-index: 1500;
  animation: praiseAnim 1s ease-out;
  pointer-events: none;
}
@keyframes praiseAnim {
  0% { transform: translate(-50%, -50%) scale(0); }
  50% { transform: translate(-50%, -50%) scale(1.2); }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* 每题讲解区 */
.quiz-explain {
  margin-top: 12px; padding: 12px 14px;
  background: #fff7e6; border-radius: 12px;
  border-left: 4px solid var(--primary);
  font-size: 14px; line-height: 1.8; color: var(--text);
  animation: fadeIn 0.3s;
}
.quiz-explain .qe-title { font-weight: bold; color: var(--primary-dark); margin-bottom: 6px; }
.quiz-explain .qe-ans { color: var(--primary-dark); font-weight: bold; }
.quiz-explain .qe-text { color: #555; margin-top: 4px; }

/* 动画内嵌口诀卡片 */
.mnemonic-inline {
  background: linear-gradient(135deg, #fff9e6, #ffe8b3);
  border: 3px solid var(--accent);
  border-radius: 16px; padding: 18px 22px;
  text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  animation: pop 0.4s;
}
.mnemonic-inline .mi-title { color: var(--primary-dark); font-size: 18px; font-weight: bold; margin-bottom: 10px; }
.mnemonic-inline .mi-line { font-size: 16px; line-height: 2; color: var(--text); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== 浮动电子棋盘按钮 ===== */
.eb-float-btn {
  position: fixed;
  right: 14px;
  bottom: 18px;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(135deg, #d32f2f, #b71c1c);
  border: 2px solid #fff;
  border-radius: 28px;
  box-shadow: 0 4px 14px rgba(211, 47, 47, 0.5);
  cursor: pointer;
  animation: ebPulse 2.2s infinite ease-in-out;
  transition: transform 0.2s;
}
.eb-float-btn:hover { transform: scale(1.08); }
.eb-float-btn:active { transform: scale(0.95); }
@keyframes ebPulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(211, 47, 47, 0.5); }
  50% { box-shadow: 0 4px 22px rgba(211, 47, 47, 0.85); }
}
.eb-float-label { font-size: 13px; letter-spacing: 0.5px; }

/* ===== 电子棋盘 Modal ===== */
.eb-modal {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1300;
}
.eb-modal-box {
  background: #fff;
  border-radius: 18px;
  padding: 18px 22px 14px;
  max-width: 96vw;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  animation: ebSlideIn 0.3s ease-out;
}
@keyframes ebSlideIn {
  from { opacity: 0; transform: translateY(30px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.eb-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.eb-title {
  font-size: 20px;
  font-weight: bold;
  color: var(--primary-dark);
}
.eb-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #ffebee;
  color: #c62828;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}
.eb-close-btn:hover { background: #ffcdd2; }
.eb-status {
  font-size: 14px;
  text-align: center;
  color: var(--text);
  margin-bottom: 10px;
  padding: 6px 10px;
  background: #fff8e1;
  border-radius: 8px;
  border-left: 4px solid var(--primary);
}
.eb-board-wrap {
  display: flex;
  justify-content: center;
  margin: 6px auto;
}

/* 摆棋棋子面板 */
.eb-palette {
  flex-direction: column;
  gap: 6px;
  margin: 2px 0 8px;
  padding: 8px 10px;
  background: #fff8e1;
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.eb-palette-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.eb-palette-label {
  width: 20px;
  flex: none;
  text-align: center;
  font-size: 13px;
  font-weight: bold;
}
.eb-palette-label.red { color: #c62828; }
.eb-palette-label.black { color: #212121; }
.eb-palette-piece, .eb-palette-eraser {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: bold;
  cursor: pointer;
  border: 2px solid;
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  transition: transform 0.15s, box-shadow 0.15s;
  user-select: none;
}
.eb-palette-piece.red {
  background: radial-gradient(circle at 35% 30%, #fff5f0, #ffccbc);
  color: #c62828;
  border-color: #c62828;
}
.eb-palette-piece.black {
  background: radial-gradient(circle at 35% 30%, #f0f0f0, #bdbdbd);
  color: #212121;
  border-color: #212121;
}
.eb-palette-piece.selected {
  box-shadow: 0 0 0 3px var(--success);
  transform: scale(1.12);
}
.eb-palette-eraser {
  background: #fff;
  border: 2px dashed #999;
  color: #666;
  font-size: 16px;
}
.eb-palette-eraser.selected {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239, 83, 80, 0.5);
  transform: scale(1.12);
}
.eb-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}
.eb-tip {
  text-align: center;
  font-size: 12px;
  color: #888;
  margin-top: 8px;
}

/* 移动端适配 */
@media (max-width: 480px) {
  .char-svg { width: 70px; height: 90px; }
  .lesson-grid { grid-template-columns: repeat(2, 1fr); }
  .tab { font-size: 12px; padding: 10px 2px; }
  .eb-float-label { display: none; }
  .eb-float-btn { padding: 10px; }
  .eb-title { font-size: 16px; }
  .eb-modal-box { padding: 14px; }
}
