/* 家庭战况版 — 活力课堂风 */
:root {
  --bg: #1a1a2e;
  --card: #16213e;
  --text: #eef1f7;
  --text2: #a0a8b8;
  --green: #00b894;
  --green-bg: #1a3a3a;
  --red: #e17055;
  --red-bg: #3a2a2a;
  --gold: #fdcb6e;
  --gold-light: #3a3520;
  --primary: #7c6cf6;
  --shadow: 0 2px 12px rgba(0,0,0,0.25);
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); height: 100%;
  -webkit-font-smoothing: antialiased;
}
.app {
  max-width: 430px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; background: var(--bg);
}
.app-header {
  padding: 14px 18px 10px; font-size: 20px; font-weight: 800;
  background: var(--card); border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.app-main {
  flex: 1; overflow-y: auto; padding: 12px 14px calc(80px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}
.screen { display: none; }
.screen.active { display: block; }

/* 底部 Tab 栏 */
.app-tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: 430px;
  display: flex; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(22,33,62,0.95); backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255,255,255,0.06); z-index: 20;
}
.tab {
  flex: 1; border: 0; background: transparent; color: #b2bec3;
  font-size: 12px; font-weight: 700; padding: 6px 0; border-radius: 12px;
  cursor: pointer; transition: all 0.15s;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tab .tab-ico { font-size: 22px; line-height: 1; }
.tab.active { color: var(--primary); background: rgba(108,92,231,0.1); }
.tab:active { transform: scale(0.94); }

/* 卡片 */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 10px;
  transition: transform 0.12s;
}
.card:active { transform: scale(0.97); }

/* 按钮 */
.btn {
  border: 0; font: inherit; font-weight: 800; cursor: pointer;
  border-radius: 14px; padding: 12px 20px; font-size: 15px;
  transition: transform 0.1s; min-height: 44px;
}
.btn:active { transform: scale(0.95); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.red { background: var(--red); color: #fff; }
.btn.ghost { background: rgba(0,0,0,0.05); color: var(--text); }

/* 空状态 */
.empty-state {
  text-align: center; padding: 50px 20px; color: var(--text2);
}
.empty-state .ico { font-size: 48px; margin-bottom: 10px; }
.empty-state p { font-size: 15px; line-height: 1.5; }

/* 弹层 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 50; display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s;
}
.modal-box {
  background: var(--card); border-radius: 22px; padding: 24px 28px 20px;
  width: 80%; max-width: 300px; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.modal-box .name { font-size: 20px; font-weight: 800; margin-bottom: 16px; color: var(--text); }
.modal-box .score-big { font-size: 42px; font-weight: 800; color: var(--primary); margin-bottom: 16px; }
.modal-box .score-big { font-size: 42px; font-weight: 800; color: var(--primary); margin-bottom: 16px; }
.modal-actions { display: flex; gap: 14px; justify-content: center; }
.modal-actions .btn { flex: 1; font-size: 22px; padding: 16px; border-radius: 16px; }
.modal-actions .btn.green { font-size: 28px; }
.modal-actions .btn.red { font-size: 28px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* 撒花 canvas */
.confetti-canvas {
  position: fixed; left: 0; top: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 100;
}

/* 英雄榜 */
.hero-card {
  background: linear-gradient(135deg, #fff8e1, #fff3cd);
  border: 2px solid var(--gold); border-radius: var(--radius);
  padding: 18px; margin-bottom: 10px; text-align: center;
  box-shadow: 0 4px 20px rgba(253,203,110,0.3);
  animation: glow 1.5s ease-in-out infinite alternate;
}
.hero-card .rank { font-size: 14px; color: #b8860b; font-weight: 700; }
.hero-card .name { font-size: 22px; font-weight: 800; margin: 4px 0; }
.hero-card .score { font-size: 32px; font-weight: 800; color: #e17055; }
@keyframes glow {
  from { box-shadow: 0 4px 20px rgba(253,203,110,0.3); }
  to { box-shadow: 0 4px 30px rgba(253,203,110,0.6); }
}

/* 排行榜行 */
.rank-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--card); border-radius: var(--radius);
  margin-bottom: 6px; box-shadow: var(--shadow);
}
.rank-row .pos { width: 28px; font-weight: 800; font-size: 16px; color: var(--text2); text-align: center; }
.rank-row .pos.gold { color: #f39c12; font-size: 20px; }
.rank-row .pos.silver { color: #95a5a6; font-size: 18px; }
.rank-row .pos.bronze { color: #d35400; font-size: 18px; }
.rank-row .name { flex: 1; font-weight: 700; font-size: 16px; }
.rank-row .score { font-weight: 800; font-size: 18px; color: var(--primary); }

/* 回顾页统计卡 */
.stat-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; background: var(--card); border-radius: var(--radius);
  margin-bottom: 6px; box-shadow: var(--shadow);
}
.stat-card .name { font-weight: 700; font-size: 16px; flex: 1; }
.stat-card .stats { display: flex; gap: 12px; font-size: 14px; }
.stat-card .stats .up { color: var(--green); font-weight: 700; }
.stat-card .stats .down { color: var(--red); font-weight: 700; }
.stat-card .stats .total { font-weight: 800; color: var(--primary); font-size: 16px; }

/* AI 小老师聊天 */
#aiTutor {
  display: flex; flex-direction: column; min-height: 400px;
}
#chatMessages {
  flex: 1; overflow-y: auto; padding: 4px 0 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-bubble {
  max-width: 85%; padding: 10px 14px; border-radius: 16px;
  font-size: 15px; line-height: 1.5; word-break: break-word;
  animation: fadeIn 0.2s ease;
}
.chat-bubble.me {
  align-self: flex-end;
  background: var(--primary); color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble.tutor {
  align-self: flex-start;
  background: var(--card); color: var(--text);
  border: 1px solid rgba(255,255,255,0.06);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* 兑换商店 */
.shop-header { text-align: center; padding: 16px 0 8px; }
.shop-total { font-size: 18px; font-weight: 700; color: var(--text2); }
.shop-total .big { font-size: 32px; color: var(--gold); }
.shop-items { display: flex; flex-direction: column; gap: 10px; }
.shop-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow); transition: transform 0.12s;
}
.shop-card.locked { opacity: 0.55; }
.shop-card:active { transform: scale(0.97); }
.shop-emoji { font-size: 32px; }
.shop-name { flex: 1; font-weight: 700; font-size: 17px; }
.shop-price { font-size: 20px; font-weight: 800; color: var(--gold); margin-right: 8px; }
.shop-card .btn { flex-shrink: 0; font-size: 14px; padding: 10px 16px; }
