/* -------------------- BODY & TEXT -------------------- */
body {
  max-width: 1200px;
  min-width: 600px;
  margin: auto;
  background: black;
  font-family: Arial, sans-serif;
}

h1, p {
  color: white;
  text-align: center;
}

/* -------------------- IMAGE SELECTION -------------------- */
.imageContainer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.imageContainer img {
  width: 150px;
  height: auto;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.3s ease;
}

.imageContainer img:hover,
.imageContainer img.selectedImage {
  border-color: orangered;
}

select#pieceCount {
  display: block;
  margin: 10px auto 20px auto;
  padding: 8px;
  font-size: 1rem;
}

/* -------------------- PUZZLE AREA -------------------- */
.puzzle-area {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  margin-top: 20px;
}

/* -------------------- PIECE TRAY -------------------- */
#pieceTray {
  width: 300px;
  min-height: 400px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  align-content: flex-start;
  border: 2px dashed #555;
  padding: 10px;
  background: #111;
  box-sizing: border-box;
  position: relative;
  z-index: 500; /* Keep tray above other elements initially */
}

#pieceTray .puzzlePiece {
  position: relative;
  cursor: grab;
  border: 1px solid rgba(255, 255, 255, 0.2);
  user-select: none;
  box-sizing: border-box;
  touch-action: none;
  transition: transform 0.1s, box-shadow 0.1s; /* Smooth drag visuals */
}

/* -------------------- PUZZLE BOARD -------------------- */
#puzzleContainer {
  width: 450px;
  height: 450px;
  aspect-ratio: 1 / 1;
  position: relative;
  border: 2px solid #333;
  overflow: hidden;
  background-color: #222;
  box-sizing: border-box;
  touch-action: none; /* Prevent scroll while dragging */
}

/* -------------------- PUZZLE PIECES -------------------- */
.puzzlePiece {
  background-size: cover;
  background-position: center;
  user-select: none;
  box-sizing: border-box;
  touch-action: none;
}

.puzzlePiece.dragging {
  cursor: grabbing;
  transform: scale(1.05);
  z-index: 1000;
  box-shadow: 0 15px 25px rgba(0, 0, 0, 0.4);
}

.puzzlePiece.locked {
  cursor: default;
  z-index: 1 !important;
  box-shadow: none !important;
  transform: none !important;
  border: 1px solid #7DCC25; /* Green border for locked pieces */
  opacity: 0.85; /* Slight transparency for locked pieces */
}

/* -------------------- NAVBAR -------------------- */
* {
  -webkit-tap-highlight-color: transparent;
}

#navbar {
  overflow: hidden;
  background-color: #333;
  margin-bottom: 20px;
}

#navbar a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 20px 14px 30px;
  text-decoration: none;
  font-size: 17px;
}

#navbar a:hover {
  background-color: silver;
  color: black;
}

#navbar a.active {
  background-color: orangered;
  color: white;
}

.sticky {
  position: fixed;
  top: 0;
  width: 100%;
}


/* Modal background */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
}
/* Modal content box */
.modal-content {
  background-color: #fefefe;
  margin: 15% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 50%;
  border-radius: 5px;
  position: relative;
  color:black;
}
/* Close button */
.close {
  color: black;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  position: absolute;
  top: 10px;
  right: 15px;
}
.close:hover, .close:focus {
  color: black;
  text-decoration: none;
}
/* -------------------- RESPONSIVE -------------------- */
@media (max-width: 600px) {
  .imageContainer img {
    width: 100px;
  }

  #puzzleContainer,
  #pieceTray {
    max-width: 300px;
    min-height: 250px;
  }

  /* Stack tray above puzzle container */
  .puzzle-area {
    flex-direction: column; /* vertical layout */
    align-items: center;    /* center both tray and puzzle */
    gap: 15px;              /* spacing between tray and puzzle */
  }
}