/* ============================================================
   Math Adventures — learn/assets/css/math.css
   Used on: math.php (landing) + math-lesson.php (game page)
   ============================================================ */

/* ── Breadcrumb ──────────────────────────────────────────── */
.math-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem .5rem;
  font-size: .8rem;
  color: #6b7280;
  padding: .6rem 0;
}
.math-breadcrumb a {
  color: #6b7280;
  text-decoration: none;
}
.math-breadcrumb a:hover { color: #f59e0b; }
.math-breadcrumb span[aria-current] { color: #1f2937; font-weight: 600; }

/* ── Hero ────────────────────────────────────────────────── */
.math-hero {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 60%, #fde68a 100%);
  padding: 2.5rem 0 2rem;
  text-align: center;
  border-bottom: 1px solid #fde68a;
}
.math-hero-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: .5rem;
}
.math-hero-title {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  color: #1f2937;
  margin: 0 0 .5rem;
}
.math-hero-sub {
  font-size: 1rem;
  color: #6b7280;
  margin: 0 auto .5rem;
  max-width: 520px;
}
.math-hero-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.math-hero-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
}
.math-hero-stat-val {
  font-size: 1.6rem;
  font-weight: 800;
  color: #f59e0b;
  line-height: 1;
}
.math-hero-stat-lbl {
  font-size: .75rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Age badge ───────────────────────────────────────────── */
.math-age-badge {
  display: inline-block;
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: .75rem;
  font-weight: 700;
  padding: .25rem .75rem;
  border-radius: 2rem;
  margin-top: .25rem;
}

/* ── Category nav ────────────────────────────────────────── */
.math-cats {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .25rem 0;
}
.math-cat-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .4rem .85rem;
  border-radius: 2rem;
  font-size: .82rem;
  font-weight: 600;
  color: #374151;
  background: #f3f4f6;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.math-cat-btn:hover {
  background: #e5e7eb;
  color: #111827;
}
.math-cat-btn.active {
  background: var(--cat-active, #f59e0b);
  color: #fff;
  border-color: transparent;
}
.math-cat-count {
  background: rgba(255,255,255,.35);
  color: inherit;
  font-size: .7rem;
  font-weight: 700;
  padding: .05rem .4rem;
  border-radius: 1rem;
}
.math-cat-btn:not(.active) .math-cat-count {
  background: #e5e7eb;
  color: #6b7280;
}

.math-category-sections {
  display: grid;
  gap: 2rem;
}
.math-category-section {
  border-top: 4px solid var(--section-accent, #f59e0b);
  border-radius: 1.1rem;
  background: rgba(255,255,255,.58);
  padding: 1rem;
}
.math-category-section-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .85rem;
  margin-bottom: 1rem;
}
.math-category-section-icon {
  width: 3rem;
  height: 3rem;
  border-radius: .9rem;
  background: var(--section-accent, #f59e0b);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 8px 20px rgba(31,41,55,.12);
}
.math-category-section-head h2 {
  margin: 0;
  color: #1f2937;
  font-size: clamp(1.15rem, 3vw, 1.55rem);
  font-weight: 900;
}
.math-category-section-head p {
  margin: .18rem 0 0;
  color: #6b7280;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.35;
}
.math-category-section-link {
  border: 1.5px solid color-mix(in srgb, var(--section-accent, #f59e0b) 35%, #fff 65%);
  border-radius: 999px;
  background: #fff;
  color: var(--section-accent, #f59e0b);
  font-size: .8rem;
  font-weight: 900;
  padding: .42rem .78rem;
  text-decoration: none;
  white-space: nowrap;
}
.math-category-section-link:hover {
  background: #fffbeb;
  color: var(--section-accent, #f59e0b);
  text-decoration: none;
}

/* ── Lesson grid ─────────────────────────────────────────── */
.math-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

/* ── Lesson card ─────────────────────────────────────────── */
.math-card {
  position: relative;
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 1rem;
  padding: 1.1rem 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  border-top: 3px solid var(--card-accent, #f59e0b);
}
.math-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  border-color: var(--card-accent, #f59e0b);
}
.math-card-done {
  position: absolute;
  top: .65rem;
  right: .75rem;
  background: #10b981;
  color: #fff;
  font-size: .7rem;
  font-weight: 800;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.math-card-top {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.math-card-icon { font-size: 1.5rem; line-height: 1; }
.math-card-cat {
  font-size: .72rem;
  font-weight: 700;
  color: var(--card-accent, #f59e0b);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.math-card-title {
  font-size: .95rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
  line-height: 1.3;
}
.math-card-desc {
  font-size: .8rem;
  color: #6b7280;
  line-height: 1.4;
  margin: 0;
  flex: 1;
}
.math-card-badges {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
}
.math-badge {
  font-size: .68rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 1rem;
  white-space: nowrap;
}
.math-badge--type { background: #f3f4f6; color: #374151; }
.math-badge--diff { background: #e0f2fe; color: #0369a1; }
.math-badge--medium { background: #fef9c3; color: #92400e; }
.math-badge--hard { background: #fee2e2; color: #991b1b; }

.math-card-score {
  font-size: .75rem;
  color: #10b981;
  font-weight: 700;
}
.math-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: .5rem;
  border-top: 1px solid #f3f4f6;
}
.math-card-pts {
  font-size: .75rem;
  color: #f59e0b;
  font-weight: 700;
}
.math-card-play {
  display: inline-block;
  background: var(--card-accent, #f59e0b);
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  padding: .3rem .85rem;
  border-radius: 2rem;
  text-decoration: none;
  transition: opacity .15s;
}
.math-card-play:hover { opacity: .85; }

/* ── Empty state ─────────────────────────────────────────── */
.math-empty {
  text-align: center;
  padding: 4rem 1rem;
  color: #9ca3af;
}
.math-empty-icon { font-size: 3rem; display: block; margin-bottom: .75rem; }

/* ── Lesson page layout ──────────────────────────────────── */
.math-lesson-page {
  --cat-color: #f59e0b;
  padding-bottom: 3rem;
}

/* ── Lesson header ───────────────────────────────────────── */
.math-lesson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0 .75rem;
  flex-wrap: wrap;
}
.math-lesson-header-left {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.math-lesson-cat-icon { font-size: 2rem; line-height: 1; }
.math-lesson-cat-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--cat-color);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.math-lesson-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #1f2937;
  margin: 0;
}
.math-lesson-balance {
  font-size: .82rem;
  font-weight: 700;
  color: #f59e0b;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: .3rem .75rem;
  border-radius: 2rem;
  white-space: nowrap;
}

/* ── Intro / concept panel ───────────────────────────────── */
.math-lesson-info {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.math-lesson-intro {
  font-size: .95rem;
  color: #374151;
  line-height: 1.6;
  margin: 0 0 1rem;
}
.math-concept {
  font-size: .9rem;
  color: #374151;
  line-height: 1.7;
}
.math-concept p { margin: 0 0 .6rem; }
.math-concept p:last-child { margin-bottom: 0; }
.math-concept strong { color: #1f2937; }

.math-start-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-top: 1.25rem;
  background: var(--cat-color, #f59e0b);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  padding: .65rem 1.75rem;
  border-radius: 2rem;
  border: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.math-start-btn:hover { opacity: .88; transform: translateY(-1px); }

/* ── Game wrap ───────────────────────────────────────────── */
.math-game-wrap {
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 1.25rem;
  padding: 1.25rem;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* ── Progress row ────────────────────────────────────────── */
.math-progress-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .85rem;
  flex-wrap: wrap;
}
.math-progress-bar-wrap {
  flex: 1 1 12rem;
  background: #f3f4f6;
  border-radius: 2rem;
  height: .55rem;
  overflow: hidden;
}
.math-progress-fill {
  height: 100%;
  background: var(--cat-color, #f59e0b);
  border-radius: 2rem;
  transition: width .35s ease;
}
.math-progress-text {
  font-size: .75rem;
  font-weight: 700;
  color: #6b7280;
  white-space: nowrap;
}
.math-timer {
  font-size: .8rem;
  font-weight: 800;
  color: #ef4444;
  background: #fee2e2;
  padding: .2rem .6rem;
  border-radius: .5rem;
  white-space: nowrap;
  min-width: 3.2rem;
  text-align: center;
}
.math-timer.urgent { animation: timerPulse .5s infinite alternate; }
@keyframes timerPulse {
  from { background: #fee2e2; }
  to   { background: #fca5a5; }
}

/* ── Scorebar ────────────────────────────────────────────── */
.math-scorebar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: .85rem;
  font-size: .85rem;
  flex-wrap: wrap;
}
.math-score-label { font-weight: 700; color: #1f2937; }
.math-streak { font-weight: 700; color: #ef4444; }

/* ── Game area ───────────────────────────────────────────── */
.math-game-area {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: .85rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}
.math-loading {
  font-size: 1.25rem;
  color: #9ca3af;
  padding: 3rem 1rem;
  margin: auto;
}

/* ── Feedback overlay ────────────────────────────────────── */
.math-feedback {
  min-height: 1.6rem;
  font-size: .9rem;
  font-weight: 700;
  text-align: center;
  border-radius: .5rem;
  padding: .35rem .75rem;
  margin-top: .5rem;
  transition: opacity .2s;
}
.math-feedback--ok  { color: #059669; background: #ecfdf5; }
.math-feedback--err { color: #dc2626; background: #fef2f2; }

/* ── Question card ───────────────────────────────────────── */
.math-q-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}
.math-q-text {
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  font-weight: 800;
  color: #1f2937;
  text-align: center;
  line-height: 1.3;
  padding: .5rem 0;
}
.math-q-img {
  max-width: 200px;
  border-radius: .5rem;
  margin: 0 auto;
  display: block;
}
.math-q-hint {
  font-size: .78rem;
  color: #6b7280;
  text-align: center;
  font-style: italic;
}

/* ── Multiple choice ─────────────────────────────────────── */
.math-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: .6rem;
  width: 100%;
}
.math-choice-btn {
  padding: .75rem .5rem;
  min-height: 3.25rem;
  border-radius: .75rem;
  border: 2px solid #e5e7eb;
  background: #f9fafb;
  font-size: 1rem;
  font-weight: 700;
  color: #1f2937;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .08s;
  text-align: center;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.math-choice-btn:hover:not(:disabled) {
  background: #fffbeb;
  border-color: var(--cat-color, #f59e0b);
}
.math-choice-btn:active:not(:disabled) { transform: scale(.97); }
.math-choice-btn.correct {
  background: #dcfce7;
  border-color: #16a34a;
  color: #15803d;
}
.math-choice-btn.wrong {
  background: #fee2e2;
  border-color: #dc2626;
  color: #b91c1c;
}
.math-choice-btn:disabled { cursor: default; }

/* ── Listen (audio) mode ─────────────────────────────────── */
.math-listen-card {
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .85rem;
  padding: 1.25rem 0 .75rem;
}
.math-listen-label {
  font-size: .88rem;
  color: #374151;
  font-weight: 700;
  letter-spacing: .01em;
}
.math-listen-sublabel {
  font-size: .8rem;
  color: #9ca3af;
  font-weight: 500;
}
.math-big-listen-btn {
  background: var(--cat-color, #f59e0b);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 7rem;
  height: 7rem;
  font-size: 3rem;
  line-height: 1;
  cursor: pointer;
  transition: opacity .15s, transform .12s, box-shadow .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
  flex-shrink: 0;
}
.math-big-listen-btn:hover  { opacity: .9; transform: scale(1.07); box-shadow: 0 8px 28px rgba(0,0,0,.22); }
.math-big-listen-btn:active { transform: scale(.94); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.math-listen-btn {
  background: none;
  border: 2px solid var(--cat-color, #f59e0b);
  color: var(--cat-color, #f59e0b);
  padding: .4rem 1rem;
  border-radius: 2rem;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.math-listen-btn:hover {
  background: var(--cat-color, #f59e0b);
  color: #fff;
}

/* ── Flashcard ───────────────────────────────────────────── */
.math-flashcard {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  perspective: 1000px;
  cursor: pointer;
}
.math-flashcard-inner {
  position: relative;
  width: 100%;
  height: 320px;
  transition: transform .45s;
  transform-style: preserve-3d;
}
.math-flashcard.flipped .math-flashcard-inner { transform: rotateY(180deg); }
.math-flashcard-front,
.math-flashcard-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 2rem 2.25rem;
  text-align: center;
  overflow: hidden;
}
.math-flashcard-front {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 2px solid #fde68a;
}
.math-flashcard-back {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 2px solid #6ee7b7;
  transform: rotateY(180deg);
}
.math-flashcard-text {
  font-size: clamp(1.15rem, 3.5vw, 1.85rem);
  font-weight: 800;
  color: #1f2937;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}
.math-flashcard-hint {
  font-size: .82rem;
  color: #6b7280;
  font-style: italic;
  line-height: 1.4;
}
.math-flashcard-sub {
  font-size: .85rem;
  color: #6b7280;
}
.math-fc-actions {
  display: flex;
  gap: .75rem;
  justify-content: center;
  margin-top: .85rem;
  width: 100%;
}
.math-fc-btn--got-it,
.math-fc-btn--try-again {
  flex: 1;
  max-width: 180px;
  padding: .65rem .5rem;
  border-radius: .85rem;
  border: 2px solid transparent;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.math-fc-btn--got-it {
  background: #10b981;
  color: #fff;
}
.math-fc-btn--try-again {
  background: #fff;
  border-color: #d1d5db;
  color: #374151;
}
.math-fc-btn--got-it:hover,
.math-fc-btn--try-again:hover { opacity: .82; }

/* ── Fill-in-the-blank ───────────────────────────────────── */
.math-fill-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .85rem;
}
.math-fill-input {
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  width: 7rem;
  padding: .5rem;
  border: 2.5px solid #d1d5db;
  border-radius: .75rem;
  outline: none;
  color: #1f2937;
  transition: border-color .15s;
}
.math-fill-input:focus { border-color: var(--cat-color, #f59e0b); }
.math-fill-check {
  background: var(--cat-color, #f59e0b);
  color: #fff;
  border: none;
  padding: .55rem 1.75rem;
  border-radius: 2rem;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.math-fill-check:hover { opacity: .85; }

/* ── Memory match ────────────────────────────────────────── */
.math-memory-grid {
  display: grid;
  gap: .6rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  align-self: stretch;
}
.math-memory-grid[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.math-memory-grid[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.math-memory-grid[data-cols="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 600px) {
  .math-mode-pill {
    flex: 1 1 calc(50% - .45rem);
    justify-content: center;
    min-height: 2.35rem;
    white-space: normal;
    text-align: center;
  }
  .math-mode-pill--print {
    margin-left: 0;
  }
  .math-memory-grid,
  .math-memory-grid[data-cols="3"],
  .math-memory-grid[data-cols="4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
  }
  .math-mem-logo {
    max-height: 52px;
  }
}

@media (max-width: 380px) {
  .math-memory-grid,
  .math-memory-grid[data-cols="2"],
  .math-memory-grid[data-cols="3"],
  .math-memory-grid[data-cols="4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.math-mem-card {
  aspect-ratio: 1;
  position: relative;
  cursor: pointer;
  perspective: 600px;
  min-height: 6rem;
  min-width: 0;
  width: 100%;
}
.math-mem-front,
.math-mem-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(.8rem, 2.5vw, 1.25rem);
  font-weight: 800;
  transition: transform .3s;
  padding: .45rem;
  text-align: center;
  overflow-wrap: anywhere;
  line-height: 1.15;
}
.math-mem-front {
  background: linear-gradient(135deg, var(--cat-color, #f59e0b), color-mix(in srgb, var(--cat-color, #f59e0b) 70%, #000 30%));
  color: #fff;
  border: 2px solid transparent;
}
.math-mem-back {
  background: #fff;
  border: 2px solid #e5e7eb;
  color: #1f2937;
  transform: rotateY(180deg);
}
.math-mem-card.flipped .math-mem-front  { transform: rotateY(-180deg); }
.math-mem-card.flipped .math-mem-back   { transform: rotateY(0); }
.math-mem-card.matched .math-mem-back {
  background: #dcfce7;
  border-color: #16a34a;
}

/* ── Boss battle ─────────────────────────────────────────── */
.math-boss-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.math-boss-char {
  font-size: 4rem;
  text-align: center;
  transition: transform .15s;
}
.math-boss-char.math-boss-hit { animation: bossHit .3s ease; }
@keyframes bossHit {
  0%   { transform: scale(1) translateX(0); }
  25%  { transform: scale(1.15) translateX(-8px); }
  75%  { transform: scale(.95) translateX(8px); }
  100% { transform: scale(1) translateX(0); }
}
.math-boss-hp-bar-wrap {
  background: #fee2e2;
  border-radius: 2rem;
  height: .75rem;
  overflow: hidden;
}
.math-boss-hp-bar {
  height: 100%;
  background: #ef4444;
  border-radius: 2rem;
  transition: width .35s ease;
}
.math-boss-hp-label {
  font-size: .72rem;
  color: #ef4444;
  font-weight: 700;
  text-align: right;
}

/* ── Completion modal ────────────────────────────────────── */
.math-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(3px);
}
.math-modal-box {
  background: #fff;
  border-radius: 1.5rem;
  padding: 2rem 2rem 1.75rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  animation: modalIn .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.7) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.math-modal-trophy {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: .5rem;
}
.math-modal-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #1f2937;
  margin: 0 0 .75rem;
}
.math-modal-score-wrap {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: .75rem;
  margin-bottom: .85rem;
}
.math-modal-score-big {
  font-size: 2.8rem;
  font-weight: 900;
  color: #f59e0b;
  line-height: 1;
}
.math-modal-pts {
  font-size: 1rem;
  font-weight: 700;
  color: #10b981;
}
.math-modal-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
  margin-bottom: 1.25rem;
  min-height: .5rem;
}
.math-modal-badge {
  display: flex;
  align-items: center;
  gap: .35rem;
  background: #fef9c3;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: .78rem;
  font-weight: 700;
  padding: .3rem .7rem;
  border-radius: 2rem;
}
.math-modal-actions {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.math-modal-btn--primary,
.math-modal-btn--outline {
  width: 100%;
  padding: .7rem 1.5rem;
  border-radius: 2rem;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: opacity .15s, transform .1s;
}
.math-modal-btn--primary {
  background: var(--cat-color, #f59e0b);
  color: #fff;
}
.math-modal-btn--outline {
  background: #fff;
  border-color: #d1d5db;
  color: #374151;
}
.math-modal-btn--primary:hover,
.math-modal-btn--outline:hover { opacity: .82; transform: translateY(-1px); }

/* ── Guest login nudge inside modal ──────────────────────── */
.math-modal-guest {
  font-size: .8rem;
  color: #6b7280;
  margin-bottom: 1rem;
}
.math-modal-guest a {
  color: #f59e0b;
  font-weight: 700;
  text-decoration: none;
}

/* ── Lesson page cat-color custom prop ───────────────────── */
/* applied on .math-game-wrap and children via var(--cat-color) */

/* ── Confetti canvas ─────────────────────────────────────── */
#mathConfettiCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9100;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .math-cats {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    padding: .25rem 0 .6rem;
    scrollbar-width: none;
  }
  .math-cats::-webkit-scrollbar {
    display: none;
  }
  .math-cat-btn {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }
  .math-category-section {
    padding: .8rem;
    border-radius: .95rem;
  }
  .math-category-section-head {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
  }
  .math-category-section-link {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .math-grid {
    grid-template-columns: 1fr;
    gap: .85rem;
  }
  .math-hero { padding: 1.75rem 0 1.5rem; }
  .math-lesson-header-left {
    align-items: flex-start;
    min-width: 0;
  }
  .math-lesson-title {
    font-size: 1.05rem;
    overflow-wrap: anywhere;
  }
  .math-mode-bar {
    gap: .45rem;
  }
  .math-mode-pill {
    flex: 1 1 calc(50% - .45rem);
    justify-content: center;
    min-height: 2.35rem;
    white-space: normal;
    text-align: center;
  }
  .math-mode-pill--print {
    margin-left: 0;
  }
  .math-game-wrap {
    padding: .9rem;
    border-radius: 1rem;
  }
  .math-game-area {
    min-height: 0;
    gap: .75rem;
  }
  .math-progress-text,
  .math-timer {
    flex: 0 0 auto;
  }
  .math-choices { gap: .45rem; }
  .math-choice-btn {
    font-size: 1rem;
    padding: .85rem .55rem;
    min-height: 3.6rem;
  }
  .math-fill-input {
    width: min(12rem, 100%);
    min-height: 3.4rem;
  }
  .math-fill-check,
  .math-listen-btn {
    min-height: 2.8rem;
    width: 100%;
  }
  .math-memory-grid,
  .math-memory-grid[data-cols="3"],
  .math-memory-grid[data-cols="4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
  }
  .math-mem-card {
    min-height: clamp(7.4rem, 38vw, 10rem);
  }
  .math-mem-front,
  .math-mem-back {
    border-radius: .9rem;
    font-size: clamp(1rem, 5vw, 1.35rem);
    padding: .55rem;
  }
  .math-mem-logo {
    max-height: 52px;
  }
  .math-modal-box { padding: 1.5rem 1.25rem 1.5rem; }
  .math-modal-score-big { font-size: 2.2rem; }
  .math-flashcard { max-width: 100%; }
  .math-flashcard-inner { height: 270px; }
  .math-flashcard-front,
  .math-flashcard-back { padding: 1.5rem 1.25rem; }
}
@media (max-width: 380px) {
  .math-grid { grid-template-columns: 1fr; }
  .math-choices { grid-template-columns: 1fr; }
  .math-memory-grid,
  .math-memory-grid[data-cols="2"],
  .math-memory-grid[data-cols="3"],
  .math-memory-grid[data-cols="4"] {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Card mode chips ─────────────────────────────────────── */
.math-card-modes {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin: .35rem 0 .25rem;
}
.math-mode-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #f3f4f6;
  font-size: .85rem;
  text-decoration: none;
  transition: background .12s, transform .1s;
  border: 1.5px solid transparent;
}
.math-mode-chip:hover {
  background: #e5e7eb;
  transform: scale(1.1);
}
.math-mode-chip--default {
  background: var(--card-accent, #f59e0b);
  border-color: var(--card-accent, #f59e0b);
}
.math-mode-chip--print {
  background: #f0fdf4;
  border-color: #a7f3d0;
}
.math-card-print-link {
  font-size: .72rem;
  font-weight: 700;
  color: #6b7280;
  text-decoration: none;
  padding: .25rem .55rem;
  border: 1px solid #e5e7eb;
  border-radius: 2rem;
  transition: color .12s, border-color .12s;
}
.math-card-print-link:hover { color: #059669; border-color: #059669; }

/* ── Card footer adjustment for print link ───────────────── */
.math-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

/* ── Badge pts variant ───────────────────────────────────── */
.math-badge--pts {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

/* ── Mode switcher bar (lesson page) ─────────────────────── */
.math-mode-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .5rem 0 .75rem;
  align-items: center;
}
.math-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .3rem .75rem;
  border-radius: 2rem;
  font-size: .78rem;
  font-weight: 700;
  text-decoration: none;
  background: #f3f4f6;
  color: #374151;
  border: 1.5px solid transparent;
  transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
}
.math-mode-pill:hover {
  background: #e5e7eb;
  color: #111;
}
.math-mode-pill--active {
  background: var(--cat-color, #f59e0b);
  color: #fff;
  border-color: var(--cat-color, #f59e0b);
}
.math-mode-pill--print {
  background: #f0fdf4;
  color: #059669;
  border-color: #a7f3d0;
  margin-left: auto;
}
.math-mode-pill--print:hover { background: #dcfce7; }

/* ── Memory card logo ────────────────────────────────────── */
.math-mem-logo {
  max-height: 36px;
  max-width: 80%;
  object-fit: contain;
  opacity: .85;
}
.math-mem-logo-emoji { font-size: 1.5rem; }
.math-memory-hint {
  text-align: center;
  font-size: .85rem;
  color: #6b7280;
  font-weight: 600;
  margin-bottom: .5rem;
  width: 100%;
}

/* ── Memory grid cols via data-attr ──────────────────────── */

/* ── Print helper (referenced in spec) ──────────────────── */
@media print {
  .math-lesson-balance, .math-game-wrap, .math-feedback,
  .math-modal-overlay, #mathConfettiCanvas { display: none !important; }
  .math-lesson-info { border: 1px solid #ccc; }
}
