/* ==========================================================
   豆豆数学岛 · 主样式
   设计原则:大、大、大;糖果色;圆润;全程温柔
   ========================================================== */

:root {
  /* 主色 */
  --primary: #2E9EE0;       /* 豆豆橙 */
  --primary-light: #A8DBF5;
  --secondary: #31C4B4;     /* 天空蓝 */
  --secondary-light: #B7EBE6;
  --accent: #ffd166;        /* 阳光黄 */
  --success: #4CC38A;       /* 嫩芽绿 */
  --danger: #ff8a8a;        /* 草莓红 */
  --purple: #9B8CF0;        /* 葡萄紫 */

  /* 背景 */
  --bg: #F0F8FD;            /* 奶油色背景 */
  --bg-card: #ffffff;
  --bg-soft: #DFF1FA;
  --bg-sky: linear-gradient(180deg, #C7E9FF 0%, #F0F8FD 60%);

  /* 文字 */
  --text: #1F3A4D;
  --text-soft: #6B879B;
  --text-light: #ffffff;

  /* 圆角与阴影 */
  --r-sm: 12px;
  --r-md: 20px;
  --r-lg: 32px;
  --shadow-sm: 0 4px 12px rgba(46, 158, 224, 0.15);
  --shadow-md: 0 8px 24px rgba(46, 158, 224, 0.18);
  --shadow-lg: 0 12px 40px rgba(46, 158, 224, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

/* ---------- 通用布局 ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg);
  padding-bottom: 96px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(240, 248, 253, 0.92);
  backdrop-filter: blur(8px);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px dashed #CFE8F7;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
}

.topbar .back {
  background: var(--bg-card);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.topbar .star-pill {
  background: linear-gradient(135deg, #ffd166, #ff9f43);
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 16px;
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.topbar .sound-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--bg-card);
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.topbar .sound-btn:active { transform: scale(0.9); }
.topbar .sound-btn.muted { opacity: 0.55; background: #E4EEF4; }

/* ---------- 大按钮 ---------- */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #6CBDEE);
  color: white;
  border-radius: 999px;
  padding: 16px 28px;
  font-size: 20px;
  font-weight: 800;
  box-shadow: var(--shadow-md);
  min-width: 140px;
  min-height: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .15s ease;
}

.btn-primary:active { transform: scale(0.96); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--primary);
  border-radius: 999px;
  padding: 14px 24px;
  font-size: 18px;
  font-weight: 700;
  border: 3px solid var(--primary-light);
  box-shadow: var(--shadow-sm);
  min-height: 56px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  font-size: 16px;
  padding: 8px 12px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 20px;
  margin: 12px 20px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 8px 0;
  color: var(--text);
}

/* ---------- 学习地图(首页) ---------- */
.hero {
  background: var(--bg-sky);
  padding: 28px 20px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-mascot {
  font-size: 64px;
  display: block;
  filter: drop-shadow(0 6px 16px rgba(46,158,224,.3));
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-8px); }
}

.hero h2 {
  font-size: 26px;
  margin: 8px 0 4px;
  font-weight: 900;
  color: var(--primary);
}

.hero p {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 15px;
}

.today-task {
  background: white;
  margin: 16px 20px;
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-md);
  display: flex;
  gap: 12px;
  align-items: center;
}

.today-task .badge {
  background: var(--accent);
  color: #1F4A66;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
}

.today-task .progress {
  flex: 1;
  background: #DFF1FA;
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
}

.today-task .progress > div {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width .6s ease;
}

.island-map {
  padding: 8px 12px 24px;
  position: relative;
}

.island {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 16px;
  margin: 14px 0;
  box-shadow: var(--shadow-sm);
  border: 3px solid transparent;
  transition: transform .15s ease;
  text-decoration: none;
  color: inherit;
  position: relative;
}

.island:active { transform: scale(0.97); }

.island.locked { opacity: 0.55; }
.island.locked::after {
  content: '🔒';
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 22px;
}

.island.completed { border-color: var(--success); }
.island.completed::after {
  content: '✅';
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 20px;
}

.island .emoji {
  font-size: 56px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.08));
}

.island .info { flex: 1; }
.island .info h3 {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 800;
}
.island .info p {
  margin: 0;
  font-size: 13px;
  color: var(--text-soft);
}

