/* ===================================================================
   Soap Bubble Magic - Primary Stylesheet
   Designed for Speech Therapy, Accessibility & Child Comfort
   =================================================================== */

:root {
  --primary: #8E24AA;
  --primary-light: #BA68C8;
  --accent: #FF4081;
  --gold: #FFD54F;
  --sky-top: #E1F5FE;
  --sky-bottom: #FFF9C4;
  --grass-top: #C8E6C9;
  --grass-bottom: #81C784;
  --card-bg: rgba(255, 255, 255, 0.94);
  --text-main: #263238;
  --text-muted: #546E7A;
  --font-family: 'Comic Neue', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  background: #E1F5FE;
}

.game-viewport {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ================= Scenery & Background ================= */
.scenery {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #B3E5FC 0%, #E1F5FE 50%, #FFF9C4 75%, #C8E6C9 100%);
  z-index: 1;
}

.sun {
  position: absolute;
  top: 35px;
  right: 60px;
  width: 90px;
  height: 90px;
  background: radial-gradient(circle, #FFF59D 0%, #FFD54F 70%, rgba(255,213,79,0) 100%);
  border-radius: 50%;
  box-shadow: 0 0 45px #FFD54F;
  opacity: 0.9;
  animation: sunPulse 6s ease-in-out infinite alternate;
}

.cloud {
  position: absolute;
  background: #FFFFFF;
  border-radius: 50px;
  opacity: 0.82;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.04));
}

.cloud-1 {
  top: 70px;
  left: 8%;
  width: 140px;
  height: 45px;
  animation: cloudDrift 42s linear infinite;
}
.cloud-1::before {
  content: '';
  position: absolute;
  top: -22px;
  left: 25px;
  width: 55px;
  height: 55px;
  background: #FFFFFF;
  border-radius: 50%;
}
.cloud-1::after {
  content: '';
  position: absolute;
  top: -15px;
  left: 65px;
  width: 45px;
  height: 45px;
  background: #FFFFFF;
  border-radius: 50%;
}

.cloud-2 {
  top: 130px;
  left: 55%;
  width: 180px;
  height: 55px;
  animation: cloudDrift 55s linear infinite;
}
.cloud-2::before {
  content: '';
  position: absolute;
  top: -28px;
  left: 30px;
  width: 70px;
  height: 70px;
  background: #FFFFFF;
  border-radius: 50%;
}

/* Rolling gentle hills at bottom */
.hill-back {
  position: absolute;
  bottom: 0;
  left: -10%;
  width: 120%;
  height: 180px;
  background: linear-gradient(180deg, #A5D6A7 0%, #81C784 100%);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  opacity: 0.85;
}

.hill-front {
  position: absolute;
  bottom: 0;
  left: -5%;
  width: 110%;
  height: 120px;
  background: linear-gradient(180deg, #C8E6C9 0%, #A5D6A7 100%);
  border-radius: 60% 40% 0 0 / 100% 100% 0 0;
}

/* Flowers on grass */
.flower {
  position: absolute;
  bottom: 40px;
  font-size: 24px;
  opacity: 0.85;
}
.flower-1 { left: 8%; bottom: 65px; font-size: 26px; }
.flower-2 { left: 22%; bottom: 45px; font-size: 20px; }
.flower-3 { left: 58%; bottom: 50px; font-size: 28px; }
.flower-4 { left: 82%; bottom: 70px; font-size: 24px; }

/* ================= Canvas for Soap Bubbles ================= */
#bubbleCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  cursor: pointer;
}

/* ================= Girl Character Container ================= */
.girl-wrapper {
  position: absolute;
  bottom: 45px;
  left: 6%;
  width: 280px;
  height: 420px;
  z-index: 15;
  pointer-events: none;
  transition: transform 0.3s ease;
}

@media (max-width: 768px) {
  .girl-wrapper {
    left: 2%;
    width: 220px;
    height: 330px;
    bottom: 30px;
  }
}

.girl-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 12px 20px rgba(0,0,0,0.12));
}

/* Girl CSS Animations */
.girl-svg.state-idle .girl-body {
  animation: girlBreathe 3.5s ease-in-out infinite alternate;
  transform-origin: 140px 340px;
}

.girl-svg.state-idle .girl-head {
  animation: girlHeadTilt 4.2s ease-in-out infinite alternate;
  transform-origin: 140px 195px;
}

.girl-svg.state-blowing .girl-right-arm {
  transform: translateY(-8px) rotate(-6deg);
  transform-origin: 170px 225px;
  transition: transform 0.25s ease-out;
}

.girl-svg.state-blowing .cheek {
  transform: scale(1.35);
  transition: transform 0.2s ease;
  transform-origin: center;
}

.girl-svg.state-celebrating {
  animation: girlCheerJump 0.65s ease-in-out infinite alternate;
  transform-origin: 140px 435px;
}

.wand-film {
  animation: wandShimmer 2.4s ease-in-out infinite alternate;
}

/* ================= Top HUD Bar ================= */
.top-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 25;
  pointer-events: none;
}

.hud-pill {
  pointer-events: auto;
  background: var(--card-bg);
  padding: 8px 18px;
  border-radius: 24px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);
  border: 2px solid rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-title-badge {
  font-size: 20px;
  font-weight: 900;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.3px;
}

