* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  height: 100%;
  width: 100%;
}

#game-root {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #a8d8ff;
  touch-action: manipulation;
}

#hud-bar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #2d3a1f;
  pointer-events: none;
}

.hud-button {
  position: absolute;
  top: 56px;
  right: 12px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: #ff8a5b;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  color: #fff;
  text-align: center;
}

#game-title {
  font-size: 2rem;
  margin: 0;
}

.cta-button {
  padding: 12px 32px;
  font-size: 1.2rem;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  background: #ffd23f;
  color: #4a3000;
  cursor: pointer;
}

.cta-button:active {
  transform: scale(0.97);
}

.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 12px;
}

.modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#question-text {
  font-size: 1.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 0;
  color: #2d3a1f;
}

#answer-input {
  font-size: 1.4rem;
  padding: 8px 12px;
  width: 120px;
  text-align: center;
  border: 2px solid #ccc;
  border-radius: 8px;
}

.bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #fff;
  border-radius: 999px;
  padding: 8px 20px;
  font-weight: 700;
  font-size: 1.1rem;
  color: #b33;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.correct-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.correct-check {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.4);
  width: 110px;
  height: 110px;
  line-height: 110px;
  text-align: center;
  border-radius: 50%;
  background: #2ecc71;
  color: #fff;
  font-size: 64px;
  font-weight: 900;
  opacity: 0;
}

.correct-fx.playing .correct-check {
  animation: checkPop 1s ease-out forwards;
}

@keyframes checkPop {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  20% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  35% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  75% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

.confetti-piece {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 14px;
  opacity: 0;
}

.correct-fx.playing .confetti-piece {
  animation: confettiBurst 0.9s ease-out forwards;
}

@keyframes confettiBurst {
  0% {
    transform: translate(-50%, -50%) rotate(0deg) translateY(0);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) translateY(0);
    opacity: 0;
  }
}

.wrong-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.wrong-cross {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.4);
  width: 110px;
  height: 110px;
  line-height: 110px;
  text-align: center;
  border-radius: 50%;
  background: #e74c3c;
  color: #fff;
  font-size: 64px;
  font-weight: 900;
  opacity: 0;
}

.wrong-fx.playing .wrong-cross {
  animation: crossPop 1s ease-out forwards;
}

@keyframes crossPop {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  20% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  35% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  75% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

.cheer-marquee {
  position: absolute;
  left: 0;
  right: 0;
  overflow: hidden;
  white-space: nowrap;
  pointer-events: none;
}

.cheer-marquee span {
  display: inline-block;
  padding-left: 100%;
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  animation: marqueeScroll 3.5s linear forwards;
}

@keyframes marqueeScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-200%); }
}
