/* MISSION COMPANION & HEADER */
.mission-header {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-bg-card);
  padding: 8px 14px;
  border-radius: var(--border-radius-md);
  border: 2px solid var(--color-border);
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: visible;
}

#mission-companion-bubble {
  position: absolute;
  top: -65px;
  left: 20px;
  background: var(--color-primary);
  color: white;
  padding: 8px 15px;
  border-radius: var(--border-radius-md);
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(10px) scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 100;
}

#mission-companion-bubble.active {
  opacity: 1;
  transform: translateY(0) scale(1);
}

#mission-companion-bubble::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 25px;
  border-width: 8px 8px 0;
  border-style: solid;
  border-color: var(--color-primary) transparent;
  display: block;
  width: 0;
}

.companion-avatar {
  font-size: 1.8rem;
}

.companion-message {
  font-size: 0.95rem;
}

.mission-copy {
  flex: 1;
}

.mission-title {
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--color-primary);
  margin: 0 0 4px 0;
}

.mission-goal {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0;
  font-weight: 700;
}

.mission-progress {
  font-weight: 900;
  font-size: 1rem;
  color: var(--color-text-main);
  background: var(--color-bg-alt);
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
}

/* COMPANION CHOICE OVERLAY */
.companion-choice-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 10000;
}

.choice-card {
  background: #ffffff;
  color: #1e293b;
  padding: 35px 30px;
  border-radius: var(--border-radius-lg);
  border: 3px solid var(--color-primary);
  max-width: 580px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

body.dark-mode .choice-card {
  background: #1e1e2f;
  color: #f7fafc;
}

.companion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 15px;
  margin: 20px 0;
}

.companion-select-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #f8fafc;
  color: #1e293b;
  border: 3px solid #e2e8f0;
  border-radius: var(--border-radius-md);
  padding: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
}

body.dark-mode .companion-select-btn {
  background: #2d2d44;
  color: #f7fafc;
  border-color: #3f3f5a;
}

.companion-select-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  border-color: var(--color-primary);
}

.companion-select-btn.selected {
  border-color: var(--color-primary) !important;
  background: rgba(108, 92, 231, 0.15);
  box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.3);
}

body.dark-mode .companion-select-btn.selected {
  background: rgba(143, 130, 255, 0.2);
  box-shadow: 0 0 0 4px rgba(143, 130, 255, 0.4);
}

.comp-icon {
  font-size: 2.8rem;
  margin-bottom: 8px;
}

.comp-name {
  font-weight: 900;
  font-size: 0.95rem;
}

/* CELEBRATION EFFECT (CONFETTI) */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  top: -20px;
  animation: fall 1.5s linear forwards;
}

@keyframes fall {
  to {
    transform: translateY(105vh) rotate(360deg);
  }
}

/* REDUCED MOTION SAFEGUARDS */
@media (prefers-reduced-motion: reduce) {
  .confetti-piece {
    animation: none;
    display: none;
  }
  .companion-select-btn:hover {
    transform: none;
  }
}

.flash-effect {
  animation: static-flash 0.5s ease-in-out;
}

@keyframes static-flash {
  0% { outline: 5px solid var(--color-primary); }
  100% { outline: 0px solid transparent; }
}

/* FEEDBACK AREA DESIGN */
.engagement-feedback-text {
  padding: 8px 12px;
  border-radius: var(--border-radius-md);
  font-weight: 800;
  text-align: center;
  font-size: 1rem;
  margin-top: 8px;
  animation: slideUp 0.3s ease;
}

.engagement-feedback-text.success {
  background: #ecfdf5;
  color: #065f46;
  border: 2px solid #a7f3d0;
}

.engagement-feedback-text.retry {
  background: #fffbeb;
  color: #92400e;
  border: 2px solid #fde68a;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   CORRECT ANSWER CELEBRATION & SUCCESS FEEDBACK SYSTEM
   ========================================================================== */

/* 1. ANSWER CARD SUCCESS REACTION */
.correct-answer-active,
.option-card.correct-answer-active,
.option-card.selected.correct-answer-active {
  border: 3px solid #2ecc71 !important;
  background: rgba(46, 204, 113, 0.15) !important;
  box-shadow: 0 8px 28px rgba(46, 204, 113, 0.4), 0 0 0 4px rgba(46, 204, 113, 0.25) !important;
  position: relative !important;
  animation: cardBouncePop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
  z-index: 5 !important;
}

body.dark-mode .correct-answer-active,
body.dark-mode .option-card.correct-answer-active,
body.dark-mode .option-card.selected.correct-answer-active {
  background: rgba(46, 204, 113, 0.25) !important;
  border-color: #2ecc71 !important;
  box-shadow: 0 8px 28px rgba(46, 204, 113, 0.5), 0 0 0 4px rgba(46, 204, 113, 0.3) !important;
}

@keyframes cardBouncePop {
  0% { transform: scale(1); }
  35% { transform: scale(1.06); }
  70% { transform: scale(0.98); }
  100% { transform: scale(1); }
}

/* Faded unselected cards */
.option-card-faded {
  opacity: 0.45 !important;
  filter: grayscale(30%) !important;
  pointer-events: none !important;
  transition: opacity 0.4s ease, filter 0.4s ease;
}

/* Success Checkmark Spring Badge */
.success-checkmark-badge {
  position: absolute;
  top: -12px;
  right: -12px;
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.5);
  animation: checkmarkSpring 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.4) forwards;
  z-index: 10;
}

