:root {
  --sky-top: #ffe0a8;
  --sky-low: #ffefd0;
  --jungle-back: #8cc76d;
  --jungle-front: #5faf60;
  --leaf: #3f8f52;
  --ink: #4a3b5c;
  --white: #fffdf7;
  --pink: #ff9ec4;
  --good: #6fd45e;
  --wood: #d9a05b;
  --wood-dark: #b47a3c;
  --card-bad: #ff8a8a;
}

* { 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;
}

#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 jungle backdrop ---------- */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: url("../shared/backgrounds/jungle.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;
}

.band-buttons { display: flex; flex-wrap: wrap; gap: clamp(18px, 4vw, 48px); justify-content: center; }

.badge-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(1.3rem, 3vw, 1.9rem);
  color: var(--white);
  width: clamp(110px, 15vw, 160px);
  height: clamp(110px, 15vw, 160px);
  border-radius: 50%;
  border: 6px dashed var(--white);
  background: radial-gradient(circle at 35% 30%, var(--wood), var(--wood-dark));
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.15);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  line-height: 1.2;
}
.badge-btn:hover, .badge-btn.hovered { transform: scale(1.12) rotate(-4deg); }

/* ---------- HUD ---------- */
.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-evenly;
  width: 100%;
  padding: 0 20px 4vh;
}

/* ---------- The jungle radio ---------- */
.radio {
  position: relative;
  width: clamp(150px, 22vw, 240px);
  height: clamp(100px, 15vw, 165px);
  border: 5px solid var(--wood-dark);
  border-radius: 26px 26px 18px 18px;
  background: linear-gradient(var(--wood), var(--wood-dark));
  cursor: pointer;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.radio:hover, .radio.hovered { transform: scale(1.1) rotate(-2deg); }
.radio.talking { animation: radio-wiggle 0.5s ease-in-out infinite; }

.radio-antenna {
  position: absolute;
  top: -34px;
  right: 26px;
  width: 5px;
  height: 34px;
  background: var(--ink);
  border-radius: 4px;
}
.radio-antenna::after {
  content: "";
  position: absolute;
  top: -10px;
  left: -5px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--pink);
}

.radio-speaker {
  position: absolute;
  left: 12%;
  top: 50%;
  transform: translateY(-50%);
  font-size: clamp(2.4rem, 5.5vw, 4rem);
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.2));
}

.radio-grill {
  position: absolute;
  right: 12%;
  top: 22%;
  bottom: 22%;
  width: 38%;
  border-radius: 12px;
  background: repeating-linear-gradient(
    var(--wood-dark) 0 6px,
    rgba(255, 253, 247, 0.6) 6px 12px
  );
  border: 3px solid var(--wood-dark);
}

.radio-notes { position: absolute; inset: 0; pointer-events: none; }
.radio-notes i {
  position: absolute;
  left: 50%;
  top: 0;
  font-style: normal;
  font-size: 1.6rem;
  opacity: 0;
}
.radio.talking .radio-notes i { animation: note-float 1.6s ease-out infinite; }
.radio.talking .radio-notes i:nth-child(2) { animation-delay: 0.5s; left: 30%; }
.radio.talking .radio-notes i:nth-child(3) { animation-delay: 1s; left: 70%; }

@keyframes radio-wiggle {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg) scale(1.03); }
}
@keyframes note-float {
  0% { transform: translateY(0); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translateY(-9vh) translateX(12px); opacity: 0; }
}

/* Text fallback when the browser has no speech synthesis */
.clue-bubble {
  position: relative;
  max-width: min(80vw, 560px);
  background: var(--white);
  border-radius: 20px;
  padding: 10px 22px;
  font-weight: 600;
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  box-shadow: 0 6px 14px rgba(74, 59, 92, 0.2);
  margin-top: -1vh;
}
.clue-bubble::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 12px solid var(--white);
}
.clue-bubble.hidden { display: none; }

/* ---------- Photo cards on the rope ---------- */
.rope {
  width: min(92vw, 980px);
  height: 3vh;
  border-bottom: 5px dashed var(--wood-dark);
  border-radius: 50%;
  margin-bottom: -1vh;
}

.cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(12px, 3vw, 36px);
  width: 100%;
}

.photo-card {
  font-family: inherit;
  position: relative;
  background: var(--white);
  border: none;
  border-radius: 10px;
  padding: 10px 10px 6px;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(74, 59, 92, 0.25);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: dangle 4s ease-in-out infinite;
  transform-origin: 50% -12px;
}
.photo-card::before {
  /* clothespin */
  content: "";
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 22px;
  border-radius: 5px;
  background: var(--wood-dark);
}
.photo-card:nth-child(1) { rotate: -3deg; animation-delay: -0.7s; }
.photo-card:nth-child(2) { rotate: 2deg; animation-delay: -1.9s; }
.photo-card:nth-child(3) { rotate: -2deg; animation-delay: -2.8s; }
.photo-card:nth-child(4) { rotate: 3deg; animation-delay: -3.5s; }

.photo-card:hover, .photo-card.hovered { transform: scale(1.12); z-index: 5; }

.photo-card img, .photo-card .card-emoji {
  display: block;
  width: clamp(96px, 15vw, 170px);
  height: clamp(96px, 15vw, 170px);
  object-fit: contain;
  border-radius: 8px;
  background: #fdf7ec;
}
.photo-card .card-emoji {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(3.4rem, 9vw, 6.5rem);
}

.card-word {
  display: block;
  font-weight: 700;
  font-size: clamp(1rem, 2.4vw, 1.5rem);
  padding: 4px 0 2px;
}

.photo-card.correct { background: var(--good); color: var(--white); transform: scale(1.18); z-index: 6; }
.photo-card.correct .card-word { color: var(--white); }
.photo-card.wrong {
  background: var(--card-bad);
  opacity: 0.4;
  pointer-events: none;
  animation: wilt 0.7s ease forwards;
}

@keyframes dangle {
  0%, 100% { transform: rotate(-1.5deg); }
  50% { transform: rotate(1.5deg); }
}
@keyframes wilt {
  to { transform: rotate(14deg) translateY(3vh) scale(0.9); opacity: 0.35; }
}

/* ---------- 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 (same as Balloon Pop) ---------- */
.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 {
  position: fixed;
  width: 13px;
  height: 13px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 60;
}

.hidden { visibility: hidden; }

@media (max-width: 620px) {
  .photo-card img, .photo-card .card-emoji { width: 32vw; height: 32vw; }
  .radio { width: 44vw; height: 30vw; }
  .stage { padding-bottom: 2vh; }
}

@media (prefers-reduced-motion: reduce) {
  .photo-card, .leaf, .radio.talking, .radio-notes i { animation: none !important; }
}