.island .progress-mini {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.island .star-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #D3EBF8;
}
.island .star-dot.on {
  background: linear-gradient(135deg, #ffd166, #ff9f43);
  box-shadow: 0 2px 6px rgba(255,159,67,.5);
}

/* ---------- 单元主页 ---------- */
.unit-hero {
  background: linear-gradient(135deg, #CFE8F7, #F0F8FD);
  padding: 24px 20px;
  text-align: center;
}
.unit-hero .emoji { font-size: 72px; display: block; }
.unit-hero h2 {
  margin: 8px 0 4px;
  font-size: 24px;
  font-weight: 900;
  color: var(--primary);
}
.unit-hero p { margin: 0; color: var(--text-soft); font-size: 14px; }

.lesson-list { padding: 8px 16px 24px; }
.lesson-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: white;
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin: 10px 0;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
}
.lesson-item .num {
  background: var(--primary);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 18px;
}
.lesson-item .body { flex: 1; }
.lesson-item .body h4 {
  margin: 0 0 2px 0;
  font-size: 17px;
  font-weight: 800;
}
.lesson-item .body p {
  margin: 0;
  font-size: 13px;
  color: var(--text-soft);
}
.lesson-item .status {
  font-size: 24px;
}
.lesson-item.done { border-left: 6px solid var(--success); }
.lesson-item.todo { border-left: 6px solid #D3EBF8; }

/* ---------- 微课页 ---------- */
.lesson-stage {
  padding: 24px 20px;
  text-align: center;
}
.scene {
  display: block;
  max-width: 100%;
  margin: 14px auto 20px;
  padding: 0 4px;
  font-size: 64px;
  line-height: 1.35;
  letter-spacing: 3px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  animation: pop .6s ease;
}
@keyframes pop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.lesson-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 12px 0 24px;
  min-height: 70px;
  line-height: 1.5;
}
.tts-btn {
  background: var(--secondary);
  color: white;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 15px;
  margin: 4px;
}
.nav-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  flex-wrap: wrap;
}

/* ---------- 数字气泡 ---------- */
.number-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 16px 0;
}
.number-bubble {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--secondary), #7FD8CE);
  color: white;
  font-size: 28px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  animation: float 2.4s ease-in-out infinite;
}
.number-bubble:nth-child(2n)  { animation-delay: .3s; }
.number-bubble:nth-child(3n)  { animation-delay: .6s; }
.number-bubble:nth-child(4n)  { animation-delay: .9s; background: linear-gradient(135deg, var(--purple), #d3b9ff); }
.number-bubble:nth-child(5n)  { animation-delay: 1.2s; background: linear-gradient(135deg, var(--accent), #FFD980); }
@keyframes float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-6px); }
}

/* ---------- 计数器 ---------- */
.counter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
}
.counter .objects {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  min-height: 90px;
}
.counter .objects span { font-size: 36px; }
.counter .count-display {
  font-size: 64px;
  font-weight: 900;
  color: var(--primary);
  background: white;
  border-radius: 24px;
  padding: 8px 24px;
  margin: 4px;
  box-shadow: var(--shadow-sm);
}
.counter .ctrl {
  display: flex;
  gap: 12px;
}
.counter .ctrl button {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: white;
  font-size: 36px;
  font-weight: 900;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.counter .ctrl button:active { transform: scale(0.92); }
.counter .ctrl button:disabled { opacity: .4; }

/* ---------- 答题卡 ---------- */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 16px 0 24px;
}
.choice {
  background: white;
  border: 3px solid #D3EBF8;
  border-radius: var(--r-md);
  padding: 22px;
  font-size: 32px;
  font-weight: 900;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.choice:active { transform: scale(0.96); }
.choice.correct {
  background: var(--success);
  color: white;
  border-color: var(--success);
  animation: shake .4s ease;
}
.choice.wrong {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  animation: shake .4s ease;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-6px); }
  75%     { transform: translateX(6px); }
}

.score-banner {
  text-align: center;
  font-size: 28px;
  font-weight: 900;
  margin: 12px 0;
  color: var(--primary);
}

/* ---------- 拖拽/配对 ---------- */
.pair-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
  padding: 12px;
  background: white;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.pair-left {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  font-size: 28px;
}
.pair-symbol {
  font-size: 24px;
  font-weight: 900;
  color: var(--text-soft);
}
.pair-right {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  font-size: 28px;
}
.pair-cell {
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 4px 8px;
  min-width: 36px;
  text-align: center;
}

