/* Math Game - Minimal custom styles */
/* Most styling comes from site's main CSS */

/* Mobile optimization for small screens (iPhone 6, etc) */
@media (max-width: 400px) {
  .math-game-question {
    font-size: clamp(2rem, 8vw, 2.5rem) !important;
    margin: 0.5rem 0 !important;
  }

  .math-game-status span {
    padding: 0.4rem 0.75rem !important;
    font-size: 0.75rem !important;
  }

  .math-game-task-label,
  .math-game-panel-label {
    margin: 0.5rem 0 0.25rem !important;
    font-size: 0.85rem !important;
  }

  .math-game-tile-grid {
    gap: 6px !important;
    margin-bottom: 0.5rem !important;
  }

  .math-game-setup-tile {
    padding: 0.6rem !important;
  }

  .math-game-tile-title {
    font-size: 0.95rem !important;
  }

  .math-game-tile-sub {
    font-size: 0.7rem !important;
  }

  .math-game-choices-grid {
    gap: 0.5rem !important;
    margin-top: 0.5rem !important;
  }

  .math-game-choice-btn {
    padding: 0.9rem !important;
    font-size: 1.3rem !important;
  }

  .math-game-keypad {
    gap: 0.4rem !important;
    margin-top: 0.5rem !important;
  }

  .math-game-key {
    min-height: 2.8rem !important;
    font-size: 1.1rem !important;
  }

  .math-game-key-empty {
    min-height: 2.8rem !important;
  }

  .math-game-answer-display {
    min-height: 3rem !important;
    font-size: 1.6rem !important;
    margin: 0.5rem 0 !important;
  }

  #mg-message {
    font-size: 1rem !important;
    padding: 0.5rem 0.75rem !important;
    letter-spacing: 0.3px !important;
    max-width: 90% !important;
  }

  #mg-message.ok {
    border-width: 3px !important;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6) !important;
  }

  #mg-message.err {
    border-width: 4px !important;
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.8) !important;
  }

  .math-game-question {
    padding: 0.4rem 0.75rem !important;
  }

  .math-game-question.correct-answer,
  .math-game-question.wrong-answer {
    border-width: 2px !important;
  }
}

/* Fun animations for kids! */
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

@keyframes pulse-scale {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes celebrate {
  0% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.2) rotate(-10deg); }
  50% { transform: scale(1.3) rotate(10deg); }
  75% { transform: scale(1.2) rotate(-5deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes rainbow-glow {
  0% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.5); }
  33% { box-shadow: 0 0 20px rgba(236, 72, 153, 0.5); }
  66% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.5); }
  100% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.5); }
}

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

/* Tile grid for game options */
.math-game-tile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 1rem;
}

.math-game-tile-grid.three {
  grid-template-columns: repeat(3, 1fr);
}

.math-game-tile-grid.four {
  grid-template-columns: repeat(4, 1fr);
}

.math-game-tile-grid.six {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 640px) {
  .math-game-tile-grid.three {
    grid-template-columns: 1fr;
  }

  .math-game-tile-grid.four {
    grid-template-columns: repeat(2, 1fr);
  }

  .math-game-tile-grid.six {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Setup tiles */
.math-game-setup-tile {
  border: 2px solid #e5e7eb;
  border-radius: 1rem;
  background: white;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.math-game-setup-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  animation: wiggle 0.5s ease;
}

.math-game-setup-tile.active {
  border-color: #8b5cf6;
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
  animation: pulse-scale 2s infinite;
}

.math-game-tile-title {
  display: block;
  font-weight: 900;
  font-size: 1.1rem;
  color: #1f2937;
  white-space: nowrap;
}

.math-game-tile-sub {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: #6b7280;
  font-weight: 600;
}

.math-game-mode-symbol {
  font-size: 1.5rem;
  letter-spacing: 2px;
  font-family: "Trebuchet MS", "Verdana", sans-serif;
}

.math-game-setup-message {
  min-height: 1.5rem;
  margin-top: -0.25rem;
  margin-bottom: 0.5rem;
  color: #dc2626;
  font-weight: 700;
  text-align: center;
}

#mg-start-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Game status badges */
.math-game-status {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.math-game-status span {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 800;
  color: #0c4a6e;
}

/* Question display */
.math-game-question {
  margin: 1rem 0;
  text-align: center;
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  font-weight: 900;
  color: #1f2937;
  animation: bounce 0.5s ease;
  padding: 0.5rem 1rem;
  border-radius: 1rem;
  transition: all 0.3s ease;
}

.math-game-question.correct-answer {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border: 3px solid #10b981;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
  color: #047857;
}

.math-game-question.wrong-answer {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border: 3px solid #ef4444;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
  color: #b91c1c;
}

.math-game-task-label,
.math-game-panel-label {
  margin: 1rem 0 0.5rem;
  color: #6b7280;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
}

/* Choice buttons (easy mode) */
.math-game-choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

.math-game-choice-btn {
  border: 2px solid #e5e7eb;
  border-radius: 1rem;
  padding: 1.25rem;
  font-size: 1.5rem;
  font-weight: 900;
  color: #1f2937;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.math-game-choice-btn:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.3);
  animation: float 1s ease-in-out;
}

.math-game-choice-btn.selected {
  border-color: #8b5cf6;
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
  animation: pulse-scale 1s infinite;
}

.math-game-choice-btn.correct {
  border-color: #10b981;
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  animation: celebrate 0.6s ease;
}

.math-game-choice-btn.wrong {
  border-color: #ef4444;
  animation: shake 0.5s ease;
}

.math-game-choice-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Answer display (hard mode) */
.math-game-answer-display {
  margin: 1rem 0;
  width: 100%;
  min-height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 100%);
  border: 2px dashed #c7d2fe;
  border-radius: 1rem;
  color: #1f2937;
}

/* Keypad (hard mode) */
.math-game-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 1rem;
}

.math-game-key-empty {
  /* Empty cell in keypad grid */
  min-height: 3.5rem;
}

.math-game-key {
  border: 2px solid #e5e7eb;
  border-radius: 0.75rem;
  min-height: 3.5rem;
  font-size: 1.3rem;
  font-weight: 900;
  background: white;
  color: #1f2937;
  cursor: pointer;
  transition: all 0.15s ease;
}

.math-game-key:hover {
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.math-game-key:active {
  transform: scale(0.95);
  animation: wiggle 0.3s ease;
}

.math-game-key.alt {
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 700;
}

/* Message styles - absolute overlay in status bar */
#mg-message {
  transition: all 0.3s ease;
  opacity: 0;
  transform: scale(0.85);
  text-align: center;
  white-space: nowrap;
  max-width: 95%;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
}

#mg-message:empty {
  display: none;
}

#mg-message.ok {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #047857;
  border: 4px solid #10b981;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.6);
  animation: celebrate 0.6s ease;
  opacity: 1;
  transform: scale(1);
  font-weight: 900;
  font-size: 1.35rem;
  letter-spacing: 0.5px;
}

#mg-message.err {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #b91c1c;
  border: 5px solid #ef4444;
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.7);
  animation: shake 0.5s ease;
  opacity: 1;
  transform: scale(1);
  font-weight: 900;
  font-size: 1.35rem;
  letter-spacing: 0.5px;
}

/* Confetti effect container */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #f0f;
  animation: confetti-fall 3s linear forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(100vh) rotate(360deg);
    opacity: 0;
  }
}
