/* 识字乐园 — 老年适配样式：大字、高对比、大按钮、无细小文字 */

:root {
  --bg: #FFF7E8;
  --card: #FFFFFF;
  --ink: #2A2419;
  --muted: #7A6F5E;
  --line: #EFE3CC;
  --primary: #E85D2F;
  --primary-deep: #C9481E;
  --primary-ink: #FFFFFF;
  --good: #2E9E44;
  --good-bg: #E6F6E9;
  --bad: #D64545;
  --bad-bg: #FDEBEB;
  --gold: #F5A623;
  --shadow: 0 4px 14px rgba(94, 74, 28, 0.10);
  --radius: 20px;
  --char-size: clamp(96px, 34vw, 230px);
  --btn-h: 78px;
  --body-size: 22px;
}

html[data-font="huge"] {
  --char-size: clamp(120px, 42vw, 300px);
  --btn-h: 92px;
  --body-size: 25px;
}
/* 首页关键字号跟着档位放大 */
html[data-font="huge"] .logo { font-size: 46px; }
html[data-font="huge"] .big-continue { font-size: 38px; min-height: 118px; }
html[data-font="huge"] .review-entry { font-size: 32px; min-height: 104px; }
html[data-font="huge"] .lesson-card { font-size: 28px; }
html[data-font="huge"] .lesson-card .emoji { font-size: 62px; }
html[data-font="huge"] .lesson-card .meta { font-size: 21px; }
html[data-font="huge"] .mode-chips a { font-size: 23px; min-height: 62px; }
html[data-font="huge"] .quiz-prompt .hint { font-size: 27px; }
html[data-font="huge"] .sentence .text { font-size: 25px; }
html[data-font="huge"] .flash .pinyin { font-size: 32px; }

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: var(--body-size);
  line-height: 1.5;
}

.app { max-width: 620px; margin: 0 auto; min-height: 100dvh; }

.screen {
  padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 116px);
}

