:root {
  --coral: #FF8A65;
  --coral-d: #F4663B;
  --teal: #4ECDC4;
  --yellow: #FFD93D;
  --purple: #A78BFA;
  --blue: #5AA9FF;
  --pink: #FF7EB6;
  --bg: #FFF7F0;
  --card: #FFFFFF;
  --ink: #4A3B33;
  --ink-soft: #8A7A70;
  --ok: #36C98C;
  --no: #FF6B6B;
  --shadow: 0 8px 22px rgba(255, 138, 101, 0.18);
  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, "PingFang SC", "Heiti SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
}

/* 顶部栏 */
.topbar {
  position: sticky; top: 0; z-index: 30;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: linear-gradient(120deg, var(--coral), var(--yellow));
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 4px 14px rgba(255,138,101,.25);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { font-size: 22px; }
.brand-name { color: #fff; font-weight: 800; font-size: 17px; letter-spacing: .5px; }
.status { display: flex; gap: 8px; }
.points-pill, .level-pill {
  background: rgba(255,255,255,.92); border-radius: 999px;
  padding: 6px 12px; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; gap: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,.1);
}
.points-pill { color: var(--coral-d); }
.level-pill { color: var(--purple); }

/* 视图区 */
.view {
  padding: 16px 14px calc(76px + var(--safe-bottom));
  max-width: 720px; margin: 0 auto;
  min-height: calc(100vh - 120px);
}

/* 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: #fff;
  padding: 6px 4px calc(6px + var(--safe-bottom));
  box-shadow: 0 -4px 18px rgba(0,0,0,.08);
  border-top: 1px solid #ffe9dd;
}
.tab {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0; color: var(--ink-soft); font-size: 11px; font-weight: 700;
  transition: transform .12s;
}
.tab:active { transform: scale(.92); }
.tab-ico { font-size: 24px; line-height: 1; }
.tab.active { color: var(--coral-d); }
.tab.active .tab-ico { transform: translateY(-2px) scale(1.12); }

/* 通用卡片/按钮 */
.section-title {
  font-size: 20px; font-weight: 800; margin: 6px 2px 12px;
  display: flex; align-items: center; gap: 8px;
}
.section-title small { font-weight: 600; color: var(--ink-soft); font-size: 12px; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}

.btn {
  border: 0; border-radius: 16px; padding: 14px 18px;
  font-size: 17px; font-weight: 800; color: #fff; cursor: pointer;
  background: var(--coral); box-shadow: 0 5px 0 var(--coral-d);
  transition: transform .08s, box-shadow .08s;
  width: 100%;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--coral-d); }
