.image-puzzle-modal {
  position: fixed;
  inset: 0;
  z-index: 12020;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.image-puzzle-content {
  position: relative;
  width: min(94vw, 430px);
  height: min(calc(var(--vh, 1vh) * 82), 660px);
  min-height: 520px;
  background: var(--modal-frame-image) center / 100% 100% no-repeat;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 52px 54px 46px;
  color: #fff;
  overflow: hidden;
}

.image-puzzle-close {
  top: 7.5%;
  right: 14%;
}

.image-puzzle-title {
  margin: 0;
  max-width: 74%;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.08;
  text-shadow: 0 2px 5px #000;
}

.image-puzzle-progress {
  margin: 12px 0 14px;
  min-width: 74px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('/static/images/icons/tab.webp') center / 100% 100% no-repeat;
  color: #f4ead9;
  font-size: 17px;
  font-weight: 700;
  text-shadow: 0 2px 3px #000;
}

.image-puzzle-board {
  width: min(72vw, 302px);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  padding: 7px;
  background: rgba(6, 14, 18, 0.74);
  border: 1px solid rgba(235, 211, 165, 0.45);
  box-shadow:
    inset 0 0 20px rgba(0, 0, 0, 0.9),
    0 8px 24px rgba(0, 0, 0, 0.45);
  touch-action: none;
}

.image-puzzle-tile {
  position: relative;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(247, 219, 176, 0.35);
  border-radius: 4px;
  background-color: #13252a;
  background-size: 300% 300%;
  background-repeat: no-repeat;
  cursor: grab;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
  touch-action: none;
  appearance: none;
}

.image-puzzle-tile:active {
  cursor: grabbing;
}

.image-puzzle-tile.selected {
  z-index: 2;
  filter: brightness(1.13);
  box-shadow:
    inset 0 0 10px rgba(0, 0, 0, 0.4),
    0 0 0 2px #d42a2a,
    0 0 16px rgba(255, 70, 70, 0.7);
}

.image-puzzle-tile.drag-source {
  opacity: 0.38;
}

.image-puzzle-board.solved .image-puzzle-tile {
  filter: brightness(1.2);
  box-shadow:
    inset 0 0 8px rgba(255, 255, 255, 0.18),
    0 0 12px rgba(113, 255, 126, 0.45);
}

.image-puzzle-ghost {
  position: fixed;
  z-index: 14000;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.06);
  border: 1px solid rgba(247, 219, 176, 0.6);
  border-radius: 4px;
  background-size: 300% 300%;
  background-repeat: no-repeat;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.58), 0 0 18px rgba(255, 70, 70, 0.4);
}

@media (max-width: 480px) {
  .image-puzzle-content {
    width: 100vw;
    height: calc(var(--vh, 1vh) * 76);
    min-height: 500px;
    padding: 46px 50px 42px;
  }

  .image-puzzle-title {
    font-size: 21px;
  }

  .image-puzzle-board {
    width: min(74vw, 290px);
  }
}
