/* ==========================================================================
   数学小岛：认识数字 / 听音选数字 / 比一比 / 形状 / 规律 / 解谜
   ========================================================================== */

/* ---------- 认识数字 ---------- */
.math-numbers { gap: clamp(10px, 2vh, 20px); }
.math-number-stage { flex: 1; display: grid; place-items: center; min-height: 0; }
.math-number-card {
  position: relative;
  width: min(660px, 92vw);
  display: grid;
  justify-items: center;
  gap: clamp(6px, 1.2vh, 12px);
  padding: clamp(18px, 2.6vw, 32px);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-l);
  transition: transform var(--fast) var(--ease);
}
.math-number-card:active { transform: scale(0.99); }
.math-number-big {
  font-family: "Nunito", sans-serif;
  font-size: clamp(110px, 22vh, 190px);
  font-weight: 900;
  line-height: 0.9;
  color: var(--unit-main);
  text-shadow: 0 8px 0 rgba(0, 0, 0, 0.05);
}
.math-number-word {
  min-width: 132px;
  padding: 6px 26px 8px;
  border-radius: 22px;
  background: var(--unit-soft);
  font-size: clamp(28px, 3.6vw, 42px);
  font-weight: 900;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.08;
}
.math-number-word small {
  display: block;
  margin-top: 3px;
  font-size: 0.46em;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.ten-frame {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: clamp(5px, 0.9vw, 9px);
  width: min(340px, 70%);
  padding: clamp(8px, 1.4vw, 14px);
  border-radius: 20px;
  background: var(--unit-soft);
}
.ten-frame i {
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 2px rgba(94, 78, 110, 0.08);
  transition: transform 0.25s var(--ease-out), background 0.25s;
}
.ten-frame i.is-on {
  background: var(--unit-main);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
  animation: pop-in 0.3s var(--ease-out) both;
}
.math-number-speaker {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--unit-soft);
  color: var(--unit-deep);
}
.math-number-speaker svg { width: 24px; height: 24px; }
.math-number-actions { display: flex; gap: 14px; flex: none; }
.math-number-actions .btn { flex: 1; }

/* ---------- 听音选数字 ---------- */
.math-listen-number { gap: clamp(10px, 1.8vh, 18px); }
.math-listen-orb {
  width: clamp(150px, 24vh, 220px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 34% 28%, #ffe08a, #f2b93f);
  box-shadow: 0 10px 0 #cf9a31, 0 22px 40px rgba(207, 154, 49, 0.3);
  color: #fff;
  transition: transform var(--fast);
}
.math-listen-orb:active { transform: translateY(5px); }
.math-listen-orb svg { width: 42%; height: 42%; }

/* ---------- 比一比 ---------- */
.math-compare-game { gap: clamp(10px, 1.8vh, 18px); }
.cmp-stage { flex: 1; display: grid; place-items: center; min-height: 0; }
.cmp-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: clamp(8px, 1.6vw, 18px);
  align-items: center;
  width: min(960px, 94vw);
}
.cmp-side {
  min-height: clamp(230px, 36vh, 330px);
  padding: clamp(12px, 2vw, 22px);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-l);
  display: grid;
  place-items: center;
  transition: transform var(--fast), background var(--fast);
}
.cmp-side:active { transform: scale(0.985); }
.cmp-side.is-right {
  background: linear-gradient(180deg, #e5f8ee, #cdf0dd);
  box-shadow: 0 0 0 5px rgba(110, 199, 159, 0.35), var(--shadow-l);
}
.cmp-side.is-wrong { background: #fdf1ee; animation: wobble 0.5s var(--ease); }
.cmp-vs-badge {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-s);
  font-family: "Nunito", sans-serif;
  font-size: 24px;
  font-weight: 900;
  color: var(--muted);
}
.cmp-visual {
  width: 100%;
  min-height: clamp(170px, 25vh, 230px);
  display: grid;
  place-items: center;
}
.cmp-length span {
  display: block;
  height: clamp(18px, 3vh, 30px);
  min-width: 18%;
  border-radius: 99px;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.1), 0 5px 10px rgba(94, 78, 110, 0.12);
}
.cmp-height { align-items: end; }
.cmp-height span {
  display: flex;
  flex-direction: column-reverse;
  justify-content: space-between;
  width: clamp(46px, 7vw, 70px);
  min-height: 20%;
  border-radius: 12px 12px 6px 6px;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35), 0 6px 12px rgba(94, 78, 110, 0.12);
}
.cmp-height i { display: block; height: 14%; border-top: 2px solid rgba(255, 255, 255, 0.4); }
.cmp-thickness { align-items: center; }
.cmp-thickness span {
  display: block;
  height: clamp(150px, 22vh, 210px);
  border-radius: 30px;
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.08), 0 8px 14px rgba(94, 78, 110, 0.12);
}
.cmp-flat { align-items: end; }
.cmp-flat span {
  display: block;
  width: clamp(100px, 16vw, 150px);
  border-radius: 8px;
  background-image: repeating-linear-gradient(180deg, rgba(255,255,255,.55) 0 3px, transparent 3px 9px);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.1), 0 8px 14px rgba(94, 78, 110, 0.12);
}
.cmp-weight img, .cmp-speed img {
  width: clamp(100px, 16vw, 150px);
  height: auto;
  filter: drop-shadow(0 10px 14px rgba(90, 74, 60, 0.2));
}
.cmp-weight img[src*="grape"] { width: clamp(52px, 8vw, 76px); }
.cmp-speed { position: relative; }
.cmp-speed-line {
  position: absolute;
  left: 12%;
  right: 38%;
  top: 58%;
  height: 4px;
  border-radius: 99px;
  background: rgba(94, 78, 110, 0.18);
  box-shadow: 0 10px 0 rgba(94, 78, 110, 0.12);
}

