/* ===================================================================== */
/*  Bloop's Play World — styles                                          */
/* ===================================================================== */

:root {
  --purple: #6c5ce7;
  --sky-1: #8ec5ff;
  --sky-2: #c2e9fb;
  --ink: #3a2f6b;
  --font: "Baloo 2", "Comic Sans MS", "Chalkboard SE", "Trebuchet MS",
    system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 55%, #eafff2 100%);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.app {
  position: relative;
  z-index: 2;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---- sky decorations ------------------------------------------------- */
.sky-deco {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
.cloud {
  position: absolute;
  background: #fff;
  border-radius: 100px;
  opacity: 0.85;
  filter: blur(0.3px);
}
.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}
.cloud-1 {
  width: 120px;
  height: 40px;
  top: 12%;
  left: -140px;
  animation: drift 38s linear infinite;
}
.cloud-2 {
  width: 90px;
  height: 30px;
  top: 30%;
  left: -140px;
  animation: drift 52s linear infinite;
  animation-delay: -12s;
}
.cloud-3 {
  width: 150px;
  height: 48px;
  top: 8%;
  left: -180px;
  animation: drift 66s linear infinite;
  animation-delay: -30s;
}
.cloud::before {
  width: 55%;
  height: 160%;
  top: -55%;
  left: 12%;
}
.cloud::after {
  width: 45%;
  height: 140%;
  top: -40%;
  right: 12%;
}
@keyframes drift {
  to {
    transform: translateX(115vw);
  }
}
.sun {
  position: absolute;
  top: 18px;
  right: 24px;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #fff3a0, #ffd23f);
  box-shadow: 0 0 40px rgba(255, 210, 63, 0.7);
  animation: sun-pulse 5s ease-in-out infinite;
}
@keyframes sun-pulse {
  50% {
    transform: scale(1.06);
  }
}

/* ---- screens & transitions ------------------------------------------ */
.screen {
  min-height: 100%;
  padding: 16px 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.screen-enter {
  animation: screen-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
}

/* ===================================================================== */
/*  Mascot (Bloop)                                                       */
/* ===================================================================== */
.bloop {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.bloop-star {
  transform-origin: 100px 8px;
  animation: twinkle 2.4s ease-in-out infinite;
}
@keyframes twinkle {
  50% {
    transform: scale(1.25) rotate(15deg);
  }
}
.bloop-wave {
  transform-origin: 150px 120px;
  animation: wave 1.2s ease-in-out infinite;
}
@keyframes wave {
  0%,
  100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(-24deg);
  }
}
@keyframes bob {
  50% {
    transform: translateY(-8px);
  }
}

/* ===================================================================== */
/*  HOME                                                                 */
/* ===================================================================== */
.home-header {
  position: relative;
  text-align: center;
  width: 100%;
  max-width: 720px;
}
.home-mascot {
  width: 150px;
  height: 158px;
  margin: 4px auto 0;
  animation: bob 3s ease-in-out infinite;
}
.home-title {
  font-size: clamp(30px, 8vw, 52px);
  margin: 0;
  color: #fff;
  text-shadow: 0 3px 0 var(--purple), 0 6px 14px rgba(0, 0, 0, 0.2);
  letter-spacing: 0.5px;
}
.home-subtitle {
  font-size: clamp(16px, 4vw, 22px);
  margin: 6px 0 18px;
  color: var(--ink);
  font-weight: 700;
}
.home-controls {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 10px;
}
.star-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  gap: 6px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 720px;
  margin-top: 6px;
}
.game-card {
  border: none;
  cursor: pointer;
  border-radius: 26px;
  padding: 22px 14px 16px;
  background: #fff;
  box-shadow: 0 8px 0 var(--card-color), 0 14px 22px rgba(0, 0, 0, 0.16);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
  color: var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}
.game-card:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 var(--card-color), 0 6px 12px rgba(0, 0, 0, 0.16);
}
.game-card-emoji {
  font-size: clamp(44px, 12vw, 64px);
  line-height: 1;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.15));
}
.game-card-title {
  font-size: clamp(17px, 4.4vw, 22px);
  font-weight: 800;
}
.game-card-blurb {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.6;
  text-align: center;
}
.game-card-stars {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 800;
  background: #fff6d8;
  color: #b8860b;
  border-radius: 999px;
  padding: 3px 12px;
}

