/* ========================================================
   乐学萌岛 (Kids Learn Island) - 样式表
   风格：圆润糖果风、低刺激暖色调、超大触控靶心、弹性动效
   ======================================================== */

:root {
  --primary-bg: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
  --panel-bg: rgba(255, 255, 255, 0.95);
  --text-main: #2d3748;
  --text-muted: #718096;
  --accent-color: #ff7675;
  --star-color: #f1c40f;
  --green-correct: #2ed573;
  --red-wrong: #ff6b6b;
  --shadow-candy: 0 10px 25px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.04);
  --shadow-btn: 0 6px 0 rgba(0, 0, 0, 0.15);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--primary-bg);
  min-height: 100vh;
  color: var(--text-main);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  overflow-x: hidden;
}

/* 主容器 */
.app-container {
  width: 100%;
  max-width: 860px;
  min-height: 640px;
  background: var(--panel-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-candy);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  border: 4px solid #ffffff;
}

/* 顶部状态栏 */
.top-navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: #ffffff;
  border-bottom: 2px solid #edf2f7;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  font-size: 1.25rem;
  font-weight: 800;
  color: #3b82f6;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  padding: 6px 14px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 1rem;
}

.badge-item.star {
  color: #d97706;
  background: #fffbeb;
  border-color: #fde68a;
}

.badge-item.combo {
  color: #e11d48;
  background: #fff1f2;
  border-color: #fecdd3;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.badge-item.combo.bump {
  transform: scale(1.25);
}

/* 通用按钮 */
.icon-btn {
  background: #f1f5f9;
  border: none;
  font-size: 1.2rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.06);
}

.icon-btn:hover {
  background: #e2e8f0;
  transform: translateY(-2px);
}

.icon-btn:active {
  transform: scale(0.92);
}

/* 通用隐藏类 */
.hidden {
  display: none !important;
}

/* 视图容器 */
.view {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

/* ================== 主页大厅视图 ================== */
.hero-banner {
  text-align: center;
  margin-bottom: 24px;
}

.hero-banner h1 {
  font-size: 2.2rem;
  font-weight: 900;
  color: #1e3a8a;
  letter-spacing: 1px;
}

.hero-banner p {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-top: 6px;
}

/* 关卡/学科网格 */
.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

.portal-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 20px;
  border: 3px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.portal-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-candy);
}

.portal-card:active {
  transform: scale(0.96);
}

.card-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.card-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.card-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  margin-top: 10px;
}

