/* ===== Giggle Zone — shared in-game chrome ===== */

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--paper-glass);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid rgba(58, 46, 92, 0.06);
}

.game-title-wrap { text-align: center; flex: 1; }
.game-title-wrap h1 {
  font-size: clamp(1.2rem, 4.5vw, 1.7rem);
  margin: 0;
}
.game-title-wrap .subtitle {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: #6b5f8f;
}

/* On narrow phones the title + subtitle get squeezed into a tall, cramped
   sliver between the home icon and the language/mute controls. Wrapping the
   title onto its own full-width row keeps the top row compact and gives the
   text room to breathe. */
@media (max-width: 480px) {
  .game-header { flex-wrap: wrap; row-gap: 8px; }
  .game-title-wrap { flex-basis: 100%; order: 3; }
}

.hud {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 4px auto 18px;
}
.hud .pill {
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.level-picker {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 6px 0 20px;
}
.level-picker button {
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 700;
  font-size: 0.95rem;
  border: 3px solid transparent;
  transition: transform 0.12s ease;
}
.level-picker button.active {
  border-color: var(--purple);
  background: #f3ecff;
}
.level-picker button:active { transform: scale(0.94); }

.game-stage {
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 22px;
  max-width: 720px;
  margin: 0 auto;
  position: relative;
  animation: fade-in-up 0.5s var(--ease-bounce) both;
  animation-delay: 0.1s;
}

.big-round-btn {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 6px 0 #5c3fa0;
  margin-top: 18px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.big-round-btn:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 #5c3fa0;
}

/* ---- Card grid (memory match) ---- */
.card-grid {
  display: grid;
  gap: 12px;
  justify-content: center;
  margin: 0 auto;
}
.memory-card {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--purple), var(--pink));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  box-shadow: var(--shadow-pop);
  transform-style: preserve-3d;
  transition: transform 0.35s ease, box-shadow 0.2s ease;
  user-select: none;
  position: relative;
}
.memory-card .face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  backface-visibility: hidden;
}
.memory-card .face.front { background: transparent; }
.memory-card .face.back {
  background: var(--paper);
  transform: rotateY(180deg);
}
.memory-card.flipped { transform: rotateY(180deg); }
.memory-card.matched {
  box-shadow: none;
  animation: pop-match 0.4s ease;
}
.memory-card.shake { animation: shake 0.4s ease; }

