:root {
  --ink: #4a3b5c;
  --white: #fffdf7;
  --pink: #ff9ec4;
  --yellow: #ffd35c;
  --mint: #8fe3c0;
  --lilac: #c5a8f0;
  --good: #6fd45e;
  --bad: #ff8a8a;
  --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(#aee4f5, #d8f2fb 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;
  pointer-events: none;
  z-index: 1;
}

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

#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 { 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 sentence sign ---------- */
.sign {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(var(--wood), var(--wood-dark));
  border: 5px solid var(--wood-dark);
  border-radius: 22px;
  padding: 18px 28px;
  max-width: min(92vw, 820px);
  box-shadow: 0 12px 24px rgba(74, 59, 92, 0.25);
}

.clue-art {
  flex-shrink: 0;
  background: var(--white);
  border-radius: 16px;
  padding: 6px;
}
.clue-art img {
  display: block;
  width: clamp(70px, 11vw, 120px);
  height: clamp(70px, 11vw, 120px);
  object-fit: contain;
  border-radius: 12px;
  background: #fdf7ec;
}
.clue-art.hidden { display: none; }

.sentence {
  margin: 0;
  font-weight: 700;
  font-size: clamp(1.3rem, 3.4vw, 2.2rem);
  color: var(--white);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  line-height: 1.35;
}
.sentence .gap {
  display: inline-block;
  min-width: 3.2em;
  border-bottom: 4px dashed var(--yellow);
  color: var(--yellow);
  font-family: "Titan One", "Fredoka", sans-serif;
  text-align: center;
}
.sentence .gap.filled {
  border-bottom-color: transparent;
  color: var(--yellow);
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.say-again {
  position: absolute;
  right: -20px;
  top: -20px;
  font-family: inherit;
  font-size: clamp(1.3rem, 2.8vw, 1.8rem);
  background: var(--yellow);
  border: 4px solid #fff;
  border-radius: 50%;
  width: clamp(50px, 6.5vw, 66px);
  height: clamp(50px, 6.5vw, 66px);
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(74, 59, 92, 0.25);
  transition: transform 0.15s;
}
.say-again:hover, .say-again.hovered { transform: scale(1.15) rotate(-6deg); }
.say-again.talking { animation: wiggle 0.5s ease-in-out infinite; }

/* ---------- Word flowers ---------- */
.flowers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(12px, 3vw, 40px);
  width: 100%;
}

.flower {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  animation: sway-flower 4s ease-in-out infinite;
  transform-origin: 50% 100%;
}
.flower:nth-child(1) { animation-delay: -0.6s; }
.flower:nth-child(2) { animation-delay: -1.7s; }
.flower:nth-child(3) { animation-delay: -2.5s; }
.flower:nth-child(4) { animation-delay: -3.3s; }

.blossom {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(104px, 15vw, 168px);
  height: clamp(104px, 15vw, 168px);
  border-radius: 46% 54% 52% 48% / 52% 47% 53% 48%;
  border: 6px dotted rgba(255, 255, 255, 0.85);
  color: var(--ink);
  font-weight: 700;
  font-size: clamp(1.1rem, 2.6vw, 1.7rem);
  padding: 10px;
  overflow-wrap: anywhere;
  line-height: 1.1;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 10px 18px rgba(74, 59, 92, 0.2);
}
.flower-pink .blossom { background: var(--pink); }
.flower-yellow .blossom { background: var(--yellow); }
.flower-mint .blossom { background: var(--mint); }
.flower-lilac .blossom { background: var(--lilac); }

.stem { width: 7px; height: clamp(28px, 5vh, 55px); background: #5faf60; border-radius: 4px; }

.flower:hover .blossom, .flower.hovered .blossom { transform: scale(1.14) rotate(-4deg); }
.flower.correct .blossom { background: var(--good); color: var(--white); transform: scale(1.2); }
.flower.wrong { animation: wilt 0.8s ease forwards; pointer-events: none; }

@keyframes sway-flower {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2.5deg); }
}
@keyframes wilt {
  to { transform: rotate(24deg) translateY(3vh) scale(0.85); opacity: 0.4; }
}
@keyframes pop-in {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg) scale(1.05); }
}

.end-stars { font-size: clamp(2.6rem, 8vw, 5rem); letter-spacing: 12px; }

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

.hidden { visibility: hidden; }

@media (max-width: 620px) {
  .sign { flex-direction: column; gap: 10px; padding: 14px 18px; }
  .blossom { width: 22vw; height: 22vw; font-size: 0.95rem; }
}

@media (prefers-reduced-motion: reduce) {
  .flower, .say-again.talking { animation: none !important; }
}
