/* ChunkEar PWA Styles */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #2c3e50;
  --text2: #888;
  --primary: #4A90D9;
  --radius: 12px;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ====== HEADER ====== */
#header {
  background: var(--card);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 700px; margin: 0 auto; padding: 0 16px;
  height: 52px; display: flex; align-items: center;
}
.logo {
  font-size: 20px; font-weight: 700; color: var(--primary);
  cursor: pointer; display: flex; align-items: center; gap: 8px;
}
.logo-sub { font-size: 12px; color: var(--text2); font-weight: 400; }

/* ====== VIEWS ====== */
#main-content { max-width: 700px; margin: 0 auto; padding: 16px 16px 60px; }
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.hidden { display: none !important; }
.loading { text-align: center; padding: 40px; color: var(--text2); }

/* ====== BACK BUTTON ====== */
.back-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.back-btn {
  background: none; border: none; font-size: 24px; cursor: pointer;
  padding: 4px 8px; color: var(--text); line-height: 1;
}

/* ====== HOME - LEVEL GRID ====== */
.section-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.section-subtitle { font-size: 14px; color: var(--text2); margin-bottom: 20px; line-height: 1.5; }
.level-grid { display: flex; flex-direction: column; gap: 12px; }

.level-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  cursor: pointer; transition: all 0.2s; border: 2px solid transparent;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.level-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); border-color: var(--primary); }
.level-card-header { display: flex; align-items: center; gap: 10px; }
.level-icon { font-size: 22px; }
.level-badge {
  width: 28px; height: 28px; border-radius: 50%;
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.level-name { font-size: 16px; font-weight: 600; flex: 1; }
.level-stats { font-size: 13px; color: var(--text2); margin-top: 6px; }
.level-bar {
  height: 6px; background: #e0e0e0; border-radius: 3px;
  margin-top: 8px; overflow: hidden;
}
.level-bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.level-bar-label { font-size: 11px; color: var(--text2); margin-top: 3px; }
.level-locked-msg { font-size: 12px; color: #999; margin-top: 6px; font-style: italic; }

/* ====== LEVEL VIEW ====== */
.level-header { margin-bottom: 20px; }
.level-header h2 { font-size: 22px; }
.level-header .stats { font-size: 13px; color: var(--text2); margin-top: 4px; }

/* Module List */
.module-list { margin-bottom: 24px; }
.module-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: var(--card);
  border-radius: 8px; margin-bottom: 6px;
  border-left: 3px solid #e0e0e0;
}
.module-item[data-status="passed"] { border-left-color: #27ae60; background: #f0faf0; }
.module-item[data-status="in-progress"] { border-left-color: #f39c12; background: #fffcf0; }
.module-left { display: flex; align-items: center; gap: 10px; flex: 1; }
.module-status { font-size: 16px; }
.module-text { flex: 1; }
.module-en { font-size: 14px; font-weight: 500; }
.module-cn { font-size: 12px; color: var(--text2); margin-top: 2px; }
.module-right { text-align: right; }
.module-status-text { font-size: 11px; color: var(--text2); }

/* Mode Buttons */
.mode-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.mode-card {
  background: var(--card); border-radius: var(--radius); padding: 16px 12px;
  text-align: center; cursor: pointer; transition: all 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.mode-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-2px); }
.mode-icon { font-size: 28px; margin-bottom: 6px; }
.mode-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.mode-desc { font-size: 11px; color: var(--text2); line-height: 1.4; }

/* ====== TRAINING ====== */
#training-header { margin-bottom: 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.training-title { font-size: 16px; font-weight: 600; }
.training-mode { font-size: 14px; color: var(--text2); }

/* Buttons */
.btn {
  display: inline-block; padding: 10px 24px; border-radius: 8px;
  border: none; font-size: 15px; font-weight: 500; cursor: pointer;
  background: var(--primary); color: #fff; transition: all 0.2s;
  margin: 4px; font-family: inherit;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-secondary { background: #e8f0fe; color: var(--primary); }

/* Completed View */
.completed-view { text-align: center; padding: 40px 20px; }
.completed-icon { font-size: 48px; margin-bottom: 16px; }
.completed-text { font-size: 16px; color: var(--text); margin-bottom: 20px; line-height: 1.6; }

/* ====== LEARN MODE ====== */
.learn-card { background: var(--card); border-radius: var(--radius); padding: 24px; text-align: center; }
.learn-progress { font-size: 13px; color: var(--text2); margin-bottom: 12px; }
.learn-phase { font-size: 14px; color: var(--text2); margin-bottom: 16px; }
.learn-icon { font-size: 40px; margin-bottom: 12px; }
.learn-eng { font-size: 22px; font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.learn-repeat { font-size: 14px; color: #8e44ad; margin: 8px 0; font-weight: 500; }
.learn-chn { font-size: 18px; color: var(--text2); margin-top: 8px; }
.show-chn-btn, .next-btn { margin: 4px; }
.learn-hint { margin: 16px 0; padding: 16px; background: #f8f9fa; border-radius: 8px; }
.learn-controls { margin-top: 20px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* ====== PRACTICE MODE ====== */
.practice-header { display: flex; justify-content: space-between; margin-bottom: 8px; align-items: center; }
.round-badge, .passed-badge { font-size: 12px; padding: 4px 10px; border-radius: 10px; background: #e8f0fe; color: var(--primary); }
.passed-badge { background: #e8f5e9; color: #27ae60; }
.practice-remaining { font-size: 13px; color: var(--text2); margin-bottom: 16px; }
.practice-question { text-align: center; margin-bottom: 16px; }
.practice-listen-icon { font-size: 36px; margin-bottom: 8px; }
.practice-listen-text { font-size: 15px; color: var(--text2); }

.practice-options, .test-options { display: flex; flex-direction: column; gap: 8px; }
.practice-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--card);
  border: 2px solid #e0e0e0; border-radius: 10px;
  cursor: pointer; transition: all 0.2s; font-size: 15px;
}
.practice-opt:hover { border-color: var(--primary); background: #f0f6ff; }
.practice-opt.disabled { cursor: default; opacity: 0.85; }
.practice-opt.correct { border-color: #27ae60; background: #e8f5e9; }
.practice-opt.wrong { border-color: #e74c3c; background: #fce4ec; }
.opt-label { font-weight: 700; color: var(--text2); min-width: 24px; }
.opt-text { flex: 1; }

#practice-feedback { margin: 12px 0; }
.feedback { padding: 12px 16px; border-radius: 8px; font-size: 14px; }
.feedback.correct { background: #e8f5e9; color: #27ae60; }
.feedback.wrong { background: #fce4ec; color: #e74c3c; }
.slow-link { text-decoration: underline; cursor: pointer; }

.practice-streak { text-align: center; font-size: 13px; color: #e67e22; margin-top: 12px; }

/* ====== TEST MODE ====== */
.test-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.test-progress { font-size: 16px; font-weight: 600; color: var(--primary); }
.test-lives { font-size: 18px; }
.test-question { text-align: center; margin-bottom: 16px; }
.test-listen-icon { font-size: 36px; margin-bottom: 8px; }
.test-timer { font-size: 22px; font-weight: 700; color: #e74c3c; }

/* ====== RESPONSIVE ====== */
@media (max-width: 480px) {
  .mode-grid { grid-template-columns: 1fr; }
  .learn-eng { font-size: 18px; }
  .level-card { padding: 12px; }
}
