/* 习惯岛 · 多邻国风格设计系统 */
:root {
  --green: #58cc02;
  --green-dark: #46a302;
  --green-light: #f2ffe9;
  --blue: #1cb0f6;
  --blue-dark: #1899d6;
  --blue-light: #e7f7ff;
  --yellow: #ffc800;
  --yellow-dark: #e0a800;
  --red: #ff4b4b;
  --red-dark: #d33131;
  --purple: #ce82ff;
  --purple-dark: #a568cc;
  --white: #fff;
  --bg: #f7f7f7;
  --text: #3c3c3c;
  --gray: #afafaf;
  --line: #e5e5e5;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  font-family: 'Nunito', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; }

/* ---------- 3D 大按钮 ---------- */
.btn-3d {
  border: none;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  padding: 14px 24px;
  border-bottom: 4px solid var(--blue-dark);
  cursor: pointer;
  transition: transform .05s, border-bottom-width .05s;
}
.btn-3d:active { transform: translateY(4px); border-bottom-width: 0; }
.btn-3d.green { background: var(--green); border-bottom-color: var(--green-dark); }
.btn-3d:disabled { background: var(--gray); border-bottom-color: #979797; cursor: default; }

/* ---------- 卡片 ---------- */
.card {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card.done { border-color: var(--green); background: var(--green-light); }

/* ---------- 页面 ---------- */
.screen { display: none; padding: 16px 16px 96px; min-height: 100vh; }
.screen.active { display: block; }
.section-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--gray);
  letter-spacing: 2px;
  margin: 20px 0 10px;
}

/* ---------- 选孩子页 ---------- */
#screen-select { text-align: center; padding-top: 12vh; }
#screen-select h1 {
  font-size: 30px;
  font-weight: 900;
  margin-bottom: 8px;
}
#screen-select .subtitle { color: var(--gray); font-weight: 700; margin-bottom: 36px; }
.avatar-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 28px; }
.avatar-btn {
  width: 120px;
  border: none;
  background: none;
  cursor: pointer;
}
.avatar-circle {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--line);
  font-size: 58px;
  line-height: 104px;
  margin-bottom: 10px;
  transition: transform .1s, border-color .1s, box-shadow .1s;
}
.avatar-btn:active .avatar-circle { transform: scale(.94); }
.avatar-btn.selected .avatar-circle {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(88, 204, 2, .25);
}
.avatar-btn .avatar-name { font-weight: 800; font-size: 16px; color: var(--text); }
.avatar-btn.selected .avatar-name { color: var(--green-dark); }

/* ---------- 打卡页头部 ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.back-btn {
  width: 40px; height: 40px;
  border: none; border-radius: 12px;
  background: #fff; border: 2px solid var(--line);
  font-size: 18px; font-weight: 900; color: var(--gray);
  cursor: pointer;
}
.child-tag {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  font-size: 18px; font-weight: 900;
}
.child-tag .mini-avatar { font-size: 26px; }
.points-pill {
  display: flex; align-items: center; gap: 6px;
  background: #fff7df;
  border: 2px solid #ffe6a3;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 900;
  font-size: 16px;
  color: #b8860b;
}
.points-pill.pop { animation: pop .3s ease; }

/* ---------- 习惯卡片 ---------- */
.habit-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  cursor: pointer;
  transition: transform .05s;
}
.habit-card:active { transform: scale(.98); }
.habit-icon {
  flex: none;
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--blue-light);
  font-size: 30px;
  line-height: 56px;
  text-align: center;
}
.habit-card.done .habit-icon { background: var(--green-light); }
.habit-body { flex: 1; min-width: 0; }
.habit-name { font-size: 18px; font-weight: 900; display: block; }
.habit-meta { font-size: 14px; font-weight: 800; color: var(--gray); margin-top: 4px; display: block; }
.habit-state {
  flex: none;
  font-size: 14px;
  font-weight: 900;
  color: #fff;
  background: var(--blue);
  border-radius: 999px;
  padding: 7px 14px 6px;
  border-bottom: 3px solid var(--blue-dark);
  white-space: nowrap;
}
.habit-card.done .habit-state { background: var(--green); border-bottom-color: var(--green-dark); }

