/* ============================================================
   成长配对乐园 —— 全局样式
   风格：糖果渐变卡通风（大圆角 / 柔和渐变 / 圆润粗体 / 弹跳动效）
   主题皮肤：通过 <html data-skin="..."> 覆盖 CSS 变量实现
   ============================================================ */

/* ---------- 默认皮肤：糖果乐园 ---------- */
:root {
  --primary: #ff5fa2;
  --primary-dark: #e14a86;
  --primary-soft: #ffe6f1;
  --accent: #8b6cf6;
  --accent-soft: #efe9ff;
  --bg-a: #fff3f9;
  --bg-b: #eef2ff;
  --nav-a: #ff8fc4;
  --nav-b: #9d7bf9;
  --card: #ffffff;
  --text: #463a55;
  --text-sub: #9a92ab;
  --line: #f0e6f2;
  --ok: #35c48d;
  --warn: #ff8a4c;
  --gold: #ffc53d;
  --radius: 20px;
  --radius-lg: 26px;
  --shadow: 0 6px 18px rgba(150, 110, 190, 0.14);
  --shadow-lg: 0 12px 28px rgba(150, 110, 190, 0.20);
  --tab-h: 62px;
}

/* ---------- 主题皮肤变体 ---------- */
html[data-skin="piggy"] {
  --primary: #ff7fae; --primary-dark: #e5548c; --primary-soft: #ffe4ef;
  --accent: #ff9ec7; --accent-soft: #ffeaf4;
  --bg-a: #fff1f6; --bg-b: #ffe7ef;
  --nav-a: #ff9ec4; --nav-b: #ff7fae;
}
html[data-skin="puppy"] {
  --primary: #ff9c3d; --primary-dark: #e07b16; --primary-soft: #fff0dd;
  --accent: #ffd166; --accent-soft: #fff6df;
  --bg-a: #fff8ea; --bg-b: #fff0dd;
  --nav-a: #ffc46b; --nav-b: #ff9c3d;
}
html[data-skin="sheriff"] {
  --primary: #4a72e8; --primary-dark: #3358c4; --primary-soft: #e6ecff;
  --accent: #ff6b6b; --accent-soft: #ffe6e6;
  --bg-a: #eff4ff; --bg-b: #e2ebff;
  --nav-a: #6d92ff; --nav-b: #3f63d6;
}
html[data-skin="forest"] {
  --primary: #45b07c; --primary-dark: #2f8d5f; --primary-soft: #e2f6ec;
  --accent: #ffb54d; --accent-soft: #fff2dc;
  --bg-a: #eefbf3; --bg-b: #e4f7ea;
  --nav-a: #7fd3a4; --nav-b: #3aa06c;
}
html[data-skin="ocean"] {
  --primary: #2bb3d6; --primary-dark: #1a8db0; --primary-soft: #e0f6fd;
  --accent: #5f7cf6; --accent-soft: #e8ecff;
  --bg-a: #eafbff; --bg-b: #dff3ff;
  --nav-a: #7ed6ea; --nav-b: #2bb3d6;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: linear-gradient(160deg, var(--bg-a) 0%, var(--bg-b) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font-family: inherit; }

/* 小程序外壳：手机宽度居中 */
.phone {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  background: linear-gradient(170deg, var(--bg-a) 0%, var(--bg-b) 60%, var(--bg-a) 100%);
  position: relative;
  overflow: hidden;
}

/* 顶部导航栏 */
.nav {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(120deg, var(--nav-a), var(--nav-b));
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  box-shadow: 0 6px 16px rgba(120, 90, 170, 0.22);
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
}
.nav .back {
  position: absolute; left: 8px; top: 0; height: 50px; width: 48px;
  border: none; background: none; font-size: 24px; color: #fff; cursor: pointer;
}
.nav .back:active { opacity: .55; }

/* 页面容器 */
.page { display: none; padding: 14px 14px calc(var(--tab-h) + 26px); }
.page.active { display: block; animation: fade .26s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.block { margin-bottom: 18px; }
.block-title {
  font-size: 16px; font-weight: 800; margin: 0 0 10px 4px; color: var(--primary-dark);
  display: flex; align-items: center; gap: 6px;
}
.block-title::before {
  content: ''; width: 8px; height: 18px; border-radius: 6px;
  background: linear-gradient(180deg, var(--primary), var(--accent));
}
.hint-text { font-size: 13px; color: var(--text-sub); margin: 8px 4px 0; font-weight: 600; }

/* 首页标题区 */
.hero { text-align: center; padding: 6px 0 16px; position: relative; }
.hero .buddy {
  font-size: 54px; line-height: 1; display: inline-block;
  animation: floaty 2.4s ease-in-out infinite;
  filter: drop-shadow(0 8px 12px rgba(150,110,190,.28));
}
@keyframes floaty { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(2deg); } }
.hero h1 {
  font-size: 27px; margin: 6px 0 0; letter-spacing: 1px; font-weight: 900;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { margin: 8px 0 0; color: var(--text-sub); font-size: 14px; }

/* 主题皮肤选择 */
.skin-row { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.skin-row::-webkit-scrollbar { display: none; }
.skin-card {
  flex: 0 0 auto; width: 92px;
  background: var(--card); border: 3px solid transparent; border-radius: 18px;
  padding: 12px 6px 10px; text-align: center; box-shadow: var(--shadow);
  cursor: pointer; transition: .2s;
}
.skin-card .sk { font-size: 30px; line-height: 1; }
.skin-card .nmm { font-size: 13px; font-weight: 800; margin-top: 7px; }
.skin-card .dsc { font-size: 10px; color: var(--text-sub); margin-top: 2px; font-weight: 600; }
.skin-card.sel {
  border-color: var(--primary);
  background: linear-gradient(160deg, var(--primary-soft), var(--accent-soft));
  transform: translateY(-2px) scale(1.03);
  box-shadow: var(--shadow-lg);
}
.skin-card:active { transform: scale(.97); }

/* 学科卡片组 */
.subject-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.subject-card {
  background: var(--card); border: 3px solid transparent; border-radius: var(--radius-lg);
  padding: 16px 6px 13px; text-align: center; box-shadow: var(--shadow);
  cursor: pointer; transition: .2s;
}
.subject-card .ico { font-size: 28px; display: block; margin-bottom: 7px; }
.subject-card .nm { font-size: 15px; font-weight: 800; }
.subject-card.sel {
  border-color: var(--primary);
  background: linear-gradient(160deg, var(--primary-soft), var(--accent-soft));
  transform: translateY(-2px); box-shadow: var(--shadow-lg);
}
.subject-card:active { transform: scale(.97); }
.subject-card.disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }
.subject-card .lock { display: block; font-size: 11px; color: var(--text-sub); margin-top: 4px; }

/* 主题卡片 */
.theme-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-card {
  background: var(--card); border: 3px solid transparent; border-radius: var(--radius);
  padding: 13px 6px 11px; text-align: center; box-shadow: var(--shadow);
  cursor: pointer; transition: .2s;
}
.theme-card .prev { font-size: 30px; line-height: 1; display: block; }
.theme-card .nm { font-size: 15px; font-weight: 800; margin-top: 8px; }
.theme-card .gd { font-size: 11px; color: var(--text-sub); margin-top: 3px; }
.theme-card.sel {
  border-color: var(--primary);
  background: linear-gradient(160deg, var(--primary-soft), var(--accent-soft));
  transform: translateY(-2px); box-shadow: var(--shadow-lg);
}
.theme-card:active { transform: scale(.97); }

/* 单选组 */
.opt-list { display: flex; flex-direction: column; gap: 9px; }
.opt {
  display: flex; align-items: center; gap: 11px;
  background: var(--card); border: 3px solid transparent;
  border-radius: 16px; padding: 13px 15px; box-shadow: var(--shadow); cursor: pointer; transition: .2s;
}
.opt .dot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #d9c8e2; flex: 0 0 auto; position: relative; }
.opt.sel { border-color: var(--primary); background: linear-gradient(120deg, var(--primary-soft), var(--accent-soft)); }
.opt.sel .dot { border-color: var(--primary); }
.opt.sel .dot::after { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: var(--primary); }
.opt .lbl { font-size: 15px; font-weight: 800; }
.opt .sub { font-size: 12px; color: var(--text-sub); margin-top: 2px; font-weight: 600; }
.opt:active { transform: scale(.985); }

/* 主按钮（糖果渐变 + 流动光泽） */
.btn-main {
  width: 100%; height: 58px; border: none; border-radius: 29px; position: relative; overflow: hidden;
  background: linear-gradient(120deg, var(--primary), var(--accent));
  background-size: 180% 100%;
  color: #fff; font-size: 20px; font-weight: 800; letter-spacing: 1px;
  box-shadow: 0 10px 22px rgba(150, 110, 190, .38); cursor: pointer; transition: .18s;
  animation: flow 4s ease infinite;
}
@keyframes flow { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.btn-main::after {
  content: ''; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,.5), transparent);
  transform: skewX(-18deg); animation: shine 3.2s ease-in-out infinite;
}
@keyframes shine { 0% { left: -60%; } 55%,100% { left: 130%; } }
.btn-main:active { transform: scale(.975); }
.btn-main:disabled {
  background: #d8d2e4; box-shadow: none; color: #fff; cursor: not-allowed; animation: none;
}
.btn-main:disabled::after { display: none; }

/* 底部 Tab */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 480px; height: var(--tab-h);
  background: #fff; box-shadow: 0 -6px 18px rgba(150,110,190,.14);
  display: grid; grid-template-columns: repeat(3, 1fr); z-index: 40;
  padding-bottom: env(safe-area-inset-bottom);
  border-top-left-radius: 22px; border-top-right-radius: 22px;
}
.tabbar .tab {
  border: none; background: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; color: var(--text-sub); cursor: pointer; transition: .2s; font-weight: 700;
}
.tabbar .tab .ic { font-size: 22px; transition: .2s; }
.tabbar .tab.on { color: var(--primary); }
.tabbar .tab.on .ic { transform: translateY(-2px) scale(1.15); }

