/* ============================================================
   style.css —— 手机端优先。所有尺寸围绕 360–430px 宽度设计
   ============================================================ */

:root {
  --cream:  #FFF8EF;
  --ink:    #4A3728;
  --red:    #FF6B6B;
  --yellow: #FFC93C;
  --green:  #7BC96F;
  --blue:   #5BB0E8;
  --purple: #9B7BE8;
  --pink:   #FF8FB1;
  --line:   3px solid var(--ink);
  --pop:    0 4px 0 var(--ink);
  --pop-lg: 0 6px 0 var(--ink);
  --r:      20px;
  --en: 'Chalkboard SE', 'Comic Sans MS', 'Trebuchet MS', system-ui, sans-serif;
  --zh: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
}

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

html, body {
  margin: 0; padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--zh);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* 顶部装饰条纹背景 */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at 12% 8%,  #FFE38A55 0 90px, transparent 91px),
    radial-gradient(circle at 88% 22%, #A8E89055 0 70px, transparent 71px),
    radial-gradient(circle at 20% 88%, #9BC9F555 0 100px, transparent 101px);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative; z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}

/* ---------------- 通用组件 ---------------- */

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 0 12px;
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(var(--cream) 72%, transparent);
}

.btn-back {
  width: 42px; height: 42px; flex: 0 0 42px;
  border: var(--line); border-radius: 14px;
  background: #fff; box-shadow: var(--pop);
  font-size: 20px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
  padding: 0 0 3px;
}
.btn-back:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.topbar h1 { font-size: 20px; margin: 0; flex: 1; font-weight: 800; }

.starcount {
  display: flex; align-items: center; gap: 4px;
  background: #fff; border: var(--line); border-radius: 14px;
  padding: 5px 10px 5px 7px; box-shadow: var(--pop);
  font-weight: 800; font-size: 15px;
}
.starcount svg { width: 20px; height: 20px; }

.btn {
  display: block; width: 100%;
  border: var(--line); border-radius: var(--r);
  background: var(--yellow); color: var(--ink);
  font-family: var(--zh); font-size: 19px; font-weight: 800;
  padding: 15px; box-shadow: var(--pop-lg); cursor: pointer;
  transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.btn.green  { background: var(--green); }
.btn.blue   { background: var(--blue); }
.btn.ghost  { background: #fff; }

.card {
  background: #fff; border: var(--line); border-radius: var(--r);
  box-shadow: var(--pop-lg);
}

/* ---------------- 首页 ---------------- */

.hero {
  text-align: center; padding: 4px 0 18px;
}
.hero-art { display: flex; justify-content: center; align-items: flex-end; gap: 4px; }
.hero-art svg { width: 92px; height: 92px; }
.hero-art svg:last-child { width: 78px; height: 78px; }
.hero h2 { margin: 6px 0 2px; font-size: 25px; font-weight: 900; letter-spacing: .5px; }
.hero p  { margin: 0; font-size: 14px; opacity: .65; }

.scene-list { display: flex; flex-direction: column; gap: 14px; }

.scene-card {
  display: flex; align-items: center; gap: 13px;
  padding: 15px; cursor: pointer;
  transition: transform .06s, box-shadow .06s;
}
.scene-card:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.scene-card.locked { opacity: .5; box-shadow: var(--pop); }

.scene-emoji {
  width: 56px; height: 56px; flex: 0 0 56px;
  border: var(--line); border-radius: 16px;
  display: grid; place-items: center; font-size: 28px;
}
.scene-emoji svg { width: 30px; height: 30px; }

.scene-meta { flex: 1; min-width: 0; }
.scene-meta b { display: block; font-size: 18px; font-weight: 800; }
.scene-meta .en { font-family: var(--en); font-size: 13px; opacity: .6; }
.scene-meta .desc { font-size: 12.5px; opacity: .6; margin-top: 2px; }

.pbar { height: 9px; background: #EFE6DA; border-radius: 5px; margin-top: 8px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--green); border-radius: 5px; transition: width .4s; }

/* ---------------- 场景四步 ---------------- */

.step-list { display: flex; flex-direction: column; gap: 13px; margin-top: 4px; }

.step {
  display: flex; align-items: center; gap: 13px;
  padding: 14px 15px; cursor: pointer;
  transition: transform .06s, box-shadow .06s;
}
.step:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }

.step-no {
  width: 46px; height: 46px; flex: 0 0 46px;
  border: var(--line); border-radius: 14px;
  display: grid; place-items: center; font-size: 24px;
}
.step-txt { flex: 1; }
.step-txt b { font-size: 17px; font-weight: 800; }
.step-txt span { display: block; font-size: 12.5px; opacity: .6; }
.step-stars { font-size: 14px; letter-spacing: 1px; }

/* ---------------- 漫画 ---------------- */

.comic-wrap { padding-bottom: 12px; }

.panel {
  position: relative; width: 100%; aspect-ratio: 1 / 1;
  border: var(--line); border-radius: var(--r);
  overflow: hidden; box-shadow: var(--pop-lg);
}
.panel .bg { position: absolute; inset: 0; }
.panel .actor, .panel .prop {
  position: absolute; transform: translate(-50%, -50%);
  filter: drop-shadow(0 3px 0 rgba(74,55,40,.18));
}
.panel .prop {
  cursor: pointer; border-radius: 22%;
  background: rgba(255,255,255,.86);
  box-shadow: 0 0 0 5px rgba(255,255,255,.86);
}
.panel .prop:active { transform: translate(-50%, -50%) scale(.9); }

.prop-tag {
  position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%);
  background: #fff; border: 2.5px solid var(--ink); border-radius: 9px;
  font-family: var(--en); font-size: 12px; font-weight: 700;
  padding: 1px 7px; white-space: nowrap;
}

.bubble {
  position: absolute; left: 4%; top: 4%;
  width: 72%; background: #fff; border: var(--line); border-radius: 16px;
  padding: 9px 12px; text-align: center;
  box-shadow: 0 3px 0 rgba(74,55,40,.25);
}
.bubble .en { font-family: var(--en); font-size: 17px; font-weight: 700; }
.bubble .zh { font-size: 12.5px; opacity: .6; margin-top: 1px; }
.bubble.to-right { left: auto; right: 4%; }
.bubble::after {
  content: ''; position: absolute; bottom: -13px; left: 22%;
  border: 8px solid transparent; border-top: 13px solid var(--ink);
}
.bubble.to-right::after { left: auto; right: 22%; }

.caption {
  margin-top: 12px; font-size: 14.5px; text-align: center;
  background: #fff; border: 2.5px dashed #D6C7B4; border-radius: 14px; padding: 10px 12px;
}

.comic-nav { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.comic-nav .btn { flex: 1; padding: 13px; font-size: 17px; }
.dots { display: flex; gap: 5px; justify-content: center; margin-top: 12px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: #DCCFC0; }
.dots i.on { background: var(--red); width: 20px; border-radius: 4px; }

/* ---------------- 单词卡 ---------------- */

.wordcard {
  padding: 20px 16px 18px; text-align: center; margin-top: 4px;
}
.wordcard .art { width: 150px; height: 150px; margin: 0 auto 6px; }
.wordcard .art svg { width: 100%; height: 100%; }
.wordcard .en {
  font-family: var(--en); font-size: 38px; font-weight: 700; line-height: 1.15;
}
.wordcard .zh { font-size: 19px; font-weight: 700; opacity: .75; margin-top: 2px; }
.wordcard .hint { font-size: 13px; opacity: .55; margin-top: 6px; }

.btn-speak {
  margin: 14px auto 0; width: 62px; height: 62px;
  border: var(--line); border-radius: 50%; background: var(--yellow);
  box-shadow: var(--pop-lg); display: grid; place-items: center; cursor: pointer;
}
.btn-speak svg { width: 32px; height: 32px; }
.btn-speak:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }

.card-nav { display: flex; gap: 10px; margin-top: 16px; }
.card-nav .btn { flex: 1; }

/* ---------------- 游戏通用 ---------------- */

.game-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; font-weight: 700; margin-bottom: 12px;
}
.game-head .lives { letter-spacing: 2px; }

.q-prompt {
  padding: 20px 16px; text-align: center; margin-bottom: 16px;
}
.q-prompt .big { font-family: var(--en); font-size: 34px; font-weight: 700; }
.q-prompt .zhbig { font-size: 30px; font-weight: 800; }
.q-prompt .sub { font-size: 13px; opacity: .55; margin-top: 4px; }

.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt {
  border: var(--line); border-radius: 18px; background: #fff;
  box-shadow: var(--pop); padding: 10px; cursor: pointer;
  display: grid; place-items: center; gap: 4px;
  transition: transform .06s, box-shadow .06s, background .2s;
}
.opt:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.opt svg { width: 74px; height: 74px; }
.opt .lbl { font-family: var(--en); font-size: 18px; font-weight: 700; }
.opt.right { background: #C8F5C0; }
.opt.wrong { background: #FFC9C9; }

.opt-list { display: flex; flex-direction: column; gap: 11px; }
.opt-list .opt { flex-direction: row; justify-content: flex-start; padding: 14px 16px; }
.opt-list .opt .lbl { font-size: 21px; }

/* 翻牌 */
.mem-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mem { aspect-ratio: 1; perspective: 700px; cursor: pointer; }
.mem-in {
  position: relative; width: 100%; height: 100%;
  transition: transform .38s; transform-style: preserve-3d;
}
.mem.open .mem-in, .mem.done .mem-in { transform: rotateY(180deg); }
.mem-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border: var(--line); border-radius: 16px; box-shadow: var(--pop);
  display: grid; place-items: center; padding: 6px; overflow: hidden;
}
.mem-back { background: var(--purple); }
.mem-back span { font-size: 26px; }
.mem-front { background: #fff; transform: rotateY(180deg); }
.mem-front svg { width: 100%; height: 100%; }
.mem-front .txt { font-family: var(--en); font-size: 14px; font-weight: 700; text-align: center; line-height: 1.15; }
.mem.done { opacity: .35; }

/* 拼写 */
.spell-slots { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 52px; }
.slot {
  width: 38px; height: 46px; border: var(--line); border-radius: 10px;
  background: #fff; display: grid; place-items: center;
  font-family: var(--en); font-size: 24px; font-weight: 700;
}
.slot.gap { border: none; background: none; width: 14px; }
.slot.filled { background: var(--yellow); }

.letter-pool { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.letter {
  width: 46px; height: 52px; border: var(--line); border-radius: 12px;
  background: #fff; box-shadow: var(--pop); cursor: pointer;
  display: grid; place-items: center;
  font-family: var(--en); font-size: 24px; font-weight: 700;
}
.letter:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.letter.used { opacity: .25; pointer-events: none; }

/* ---------------- 结算 ---------------- */

.result { text-align: center; padding: 26px 18px; margin-top: 20px; }
.result .big-stars { font-size: 46px; letter-spacing: 4px; }
.result h3 { font-size: 24px; margin: 10px 0 4px; }
.result p { font-size: 14px; opacity: .65; margin: 0 0 20px; }
.result svg { width: 110px; height: 110px; }

/* ---------------- 动效 ---------------- */

@keyframes pop { 0% { transform: scale(.7); opacity: 0 } 70% { transform: scale(1.06) } 100% { transform: scale(1); opacity: 1 } }
@keyframes shake { 0%,100% { transform: translateX(0) } 25% { transform: translateX(-7px) } 75% { transform: translateX(7px) } }
@keyframes float { 0%,100% { transform: translate(-50%,-50%) translateY(0) } 50% { transform: translate(-50%,-50%) translateY(-7px) } }
@keyframes slidein { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }

.view { animation: slidein .26s ease both; padding-bottom: 20px; }
.pop { animation: pop .3s ease both; }
.shake { animation: shake .3s ease; }
.panel .actor { animation: float 3.4s ease-in-out infinite; }
.panel .actor:nth-child(2) { animation-delay: .7s; }

/* 星星飞出 */
.fly-star {
  position: fixed; z-index: 99; width: 34px; height: 34px;
  pointer-events: none;
  animation: flyup .9s ease-out forwards;
}
@keyframes flyup {
  0%   { opacity: 1; transform: translate(-50%,-50%) scale(.5) }
  40%  { opacity: 1; transform: translate(-50%,-140%) scale(1.3) }
  100% { opacity: 0; transform: translate(-50%,-220%) scale(.7) }
}

/* 全屏庆祝 */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti i {
  position: absolute; width: 10px; height: 14px; border-radius: 2px;
  animation: fall 2.4s linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: .2 }
}

/* ============================================================
   M1 新增：底栏外壳 / 新组件
   ============================================================ */

#app { padding-bottom: 24px; }
body.has-tabbar #app { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

/* ---- 底栏（仅一级页；学习流沉浸全屏，PRD §4.4） ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: none; justify-content: center; gap: 4px;
  background: #fff; border-top: var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
body.has-tabbar .tabbar { display: flex; }
.tab {
  flex: 1; max-width: 150px; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 5px 0 3px; border-radius: 14px; font-family: var(--zh);
  transition: background .15s, transform .1s;
}
.tab .ti { width: 26px; height: 26px; display: block; }
.tab .ti svg { width: 100%; height: 100%; }
.tab .tl { font-size: 11px; font-weight: 700; color: var(--ink-3, #8A7F72); }
.tab.on .tl { color: var(--ink); }
.tab.on { background: #FFF3E4; }
.tab:active { transform: scale(.94); }

/* ---- 通用 ---- */
.lead { font-size: 13.5px; opacity: .65; margin: -4px 0 14px; }
.tip { text-align: center; font-size: 12.5px; opacity: .5; margin-top: 14px; }
.sec-h { font-size: 15px; font-weight: 800; margin: 22px 0 10px; }

/* ---- 场景卡的教材角标 ---- */
.scene-card { position: relative; }
.unit-badge {
  position: absolute; top: -8px; right: 10px;
  background: var(--yellow); border: 2.5px solid var(--ink); border-radius: 8px;
  font-size: 10.5px; font-weight: 800; padding: 1px 7px;
}

/* ---- 场景主页 ---- */
.scene-hero { display: flex; align-items: center; gap: 12px; padding: 15px; margin-bottom: 12px; }
.scene-hero .he { font-size: 36px; }
.scene-hero .hm { flex: 1; min-width: 0; }
.scene-hero .hen { font-family: var(--en); font-size: 18px; font-weight: 700; }
.scene-hero .hd { font-size: 12.5px; opacity: .65; }
.value-strip {
  background: #EFF6F0; border: 2.5px solid #B8D9BB; border-radius: 14px;
  padding: 9px 13px; font-size: 12.5px; color: #2A5C31; margin-bottom: 14px; line-height: 1.6;
}
.value-strip b { margin-right: 4px; }

/* ---- 今天 Tab ---- */
.task-card { padding: 16px; margin-bottom: 14px; }
.tc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.tc-tag { font-size: 11px; font-weight: 800; background: var(--ink); color: #fff; border-radius: 6px; padding: 2px 8px; }
.tc-p { font-family: var(--en); font-size: 12px; opacity: .6; }
.task-card h3 { font-size: 21px; margin: 2px 0 0; }
.tc-en { font-family: var(--en); font-size: 13px; opacity: .6; margin-bottom: 8px; }
.task-card .btn { margin-top: 14px; }
.streak-card { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.streak-card b { font-size: 15px; display: block; }
.streak-card span { font-size: 12px; opacity: .6; }
.streak-card .slots { display: flex; gap: 6px; }
.streak-card .slots i {
  width: 34px; height: 34px; border: 2.5px solid var(--ink); border-radius: 11px;
  display: grid; place-items: center; font-style: normal; font-size: 16px; opacity: .3; background: #fff;
}
.streak-card .slots i.on { opacity: 1; background: var(--yellow); }

/* ---- 我的 Tab ---- */
.me-hero { position: relative; display: flex; align-items: center; gap: 14px; padding: 16px; margin-bottom: 14px; }
.mh-art { width: 74px; height: 74px; flex: 0 0 74px; }
.mh-art svg { width: 100%; height: 100%; }
.mh-star { display: flex; align-items: center; gap: 6px; }
.mh-star svg { width: 30px; height: 30px; }
.mh-star b { font-size: 30px; font-family: var(--en); }
.mh-sub { font-size: 12.5px; opacity: .6; }
.gear {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px;
  border: 2.5px solid var(--ink); border-radius: 11px; background: #fff;
  font-size: 15px; cursor: pointer; line-height: 1;
}
.stat-row { display: flex; gap: 10px; margin-bottom: 6px; }
.stat {
  flex: 1; background: #fff; border: var(--line); border-radius: 16px; box-shadow: var(--pop);
  padding: 11px 6px; text-align: center;
}
.stat b { display: block; font-size: 22px; font-family: var(--en); }
.stat span { font-size: 11px; opacity: .6; }

.dex { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.dex-cell {
  background: #fff; border: 2.5px solid var(--ink); border-radius: 14px;
  padding: 7px 5px; text-align: center;
}
.dex-cell .da { width: 100%; aspect-ratio: 1; }
.dex-cell .da svg { width: 100%; height: 100%; }
.dex-cell span { font-family: var(--en); font-size: 10.5px; font-weight: 700; display: block; line-height: 1.2; }
.dex-cell.new { opacity: .32; filter: grayscale(1); }
.dex-cell.gold { border-color: #E0A800; background: #FFFBEC; box-shadow: 0 0 0 2px #FFE79A inset; }

/* ---- 家长区 ---- */
.parent .pbanner {
  background: var(--ink); color: #fff; border-radius: 12px;
  padding: 7px 12px; font-size: 12px; text-align: center; margin-bottom: 6px;
}
.tbl { overflow-x: auto; border: 2.5px solid var(--ink); border-radius: 14px; background: #fff; }
.tbl table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 8px 10px; text-align: center; border-bottom: 1px solid var(--border-soft, #E8E4DC); }
.tbl th { background: #F2EDE4; font-size: 11.5px; font-weight: 700; }
.tbl tr:last-child td { border-bottom: none; }
.btn.danger { color: #C44A39; }
.dump {
  display: none; width: 100%; height: 120px; margin-top: 12px; font-size: 10px;
  border: 2.5px solid var(--ink); border-radius: 12px; padding: 8px; font-family: var(--en);
}

/* ---- 拼单词：固定首字母提示 ---- */
.slot.fixed { background: #EFE6DA; }
.slot.ok { background: #C8F5C0; }
.btn-speak.sm { width: 50px; height: 50px; }
.btn-speak.sm svg { width: 26px; height: 26px; }
.q-prompt .qart { width: 112px; height: 112px; margin: 0 auto 6px; }
.q-prompt .qart svg { width: 100%; height: 100%; }
.result .rart { width: 110px; height: 110px; margin: 0 auto; }
.result .rart svg { width: 100%; height: 100%; }
