/* Puzzle Game — layout поверх alternatives.css */

/* Wrapper для всієї ігрової зони */
.puzzle-wrapper {
  position: relative;
  margin-top: 2rem;
}

/* ---- Setup panel ---- */
.puzzle-setup {
  background: #ffffff;
  border-radius: 20px;
  padding: 2rem 2.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  margin-bottom: 2rem;
}

[data-theme="dark"] .puzzle-setup {
  background: #1e2a3a;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

/* Два стовпці на десктопі */
.puzzle-setup-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  align-items: start;
}

.puzzle-setup-col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.puzzle-section-label {
  font-weight: 700;
  font-size: 0.9rem;
  color: #4a5568;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

[data-theme="dark"] .puzzle-section-label {
  color: #a0aec0;
}

/* Image picker */
.puzzle-image-picker {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.puzzle-img-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 3px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.5rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.puzzle-img-btn img {
  width: 110px;
  height: 75px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.puzzle-img-btn span {
  font-size: 0.78rem;
  font-weight: 600;
  color: #4a5568;
}

[data-theme="dark"] .puzzle-img-btn span { color: #a0aec0; }

.puzzle-img-btn:hover { border-color: #f59e0b; transform: translateY(-2px); }
.puzzle-img-btn.active { border-color: #f59e0b; background: #fef3c7; }
[data-theme="dark"] .puzzle-img-btn.active { background: #3a2a00; }

/* Difficulty */
.puzzle-difficulty {
  display: flex;
  gap: 0.75rem;
}

.puzzle-diff-btn {
  flex: 1;
  padding: 0.75rem 0.5rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  color: #1a202c;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  transition: border-color 0.2s, background 0.2s;
}

[data-theme="dark"] .puzzle-diff-btn { color: #f0f4f8; border-color: #2d3748; }

.puzzle-diff-btn .diff-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: #718096;
}

.puzzle-diff-btn:hover, .puzzle-diff-btn.active {
  border-color: #f59e0b;
  background: #fef3c7;
}

[data-theme="dark"] .puzzle-diff-btn.active { background: #3a2a00; }

/* Start button */
.puzzle-start-btn {
  padding: 0.9rem 2rem;
  background: #f59e0b;
  color: #1a202c;
  border: none;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  width: 100%;
}

.puzzle-start-btn:hover { background: #d97706; transform: translateY(-2px); }

/* ---- Game header ---- */
.puzzle-game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #ffffff;
  border-radius: 16px;
  padding: 0.875rem 1.25rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

[data-theme="dark"] .puzzle-game-header { background: #1e2a3a; }

.puzzle-stats-group {
  display: flex;
  gap: 1.5rem;
}

.puzzle-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 55px;
}

.puzzle-stat-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #718096;
}

.puzzle-stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: #f59e0b;
}

.puzzle-game-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.puzzle-action-btn {
  padding: 0.45rem 0.9rem;
  background: none;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #4a5568;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.puzzle-action-btn:hover { border-color: #f59e0b; color: #d97706; }
[data-theme="dark"] .puzzle-action-btn { color: #a0aec0; border-color: #2d3748; }

.puzzle-fs-btn { border-color: #c3dafe; color: #4c51bf; }
.puzzle-fs-btn:hover { border-color: #4c51bf; background: #ebf4ff; color: #3c366b; }
[data-theme="dark"] .puzzle-fs-btn { border-color: #2c3e7a; color: #a3bffa; }

/* ---- Play area ---- */
.puzzle-play-area {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

/* Board — aspect-ratio виставляється динамічно в JS під розміри постера */
.puzzle-board {
  display: grid;
  gap: 4px;
  flex: 1;
  align-self: flex-start;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  max-width: 520px;
}

.puzzle-tile {
  background-repeat: no-repeat;
  cursor: pointer;
  transition: opacity 0.15s, outline 0.1s;
  outline: 3px solid transparent;
  border-radius: 4px;
}

.puzzle-tile:hover { opacity: 0.85; }

.puzzle-tile.selected {
  outline: 3px solid #f59e0b;
  opacity: 0.9;
  z-index: 1;
}

/* Preview */
.puzzle-preview {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex-shrink: 0;
  width: 240px;
}

.puzzle-preview-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #718096;
  text-align: center;
}

.puzzle-preview-img {
  width: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  display: block;
}

/* ---- Fullscreen mode ---- */
.puzzle-wrapper.is-fullscreen {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #0f1923;
  padding: 1rem 1.5rem 1.5rem;
  box-sizing: border-box;
  overflow: hidden;
}

.puzzle-wrapper.is-fullscreen .puzzle-game {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.puzzle-wrapper.is-fullscreen .puzzle-play-area {
  flex: 1;
  min-height: 0;
  align-items: flex-start;
  overflow: hidden;
}

/* Борд обмежений по висоті, ширина рахується з aspect-ratio */
.puzzle-wrapper.is-fullscreen .puzzle-board {
  height: 100%;
  width: auto;
  max-width: 75%;
  flex: 0 0 auto;
}

.puzzle-wrapper.is-fullscreen .puzzle-game-header {
  background: #1a2535;
  flex-shrink: 0;
}

.puzzle-wrapper.is-fullscreen .puzzle-preview {
  flex: 1;
  width: auto;
  max-width: 220px;
}

/* ---- Win overlay ---- */
.puzzle-win {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.puzzle-win-box {
  background: #ffffff;
  border-radius: 24px;
  padding: 3rem 2.5rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  max-width: 360px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

[data-theme="dark"] .puzzle-win-box { background: #1e2a3a; }

.puzzle-win-emoji { font-size: 4rem; line-height: 1; }

.puzzle-win-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: #1a202c;
  margin: 0;
}

[data-theme="dark"] .puzzle-win-title { color: #f0f4f8; }

.puzzle-win-stats { font-size: 1rem; color: #718096; margin: 0; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .puzzle-setup-cols {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .puzzle-board {
    max-width: 100%;
    width: 100%;
    align-self: stretch;
  }

  .puzzle-play-area {
    flex-direction: column;
    align-items: stretch;
  }

  .puzzle-preview {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }

  .puzzle-preview-img {
    width: 100px;
    aspect-ratio: auto;
    height: 140px;
  }

  .puzzle-image-picker {
    justify-content: center;
  }
}
