* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: #f2f4f8; }

.bab-outer {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.bab-container {
  width: 100%;
  max-width: 760px;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 45px rgba(0,0,0,0.15);
}

/* ---------- Header ---------- */
.bab-header {
  background: #1c4e9e;
  color: #fff;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.bab-instruction { font-size: 13px; font-weight: 600; }
.bab-header-right { display: flex; align-items: center; gap: 14px; }
.bab-progress, .bab-life { font-size: 13px; font-weight: 700; }
.bab-home-btn {
  background: #2ecc71; color: #fff; border: none; border-radius: 20px; padding: 6px 18px;
  font-size: 13px; font-weight: 700; cursor: pointer;
}

/* ---------- Scene (outdoor cartoon background) ---------- */
.bab-scene {
  background: linear-gradient(#bfe3fb 0%, #bfe3fb 55%, #8fd68a 55%, #6fc562 100%);
  padding: 24px 20px 0;
  min-height: 460px;
  position: relative;
}

.bab-loading, .bab-warning {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; gap: 14px; color: #3a3a3a;
}
.bab-spinner {
  width: 36px; height: 36px; border: 4px solid #cfe8ff; border-top-color: #1c4e9e;
  border-radius: 50%; animation: bab-spin 0.8s linear infinite;
}
@keyframes bab-spin { to { transform: rotate(360deg); } }
.bab-warning-icon { font-size: 40px; }

/* ---------- Question panel ---------- */
.bab-question-panel {
  background: #ff9f1c;
  border-radius: 16px;
  padding: 22px 24px;
  text-align: center;
  color: #fff;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}
.bab-fill-label { font-size: 15px; font-weight: 600; margin-bottom: 6px; opacity: 0.95; }
.bab-question-text { font-size: 26px; font-weight: 800; word-wrap: break-word; }

.bab-feedback {
  text-align: center; font-size: 15px; font-weight: 700; padding: 10px; border-radius: 10px; margin-top: 14px;
}
.bab-feedback-correct { background: rgba(46,204,113,0.9); color: #fff; }
.bab-feedback-incorrect { background: rgba(231,76,60,0.9); color: #fff; }

/* ---------- Balloon answers ---------- */
.bab-balloons {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 26px;
  flex-wrap: wrap;
}
.bab-balloon {
  background: #ff9f1c;
  border: 3px solid #d97e0a;
  border-radius: 14px;
  padding: 20px 10px;
  min-width: 90px;
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.bab-balloon:hover { transform: scale(1.06); box-shadow: 0 8px 16px rgba(0,0,0,0.2); }
.bab-balloon.selected { background: #5b8def; border-color: #3f6fd8; }
.bab-balloon.correct { background: #2ecc71; border-color: #23a35e; animation: bab-bounce 0.4s; }
.bab-balloon.incorrect { background: #e74c3c; border-color: #c0392b; animation: bab-shake 0.4s; }
.bab-balloon:disabled, .bab-balloon.disabled { cursor: default; opacity: 0.85; }
@keyframes bab-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes bab-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ---------- Ground decoration ---------- */
.bab-ground {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 30px;
  padding-bottom: 14px;
  font-size: 40px;
}
.bab-kid { opacity: 0.9; }

/* ---------- Result screen ---------- */
.bab-result { text-align: center; padding: 60px 30px; background: #fff; }
.bab-result-icon { font-size: 56px; margin-bottom: 8px; }
.bab-result h2 { margin: 0 0 8px; color: #2f3542; }
.bab-result p { color: #6b6b6b; margin: 0 0 20px; }
.bab-result-stats { display: flex; justify-content: center; gap: 30px; margin-bottom: 26px; }
.bab-result-stats span { display: block; font-size: 26px; font-weight: 800; color: #ff9f1c; }
.bab-result-stats small { color: #999; font-size: 12px; }
.bab-result-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

.bab-btn {
  border: none; border-radius: 12px; padding: 12px 26px; font-size: 14px; font-weight: 700;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.bab-btn-primary { background: #2ecc71; color: #fff; }
.bab-btn-secondary { background: #5b8def; color: #fff; }

/* ---------- Home confirmation modal ---------- */
.bab-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.bab-modal {
  background: #fff; border-radius: 16px; padding: 26px 24px; max-width: 340px; text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.bab-modal p { font-size: 15px; font-weight: 600; color: #2f3542; margin: 0 0 18px; }
.bab-modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .bab-outer { padding: 10px; }
  .bab-container { border-radius: 12px; }
  .bab-header { padding: 10px 12px; }
  .bab-instruction { flex-basis: 100%; text-align: center; order: 1; font-size: 11px; }
  .bab-header-right { order: 2; margin: 0 auto; }
  .bab-progress, .bab-life { font-size: 12px; }

  .bab-scene { padding: 16px 12px 0; min-height: 400px; }
  .bab-question-panel { padding: 16px 14px; }
  .bab-question-text { font-size: 19px; }

  .bab-balloons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
  .bab-balloon { min-width: 0; font-size: 20px; padding: 18px 8px; }

  .bab-ground { gap: 18px; font-size: 30px; }
}
