/* ================= Celebration Overlay ================= */
.celebration-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.celebration-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.celebration-content {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 40px 30px;
  text-align: center;
  max-width: 440px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.star-explosion {
  font-size: 4rem;
  margin-bottom: 12px;
  animation: spin 3s linear infinite;
}

/* ================= Interactive Visual Math Engine Styles ================= */
.math-cat-tabs {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.math-cat-btn {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 50px;
  padding: 8px 18px;
  font-size: 1rem;
  font-weight: 800;
  color: #475569;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  transition: all 0.2s;
}

.math-cat-btn:hover {
  border-color: var(--cat-color, #2563eb);
  transform: translateY(-2px);
}

.math-cat-btn.active {
  background: var(--cat-color, #2563eb);
  color: #ffffff;
  border-color: var(--cat-color, #2563eb);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.math-level-filters {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.math-lvl-btn {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}

.math-lvl-btn:hover {
  border-color: #3b82f6;
}

.math-lvl-btn.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.math-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  max-width: 720px;
  margin: 0 auto;
}

.math-progress-bar {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}

.math-progress-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.math-question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.math-question-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #1e293b;
  margin: 0;
}

.math-visual-stage {
  background: #f8fafc;
  border-radius: 20px;
  padding: 24px;
  border: 2px dashed #cbd5e1;
  margin-bottom: 24px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.math-visual-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.math-tray {
  border-radius: 18px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.blue-tray { background: #e0f2fe; border: 2px solid #bae6fd; }
.gold-tray { background: #fef9c3; border: 2px solid #fef08a; }
.purple-tray { background: #f3e8ff; border: 2px solid #e9d5ff; }
.orange-tray { background: #ffedd5; border: 2px solid #fed7aa; }
.green-tray { background: #dcfce7; border: 2px solid #bbf7d0; }

.tray-count-badge {
  position: absolute;
  top: -10px;
  left: -8px;
  background: #0f172a;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 900;
  border-radius: 12px;
  padding: 2px 8px;
}

.tray-items {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.math-emoji-item {
  font-size: 2.2rem;
  line-height: 1;
  display: inline-block;
  transition: transform 0.2s;
}

.math-operator-sym {
  font-size: 2rem;
  font-weight: 900;
  color: #334155;
}

.bead-gold-mini {
  width: 14px;
  height: 14px;
  background: radial-gradient(circle, #fde047 30%, #ca8a04 100%);
  border-radius: 50%;
  border: 1px solid #a16207;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.bead-gold-unit {
  width: 22px;
  height: 22px;
  background: radial-gradient(circle, #fef08a 30%, #eab308 100%);
  border-radius: 50%;
  border: 2px solid #a16207;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.eaten-item {
  opacity: 0.35;
  filter: grayscale(80%);
  position: relative;
}

.number-line-container {
  width: 100%;
  overflow-x: auto;
  padding: 10px 0;
}

.number-line-track {
  display: flex;
  gap: 6px;
  justify-content: center;
  min-width: 480px;
}

.number-line-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  padding: 8px 10px;
  min-width: 36px;
  font-weight: 800;
  font-size: 1.1rem;
  color: #334155;
}

.number-line-step.number-line-start {
  border-color: #ea580c;
  background: #ffedd5;
  color: #c2410c;
}

.number-line-step.number-line-dest {
  border-color: #22c55e;
  background: #dcfce7;
  color: #15803d;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

.step-label {
  font-size: 0.7rem;
  font-weight: 800;
  margin-top: 4px;
}

.math-basket {
  background: #ffffff;
  border: 2px dashed #9333ea;
  border-radius: 16px;
  padding: 12px 16px;
  position: relative;
}

.basket-badge {
  position: absolute;
  top: -10px;
  left: 10px;
  background: #9333ea;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 800;
  border-radius: 10px;
  padding: 2px 8px;
}

.math-matrix-board {
  background: #ffffff;
  border: 2px solid #e9d5ff;
  border-radius: 18px;
  padding: 16px 24px;
}

.bead-matrix-dot {
  font-size: 1.8rem;
  line-height: 1;
}

.repeat-num-block {
  background: #9333ea;
  color: #ffffff;
  font-size: 1.6rem;
  font-weight: 900;
  padding: 6px 16px;
  border-radius: 12px;
}

.fair-share-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.fair-share-recipient {
  background: #ffffff;
  border: 2px solid #bbf7d0;
  border-radius: 20px;
  padding: 14px 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 110px;
}

.recipient-avatar {
  font-size: 2.5rem;
}

.recipient-name {
  font-size: 0.85rem;
  font-weight: 800;
  color: #15803d;
}

.recipient-plate {
  background: #f0fdf4;
  border: 2px dashed #86efac;
  border-radius: 14px;
  padding: 6px 12px;
  min-height: 44px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.math-packing-box {
  background: #ffffff;
  border: 2px solid #86efac;
  border-radius: 16px;
  padding: 12px 16px;
  position: relative;
  min-width: 100px;
}

.box-tag {
  position: absolute;
  top: -10px;
  left: 8px;
  background: #16a34a;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 800;
  border-radius: 8px;
  padding: 2px 6px;
}

.math-mystery-box-stage {
  padding: 10px;
}

.mystery-equation {
  font-size: 2rem;
  font-weight: 900;
  color: #1e293b;
}

.mystery-qmark-badge {
  background: #f59e0b;
  color: #ffffff;
  padding: 4px 14px;
  border-radius: 14px;
  display: inline-block;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.4);
  animation: pulse 1.5s infinite;
}

.math-quick-display {
  padding: 16px;
}

.quick-equation-text {
  font-size: 2.4rem;
  font-weight: 900;
  color: #0f172a;
}

.math-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.math-choice-btn {
  font-size: 1.8rem !important;
  font-weight: 900 !important;
  padding: 14px 10px !important;
  border-radius: 18px !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25) !important;
  transition: all 0.15s !important;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
  color: #ffffff !important;
  border: 2px solid rgba(255, 255, 255, 0.4) !important;
}

.math-choice-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35) !important;
}

.math-choice-btn:active {
  transform: translateY(2px);
}

/* ================= 3D Kid-Friendly Action Controls ================= */
.math-bottom-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 2px dashed #e2e8f0;
}

.btn-wb-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Quicksand', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 10px 20px;
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12), 0 3px 0 rgba(0, 0, 0, 0.15);
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  overflow: hidden;
}

.btn-wb-action:hover {
  transform: translateY(-2px) scale(1.04);
}

.btn-wb-action:active {
  transform: translateY(2px) scale(0.97);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), 0 1px 0 rgba(0, 0, 0, 0.15);
}

.btn-wb-action::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-20deg);
  transition: none;
}

.btn-wb-action:hover::after {
  left: 140%;
  transition: all 0.65s ease-in-out;
}

.btn-wb-reset {
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.35), 0 3px 0 #c2410c;
}

.btn-wb-reset:hover {
  box-shadow: 0 6px 18px rgba(234, 88, 12, 0.45), 0 4px 0 #c2410c;
}

.btn-wb-next {
  background: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4), 0 3px 0 #047857;
  font-size: 1.05rem;
  padding: 11px 26px;
}

.btn-wb-next:hover {
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5), 0 4px 0 #047857;
}

.btn-wb-random {
  background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35), 0 3px 0 #6d28d9;
}

.btn-wb-random:hover {
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.45), 0 4px 0 #6d28d9;
}

.btn-wb-prev {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  box-shadow: 0 4px 12px rgba(71, 85, 105, 0.3), 0 3px 0 #334155;
}

.number-line-range {
  background: #fef3c7;
  border-color: #f59e0b;
}