.bubble-counter {
  font-size: 22px;
  font-weight: 800;
  color: #0277BD;
  background: #E1F5FE;
  padding: 6px 18px;
  border-radius: 20px;
  border: 2px solid #81D4FA;
}

.mic-chip {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.mic-chip.active {
  color: #2E7D32;
  background: #E8F5E9;
  border-color: #A5D6A7;
}

/* ================= Speech Bubble Prompt ================= */
.speech-bubble {
  position: absolute;
  bottom: 390px;
  left: 14%;
  background: #FFFFFF;
  border: 4px solid #B388FF;
  border-radius: 24px;
  padding: 14px 24px;
  box-shadow: 0 10px 25px rgba(106, 27, 154, 0.15);
  z-index: 20;
  max-width: 420px;
  animation: promptFloat 3s ease-in-out infinite alternate;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -16px;
  left: 45px;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 16px solid #B388FF;
}

.prompt-text {
  font-size: 19px;
  font-weight: 800;
  color: #4A148C;
  line-height: 1.35;
  text-align: center;
}

@media (max-width: 768px) {
  .speech-bubble {
    bottom: 320px;
    left: 6%;
    padding: 10px 16px;
    max-width: 320px;
  }
  .prompt-text {
    font-size: 16px;
  }
}

/* ================= Bottom Bar ================= */
.bottom-bar {
  position: absolute;
  bottom: 14px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  z-index: 25;
}

.hud-btn {
  background: var(--card-bg);
  border: 2px solid rgba(255,255,255,0.9);
  padding: 8px 16px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s ease, background 0.2s;
}

.hud-btn:hover {
  transform: translateY(-2px);
  background: #FFFFFF;
}

.license-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 14px;
}

.license-badge.active {
  background: #E8F5E9;
  color: #1B5E20;
  border: 1px solid #A5D6A7;
}

.license-badge.trial {
  background: #FFF3E0;
  color: #E65100;
  border: 1px solid #FFE082;
}

/* ================= Victory Banner ================= */
.victory-banner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.victory-banner.show {
  opacity: 1;
  pointer-events: auto;
}

.victory-card {
  background: linear-gradient(135deg, #FFFFFF 0%, #FFFDE7 100%);
  border: 6px solid #FFD54F;
  border-radius: 36px;
  padding: 36px 48px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  max-width: 520px;
  animation: bannerPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.victory-title {
  font-size: 38px;
  font-weight: 900;
  color: #E65100;
  margin-bottom: 12px;
}

.victory-desc {
  font-size: 19px;
  color: #455A64;
  margin-bottom: 26px;
  line-height: 1.4;
}

.victory-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.btn-play-again {
  background: linear-gradient(180deg, #4CAF50 0%, #2E7D32 100%);
  color: #FFFFFF;
  font-size: 20px;
  font-weight: 800;
  padding: 14px 34px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(46, 125, 50, 0.4);
  transition: transform 0.15s;
}

.btn-play-again:hover {
  transform: translateY(-2px) scale(1.03);
}

.btn-finish {
  background: #ECEFF1;
  color: #37474F;
  font-size: 18px;
  font-weight: 700;
  padding: 14px 26px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-finish:hover {
  background: #CFD8DC;
}

/* ================= Modals ================= */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-window {
  background: #FFFFFF;
  width: 90%;
  max-width: 520px;
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.25);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid #ECEFF1;
  padding-bottom: 10px;
}

.modal-title {
  font-size: 20px;
  font-weight: 800;
  color: #263238;
}

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #78909C;
  cursor: pointer;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #37474F;
  margin-bottom: 6px;
}

.form-help {
  font-size: 12px;
  color: #78909C;
  margin-top: 4px;
  line-height: 1.4;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-container input[type="range"] {
  flex: 1;
  accent-color: #8E24AA;
}

.meter-wrapper {
  position: relative;
  width: 100%;
  height: 16px;
  background: #E0E0E0;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 6px;
}

.mic-bar {
  height: 100%;
  width: 0%;
  background: #4CAF50;
  transition: width 0.05s linear;
}

.mic-bar.active {
  background: #FF9800;
}

.threshold-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #D32F2F;
}

.select-input, .text-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #CFD8DC;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  outline: none;
}

.select-input:focus, .text-input:focus {
  border-color: #8E24AA;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #37474F;
  cursor: pointer;
}

.action-btn {
  background: linear-gradient(135deg, #8E24AA 0%, #6A1B9A 100%);
  color: #FFFFFF;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(106, 27, 154, 0.25);
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(106, 27, 154, 0.35);
}

.action-btn.secondary {
  background: #ECEFF1;
  color: #37474F;
  box-shadow: none;
}

.action-btn.secondary:hover {
  background: #CFD8DC;
}

.status-msg {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
  display: none;
}

.status-msg.success {
  display: block;
  background: #E8F5E9;
  color: #2E7D32;
}

.status-msg.error {
  display: block;
  background: #FFEBEE;
  color: #C62828;
}

.status-msg.info {
  display: block;
  background: #E1F5FE;
  color: #0277BD;
}