/* ===================================================================== */
/*  Top bar (shared)                                                     */
/* ===================================================================== */
.top-bar {
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.top-bar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: clamp(16px, 4vw, 22px);
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
}
.top-bar-emoji {
  font-size: 24px;
}
.icon-btn {
  border: none;
  cursor: pointer;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fff;
  font-size: 22px;
  color: var(--purple);
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease;
  flex-shrink: 0;
}
.icon-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.15);
}

/* ===================================================================== */
/*  Level select                                                         */
/* ===================================================================== */
.levels-mascot {
  width: 96px;
  height: 100px;
  animation: bob 3s ease-in-out infinite;
}
.levels-heading {
  color: #fff;
  text-shadow: 0 2px 0 var(--purple);
  font-size: clamp(22px, 6vw, 32px);
  margin: 4px 0 14px;
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 520px;
}
.level-btn {
  aspect-ratio: 1;
  border: none;
  cursor: pointer;
  border-radius: 24px;
  background: #fff;
  color: var(--card-color);
  font-size: 34px;
  font-weight: 900;
  position: relative;
  box-shadow: 0 6px 0 var(--card-color), 0 10px 16px rgba(0, 0, 0, 0.16);
  transition: transform 0.1s ease;
  font-family: var(--font);
}
.level-btn:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 var(--card-color);
}
.level-btn.locked {
  background: #dfe4ee;
  color: #9aa4b8;
  box-shadow: 0 6px 0 #c3ccdb;
  cursor: not-allowed;
}
.level-btn.done {
  background: linear-gradient(160deg, #fff, #fff6d8);
}
.level-btn-star {
  position: absolute;
  top: -10px;
  right: -8px;
  font-size: 26px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
  animation: twinkle 2s ease-in-out infinite;
}

/* ===================================================================== */
/*  Play screen shared bits                                              */
/* ===================================================================== */
.progress-dots {
  display: flex;
  gap: 10px;
  margin: 4px 0 14px;
  min-height: 20px;
  flex-wrap: wrap;
  justify-content: center;
}
.progress-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, background 0.2s ease;
}
.progress-dot.filled {
  background: #ffd23f;
  transform: scale(1.15);
  box-shadow: 0 0 10px rgba(255, 210, 63, 0.8);
}
.stage {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-height: 0;
}

/* mascot corner + speech bubble */
.mascot-corner {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}
.mini-mascot {
  width: 84px;
  height: 88px;
  animation: bob 3s ease-in-out infinite;
}
.speech-bubble {
  max-width: 190px;
  background: #fff;
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  transition: opacity 0.2s ease, transform 0.2s ease;
  position: relative;
}
.speech-bubble.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.speech-bubble::after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: 16px;
  border: 9px solid transparent;
  border-left-color: #fff;
}

/* ===================================================================== */
/*  Memory Match                                                         */
/* ===================================================================== */
.memory-board {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: clamp(8px, 2.5vw, 16px);
  width: 100%;
  max-width: 560px;
  margin: 10px auto;
}
.memory-card {
  aspect-ratio: 1;
  border: none;
  background: transparent;
  cursor: pointer;
  perspective: 700px;
  padding: 0;
}
.memory-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.memory-card.flipped .memory-inner {
  transform: rotateY(180deg);
}
.memory-face {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(30px, 9vw, 52px);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.12), 0 8px 14px rgba(0, 0, 0, 0.14);
}
.memory-back {
  background: linear-gradient(160deg, #ff9ec4, #ff7bac);
  color: #fff;
}
.memory-front {
  background: #fff;
  transform: rotateY(180deg);
}
.memory-card.matched .memory-inner {
  animation: matched-pop 0.5s ease;
}
.memory-card.matched .memory-front {
  background: #eafff2;
  box-shadow: 0 0 0 4px #4dd599, 0 8px 14px rgba(0, 0, 0, 0.14);
}
@keyframes matched-pop {
  40% {
    transform: rotateY(180deg) scale(1.12);
  }
}

/* ===================================================================== */
/*  Learn to Count                                                       */
/* ===================================================================== */
.count-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.count-objects {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 12px;
  min-height: 120px;
  align-items: center;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 28px;
  padding: 18px 22px;
  width: 100%;
  max-width: 560px;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.6);
}
.count-thing {
  font-size: clamp(38px, 11vw, 60px);
  line-height: 1;
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.12));
}
.count-question {
  color: #fff;
  text-shadow: 0 2px 0 var(--purple);
  font-size: clamp(22px, 6vw, 30px);
  margin: 16px 0 6px;
}
.count-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 10px;
}
.count-choice {
  width: 74px;
  height: 74px;
  border: none;
  cursor: pointer;
  border-radius: 22px;
  background: #fff;
  color: var(--purple);
  font-size: 36px;
  font-weight: 900;
  font-family: var(--font);
  box-shadow: 0 6px 0 #d9d2ff, 0 10px 16px rgba(0, 0, 0, 0.14);
  transition: transform 0.1s ease;
}
.count-choice:active {
  transform: translateY(5px);
}
.count-choice.right {
  background: #4dd599;
  color: #fff;
  box-shadow: 0 6px 0 #3bb880;
  animation: matched-pop 0.5s ease;
}
.count-choice.nope {
  background: #ffe0e0;
  color: #ff5d5d;
  box-shadow: 0 6px 0 #ffb3b3;
  animation: shake 0.4s ease;
}
@keyframes shake {
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}
.hear-btn {
  border: none;
  cursor: pointer;
  background: #ffd23f;
  color: #7a5c00;
  font-weight: 800;
  font-family: var(--font);
  font-size: 16px;
  border-radius: 999px;
  padding: 8px 18px;
  box-shadow: 0 4px 0 #d9a800;
  margin-top: 4px;
}
.hear-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #d9a800;
}