button {
  font-family: inherit;
  border: none;
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  font-size: 26px;
  font-weight: 700;
  min-height: var(--btn-h);
  padding: 10px 22px;
  box-shadow: var(--shadow);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
button:active { transform: scale(0.97); box-shadow: 0 1px 6px rgba(94,74,28,0.12); }
button:disabled { opacity: 0.4; }
button:focus-visible { outline: 4px solid var(--gold); }

.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-good { background: var(--good); color: #fff; }
.btn-ghost { background: #FFF1DD; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 14px;
}
.topbar .back {
  min-height: 64px;
  min-width: 64px;
  font-size: 30px;
  padding: 6px 16px;
  flex: none;
}
.topbar .title {
  flex: 1;
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .side { flex: none; min-width: 8px; }

/* ---------- 首页 ---------- */
.home-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 2px 10px;
}
.home-head .logo { font-size: 40px; font-weight: 800; letter-spacing: 2px; }
.home-head .gear {
  min-height: 60px; min-width: 60px; font-size: 28px; padding: 4px 12px;
}

.big-continue {
  width: 100%;
  font-size: 32px;
  min-height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-radius: 26px;
  margin: 10px 0 6px;
  background: var(--primary);
  color: #fff;
}

.review-entry {
  width: 100%;
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 28px;
  background: #FFF1DD;
  margin: 12px 0 4px;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 14px;
}
.lesson-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 8px 14px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 3px solid transparent;
  text-decoration: none;
  color: var(--ink);
  font-size: 25px;
  font-weight: 800;
  text-align: center;
  min-height: 132px;
  justify-content: center;
}
.lesson-card:active { transform: scale(0.98); }
.lesson-card .emoji { font-size: 54px; line-height: 1.2; }
.lesson-card .meta { font-size: 19px; color: var(--muted); font-weight: 600; }
.lesson-card .trophy { font-size: 26px; }

/* ---------- 模式切换（学/写/考） ---------- */
.mode-chips {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 2px 0 10px;
}
.mode-chips a {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  border-radius: 14px;
  background: #F5EBD8;
  color: var(--ink);
  text-decoration: none;
  font-size: 21px;
  font-weight: 700;
  min-height: 56px;
  line-height: 1.3;
}
.mode-chips a.active { background: var(--primary); color: #fff; }

/* ---------- 学字卡 ---------- */
.flash {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px 16px;
  text-align: center;
}
.flash .counter { font-size: 20px; color: var(--muted); text-align: right; padding: 2px 6px 0; }
.flash .the-char {
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "FZKai-Z03S", "Noto Serif SC", serif;
  font-size: var(--char-size);
  line-height: 1.05;
  color: var(--ink);
  background: none;
  box-shadow: none;
  min-height: 0;
  padding: 0;
  display: block;
  margin: 0 auto;
  border-radius: 0;
  font-weight: 400;
}
.flash .the-char:active { transform: scale(0.98); }
.flash .pinyin { font-size: 28px; color: var(--primary-deep); font-weight: 800; letter-spacing: 3px; margin-top: -2px; }
.flash .pic { font-size: 54px; line-height: 1.15; margin: 2px 0 0; }
.word-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 10px 0 2px;
}
.word-chip {
  font-size: 24px;
  font-weight: 700;
  padding: 6px 18px;
  min-height: 52px;
  border-radius: 999px;
  background: #FFF1DD;
}
.sentence {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FBF3E2;
  border-radius: 16px;
  padding: 6px 10px;
  margin-top: 10px;
}
.sentence .text { flex: 1; text-align: left; font-size: 22px; line-height: 1.4; }
.sentence .speak {
  min-height: 56px; min-width: 56px; font-size: 24px; padding: 4px 10px; flex: none;
}

/* ---------- 底部操作条 ---------- */
.bottombar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 12px;
  padding: 12px 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: linear-gradient(to top, var(--bg) 82%, rgba(255, 247, 232, 0));
  max-width: 620px;
  margin: 0 auto;
}
.bottombar button { flex: 1; font-size: 26px; padding: 10px 6px; white-space: nowrap; }
.bottombar .prev { background: #FFF1DD; }

/* ---------- 写字页 ---------- */
.char-picker {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  scrollbar-width: none;
}
.char-picker::-webkit-scrollbar { display: none; }
.char-picker button {
  min-height: 72px;
  min-width: 72px;
  padding: 4px 8px;
  font-size: 38px;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif SC", serif;
  border: 3px solid var(--line);
  background: var(--card);
}
.char-picker button.current { border-color: var(--primary); background: #FFEDD9; }
.write-board {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  text-align: center;
}
#writer-target { width: min(78vw, 340px); height: min(78vw, 340px); margin: 4px auto; }
.write-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.write-btns button { min-height: 70px; font-size: 25px; padding: 8px 18px; }
.write-tip { font-size: 22px; color: var(--muted); padding: 16px 6px; }

/* ---------- 测验页 ---------- */
.quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 10px;
  font-size: 22px;
  color: var(--muted);
  font-weight: 700;
}
.quiz-prompt {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 12px;
  text-align: center;
  margin-bottom: 16px;
}
.quiz-prompt .hint { font-size: 24px; color: var(--muted); font-weight: 700; }
.quiz-prompt .listen-btn {
  font-size: 33px;
  min-height: 96px;
  min-width: 96px;
  border-radius: 28px;
  background: var(--primary);
  color: #fff;
}
.quiz-prompt .pic-emoji { font-size: 110px; line-height: 1.15; margin: 4px 0; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.options button {
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif SC", serif;
  font-size: clamp(64px, 19vw, 104px);
  line-height: 1.1;
  min-height: 150px;
  font-weight: 400;
  padding: 10px;
}
.options button:disabled { opacity: 1; }
.options button.correct { background: var(--good); color: #fff; animation: pop 0.35s ease; }
.options button.wrong { background: var(--bad-bg); border: 4px solid var(--bad); color: var(--bad); animation: shake 0.4s ease; opacity: 0.65; }
.options button.reveal { border: 5px dashed var(--gold); animation: pulse 1s ease infinite; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { border-color: var(--gold); }
  50% { border-color: var(--primary); }
}

/* ---------- 结算 / 空状态 ---------- */
.finish {
  text-align: center;
  padding: 30px 10px;
}
.finish .big-emoji { font-size: 100px; line-height: 1.1; }
.finish h2 { font-size: 36px; margin: 12px 0 6px; }
.finish .stars { font-size: 46px; letter-spacing: 6px; margin: 8px 0 16px; }
.finish .btn-col { display: flex; flex-direction: column; gap: 12px; }
.finish .btn-col button { width: 100%; font-size: 29px; }

/* ---------- 设置页 ---------- */
.settings-group {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.settings-group h3 { margin: 2px 4px 12px; font-size: 26px; }
.seg { display: flex; gap: 10px; }
.seg button { flex: 1; background: #F5EBD8; font-size: 26px; padding: 10px 4px; white-space: nowrap; }
.seg button.active { background: var(--primary); color: #fff; }
.tip-text { font-size: 20px; color: var(--muted); margin-top: 10px; }
.danger { background: var(--bad-bg); color: var(--bad); width: 100%; }

.banner {
  background: #FFF3CD;
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 20px;
  margin: 8px 0;
}

@media (min-width: 700px) {
  .options button { min-height: 170px; }
  .lesson-grid { gap: 18px; }
}
