/* Classic jigsaw: the complete image is cropped once to the same 4:3 viewBox
   used by the guide, tray and all locked pieces. */
.jg-board.jg-board {
  position: relative;
  display: block;
  direction: ltr;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  isolation: isolate;
  background: #21192f;
  box-shadow: inset 0 0 0 1px #8391be;
  touch-action: manipulation;
}
.jg-board .jg-picture,
.jg-board .jg-slots {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.jg-board .jg-picture { display: block; }
.jg-board .jg-ghost { opacity: .33; }
.jg-board .jg-guide {
  fill: transparent;
  stroke: #dbcde9;
  stroke-opacity: .78;
  stroke-width: 1.2px;
}
.jg-board .jg-guide.jg-filled { stroke-opacity: 0; }
.jg-board .jg-guide.jg-hinted {
  fill: #ebf8a8;
  fill-opacity: .42;
  stroke: #f1ff9c;
  stroke-width: 3px;
  stroke-opacity: 1;
  stroke-dasharray: 6 3;
}
.jg-board .jg-guide.jg-hovered {
  fill: #dce7ff;
  fill-opacity: .28;
  stroke: #eff4ff;
  stroke-width: 2px;
}
.jg-board .jg-guide.jg-wrong {
  fill: #ffc5ad;
  stroke: #ffdfc9;
  stroke-width: 2.5px;
  fill-opacity: .53;
}
.jg-board .jg-fixed-line,
.jg-tray .jg-piece-line,
.jg-floating-piece .jg-piece-line {
  fill: none;
  stroke: #fff5dd;
  stroke-opacity: .8;
  stroke-width: 1.2px;
  stroke-linejoin: round;
}
.jg-board .jg-slots { display: grid; direction: ltr; gap: 0; }
.jg-board .jg-slot.jg-slot {
  display: block;
  opacity: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  cursor: pointer;
}
.jg-board .jg-slot:focus-visible {
  outline: 3px dashed #f0ff9c;
  outline-offset: -4px;
  z-index: 1;
}
.jg-board .jg-slot:disabled { cursor: default; }
.jg-board[data-solved=true] .jg-slots { display: none; }
.jg-board.jg-board[data-solved=true] { aspect-ratio:1; }
.jg-board .jg-final {
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  background:#21192f;
  object-fit:contain;
  animation:jg-fade-in .35s ease-out;
}
@keyframes jg-fade-in { from { opacity: .8; } to { opacity: 1; } }
.jg-tray {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(min(83px,100%),1fr));
  align-items: stretch;
  justify-items: stretch;
  gap: 8px;
  padding: 10px;
  border: 1px solid #514360;
  border-radius: 12px;
  background-color: #221c30;
  background-image: radial-gradient(#4a3a5b 1px, transparent 1px);
  background-size: 12px 12px;
  direction: ltr;
}
.jg-tray:empty,
.jg-tray:not(:has(.jg-piece:not([hidden]))) { display: none; }
.jg-tray .jg-piece {
  display: grid;
  place-items: center;
  position: relative;
  width: 100%;
  max-width: 130px;
  min-width: 0;
  min-height: 46px;
  aspect-ratio: 1.14;
  justify-self: center;
  margin: 0;
  padding: 3px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
.jg-tray .jg-piece[hidden] { display: none; }
.jg-tray .jg-piece svg {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  filter: drop-shadow(0 3px 3px #090610c9);
}
.jg-tray .jg-piece[aria-pressed=true],
.jg-tray .jg-piece.jg-hinted {
  border: 2px solid #ffe0a4;
  background: #473448;
  padding: 2px;
}
.jg-tray .jg-piece:focus-visible {
  outline: 3px solid #ecff9e;
  outline-offset: 2px;
}
.jg-tray .jg-piece.jg-dragging { opacity: .45; cursor: grabbing; }
.jg-floating-piece {
  position: fixed;
  z-index: 9999;
  transform: translate(-50%, -50%);
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 5px 6px #08132d99);
}
@media (max-width: 650px) {
  .jg-tray { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; padding: 8px; }
}
@media (max-width: 350px) {
  .jg-tray { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .jg-board .jg-final { animation: none; }
}

/* Early rounds leave room for small fingers to see the photograph on each piece. */
.jg-tray[data-total="4"] { grid-template-columns: repeat(2,minmax(0,120px)); justify-content:center; }
@media(max-width:650px) {
  .jg-tray[data-total="4"] { grid-template-columns:repeat(2,minmax(0,91px)); column-gap:20px; }
  .jg-tray[data-total="6"] { grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media(max-width:650px) and (max-height:690px) {
  .jg-tray[data-total="4"] { grid-template-columns:repeat(4,minmax(0,1fr)); gap:4px; }
}