/* ===================================================================== */
/*  Spot the Differences                                                 */
/* ===================================================================== */
.spot-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.spot-panels {
  display: flex;
  gap: 14px;
  width: 100%;
  max-width: 720px;
  justify-content: center;
  flex-wrap: wrap;
}
.spot-panel {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 24px;
  padding: 12px;
  flex: 1 1 300px;
  min-width: 260px;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.6);
}
.spot-panel-tag {
  display: block;
  text-align: center;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--purple);
}
.spot-scene {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 6px;
  background: #fff;
  border-radius: 16px;
  padding: 8px;
}
.spot-cell {
  aspect-ratio: 1;
  border: none;
  cursor: pointer;
  background: #f4f6ff;
  border-radius: 12px;
  font-size: clamp(24px, 6vw, 38px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, background 0.2s ease;
}
.spot-cell:active {
  transform: scale(0.9);
}
.spot-cell.found {
  background: #eafff2;
  box-shadow: inset 0 0 0 3px #4dd599;
  animation: matched-pop 0.5s ease;
}
.spot-cell.wrong-tap {
  background: #ffe0e0;
  animation: shake 0.4s ease;
}

/* ===================================================================== */
/*  Shape & Color Match                                                  */
/* ===================================================================== */
.match-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.match-prompt {
  color: #fff;
  text-shadow: 0 2px 0 var(--purple);
  font-size: clamp(22px, 6vw, 32px);
  margin: 4px 0 12px;
}
.match-target {
  width: clamp(120px, 34vw, 170px);
  height: clamp(120px, 34vw, 170px);
  background: #fff;
  border-radius: 28px;
  padding: 16px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.1), 0 12px 20px rgba(0, 0, 0, 0.15);
  animation: bob 3s ease-in-out infinite;
}
.match-target svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.15));
}
.match-options {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin-top: 26px;
}
.match-option {
  width: clamp(84px, 22vw, 110px);
  height: clamp(84px, 22vw, 110px);
  border: none;
  cursor: pointer;
  background: #fff;
  border-radius: 24px;
  padding: 12px;
  box-shadow: 0 6px 0 #d9d2ff, 0 10px 16px rgba(0, 0, 0, 0.14);
  transition: transform 0.1s ease;
}
.match-option:active {
  transform: translateY(5px);
}
.match-option svg {
  width: 100%;
  height: 100%;
}
.match-option.right {
  box-shadow: 0 6px 0 #3bb880, 0 0 0 4px #4dd599;
  animation: matched-pop 0.5s ease;
}
.match-option.nope {
  opacity: 0.4;
  animation: shake 0.4s ease;
}

