/**
 * Balloon pop game — CENTRAL stylesheet, shared by addition, subtraction,
 * multiplication and division (see balloon-pop-game.js, which drives all
 * four operations off the same markup/classes).
 *
 * The "bap" class prefix predates this refactor (originally "balloon
 * addition pop") but is kept as-is and now read generically as
 * "balloon pop" — renaming ~80 selectors would add risk with no visual
 * benefit. Only the two operation-agnostic root classes changed:
 *   .balloon-addition-game     -> .balloon-pop-game
 *   .balloon-addition-fullpage -> .balloon-pop-fullpage
 *
 * To retheme or fix a look-and-feel bug for ANY operation's balloon game,
 * this is the only CSS file to touch (besides quiz-popup-theme.css, which
 * owns the shared popup chrome/scene variables).
 */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;700&display=swap');

.balloon-pop-game {
  --bap-red: var(--popup-scene-accent-red);
  --bap-green: var(--popup-scene-accent-green);
  --bap-purple: var(--popup-scene-accent-purple);
  --bap-ink: var(--popup-scene-ink);
  --bap-card: var(--popup-scene-card);
  --bap-shadow: var(--popup-scene-shadow);
  --bap-sun: var(--popup-scene-sun);
  position: relative;
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  font-family: 'Nunito', sans-serif;
  color: var(--bap-ink);
}

.balloon-pop-fullpage {
  min-height: 100vh;
  border-radius: 0;
}

.balloon-pop-game .bap-stage {
  position: relative;
  width: 100%;
  min-height: 540px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.balloon-pop-fullpage .bap-stage {
  min-height: 100vh;
}

/* ---- decorative sun/clouds (standalone/fullpage use only —
   hidden automatically when nested in .quiz-modal via quiz-popup-theme.css,
   since the modal already supplies its own sun + sky background) ---- */
.balloon-pop-game .bap-sun {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #FFF1A8, var(--bap-sun));
  box-shadow: 0 0 26px 5px rgba(255, 217, 61, 0.6);
}

.balloon-pop-game .bap-cloud {
  position: absolute;
  background: #fff;
  border-radius: 50px;
  opacity: 0.9;
  filter: drop-shadow(0 4px 0 rgba(255, 255, 255, 0.4));
  animation: bap-drift linear infinite;
}
.balloon-pop-game .bap-cloud:before,
.balloon-pop-game .bap-cloud:after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}
.balloon-pop-game .bap-c1 { width: 80px; height: 30px; top: 60px; left: -110px; animation-duration: 38s; }
.balloon-pop-game .bap-c1:before { width: 44px; height: 44px; top: -22px; left: 10px; }
.balloon-pop-game .bap-c1:after { width: 30px; height: 30px; top: -12px; left: 46px; }

.balloon-pop-game .bap-c2 { width: 62px; height: 24px; top: 130px; left: -100px; animation-duration: 52s; animation-delay: -15s; }
.balloon-pop-game .bap-c2:before { width: 34px; height: 34px; top: -16px; left: 8px; }
.balloon-pop-game .bap-c2:after { width: 24px; height: 24px; top: -8px; left: 36px; }

.balloon-pop-game .bap-c3 { width: 54px; height: 20px; top: 34px; left: -90px; animation-duration: 46s; animation-delay: -30s; }
.balloon-pop-game .bap-c3:before { width: 28px; height: 28px; top: -13px; left: 8px; }
.balloon-pop-game .bap-c3:after { width: 20px; height: 20px; top: -7px; left: 30px; }

@keyframes bap-drift {
  from { transform: translateX(0); }
  to { transform: translateX(120vw); }
}

/* ---- top bar ---- */
.balloon-pop-game .bap-topbar {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 480px;
  padding: 14px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.balloon-pop-game .bap-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Fredoka', sans-serif;
}

