/* 数学练习 - 专属样式
 * 覆盖 style.css 的暗色变量为亮色主题，适合学习场景
 * 添加数学练习特有样式：年级卡片、单元列表、闯关路径、答题卡、游戏面板
 */

:root {
  --bg-primary: #f0f4f8;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f1f5f9;
  --border-color: #e2e8f0;
  --border-glow: rgba(20, 184, 166, 0.3);
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent-primary: #0d9488;
  --accent-secondary: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #0d9488 0%, #8b5cf6 50%, #ec4899 100%);
  --accent-glow: rgba(13, 148, 136, 0.2);
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --error: #ef4444;
  --error-glow: rgba(239, 68, 68, 0.2);
  --warning: #f59e0b;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* === Header === */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--border-color);
}
.header-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-primary);
}
.brand-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.subject-toggle-group {
  display: flex;
  background: rgba(0,0,0,0.05);
  padding: 3px;
  border-radius: 12px;
  gap: 4px;
}
.subject-tab {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.subject-tab.active {
  background: #fff;
  color: var(--accent-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.nav-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Profile widget */
.profile-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  transition: border-color 0.2s;
}
.profile-btn:hover { border-color: var(--accent-primary); }
.profile-avatar { font-size: 18px; }
.profile-caret { font-size: 10px; color: var(--text-muted); }
.profile-panel {
  position: absolute;
  top: 100%; right: 0;
  margin-top: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  padding: 16px;
  min-width: 220px;
  z-index: 200;
}
.profile-panel.hidden { display: none; }
.profile-panel-title {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-align: center;
}
.profile-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.profile-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}
.profile-item:hover { background: var(--bg-input); }
.profile-item.active { background: rgba(13,148,136,0.1); color: var(--accent-primary); font-weight: 700; }
.profile-delete { font-size: 12px; color: var(--error); cursor: pointer; opacity: 0.6; }
.profile-delete:hover { opacity: 1; }
.profile-add { display: flex; gap: 6px; }
.profile-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text-primary);
}
.profile-add-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  background: var(--accent-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* Stat group */
.stat-group { display: flex; align-items: center; gap: 8px; }
.stat-item {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}
.stat-xp { color: var(--accent-primary); }
.stat-streak { color: var(--warning); }
.stat-mistakes-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--error);
  font-size: 13px;
  font-weight: 700;
}