/* ===================================================================== */
/*  Paint by Tap                                                         */
/* ===================================================================== */
.paint-wrap {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.paint-canvas-card {
  width: 100%;
  flex: 1;
  min-height: 0;
  background: #fff;
  border-radius: 24px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.1), 0 12px 20px rgba(0, 0, 0, 0.15);
}
.paint-svg {
  /* viewBox + default preserveAspectRatio keeps the picture square and
     centered, so it grows as large as the card allows in both dimensions. */
  width: 100%;
  height: 100%;
  display: block;
}
.paint-region {
  fill: #eef1f6;
  stroke: #3a2f6b;
  stroke-width: 1.6;
  stroke-linejoin: round;
  cursor: pointer;
  transition: fill 0.12s ease;
  vector-effect: non-scaling-stroke;
}
.paint-region:active {
  filter: brightness(0.94);
}
.paint-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 14px 0 4px;
  max-width: 420px;
}

/* ===================================================================== */
/*  Doodle Pad                                                           */
/* ===================================================================== */
.draw-wrap {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.draw-canvas-card {
  width: 100%;
  flex: 1;
  min-height: 0;
  background: #fff;
  border-radius: 24px;
  padding: 10px;
  display: flex;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.1), 0 12px 20px rgba(0, 0, 0, 0.15);
}
.draw-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #fff;
  border-radius: 16px;
  touch-action: none;
  cursor: crosshair;
}
.draw-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 12px 0 4px;
  max-width: 440px;
}
.draw-controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  margin: 8px 0;
}
.draw-brushes,
.draw-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.draw-brush {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: none;
  background: #fff;
  box-shadow: 0 4px 0 #d9d2ff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.draw-brush.active {
  box-shadow: 0 4px 0 #5b4bd6, 0 0 0 3px var(--purple);
}
.draw-brush:active {
  transform: translateY(3px);
}
.draw-brush-dot {
  background: #3a2f6b;
  border-radius: 50%;
  display: block;
}
.draw-tool {
  border: none;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 800;
  font-size: 15px;
  border-radius: 999px;
  padding: 9px 14px;
  box-shadow: 0 4px 0 #d9d2ff;
  transition: transform 0.1s ease;
}
.draw-tool.active {
  background: #ffd23f;
  color: #7a5c00;
  box-shadow: 0 4px 0 #d9a800;
}
.draw-tool:active {
  transform: translateY(3px);
}
.draw-done {
  background: #4dd599;
  box-shadow: 0 6px 0 #3bb880;
  font-size: 20px;
  padding: 12px 26px;
  margin-top: 6px;
  align-self: center;
}

/* ===================================================================== */
/*  Shape Sorter                                                         */
/* ===================================================================== */
.sort-wrap {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8px;
}
.sort-board {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(10px, 3vw, 22px);
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 28px;
  padding: 18px;
  width: 100%;
  max-width: 680px;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.6);
}
.sort-hole {
  width: clamp(68px, 17vw, 108px);
  height: clamp(68px, 17vw, 108px);
  display: flex;
}
.sort-hole.pop .sort-shape {
  animation: matched-pop 0.5s ease;
}
.sort-tray {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(12px, 3vw, 22px);
  justify-content: center;
  align-items: center;
  min-height: 110px;
  width: 100%;
  max-width: 680px;
}
.sort-piece {
  width: clamp(62px, 16vw, 100px);
  height: clamp(62px, 16vw, 100px);
  cursor: grab;
  touch-action: none;
  transition: transform 0.1s ease, filter 0.1s ease;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.22));
}
.sort-piece.dragging {
  cursor: grabbing;
  transform: scale(1.14) rotate(-4deg);
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.3));
}
.sort-shape {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none; /* drops target the piece/hole box, not the SVG */
}

/* ===================================================================== */
/*  Build a Picture                                                      */
/* ===================================================================== */
.build-wrap {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}
.build-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.build-ref-card {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 18px;
  padding: 8px 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.build-ref-label {
  font-weight: 800;
  font-size: 13px;
  color: var(--purple);
}
.build-ref {
  position: relative;
  width: clamp(70px, 17vw, 104px);
  height: clamp(70px, 17vw, 104px);
}
.build-board {
  position: relative;
  width: min(88vw, 44vh, 420px);
  height: min(88vw, 44vh, 420px);
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.08), 0 12px 20px rgba(0, 0, 0, 0.14);
}
.build-slot,
.build-ref-shape {
  position: absolute;
}
.build-slot.pop .build-shape {
  animation: matched-pop 0.5s ease;
}
.build-shape {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none; /* drops target the piece/slot box, not the SVG */
}
.build-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  align-items: center;
  min-height: 92px;
  width: 100%;
  max-width: 680px;
}
.build-piece {
  cursor: grab;
  touch-action: none;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.22));
  transition: transform 0.1s ease, filter 0.1s ease;
}
.build-piece.dragging {
  cursor: grabbing;
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.3));
}

