body {
  font-family: "Arial", sans-serif;
  background-color: #faf8ef;
  color: #776e65;
  text-align: center;
  margin: 0;
  padding: 0;
}

header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background-color: #bbada0;
  position: relative; /* Ensure header context for positioning */
}

header h1 {
  margin: 0;
  color: #f9f6f2;
  font-size: 24px;
}

#rules-button {
  padding: 10px;
  background-color: #8f7a66;
  color: #f9f6f2;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  font-size: 20px;
  font-weight: bold;
  width: 40px;
  height: 40px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  position: relative; /* Ensure button is in the flow of the document */
}

#rules {
  position: fixed; /* Fix position relative to the viewport */
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  max-width: 300px;
  padding: 20px;
  background-color: #f9f6f2;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  z-index: 1000; /* Ensure it is above other content */
  display: none; /* Initially hidden */
  text-align: left; /* Align text to the left for better readability */
}

.hidden {
  display: none;
}

#rules-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: #8f7a66;
  color: #f9f6f2;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  font-size: 18px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#controls {
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#controls-top {
  display: flex;
  flex-direction: row;
  gap: 20px;
  margin-bottom: 20px;
}

#controls label {
  margin: 0;
  font-size: 18px;
}

#controls select {
  padding: 5px;
  font-size: 18px;
  border: 1px solid #bbada0;
  border-radius: 5px;
  background-color: #f9f6f2;
  color: #776e65;
  width: 100px; /* Adjust width as needed */
}

#controls button {
  padding: 10px 20px;
  background-color: #8f7a66;
  color: #f9f6f2;
  border: none;
  cursor: pointer;
  border-radius: 5px;
  font-size: 16px;
  margin: 5px;
  width: 100%; /* Full width on smaller screens */
  max-width: 300px;
}

#grid-container {
  display: grid;
  gap: 10px;
  justify-content: center;
  align-items: center;
  background-color: #bbada0;
  padding: 15px;
  border-radius: 10px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}

.grid-cell {
  width: 50px;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #cdc1b4;
  border-radius: 5px;
  font-size: 18px;
  font-weight: bold;
  color: #776e65;
  transition: background-color 0.3s, transform 0.2s;
}

.grid-cell.selected {
  background-color: #f2b179;
  transform: scale(1.1);
}

.grid-cell.solution {
  background-color: #ffcc00;
  transform: scale(1.1);
}

#score-display p {
  font-size: 18px;
  margin: 10px 0;
  color: #776e65;
}