.btn.teal { background: var(--teal); box-shadow: 0 5px 0 #2fae9f; }
.btn.teal:active { box-shadow: 0 1px 0 #2fae9f; }
.btn.purple { background: var(--purple); box-shadow: 0 5px 0 #7c5ce0; }
.btn.purple:active { box-shadow: 0 1px 0 #7c5ce0; }
.btn.blue { background: var(--blue); box-shadow: 0 5px 0 #3a86d6; }
.btn.blue:active { box-shadow: 0 1px 0 #3a86d6; }
.btn.ghost { background: #fff; color: var(--coral-d); box-shadow: 0 5px 0 #ffd9c7; }
.btn.ghost:active { box-shadow: 0 1px 0 #ffd9c7; }
.btn.small { width: auto; padding: 10px 16px; font-size: 15px; border-radius: 14px; }

.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }

/* 首页仪表盘 */
.hero {
  background: linear-gradient(135deg, #FF9A8B, #FF6A88);
  border-radius: 26px; padding: 20px; color: #fff;
  box-shadow: var(--shadow); margin-bottom: 16px; position: relative; overflow: hidden;
}
.hero h1 { margin: 0 0 4px; font-size: 22px; }
.hero p { margin: 0; opacity: .95; font-size: 13px; }
.hero .mascot { position: absolute; right: 8px; bottom: -6px; font-size: 70px; opacity: .9; }
.progress-ring { display: flex; gap: 8px; margin-top: 14px; }
.chip {
  background: rgba(255,255,255,.22); border-radius: 14px; padding: 8px 12px;
  font-size: 12px; font-weight: 700; backdrop-filter: blur(2px);
}

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile {
  border-radius: 20px; padding: 16px; color: #fff; cursor: pointer;
  box-shadow: var(--shadow); min-height: 110px; display: flex; flex-direction: column;
  justify-content: space-between; transition: transform .1s; position: relative; overflow: hidden;
}
.tile:active { transform: scale(.96); }
.tile .emoji { font-size: 38px; }
.tile .t-title { font-size: 17px; font-weight: 800; }
.tile .t-sub { font-size: 11px; opacity: .9; }
.tile.c1 { background: linear-gradient(135deg,#FF8A65,#FF5E62); }
.tile.c2 { background: linear-gradient(135deg,#4ECDC4,#2BB6A8); }
.tile.c3 { background: linear-gradient(135deg,#A78BFA,#7C5CE0); }
.tile.c4 { background: linear-gradient(135deg,#5AA9FF,#3A86D6); }
.tile.c5 { background: linear-gradient(135deg,#FFD93D,#FFB02E); color:#7a5b00; }
.tile.c6 { background: linear-gradient(135deg,#FF7EB6,#FF5C8A); }

/* 关卡/列表 */
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: #fff; border-radius: 16px; margin-bottom: 10px; box-shadow: var(--shadow);
  cursor: pointer;
}
.list-item:active { transform: scale(.98); }
.list-item .li-emoji { font-size: 30px; width: 44px; text-align: center; }
.list-item .li-body { flex: 1; }
.list-item .li-title { font-weight: 800; font-size: 16px; }
.list-item .li-sub { font-size: 12px; color: var(--ink-soft); }
.list-item .li-go { color: var(--coral); font-size: 22px; }
.badge-done { background: var(--ok); color:#fff; font-size: 11px; font-weight:800; padding:2px 8px; border-radius:999px; }

/* 学习卡片（闪卡） */
.flash {
  background: #fff; border-radius: 28px; box-shadow: var(--shadow);
  padding: 26px 18px; text-align: center; margin-bottom: 16px; position: relative;
  min-height: 320px; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.flash .big { font-size: 110px; font-weight: 800; line-height: 1; color: var(--coral-d); }
.flash .big.teal { color: #2fae9f; }
.flash .big.purple { color: #7c5ce0; }
.flash .big.blue { color: #3a86d6; }
.flash .pinyin { font-size: 22px; color: var(--ink-soft); margin-top: 6px; }
.flash .hint { font-size: 14px; color: var(--ink-soft); margin-top: 4px; }
.flash .speak {
  position: absolute; top: 14px; right: 14px; width: 46px; height: 46px; border-radius: 50%;
  background: var(--teal); color:#fff; font-size: 22px; border:0; cursor:pointer;
  box-shadow: 0 4px 0 #2fae9f; display:flex; align-items:center; justify-content:center;
}
.flash .speak:active { transform: translateY(3px); box-shadow: 0 1px 0 #2fae9f; }

.options { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }
.opt {
  background: #fff; border: 3px solid #ffe1d4; border-radius: 18px; padding: 18px 10px;
  font-size: 26px; font-weight: 800; color: var(--ink); cursor: pointer; text-align: center;
  box-shadow: var(--shadow); transition: transform .08s; min-height: 76px; display:flex; align-items:center; justify-content:center;
}
.opt:active { transform: scale(.95); }
.opt.correct { background: #e7fbf2; border-color: var(--ok); color: var(--ok); }
.opt.wrong { background: #ffecec; border-color: var(--no); color: var(--no); }
.opt.disabled { pointer-events: none; opacity: .55; }

/* 象形字卡片 */
.picto-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.picto {
  background:#fff; border-radius:18px; padding:10px 6px; text-align:center; cursor:pointer;
  box-shadow: var(--shadow); transition: transform .1s; border:2px solid #fff;
}
.picto:active { transform: scale(.94); }
.picto.flipped { border-color: var(--yellow); background:#fffdf0; }
.picto .glyph { font-size: 40px; font-weight: 800; color: var(--coral-d); }
.picto .pinyin { font-size: 12px; color: var(--ink-soft); }
.picto .svgbox { height: 54px; display:flex; align-items:center; justify-content:center; margin:2px 0; }
.picto .svgbox svg { height: 50px; }
.picto .meaning { font-size: 12px; font-weight: 700; color: var(--ink); margin-top:2px; }

/* 子标签（识字/英语内部分类） */
.subtabs { display:flex; gap:8px; margin-bottom:14px; }
.subtab {
  flex:1; text-align:center; padding:10px; border-radius:14px; background:#fff;
  font-weight:800; font-size:14px; color:var(--ink-soft); cursor:pointer; box-shadow: var(--shadow);
  border:2px solid #fff;
}
.subtab.active { color:var(--coral-d); border-color: var(--coral); background:#fff4ee; }

/* 进度条 */
.bar { height: 12px; background:#ffe6da; border-radius:999px; overflow:hidden; margin:8px 0; }
.bar > i { display:block; height:100%; background:linear-gradient(90deg,var(--coral),var(--yellow)); border-radius:999px; transition:width .4s; }

/* 奖励商店 */
.reward-grid { display:grid; grid-template-columns: repeat(2,1fr); gap:12px; }
.reward {
  background:#fff; border-radius:20px; padding:16px; text-align:center; box-shadow:var(--shadow);
  cursor:pointer; border:2px solid #fff;
}
.reward:active { transform:scale(.96); }
.reward.owned { border-color: var(--yellow); background:#fffdf0; }
.reward.locked { opacity:.6; }
.reward .r-emoji { font-size:46px; }
.reward .r-name { font-weight:800; margin-top:4px; }
.reward .r-cost { font-size:13px; color:var(--coral-d); font-weight:700; margin-top:4px; }
.reward .r-cost.free { color: var(--ok); }

.kids-progress { display:flex; gap:6px; flex-wrap:wrap; margin-top:6px; }
.kids-progress .kp { font-size:11px; background:#fff0e8; color:var(--coral-d); border-radius:999px; padding:3px 9px; font-weight:700; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45);
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.modal-mask.hidden { display:none; }
.modal-box {
  background:#fff; border-radius:26px; padding:24px; max-width:340px; width:100%;
  text-align:center; box-shadow:0 20px 50px rgba(0,0,0,.3); animation: pop .25s ease;
}
@keyframes pop { from{ transform:scale(.8); opacity:0;} to{transform:scale(1); opacity:1;} }
.modal-box h2 { margin:0 0 6px; font-size:24px; }
.modal-box p { color:var(--ink-soft); margin:4px 0 16px; font-size:14px; }
.modal-box .big-emoji { font-size:64px; margin-bottom:6px; }

/* 飘分 */
.float-layer { position: fixed; inset:0; pointer-events:none; z-index:50; }
.float-score {
  position:absolute; font-weight:900; font-size:28px; color:var(--yellow);
  text-shadow:0 2px 0 #e08e00; animation: floatUp 1s ease forwards;
}
@keyframes floatUp { to { transform: translateY(-80px); opacity:0; } }

/* 撒花 */
.confetti-canvas { position: fixed; inset:0; pointer-events:none; z-index:55; }

/* 安装提示 */
.install-tip {
  position: fixed; left: 12px; right: 12px; bottom: calc(84px + var(--safe-bottom));
  z-index: 40; background: rgba(74,59,51,.95); color:#fff; border-radius:16px;
  padding: 12px 14px; font-size:13px; box-shadow:0 8px 24px rgba(0,0,0,.3);
  display:flex; align-items:center; gap:10px;
}
.install-tip.hidden { display:none; }
.install-tip .it-btn { background:var(--yellow); color:#7a5b00; border:0; border-radius:12px; padding:8px 12px; font-weight:800; cursor:pointer; }
.install-tip .it-x { margin-left:auto; cursor:pointer; font-size:18px; opacity:.8; }

/* 关卡完成横幅 */
.banner {
  background: linear-gradient(135deg,#36C98C,#1FA877); color:#fff; border-radius:20px;
  padding:14px 16px; text-align:center; font-weight:800; margin-bottom:14px; box-shadow:var(--shadow);
}

.muted { color: var(--ink-soft); font-size:13px; }
.center { text-align:center; }
.mt { margin-top:12px; }
.hidden { display:none !important; }
