html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
}

/* Navbar override */
.navbar {
  background: rgba(255,255,255,0.95) !important;
  backdrop-filter: blur(10px);
}

/* Main container */
.math-container {
  max-width: 900px;
  margin: 20px auto;
  padding: 30px;
  background: rgba(255,255,255,0.95);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

/* Score banner */
.score-banner {
  border-radius: 15px;
  animation: fadeInUp 0.5s ease;
}

.score-banner.alert-success {
  background: linear-gradient(135deg, #d4edda, #c3e6cb);
  border: 2px solid #28a745;
  animation: pulse 1.5s ease infinite;
}

/* Problems grid */
.problems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.problem-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #f8f9fa;
  border-radius: 12px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.problem-item:hover {
  border-color: #667eea;
  background: #eef0ff;
}

.problem-item.correct {
  border-color: #28a745;
  background: #d4edda;
  animation: correctPop 0.4s ease;
}

.problem-item.wrong {
  border-color: #dc3545;
  background: #f8d7da;
  animation: shake 0.4s ease;
}

.problem-label {
  font-weight: bold;
  color: #6c757d;
  min-width: 30px;
  font-size: 1rem;
}

.problem-expr {
  font-size: 1.3rem;
  font-weight: 600;
  color: #333;
  min-width: 70px;
  font-family: 'Consolas', 'Courier New', monospace;
}

.answer-input {
  width: 75px;
  padding: 6px 8px;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  transition: all 0.3s ease;
  font-family: 'Consolas', 'Courier New', monospace;
}

.answer-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.answer-input.input-correct {
  border-color: #28a745;
  background: #fff;
}

.answer-input.input-wrong {
  border-color: #dc3545;
  background: #fff;
}

.check-mark {
  color: #28a745;
  font-size: 1.4rem;
  font-weight: bold;
}

.correct-answer {
  color: #dc3545;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Celebration overlay */
#celebration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  pointer-events: none;
  animation: fadeIn 0.5s ease;
}

.celebration-text {
  text-align: center;
  animation: celebrationBounce 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.trophy {
  font-size: 6rem;
  animation: trophySpin 1s ease, trophyFloat 2s ease-in-out infinite;
}

.congrats {
  font-size: 3rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 0 60px rgba(255,215,0,0.6);
  margin-top: 10px;
}

.perfect {
  font-size: 1.8rem;
  font-weight: 700;
  color: #ffd93d;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
  margin-top: 5px;
}

.stars {
  font-size: 2.5rem;
  margin-top: 10px;
  animation: starPulse 0.6s ease-in-out infinite alternate;
}

/* Confetti canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 999;
  pointer-events: none;
}

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

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

@keyframes celebrationBounce {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes trophySpin {
  0% { transform: rotateY(0deg) scale(0); }
  50% { transform: rotateY(180deg) scale(1.3); }
  100% { transform: rotateY(360deg) scale(1); }
}

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

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

/* Responsive adjustments */
@media (max-width: 576px) {
  .math-container {
    margin: 10px;
    padding: 15px;
    border-radius: 12px;
  }

  .problems-grid {
    grid-template-columns: 1fr;
  }

  .trophy {
    font-size: 4rem;
  }

  .congrats {
    font-size: 2rem;
  }

  .perfect {
    font-size: 1.2rem;
  }
}
