/* General Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
   font-family: 'Arial', sans-serif;
  text-align: center;
  margin: 0;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-image: url('./assets/bg1.jpg'); 
  background-size: cover; 
  background-position: center; 
  background-repeat: no-repeat; 
  position: relative; 
}
/* Add a semi-transparent overlay to ensure readability */
body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.4); 
  z-index: -1; 
}

/* Ensure all content is above the overlay */
h1, .container, .button-container, .rules-box {
  position: relative;
  z-index: 1;
}

h1 ,h2 {
  margin-bottom: 20px;
  font-size: 2.5rem;
  color: #333;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
}

.container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
  width: 100%;
  max-width: 1200px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  background-color: #f5ece0;
  padding: 10px;
  border: 2px solid #000;
  width: 100%;
  max-width: 400px;
  box-shadow: 10px 10px 10px rgba(0, 0, 0, 0.4);
}

.cell {
  aspect-ratio: 1;
  border: 2px solid #000;
  background-color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s ease;
}

.cell:hover {
  background-color: #f0f8ff;
}

.reference {
  text-align: center;
  max-width: 400px;
}

.reference img {
  width: 100%;
  height: auto;
  border: 2px solid #000;
  /* border-radius: 10px; */
  box-shadow: 10px 10px 8px rgba(0, 0, 0, 0.4);
}

.reference p {
  margin-top: 10px;
  font-size: 1.2rem;
  font-weight: bold;
  color: #555;
}

.pieces {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 10px 0;
  width: 100%;
  max-width: 800px;
}

.piece {
  width: 100px;
  height: 100px;
  border: 2px solid #000;
  /* box-shadow: 10px 10px 8px rgba(0, 0, 0, 0.4); */
  cursor: grab;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  /* border-radius: 10px; */
}

.piece:hover {
  transform: scale(1.05);
  box-shadow: 6px 6px 8px rgba(0, 0, 0, 0.3);
}

.button-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}

#reset-button,
#undo-button,
#start-button,
#solve-button {
  padding: 10px 20px;
  font-size: 1rem;
  cursor: pointer;
  background-color: #007bff;
  color: #fff;
  border: none;
  box-shadow: 6px 6px 8px rgba(0, 0, 0, 0.4);

  border-radius: 5px;
  margin: 10px 5px;
  transition: background-color 0.3s ease, transform 0.3s ease;
}

#reset-button:hover,
#undo-button:hover,
#start-button:hover,
#solve-button:hover {
  background-color: #0056b3;
  transform: translateY(-2px);
}

#start-button {
  background-color: #ff9800;
}

#start-button:hover {
  background-color: #e68900;
}

#start-button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

#undo-button {
  background-color: #28a745;
}

#undo-button:hover {
  background-color: #218838;
}

#solve-button {
  background-color: #4CAF50;
}

#solve-button:hover {
  background-color: #45a049;
}

/* Puzzle Solved Message */
#solved-message {
  margin-top: 20px;
  font-size: 1.5rem;
  font-weight: bold;
  color: green;
  animation: fadeIn 1s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.hidden {
  display: none;
}

/* Timer Display */
#timer {
  margin-top: 10px;
  font-size: 1.2rem;
  font-weight: bold;
  color: #333;
}

/* Rules Box */
.rules-box {
  margin-top: 20px;
  padding: 20px;
  background-color: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 10px;
  max-width: 500px;
  text-align: left;
  box-shadow: 10px 10px 8px rgba(0, 0, 0, 0.3);
}

.rules-box h2 {
  font-size: 1.5rem;
  margin-bottom: 10px;
  color: #333;
}

.rules-box ul {
  list-style-type: disc;
  padding-left: 20px;
}

.rules-box li {
  font-size: 1rem;
  margin-bottom: 8px;
  color: #555;
}

.rules-box strong {
  color: #007bff;
}


/* Responsive Design */
@media (max-width: 768px) {
  h1 {
    font-size: 1.5rem; 
  }

  .grid {
    max-width: 300px; 
  }

  .piece {
    width: 90px; 
    height: 90px;
  }

  .reference img {
    max-width: 300px; 
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.2rem; 
  }

  .grid {
    max-width: 250px;
  }

  .piece {
    width: 70px; 
    height: 70px;
  }

  .reference img {
    max-width: 250px; 
  }

  .container {
    gap: 20px; 
  }
}
@media (min-width: 480px) and (max-width: 767px){
   h1 {
    font-size: 2.0rem; 
  }

  .grid {
    max-width: 300px; 
  }

  .piece {
    width: 88px; 
    height: 88px;
  }

  .reference img {
    max-width: 300px;
  }  
}

@media (min-width: 768px) and (max-width: 1023px) {
  h1 {
    font-size: 1.8rem; 
  }

  .grid {
    max-width:330px;
  }

  .piece {
    width: 98px; 
    height: 98px;
  }

  .reference img {
    max-width: 330px; 
  }

  .container {
    gap: 60px; 
  }
}

/* Laptop Screens (1024px) */
@media (min-width: 1024px) and (max-width: 1919px) {
  h1 {
    font-size: 1.8rem; 
  }

  .grid {
    max-width:330px; 
  }

  .piece {
    width: 98px; 
    height: 98px;
  }

  .reference img {
    max-width: 330px; 
  }

  .container {
    gap: 60px; 
  }
}

/* Desktop Screens (1920px and above) */
@media (min-width: 1920px) {
  h1 {
    font-size: 2.5rem; 
  }

  .grid {
    max-width: 458px; 
  }

  .piece {
    width: 140px; 
    height: 140px;
  }

  .reference img {
    max-width: 500px; 
  }

  .container {
    gap: 60px; 
  }
}