/* ============ 音标跟读小老师 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: linear-gradient(160deg, #ffd66b 0%, #ffb45e 30%, #ff9a76 70%, #ff8e8e 100%);
  color: #4a3420;
  overflow: hidden;
  user-select: none;
}

/* 关键：整个应用钉在视口（小课屏白屏教训），内部用流式 flex 纵向排布，避免真机 fixed 堆叠 */
.app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  max-width: 520px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 10px) 18px calc(env(safe-area-inset-bottom) + 12px);
  z-index: 1;
}

/* ===== 顶部：小老师 + 标题 ===== */
.top {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 10px;
}
.top .title { font-size: 20px; font-weight: 800; color: #5b3a1e; text-shadow: 0 1px 0 rgba(255,255,255,.5); }
.top .badge {
  background: rgba(255,255,255,.9); border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 700; color: #b45309;
  box-shadow: 0 2px 8px rgba(0,0,0,.08); white-space: nowrap;
}

/* ===== 主卡片区（占据可伸缩中区，内部纵向排布） ===== */
.stage {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
}
.card {
  width: 100%;
  background: rgba(255,255,255,.96);
  border-radius: 28px;
  padding: 24px 20px 20px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(160,80,20,.25);
}
.word-ipa {
  font-size: 40px; font-weight: 800; color: #2d2012;
  letter-spacing: 1px; line-height: 1.4; word-break: break-all;
}
.word-en {
  margin-top: 8px; font-size: 28px; font-weight: 700; color: #ea8a2b;
}
.word-hint { margin-top: 6px; font-size: 15px; color: #9a8a75; }
.progress-dot { margin-top: 10px; font-size: 13px; color: #b09a80; font-weight: 600; }

/* ===== 反馈区（流式显示在卡片下方，不覆盖底部按钮） ===== */
.feedback {
  width: 100%; flex-shrink: 0;
  display: none; flex-direction: row; align-items: center; justify-content: center; gap: 12px;
}
.feedback.show { display: flex; }
.teacher-avatar {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
}
.speech-bubble {
  background: #fff; border-radius: 18px 18px 18px 4px;
  padding: 12px 16px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  animation: pop .3s ease;
  max-width: 78%;
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.stars { display: flex; justify-content: center; gap: 6px; margin-bottom: 4px; }
.stars .star { font-size: 26px; opacity: 0; transform: scale(.5); }
.stars .star.on { opacity: 1; transform: scale(1); transition: all .3s; }
.feedback .actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.btn {
  border: none; border-radius: 999px; padding: 9px 16px;
  font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: transform .12s;
}
.btn:active { transform: scale(.95); }
.btn-again { background: #ffe9b3; color: #a05a00; }
.btn-next { background: #ff8e5e; color: #fff; box-shadow: 0 4px 14px rgba(255,120,60,.4); }
.btn-sound { background: #e6f0ff; color: #2d6fd6; }
.btn-ok { background: #4caf6e; color: #fff; }
.btn-familiar { background: #43a047; color: #fff; }
.btn-general { background: #fb8c00; color: #fff; }
.btn-no { background: #e53935; color: #fff; }
.judge-btns { display: flex; gap: 10px; justify-content: center; padding: 20px 16px 6px; }
.judge-btns .judge { flex: 1; max-width: 140px; padding: 16px 8px; font-size: 16px; border-radius: 16px; }
.nav-btns { display: flex; gap: 12px; justify-content: center; padding: 8px 16px 2px; }
.nav-btns .btn { flex: 1; max-width: 150px; padding: 12px 8px; font-size: 15px; background: #fff; color: #8a6a3a; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.word-en { display: none; } /* 先隐藏单词拼写，只留音标 */
.sound-btn {
  width: 56px; height: 56px; margin: 12px auto 4px; border-radius: 50%;
  background: linear-gradient(145deg, #7cc4ff, #4a90e2); border: none; color: #fff;
  font-size: 26px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(74,144,226,.4); flex-shrink: 0;
}
.sound-btn:active { transform: scale(.93); }
.btn-bank {
  background: rgba(255,255,255,.9); color: #b45309;
  box-shadow: 0 4px 14px rgba(0,0,0,.12); flex-shrink: 0;
}

/* ===== 错题库（孩子可见，全屏覆盖） ===== */
.bank-view {
  position: fixed; inset: 0; z-index: 150;
  background: linear-gradient(160deg, #ffd66b, #ff9a76);
  display: none; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px;
}
.bank-view.show { display: flex; }
.bank-box {
  background: #fff; border-radius: 22px; padding: 18px 16px;
  max-width: 460px; width: 100%; max-height: 82vh;
  display: flex; flex-direction: column;
  box-shadow: 0 16px 50px rgba(0,0,0,.18);
}
.bank-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.bank-head h3 { font-size: 18px; color: #b45309; }
.bank-close {
  background: #ffe9b3; border: none; width: 32px; height: 32px; border-radius: 50%;
  font-size: 16px; color: #a05a00; cursor: pointer; font-weight: 700;
}
.bank-list { flex: 1; overflow-y: auto; min-height: 60px; }
.bank-empty { text-align: center; color: #9a8a75; padding: 30px 0; font-size: 15px; }
.bank-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px; margin-bottom: 8px;
  background: #fff7ea; cursor: pointer; border: 1px solid #ffe4c0;
}
.bank-item:active { transform: scale(.98); }
.bank-item .bw { flex: 1; min-width: 0; }
.bank-item .bw .bw-en { font-size: 17px; font-weight: 800; color: #5b3a1e; }
.bank-item .bw .bw-ipa { font-size: 13px; color: #b45309; margin-top: 2px; }
.bank-item .bw-times {
  font-size: 12px; color: #fff; background: #ff8e5e;
  border-radius: 999px; padding: 3px 10px; font-weight: 700; flex-shrink: 0;
}
.bank-item .bw-play { font-size: 18px; flex-shrink: 0; color: #2d6fd6; }
.bank-actions { margin-top: 12px; display: flex; justify-content: center; }
.bank-actions .btn { padding: 12px 28px; font-size: 15px; }

/* ===== 错读列表（流式显示在反馈下方） ===== */
.wrong-list {
  width: 100%; flex-shrink: 0;
  display: none; margin-top: 8px;
}
.wrong-list.show { display: block; }
.wrong-list .wl-box {
  background: rgba(255,255,255,.92); border-radius: 16px;
  padding: 10px 14px; box-shadow: 0 4px 16px rgba(0,0,0,.1);
  max-height: 22vh; overflow-y: auto;
}
.wrong-list .wl-title { font-size: 13px; font-weight: 800; color: #b45309; margin-bottom: 6px; }
.wrong-list .wl-item { font-size: 14px; color: #6b4a24; padding: 3px 0; border-bottom: 1px dashed #f0dcc0; }
.wrong-list .wl-item:last-child { border-bottom: none; }

/* ===== 录音按钮（底部，不参与中区伸缩） ===== */
.rec-btn-wrap {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center;
  padding-top: 6px;
}
.rec-btn {
  width: 104px; height: 104px; border-radius: 50%;
  border: none; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #ff7a59, #ff4d4d 70%);
  box-shadow: 0 10px 30px rgba(255,77,77,.4), inset 0 -6px 12px rgba(0,0,0,.15);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
  position: relative;
}
.rec-btn:active { transform: scale(.94); }
.rec-btn .mic-icon { width: 44px; height: 44px; }
.rec-btn.recording {
  background: radial-gradient(circle at 35% 30%, #ffb45e, #ff8e3d 70%);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,100,60,.55); }
  70% { box-shadow: 0 0 0 26px rgba(255,100,60,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,100,60,0); }
}
.rec-btn.recording::after {
  content: "●"; position: absolute; top: 6px; right: 6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; color: #ff3b3b; font-size: 14px; line-height: 18px; text-align: center;
}
.rec-hint { margin-top: 8px; font-size: 14px; font-weight: 700; color: #6b4a24; background: rgba(255,255,255,.75); padding: 5px 16px; border-radius: 999px; }

/* ===== 家长入口（固定在角落） ===== */
.parent-link {
  position: fixed; bottom: 8px; right: 12px;
  font-size: 11px; color: rgba(90,60,20,.45); z-index: 60;
  background: none; border: none; cursor: pointer; text-decoration: none;
}

/* ===== 名字输入（全屏弹层） ===== */
.name-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.45);
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.name-mask.show { display: flex; }
.name-box {
  background: #fff; border-radius: 22px; padding: 26px 22px;
  text-align: center; max-width: 340px; width: 100%;
}
.name-box h3 { font-size: 20px; color: #b45309; margin-bottom: 6px; }
.name-box p { font-size: 13px; color: #9a8a75; margin-bottom: 14px; }
.name-box input {
  width: 100%; padding: 12px 14px; border: 2px solid #ffd9b0; border-radius: 12px;
  font-size: 18px; text-align: center; outline: none; margin-bottom: 14px;
}
.name-box input:focus { border-color: #ff8e5e; }

/* ===== 完成页（全屏覆盖） ===== */
.done-view {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(160deg, #ffd66b, #ff9a76);
  display: none; align-items: center; justify-content: center;
  padding: 24px;
}
.done-view.show { display: flex; }
.done-box {
  background: #fff; border-radius: 28px; padding: 30px 24px;
  text-align: center; max-width: 400px; width: 100%;
  box-shadow: 0 16px 50px rgba(0,0,0,.2);
}
.done-box h2 { font-size: 26px; color: #b45309; margin-bottom: 6px; }
.done-box .done-sub { font-size: 15px; color: #9a8a75; margin-bottom: 16px; }
.done-stats { display: flex; justify-content: center; gap: 20px; margin-bottom: 16px; }
.done-stats .ds { text-align: center; }
.done-stats .ds b { display: block; font-size: 30px; color: #ff7a3c; }
.done-stats .ds span { font-size: 12px; color: #9a8a75; }
