/* Shape Pop — Modernized Styles
   Tactile Soap Bubble & Balloon Aesthetic for Young Children (Ages 2-5)
*/

:root {
  --sp-sky-top: #E0F2FE;
  --sp-sky-mid: #F0F9FF;
  --sp-sky-bot: #FEF3C7;
  --sp-bubble-border: rgba(255, 255, 255, 0.85);
  --sp-bubble-shadow: rgba(56, 189, 248, 0.25);
  --sp-card-radius: 20px;
  --sp-accent: #0284C7;
}

/* Container */
.shape-pop-container {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: linear-gradient(180deg, var(--sp-sky-top) 0%, var(--sp-sky-mid) 55%, var(--sp-sky-bot) 100%);
  overflow: hidden;
  padding-top: var(--header-h, 96px);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* Background floating decorative cloud drift */
.sp-bg-clouds {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.sp-cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  filter: blur(2px);
  animation: cloudDrift linear infinite;
}

.sp-cloud::before, .sp-cloud::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 50%;
}

.sp-cloud-1 {
  width: 140px;
  height: 44px;
  top: 14%;
  left: -150px;
  animation-duration: 48s;
}
.sp-cloud-1::before { width: 50px; height: 50px; top: -22px; left: 24px; }
.sp-cloud-1::after { width: 40px; height: 40px; top: -16px; left: 66px; }

.sp-cloud-2 {
  width: 180px;
  height: 52px;
  top: 36%;
  left: -200px;
  animation-duration: 62s;
  animation-delay: -20s;
}
.sp-cloud-2::before { width: 64px; height: 64px; top: -28px; left: 32px; }
.sp-cloud-2::after { width: 54px; height: 54px; top: -22px; left: 88px; }

.sp-cloud-3 {
  width: 120px;
  height: 38px;
  top: 65%;
  left: -140px;
  animation-duration: 54s;
  animation-delay: -35s;
}
.sp-cloud-3::before { width: 44px; height: 44px; top: -20px; left: 20px; }
.sp-cloud-3::after { width: 36px; height: 36px; top: -14px; left: 56px; }

@keyframes cloudDrift {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(100vw + 250px)); }
}

/* Top Bar: Title & Controls */
.sp-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 18px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
  position: relative;
}

.sp-title-box {
  display: flex;
  flex-direction: column;
}

.sp-game-title {
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-size: clamp(1.4rem, 3.8vw, 2.1rem);
  font-weight: 800;
  color: var(--sky, #0284C7);
  line-height: 1.1;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sp-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  animation: gentleFloat 3s ease-in-out infinite;
}

.sp-game-subtitle {
  font-size: clamp(0.78rem, 1.8vw, 0.95rem);
  color: var(--text-muted, #64748B);
  font-weight: 500;
  margin: 2px 0 0 0;
}

/* Action Controls (Mode, Sound, Voice, Reset) */
.sp-controls-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sp-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1.5px solid #CBD5E1;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  touch-action: manipulation;
  min-height: 36px;
}

.sp-pill-btn:hover {
  background: #FFFFFF;
  border-color: #94A3B8;
  transform: translateY(-1px);
}

.sp-pill-btn:active {
  transform: scale(0.94);
}

.sp-pill-btn.muted {
  opacity: 0.55;
  background: #F1F5F9;
  border-color: #E2E8F0;
}

.sp-pill-btn.active-mode {
  background: #0284C7;
  color: #FFFFFF;
  border-color: #0284C7;
  box-shadow: 0 3px 10px rgba(2, 132, 199, 0.35);
}

/* Prompt Card / Mission Banner */
.sp-mission-banner {
  max-width: 720px;
  width: calc(100% - 32px);
  margin: 4px auto 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(226, 232, 240, 0.95);
  border-radius: 18px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 10;
  position: relative;
  flex-shrink: 0;
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.sp-target-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(240, 249, 255, 0.9);
  border: 2px solid #BAE6FD;
  border-radius: 14px;
  padding: 4px 12px;
  box-shadow: inset 0 2px 4px rgba(2, 132, 199, 0.08);
  animation: targetPulse 3s ease-in-out infinite;
}

.sp-target-icon-box {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sp-target-icon-box svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.sp-target-text-group {
  display: flex;
  flex-direction: column;
}

.sp-mission-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #0284C7;
}

.sp-target-name {
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 800;
  color: #0F172A;
  line-height: 1.1;
}

.sp-mission-instruction {
  font-size: clamp(0.85rem, 2vw, 1.05rem);
  font-weight: 600;
  color: #475569;
  text-align: center;
}

/* Play Arena (Soap Bubble Pond / Sky Room) */
.sp-arena {
  flex: 1;
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  overflow: hidden;
  z-index: 5;
  min-height: 0;
  display: block;
  touch-action: none;
}

/* Interactive Floating Shape Bubble */
.sp-bubble {
  position: absolute;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  z-index: 10;
  user-select: none;
  -webkit-user-select: none;
  /* Soap bubble shiny glassy background with translucent reflection */
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0.3) 22%, rgba(224, 242, 254, 0.2) 60%, rgba(186, 230, 253, 0.45) 90%, rgba(125, 211, 252, 0.7) 100%);
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow:
    inset -4px -6px 12px rgba(14, 165, 233, 0.22),
    inset 4px 6px 10px rgba(255, 255, 255, 0.85),
    0 10px 24px rgba(14, 165, 233, 0.18),
    0 3px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.15s cubic-bezier(0.17, 0.67, 0.29, 1.3), opacity 0.25s ease;
  will-change: transform, left, top;
}

