/* Puzzle game — styled against the site's design tokens (see :root in
   style.css). Reuses .btn, .section-heading, .book-age, and .ink-trail
   from the main stylesheet rather than redefining them. The card-grid
   library layout, empty-state message, and difficulty picker are shared
   across /games/ and now live in games.css as .game-grid, .game-card,
   .game-empty, and .difficulty-picker/.difficulty-btn. */

.puzzle-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.puzzle-reference:not([hidden]) {
  display: block;
  width: 140px;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

@media (min-width: 820px) {
  .puzzle-layout {
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 1.75rem;
  }

  .puzzle-reference:not([hidden]) {
    width: 200px;
  }
}

.puzzle-frame {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 20px;
  width: min(100%, 520px);
  margin: 0 auto;
}

.puzzle-board {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 4px;
  box-sizing: border-box;
  background: var(--ink);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.puzzle-piece {
  border: none;
  padding: 0;
  margin: 0;
  background-repeat: no-repeat;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.puzzle-piece:hover:not(:disabled) {
  filter: brightness(1.08);
}

.puzzle-piece.is-selected {
  outline: 3px solid var(--mustard);
  outline-offset: -3px;
  z-index: 2;
  position: relative;
  transform: scale(1.04);
  box-shadow: 0 6px 14px rgba(38, 50, 74, 0.35);
}

.puzzle-board.is-solved {
  gap: 0;
  padding: 0;
  background: none;
  animation: puzzle-solved-pop 0.5s ease;
}

.puzzle-board.is-solved .puzzle-piece {
  cursor: default;
}

@keyframes puzzle-solved-pop {
  0% { transform: scale(0.96); opacity: 0.6; }
  60% { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .puzzle-board.is-solved { animation: none; }
}

.puzzle-page {
  text-align: center;
  padding-bottom: 3rem;
}

.puzzle-status {
  margin-top: 1.25rem;
  font-weight: 700;
  min-height: 1.6em;
}

.puzzle-status.is-solved {
  font-family: var(--font-hand);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--coral-deep);
  display: inline-block;
  transform: rotate(-1.5deg);
}

.puzzle-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.75rem;
}