/* ---------- 游戏页 ---------- */
.game-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 4px 10px; font-size: 15px; font-weight: 800;
}
.game-head .score { color: var(--gold); }
.game-head .combo-badge {
  font-size: 12px; padding: 3px 10px; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary-dark);
  transition: .2s; opacity: .5;
}
.game-head .combo-badge.hot {
  opacity: 1; color: #fff;
  background: linear-gradient(120deg, var(--warn), var(--primary));
  animation: pop .3s cubic-bezier(.2,.9,.3,1.5);
}
@keyframes pop { 0% { transform: scale(.6); } 100% { transform: scale(1); } }

.progress { height: 12px; border-radius: 8px; background: var(--primary-soft); overflow: hidden; margin: 0 2px 10px; }
.progress .bar {
  height: 100%; width: 0; border-radius: 8px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .35s cubic-bezier(.2,.9,.3,1.2);
}

/* 游戏页小助手 */
.game-buddy { display: flex; align-items: center; gap: 8px; margin: 0 2px 10px; min-height: 40px; }
.game-buddy .buddy { font-size: 32px; line-height: 1; animation: bounceIn .3s ease; }
.game-buddy .buddy.wiggle { animation: wiggle .5s ease; }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-12deg) scale(1.1); } 75% { transform: rotate(12deg) scale(1.1); } }
@keyframes bounceIn { 0% { transform: scale(.7); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.game-buddy .bubble {
  font-size: 13px; font-weight: 700; color: var(--primary-dark);
  background: #fff; border-radius: 14px; padding: 6px 12px;
  box-shadow: var(--shadow); position: relative;
}
.game-buddy .bubble::before {
  content: ''; position: absolute; left: -6px; top: 50%; transform: translateY(-50%);
  border: 6px solid transparent; border-right-color: #fff;
}

.game-fn { display: flex; gap: 10px; margin-bottom: 12px; }
.btn-fn {
  flex: 1; height: 46px; border: none; border-radius: 15px;
  background: #fff; color: var(--primary-dark); font-size: 15px; font-weight: 800;
  box-shadow: var(--shadow); cursor: pointer; transition: .18s;
}
.btn-fn:disabled { opacity: .45; cursor: not-allowed; }
.btn-fn:active { background: var(--primary-soft); transform: scale(.98); }

.board-wrap { position: relative; }
.board { display: grid; gap: 7px; margin: 0 auto 12px; width: 100%; position: relative; z-index: 2; }
.cell { perspective: 700px; }
.card {
  width: 100%; height: 100%; border-radius: 14px;
  background: linear-gradient(160deg, #ffffff, #fff7fb);
  border: 3px solid var(--line);
  box-shadow: 0 3px 8px rgba(120, 90, 150, .10);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; transition: opacity .35s, transform .18s, border-color .15s, box-shadow .18s;
  overflow: hidden; padding: 3px;
}
.card .emoji { line-height: 1.05; }
.card .word { font-weight: 800; word-break: break-word; text-align: center; padding: 0 2px; }
.card .zh { font-size: 11px; color: var(--text-sub); margin-top: 3px; }
.card:active { transform: scale(.96); }
.card.sel {
  border-color: var(--primary);
  background: linear-gradient(160deg, var(--primary-soft), var(--accent-soft));
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 18px rgba(150,110,190,.30);
}
.card.wrong { animation: shake .42s; border-color: var(--warn); background: #fff0e6; }
.card.hint { animation: pulse 1s infinite; border-color: var(--ok); }
.card.pop { animation: cardPop .42s cubic-bezier(.2,.9,.3,1.6); }
.card.gone { opacity: 0; transform: scale(.5) rotate(8deg); pointer-events: none; }
@keyframes cardPop { 0% { transform: scale(1); } 45% { transform: scale(1.16); } 100% { transform: scale(1); } }
@keyframes shake {
  0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); } 75% { transform: translateX(-3px); }
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(53,196,141,.55); } 50% { box-shadow: 0 0 0 10px rgba(53,196,141,0); } }
.cell.blank { visibility: hidden; }

/* 庆祝粒子层 */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; overflow: visible; }
.fx .p {
  position: absolute; font-size: 20px; line-height: 1; pointer-events: none;
  animation: burst .7s ease-out forwards;
}
@keyframes burst {
  0% { opacity: 1; transform: translate(0,0) scale(.4); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.1) rotate(var(--rot)); }
}
.fx .confetti {
  position: absolute; width: 10px; height: 14px; border-radius: 3px; top: -20px;
  animation: fall 2.4s linear forwards;
}
@keyframes fall {
  0% { opacity: 1; transform: translateY(0) rotate(0); }
  100% { opacity: 0; transform: translateY(120vh) rotate(720deg); }
}