[dir="rtl"] .success-checkmark-badge {
  right: auto;
  left: -12px;
}

@keyframes checkmarkSpring {
  0% { transform: scale(0) rotate(-45deg); opacity: 0; }
  70% { transform: scale(1.25) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Sparkle particles around card */
.card-sparkle-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f1c40f;
  pointer-events: none;
  animation: sparklePop 0.6s ease-out forwards;
}

@keyframes sparklePop {
  0% { transform: scale(0); opacity: 1; }
  100% { transform: scale(2) translateY(-15px); opacity: 0; }
}

/* 2. FESTIVAL CELEBRATION OVERLAY & PARTICLES */
#festival-celebration-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  pointer-events: none !important;
  overflow: visible !important;
  z-index: 999999 !important;
}

.flank-celebration-item {
  position: fixed !important;
  font-size: 4.2rem;
  pointer-events: none;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.25));
  will-change: transform, opacity;
  z-index: 999999 !important;
  animation: flankBopFloat 2.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes flankBopFloat {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(0deg);
    opacity: 0;
  }
  15% {
    transform: translate(-50%, -50%) scale(1.35) rotate(-10deg);
    opacity: 1;
  }
  38% {
    transform: translate(calc(-50% + 14px), calc(-50% - 22px)) scale(1.1) rotate(14deg);
    opacity: 1;
  }
  60% {
    transform: translate(calc(-50% - 14px), calc(-50% - 44px)) scale(1.28) rotate(-12deg);
    opacity: 1;
  }
  85% {
    transform: translate(calc(-50% + 10px), calc(-50% - 66px)) scale(1.12) rotate(8deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, calc(-50% - 90px)) scale(0.3) rotate(-5deg);
    opacity: 0;
  }
}

@keyframes balloonFloatUpStream {
  0% {
    transform: translateY(0) scale(0.5) rotate(0deg);
    opacity: 1;
  }
  45% {
    transform: translateY(-50vh) scale(1.3) rotate(14deg);
    opacity: 1;
  }
  85% {
    transform: translateY(-90vh) scale(1.45) rotate(-14deg);
    opacity: 1;
  }
  100% {
    transform: translateY(-125vh) scale(1.6) rotate(10deg);
    opacity: 0;
  }
}

@keyframes balloonFloatDownStream {
  0% {
    transform: translateY(0) scale(0.5) rotate(0deg);
    opacity: 1;
  }
  45% {
    transform: translateY(45vh) scale(1.3) rotate(-16deg);
    opacity: 1;
  }
  85% {
    transform: translateY(85vh) scale(1.45) rotate(16deg);
    opacity: 1;
  }
  100% {
    transform: translateY(120vh) scale(1.6) rotate(-12deg);
    opacity: 0;
  }
}

.festival-particle {
  position: absolute;
  pointer-events: none;
  will-change: transform, opacity;
}

.festival-confetti {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  animation: festivalFly 1.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.festival-star {
  font-size: 1.6rem;
  animation: festivalStarFly 1.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes festivalFly {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
  70% {
    opacity: 0.9;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(0.6);
    opacity: 0;
  }
}

@keyframes festivalStarFly {
  0% {
    transform: translate(0, 0) scale(0.4) rotate(0deg);
    opacity: 0;
  }
  30% {
    opacity: 1;
    transform: translate(calc(var(--dx) * 0.4), calc(var(--dy) * 0.4)) scale(1.3) rotate(90deg);
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(0.7) rotate(240deg);
    opacity: 0;
  }
}

.festival-balloon {
  position: fixed !important;
  font-size: 3.5rem;
  pointer-events: none;
  will-change: transform, opacity;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.22));
  z-index: 999999 !important;
}