/* 各卡片主题色 */
.portal-card.add {
  border-color: #fed7aa;
  background: linear-gradient(180deg, #fffaf5 0%, #fff 100%);
}
.portal-card.add .card-title { color: #ea580c; }
.portal-card.add .card-tag { background: #ffedd5; color: #c2410c; }

.portal-card.sub {
  border-color: #bbf7d0;
  background: linear-gradient(180deg, #f0fdf4 0%, #fff 100%);
}
.portal-card.sub .card-title { color: #16a34a; }
.portal-card.sub .card-tag { background: #dcfce7; color: #15803d; }

.portal-card.mul {
  border-color: #ddd6fe;
  background: linear-gradient(180deg, #faf5ff 0%, #fff 100%);
}
.portal-card.mul .card-title { color: #7c3aed; }
.portal-card.mul .card-tag { background: #f3e8ff; color: #6d28d9; }

.portal-card.div {
  border-color: #bae6fd;
  background: linear-gradient(180deg, #f0f9ff 0%, #fff 100%);
}
.portal-card.div .card-title { color: #0284c7; }
.portal-card.div .card-tag { background: #e0f2fe; color: #0369a1; }

.portal-card.mix {
  border-color: #fbcfe8;
  background: linear-gradient(180deg, #fff1f2 0%, #fff 100%);
  grid-column: 1 / -1;
}
.portal-card.mix .card-title { color: #db2777; }
.portal-card.mix .card-tag { background: #fce7f3; color: #be185d; }

.portal-card.locked {
  opacity: 0.65;
  filter: grayscale(40%);
  cursor: not-allowed;
  border-style: dashed;
}

/* ================== 答题舞台视图 ================== */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.quiz-mode-title {
  font-size: 1.3rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 进度条与倒计时条 */
.timer-bar-container {
  width: 100%;
  height: 12px;
  background: #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 24px;
}

.timer-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #10b981, #f59e0b, #ef4444);
  background-size: 200% 100%;
  border-radius: 10px;
  transition: width 0.1s linear;
}

/* ================== 现实意义与启蒙动画舞台 ================== */
.enlighten-stage-wrapper {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.02);
}

.story-narration {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 2px dashed #e2e8f0;
  flex-wrap: wrap;
}

.story-tag {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
}

.story-text {
  font-size: 1.18rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.6;
  flex: 1;
}

/* 醒目放大的鲜艳数字胶囊 (专为儿童视觉强化) */
.hl-num {
  font-size: 1.5rem;
  font-weight: 900;
  color: #e11d48;
  background: #fff1f2;
  border: 2px solid #fecdd3;
  border-radius: 8px;
  padding: 1px 8px;
  margin: 0 4px;
  display: inline-block;
  vertical-align: middle;
  line-height: 1.15;
  box-shadow: 0 2px 6px rgba(225, 29, 72, 0.15);
  transform: translateY(-2px);
  letter-spacing: 0.5px;
}

.visual-stage {
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* 启蒙小贴士气泡 */
.enlighten-bubble {
  background: #fffbeb;
  border: 2px solid #fde68a;
  color: #92400e;
  padding: 8px 14px;
  border-radius: 14px;
  font-size: 0.92rem;
  font-weight: 700;
  margin-top: 10px;
  text-align: center;
  width: 100%;
  line-height: 1.5;
  position: relative;
  transition: all 0.3s ease;
}

.enlighten-bubble.glow {
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
}

.enlighten-bubble.pulse {
  animation: gentlePulse 0.5s ease 2;
  background: #fef08a;
  border-color: #eab308;
}

/* 跳过/下一题轻量按键 */
.btn-skip-anim {
  background: #f59e0b;
  color: #ffffff;
  border: none;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  margin-left: 8px;
  box-shadow: 0 2px 5px rgba(245, 158, 11, 0.3);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-skip-anim:hover {
  background: #d97706;
  transform: scale(1.06);
}

.btn-skip-anim:active {
  transform: scale(0.94);
}

/* 1. 加法舞台 */
.add-stage {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  gap: 12px;
  flex-wrap: wrap;
}

.pile {
  background: #ffffff;
  border: 2px solid #fed7aa;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  min-width: 150px;
  text-align: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.pile-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #ea580c;
  margin-bottom: 8px;
}

.item-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.tens-boxes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.tens-box {
  background: #ffedd5;
  border: 2px solid #f97316;
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 1.15rem;
  font-weight: 900;
  color: #c2410c;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  transition: transform 0.2s ease;
}

.tens-box.celebrate {
  animation: bounce 0.4s ease 2;
  background: #fed7aa;
}

.tens-box.unpacking {
  animation: shake 0.5s infinite;
  border-color: #ef4444;
  background: #fee2e2;
}

.tens-box.new-packed {
  background: #fef08a;
  border-color: #eab308;
  box-shadow: 0 0 12px rgba(234, 179, 8, 0.6);
  animation: popIn 0.3s ease, gentlePulse 0.5s infinite alternate;
}

.tens-box.new-packed .box-label {
  background: #ca8a04;
}

.merged-pile {
  background: #ffffff;
  border: 2px solid #22c55e;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  animation: popIn 0.3s ease;
  text-align: center;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.15);
  width: 100%;
  max-width: 480px;
}

.bounce-items {
  animation: bounce 0.4s ease 2;
}

.cookie-row.scanned-active {
  background: #fef9c3;
  border-radius: 10px;
  transform: scale(1.04);
  box-shadow: 0 2px 8px rgba(234, 179, 8, 0.25);
  transition: all 0.2s ease;
}

.baking-tray.tray-baked {
  background: #fef3c7;
  border-color: #f59e0b;
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.35);
  transition: all 0.3s ease;
}

.animal-plate-card.dancing {
  animation: bounce 0.4s infinite alternate;
  border-color: #22c55e;
  box-shadow: 0 4px 8px rgba(34, 197, 94, 0.2);
}

.box-label {
  font-size: 0.75rem;
  background: #ea580c;
  color: #fff;
  border-radius: 10px;
  padding: 0 5px;
}

.ones-items {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 1.25rem;
  max-width: 180px;
}

.unit-item {
  display: inline-block;
  animation: popIn 0.2s ease;
}

.op-symbol-stage {
  font-size: 2.2rem;
  font-weight: 900;
  color: #f97316;
}

/* 2. 减法舞台 */
.sub-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.pile-total {
  width: 100%;
  max-width: 500px;
  border-color: #bbf7d0;
}

.pile-total .pile-title {
  color: #16a34a;
}

.sub-action-indicator {
  margin-top: 10px;
  background: #fef2f2;
  border: 2px dashed #fca5a5;
  color: #b91c1c;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 700;
}

/* 3. 乘法舞台 */
.mul-stage {
  display: flex;
  justify-content: center;
  width: 100%;
}

.baking-tray {
  background: #fefce8;
  border: 3px dashed #ca8a04;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  overflow-x: auto;
  box-shadow: 0 4px 10px rgba(202, 138, 4, 0.08);
}

.tray-header {
  margin-bottom: 8px;
}

.badge-accent {
  background: #fef08a;
  color: #854d0e;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 3px 12px;
  border-radius: 12px;
  border: 1px solid #fde047;
}

.cookie-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cookie-row {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: popIn 0.25s ease forwards;
}

.row-label {
  font-size: 0.8rem;
  color: #a16207;
  font-weight: 800;
  width: 44px;
  text-align: right;
}

.cookie-item {
  font-size: 1.5rem;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: inline-block;
}

.cookie-item.baked {
  transform: scale(1.35) rotate(15deg);
  filter: drop-shadow(0 0 6px #f59e0b);
}

/* 4. 除法舞台 */
.div-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.picnic-table {
  background: #ffffff;
  border: 2px solid #bae6fd;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  width: 100%;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.table-title {
  font-size: 0.9rem;
  color: #0369a1;
  margin-bottom: 6px;
  font-weight: 700;
}

.strawberry-pool {
  font-size: 1.25rem;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.div-action-divider {
  font-size: 0.9rem;
  font-weight: 800;
  color: #0284c7;
  margin: 8px 0;
}

.animal-plates-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.animal-plate-card {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  min-width: 75px;
  text-align: center;
  flex: 1;
}

.animal-avatar {
  font-size: 0.95rem;
  font-weight: 800;
  color: #334155;
  margin-bottom: 4px;
}

.plate-dish {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 2px;
  font-size: 1.15rem;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.plate-dish.happy {
  background: #dcfce7;
  border-color: #22c55e;
  animation: bounce 0.4s ease;
}

.plate-placeholder {
  font-size: 0.75rem;
  color: #94a3b8;
}

.count-tag {
  font-size: 0.75rem;
  background: #16a34a;
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-weight: 800;
}

.empty-hint {
  font-size: 0.8rem;
  color: #94a3b8;
}

@keyframes gentlePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

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

/* 题目展示区 */
.question-stage {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 80px;
  margin: 10px 0;
  position: relative;
}

.question-formula {
  font-size: 3.2rem;
  font-weight: 900;
  color: #1e293b;
  letter-spacing: 2px;
  text-shadow: 2px 2px 0 #cbd5e1;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.streak-cheer {
  position: absolute;
  top: -10px;
  font-size: 1.1rem;
  font-weight: 800;
  color: #ff4757;
  background: #ffeaa7;
  padding: 4px 16px;
  border-radius: 20px;
  transform: rotate(-3deg);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  display: none;
}

/* 4选1 糖果选项区 */
.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-top: 24px;
  margin-bottom: 12px;
}

.option-btn {
  background: #ffffff;
  border: 3px solid #cbd5e1;
  border-bottom-width: 8px;
  border-radius: var(--radius-md);
  padding: 22px 10px;
  font-size: 2.4rem;
  font-weight: 900;
  color: #1e293b;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease, background 0.1s ease;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.option-btn:hover {
  transform: translateY(-2px);
  border-color: #94a3b8;
}

.option-btn:active {
  transform: translateY(4px);
  border-bottom-width: 4px;
}

/* 选项按键状态 */
.option-btn.btn-0 { border-color: #93c5fd; background: #eff6ff; color: #1d4ed8; }
.option-btn.btn-1 { border-color: #fde047; background: #fefce8; color: #a16207; }
.option-btn.btn-2 { border-color: #86efac; background: #f0fdf4; color: #15803d; }
.option-btn.btn-3 { border-color: #f9a8d4; background: #fdf2f8; color: #be185d; }

.option-btn.correct {
  background: #22c55e !important;
  color: #ffffff !important;
  border-color: #15803d !important;
  animation: jelly 0.4s ease;
}

.option-btn.wrong {
  background: #f87171 !important;
  color: #ffffff !important;
  border-color: #b91c1c !important;
  animation: shake 0.4s ease;
}

/* ================== 弹窗体系 (锦囊/结算) ================== */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 30px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  text-align: center;
  border: 4px solid #fed7aa;
  animation: modalScale 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hint-icon {
  font-size: 3.5rem;
  margin-bottom: 8px;
}

.hint-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: #ea580c;
  margin-bottom: 12px;
}

.hint-content {
  background: #fff7ed;
  border: 2px dashed #fdba74;
  border-radius: var(--radius-md);
  padding: 16px;
  color: #9a3412;
  font-size: 1.15rem;
  line-height: 1.6;
  white-space: pre-line;
  margin-bottom: 20px;
  text-align: left;
  font-weight: 600;
}

.btn-primary {
  background: #3b82f6;
  color: #ffffff;
  border: none;
  border-bottom: 5px solid #1d4ed8;
  border-radius: 30px;
  padding: 14px 32px;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.1s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:active {
  transform: translateY(3px);
  border-bottom-width: 2px;
}

/* ================== 结算面板 ================== */
.result-stars {
  font-size: 3.2rem;
  letter-spacing: 8px;
  margin: 16px 0;
  color: #f59e0b;
}

.result-stat-row {
  display: flex;
  justify-content: space-around;
  margin: 20px 0;
  background: #f8fafc;
  padding: 14px;
  border-radius: var(--radius-md);
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-item .val {
  font-size: 1.6rem;
  font-weight: 900;
  color: #1e293b;
}

.stat-item .lbl {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ================== 动画定义 ================== */
@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes modalScale {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

@keyframes jelly {
  0% { transform: scale(1, 1); }
  30% { transform: scale(1.15, 0.85); }
  40% { transform: scale(0.85, 1.15); }
  50% { transform: scale(1.05, 0.95); }
  65% { transform: scale(0.98, 1.02); }
  75% { transform: scale(1.02, 0.98); }
  100% { transform: scale(1, 1); }
}

/* 手机和平板横竖屏适配 */
@media (max-width: 640px) {
  body {
    padding: 8px;
  }
  .app-container {
    min-height: 94vh;
    border-radius: var(--radius-md);
  }
  .top-navbar {
    padding: 12px 16px;
  }
  .brand-badge {
    font-size: 1.05rem;
  }
  .hero-banner h1 {
    font-size: 1.6rem;
  }
  .portal-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .question-formula {
    font-size: 2.8rem;
  }
  .options-grid {
    gap: 12px;
  }
  .option-btn {
    font-size: 1.8rem;
    padding: 16px 8px;
  }
}
