/* 启蒙英语 — polished product UI v2.1 */
:root {
  --bg: #FFF6EE;
  --bg-soft: #FFE8D6;
  --card: #FFFFFF;
  --primary: #FF7A3D;
  --primary-dark: #E86528;
  --primary-soft: #FFE4D4;
  --accent: #6C5CE7;
  --accent-soft: #EEE9FF;
  --success: #2ECC71;
  --success-soft: #E6F9EF;
  --danger: #E74C3C;
  --danger-soft: #FDECEA;
  --text: #1F2A30;
  --muted: #7A8690;
  --border: #F0E4D8;
  --tab-h: 68px;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 6px 20px rgba(45, 52, 54, 0.07);
  --shadow-lg: 0 12px 32px rgba(45, 52, 54, 0.12);
  --font: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: #12121f;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#app {
  max-width: 390px;
  margin: 0 auto;
  min-height: 100%;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, #FFD4B8 0%, transparent 55%),
    var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(0,0,0,0.45);
  overflow: hidden;
}

/* —— Screens —— */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow-y: auto;
  padding-bottom: calc(var(--tab-h) + 14px);
  -webkit-overflow-scrolling: touch;
  animation: fadeIn 0.28s var(--ease);
}
.screen.active { display: flex; }
.screen.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  padding-bottom: 12px;
  animation: slideUp 0.3s var(--ease);
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  padding: 18px 20px 10px;
  text-align: center;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text);
  position: sticky;
  top: 0;
  background: rgba(255, 246, 238, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 5;
}
.page-header.with-back {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  gap: 8px;
  padding-top: 14px;
}
.page-header .title { flex: 1; text-align: center; font-size: 17px; font-weight: 800; }
.page-header .progress-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  min-width: 52px;
  text-align: right;
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 4px 8px;
  border-radius: 20px;
}

.btn-back {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
  color: var(--primary);
  padding: 6px 10px;
  min-width: 40px;
  height: 40px;
  box-shadow: var(--shadow);
  line-height: 1;
}
.btn-back:active { transform: scale(0.94); }

.content { padding: 4px 16px 20px; flex: 1; }
.tab-intro {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.5;
  padding: 0 2px;
}

/* —— Book hero —— */
.book-card {
  background: linear-gradient(145deg, #FF8A45 0%, #FF6B6B 48%, #FF5E8A 100%);
  border-radius: 22px;
  padding: 22px 20px 18px;
  color: #fff;
  box-shadow: 0 14px 36px rgba(255, 107, 107, 0.35);
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}
.book-card::before {
  content: "";
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  top: -40px;
  right: -30px;
}
.book-card::after {
  content: "";
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  bottom: -20px;
  left: 20px;
}
.book-card .book-title {
  position: relative;
  font-size: 23px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.book-card .book-meta {
  position: relative;
  font-size: 13px;
  opacity: 0.92;
  margin-bottom: 14px;
  font-weight: 500;
}
.book-card .progress-bar {
  position: relative;
  height: 9px;
  background: rgba(255,255,255,0.28);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}
.book-card .progress-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #fff, #FFE8B0);
  border-radius: 6px;
  transition: width 0.4s var(--ease);
  box-shadow: 0 0 8px rgba(255,255,255,0.6);
}
.book-card .progress-text {
  position: relative;
  font-size: 13px;
  opacity: 0.95;
  font-weight: 600;
}
.trial-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  background: rgba(255,255,255,0.22);
  backdrop-filter: blur(4px);
  padding: 6px 14px;
  border-radius: 24px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.28);
  transition: background 0.2s;
}
.trial-chip:active { background: rgba(255,255,255,0.35); }
.trial-chip.on {
  background: rgba(46, 204, 113, 0.4);
  border-color: rgba(255,255,255,0.35);
}