/* 连胜火焰 */
.streak-flame { color: var(--yellow); font-weight: 900; }
.streak-flame.at-risk {
  color: var(--red);
  display: inline-block;
  animation: pulse 1s infinite;
  /* 火焰是 emoji，不吃 color，用红色光晕强调危险 */
  filter: drop-shadow(0 0 4px var(--red)) drop-shadow(0 0 4px var(--red));
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: .65; }
}

@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.15); } 100% { transform: scale(1); } }
.pop { animation: pop .3s ease; }

/* ---------- 我的页 ---------- */
.me-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.me-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: #fff; border: 3px solid var(--green);
  font-size: 34px; line-height: 58px; text-align: center;
}
.me-name { font-size: 22px; font-weight: 900; }
.me-sub { font-size: 14px; font-weight: 700; color: var(--gray); margin-top: 2px; }

.stat-row { display: flex; gap: 12px; margin-bottom: 12px; }
.stat-card {
  flex: 1;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.stat-card .stat-emoji { font-size: 26px; }
.stat-card .stat-value { font-size: 20px; font-weight: 900; margin-top: 4px; }
.stat-card .stat-label { font-size: 12px; font-weight: 800; color: var(--gray); margin-top: 2px; }

.badge-wall {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.badge {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 4px 8px;
  text-align: center;
}
.badge .badge-emoji { font-size: 26px; }
.badge .badge-name {
  font-size: 11px;
  font-weight: 800;
  margin-top: 4px;
  line-height: 1.25;
  word-break: break-all;
}
.badge.earned { border-color: var(--yellow); background: #fffaf0; }
.badge.locked { opacity: .38; filter: grayscale(1); }

.treasure-card { display: flex; align-items: center; gap: 12px; }
.treasure-card .treasure-emoji { font-size: 34px; }
.treasure-card .treasure-text { font-size: 14px; font-weight: 800; }
.treasure-card .treasure-text b { font-size: 15px; }

/* ---------- 底部标签栏 ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-top: 2px solid var(--line);
  display: flex;
  z-index: 5;
}
.tabbar.hidden { display: none; }
.tabbar button {
  flex: 1;
  padding: 10px 0 12px;
  font-size: 14px;
  font-weight: 800;
  color: var(--gray);
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tabbar button .tab-emoji { font-size: 22px; }
.tabbar button.active { color: var(--blue); }

/* ---------- 徽章庆祝层 ---------- */
#celebrate {
  position: fixed;
  inset: 0;
  background: rgba(88, 204, 2, .25);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 10;
  overflow: hidden;
}
#celebrate.show { display: flex; }
.celebrate-card {
  background: #fff;
  border: 3px solid var(--yellow);
  border-radius: 24px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: 0 8px 0 rgba(0, 0, 0, .12);
  animation: pop .4s ease;
  max-width: 82%;
}
.celebrate-card .trophy { font-size: 64px; }
.celebrate-card h2 { font-size: 24px; font-weight: 900; color: var(--green-dark); margin-top: 8px; }
.celebrate-card .new-badge { font-size: 17px; font-weight: 800; margin-top: 10px; line-height: 1.5; }

.confetti {
  position: absolute;
  top: -24px;
  width: 10px;
  height: 18px;
  border-radius: 3px;
  opacity: .95;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(115vh) rotate(720deg); }
}

/* ---------- 轻提示 ---------- */
#toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--text);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  padding: 12px 22px;
  border-radius: 999px;
  z-index: 20;
  transition: transform .25s;
  max-width: 86%;
  text-align: center;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.good { background: var(--green-dark); }

/* ---------- 开发模式日期控制（默认隐藏，dev-server 下显示） ---------- */
.dev-pill {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: #2b2b2b;
  border-radius: 999px;
  padding: 6px 8px 6px 14px;
  z-index: 6;
  box-shadow: 0 3px 0 rgba(0,0,0,.2);
  font-size: 13px;
}
.dev-pill.hidden { display: none; }
.dev-date-label { color: #ffd84d; font-weight: 800; white-space: nowrap; }
.dev-btn {
  border: none;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  padding: 6px 12px;
  border-bottom: 3px solid var(--green-dark);
  cursor: pointer;
  transition: transform .05s, border-bottom-width .05s;
}
.dev-btn:active { transform: translateY(3px); border-bottom-width: 0; }
.dev-btn.ghost { background: #555; border-bottom-color: #333; }