.balloon-pop-game .bap-pill {
  background: var(--bap-card);
  border-radius: 999px;
  padding: 7px 14px;
  box-shadow: 0 4px 0 var(--bap-shadow);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.balloon-pop-game .bap-pill .bap-num { font-size: 18px; color: var(--bap-red); }
.balloon-pop-game .bap-pill.bap-level .bap-num { color: var(--bap-purple); }

.balloon-pop-game .bap-progress-wrap {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  height: 14px;
  width: 100%;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}
.balloon-pop-game .bap-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--bap-green), #7EE39A);
  width: 0%;
  transition: width 0.4s ease;
}
.balloon-pop-game .bap-progress-label {
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--bap-ink);
  margin-top: 2px;
  opacity: 0.75;
}

/* ---- main game area ---- */
.balloon-pop-game .bap-game-area {
  position: relative;
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 2;
  padding: 8px 0 4px;
}

.balloon-pop-game .bap-balloon-zone {
  position: relative;
  width: 210px;
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.balloon-pop-game .bap-timer-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 210px;
  height: 210px;
  transform: rotate(-90deg);
}
.balloon-pop-game .bap-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 8;
}
.balloon-pop-game .bap-ring-progress {
  fill: none;
  stroke: var(--bap-purple);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset linear, stroke 0.3s ease;
}
.balloon-pop-game .bap-ring-progress.bap-urgent { stroke: var(--bap-red); }

.balloon-pop-game .bap-balloon {
  position: relative;
  width: 136px;
  height: 164px;
  transform-origin: center bottom;
  transition: transform 0.25s ease-out;
}

.balloon-pop-game .bap-body {
  width: 100%;
  height: 100%;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 32% 28%, rgba(255,255,255,0.75), transparent 40%),
              linear-gradient(160deg, var(--bap-color-1, #FF9AA2), var(--bap-color-2, #FF6B6B));
  box-shadow: 0 10px 18px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.balloon-pop-game .bap-knot {
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 11px solid var(--bap-color-2, #FF6B6B);
}

.balloon-pop-game .bap-string {
  position: absolute;
  bottom: -64px;
  left: 50%;
  width: 2px;
  height: 64px;
  background: rgba(80, 60, 40, 0.4);
  transform-origin: top center;
  animation: bap-sway 2.4s ease-in-out infinite;
}
@keyframes bap-sway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

.balloon-pop-game .bap-balloon.bap-urgent { animation: bap-shake 0.35s ease-in-out infinite; }
@keyframes bap-shake {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25% { transform: translateX(-3px) rotate(-2deg); }
  75% { transform: translateX(3px) rotate(2deg); }
}

.balloon-pop-game .bap-balloon.bap-pop-anim { animation: bap-popScale 0.15s ease-out forwards; }
@keyframes bap-popScale { to { transform: scale(1.3); opacity: 0; } }

.balloon-pop-game .bap-balloon.bap-correct-float { animation: bap-floatAway 0.6s ease-in forwards; }
@keyframes bap-floatAway { to { transform: translateY(-150px) scale(0.7); opacity: 0; } }

.balloon-pop-game .bap-equation {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 30px;
  color: #fff;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.15);
}

/* ---- storm cloud ---- */
.balloon-pop-game .bap-cloud-track {
  position: absolute;
  top: -28px;
  right: -36px;
  width: 118px;
  height: 86px;
  z-index: 6;
  transform: translateX(180px) scale(0.75);
  pointer-events: none;
}
.balloon-pop-game .bap-cloud-track.bap-lunge {
  transition: transform 0.25s ease-in !important;
  transform: translateX(-108px) translateY(18px) scale(1.15) !important;
}
.balloon-pop-game .bap-black-cloud {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.4));
}
.balloon-pop-game .bap-black-cloud.bap-urgent { animation: bap-cloudShake 0.28s ease-in-out infinite; }
@keyframes bap-cloudShake {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25% { transform: translateX(-3px) rotate(-2deg); }
  75% { transform: translateX(3px) rotate(2deg); }
}
.balloon-pop-game .bap-bolt { opacity: 0; }
.balloon-pop-game .bap-black-cloud.bap-urgent .bap-bolt { animation: bap-boltFlicker 0.4s steps(2, jump-none) infinite; }
@keyframes bap-boltFlicker {
  0%, 100% { opacity: 0; }
  50% { opacity: 0.95; }
}
.balloon-pop-game .bap-cloud-track.bap-impact { animation: bap-cloudLunge 0.25s ease-out forwards; }
@keyframes bap-cloudLunge { to { transform: translateX(-12px) scale(0.85); } }

/* ---- burst particles ---- */
.balloon-pop-game .bap-burst {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
}
.balloon-pop-game .bap-burst span {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bap-red);
  opacity: 0;
}
.balloon-pop-game .bap-burst.bap-show span { animation: bap-fly 0.55s ease-out forwards; }
@keyframes bap-fly {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}