/* —— Counters (legacy) —— */
.counters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 22px;
}
.counter-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 14px 14px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.counter-box::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}
.counter-box:nth-child(2)::before { background: var(--accent); }
.counter-box .num {
  font-size: 30px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.counter-box:nth-child(2) .num { color: var(--accent); }
.counter-box .label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.counter-box .num span {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}
.counter-box .btn { margin-top: 12px; }

/* —— 今日学习 queue (P0, Homer-style) —— */
.today-queue {
  background: var(--card);
  border-radius: 22px;
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.today-queue::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, #FF8A45, #FF6B6B 40%, #6C5CE7);
}
.today-queue-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
.today-queue-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
}
.today-ico { font-size: 18px; line-height: 1; }
.today-queue-hint {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg-soft);
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.today-queue-body {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 14px;
  background: linear-gradient(180deg, #FFF9F4, #FFF3EA);
  border-radius: 16px;
  padding: 14px 8px;
  border: 1px solid rgba(255, 122, 61, 0.12);
}
.today-stat {
  flex: 1;
  text-align: center;
  padding: 4px 8px;
}
.today-stat-divider {
  width: 1px;
  background: linear-gradient(transparent, rgba(255,122,61,0.25), transparent);
  margin: 4px 0;
  flex-shrink: 0;
}
.today-stat-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.today-stat-num {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--primary);
}
.today-stat.review .today-stat-num { color: var(--accent); }
.today-stat-num span {
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
}
.today-stat-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 4px;
}
.today-queue-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.today-queue.done .today-queue-hint {
  background: var(--success-soft);
  color: #1B9E5A;
}
.today-queue.has-work .today-stat.new .today-stat-num {
  animation: softPulse 2.4s ease-in-out infinite;
}
@keyframes softPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  padding: 12px 18px;
  transition: transform 0.12s, opacity 0.15s, box-shadow 0.2s;
  width: 100%;
  letter-spacing: 0.04em;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none !important; }
.btn-primary {
  background: linear-gradient(180deg, #FF9358, var(--primary));
  color: #fff;
  box-shadow: 0 6px 16px rgba(255, 122, 61, 0.35);
}
.btn-primary:not(:disabled):active { box-shadow: 0 2px 8px rgba(255, 122, 61, 0.3); }
.btn-accent {
  background: linear-gradient(180deg, #8B7CF0, var(--accent));
  color: #fff;
  box-shadow: 0 6px 16px rgba(108, 92, 231, 0.32);
}
.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 2px solid var(--primary);
  box-shadow: none;
}
.btn-ghost {
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.btn-lg { padding: 15px 24px; font-size: 17px; border-radius: 16px; }
.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; }

/* —— Section / games —— */
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 800;
}
.section-title .badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 5px 11px;
  border-radius: 20px;
}

.games-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.game-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 12px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s;
}
.game-card:active { transform: scale(0.96); }
.game-card .icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: var(--primary-soft);
}
.game-card:nth-child(2) .icon { background: #E0F7FA; }
.game-card:nth-child(3) .icon { background: var(--accent-soft); }
.game-card:nth-child(4) .icon { background: #FFF3CD; }
.game-card .name { font-size: 14px; font-weight: 800; color: var(--text); }

/* —— Bottom tabs —— */
.tab-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tab-h);
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(240, 228, 216, 0.9);
  display: flex;
  z-index: 30;
  padding: 4px 6px calc(6px + env(safe-area-inset-bottom, 0));
  box-shadow: 0 -4px 24px rgba(45,52,54,0.06);
}
.tab-bar.hidden { display: none; }
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 14px;
  transition: color 0.2s, background 0.2s;
}
.tab.active {
  color: var(--primary);
  font-weight: 800;
  background: var(--primary-soft);
}
.tab .tab-icon { font-size: 22px; line-height: 1; }

/* —— Word stage —— */
.word-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 20px;
  gap: 10px;
}
.word-stage.scrollable {
  justify-content: flex-start;
  overflow-y: auto;
  padding-bottom: 8px;
}