.festival-balloon-burst {
  position: fixed !important;
  font-size: 3.8rem;
  pointer-events: none;
  will-change: transform, opacity;
  animation: balloonBurst 2.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.25));
  z-index: 999999 !important;
}

@keyframes balloonBurst {
  0% {
    transform: translate(-50%, -50%) scale(0.2) rotate(0deg);
    opacity: 0.2;
  }
  15% {
    transform: translate(-50%, -50%) scale(1.1) rotate(-8deg);
    opacity: 1;
  }
  50% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.4) rotate(14deg);
    opacity: 1;
  }
  85% {
    transform: translate(calc(-50% + var(--dx) * 1.3), calc(-50% + var(--dy) - 140px)) scale(1.55) rotate(-14deg);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx) * 1.5), calc(-50% + var(--dy) - 240px)) scale(1.7) rotate(20deg);
    opacity: 0;
  }
}

.festival-balloon-up {
  bottom: -80px;
  animation: floatUpBalloon 2.4s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

.festival-balloon-down {
  top: 0px !important;
  animation: floatDownBalloon 2.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes floatUpBalloon {
  0% {
    transform: translateY(0) scale(0.5) rotate(0deg);
    opacity: 1;
  }
  45% {
    transform: translateY(-45vh) scale(1.3) rotate(14deg);
    opacity: 1;
  }
  85% {
    transform: translateY(-90vh) scale(1.45) rotate(-14deg);
    opacity: 1;
  }
  100% {
    transform: translateY(-125vh) scale(1.6) rotate(10deg);
    opacity: 0;
  }
}

@keyframes floatDownBalloon {
  0% {
    transform: translateY(-20px) scale(0.5) rotate(0deg);
    opacity: 1;
  }
  45% {
    transform: translateY(45vh) scale(1.3) rotate(-16deg);
    opacity: 1;
  }
  85% {
    transform: translateY(85vh) scale(1.45) rotate(16deg);
    opacity: 1;
  }
  100% {
    transform: translateY(120vh) scale(1.6) rotate(-12deg);
    opacity: 0;
  }
}

/* 3. HAPPY ANIMAL MASCOT REACTION */
.mascot-celebrate {
  animation: mascotJoyfulJump 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) ease-in-out infinite alternate !important;
}

@keyframes mascotJoyfulJump {
  0% { transform: translateY(0) scale(1, 1); }
  25% { transform: translateY(4px) scale(1.14, 0.86); }
  50% { transform: translateY(-20px) scale(0.9, 1.15) rotate(-3deg); }
  75% { transform: translateY(-8px) scale(1.06, 0.95) rotate(3deg); }
  100% { transform: translateY(0) scale(1, 1); }
}

.mascot-sparkle-aura {
  position: absolute;
  top: -10px;
  right: -10px;
  font-size: 1.2rem;
  pointer-events: none;
  animation: floatMascotStar 1.2s ease-out forwards;
}

@keyframes floatMascotStar {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  50% { opacity: 1; transform: translateY(-15px) scale(1.2); }
  100% { transform: translateY(-30px) scale(0.8); opacity: 0; }
}

/* 5. SUCCESS FEEDBACK PANEL SPRING */
#panel-feedback-correct.celebrate-slide {
  animation: feedbackSpringUp 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.2) forwards;
}

@keyframes feedbackSpringUp {
  0% { opacity: 0; transform: translateY(16px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.success-title-rotating {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.2rem;
  font-weight: 900;
}

/* 6. STAR / SCORE REWARD FLYING ANIMATION */
.reward-flying-star {
  position: fixed;
  font-size: 2rem;
  z-index: 10000;
  pointer-events: none;
  transition: transform 0.75s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.75s ease;
  filter: drop-shadow(0 0 12px #f1c40f);
}

.star-counter-pop {
  animation: starCounterPulse 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.3) forwards;
}

@keyframes starCounterPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.38); box-shadow: 0 0 22px #fdcb6e; background: #fff3bf; }
  100% { transform: scale(1); }
}

/* 7. PROGRESS REACTION */
.step-dot-success-glow {
  animation: stepDotPulse 0.8s ease-in-out;
}

@keyframes stepDotPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.45); background: #2ecc71 !important; box-shadow: 0 0 14px #2ecc71; }
  100% { transform: scale(1); }
}

/* 8. NEXT BUTTON INVITING PULSE */
.btn-next-inviting-pulse {
  animation: invitingPulse 1.6s ease-in-out infinite;
}

@keyframes invitingPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 12px rgba(253, 203, 110, 0.4); }
  50% { transform: scale(1.05); box-shadow: 0 8px 24px rgba(253, 203, 110, 0.7); }
}