.board-tip { text-align: center; font-size: 13px; color: var(--text-sub); margin: 0 0 8px; font-weight: 600; }

/* ---------- 学习档案 ---------- */
.filter-row { display: flex; gap: 10px; margin-bottom: 14px; }
.filter-row select {
  flex: 1; height: 46px; border-radius: 14px; border: 3px solid var(--line);
  background: #fff; font-size: 15px; font-weight: 700; padding: 0 12px; color: var(--text);
  box-shadow: var(--shadow); appearance: none;
}
.rec {
  background: #fff; border-radius: var(--radius); padding: 13px 15px;
  box-shadow: var(--shadow); margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.rec .info { font-size: 14px; line-height: 1.6; font-weight: 600; }
.rec .info b { font-size: 16px; font-weight: 800; }
.rec .info .dim { color: var(--text-sub); font-size: 12px; }
.btn-sm {
  border: none; border-radius: 12px; height: 38px; padding: 0 15px;
  background: linear-gradient(120deg, var(--primary-soft), var(--accent-soft));
  color: var(--primary-dark); font-size: 13px; font-weight: 800; cursor: pointer; white-space: nowrap;
}
.btn-sm:active { opacity: .7; }
.empty { text-align: center; color: var(--text-sub); font-size: 13px; padding: 26px 0; font-weight: 600; }
.wrong-count { font-size: 13px; color: var(--warn); font-weight: 800; }

/* ---------- 设置页 ---------- */
.set-item {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border-radius: var(--radius); padding: 16px 17px;
  box-shadow: var(--shadow); margin-bottom: 11px; font-size: 15px; font-weight: 800;
}
.switch { width: 54px; height: 30px; border-radius: 15px; background: #ddd5e6; position: relative; transition: .2s; cursor: pointer; border: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.switch.on { background: linear-gradient(120deg, var(--primary), var(--accent)); }
.switch.on::after { left: 27px; }
.set-text { font-size: 14px; color: var(--text-sub); line-height: 1.9; padding: 4px 4px 0; font-weight: 600; }

/* ---------- 弹窗 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(60, 40, 80, .48);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 24px;
  backdrop-filter: blur(2px);
}
.mask.show { display: flex; animation: fade .2s; }
.dialog {
  width: 100%; max-width: 348px;
  background: linear-gradient(170deg, #fff, var(--bg-a));
  border-radius: 26px; padding: 24px 20px 18px; text-align: center;
  animation: pop .26s cubic-bezier(.2,.9,.3,1.3);
  max-height: 84vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.dialog h3 {
  margin: 0 0 8px; font-size: 21px; font-weight: 900;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.dialog .sub { font-size: 14px; color: var(--text-sub); line-height: 1.7; font-weight: 600; }
.dialog .actions { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }
.dialog .actions.row { flex-direction: row; }
.btn-dlg { flex: 1; height: 48px; border: none; border-radius: 24px; font-size: 16px; font-weight: 800; cursor: pointer; transition: .15s; }
.btn-dlg.primary { background: linear-gradient(120deg, var(--primary), var(--accent)); color: #fff; box-shadow: 0 8px 16px rgba(150,110,190,.32); }
.btn-dlg.ghost { background: var(--primary-soft); color: var(--primary-dark); }
.btn-dlg:active { transform: scale(.97); }

/* 星星评级 */
.stars { font-size: 30px; letter-spacing: 4px; margin: 6px 0 2px; }
.stars .off { opacity: .25; filter: grayscale(1); }
.stars .on { display: inline-block; animation: starPop .4s backwards cubic-bezier(.2,.9,.3,1.6); }
.stars .on:nth-child(2) { animation-delay: .12s; }
.stars .on:nth-child(3) { animation-delay: .24s; }
@keyframes starPop { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: scale(1) rotate(0); } }

/* 通关清单 */
.learn-list { margin: 14px 0 0; text-align: left; max-height: 34vh; overflow-y: auto; }
.learn-item { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border-radius: 12px; background: var(--bg-a); margin-bottom: 6px; font-size: 14px; }
.learn-item .e { font-size: 20px; }
.learn-item .t { font-weight: 800; }
.learn-item .z { color: var(--text-sub); font-size: 12px; margin-left: auto; font-weight: 600; }

/* 加载态 */
.loading {
  position: fixed; inset: 0; background: rgba(255,255,255,.88); z-index: 200;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  font-size: 14px; color: var(--text-sub); font-weight: 700;
}
.loading.show { display: flex; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 30px); transform: translateX(-50%) translateY(10px);
  background: linear-gradient(120deg, var(--primary), var(--accent)); color: #fff;
  font-size: 14px; font-weight: 700; padding: 10px 20px; border-radius: 22px;
  opacity: 0; transition: .25s; z-index: 300; pointer-events: none; white-space: nowrap;
  box-shadow: 0 8px 18px rgba(150,110,190,.36);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