/* Photo-first one-screen (P0): fit photo + word + phrases without scroll on 390×844 */
.word-stage.photo-first {
  justify-content: flex-start;
  overflow: hidden;
  padding: 8px 16px 4px;
  gap: 6px;
  min-height: 0;
}
.word-stage.photo-first .word-photo.hero {
  width: min(72vw, 240px);
  height: min(72vw, 240px);
  max-height: 38vh;
  border-radius: 28px;
  border-width: 5px;
  box-shadow: 0 14px 36px rgba(45, 52, 54, 0.14);
}
.word-stage.photo-first .word-en {
  font-size: 34px;
  margin-top: 2px;
}
.word-stage.photo-first .word-zh {
  font-size: 16px;
  margin-top: -2px;
}
.word-stage.photo-first .speak-btn {
  width: 48px;
  height: 48px;
  font-size: 22px;
  margin-top: 0;
}
.word-stage.photo-first .phrase-block,
.word-stage.photo-first .sentence-block {
  margin-top: 2px;
  max-width: 100%;
}
.word-stage.photo-first .block-label {
  margin-bottom: 4px;
  font-size: 10px;
}
.word-stage.photo-first .chip {
  padding: 7px 12px;
  font-size: 12px;
}
.word-stage.photo-first .sentence-row {
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 6px;
  border-radius: 12px;
}
.word-stage.photo-first .chip-row {
  gap: 6px;
}
#screen-card-detail .session-actions,
#screen-learn .session-actions {
  padding-top: 8px;
  padding-bottom: 14px;
}

