/* 15-puzzle — sliding tile board. Tile elements are absolutely positioned
   inside the board and translated to their (row, col) cell, so a CSS
   transform transition gives smooth sliding when state changes. */

.p15-wrap {
  display: flex;
  justify-content: center;
  padding: 24px 16px;
}

.p15-board {
  position: relative;
  width: min(82vmin, 480px);
  aspect-ratio: 1 / 1;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 4px;
  box-sizing: border-box;
  /* --p15-cells is set by JS based on difficulty */
  --p15-cells: 4;
  --p15-inner: calc(100% - 8px);
  --p15-cell:  calc(var(--p15-inner) / var(--p15-cells));
  touch-action: manipulation;
}

.p15-tile {
  position: absolute;
  left: 4px;
  top: 4px;
  width: var(--p15-cell);
  height: var(--p15-cell);
  background: #ffd54f;
  color: #222;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: clamp(22px, 7vmin, 48px);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}
/* Tile is currently in its goal position */
.p15-tile.solved-pos {
  background: #aed581;
}
/* When the whole puzzle is solved, fade slightly to "done" state */
.p15-board.solved .p15-tile {
  cursor: default;
  background: #aed581;
}

/* Top-bar mini-stats */
.p15-stat {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.p15-stat b {
  font-weight: 700;
  font-size: 16px;
  margin-left: 4px;
}

/* Win overlay */
#p15-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#p15-overlay.hidden { display: none; }
.p15-overlay-card {
  background: white;
  color: #222;
  padding: 32px 48px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.p15-overlay-card h1 { margin: 0 0 12px; font-size: 32px; }
.p15-overlay-card p  { margin: 0 0 18px; font-size: 16px; }

@media (max-width: 580px) {
  .p15-overlay-card { padding: 26px 36px; }
}
