* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport - avoids iOS browser chrome */
  overflow: hidden;
  background: linear-gradient(180deg, #ffe4ec 0%, #fff0f5 40%, #fce4ec 100%);
  user-select: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Start Screen */
#start-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  text-align: center;
  position: relative;
}

#start-hearts {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.start-heart {
  position: absolute;
  bottom: -30px;
  font-size: 1.5rem;
  opacity: 0.6;
  animation: floatUp 6s ease-in infinite;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.6;
  }
  100% {
    transform: translateY(-110vh) rotate(360deg);
    opacity: 0.2;
  }
}

.game-title {
  font-size: clamp(1.8rem, 5vw, 3rem);
  color: #c71585;
  margin-bottom: 24px;
  text-shadow: 2px 2px 4px rgba(199, 21, 133, 0.2);
  animation: titlePulse 2s ease-in-out infinite;
}

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

.intro-message {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: #8b4789;
  margin-bottom: 32px;
  max-width: 400px;
  line-height: 1.6;
}

.btn {
  padding: 14px 32px;
  font-size: 1.2rem;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, #ff69b4, #db7093);
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(219, 112, 147, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(219, 112, 147, 0.5);
}

.btn:active {
  transform: translateY(0);
}

/* Game Screen */
.hidden {
  display: none !important;
}

#game-screen {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

#score-display,
#lives-display {
  position: absolute;
  top: 16px;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 600;
  color: #8b4789;
  z-index: 10;
}

#score-display {
  left: 16px;
}

#lives-display {
  right: 16px;
}

#lives-display.warning {
  color: #c71585;
  animation: blink 0.5s ease-in-out 3;
}

/* Catch burst effect */
#catch-burst {
  position: fixed;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 90;
}

.burst-piece {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 18px;
  opacity: 0;
}

.burst-piece:nth-child(1) { animation: burstOut1 0.55s ease-out forwards; }
.burst-piece:nth-child(2) { animation: burstOut2 0.55s ease-out forwards; }
.burst-piece:nth-child(3) { animation: burstOut3 0.55s ease-out forwards; }
.burst-piece:nth-child(4) { animation: burstOut4 0.55s ease-out forwards; }
.burst-piece:nth-child(5) { animation: burstOut5 0.55s ease-out forwards; }
.burst-piece:nth-child(6) { animation: burstOut6 0.55s ease-out forwards; }
.burst-piece:nth-child(7) { animation: burstOut7 0.55s ease-out forwards; }
.burst-piece:nth-child(8) { animation: burstOut8 0.55s ease-out forwards; }

@keyframes burstOut1 { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -95px) scale(0.4); } }
@keyframes burstOut2 { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(calc(-50% + 32px), calc(-50% - 32px)) scale(0.4); } }
@keyframes burstOut3 { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(0px, -95px) scale(0.4); } }
@keyframes burstOut4 { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(32px, calc(-50% - 32px)) scale(0.4); } }
@keyframes burstOut5 { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -5px) scale(0.4); } }
@keyframes burstOut6 { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(calc(-50% - 32px), calc(-50% - 32px)) scale(0.4); } }
@keyframes burstOut7 { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-100px, -50px) scale(0.4); } }
@keyframes burstOut8 { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(calc(-50% + 32px), calc(-50% - 32px)) scale(0.4); } }

@keyframes blink {
  50% { opacity: 0.5; }
}

#game-area {
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  background: linear-gradient(180deg, transparent 0%, rgba(255, 228, 225, 0.3) 100%);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

#basket {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 50px;
  background: linear-gradient(180deg, #ffb6c1 0%, #ff69b4 100%);
  border-radius: 0 0 40px 40px;
  box-shadow: 0 4px 12px rgba(199, 21, 133, 0.3);
  border: 3px solid #db7093;
  transition: left 0.05s ease-out;
  z-index: 5;
}

#basket::before {
  content: '';
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 20px;
  border: 3px solid #db7093;
  border-bottom: none;
  border-radius: 30px 30px 0 0;
  background: transparent;
}

.heart {
  position: absolute;
  font-size: 28px;
  top: 0;
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(199, 21, 133, 0.3));
  transition: transform 0.1s ease-out;
}

.heart.special {
  font-size: 32px;
  animation: wiggle 0.6s ease-in-out infinite;
}

/* Glitter heart – carries "For you a thousand times over" at 250 score */
.heart.glitter-heart {
  font-size: 36px;
  animation: wiggle 0.6s ease-in-out infinite, glitterPulse 1.5s ease-in-out infinite;
  filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.9)) drop-shadow(0 0 16px rgba(255, 105, 180, 0.7));
}

@keyframes glitterPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

/* Floating message when heart caught */
#floating-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(199, 21, 133, 0.3);
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  color: #c71585;
  z-index: 100;
  animation: floatMsg 1.5s ease-out forwards;
  pointer-events: none;
  text-align: center;
  max-width: 90%;
}

@keyframes floatMsg {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(1);
  }
}

/* Game Over Screen */
#game-over-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  text-align: center;
  background: linear-gradient(180deg, #ffe4ec 0%, #fff0f5 100%);
}

#game-over-screen h2 {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  color: #c71585;
  margin-bottom: 16px;
}

.final-score {
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  color: #8b4789;
  margin-bottom: 24px;
}

.end-message {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: #8b4789;
  margin-bottom: 32px;
  max-width: 320px;
}

#game-over-screen {
  position: relative;
}

#gameover-hearts {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.gameover-heart {
  position: absolute;
  bottom: -20px;
  font-size: 1.25rem;
  opacity: 0.5;
  animation: floatUpSlow 4s ease-out forwards;
}

@keyframes floatUpSlow {
  0% {
    transform: translateY(0) scale(0.8);
    opacity: 0.5;
  }
  100% {
    transform: translateY(-100vh) scale(1.2);
    opacity: 0;
  }
}

/* iPhone / mobile browser friendly - keep basket above Safari UI */
@media (max-width: 480px) {
  #basket {
    width: 60px;
    height: 40px;
    border-radius: 0 0 30px 30px;
    bottom: 24px;
  }

  #basket::before {
    width: 45px;
    height: 15px;
  }

  .heart {
    font-size: 24px;
  }

  .heart.special {
    font-size: 26px;
  }

  .heart.glitter-heart {
    font-size: 30px;
  }
}