/* === Main content === */
.main-content {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  min-height: calc(100vh - 64px);
}
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view-inner { display: flex; flex-direction: column; gap: 16px; }
.view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.view-title { font-size: 20px; font-weight: 800; flex: 1; }
.btn-back {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  cursor: pointer;
  font-size: 16px;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.btn-back:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.btn-back-small {
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
}

/* === Home cards === */
.card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 16px rgba(0,0,0,0.04);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 28px rgba(0,0,0,0.08); }
.card-icon-wrap {
  width: 64px; height: 64px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.card-icon-teal { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.card-icon-purple { background: linear-gradient(135deg, #a855f7, #7c3aed); }
.card-icon-rose { background: linear-gradient(135deg, #fb7185, #e11d48); }
.card-body { flex: 1; min-width: 0; }
.card-title { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.card-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.card-arrow { font-size: 20px; color: var(--text-muted); flex-shrink: 0; }

/* === Level grid === */
.level-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.level-card {
  padding: 16px;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.level-card:hover { border-color: var(--accent-primary); background: var(--bg-card-hover); }
.level-card-stage { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.level-card-name { font-size: 15px; font-weight: 800; }
.level-card-progress { font-size: 11px; color: var(--text-secondary); margin-top: 6px; }
.level-card-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
}
.badge-done { background: #d1fae5; color: #059669; }
.badge-todo { background: #f1f5f9; color: var(--text-muted); }

/* === Unit list === */
.btn-midterm {
  padding: 12px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(245,158,11,0.3);
  transition: transform 0.15s;
}
.btn-midterm:active { transform: scale(0.98); }
.unit-list { display: flex; flex-direction: column; gap: 12px; }
.unit-item {
  padding: 16px;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all 0.2s;
}
.unit-item:hover { border-color: var(--accent-primary); }
.unit-item.locked { opacity: 0.6; }
.unit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.unit-title { font-size: 14px; font-weight: 700; }
.unit-progress { font-size: 12px; color: var(--text-muted); }
.unit-stars { display: flex; gap: 2px; margin-top: 6px; }
.unit-star { font-size: 12px; }
.star-done { color: #fbbf24; }
.star-todo { color: #e2e8f0; }
.unit-actions { display: flex; gap: 8px; margin-top: 10px; }
.unit-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.unit-btn-path { background: rgba(13,148,136,0.1); color: var(--accent-primary); }
.unit-btn-path:hover { background: rgba(13,148,136,0.2); }
.unit-btn-test { background: rgba(99,102,241,0.1); color: #6366f1; }
.unit-btn-test:hover { background: rgba(99,102,241,0.2); }
.unit-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* === Path view (Duolingo-style) === */
.path-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 20px 0;
}
.path-node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s;
}
.path-node:hover { transform: scale(1.05); }
.path-node-circle {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  border: 4px solid #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  transition: all 0.2s;
  position: relative;
}
.path-node.completed .path-node-circle {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
}
.path-node.available .path-node-circle {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
  color: #fff;
  animation: pulse 2s ease infinite;
}
.path-node.locked .path-node-circle {
  background: #e2e8f0;
  color: var(--text-muted);
}
@keyframes pulse {
  0%,100% { box-shadow: 0 4px 16px rgba(13,148,136,0.2); }
  50% { box-shadow: 0 4px 24px rgba(13,148,136,0.5); }
}
.path-sub-desc {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.lesson-stage-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.lesson-stage-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border-color);
}

.lesson-num-badge {
  background: var(--accent-primary);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
}

.stages-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 12px;
}

.stage-bubble {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s, filter 0.2s;
  min-width: 70px;
}

.stage-bubble:hover {
  transform: translateY(-3px);
}

.stage-bubble-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border: 3px solid #fff;
  transition: all 0.2s;
}

.stage-bubble.unlocked .stage-bubble-circle {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
  color: #fff;
  animation: pulse 2.5s ease infinite;
}

.stage-bubble.passed .stage-bubble-circle {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
}

.stage-bubble.perfect .stage-bubble-circle {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
}

.stage-bubble.boss-stage .stage-bubble-circle {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  color: #fff;
  border: 3px solid #fef08a;
}

.stage-bubble.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.stage-bubble.locked .stage-bubble-circle {
  background: #cbd5e1;
  color: #64748b;
  box-shadow: none;
}

.stage-bubble-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 6px;
  text-align: center;
  max-width: 80px;
}

.stage-bubble-stars {
  font-size: 10px;
  color: #f59e0b;
  margin-top: 2px;
}

.stage-connector {
  flex: 1;
  height: 4px;
  min-width: 14px;
  background: var(--border-color);
  border-radius: 2px;
}

.stage-connector.active {
  background: #10b981;
}

/* === Quiz === */
.quiz-container {
  max-width: 520px;
  margin: 0 auto;
}
.quiz-progress-bar {
  padding: 12px 0;
  margin-bottom: 8px;
}
.quiz-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
#quizHearts { font-size: 16px; }
.progress-track {
  height: 6px;
  background: var(--border-color);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #14b8a6, #2dd4bf);
  border-radius: 100px;
  transition: width 0.3s ease;
  width: 0%;
}
.quiz-stats-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  font-size: 13px;
  font-weight: 700;
}
.quiz-stat { color: var(--text-secondary); }

.quiz-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 28px 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.04);
}
.quiz-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.quiz-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.quiz-lesson-tag {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--bg-input);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}
.quiz-methodology-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}
.badge-cpa { background: rgba(16, 185, 129, 0.12); color: #059669; }
.badge-logic { background: rgba(99, 102, 241, 0.12); color: #4f46e5; }
.badge-inquiry { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.badge-calc { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.badge-standard { background: rgba(100, 116, 139, 0.12); color: #475569; }

.quiz-audio-controls {
  display: flex;
  gap: 6px;
}
.btn-audio {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-audio:hover {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

.quiz-question {
  font-size: 20px;
  font-weight: 800;
  text-align: left;
  margin-bottom: 6px;
  line-height: 1.5;
  color: var(--text-primary);
}
.quiz-question-en {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 14px;
  font-style: italic;
}
.quiz-keywords-box {
  background: rgba(13, 148, 136, 0.06);
  border-left: 3px solid var(--accent-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.kw-title {
  font-weight: 700;
  color: var(--accent-primary);
}
.kw-pill {
  background: var(--bg-card);
  border: 1px solid rgba(13, 148, 136, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-primary);
}
.quiz-exp-box {
  margin-top: 10px;
  text-align: left;
  background: var(--bg-input);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
}
.quiz-exp-box .exp-zh {
  color: var(--text-primary);
  margin-bottom: 4px;
}
.quiz-exp-box .exp-en {
  color: var(--text-secondary);
  font-size: 12px;
}
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.quiz-option {
  padding: 14px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-primary);
}
.quiz-option:hover { border-color: var(--accent-primary); }
.quiz-option.selected {
  border-color: var(--accent-primary);
  background: rgba(13,148,136,0.08);
}
.quiz-option.correct {
  border-color: var(--success);
  background: rgba(16,185,129,0.1);
  color: var(--success);
}
.quiz-option.wrong {
  border-color: var(--error);
  background: rgba(239,68,68,0.1);
  color: var(--error);
}
.quiz-feedback {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  min-height: 24px;
  margin-bottom: 8px;
}
.quiz-feedback.correct { color: var(--success); }
.quiz-feedback.wrong { color: var(--error); }
.quiz-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.btn-primary {
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent-primary);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary {
  padding: 12px 28px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { border-color: var(--text-muted); }
.hidden { display: none !important; }

/* Quiz result */
.quiz-result {
  text-align: center;
  padding: 32px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 16px rgba(0,0,0,0.04);
}
.result-emoji { font-size: 48px; margin-bottom: 12px; }
.result-title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.result-detail { font-size: 14px; color: var(--text-secondary); margin-bottom: 12px; }
.result-stars { font-size: 28px; margin-bottom: 20px; }
.result-actions { display: flex; gap: 10px; justify-content: center; }

/* === Mistakes === */
.btn-clear-mistakes {
  padding: 6px 14px;
  border: 1px solid var(--error);
  border-radius: 8px;
  background: transparent;
  color: var(--error);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.mistakes-list { display: flex; flex-direction: column; gap: 10px; }
.mistake-item {
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mistake-q { font-size: 15px; font-weight: 700; }
.mistake-a { font-size: 13px; color: var(--success); }
.mistake-user-a { font-size: 13px; color: var(--error); }
.mistake-meta { display: flex; gap: 8px; align-items: center; }
.mistake-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--bg-input);
  color: var(--text-muted);
}
.mistake-remove {
  align-self: flex-start;
  padding: 4px 12px;
  border: 1px solid var(--error);
  border-radius: 8px;
  background: transparent;
  color: var(--error);
  font-size: 12px;
  cursor: pointer;
  margin-top: 4px;
}
.mistake-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.mistake-empty-icon { font-size: 48px; margin-bottom: 12px; }

/* === Games === */
.games-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.game-card {
  padding: 24px 16px;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.game-card:hover { border-color: var(--accent-primary); transform: translateY(-2px); }
.game-icon { font-size: 36px; margin-bottom: 8px; }
.game-title { font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.game-desc { font-size: 12px; color: var(--text-secondary); }

/* === 24-point game === */
.game24-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 12px;
}
.game24-nums {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}
.game24-num {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.game24-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.game24-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  background: var(--bg-input);
  color: var(--text-primary);
}
.game24-input:focus { border-color: var(--accent-primary); outline: none; }
.game24-feedback { font-size: 14px; font-weight: 600; min-height: 24px; }
.game24-solution {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
.game24-solution summary { cursor: pointer; text-align: center; }
.game24-diff-select {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.diff-btn {
  padding: 6px 16px;
  border: 1px solid var(--border-color);
  border-radius: 100px;
  background: var(--bg-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.diff-btn.active { background: var(--accent-primary); color: #fff; border-color: var(--accent-primary); }

/* === 2048 game === */
.game2048-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}
.game2048-board {
  position: relative;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1;
  margin: 0 auto;
  background: #cbd5e1;
  border-radius: var(--radius-md);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
  touch-action: none;
  user-select: none;
}
.tile-cell {
  background: rgba(255,255,255,0.4);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  color: #1e293b;
  transition: all 0.12s ease;
}
.tile-2 { background: #eee4da; }
.tile-4 { background: #ede0c8; }
.tile-8 { background: #f2b179; color: #fff; }
.tile-16 { background: #f59563; color: #fff; }
.tile-32 { background: #f67c5f; color: #fff; }
.tile-64 { background: #f65e3b; color: #fff; }
.tile-128 { background: #edcf72; font-size: 20px; }
.tile-256 { background: #edcc61; font-size: 20px; }
.tile-512 { background: #edc850; font-size: 20px; }
.tile-1024 { background: #edc53f; font-size: 16px; }
.tile-2048 { background: #edc22e; font-size: 16px; }
.game2048-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.85);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.game2048-overlay.hidden { display: none; }
.overlay-content { text-align: center; }
.overlay-emoji { font-size: 48px; margin-bottom: 8px; }
.overlay-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.overlay-score { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.modal-overlay.hidden { display: none; }
.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  padding: 28px 24px 24px;
  max-width: 360px;
  width: calc(100% - 32px);
  text-align: center;
}
.modal-title { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.modal-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.goal-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.goal-btn {
  padding: 12px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.goal-btn.active { background: var(--accent-primary); color: #fff; }
.modal-cancel {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
}

/* === Responsive === */
@media (max-width: 600px) {
  .header-container { padding: 10px 12px; }
  .brand-title { font-size: 16px; }
  .stat-item { font-size: 12px; }
  .main-content { padding: 12px 12px 48px; }
  .level-grid { grid-template-columns: 1fr; }
  .games-grid { grid-template-columns: 1fr; }
  .quiz-question { font-size: 18px; }
  .quiz-card { padding: 20px 16px; }
  .card { padding: 16px; }
  .card-icon-wrap { width: 52px; height: 52px; font-size: 26px; }
  .card-title { font-size: 16px; }
  .card-desc { font-size: 12px; }
  .game24-num { width: 52px; height: 52px; font-size: 22px; }
}
@media (max-width: 380px) {
  .stat-group { gap: 4px; }
  .stat-item { font-size: 11px; }
}

/* Combo popup */
.combo-pop {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  border-radius: 100px;
  background: linear-gradient(135deg, #f97316, #ec4899);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 4px 16px rgba(249,115,22,0.4);
  z-index: 250;
  animation: comboPop 0.6s ease;
  pointer-events: none;
}
@keyframes comboPop {
  0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
  30% { transform: translateX(-50%) scale(1.1); opacity: 1; }
  70% { transform: translateX(-50%) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) scale(1); opacity: 0; }
}

/* === Calc Drill（心算分级闯关）=== */
.calc-select-sub {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  margin: -4px 0 18px;
}
.calc-level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}
/* .view-inner 是 flex column：子项 margin:auto 会取消 stretch、按 max-content 定宽，
   导致 auto-fill 在不定宽下铺满 3 列溢出 —— 必须显式 width:100% 才有确定宽度。 */
.calc-level-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg, 16px);
  background: var(--bg-card);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  font-family: inherit;
}
.calc-level-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(13,148,136,0.15);
}
.calc-level-card.mastered { border-color: rgba(16,185,129,0.45); }
.cl-icon {
  font-size: 34px;
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border-radius: 14px;
  flex-shrink: 0;
}
.cl-body { flex: 1; min-width: 0; }
.cl-name { font-size: 16px; font-weight: 800; color: var(--text-primary); }
.cl-sub { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-top: 2px; }
.cl-stars {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.cl-stars.none { font-size: 12px; opacity: 0.65; }
.cl-acc { font-size: 11px; font-weight: 600; color: var(--text-secondary); }

.calc-level-tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-primary);
  background: rgba(13,148,136,0.1);
  padding: 3px 10px;
  border-radius: 100px;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calc-combo {
  font-size: 12px;
  font-weight: 800;
  color: #ea580c;
  background: rgba(249,115,22,0.14);
  padding: 3px 10px;
  border-radius: 100px;
}
.calc-combo.pop { animation: calcComboPop 0.3s ease; }
@keyframes calcComboPop {
  0% { transform: scale(0.7); }
  55% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.calc-spacer { flex: 1; }

/* 大号题目 + 2×2 四宫格选项 */
.calc-question {
  font-size: clamp(42px, 9vw, 62px);
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  margin: 14px 0 22px;
}
.calc-card.done .calc-question,
.calc-card.done .calc-options,
.calc-card.done .quiz-feedback { display: none; }
.calc-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 10px;
}
.calc-option {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-color);
  border-radius: 18px;
  background: var(--bg-input);
  font-size: clamp(26px, 6vw, 36px);
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  font-family: inherit;
}
.calc-option:hover { border-color: var(--accent-primary); }
.calc-option:active { transform: scale(0.95); }
.calc-option.correct {
  border-color: var(--success);
  background: rgba(16,185,129,0.14);
  color: var(--success);
}
.calc-option.wrong {
  border-color: var(--error);
  background: rgba(239,68,68,0.12);
  color: var(--error);
  animation: calcShake 0.35s ease;
}
@keyframes calcShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

/* 结算面板 */
.calc-result {
  text-align: center;
  padding: 10px 0 6px;
}
.calc-result-emoji { font-size: 58px; line-height: 1.1; }
.calc-result-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 6px;
}
.calc-result-stars { font-size: 30px; letter-spacing: 6px; margin: 8px 0 14px; }
.calc-result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.crs-item {
  background: var(--bg-input);
  border-radius: 12px;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.crs-num { font-size: 18px; font-weight: 800; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.crs-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.calc-result-xp {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-primary);
  margin-bottom: 14px;
}
.calc-result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

@media (max-width: 480px) {
  .calc-option { min-height: 74px; border-radius: 14px; }
  .calc-options { gap: 10px; }
  .calc-question { margin: 8px 0 16px; }
  .calc-result-stats { grid-template-columns: repeat(2, 1fr); }
  .calc-level-card { padding: 13px 14px; }
  .cl-icon { width: 48px; height: 48px; font-size: 28px; }
}