.word-photo {
  width: 196px;
  height: 196px;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: linear-gradient(145deg, #f5f5f5, #e8e8e8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  flex-shrink: 0;
  border: 4px solid #fff;
  outline: 1px solid var(--border);
}
.word-photo.sm {
  width: 128px;
  height: 128px;
  border-radius: 22px;
  border-width: 3px;
}
.word-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.word-en {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: var(--text);
  line-height: 1.15;
}
.word-zh {
  font-size: 18px;
  color: var(--muted);
  font-weight: 600;
}
.speak-btn {
  background: linear-gradient(180deg, #FFE8D6, var(--primary-soft));
  border: none;
  border-radius: 50%;
  width: 58px;
  height: 58px;
  font-size: 26px;
  cursor: pointer;
  margin-top: 2px;
  transition: transform 0.12s;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(255, 122, 61, 0.22);
}
.speak-btn.sm { width: 44px; height: 44px; font-size: 20px; margin: 0; box-shadow: none; }
.speak-btn:active { transform: scale(0.9); }
.speak-btn.speaking { animation: pulse 0.6s ease; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.block-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  width: 100%;
}
.phrase-block, .sentence-block {
  width: 100%;
  max-width: 320px;
  margin-top: 6px;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.chip {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(45,52,54,0.04);
  transition: border-color 0.15s, background 0.15s;
}
.chip:active { border-color: var(--primary); background: var(--primary-soft); }
.sentence-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  line-height: 1.45;
  box-shadow: var(--shadow);
}
.sentence-row:active { background: var(--primary-soft); }

.session-actions {
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(transparent, var(--bg) 30%);
}
.session-actions.row {
  flex-direction: row;
  gap: 12px;
}
.session-actions.row .btn { flex: 1; }

/* —— Toast + celebration FX (P0 instant feedback) —— */
.toast {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.72);
  background: rgba(31, 42, 48, 0.92);
  color: #fff;
  padding: 18px 28px 16px;
  border-radius: 24px;
  font-size: 22px;
  font-weight: 800;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.28s var(--ease);
  box-shadow: var(--shadow-lg);
  text-align: center;
  min-width: 140px;
  max-width: 86%;
  line-height: 1.25;
}
.toast .toast-emoji {
  display: block;
  font-size: 36px;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}
.toast .toast-msg { display: block; }
.toast .toast-sub {
  display: block;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.9;
  margin-top: 4px;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.toast.ok {
  background: linear-gradient(160deg, #3DDB84 0%, #2ECC71 55%, #27AE60 100%);
  animation: celebPop 0.55s var(--ease);
}
.toast.ok.celebrate {
  padding: 22px 32px 18px;
  font-size: 24px;
  box-shadow: 0 16px 40px rgba(46, 204, 113, 0.45);
}
.toast.no {
  background: linear-gradient(160deg, #FFB347 0%, #FF9F43 60%, #F39C12 100%);
  color: #4A2E00;
  animation: gentleNudge 0.45s ease;
}
.toast.retry {
  background: linear-gradient(160deg, #FFE8C8 0%, #FFD8A0 100%);
  color: #6B3E00;
  border: 2px solid rgba(255, 159, 67, 0.45);
}
@keyframes celebPop {
  0% { transform: translate(-50%, -50%) scale(0.5); }
  55% { transform: translate(-50%, -50%) scale(1.12); }
  100% { transform: translate(-50%, -50%) scale(1); }
}
@keyframes gentleNudge {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  20% { transform: translate(calc(-50% - 6px), -50%) scale(1); }
  40% { transform: translate(calc(-50% + 6px), -50%) scale(1); }
  60% { transform: translate(calc(-50% - 4px), -50%) scale(1); }
  80% { transform: translate(calc(-50% + 4px), -50%) scale(1); }
}

.fx-burst {
  position: absolute;
  inset: 0;
  z-index: 95;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
}
.fx-burst.on { opacity: 1; }
.fx-burst .fx-star {
  position: absolute;
  left: 50%;
  top: 42%;
  font-size: 18px;
  animation: starFly 0.9s var(--ease) forwards;
  opacity: 0;
}
@keyframes starFly {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.4); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2); }
}

@keyframes choiceYes {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes choiceNo {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* —— Choices —— */
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
  width: 100%;
}
.choice {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 18px 12px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  color: var(--text);
  box-shadow: var(--shadow);
}
.choice:active { transform: scale(0.96); }
.choice.correct {
  border-color: var(--success);
  background: var(--success-soft);
  color: #1B9E5A;
  animation: choiceYes 0.45s var(--ease);
}
.choice.wrong {
  border-color: #FFB347;
  background: #FFF4E0;
  color: #C47A00;
  animation: choiceNo 0.4s ease;
}
.choice.img-choice {
  padding: 10px;
  font-size: 14px;
  min-height: 108px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
}
.choice.img-choice .thumb {
  width: 68px;
  height: 68px;
  border-radius: 14px;
  object-fit: cover;
}
.choice.img-choice .c-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.question-prompt {
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

/* —— Match —— */
.match-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 16px;
}
.match-tile {
  aspect-ratio: 1;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  color: var(--text);
  padding: 4px;
  word-break: break-all;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.match-tile.img-tile { padding: 0; }
.match-tile.img-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.match-tile.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(255,122,61,0.25);
}
.match-tile.matched {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.5);
}
.match-tile.mismatch {
  border-color: var(--danger);
  animation: shake 0.3s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* —— Theme grid —— */
.themes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.theme-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 0;
  text-align: left;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.theme-card::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--theme-accent, var(--primary));
  opacity: 0.9;
}
.theme-card:active { transform: scale(0.97); }
.theme-card .theme-cover,
.theme-card .theme-cover-fallback {
  width: 100%;
  height: 96px;
  object-fit: cover;
  display: block;
  background: color-mix(in srgb, var(--theme-accent, var(--primary)) 18%, white);
}
.theme-card .theme-cover-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}
.theme-card .theme-body {
  padding: 10px 12px 14px;
}
.theme-card .name { font-size: 14px; font-weight: 800; margin-bottom: 3px; }
.theme-card .count { font-size: 11px; color: var(--muted); font-weight: 600; }
.theme-card .icon {
  width: 56px;
  height: 56px;
  margin: 14px auto 8px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: color-mix(in srgb, var(--theme-accent, var(--primary)) 16%, white);
}

/* —— Word list —— */
.word-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.word-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.1s;
}
.word-row:active { transform: scale(0.98); }
.word-row.locked { opacity: 0.88; }
.word-row .emoji-box, .word-row .photo-box {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  overflow: hidden;
  background: #f3f0ec;
  box-shadow: inset 0 0 0 1px var(--border);
}
.word-row .photo-box .thumb,
.word-row .photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.word-row .info { flex: 1; min-width: 0; }
.word-row .en { font-size: 17px; font-weight: 800; }
.word-row .zh { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.word-row .learned-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}
.word-row .learned-dot.on {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}
.btn-unlock-mini {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: none;
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
}
.lock-ico {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: rgba(15, 27, 45, 0.35);
  border-radius: 14px;
  pointer-events: none;
  z-index: 1;
}

