:root {
  --sky-top: #aee4f5;
  --sky-low: #d8f2fb;
  --hill-back: #b8e08e;
  --hill-front: #93cf62;
  --ink: #4a3b5c;
  --white: #fffdf7;
  --pink: #ff9ec4;
  --yellow: #ffd35c;
  --mint: #8fe3c0;
  --lilac: #c5a8f0;
  --good: #6fd45e;
  --wood: #d9a05b;
  --wood-dark: #b47a3c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Fredoka", "Comic Sans MS", sans-serif;
  color: var(--ink);
  background: linear-gradient(var(--sky-top), var(--sky-low) 70%);
  user-select: none;
  -webkit-user-select: none;
}

/* Hidden webcam: it only feeds the hand tracker (and the ?debug=1 HUD).
   The paw cursor is the aiming feedback, not the video. */
#webcam {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0;
  transition: opacity 0.8s;
  pointer-events: none;
  z-index: 1;
}

/* ---------- Painted meadow backdrop ---------- */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: url("../shared/backgrounds/meadow.png") center bottom / cover no-repeat;
}

/* ---------- Layout ---------- */
#app {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3vh;
  padding: 24px;
  text-align: center;
}
.screen.active { display: flex; }

.game-title {
  font-family: "Titan One", "Fredoka", sans-serif;
  font-size: clamp(2.4rem, 7vw, 4.6rem);
  line-height: 1.05;
  margin: 0;
  color: var(--white);
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 0 6px 0 rgba(74, 59, 92, 0.25);
  transform: rotate(-2deg);
}

.subtitle {
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  font-weight: 600;
  margin: 0;
  background: rgba(255, 253, 247, 0.85);
  padding: 8px 22px;
  border-radius: 999px;
}

.camera-status {
  font-size: 1.05rem;
  font-weight: 600;
  min-height: 1.5em;
  background: rgba(255, 253, 247, 0.75);
  padding: 6px 18px;
  border-radius: 999px;
}

/* ---------- Balloons (shared) ---------- */
.balloon-pink { --balloon: var(--pink); --balloon-dark: #e57ba6; }
.balloon-yellow { --balloon: var(--yellow); --balloon-dark: #e0b13a; }
.balloon-mint { --balloon: var(--mint); --balloon-dark: #64c39a; }
.balloon-lilac { --balloon: var(--lilac); --balloon-dark: #a284d4; }

.balloon, .start-balloon {
  position: relative;
  font-family: inherit;
  border: none;
  cursor: pointer;
  background: radial-gradient(circle at 32% 28%, #ffffffb0 6%, var(--balloon) 34%, var(--balloon-dark) 115%);
  border-radius: 50% 50% 50% 50% / 56% 56% 44% 44%;
  box-shadow: inset -8px -10px 0 rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.balloon::after, .start-balloon::after {
  /* balloon knot */
  content: "";
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 12px solid var(--balloon-dark);
}
.balloon::before, .start-balloon::before {
  /* string */
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 3px;
  height: 9vh;
  background: repeating-linear-gradient(rgba(74, 59, 92, 0.45) 0 8px, transparent 8px 12px);
  border-radius: 3px;
}

.balloon-word {
  font-weight: 700;
  color: var(--ink);
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  line-height: 1.1;
  padding: 0 12px;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.start-balloon {
  width: clamp(110px, 16vw, 170px);
  height: clamp(130px, 19vw, 200px);
  animation: bob 3.4s ease-in-out infinite;
}
.start-balloon:nth-child(2) { animation-delay: -1.1s; }
.start-balloon:nth-child(3) { animation-delay: -2.2s; }
.band-buttons { display: flex; flex-wrap: wrap; gap: clamp(18px, 4vw, 48px); align-items: flex-end; justify-content: center; }

.pack-buttons { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.pack-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(1rem, 2.4vw, 1.3rem);
  color: var(--ink);
  background: rgba(255, 253, 247, 0.8);
  border: 4px solid transparent;
  border-radius: 999px;
  padding: 10px 24px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.1);
  transition: transform 0.15s;
}
.pack-btn:hover, .pack-btn.hovered { transform: scale(1.08); }
.pack-btn.selected { border-color: var(--pink); background: var(--white); }

.start-balloon:hover, .start-balloon.hovered,
.balloon:hover, .balloon.hovered {
  transform: scale(1.12) rotate(-3deg);
}

/* ---------- Game screen ---------- */
.hud {
  display: flex;
  justify-content: flex-start;
  gap: 18px;
  align-items: center;
  width: 100%;
  padding: 16px 22px 0;
}

.wood-sign, .wood-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(1.1rem, 2.4vw, 1.5rem);
  color: var(--white);
  background: linear-gradient(var(--wood), var(--wood-dark));
  border: 3px solid var(--wood-dark);
  border-radius: 14px;
  padding: 8px 20px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.15);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}
.wood-btn { cursor: pointer; font-size: clamp(1.3rem, 3vw, 1.9rem); padding: 14px 34px; }
.wood-btn:hover, .wood-btn.hovered { transform: scale(1.08) rotate(-1.5deg); }

.star-trail { font-size: clamp(1.4rem, 3vw, 2rem); letter-spacing: 5px; min-height: 1.2em; }

.corner-links {
  position: fixed;
  top: 14px;
  right: 16px;
  display: flex;
  gap: 10px;
  z-index: 45;
}
.corner-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 1.5rem;
  text-decoration: none;
  background: linear-gradient(var(--wood), var(--wood-dark));
  border: 3px solid var(--wood-dark);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.15s;
}
.corner-btn:hover, .corner-btn.hovered { transform: scale(1.12) rotate(-4deg); }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1vh 20px 12vh;
}

.animal-mound { position: relative; margin-top: 1vh; }

.animal-frame {
  position: relative;
  background: var(--white);
  border: 7px solid #fff;
  border-radius: 47% 53% 50% 50% / 52% 48% 54% 46%;
  box-shadow: 0 14px 28px rgba(74, 59, 92, 0.22);
  padding: 14px;
  animation: wobble 5s ease-in-out infinite;
}
.animal-frame.celebrate { animation: bounce 0.6s ease; }

#animal-image {
  display: block;
  width: min(34vh, 56vw);
  height: min(34vh, 56vw);
  object-fit: contain;
  border-radius: 50%;
  background: #fdf7ec;
}
#animal-image.hidden { display: none; }

.animal-emoji {
  width: min(34vh, 56vw);
  height: min(34vh, 56vw);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(22vh, 36vw);
  background: #fdf7ec;
  border-radius: 50%;
}
.animal-emoji.hidden { display: none; }

.balloons {
  display: flex;
  flex-wrap: wrap; /* 2x2 on phones so no answer is ever clipped offscreen */
  align-items: flex-end;
  justify-content: center;
  gap: clamp(14px, 3.5vw, 44px);
  width: 100%;
}

.balloon {
  width: clamp(120px, 17vw, 190px);
  height: clamp(140px, 20vw, 220px);
  animation: bob ease-in-out infinite;
  animation-duration: 3.2s;
}
.balloon:nth-child(1) { animation-delay: -0.4s; margin-bottom: 3vh; }
.balloon:nth-child(2) { animation-delay: -1.3s; }
.balloon:nth-child(3) { animation-delay: -2.1s; margin-bottom: 4.5vh; }
.balloon:nth-child(4) { animation-delay: -2.8s; margin-bottom: 1.5vh; }

.balloon.popping {
  animation: pop 0.35s ease forwards;
  pointer-events: none;
}
.balloon.deflating {
  animation: deflate 0.9s ease-in forwards;
  pointer-events: none;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-2.4vh) rotate(2deg); }
}
@keyframes wobble {
  0%, 100% { transform: rotate(-1.5deg); }
  50% { transform: rotate(1.5deg); }
}
@keyframes bounce {
  0%, 100% { transform: scale(1); }
  35% { transform: scale(1.14) rotate(-3deg); }
  70% { transform: scale(0.96) rotate(2deg); }
}
@keyframes pop {
  0% { transform: scale(1); opacity: 1; }
  45% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}