/* ---- answer buttons ---- */
.balloon-pop-game .bap-answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  padding: 0 20px;
}
.balloon-pop-game .bap-answer-btn {
  font-family: 'Fredoka', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: 18px;
  padding: 16px 0;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.balloon-pop-game .bap-answer-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}
.balloon-pop-game .bap-answer-btn:nth-child(1) { background: var(--bap-red); }
.balloon-pop-game .bap-answer-btn:nth-child(2) { background: var(--bap-purple); }
.balloon-pop-game .bap-answer-btn:nth-child(3) { background: var(--bap-green); }
.balloon-pop-game .bap-answer-btn:nth-child(4) { background: #4FA9E0; }
.balloon-pop-game .bap-answer-btn.bap-correct-flash { background: var(--bap-green) !important; }
.balloon-pop-game .bap-answer-btn.bap-wrong-flash { background: var(--bap-red) !important; }
.balloon-pop-game .bap-answer-btn[disabled] { opacity: 0.55; cursor: default; }

/* ---- feedback banner ---- */
.balloon-pop-game .bap-feedback {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translate(-50%, -140%);
  background: var(--bap-card);
  padding: 9px 20px;
  border-radius: 999px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 6px 0 var(--bap-shadow);
  z-index: 10;
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.35s ease;
  white-space: nowrap;
}
.balloon-pop-game .bap-feedback.bap-show { transform: translate(-50%, 0%); opacity: 1; }
.balloon-pop-game .bap-feedback.bap-good { color: var(--bap-green); }
.balloon-pop-game .bap-feedback.bap-bad { color: var(--bap-red); }

/* ---- level up overlay ---- */
.balloon-pop-game .bap-levelup {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(35, 49, 86, 0.35);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.balloon-pop-game .bap-levelup.bap-show { opacity: 1; pointer-events: auto; }
.balloon-pop-game .bap-levelup-card {
  background: var(--bap-card);
  border-radius: 22px;
  padding: 24px 28px;
  text-align: center;
  font-family: 'Fredoka', sans-serif;
  box-shadow: 0 10px 0 var(--bap-shadow);
  transform: scale(0.7);
  transition: transform 0.3s ease;
  max-width: 320px;
  margin: 0 12px;
}
.balloon-pop-game .bap-levelup.bap-show .bap-levelup-card { transform: scale(1); }
.balloon-pop-game .bap-levelup-card h2 { margin: 0 0 6px 0; font-size: 24px; color: var(--bap-purple); }
.balloon-pop-game .bap-levelup-card p {
  margin: 0 0 16px 0;
  font-size: 14px;
  color: var(--bap-ink);
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
}
.balloon-pop-game .bap-levelup-card button {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 16px;
  background: var(--bap-green);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
}

.balloon-pop-game .bap-confetti {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 14px;
  opacity: 0.9;
  animation: bap-fall linear forwards;
  pointer-events: none;
  z-index: 15;
}
@keyframes bap-fall { to { transform: translateY(110vh) rotate(360deg); opacity: 0.4; } }

.balloon-pop-game .bap-hint {
  font-size: 12px;
  font-weight: 700;
  color: var(--bap-ink);
  opacity: 0.55;
  padding: 6px 0 12px 0;
  text-align: center;
  z-index: 2;
}

@media (max-width: 640px) {
  .balloon-pop-game .bap-stage { min-height: 480px; }
  .balloon-pop-game .bap-balloon-zone { width: 180px; height: 220px; }
  .balloon-pop-game .bap-timer-ring { width: 180px; height: 180px; }
  .balloon-pop-game .bap-balloon { width: 116px; height: 140px; }
  .balloon-pop-game .bap-equation { font-size: 24px; }
  .balloon-pop-game .bap-answer-btn { font-size: 20px; padding: 13px 0; }
}
