: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/picnic.png") center bottom / cover no-repeat;
}

/* Long word problems can outgrow short viewports — allow scrolling rather
   than clipping the answer plates. */
#app { position: relative; z-index: 2; height: 100%; display: flex; flex-direction: column; overflow-y: auto; }

.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;
  gap: 1vh;
}

/* The picnic menu board */
.board {
  background: var(--white);
  border: 6px solid #fff;
  border-radius: 30px;
  box-shadow: 0 14px 28px rgba(74, 59, 92, 0.2);
  padding: 18px 30px;
  max-width: min(92vw, 760px);
  animation: pop-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.board.celebrate { animation: bounce 0.6s ease; }

.question-text {
  margin: 0 0 6px;
  font-weight: 700;
  font-size: clamp(1.2rem, 3.2vw, 2rem);
}

.visual {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 0;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1.15;
  max-width: 620px;
}
.visual:empty { display: none; }

.visual .big-num {
  font-family: "Titan One", "Fredoka", sans-serif;
  font-size: clamp(3rem, 9vw, 5.5rem);
  padding: 0 18px;
}

/* CSS shapes for shape_recognition */
.shape { width: clamp(70px, 12vw, 120px); height: clamp(70px, 12vw, 120px); }
.shape-circle { background: var(--pink); border-radius: 50%; }
.shape-square { background: var(--mint); border-radius: 12px; }
.shape-rectangle { background: var(--yellow); border-radius: 12px; width: clamp(110px, 18vw, 190px); height: clamp(60px, 9vw, 100px); }
.shape-triangle {
  width: 0; height: 0; background: none;
  border-left: clamp(40px, 7vw, 65px) solid transparent;
  border-right: clamp(40px, 7vw, 65px) solid transparent;
  border-bottom: clamp(70px, 12vw, 115px) solid var(--lilac);
}
.shape-oval { background: var(--pink); border-radius: 50%; width: clamp(110px, 18vw, 180px); }
.shape-star, .shape-heart, .shape-diamond { background: none; font-size: clamp(4rem, 10vw, 7rem); width: auto; height: auto; }

/* "Say it again" button, pinned to the question board so it clearly
   belongs to the question. */
.board { position: relative; }
.say-again {
  position: absolute;
  right: -22px;
  top: -22px;
  font-family: inherit;
  font-size: clamp(1.4rem, 3vw, 2rem);
  background: var(--yellow);
  border: 4px solid #fff;
  border-radius: 50%;
  width: clamp(54px, 7vw, 72px);
  height: clamp(54px, 7vw, 72px);
  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; }

/* Answer plates */
.plates {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(14px, 3vw, 36px);
  width: 100%;
}

.plate {
  font-family: "Titan One", "Fredoka", sans-serif;
  font-size: clamp(1.8rem, 5vw, 3rem);
  color: var(--ink);
  width: clamp(110px, 16vw, 170px);
  height: clamp(110px, 16vw, 170px);
  border-radius: 50%;
  border: none;
  background:
    radial-gradient(circle at 50% 50%, var(--white) 58%, #eee5da 60%, var(--white) 66%);
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(74, 59, 92, 0.22);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
  line-height: 1.1;
  padding: 8px;
  overflow-wrap: anywhere;
}
.plate:nth-child(2) { animation-delay: 0.07s; }
.plate:nth-child(3) { animation-delay: 0.14s; }
.plate:nth-child(4) { animation-delay: 0.21s; }
.plate.long-text { font-size: clamp(1rem, 2.6vw, 1.6rem); font-family: "Fredoka", sans-serif; font-weight: 700; }

.plate:hover, .plate.hovered { transform: scale(1.12) rotate(-3deg); }
.plate.correct { background: var(--good); color: var(--white); transform: scale(1.16); }
.plate.wrong {
  background: var(--bad);
  opacity: 0.4;
  pointer-events: none;
  animation: shake 0.4s;
}

@keyframes pop-in {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes bounce {
  0%, 100% { transform: scale(1); }
  35% { transform: scale(1.1) rotate(-2deg); }
  70% { transform: scale(0.97) rotate(1.5deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}
@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) {
  .plate { width: 34vw; height: 34vw; }
  .board { padding: 12px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .plate, .board, .basket.talking { animation: none !important; }
}