/* Shared color swatches for painting + drawing */
.paint-swatch,
.draw-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--sw);
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 3px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.paint-swatch.active,
.draw-swatch.active {
  transform: scale(1.18);
  box-shadow: 0 0 0 3px var(--purple), 0 3px 6px rgba(0, 0, 0, 0.25);
}
.paint-swatch:active,
.draw-swatch:active {
  transform: scale(1.05);
}

/* Full-bleed play screen: nav floats over a full-screen pad so the whole
   page is usable canvas. Used by the drawing + painting games. */
.play-screen.full-bleed {
  position: fixed;
  inset: 0;
  padding: 0;
  overflow: hidden;
  min-height: 0;
}
.play-screen.full-bleed .top-bar {
  position: fixed;
  top: 12px;
  left: 0;
  right: 0;
  width: auto;
  max-width: none;
  margin: 0;
  padding: 0 12px;
  z-index: 8;
  pointer-events: none; /* let taps fall through the gaps to the canvas */
}
.play-screen.full-bleed .top-bar .icon-btn,
.play-screen.full-bleed .top-bar .top-bar-title {
  pointer-events: auto;
}
.play-screen.full-bleed .progress-dots {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  z-index: 8;
  pointer-events: none;
}
.play-screen.full-bleed .stage {
  max-width: none;
  width: 100%;
}

/* ===================================================================== */
/*  Win overlay                                                          */
/* ===================================================================== */
.win-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(60, 40, 120, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.3s ease both;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
.win-card {
  background: #fff;
  border-radius: 32px;
  padding: 26px 28px 30px;
  text-align: center;
  max-width: 340px;
  width: 86%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  animation: win-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes win-pop {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
}
.win-mascot {
  width: 130px;
  height: 138px;
  margin: 0 auto;
  animation: bob 2s ease-in-out infinite;
}
.win-title {
  color: var(--purple);
  font-size: 28px;
  margin: 6px 0 4px;
}
.win-stars {
  font-size: 56px;
  animation: twinkle 1.4s ease-in-out infinite;
}
.win-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}
.primary-btn {
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  border-radius: 999px;
  padding: 14px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.1s ease;
}
.next-btn {
  background: #4dd599;
  box-shadow: 0 6px 0 #3bb880;
}
.again-btn {
  background: var(--purple);
  box-shadow: 0 6px 0 #5b4bd6;
}
.primary-btn:active {
  transform: translateY(4px);
}
.ghost-btn {
  border: none;
  cursor: pointer;
  background: #f0f0f7;
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 800;
  border-radius: 999px;
  padding: 12px;
}

/* ===================================================================== */
/*  Settings / voice picker                                              */
/* ===================================================================== */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(60, 40, 120, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fade-in 0.3s ease both;
}
.settings-card {
  background: #fff;
  border-radius: 30px;
  padding: 22px 24px 26px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  animation: win-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.settings-mascot {
  width: 96px;
  height: 100px;
  margin: 0 auto;
  animation: bob 3s ease-in-out infinite;
}
.settings-title {
  color: var(--purple);
  font-size: 26px;
  margin: 4px 0 2px;
}
.settings-sub {
  font-weight: 700;
  opacity: 0.6;
  margin: 0 0 14px;
  font-size: 15px;
}
.voice-select {
  width: 100%;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  padding: 12px 14px;
  border: 3px solid #e3def7;
  border-radius: 16px;
  background: #f7f5ff;
  cursor: pointer;
}
.settings-test {
  margin: 16px 0 4px;
}
.settings-tip {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.55;
  line-height: 1.35;
  margin: 14px 0 16px;
}
.settings-note {
  font-weight: 700;
  color: var(--ink);
  margin: 8px 0 16px;
}

/* confetti */
.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.confetti-bit {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 16px;
  border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  to {
    transform: translateY(105vh) rotate(720deg);
    opacity: 0.9;
  }
}

/* ---- responsive tweaks ---------------------------------------------- */
@media (min-width: 620px) {
  .game-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
@media (max-width: 380px) {
  .speech-bubble {
    max-width: 130px;
    font-size: 13px;
  }
  .mini-mascot {
    width: 68px;
    height: 72px;
  }
}