/* —— Phrase / Speaking —— */
.phrase-list, .speaking-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.list-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
}
.list-card:active { transform: scale(0.98); border-color: var(--primary); }
.list-card .list-main { flex: 1; min-width: 0; }
.list-card .en { font-size: 16px; font-weight: 800; margin-bottom: 3px; }
.list-card .zh { font-size: 13px; color: var(--muted); font-weight: 500; }
.list-card .tag {
  display: inline-block;
  margin-top: 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 3px 9px;
  border-radius: 10px;
}
.list-thumb {
  width: 80px;
  height: 80px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--primary-soft, #eef4ff);
  border: 1px solid var(--border);
}
.list-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: linear-gradient(145deg, #f3e9ff, #e8f4ff);
}
.phrase-card .list-thumb,
.speaking-card .list-thumb {
  width: 80px;
  height: 80px;
}
@media (max-width: 380px) {
  .list-thumb,
  .phrase-card .list-thumb,
  .speaking-card .list-thumb {
    width: 72px;
    height: 72px;
    border-radius: 12px;
  }
}
.speaking-card { flex-wrap: nowrap; }
.speaking-card .situation {
  width: auto;
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.phrase-detail-stage .phrase-theme-tag,
.phrase-theme-tag {
  display: inline-block;
  margin: 6px auto 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 4px 12px;
  border-radius: 12px;
}
.speaking-situation-big {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent);
  margin: 4px 0 2px;
  letter-spacing: 0.02em;
}
.phrase-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* —— Profile —— */
.profile-card {
  background: var(--card);
  border-radius: 22px;
  padding: 22px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.profile-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.profile-card h2 { font-size: 21px; margin-bottom: 6px; font-weight: 800; }
.profile-card p { font-size: 13px; color: var(--muted); line-height: 1.55; margin-bottom: 10px; font-weight: 500; }
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
}
.stat-row:last-child { border-bottom: none; }
.stat-row .val {
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 13px;
}

.about-box {
  background: rgba(255,255,255,0.7);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.65;
  margin-top: 16px;
}

/* —— Result —— */
.result-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  gap: 14px;
  text-align: center;
}
.result-stage .big { font-size: 72px; filter: drop-shadow(0 8px 16px rgba(0,0,0,0.1)); }
.result-stage h2 { font-size: 26px; font-weight: 800; }
.result-stage p { color: var(--muted); font-size: 15px; font-weight: 500; }

/* —— Modal —— */
.modal {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 18, 31, 0.5);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  background: #fff;
  border-radius: 24px;
  padding: 26px 22px;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  z-index: 1;
  animation: slideUp 0.28s var(--ease);
}
.modal-card h3 {
  font-size: 20px;
  margin-bottom: 8px;
  text-align: center;
  font-weight: 800;
}
.modal-hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 16px;
  text-align: center;
}
.activate-input {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 600;
  margin-bottom: 8px;
  outline: none;
  background: #FAFAFA;
  transition: border-color 0.15s, background 0.15s;
}
.activate-input:focus {
  border-color: var(--primary);
  background: #fff;
}
.activate-error {
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
  text-align: center;
}
.activate-error.hidden { display: none; }
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.modal-actions .btn { flex: 1; }

.hidden { display: none !important; }


/* —— Header brand —— */
.home-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #FF8A45, #FF5E8A);
  letter-spacing: 0;
  box-shadow: 0 4px 10px rgba(255,122,61,0.35);
}
.header-title { font-size: 19px; font-weight: 800; }
.book-eyebrow {
  position: relative;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 4px;
}

