.nip-puzzle {
  --nip-grid: 4;
  --nip-board-ratio: 1 / 1;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 18px;
  margin: 24px 0;
  background: #ffffff;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}

.nip-puzzle__panel {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.nip-puzzle__heading {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
}

.nip-puzzle__controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  align-items: end;
}

.nip-puzzle__field {
  display: grid;
  gap: 6px;
}

.nip-puzzle__field span,
.nip-puzzle__status {
  font-size: 0.95rem;
}

.nip-puzzle__field select,
.nip-puzzle__field input[type="file"] {
  width: 100%;
}

.nip-puzzle__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.nip-button {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
  background: #111827;
  color: #ffffff;
}

.nip-button--secondary {
  background: #e5e7eb;
  color: #111827;
}

.nip-puzzle__status {
  color: #374151;
  min-height: 1.3em;
}

.nip-puzzle__board-wrap {
  position: relative;
}

.nip-puzzle__placeholder {
  border: 2px dashed #d1d5db;
  border-radius: 18px;
  min-height: 240px;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: #6b7280;
  background: #f9fafb;
}

.nip-puzzle__board {
  width: min(100%, 820px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(var(--nip-grid), minmax(0, 1fr));
  grid-template-rows: repeat(var(--nip-grid), minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: #e5e7eb;
  border-radius: 18px;
  aspect-ratio: var(--nip-board-ratio);
  box-sizing: border-box;
}

.nip-tile {
  appearance: none;
  border: 0;
  cursor: pointer;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  position: relative;
  overflow: hidden;
  background: transparent;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.nip-tile__face {
  display: block;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-color: #ffffff;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.nip-tile:hover .nip-tile__face {
  box-shadow: inset 0 0 0 3px rgba(17, 24, 39, 0.16);
}

.nip-tile--selected .nip-tile__face {
  box-shadow: inset 0 0 0 4px #111827;
}

.nip-tile--blank {
  cursor: default;
}

.nip-tile--blank .nip-tile__face {
  background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
}

.nip-tile--classic {
  overflow: visible;
}

.nip-tile--classic .nip-tile__face {
  transform: scale(0.98);
  filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.15));
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.12);
}

.nip-board--solved .nip-tile .nip-tile__face,
.nip-tile--solved .nip-tile__face {
  box-shadow: none;
}

@media (max-width: 640px) {
  .nip-puzzle {
    padding: 14px;
  }

  .nip-puzzle__controls {
    grid-template-columns: 1fr;
  }

  .nip-puzzle__buttons {
    width: 100%;
  }

  .nip-button {
    width: 100%;
  }

  .nip-puzzle__board {
    width: 100%;
  }
}