@keyframes pop-match {
  0% { transform: rotateY(180deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.15); }
  100% { transform: rotateY(180deg) scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ---- Find-the-match grid ---- */
.find-target {
  text-align: center;
  margin-bottom: 14px;
}
.find-target .target-emoji {
  font-size: clamp(2.4rem, 10vw, 3.6rem);
  display: inline-block;
  background: #fff6e0;
  border-radius: var(--radius-md);
  padding: 10px 24px;
  box-shadow: var(--shadow-soft);
}
.find-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.find-cell {
  aspect-ratio: 1/1;
  border-radius: var(--radius-sm);
  background: #f6f3ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  box-shadow: var(--shadow-pop);
  transition: transform 0.15s ease, background 0.2s ease;
}
.find-cell:active { transform: scale(0.92); }
.find-cell.correct { background: #d8f7df; animation: pop-match 0.35s ease; }
.find-cell.wrong { animation: shake 0.35s ease; }
.find-cell.done { opacity: 0.35; pointer-events: none; }

/* ---- Shape sorter ---- */
.shape-slot {
  text-align: center;
  margin-bottom: 18px;
}
.shape-slot .slot-box {
  width: 110px;
  height: 110px;
  margin: 0 auto;
  border-radius: var(--radius-md);
  border: 4px dashed #cfc7e8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  background: #faf8ff;
}
.shape-slot .slot-box.ghost {
  opacity: 0.3;
}
.shape-slot .slot-box.filled {
  border-style: solid;
  border-color: var(--green);
  background: #eafff0;
  opacity: 1;
}
.shape-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 12px;
}
.shape-btn {
  aspect-ratio: 1/1;
  background: #f6f3ff;
  border-radius: var(--radius-sm);
  font-size: 2.4rem;
  box-shadow: var(--shadow-pop);
  display: flex;
  align-items: center;
  justify-content: center;
}
.shape-btn:active { transform: scale(0.92); }

/* ---- Counting fun ---- */
.count-display {
  font-size: clamp(2.4rem, 9vw, 3.4rem);
  text-align: center;
  line-height: 1.3;
  background: #fff6e0;
  border-radius: var(--radius-md);
  padding: 20px 10px;
  margin-bottom: 18px;
  word-spacing: 6px;
}
.count-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 12px;
}
.count-btn {
  aspect-ratio: 1/1;
  background: linear-gradient(135deg, var(--blue), #7bd7ff);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 1.8rem;
  font-weight: 800;
  box-shadow: var(--shadow-pop);
}
.count-btn:active { transform: scale(0.92); }
.count-btn.correct { background: linear-gradient(135deg, var(--green), #4bbf6d); }
.count-btn.wrong { background: linear-gradient(135deg, var(--red), #d94b4b); animation: shake 0.35s ease; }

/* ---- Bubble pop ---- */
.bubble-field {
  position: relative;
  width: 100%;
  height: 60vh;
  max-height: 520px;
  min-height: 340px;
  background: linear-gradient(180deg, #cdeeff 0%, #eaf9ff 100%);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.bubble {
  position: absolute;
  bottom: -60px;
  font-size: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255,255,255,0.55);
  box-shadow: inset 0 0 12px rgba(255,255,255,0.8), 0 4px 10px rgba(0,0,0,0.08);
  animation: rise linear forwards;
  user-select: none;
}
@keyframes rise {
  to { transform: translateY(-620px); }
}
.bubble.popped {
  animation: none;
  transform: scale(1.6);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

/* ---- Whack-a-mole ---- */
.mole-field {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 420px;
  margin: 0 auto;
}
.mole-hole {
  position: relative;
  aspect-ratio: 1/1;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, #8a5a2b 0%, #6b4420 70%, #55350f 100%);
  overflow: hidden;
  box-shadow: inset 0 6px 10px rgba(0,0,0,0.4);
}
.mole {
  position: absolute;
  left: 50%;
  bottom: -100%;
  transform: translateX(-50%);
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  transition: bottom 0.18s cubic-bezier(.34,1.56,.64,1);
  background: none;
}
.mole.up { bottom: 6%; }
.mole.whacked { bottom: -100%; transition: bottom 0.15s ease-in; }

/* ---- Sliding puzzle ---- */
.puzzle-target {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  max-width: 160px;
  margin: 0 auto 16px;
  background: #f6f3ff;
  border-radius: var(--radius-sm);
  padding: 8px;
}
.puzzle-target .mini-tile {
  aspect-ratio: 1/1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: #fff;
  border-radius: 6px;
}
.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 340px;
  margin: 0 auto;
}
.puzzle-tile {
  aspect-ratio: 1/1;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  box-shadow: var(--shadow-pop);
}
.puzzle-tile.blank {
  background: #f6f3ff;
  box-shadow: none;
}
.puzzle-tile.solved-glow {
  box-shadow: 0 0 0 3px var(--green);
}

/* ---- Pattern memory (Simon-style) ---- */
.simon-board {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 320px;
  margin: 0 auto 18px;
}
.simon-pad {
  aspect-ratio: 1/1;
  border-radius: var(--radius-md);
  opacity: 0.55;
  box-shadow: var(--shadow-pop);
  transition: opacity 0.15s ease, transform 0.1s ease;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.simon-pad:active { transform: scale(0.95); }
.simon-pad.lit { opacity: 1; box-shadow: 0 0 0 4px #fff, 0 0 22px rgba(0,0,0,0.25); }
.simon-pad.pad-0 { background: #ff6b6b; }
.simon-pad.pad-1 { background: #4dc3ff; }
.simon-pad.pad-2 { background: #ffd93d; }
.simon-pad.pad-3 { background: #6fd08c; }
.simon-status {
  text-align: center;
  font-weight: 800;
  font-size: 1.1rem;
  margin-bottom: 14px;
  min-height: 1.4em;
}

/* ---- Catch Me! ---- */
.catch-field {
  position: relative;
  width: 100%;
  height: 60vh;
  max-height: 480px;
  min-height: 320px;
  background: linear-gradient(180deg, #cdeeff 0%, #d7f5d0 55%, #eafbe8 100%);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.catch-field::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 22%;
  background: linear-gradient(180deg, #bdeab0, #9adf8c);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.catch-critter {
  position: absolute;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.3rem;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  transform: scale(0);
  animation: critter-pop 0.35s var(--ease-bounce) forwards, critter-wiggle 1.4s ease-in-out infinite;
  user-select: none;
}
@keyframes critter-pop {
  to { transform: scale(1); }
}
@keyframes critter-wiggle {
  0%, 100% { transform: scale(1) rotate(-4deg); }
  50% { transform: scale(1) rotate(4deg); }
}
.catch-critter.thief {
  background: rgba(255, 210, 200, 0.85);
  box-shadow: 0 4px 10px rgba(200, 80, 60, 0.25);
}
.catch-critter.caught {
  animation: critter-caught 0.3s ease forwards !important;
}
@keyframes critter-caught {
  to { transform: scale(1.7); opacity: 0; }
}
.catch-critter.oops {
  animation: critter-oops 0.4s ease forwards !important;
}
@keyframes critter-oops {
  0% { transform: scale(1); }
  30% { transform: scale(1.25) rotate(-10deg); }
  100% { transform: scale(0) rotate(14deg); opacity: 0; }
}
.catch-puff {
  position: absolute;
  font-size: 1.6rem;
  pointer-events: none;
  animation: puff-fade 0.5s ease forwards;
}
@keyframes puff-fade {
  0% { opacity: 1; transform: translateY(0) scale(0.8); }
  100% { opacity: 0; transform: translateY(-20px) scale(1.4); }
}

/* ---- Odd One Out ---- */
.oddout-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  max-width: 420px;
  margin: 0 auto;
}
.oddout-cell {
  aspect-ratio: 1/1;
  border-radius: var(--radius-sm);
  background: #f6f3ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(2rem, 8vw, 3rem);
  box-shadow: var(--shadow-pop);
  transition: transform 0.15s var(--ease-bounce);
}
.oddout-cell:active { transform: scale(0.92); }
.oddout-cell.correct { background: #d8f7df; animation: pop-match 0.4s var(--ease-bounce); }
.oddout-cell.wrong { animation: shake 0.35s ease; }
.oddout-cell.done { opacity: 0.5; pointer-events: none; }

/* ---- What Comes Next? ---- */
.sequence-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: #fff6e0;
  border-radius: var(--radius-md);
  padding: 20px 14px;
  margin-bottom: 18px;
}
.sequence-item {
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  flex-shrink: 0;
}
.sequence-item.question-mark {
  border: 3px dashed var(--purple);
  color: var(--purple);
  font-weight: 800;
  background: #f6f3ff;
  box-shadow: none;
}
.whatnext-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 12px;
}
.whatnext-btn {
  aspect-ratio: 1/1;
  background: #f6f3ff;
  border-radius: var(--radius-sm);
  font-size: 2.2rem;
  box-shadow: var(--shadow-pop);
  transition: transform 0.15s var(--ease-bounce);
}
.whatnext-btn:active { transform: scale(0.92); }
.whatnext-btn.correct { background: #d8f7df; animation: pop-match 0.4s var(--ease-bounce); }
.whatnext-btn.wrong { animation: shake 0.35s ease; }

/* ---- Drawing pad ---- */
.draw-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.color-swatch {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  box-shadow: var(--shadow-pop);
  border: 3px solid #fff;
}
.color-swatch.active { outline: 3px solid var(--ink); outline-offset: 2px; }
.tool-btn {
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tool-btn.active { background: #f3ecff; box-shadow: inset 0 0 0 3px var(--purple); }
#drawCanvas {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-soft);
  touch-action: none;
  display: block;
}

/* ---- Floating praise text ---- */
.praise-pop {
  position: fixed;
  transform: translate(-50%, -50%);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--pink);
  text-shadow: 0 2px 0 #fff, 0 4px 8px rgba(0,0,0,0.15);
  pointer-events: none;
  z-index: 200;
  animation: praise-float 1s ease forwards;
  white-space: nowrap;
}
@keyframes praise-float {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  25% { opacity: 1; transform: translate(-50%, -80%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

/* ---- Win overlay ---- */
.win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(58, 46, 92, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.win-overlay[hidden] { display: none; }
.win-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 32px 26px;
  text-align: center;
  max-width: 340px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(58, 46, 92, 0.35);
  animation: win-pop 0.4s var(--ease-bounce);
}
@keyframes win-pop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.win-card .win-emoji { font-size: 3.4rem; }
.win-card h2 { margin: 6px 0 4px; }
.win-card .stars-earned { font-size: 2rem; margin: 10px 0; letter-spacing: 6px; }
.win-actions { display: flex; gap: 10px; margin-top: 18px; }
.win-actions button {
  flex: 1;
  padding: 13px;
  border-radius: 999px;
  font-weight: 800;
  box-shadow: var(--shadow-pop);
  transition: transform 0.15s var(--ease-bounce);
}
.win-actions button:hover { transform: translateY(-2px) scale(1.03); }
.win-actions button:active { transform: scale(0.95); }
.win-actions .btn-again { background: var(--green); color: #fff; }
.win-actions .btn-home { background: #f3ecff; color: var(--ink); }