/* 11. REDUCED MOTION SAFEGUARDS OVERRIDES */
body.reduced-motion .correct-answer-active,
@media (prefers-reduced-motion: reduce) {
  .correct-answer-active {
    animation: none !important;
  }
  .success-checkmark-badge {
    animation: none !important;
    transform: scale(1) !important;
    opacity: 1 !important;
  }
  .mascot-celebrate {
    animation: none !important;
  }
  .festival-confetti,
  .festival-star,
  .reward-flying-star {
    animation: none !important;
    display: none !important;
  }
  .star-counter-pop,
  .step-dot-success-glow,
  .btn-next-inviting-pulse {
    animation: none !important;
  }
}

/* ==========================================================================
   ANSWER OPTION FEEDBACK & REVEAL SYSTEM (WRONG IN RED / CORRECT IN GREEN)
   ========================================================================== */

/* WRONG ANSWER HIGHLIGHT (RED) */
.wrong-answer-active,
.option-card.wrong-answer-active,
.option-card.option-wrong,
.sort-item.wrong-answer-active,
.match-node.wrong-answer-active {
  border: 3px solid #e74c3c !important;
  background: rgba(231, 76, 60, 0.15) !important;
  box-shadow: 0 6px 20px rgba(231, 76, 60, 0.3), 0 0 0 3px rgba(231, 76, 60, 0.2) !important;
  position: relative !important;
  z-index: 5 !important;
  animation: wrongCardShake 0.4s ease !important;
}

.option-card.wrong-answer-active .option-text,
.option-card.option-wrong .option-text {
  color: #c0392b !important;
}

body.dark-mode .wrong-answer-active,
body.dark-mode .option-card.wrong-answer-active,
body.dark-mode .option-card.option-wrong {
  background: rgba(231, 76, 60, 0.28) !important;
  border-color: #ff6b6b !important;
  box-shadow: 0 6px 20px rgba(231, 76, 60, 0.45), 0 0 0 3px rgba(231, 76, 60, 0.3) !important;
}
body.dark-mode .option-card.wrong-answer-active .option-text,
body.dark-mode .option-card.option-wrong .option-text {
  color: #ff8787 !important;
}

/* CORRECT REVEAL HIGHLIGHT (GREEN) */
.correct-answer-reveal,
.option-card.correct-answer-reveal,
.option-card.option-correct,
.sort-item.correct-answer-reveal,
.match-node.correct-answer-reveal {
  border: 3px solid #2ecc71 !important;
  background: rgba(46, 204, 113, 0.18) !important;
  box-shadow: 0 8px 28px rgba(46, 204, 113, 0.4), 0 0 0 4px rgba(46, 204, 113, 0.25) !important;
  position: relative !important;
  z-index: 6 !important;
  animation: cardBouncePop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
}

.option-card.correct-answer-reveal .option-text,
.option-card.option-correct .option-text {
  color: #1e7e34 !important;
}

body.dark-mode .correct-answer-reveal,
body.dark-mode .option-card.correct-answer-reveal,
body.dark-mode .option-card.option-correct {
  background: rgba(46, 204, 113, 0.3) !important;
  border-color: #2ecc71 !important;
}
body.dark-mode .option-card.correct-answer-reveal .option-text,
body.dark-mode .option-card.option-correct .option-text {
  color: #a3e635 !important;
}

/* BADGES FOR OPTION CARDS */
.option-card .answer-status-badge,
.match-node .answer-status-badge {
  position: absolute;
  top: -12px;
  right: 12px;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 800;
  font-family: var(--font-kids);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  animation: badgePopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.answer-status-badge.wrong-badge {
  background: #e74c3c;
  color: #ffffff;
  border: 1px solid #c0392b;
}

.answer-status-badge.correct-badge {
  background: #2ecc71;
  color: #ffffff;
  border: 1px solid #27ae60;
}

/* TEXT INPUT & DISPLAY BANNERS FOR COMPLETING/ORDERING */
.input-complete-wrong {
  border: 3px solid #e74c3c !important;
  background: rgba(231, 76, 60, 0.1) !important;
  color: #c0392b !important;
  box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.2) !important;
}

.correct-answer-reveal-banner {
  margin-top: 15px;
  padding: 12px 18px;
  background: rgba(46, 204, 113, 0.15);
  border: 2px solid #2ecc71;
  border-radius: 16px;
  color: #1e7e34;
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  animation: fadeIn 0.3s ease-in-out;
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.2);
}
body.dark-mode .correct-answer-reveal-banner {
  background: rgba(46, 204, 113, 0.25);
  color: #a3e635;
}

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

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