/* Specular shiny reflection highlight arcs */
.sp-bubble::before {
  content: '';
  position: absolute;
  top: 10%;
  left: 15%;
  width: 28%;
  height: 18%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.1) 100%);
  transform: rotate(-32deg);
  pointer-events: none;
}

.sp-bubble::after {
  content: '';
  position: absolute;
  bottom: 12%;
  right: 18%;
  width: 14%;
  height: 9%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.sp-bubble:hover {
  transform: scale(1.08);
}

.sp-bubble:active {
  transform: scale(0.92);
}

/* Idle assist glow when child needs help finding target */
.sp-bubble.assist-glow {
  animation: assistGlowPulse 1.2s ease-in-out infinite alternate !important;
}

@keyframes assistGlowPulse {
  0% {
    box-shadow:
      0 0 0 0 rgba(245, 158, 11, 0.7),
      inset -4px -6px 12px rgba(14, 165, 233, 0.22),
      inset 4px 6px 10px rgba(255, 255, 255, 0.85),
      0 10px 24px rgba(14, 165, 233, 0.18);
    transform: scale(1.04);
  }
  100% {
    box-shadow:
      0 0 25px 8px rgba(245, 158, 11, 0.9),
      inset -4px -6px 12px rgba(14, 165, 233, 0.22),
      inset 4px 6px 10px rgba(255, 255, 255, 0.85),
      0 14px 28px rgba(14, 165, 233, 0.25);
    transform: scale(1.14);
  }
}

/* Kawaii Shape SVG Container inside bubble */
.sp-shape-content {
  width: 68%;
  height: 68%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: shapeGentleBreathe 3.5s ease-in-out infinite alternate;
}

@keyframes shapeGentleBreathe {
  0% { transform: scale(0.96); }
  100% { transform: scale(1.03); }
}

.sp-shape-content svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.12));
}

/* Eyes blinking animation */
.sp-eye {
  transform-origin: center;
  animation: cuteBlink 4s ease-in-out infinite;
}

@keyframes cuteBlink {
  0%, 96%, 100% { transform: scaleY(1); }
  98% { transform: scaleY(0.1); }
}

/* Popping explosion state */
.sp-bubble.popping {
  animation: bubbleBurst 0.35s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
  pointer-events: none;
}

@keyframes bubbleBurst {
  0% {
    transform: scale(1);
    opacity: 1;
    filter: brightness(1.2);
  }
  45% {
    transform: scale(1.4);
    opacity: 0.9;
    filter: brightness(1.6);
  }
  100% {
    transform: scale(2);
    opacity: 0;
    filter: brightness(2);
  }
}

