/* ============ 识字乐园 · 样式 ============ */
@font-face {
  font-family: "HZKai";
  src: url("../assets/fonts/kai.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #FFF7EC;
  --bg2: #EAF7FF;
  --ink: #3B2B1F;
  --ink-soft: #8A7565;
  --card: #FFFFFF;
  --line: #F0E3D2;
  --primary: #FF7043;
  --primary-d: #E2542A;
  --teal: #26C6DA;
  --green: #5CC46A;
  --yellow: #FFC53D;
  --purple: #AB6BE0;
  --red: #F0524E;
  --star: #FFB300;
  --shadow: 0 10px 26px rgba(190, 140, 90, .16);
  --shadow-sm: 0 4px 12px rgba(190, 140, 90, .14);
  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  text-rendering: optimizeLegibility;
}

body.locked { overflow: hidden; }

.kai { font-family: "HZKai", "Kaiti SC", "KaiTi", "STKaiti", serif; }

.app {
  position: relative;
  min-height: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: calc(10px + var(--safe-t)) 14px calc(14px + var(--safe-b));
}

/* ---------- 启动 ---------- */
.boot {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: linear-gradient(160deg, #FFF7EC, #EAF7FF);
}
.boot-logo {
  width: 108px; height: 108px; border-radius: 32px;
  display: grid; place-items: center;
  font-size: 66px; color: #fff;
  background: linear-gradient(140deg, #FFB74D, #FF7043);
  box-shadow: 0 16px 32px rgba(255, 112, 67, .34);
  animation: pop .5s ease;
}
.boot-text { color: var(--ink-soft); font-size: 15px; }

/* ---------- 通用 ---------- */
.screen { animation: fade .26s ease both; }
.screen-out { animation: fadeout .16s ease both; }

@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadeout { to { opacity: 0; } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }

.topbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.avatar {
  width: 48px; height: 48px; flex: 0 0 auto;
  border-radius: 50%; display: grid; place-items: center;
  font-size: 26px; background: #FFE9D6; border: 2px solid #FFD9BE;
}
.who { flex: 1 1 auto; min-width: 0; }
.who b { display: block; font-size: 17px; line-height: 1.2; }
.who span { font-size: 12px; color: var(--ink-soft); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 36px; padding: 0 13px; border-radius: 18px;
  background: #FFF; box-shadow: var(--shadow-sm);
  font-size: 14px; font-weight: 700; white-space: nowrap;
}
.pill.star { color: #B07800; }
.pill.fire { color: #E2542A; }

.icon-btn {
  width: 42px; height: 42px; flex: 0 0 auto;
  border: 0; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-sm); font-size: 19px; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:active { transform: scale(.94); }

.btn {
  appearance: none; border: 0; cursor: pointer;
  font-family: inherit; font-size: 17px; font-weight: 700;
  padding: 15px 22px; border-radius: var(--r-md);
  background: #fff; color: var(--ink);
  box-shadow: var(--shadow-sm);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:active { transform: translateY(2px) scale(.99); box-shadow: 0 2px 6px rgba(190,140,90,.2); }
.btn.primary {
  background: linear-gradient(150deg, #FF8A5C, #FF6A3D);
  color: #fff; box-shadow: 0 12px 24px rgba(255, 106, 61, .32);
}
.btn.go { background: linear-gradient(150deg, #63D6C5, #26C6DA); color: #fff; box-shadow: 0 12px 24px rgba(38,198,218,.3); }
.btn.big { width: 100%; padding: 18px 22px; font-size: 19px; border-radius: 22px; }
.btn.ghost { background: rgba(255,255,255,.75); color: var(--ink-soft); box-shadow: none; border: 2px solid var(--line); }
.btn[disabled] { opacity: .45; pointer-events: none; }

.card {
  background: var(--card); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 18px;
}

/* ---------- 首页 ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-lg);
  background: linear-gradient(150deg, #FFE3C7 0%, #FFD1B0 45%, #FFC2A8 100%);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -60px;
  width: 190px; height: 190px; border-radius: 50%;
  background: rgba(255,255,255,.34);
}
.hero .mini {
  width: 104px; height: 104px; flex: 0 0 auto; border-radius: 22px;
  background: #fff; display: grid; place-items: center;
  font-size: 68px; line-height: 1; color: #E2542A;
  box-shadow: inset 0 0 0 3px #FFE2CE, 0 8px 18px rgba(200,120,70,.18);
}
.hero-info { position: relative; z-index: 1; flex: 1 1 auto; min-width: 0; }
.hero-info .tag { font-size: 13px; font-weight: 700; color: #B4612F; letter-spacing: .5px; }
.hero-info h2 { margin: 4px 0 2px; font-size: 22px; }
.hero-info p { margin: 0 0 12px; font-size: 13px; color: #96603B; }
.hero .btn { padding: 13px 26px; font-size: 17px; }
.hero .cta { position: relative; z-index: 1; margin-top: 12px; flex: 1 0 100%; }
@media (max-width: 899px) { .hero { flex-wrap: wrap; } }
@media (min-width: 900px) {
  .hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 22px; }
  .hero .cta { margin-top: 0; flex: none; }
}

.progress-line { height: 10px; border-radius: 6px; background: rgba(255,255,255,.65); overflow: hidden; }
.progress-line i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #FFB74D, #FF7043); transition: width .5s ease; }

.tiles {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 14px;
}
.tile {
  border: 0; cursor: pointer; text-align: left;
  background: #fff; border-radius: var(--r-md); padding: 16px;
  box-shadow: var(--shadow-sm); font-family: inherit; color: var(--ink);
  display: flex; align-items: center; gap: 12px;
  transition: transform .12s ease;
}
.tile:active { transform: scale(.98); }
.tile .em { font-size: 30px; }
.tile b { display: block; font-size: 16px; }
.tile span { font-size: 12px; color: var(--ink-soft); }
.tile.soon { opacity: .72; }

.section-title {
  display: flex; align-items: baseline; gap: 8px;
  margin: 20px 2px 10px; font-size: 16px; font-weight: 800;
}
.section-title span { font-size: 12px; font-weight: 500; color: var(--ink-soft); }

/* ---------- 单元 / 关卡 ---------- */
.unit {
  background: #fff; border-radius: var(--r-lg); padding: 14px 16px;
  box-shadow: var(--shadow-sm); margin-bottom: 12px;
}
.unit-head { display: flex; align-items: center; gap: 12px; }
.unit-no {
  width: 46px; height: 46px; flex: 0 0 auto; border-radius: 14px;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px;
}
.unit-meta { flex: 1 1 auto; min-width: 0; }
.unit-meta b { font-size: 17px; }
.unit-meta span { display: block; font-size: 12px; color: var(--ink-soft); }
.unit-badge { font-size: 12px; font-weight: 700; color: #B07800; white-space: nowrap; }
.unit.locked { opacity: .62; }
.unit.locked .unit-no { background: #CFC4B8 !important; }

.levels { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; margin-top: 14px; max-width: 560px; }
.lv {
  position: relative; aspect-ratio: 1 / 1;
  border: 0; border-radius: 16px; cursor: pointer;
  background: #FFF6EC; font-family: inherit;
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 2px #F6E7D5;
  transition: transform .1s ease;
}
.lv:active { transform: scale(.96); }
.lv .ch { font-size: 30px; color: #4A3729; line-height: 1; }
.lv .st { position: absolute; bottom: 4px; font-size: 9px; letter-spacing: -1px; color: var(--star); }
.lv.done { background: #FFF0D6; box-shadow: inset 0 0 0 2px #FFD79A; }
.lv.now { background: #FFF; box-shadow: inset 0 0 0 3px var(--primary), 0 6px 14px rgba(255,112,67,.25); }
.lv.now::after {
  content: ""; position: absolute; inset: -6px; border-radius: 20px;
  border: 2px dashed rgba(255,112,67,.55); animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%,100% { opacity: .9; transform: scale(1); } 50% { opacity: .35; transform: scale(1.03); } }
.lv.lock { background: #F4EFE8; box-shadow: none; }
.lv.lock .ch { color: #C9BEB2; }

/* ---------- 字卡学习 ---------- */
.learn-wrap { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 900px) {
  .learn-wrap { grid-template-columns: 1.05fr .95fr; align-items: start; }
  .learn-right { position: sticky; top: 12px; }
}

.char-card {
  background: #fff; border-radius: var(--r-lg); padding: 16px;
  box-shadow: var(--shadow); text-align: center;
}
.pinyin { font-size: 26px; font-weight: 700; color: var(--primary-d); letter-spacing: 2px; }
.grid-box {
  position: relative; width: min(58vw, 260px); aspect-ratio: 1/1; margin: 8px auto 4px;
  border: 3px solid #FFCFA8; border-radius: 20px; background: #FFFDF8;
  display: grid; place-items: center; overflow: hidden;
}
.grid-box::before, .grid-box::after {
  content: ""; position: absolute; background: repeating-linear-gradient(90deg, #F3D3B6 0 8px, transparent 8px 16px);
}
.grid-box::before { left: 50%; top: 0; bottom: 0; width: 2px; transform: translateX(-1px); }
.grid-box::after { top: 50%; left: 0; right: 0; height: 2px; transform: translateY(-1px);
  background: repeating-linear-gradient(0deg, #F3D3B6 0 8px, transparent 8px 16px); }
.grid-box .big { font-size: min(40vw, 180px); line-height: 1; color: #3B2B1F; position: relative; z-index: 1; }

.meta-row { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
.meta-chip {
  font-size: 13px; padding: 6px 12px; border-radius: 12px;
  background: #FFF4E8; color: #9A6A44; font-weight: 600;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0; }
.chip-word {
  border: 0; cursor: pointer; font-family: inherit;
  font-size: 17px; font-weight: 700; padding: 9px 14px; border-radius: 14px;
  background: #EAF7FF; color: #1B6B7C; display: inline-flex; align-items: center; gap: 6px;
}
.chip-word:active { transform: scale(.97); }

.sentence {
  font-size: 17px; line-height: 1.8; color: #4A3729;
  background: #FFFBF2; border: 2px dashed #FFE0BE; border-radius: 16px;
  padding: 12px 14px; margin: 6px 0 10px;
}
.sentence em { font-style: normal; color: var(--primary-d); font-weight: 800; text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 4px; }
.hint { font-size: 13.5px; color: #8A7565; line-height: 1.7; text-align: left; background: #F7F9FB; border-radius: 14px; padding: 10px 12px; }

.trace-box { margin-top: 4px; }
.trace-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.trace-head b { font-size: 15px; }
canvas.trace {
  width: 100%; aspect-ratio: 1/1; max-height: 46vh;
  border-radius: 20px; background: #FFFDF8;
  box-shadow: inset 0 0 0 3px #FFCFA8;
  touch-action: none; display: block;
}

.row { display: flex; gap: 10px; }
.row > * { flex: 1 1 0; }

/* ---------- 答题 ---------- */
.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.dots { display: flex; gap: 6px; flex: 1 1 auto; }
.dots i { height: 8px; flex: 1 1 0; border-radius: 4px; background: #F0E3D2; }
.dots i.on { background: var(--primary); }
.dots i.ok { background: var(--green); }
.dots i.bad { background: #F0A9A7; }

.q-card { background: #fff; border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow); text-align: center; max-width: 780px; margin: 0 auto; }
.q-prompt { font-size: 17px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.q-big { font-size: min(26vw, 120px); line-height: 1.15; color: #3B2B1F; }
.q-word { font-size: min(12vw, 54px); font-weight: 700; letter-spacing: 6px; }
.q-blank { color: var(--primary); }
.q-pic { font-size: min(22vw, 96px); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.opt {
  border: 0; cursor: pointer; font-family: inherit;
  background: #fff; border-radius: 22px; padding: 14px 10px;
  min-height: 84px;
  box-shadow: 0 6px 16px rgba(190,140,90,.16), inset 0 0 0 2px #F6E7D5;
  display: grid; place-items: center; gap: 2px;
  transition: transform .1s ease, box-shadow .15s ease, background .15s ease;
}
.opt .ch { font-size: min(11vw, 46px); line-height: 1; color: #3B2B1F; }
.opt .em { font-size: min(11vw, 44px); line-height: 1; }
.opt .lb { font-size: 12px; color: var(--ink-soft); }
.opt:active { transform: scale(.97); }
.opt.right { background: #EAF9EC; box-shadow: 0 6px 16px rgba(92,196,106,.28), inset 0 0 0 3px var(--green); animation: okpop .3s ease; }
.opt.wrong { background: #FDECEC; box-shadow: inset 0 0 0 3px #F0A9A7; animation: shake .32s ease; }
.opt[disabled] { pointer-events: none; }
@keyframes okpop { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.feedback {
  margin-top: 12px; min-height: 26px; font-size: 16px; font-weight: 700;
}
.feedback.ok { color: #3B9B49; }
.feedback.bad { color: #D9534F; }

/* ---------- 结算 ---------- */
.result-card { text-align: center; background: #fff; border-radius: var(--r-lg); padding: 26px 18px; box-shadow: var(--shadow); }
.stars { display: flex; justify-content: center; gap: 14px; font-size: 46px; margin: 6px 0 4px; min-height: 58px; }
.stars span { filter: grayscale(1) opacity(.28); transform: scale(.8); transition: all .35s cubic-bezier(.2,1.4,.5,1); }
.stars span.on { filter: none; transform: scale(1); }
.result-char { font-size: 96px; line-height: 1.1; color: #3B2B1F; margin: 6px 0; }
.result-sub { color: var(--ink-soft); font-size: 14px; margin-bottom: 16px; }

.burst { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 80; }
.burst i { position: absolute; font-size: 26px; animation: fly 1.4s ease-out forwards; }
@keyframes fly {
  0% { transform: translate(0,0) scale(.4); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.1) rotate(var(--rot)); opacity: 0; }
}

/* ---------- 贴纸 ---------- */
.sticker-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 700px) { .sticker-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .sticker-grid { grid-template-columns: repeat(5, 1fr); } }
.sticker {
  background: #fff; border-radius: 22px; padding: 16px 12px; text-align: center;
  box-shadow: var(--shadow-sm);
}
.sticker .em { font-size: 44px; line-height: 1.1; }
.sticker b { display: block; font-size: 14px; margin-top: 6px; }
.sticker span { font-size: 11px; color: var(--ink-soft); }
.sticker.locked { background: #F4EFE8; box-shadow: none; }
.sticker.locked .em { filter: grayscale(1) opacity(.35); }

/* ---------- 家长 ---------- */
.pin-wrap { text-align: center; max-width: 420px; margin: 30px auto; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 22px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; background: #EDE3D6; transition: background .15s; }
.pin-dots i.on { background: var(--primary); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pad button {
  border: 0; cursor: pointer; font-family: inherit; font-size: 26px; font-weight: 700;
  height: 68px; border-radius: 18px; background: #fff; color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.pad button:active { transform: scale(.96); background: #FFF3E6; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border-radius: 18px; padding: 12px; text-align: center; box-shadow: var(--shadow-sm); }
.stat b { display: block; font-size: 24px; }
.stat span { font-size: 12px; color: var(--ink-soft); }

.list { background: #fff; border-radius: 18px; box-shadow: var(--shadow-sm); overflow: hidden; }
.list-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #F7EFE4; font-size: 15px; }
.list-row:last-child { border-bottom: 0; }
.list-row small { color: var(--ink-soft); font-size: 12px; }

.study-log { max-height: 46vh; overflow: auto; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; font-weight: 600; }
.input {
  width: 100%; border: 2px solid var(--line); border-radius: 16px;
  padding: 14px 16px; font-size: 17px; font-family: inherit; background: #fff; color: var(--ink);
  outline: none;
}
.input:focus { border-color: #FFC69E; }
.avatar-pick { display: flex; gap: 10px; flex-wrap: wrap; }
.avatar-pick button {
  width: 54px; height: 54px; border-radius: 16px; border: 2px solid var(--line);
  background: #fff; font-size: 26px; cursor: pointer;
}
.avatar-pick button.sel { border-color: var(--primary); background: #FFF3E6; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + var(--safe-b));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: rgba(59,43,31,.92); color: #fff; font-size: 14px; font-weight: 600;
  padding: 11px 18px; border-radius: 14px; max-width: 86vw; text-align: center;
  transition: all .22s ease; z-index: 95;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 横屏手机适配 ---------- */
@media (max-height: 480px) and (orientation: landscape) {
  .hero .mini { width: 76px; height: 76px; font-size: 48px; }
  .grid-box { width: min(30vh, 180px); }
}
@media (min-width: 760px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .app { padding-left: 26px; padding-right: 26px; }
}

/* ---------- 小屏手机 ---------- */
@media (max-width: 430px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .pill { height: 32px; padding: 0 10px; font-size: 13px; }
  .who b { font-size: 16px; }
  .who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hero { padding: 14px; gap: 12px; }
  .hero .mini { width: 84px; height: 84px; font-size: 54px; border-radius: 18px; }
  .hero-info h2 { font-size: 19px; }
  .avatar { width: 42px; height: 42px; font-size: 22px; }
  .icon-btn { width: 38px; height: 38px; font-size: 17px; }
  .levels { gap: 7px; }
  .lv .ch { font-size: 26px; }
  .card, .unit { padding: 14px; }
  .stat b { font-size: 21px; }
}