/* ---------- 形状 ---------- */
.math-shape-stage { flex: 1; display: grid; place-items: center; }
.shape-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 24px);
  width: min(760px, 92vw);
}
.shape-option {
  aspect-ratio: 1;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-m);
  display: grid;
  place-items: center;
  padding: 12%;
  transition: transform var(--fast), box-shadow var(--fast);
}
.shape-option:active { transform: scale(0.96); }
.shape-option.is-right { background: #e4f8ee; box-shadow: 0 0 0 5px rgba(110, 199, 159, 0.4), var(--shadow-m); }
.shape-option.is-wrong { background: #fdf1ee; animation: wobble 0.5s var(--ease); }
.shape-svg { width: 100%; height: 100%; }
.shape-option .shape-svg { width: 76%; height: 76%; }

/* ---------- 规律 ---------- */
.math-patterns { gap: clamp(10px, 1.8vh, 18px); }
.pattern-card {
  padding: clamp(16px, 2.4vw, 26px);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-l);
}
.pattern-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.4vw, 16px);
}
.pattern-num {
  display: grid;
  place-items: center;
  width: clamp(62px, 8vw, 96px);
  aspect-ratio: 1;
  border-radius: 22px;
  background: var(--unit-soft);
  font-family: "Nunito", sans-serif;
  font-size: clamp(30px, 4.2vw, 50px);
  font-weight: 900;
  color: var(--ink);
}
.pattern-dot {
  width: clamp(50px, 6.5vw, 76px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.08), 0 6px 10px rgba(94, 78, 110, 0.14);
}
.pattern-shape { width: clamp(56px, 7vw, 84px); aspect-ratio: 1; display: block; }
.pattern-q {
  display: grid;
  place-items: center;
  width: clamp(62px, 8vw, 96px);
  aspect-ratio: 1;
  border-radius: 22px;
  border: 3px dashed rgba(94, 78, 110, 0.25);
  color: var(--muted);
  font-family: "Nunito", sans-serif;
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 900;
}
.pattern-options { display: flex; gap: clamp(12px, 2vw, 22px); justify-content: center; align-items: center; }
.pattern-option {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: clamp(90px, 12vw, 130px);
  aspect-ratio: 1;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-m);
}
.pattern-option.is-right { background: #e4f8ee; box-shadow: 0 0 0 5px rgba(110, 199, 159, 0.4), var(--shadow-m); }
.pattern-option.is-wrong { background: #fdf1ee; animation: wobble 0.5s var(--ease); }
.pattern-option .pattern-shape { width: 70%; }

/* ---------- 逻辑解谜 ---------- */
.math-puzzle { gap: clamp(10px, 1.8vh, 18px); }
.puzzle-odd-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 1.4vw, 14px);
  width: min(440px, 76vw);
}
.puzzle-odd-cell {
  aspect-ratio: 1.2;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-m);
  display: grid;
  place-items: center;
  padding: 16%;
  cursor: pointer;
  transition: transform var(--fast), box-shadow var(--fast), background var(--fast);
}
.puzzle-odd-cell:active { transform: scale(0.97); }
.puzzle-odd-cell.is-right {
  background: #e4f8ee;
  box-shadow: 0 0 0 5px rgba(110, 199, 159, 0.4), var(--shadow-m);
}
.puzzle-odd-cell.is-wrong { background: #fdf1ee; animation: wobble 0.5s var(--ease); }
.puzzle-odd-cell .shape-svg { width: 68%; height: 68%; }
.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 1.4vw, 14px);
  width: min(420px, 80vw);
}
.puzzle-grid > * {
  aspect-ratio: 1;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-m);
  display: grid;
  place-items: center;
  padding: 16%;
}
.puzzle-grid .shape-svg { width: 70%; height: 70%; }
.puzzle-q {
  border: 3px dashed rgba(94, 78, 110, 0.28);
  background: var(--unit-soft) !important;
  box-shadow: none !important;
  color: var(--muted);
  font-family: "Nunito", sans-serif;
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 900;
}
.puzzle-options { display: flex; gap: clamp(12px, 2vw, 22px); justify-content: center; align-items: center; }
.puzzle-option {
  flex: 0 0 auto;
  width: clamp(84px, 11vw, 120px);
  aspect-ratio: 1;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-m);
  display: grid;
  place-items: center;
  padding: 14%;
}
.puzzle-option.is-right { background: #e4f8ee; box-shadow: 0 0 0 5px rgba(110, 199, 159, 0.4), var(--shadow-m); }
.puzzle-option.is-wrong { background: #fdf1ee; animation: wobble 0.5s var(--ease); }
.puzzle-option .shape-svg { width: 80%; height: 80%; }

/* 首页数学卡的小图形 */
.mini-shape { width: clamp(26px, 3.4vw, 38px); aspect-ratio: 1; display: inline-block; }
.mini-circle { border-radius: 50%; background: #ef8c7c; }
.mini-square { border-radius: 7px; background: #8fd8b6; }
.mini-triangle { background: #f5c45c; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.math-listen-mini { display: grid; place-items: center; width: clamp(30px, 4vw, 44px); color: var(--unit-main); }
.math-listen-mini svg { width: 100%; height: 100%; }
.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  width: clamp(36px, 4.6vw, 50px);
  aspect-ratio: 1;
}
.mini-grid i { border-radius: 4px; background: #b29be8; }
.mini-grid i.is-q {
  background: #fff;
  border: 2px dashed #b29be8;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 11px;
  font-weight: 900;
  color: #b29be8;
}

@media (orientation: portrait) {
  .math-number-card { width: 90vw; }
  .cmp-side { min-height: 210px; padding: 10px; }
  .cmp-visual { min-height: 150px; }
  .pattern-row { gap: 6px; }
  .pattern-num, .pattern-q { width: clamp(46px, 11vw, 64px); border-radius: 16px; font-size: 26px; }
  .pattern-dot { width: clamp(38px, 9vw, 52px); }
  .pattern-shape { width: clamp(44px, 10vw, 58px); }
  .pattern-option { width: clamp(74px, 18vw, 100px); }
  .puzzle-odd-grid { width: 78vw; }
  .puzzle-option .puzzle-shape { width: 52px; height: 52px; }
}

/* 拼图选项里的形状需要显式尺寸，否则内联 span 会塌成小点 */
.puzzle-option .puzzle-shape {
  display: block;
  width: 64px;
  height: 64px;
}
.puzzle-option .puzzle-shape .shape-svg {
  width: 100%;
  height: 100%;
}

@media (max-height: 800px) {
  .math-puzzle { gap: 8px; }
  .puzzle-odd-grid { width: min(376px, 66vw); gap: 8px; }
  .puzzle-grid { width: min(350px, 62vw); gap: 8px; }
  .puzzle-options { gap: 10px; }
  .puzzle-option { width: 96px; }
  .puzzle-option .puzzle-shape { width: 54px; height: 54px; }
}