/* Wrong shape gentle wobble */
.sp-bubble.wrong-wobble {
  animation: wobbleGentle 0.45s ease;
}

@keyframes wobbleGentle {
  0%, 100% { transform: translateX(0) scale(1); }
  20% { transform: translateX(-8px) rotate(-6deg) scale(0.96); }
  40% { transform: translateX(8px) rotate(6deg) scale(0.96); }
  60% { transform: translateX(-5px) rotate(-3deg) scale(0.98); }
  80% { transform: translateX(4px) rotate(2deg) scale(0.99); }
}

/* Floating Word / Score Badge on Pop */
.sp-pop-toast {
  position: absolute;
  pointer-events: none;
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-weight: 800;
  font-size: 1.3rem;
  color: #0284C7;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #BAE6FD;
  border-radius: 999px;
  padding: 4px 14px;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.25);
  z-index: 100;
  animation: popToastFloat 0.75s ease-out forwards;
}

@keyframes popToastFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6) translateY(0);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15) translateY(-8px);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) translateY(-28px);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9) translateY(-46px);
  }
}

/* Water Splash Ripple Ring on Pop */
.sp-pop-ripple {
  position: absolute;
  border-radius: 50%;
  border: 3px solid rgba(14, 165, 233, 0.65);
  pointer-events: none;
  z-index: 80;
  animation: popRippleExpand 0.55s ease-out forwards;
}

@keyframes popRippleExpand {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.2);
    border-width: 4px;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.8);
    border-width: 1px;
  }
}

/* Bottom Progress & Stats Track */
.sp-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  gap: 16px;
  flex-shrink: 0;
  z-index: 10;
  position: relative;
}

/* Stars track */
.sp-stars-track {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sp-star-badge {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-weight: 700;
  font-size: 0.95rem;
  color: #94A3B8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: all 0.35s cubic-bezier(0.17, 0.67, 0.29, 1.4);
}

.sp-star-badge.completed {
  background: #FEF08A;
  border-color: #F59E0B;
  color: #B45309;
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
  animation: starPopBounce 0.4s ease;
}

.sp-star-badge.active-round {
  border-color: #0284C7;
  color: #0284C7;
  background: #E0F2FE;
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.3);
}

@keyframes starPopBounce {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1.15); }
}

/* Free pop counter pill */
.sp-counter-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid #BAE6FD;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.12);
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-weight: 700;
  font-size: 1rem;
  color: #0284C7;
}

.sp-counter-num {
  font-size: 1.25rem;
  color: #D97706;
  font-weight: 800;
}

/* Status message */
.sp-status-msg {
  font-size: clamp(0.85rem, 2vw, 1rem);
  color: var(--text-muted, #64748B);
  font-weight: 600;
  text-align: right;
  flex: 1;
}

.sp-status-msg .highlight {
  color: #0284C7;
  font-weight: 800;
}

/* Common Keyframe Animations */
@keyframes gentleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes bubbleBob {
  0% { transform: translateY(0); }
  100% { transform: translateY(-12px); }
}

@keyframes targetPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .sp-top-bar {
    padding: 4px 12px;
    gap: 8px;
  }
  .sp-controls-group {
    gap: 6px;
  }
  .sp-pill-btn {
    padding: 5px 9px;
    font-size: 0.76rem;
    min-height: 32px;
  }
  .sp-mission-banner {
    padding: 6px 12px;
    gap: 8px;
  }
  .sp-target-card {
    padding: 3px 8px;
    gap: 6px;
  }
  .sp-target-icon-box {
    width: 36px;
    height: 36px;
  }
  .sp-bottom-bar {
    padding: 6px 12px;
  }
  .sp-star-badge {
    width: 32px;
    height: 32px;
    font-size: 0.82rem;
  }
}

@media (max-height: 600px) {
  .sp-mission-banner {
    margin: 2px auto 4px;
    padding: 4px 10px;
  }
  .sp-top-bar {
    padding: 2px 14px;
  }
  .sp-bottom-bar {
    padding: 4px 14px;
  }
}