/* ---------- 家长中心 ---------- */
.parent-hero {
  background: linear-gradient(135deg, #B7EBE6, #C7E9FF);
  padding: 28px 20px;
  text-align: center;
}
.parent-hero h2 { margin: 0 0 4px; font-size: 22px; color: #2c5777; }
.parent-hero p  { margin: 0; color: #2c5777; opacity: 0.85; font-size: 14px; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px 20px;
}
.metric {
  background: white;
  border-radius: var(--r-md);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.metric .v { font-size: 30px; font-weight: 900; color: var(--primary); }
.metric .l { font-size: 13px; color: var(--text-soft); margin-top: 4px; }

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  font-size: 14px;
}
.bar .name { width: 100px; color: var(--text-soft); }
.bar .track {
  flex: 1;
  height: 12px;
  background: #DFF1FA;
  border-radius: 999px;
  overflow: hidden;
}
.bar .track > div {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  height: 100%;
  border-radius: 999px;
}
.bar .val { width: 44px; text-align: right; font-weight: 800; color: var(--primary); }

/* ---------- 勋章 ---------- */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px 20px;
}
.badge-card {
  background: white;
  border-radius: var(--r-md);
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.badge-card.locked { filter: grayscale(1) opacity(.5); }
.badge-card .icon { font-size: 42px; }
.badge-card .name { font-size: 13px; font-weight: 700; margin-top: 6px; }
.badge-card .desc { font-size: 11px; color: var(--text-soft); margin-top: 2px; }
.badge-card.locked .name::after {
  content: '🔒';
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

/* ---------- 吐司/弹幕 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  background: var(--success);
  color: white;
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 16px;
  box-shadow: var(--shadow-md);
  z-index: 100;
  animation: toast-up 2.2s ease forwards;
  pointer-events: none;
}
@keyframes toast-up {
  0%   { opacity: 0; transform: translate(-50%, 30px); }
  10%  { opacity: 1; transform: translate(-50%, 0); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}

/* ---------- 模态 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: white;
  border-radius: var(--r-lg);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  animation: pop .4s ease;
}
.modal h3 { margin: 0 0 8px; font-size: 22px; }
.modal p  { color: var(--text-soft); margin: 0 0 16px; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.tag.learning { background: #CFE8F7; color: #1F6FA8; }
.tag.ready    { background: #DFF3F6; color: #2a8a5a; }
.tag.locked   { background: #E3ECF2; color: #6B879B; }

/* ---------- 底部 Tab ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: white;
  border-top: 2px solid #DCEBF6;
  display: flex;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  z-index: 40;
  max-width: 480px;
  margin: 0 auto;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}
.tabbar a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  padding: 4px;
}
.tabbar a .ico { font-size: 26px; display: block; }
.tabbar a.active { color: var(--primary); }

/* ---------- 倒计时/计时器 ---------- */
.timer-bar {
  background: linear-gradient(90deg, var(--success), var(--accent));
  height: 6px;
  position: fixed;
  top: 0; left: 0;
  z-index: 60;
  transition: width .4s linear;
}

/* ---------- 完成庆祝 ---------- */
.celebrate {
  text-align: center;
  padding: 20px;
}
.celebrate .big {
  font-size: 96px;
  margin: 12px 0;
  animation: bounce 1s ease-in-out infinite;
}
.celebrate h3 { font-size: 26px; color: var(--primary); margin: 0 0 8px; }
.celebrate p  { color: var(--text-soft); margin: 0 0 18px; }

/* ---------- 错题本 ---------- */
.error-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #F4FAFD;
  border: 2px dashed var(--primary-light);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin: 8px 0;
}
.error-row .q { font-weight: 800; color: var(--text); }
.error-row .a { color: var(--text-soft); font-size: 14px; }
.error-row .ans { margin-left: auto; color: var(--danger); font-weight: 800; }
.error-row .ok  { margin-left: auto; color: var(--success); font-weight: 800; }

@media (min-width: 481px) {
  body { background: #F0F8FD; }
  .app { box-shadow: 0 0 40px rgba(0,0,0,.04); }
}

/* ---------- 答题帮助:答错的选项被排除后置灰(只作用于被排除项,不影响"找图形"类正确的绿底项) ---------- */
.choice.choice-off {
  opacity: .45;
  cursor: default;
  filter: grayscale(.4);
  transform: none;
}

/* ===== 年级大字横幅（2026-09-18 新增）=====
   目的：一进来就先看到「这是二年级上册」，与一上（豆豆橙）一眼分开。
   ⚠ 复用主题变量 --primary / --secondary，换肤时自动跟着走，不要写死颜色。 */
.grade-banner {
  margin: 14px 16px 0;
  padding: 14px 20px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 10px 26px rgba(46, 158, 224, .30);
}
.grade-banner .gb-num {
  flex: none;
  font-size: clamp(34px, 11.5vw, 44px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 3px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .10);
}
.grade-banner .gb-right {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-left: 2px solid rgba(255, 255, 255, .45);
  padding-left: 14px;
}
.grade-banner .gb-term {
  font-size: clamp(19px, 6.4vw, 24px);
  font-weight: 900;
  letter-spacing: 3px;
  line-height: 1;
}
.grade-banner .gb-ed {
  font-size: 12.5px;
  font-weight: 700;
  opacity: .94;
  line-height: 1.35;
}