/* —— Stories (短文) v2.4 —— */
.story-level-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.level-chip {
  height: 32px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.level-chip.active {
  background: linear-gradient(135deg, #6BCBFF, #4B8FE8);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 10px rgba(75, 143, 232, 0.3);
}
.story-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 12px;
}
.story-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 4px 14px rgba(45, 52, 54, 0.05);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}
.story-card:active {
  transform: scale(0.98);
  border-color: var(--primary);
}
.story-card-emoji {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
  background: var(--story-accent, #EEF5FF);
}
.story-card-main { flex: 1; min-width: 0; }
.story-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.story-level-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 8px;
  background: #EEF5FF;
  color: var(--primary);
}
.story-level-badge.B {
  background: #FFF3E0;
  color: #E67E22;
}
.story-card-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
}
.story-card-zh {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 6px;
  line-height: 1.4;
}
.story-card-vocab {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.story-card-vocab span {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 8px;
  background: #F5F7FA;
  color: #636E72;
}

.story-read-content {
  padding-bottom: 28px;
}
.story-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.story-hero-emoji {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  background: var(--story-accent, #EEF5FF);
  flex-shrink: 0;
}
.story-hero-text { flex: 1; min-width: 0; }
.story-hero-en {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
}
.story-hero-zh {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}
.story-summary {
  background: #FFF9F0;
  border: 1.5px solid #FFE0B2;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: #8D6E63;
  margin-bottom: 12px;
  font-weight: 600;
}
.story-vocab-block {
  margin-bottom: 12px;
}
.story-vocab-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 6px;
}
.story-vocab-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.story-vocab-chips .chip {
  height: 30px;
  padding: 0 10px;
  border-radius: 15px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
}
.story-vocab-chips .chip:active { transform: scale(0.96); }

.story-tts-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.story-tts-bar .btn {
  flex: 1;
  min-width: 120px;
}

.story-body {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 16px 14px;
  margin-bottom: 16px;
  box-shadow: 0 4px 14px rgba(45, 52, 54, 0.04);
}
.story-sentence {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.65;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 10px;
  margin: 0 0 2px;
  transition: background 0.2s;
  cursor: pointer;
}
.story-sentence.reading {
  background: #E3F2FD;
  color: #1565C0;
}
.story-sentence .vocab-hl {
  color: var(--primary);
  background: linear-gradient(transparent 60%, rgba(75, 143, 232, 0.25) 60%);
  font-weight: 800;
}

.story-quiz {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 4px 14px rgba(45, 52, 54, 0.04);
}
.story-quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.story-quiz-title {
  font-size: 15px;
  font-weight: 800;
}
.story-quiz-progress {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.story-q {
  margin-bottom: 14px;
}
.story-q-en {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 2px;
  line-height: 1.4;
}
.story-q-zh {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}
.story-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.story-choice {
  text-align: left;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: #FAFBFC;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}
.story-choice:active { transform: scale(0.98); }
.story-choice.ok {
  border-color: #2ECC71;
  background: #E8F8F0;
  color: #1B7A45;
}
.story-choice.no {
  border-color: #E74C3C;
  background: #FDEDEC;
  color: #C0392B;
}
.story-choice:disabled { cursor: default; opacity: 0.95; }
.story-quiz-result {
  text-align: center;
  padding: 16px 8px 4px;
}
.story-quiz-result .big {
  font-size: 40px;
  margin-bottom: 6px;
}
.story-quiz-result h3 {
  margin: 0 0 4px;
  font-size: 18px;
}
.story-quiz-result p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.tab-bar .tab {
  font-size: 10px;
  padding: 4px 2px;
}
.tab-bar .tab .tab-icon {
  font-size: 20px;
}


/* —— Age band picker —— */
.age-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid rgba(75, 143, 232, 0.45);
  background: #eef5ff;
  color: #2b5fad;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.age-chip:active { transform: scale(0.98); }
.age-modal-card { max-width: 360px; }
.age-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.age-option {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  text-align: left;
  padding: 14px 16px;
  border-radius: 16px;
  border: 2px solid #e8eef8;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.age-option .age-emoji {
  grid-row: 1 / span 2;
  font-size: 28px;
  line-height: 1;
}
.age-option .age-label {
  font-size: 17px;
  font-weight: 700;
  color: #2c3e50;
}
.age-option .age-hint {
  font-size: 12px;
  color: #7f8c9b;
  margin-top: 2px;
}
.age-option:hover, .age-option:focus {
  border-color: #4B8FE8;
  box-shadow: 0 4px 14px rgba(75,143,232,.18);
}
.age-option.selected {
  border-color: #4B8FE8;
  background: #eef5ff;
}
.age-option:active { transform: scale(0.98); }
