html, body {
  overflow: hidden;
  overscroll-behavior: none;
}

.game {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0.75rem 1rem 1rem;
  gap: 1rem;
}

.game-head {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
}

.back {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  font-size: 1.5rem;
  background: var(--c-tile);
  border-radius: var(--r-tile);
  text-decoration: none;
  color: var(--c-text);
  font-weight: 700;
  box-shadow: var(--shadow-tile);
  line-height: 1;
}

.back:active {
  transform: translateY(3px);
  box-shadow: var(--shadow-tile-sm);
}

.prompt {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.3rem 0.4rem;
  font-family: inherit;
  text-align: center;
  margin: 0;
  font-size: clamp(1rem, 5vw, 1.5rem);
  font-weight: 700;
  line-height: 1;
  color: var(--c-text);
  background: var(--c-tile);
  padding: 0.7rem 0.9rem;
  border: none;
  border-radius: var(--r-tile);
  box-shadow: var(--shadow-tile);
  cursor: pointer;
}

/* Multi-sentence prompts (arrival game) group their tokens visually so the
 * three statements read as separate beats instead of one long blob. */
.prompt-multi {
  gap: 0.55rem 0.95rem;
}

.prompt-sentence {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
}

.prompt-icon {
  width: 1.7em;
  height: 1.7em;
  display: inline-block;
  vertical-align: middle;
  filter: grayscale(0.6) brightness(0.85);
  opacity: 0.75;
  transition: transform 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
}

.prompt-plus {
  font-weight: 700;
  color: var(--c-muted);
  margin: 0 0.1em;
  transition: color 0.18s ease;
}

.prompt-plus.is-speaking {
  color: var(--c-accent);
}

.prompt-word {
  color: var(--c-muted);
  white-space: nowrap;
  transition: color 0.18s ease, transform 0.18s ease;
}

.prompt-text {
  color: var(--c-muted);
  transition: color 0.18s ease, transform 0.18s ease;
}

.prompt-text.is-speaking,
.prompt-word.is-speaking {
  color: var(--c-accent);
  transform: scale(1.12);
}

.prompt-icon.is-speaking {
  transform: scale(1.25);
  filter: grayscale(0) brightness(1) drop-shadow(0 5px 0 var(--c-tile-shadow));
  opacity: 1;
}

.prompt-text { line-height: 1; }


/* ── Jigsaw ─────────────────────────────────────────────────────────── */

/* Play area: board + tray. Pieces are positioned in px by the engine. */
.puzzle-area {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--c-tile);
  border-radius: var(--r-tile-lg);
  box-shadow: var(--shadow-tile);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}

.feedback-correct .puzzle-area {
  box-shadow: 0 8px 0 var(--c-success-shadow);
  background: var(--c-success);
}

.board {
  position: absolute;
  border-radius: 10px;
  overflow: visible;
}

.board-svg,
.board-done {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Light, full-colour copy of the whole scene under the slots, so each
 * piece has a visible match on the board. */
.board-ghost {
  opacity: 0.4;
  filter: saturate(0.75);
}

.board-svg {
  border-radius: 6px;
  background: #fff;
}

.slot-outline {
  fill: none;
  stroke: var(--c-muted);
  stroke-width: 1.5;
  stroke-dasharray: 6 5;
  opacity: 0.6;
  vector-effect: non-scaling-stroke;
}

.board-done {
  z-index: 3;
}

.board-done.is-pop {
  animation: picture-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes picture-pop {
  0%   { transform: scale(1); }
  40%  { transform: translateY(-14px) scale(1.07); }
  70%  { transform: translateY(3px) scale(0.98); }
  100% { transform: scale(1); }
}

.board.is-entering { animation: board-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
.board.is-leaving  { animation: board-out 0.3s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards; }

@keyframes board-in {
  0%   { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}
@keyframes board-out {
  0%   { transform: scale(1);   opacity: 1; }
  100% { transform: scale(0.6); opacity: 0; }
}

/* Wrapper holds position + tray scale; the inner svg holds animations. */
.piece {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  transform-origin: 50% 50%;
  transition: left 0.18s ease-out, top 0.18s ease-out, transform 0.18s ease-out;
  will-change: left, top, transform;
}

.piece.is-dragging {
  z-index: 4;
  transition: transform 0.12s ease-out;
}

.piece.is-placed { z-index: 1; }

/* The finished picture overlay takes over; pieces would show seams. */
.piece.is-done { visibility: hidden; }

.piece-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.16));
  transition: filter 0.15s ease;
}

.piece.is-dragging .piece-svg {
  filter: drop-shadow(0 12px 6px rgba(0, 0, 0, 0.22));
}

.piece.is-placed .piece-svg {
  filter: none;
}

.piece-edge {
  fill: none;
  stroke: #fff;
  stroke-width: 2.5;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  cursor: grab;
}

.piece.is-dragging .piece-edge { cursor: grabbing; }

.piece.is-placed .piece-edge {
  stroke: rgba(255, 255, 255, 0.7);
  stroke-width: 1.5;
  cursor: default;
}

.piece-svg.is-snap {
  animation: snap 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes snap {
  0%   { transform: scale(1.08); }
  50%  { transform: scale(0.96); }
  100% { transform: scale(1); }
}

.piece-svg.is-entering { animation: bobble-in-piece 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
.piece-svg.is-leaving  { animation: bobble-out-piece 0.3s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards; }

@keyframes bobble-in-piece {
  0%   { transform: scale(0);    opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}
@keyframes bobble-out-piece {
  0%   { transform: scale(1); opacity: 1; }
  100% { transform: scale(0); opacity: 0; }
}
