.jigsaw {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
}

.jigsaw__lead {
  margin: 0 0 1.1rem;
  color: #475569;
  font-size: .95rem;
}

.jigsaw-setup {
  display: flex;
  flex-direction: column;
  gap: .9rem;
  margin-bottom: 1rem;
}

.jigsaw-presets {
  display: flex;
  justify-content: center;
  gap: .6rem;
  flex-wrap: wrap;
}

.jigsaw-preset {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  width: 60px;
  height: 60px;
  padding: 0;
  background-size: cover;
  background-position: center;
  border-radius: 10px;
  border: 3px solid transparent;
}

.jigsaw-preset.is-active {
  border-color: #0891b2;
}

.jigsaw-difficulty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.jigsaw-difficulty__label {
  font-size: .82rem;
  font-weight: 700;
  color: #64748b;
}

.jigsaw-diff-btn {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  padding: .35rem .9rem;
  font-size: .85rem;
  font-weight: 700;
  color: #334155;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
}

.jigsaw-diff-btn.is-active {
  color: #fff;
  background: #0891b2;
  border-color: #0891b2;
}

.jigsaw-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.jigsaw-stats__item {
  display: flex;
  flex-direction: column;
}

.jigsaw-stats__label {
  font-size: .74rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.jigsaw-stats__value {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.jigsaw-stats__actions {
  display: flex;
  gap: .5rem;
}

.jigsaw-stats__actions button {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  padding: .45rem .9rem;
  font-size: .82rem;
  font-weight: 700;
  color: #0891b2;
  background: #fff;
  border: 1px solid #0891b2;
  border-radius: 999px;
}

.jigsaw-stats__actions button:hover {
  background: #ecfeff;
}

.jigsaw-board-wrap {
  position: relative;
  display: inline-block;
}

.jigsaw-board {
  display: grid;
  grid-template-columns: repeat(var(--jigsaw-cols, 4), 1fr);
  grid-template-rows: repeat(var(--jigsaw-cols, 4), 1fr);
  width: min(90vw, 420px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px -14px rgba(15, 23, 42, .45);
  background: #e2e8f0;
}

.jigsaw-piece {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  padding: 0;
  border: none;
  outline: 1px solid rgba(255, 255, 255, .35);
  outline-offset: -1px;
  background-repeat: no-repeat;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}

.jigsaw-piece:hover {
  filter: brightness(1.06);
}

.jigsaw-piece.is-selected {
  outline: 3px solid #f59e0b;
  outline-offset: -3px;
  transform: scale(.92);
  z-index: 2;
  position: relative;
}

.jigsaw-hint {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: 10px;
  border: 3px solid #fff;
  box-shadow: 0 8px 22px -10px rgba(15, 23, 42, .55);
  background: #e2e8f0;
}

.jigsaw-complete {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: 1.5rem;
  background: rgba(15, 23, 42, .75);
  animation: jigsaw-fade .2s ease;
}

@keyframes jigsaw-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.jigsaw-complete__title {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
}

.jigsaw-complete__stats {
  margin: 0 0 .6rem;
  font-size: 1.05rem;
  color: #fde68a;
  font-weight: 700;
}

.jigsaw-complete button {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  padding: .7rem 1.6rem;
  font: inherit;
  font-weight: 700;
  color: #0f172a;
  background: #22d3ee;
  border: 1px solid transparent;
  border-radius: 999px;
}

.jigsaw-complete button:hover {
  background: #06b6d4;
}

.jigsaw-hint-note {
  margin: 1rem 0 0;
  font-size: .8rem;
  color: #94a3b8;
}

@media (max-width: 480px) {
  .jigsaw-hint {
    width: 76px;
    height: 76px;
    right: -4px;
    bottom: -4px;
  }
}
