/* Candy Cuddle Kids — Picture Puzzle (all rules scoped to .g-puzzle) */
.g-puzzle .pz-sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.g-puzzle .btn-sm { min-height: 46px; }
.g-puzzle .seg button { min-height: 44px; min-width: 56px; }
.g-puzzle .pz-num-btn { font-family: var(--head); font-weight: 700; font-size: .95rem; }
.g-puzzle .pz-num-btn[aria-pressed="true"] { background: var(--berry); color: #fff; box-shadow: none; }
.g-puzzle .pz-peek-btn { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.g-puzzle .pz-peek-btn.is-on { transform: translateY(3px); box-shadow: 0 3px 0 var(--gold-dark); }

/* layout */
.g-puzzle .pz-stage { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; align-items: center; }
.g-puzzle .pz-board-wrap { min-width: 0; display: flex; justify-content: center; }

/* the board: always square, sized to its container */
.g-puzzle .pz-board {
  --n: 3; --gap: clamp(2px, .5vw, 4px);
  position: relative; width: 100%; max-width: min(580px, max(280px, calc(100vh - 240px))); aspect-ratio: 1 / 1;
  border-radius: 20px; background: var(--ink); overflow: hidden; padding: 0;
  box-shadow: 0 0 0 6px var(--peach), 0 0 0 9px #fff, var(--shadow);
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; cursor: pointer;
}
.g-puzzle .pz-board:focus-visible { outline: 5px solid var(--gold); outline-offset: 12px; }
.g-puzzle .pz-board.is-loading::after {
  content: ""; position: absolute; inset: 0; z-index: 4;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .5) 50%, transparent 70%) var(--sky);
  background-size: 250% 100%; animation: pzShimmer 1.2s linear infinite;
}
.g-puzzle .pz-tile {
  position: absolute; left: 0; top: 0; width: calc(100% / var(--n)); height: calc(100% / var(--n));
  background-repeat: no-repeat; background-color: var(--sky);
  border-radius: clamp(4px, 1.2vw, 10px);
  box-shadow: inset 0 0 0 var(--gap) var(--ink), inset 0 0 0 calc(var(--gap) + 1.5px) rgba(255, 255, 255, .55), inset 0 -6px 10px -6px rgba(0, 0, 0, .35);
  transition: transform .16s cubic-bezier(.3, .8, .4, 1);
  will-change: transform;
}
.g-puzzle .pz-board.no-anim .pz-tile { transition: none; }
.g-puzzle .pz-tile.is-gap { opacity: 0; visibility: hidden; }
.g-puzzle .pz-tile.shake { animation: pzShake .35s ease; }
.g-puzzle .pz-tile-n {
  position: absolute; left: 8%; top: 8%; min-width: 1.6em; height: 1.6em; padding: 0 .35em; border-radius: 999px; display: none; place-items: center;
  background: rgba(255, 255, 255, .92); color: var(--ink); font: 700 clamp(11px, 2.4vw, 17px)/1 var(--head); box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.g-puzzle .pz-board.show-nums .pz-tile-n { display: grid; }
.g-puzzle .pz-peek {
  position: absolute; inset: 0; z-index: 3; background-size: cover; background-position: center; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.g-puzzle .pz-board.is-peeking .pz-peek { opacity: .78; }

/* solved: last piece fades in, board glows */
.g-puzzle .pz-board.is-solved { background: #fff; box-shadow: 0 0 0 6px var(--gold), 0 0 0 9px #fff, 0 0 40px 10px rgba(255, 201, 77, .7); animation: pzGlow 1.2s ease; }
.g-puzzle .pz-board.is-solved .pz-tile { box-shadow: none; border-radius: 0; transition: transform .16s, box-shadow .6s, border-radius .6s; }
.g-puzzle .pz-board.is-solved .pz-tile.is-gap { visibility: visible; opacity: 1; animation: pzFill .7s cubic-bezier(.2, 1.4, .4, 1) both; }
.g-puzzle .pz-board.is-solved .pz-tile-n { display: none; }

/* Barry + goal picture */
.g-puzzle .pz-side { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.g-puzzle .pz-buddy { display: flex; flex-direction: column-reverse; align-items: center; gap: 6px; width: 100%; }
.g-puzzle .pz-buddy-img { height: 160px; width: auto; filter: drop-shadow(0 8px 10px rgba(60, 30, 35, .2)); }
.g-puzzle .pz-bubble {
  position: relative; margin: 0; width: 100%; background: var(--peach); color: var(--ink); font-family: var(--head); font-weight: 600; font-size: 1.08rem; line-height: 1.3;
  text-align: center; padding: 12px 16px; border-radius: 20px;
}
.g-puzzle .pz-bubble::after { content: ""; position: absolute; left: 50%; bottom: -10px; margin-left: -10px; border: 10px solid transparent; border-bottom: 0; border-top-color: var(--peach); }
.g-puzzle .pz-bubble.pop { animation: pzPop .35s cubic-bezier(.2, 1.5, .4, 1); }
.g-puzzle .pz-goal { margin: 0; width: 100%; max-width: 200px; text-align: center; }
.g-puzzle .pz-goal-img { width: 100%; aspect-ratio: 1; border-radius: 16px; box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--line); object-fit: cover; background: var(--sky); }
.g-puzzle .pz-goal figcaption { margin-top: 10px; line-height: 1.25; }
.g-puzzle .pz-goal-k { display: block; font-family: var(--head); font-weight: 600; font-size: .78rem; letter-spacing: 1.5px; text-transform: uppercase; color: var(--berry); }
.g-puzzle .pz-goal-title { font-family: var(--head); font-weight: 600; font-size: 1rem; }

/* picture chooser */
.g-puzzle .pz-pics-title { font-size: 1.1rem; margin: 30px 0 10px; color: var(--ink-soft); }
.g-puzzle .pz-pics { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px; }
.g-puzzle .pz-pic {
  padding: 0; border: 0; border-radius: 14px; overflow: hidden; aspect-ratio: 1; min-width: 44px; cursor: pointer; background: var(--sky);
  box-shadow: 0 0 0 3px var(--line); transition: transform .15s, box-shadow .15s;
}
.g-puzzle .pz-pic img { width: 100%; height: 100%; object-fit: cover; }
.g-puzzle .pz-pic:hover { transform: translateY(-3px); }
.g-puzzle .pz-pic[aria-pressed="true"] { box-shadow: 0 0 0 4px var(--berry); transform: translateY(-3px); }

@media (max-width: 900px) {
  .g-puzzle .pz-stage { grid-template-columns: 1fr; gap: 18px; }
  .g-puzzle .pz-side { flex-direction: row; justify-content: center; align-items: center; gap: 14px; order: -1; }
  .g-puzzle .pz-buddy { flex-direction: row; flex: 1 1 auto; max-width: 440px; gap: 4px; }
  .g-puzzle .pz-buddy-img { height: 92px; }
  .g-puzzle .pz-bubble { text-align: left; font-size: 1rem; padding: 10px 14px; }
  .g-puzzle .pz-bubble::after { left: -10px; top: 50%; bottom: auto; margin: -10px 0 0; border: 10px solid transparent; border-left: 0; border-right-color: var(--peach); }
  .g-puzzle .pz-goal { flex: 0 0 92px; }
  .g-puzzle .pz-goal figcaption { display: none; }
  .g-puzzle .pz-pics { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .g-puzzle .game-bar { justify-content: center; }
  .g-puzzle .pz-board { box-shadow: 0 0 0 4px var(--peach), 0 0 0 6px #fff, var(--shadow-sm); border-radius: 14px; }
  .g-puzzle .pz-board.is-solved { box-shadow: 0 0 0 4px var(--gold), 0 0 0 6px #fff, 0 0 30px 6px rgba(255, 201, 77, .7); }
  .g-puzzle .pz-buddy-img { height: 74px; }
  .g-puzzle .pz-goal { flex-basis: 70px; }
  .g-puzzle .pz-goal-img { border-radius: 10px; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--line); }
  .g-puzzle .pz-pics { gap: 8px; }
  .g-puzzle .seg button { padding: 8px 10px; min-width: 50px; }
}
@media (max-width: 380px) {
  .g-puzzle .pz-best { display: none; }
}

@keyframes pzShimmer { to { background-position: -150% 0; } }
@keyframes pzShake { 25% { margin-left: -5px; } 75% { margin-left: 5px; } }
@keyframes pzFill { from { opacity: 0; filter: brightness(1.8); } }
@keyframes pzGlow { 40% { box-shadow: 0 0 0 6px var(--gold), 0 0 0 9px #fff, 0 0 70px 24px rgba(255, 201, 77, .9); } }
@keyframes pzPop { from { transform: scale(.85); } }

@media (prefers-reduced-motion: reduce) {
  .g-puzzle .pz-board.is-loading::after { background: var(--sky); }
}
