/* A picture to rebuild, with a stable reserve of real image fragments. */
.puzzle-scene { --puzzle-columns: 2; --puzzle-rows: 2; display: flex; align-items: center; justify-content: center; gap: clamp(26px, 5vw, 70px); max-width: 1000px; padding: 6px 8px; }
.puzzle-picture-area { flex: 0 1 490px; min-width: 0; }
.puzzle-board { --puzzle-frame: 10px; box-sizing: content-box; position: relative; display: grid; grid-template-columns: repeat(var(--puzzle-columns), 1fr); grid-template-rows: repeat(var(--puzzle-rows), 1fr); width: calc(100% - var(--puzzle-frame) * 2); aspect-ratio: 5 / 4; padding: var(--puzzle-frame); border-radius: 20px; background: #d8c5a3; box-shadow: 0 7px 0 #ad9878, 0 14px 24px rgb(0 0 0 / 12%); overflow: hidden; }
.puzzle-model { position: absolute; inset: var(--puzzle-frame); opacity: 0; pointer-events: none; transition: opacity 180ms ease; }
.puzzle-scene[data-level="1"] .puzzle-model { opacity: .25; }
.puzzle-scene[data-level="2"] .puzzle-model { opacity: .16; }
.puzzle-show-model .puzzle-model { opacity: .56 !important; }
.puzzle-slot { position: relative; padding: 0; min-width: 0; min-height: 0; border: 1px solid #ac9e82; border-radius: 0; background: transparent; color: #716349; touch-action: manipulation; }
.puzzle-slot-art { position: absolute; inset: 0; display: block; }
.puzzle-slot svg, .puzzle-piece svg, .puzzle-flight svg, .puzzle-model svg, .puzzle-reference > svg { overflow: hidden; }
.puzzle-slot-number { position: absolute; z-index: 1; top: 6px; left: 7px; display: none; font-size: 12px; font-weight: 600; }
.puzzle-slot.puzzle-filled { border-color: transparent; cursor: default; }
.puzzle-filled .puzzle-slot-art { inset: -1px; }
.puzzle-slot.puzzle-pending .puzzle-slot-art { visibility: hidden; }
.puzzle-has-selection .puzzle-slot:not(.puzzle-filled):hover, .puzzle-slot.puzzle-over { box-shadow: inset 0 0 0 3px #7b715c; }
.puzzle-slot:focus-visible { z-index: 2; outline: 3px solid #236179; outline-offset: -5px; }
.puzzle-reserve-area { flex: 0 1 390px; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.puzzle-tray { display: grid; grid-template-columns: repeat(var(--puzzle-columns), minmax(0, 1fr)); gap: 16px; }
.puzzle-rest { aspect-ratio: calc(300 / var(--puzzle-columns)) / calc(240 / var(--puzzle-rows)); min-width: 0; background: var(--play-hover); border-radius: 6px; box-shadow: inset 0 0 0 1px var(--tf-border); }
.puzzle-piece { display: block; position: relative; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 5px; background: #f4ebd7; box-shadow: 0 5px 0 #bca98a, 0 8px 13px rgb(0 0 0 / 12%); touch-action: none; transform-origin: center; }
.puzzle-piece > svg { border-radius: inherit; pointer-events: none; }
.puzzle-piece[aria-pressed="true"] { outline: 4px solid var(--tf-accent-text); outline-offset: 5px; }
.puzzle-piece:focus-visible { outline: var(--tf-focus-ring); outline-offset: 5px; }
.puzzle-piece.puzzle-placed { visibility: hidden; pointer-events: none; }
.puzzle-piece.puzzle-dragging { z-index: 8; cursor: grabbing; pointer-events: auto; outline-width: 3px; box-shadow: 0 7px 20px rgb(0 0 0 / 22%); }
.puzzle-piece-number { position: absolute; top: 5px; left: 5px; display: none; padding: 0 4px; border-radius: 3px; background: #fff8e7; color: #45565b; font: 600 12px/1.5 var(--tf-font); pointer-events: none; }
.puzzle-scene:focus-within .puzzle-piece-number, .puzzle-scene:focus-within .puzzle-slot:not(.puzzle-filled) .puzzle-slot-number { display: block; }
.puzzle-assist { display: flex; align-items: center; justify-content: flex-start; gap: 16px; }
.puzzle-reference { position: relative; flex: 0 0 86px; width: 86px; height: 69px; padding: 3px; border: 1px solid var(--tf-control-border); border-radius: 7px; background: #eee3ca; color: #172b3a; touch-action: manipulation; }
.puzzle-reference-icon { position: absolute; right: -6px; bottom: -6px; display: block; width: 25px; height: 25px; padding: 3px; border-radius: 50%; background: #fff7e5; box-shadow: 0 0 0 1px #b2a68c; }
.puzzle-reference[aria-pressed="true"] { outline: 3px solid var(--tf-link); outline-offset: 3px; }
.puzzle-status { margin: 0; color: var(--tf-muted); font-size: .84rem; line-height: 1.4; min-height: 2.8em; max-width: 200px; }
.puzzle-hint, .puzzle-piece.puzzle-hint { outline: 3px dashed var(--tf-link); outline-offset: 5px; }
.puzzle-slot.puzzle-hint { z-index: 2; outline-color: #236179; outline-offset: -6px; }
.puzzle-flight { position: fixed; z-index: 20; pointer-events: none; transform-origin: top left; }
.puzzle-complete .puzzle-slot { border-color: transparent; }
@media (max-width: 600px) and (orientation: portrait) {
  .puzzle-scene { flex-direction: column; gap: 19px; padding: 0 8px; }
  .puzzle-picture-area { flex: 0 0 auto; width: min(100%, 310px, calc((100dvh - 360px) * 1.25)); }
  .puzzle-board { --puzzle-frame: 7px; border-radius: 14px; box-shadow: 0 5px 0 #ad9878; }
  .puzzle-reserve-area { flex: 0 0 auto; width: min(100%, 260px); gap: 17px; }
  .puzzle-tray { gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .puzzle-scene[data-level="1"] .puzzle-tray, .puzzle-scene[data-level="2"] .puzzle-tray { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 76%; margin-inline: auto; }
  .puzzle-assist { justify-content: center; gap: 12px; }
  .puzzle-reference { width: 60px; flex-basis: 60px; height: 48px; }
  .puzzle-status { font-size: .75rem; max-width: 160px; }
}
@media (max-width: 600px) and (max-height: 670px) and (orientation: portrait) {
  body[data-game="puzzle"] .play-topline { flex-basis: 72px; }
  body[data-game="puzzle"] .play-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  body[data-game="puzzle"] .play-heading h1 { font-size: 21px; }
  body[data-game="puzzle"] .play-heading > p:last-child { margin-top: 3px; font-size: 12px; }
  body[data-game="puzzle"] .game-progress { margin-top: 7px; flex-basis: 15px; }
  .puzzle-scene { gap: 14px; }
  .puzzle-picture-area { width: min(225px, calc((100dvh - 420px) * 1.25)); }
  .puzzle-reserve-area { width: 198px; gap: 12px; }
  .puzzle-tray { gap: 10px; }
  .puzzle-scene[data-level="2"] .puzzle-tray { width: 158px; }
  .puzzle-scene[data-level="1"] .puzzle-tray { width: 140px; }
  .puzzle-reference { flex-basis: 56px; width: 56px; height: 45px; }
}
@media (max-width: 600px) and (max-height: 550px) and (orientation: portrait) {
  .puzzle-scene { position: relative; }
  .puzzle-picture-area { width: 165px; margin-right: 70px; }
  .puzzle-reserve-area { width: 178px; }
  .puzzle-assist { position: absolute; top: 45px; right: 5px; }
  .puzzle-status { display: none; }
}
@media (max-height: 520px) and (orientation: landscape) {
  body[data-game="puzzle"] .play-view { --play-bottom-space: calc(65px + env(safe-area-inset-bottom, 0px)); }
  body[data-game="puzzle"] .play-topline { flex-basis: 69px; }
  body[data-game="puzzle"] .play-heading h1 { font-size: 20px; }
  body[data-game="puzzle"] .play-heading > p:last-child { font-size: 11px; }
  body[data-game="puzzle"] .game-content { margin-top: 5px; }
  .puzzle-scene { gap: 26px; padding: 0 8px; }
  .puzzle-picture-area { flex: 0 0 auto; width: min(40vw, calc((100dvh - 175px) * 1.25)); }
  .puzzle-board { --puzzle-frame: 6px; border-radius: 13px; box-shadow: 0 4px 0 #ad9878; }
  .puzzle-reserve-area { flex: 0 0 auto; width: min(36vw, 245px); gap: 12px; }
  .puzzle-tray { gap: 10px; }
  .puzzle-scene[data-level="1"] .puzzle-tray { width: 140px; }
  .puzzle-scene[data-level="2"] .puzzle-tray { width: 155px; }
  .puzzle-reference { width: 56px; flex-basis: 56px; height: 45px; }
  .puzzle-status { font-size: .72rem; }
}
@media (max-height: 360px) and (orientation: landscape) {
  .puzzle-reserve-area { flex-direction: row; align-items: center; gap: 18px; width: 275px; }
  .puzzle-tray { flex: 1 1 auto; }
  .puzzle-scene[data-level="3"] .puzzle-tray { width: 184px; flex: 0 0 184px; }
  .puzzle-scene[data-level="2"] .puzzle-tray { flex: 0 0 141px; }
  .puzzle-assist { flex: 0 0 56px; }
  .puzzle-status { display: none; }
  .puzzle-scene { gap: 22px; }
  .puzzle-piece-number { top: 2px; left: 2px; font-size: 10px; }
}
@media (forced-colors: active) {
  .puzzle-piece, .puzzle-slot, .puzzle-reference { border: 2px solid ButtonText; }
  .puzzle-piece[aria-pressed="true"], .puzzle-slot.puzzle-hint { outline-color: Highlight; }
}

/* The guide is independent of the number of pieces. */
.puzzle-scene[data-guide="request"] .puzzle-model { opacity: 0; }
.puzzle-scene[data-guide="always"] .puzzle-model { opacity: .38; }
.puzzle-complete .puzzle-tray { opacity: 0; transition: opacity 240ms ease; }
.puzzle-complete .puzzle-assist { opacity: 0; transition: opacity 240ms ease; }
.puzzle-parent-setting .tf-help { margin: -4px 0 14px; }
.puzzle-scene[data-level="4"] .puzzle-tray { gap: 12px; }
@media (max-width: 600px) and (orientation: portrait) {
  .puzzle-scene[data-level="4"] { gap: 16px; }
  .puzzle-scene[data-level="4"] .puzzle-picture-area { width: min(280px, calc((100dvh - 424px) * 1.25)); }
  .puzzle-scene[data-level="4"] .puzzle-reserve-area { width: 222px; gap: 12px; }
}
@media (max-width: 600px) and (max-height: 670px) and (orientation: portrait) {
  .puzzle-scene[data-level="4"] { gap: 12px; }
  .puzzle-scene[data-level="4"] .puzzle-picture-area { width: 200px; }
  .puzzle-scene[data-level="4"] .puzzle-reserve-area { width: 190px; }
  .puzzle-scene[data-level="4"] .puzzle-tray { gap: 9px; }
  .puzzle-scene[data-level="4"] .puzzle-assist { position: absolute; top: 48px; right: 0; }
  .puzzle-scene[data-level="4"] .puzzle-status { display: none; }
  .puzzle-scene[data-level="4"] .puzzle-picture-area { margin-right: 60px; }
  .puzzle-scene[data-level="4"] { position: relative; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .puzzle-scene[data-level="4"] .puzzle-picture-area { width: min(38vw, calc((100dvh - 165px) * 1.25)); }
  .puzzle-scene[data-level="4"] .puzzle-reserve-area { flex-direction: row; align-items: center; gap: 14px; width: 262px; }
  .puzzle-scene[data-level="4"] .puzzle-tray { flex: 0 0 192px; width: 192px; gap: 10px; }
  .puzzle-scene[data-level="4"] .puzzle-assist { flex: 0 0 56px; }
  .puzzle-scene[data-level="4"] .puzzle-status { display: none; }
}
.reduce-motion .puzzle-complete .puzzle-tray, .reduce-motion .puzzle-complete .puzzle-assist { transition: none; }
@media (max-width: 600px) and (max-height: 550px) and (orientation: portrait) {
  body[data-game="puzzle"] .play-view:has(.puzzle-scene[data-level="4"]) { --play-bottom-space: calc(70px + env(safe-area-inset-bottom, 0px)); }
  .puzzle-scene[data-level="4"] { gap: 8px; }
  .puzzle-scene[data-level="4"] .puzzle-picture-area { width: 180px; }
  .puzzle-scene[data-level="4"] .puzzle-reserve-area { width: 180px; }
  .puzzle-scene[data-level="4"] .puzzle-tray { gap: 6px; }
}
