* {
  box-sizing: border-box;
}

body {
  font-family: "Comic Sans MS", "Segoe UI", Arial, sans-serif;
  background: linear-gradient(135deg, #7f1d1d 0%, #b91c1c 25%, #c2410c 50%, #78350f 75%, #7f1d1d 100%);
  background-size: 300% 300%;
  animation: gradientShift 14s ease infinite;
  position: relative;
  overflow-x: hidden;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

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

.card {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 24px;
  padding: 24px 20px 32px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  position: relative;
  z-index: 1;
}

.levels { display: flex; gap: 8px; margin-bottom: 20px; }

.lvl-btn {
  flex: 1;
  padding: 10px 6px;
  border-radius: 10px;
  border: 2px solid #fecaca;
  background: #fef2f2;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

.lvl-btn.active {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border-color: #991b1b;
  color: #fff;
  font-weight: 700;
}

.stats { display: flex; gap: 10px; margin-bottom: 20px; }

.stat {
  flex: 1;
  background: #fee2e2;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}

.stat .label { font-size: 12px; color: #b91c1c; font-weight: 700; }
.stat .value { font-size: 22px; font-weight: 800; color: #7f1d1d; margin-top: 2px; }

.question-box {
  background: #fffafa;
  border: 1px solid #fecaca;
  border-radius: 14px;
  padding: 18px 14px;
  text-align: center;
}

#prompt {
  font-size: 15px;
  font-weight: 700;
  color: #7f1d1d;
  margin-bottom: 14px;
}

/* ---------- Target ---------- */
.target-box {
  display: inline-block;
  min-width: 140px;
  padding: 10px 24px 12px;
  margin-bottom: 18px;
  border-radius: 16px;
  background: linear-gradient(160deg, #fde68a, #f59e0b);
  box-shadow: 0 5px 0 #b45309;
}

.target-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #78350f;
}

.target-value {
  font-size: 48px;
  font-weight: 800;
  line-height: 1.1;
  color: #78350f;
}

/* ---------- Number tiles ---------- */
.tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  min-height: 66px;
  margin-bottom: 14px;
}

.num-tile {
  min-width: 62px;
  height: 62px;
  padding: 0 10px;
  border: 3px solid transparent;
  border-radius: 14px;
  color: #fff;
  font-family: inherit;
  font-size: 26px;
  font-weight: 800;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.num-tile:hover { transform: translateY(-2px); }

.num-tile.selected {
  border-color: #1f2937;
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3);
}

.num-tile.new { animation: popIn 0.22s ease; }

.num-tile.hint {
  border-color: #fbbf24;
  animation: hintPulse 0.9s ease infinite;
}

@keyframes popIn {
  0% { transform: scale(0.4); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.8); }
  50% { box-shadow: 0 0 0 8px rgba(251, 191, 36, 0); }
}

/* ---------- Operators ---------- */
.ops {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.op-btn {
  width: 56px;
  height: 56px;
  border: 3px solid #fecaca;
  border-radius: 50%;
  background: #fff;
  color: #b91c1c;
  font-family: inherit;
  font-size: 28px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.op-btn:hover { transform: scale(1.08); }

.op-btn.selected {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border-color: #7f1d1d;
  color: #fff;
}

#feedback {
  min-height: 20px;
  font-weight: 700;
  font-size: 14px;
}

.feedback-correct { color: #15803d; }
.feedback-wrong { color: #dc2626; }
.feedback-info { color: #b45309; }

.actions { display: flex; gap: 8px; margin-top: 16px; }

.action-btn {
  flex: 1;
  padding: 12px 4px;
  border-radius: 10px;
  border: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.action-btn:disabled { opacity: 0.45; cursor: default; }

.clear-btn { background: #e5e7eb; color: #374151; }
.clear-btn:hover:not(:disabled) { background: #d1d5db; }
.hint-btn { background: #fbbf24; color: #78350f; }
.hint-btn:hover { background: #f59e0b; }
.check-btn { background: #b91c1c; color: #fff; }
.check-btn:hover { background: #991b1b; }