@keyframes deflate {
  0% { transform: scale(1) rotate(0); opacity: 1; }
  100% { transform: scale(0.15) translateY(26vh) rotate(50deg); opacity: 0; }
}

/* ---------- End screen ---------- */
.end-stars { font-size: clamp(2.6rem, 8vw, 5rem); letter-spacing: 12px; }
.end-words {
  font-size: clamp(1.2rem, 3vw, 1.7rem);
  font-weight: 600;
  max-width: 640px;
  background: rgba(255, 253, 247, 0.85);
  border-radius: 20px;
  padding: 12px 26px;
}

/* ---------- Hand cursor ---------- */
.cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 78px;
  height: 78px;
  margin: -39px 0 0 -39px;
  pointer-events: none;
  z-index: 50;
  transition: opacity 0.25s;
}
.cursor.hidden { opacity: 0; }

.cursor-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 5px solid var(--pink);
  background: rgba(255, 255, 255, 0.3);
  overflow: hidden;
}
.cursor-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: rgba(255, 158, 196, 0.6);
}
.cursor-paw {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  transition: transform 0.1s;
}
.cursor.pinching .cursor-paw { transform: scale(0.7); }
.cursor.pinching .cursor-ring { border-color: var(--good); }

.hand-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 253, 247, 0.94);
  border-radius: 999px;
  padding: 10px 28px;
  font-size: 1.3rem;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(74, 59, 92, 0.28);
  z-index: 40;
  transition: opacity 0.3s;
}
.hand-hint.hidden { opacity: 0; }

/* Confetti bits */
.confetti {
  position: fixed;
  width: 13px;
  height: 13px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 60;
}

.hidden { visibility: hidden; }

@media (max-width: 620px) {
  #animal-image, .animal-emoji { width: min(24vh, 46vw); height: min(24vh, 46vw); }
  .animal-emoji { font-size: min(15vh, 30vw); }
  .balloon { width: 30vw; height: 34vw; }
  .balloon::before { height: 4vh; }
  .stage { padding-bottom: 6vh; }
}

@media (prefers-reduced-motion: reduce) {
  .balloon, .start-balloon, .animal-frame, .sun-rays, .cloud { animation: none !important; }
}
