body {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: Arial, sans-serif;
  background-color: #f3f4f6;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  box-sizing: border-box;
}

/* Title styling */
h1 {
  font-size: 2em;
  color: #333;
  margin-bottom: 10px;
}

/* Top controls container for inline layout */
.top-controls {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
}

.top-controls form {
  margin-right: 12px;
}

.bottom-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  justify-content: center;
  padding: 20px;
  max-width: 75%;
  box-sizing: border-box;
}

.bottom-controls button {
  width: 100%;
  padding: 10px;
}

/* Timer styling */
#timer {
  font-size: 1.5em;
  font-weight: bold;
  color: #444;
  background-color: #e0e7ff;
  padding: 10px 20px;
  border-radius: 8px;
  text-align: center;
  width: 100px;
}

/* Difficulty/puzzleSize dropdown and buttons */
#difficulty,
#puzzleSize,
button {
  font-size: 1em;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 5px;
  cursor: pointer;
}

/* Button styling */
button {
  transition: background-color 0.3s;
}

button:hover {
  opacity: 0.9;
}

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

/* Button colors */
button#theme-toggle {
  background-color: #787aeb;
  color: #fff;
}

button:nth-of-type(1) {
  background-color: #38bdf8;
  color: #fff;
}

button:nth-of-type(2) {
  background-color: #38bdf8;
  color: #fff;
}

button:nth-of-type(3) {
  background-color: #4ade80;
  color: #fff;
}

button:nth-of-type(4) {
  background-color: #4ade80;
  color: #fff;
}

button:nth-of-type(5) {
  background-color: #f87171;
  color: #fff;
}

button:nth-of-type(6) {
  background-color: #f87171;
  color: #fff;
}

button:nth-of-type(7) {
  background-color: #e1cd1e;
  color: #fff;
}

button:nth-of-type(8) {
  background-color: #e1cd1e;
  color: #fff;
}

/* Dark mode button colors */
body.dark-mode button#theme-toggle {
  background-color: #4c51bf;
  color: #ddd;
}
body.dark-mode button:nth-of-type(1) {
  background-color: #2b6cb0;
  color: #ddd;
}
body.dark-mode button:nth-of-type(2) {
  background-color: #2b6cb0;
  color: #ddd;
}
body.dark-mode button:nth-of-type(3) {
  background-color: #2f855a;
  color: #ddd;
}
body.dark-mode button:nth-of-type(4) {
  background-color: #2f855a;
  color: #ddd;
}
body.dark-mode button:nth-of-type(5) {
  background-color: #c53030;
  color: #ddd;
}
body.dark-mode button:nth-of-type(6) {
  background-color: #c53030;
  color: #ddd;
}
body.dark-mode button:nth-of-type(7) {
  background-color: #ad9e16;
  color: #ddd;
}
body.dark-mode button:nth-of-type(8) {
  background-color: #ad9e16;
  color: #ddd;
}

/* Grid styling */
#sudoku-grid {
  display: grid;
  grid-gap: 5px;
  margin-bottom: 20px;
  justify-content: center;
}

.cell {
  width: 50px;
  height: 50px;
  text-align: center;
  font-size: 1.2em;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #fff;
  box-sizing: border-box;
  border: 1px solid #ccc;
}

.cell.checker-light {
  background-color: #f0f0f0;
}

.cell.checker-dark {
  background-color: #d0d0d0;
}

.cell.sub-grid-border.light-mode {
  border-width: 2px;
  border-color: #000;
}

.cell.sub-grid-border.dark-mode {
  border-width: 2px;
  border-color: red;
}

.cell:disabled {
  background-color: #e2e8f0;
  color: blue;
}

.incorrect-cell {
  background-color: #ffcccc;
}

body.light-mode {
  background-color: #f3f4f6;
  color: #333;
}

body.dark-mode {
  background-color: #1a1a2e;
  color: #f0f0f0;
}

h1 {
  font-size: 2em;
  color: #333;
  margin-bottom: 10px;
}

body.dark-mode h1 {
  font-size: 2em;
  color: #f0f0f0;
  margin-bottom: 10px;
}

#timer {
  background-color: #e0e7ff;
  color: #444;
}

body.dark-mode #timer {
  background-color: #333;
  color: #f0f0f0;
}

#difficulty {
  background-color: #4ade80;
  color: #fff;
}

#difficulty:hover {
  opacity: 0.9;
}

#puzzleSize {
  background-color: #a9b02b;
  color: white;
}

#puzzleSize:hover {
  opacity: 0.9;
}

body.dark-mode #difficulty {
  background-color: #2f855a;
  color: #ddd;
}

.grid-container .cell {
  color: #333;
  background-color: #fff;
}

body.dark-mode .grid-container .cell {
  color: #ddd;
  background-color: #333;
}

.number-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin-bottom: 10px;
}

.number-controls button {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 50px;
  height: 50px;
  font-size: 1.2rem;
  margin: 2px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background-color: #aad6f2;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.number-controls button:hover {
  background-color: #9fd1ef;
}

body.dark-mode .number-controls button {
  background-color: #3b8bbd;
  color: #ddd;
}

body.dark-mode .number-controls button:hover {
  background-color: #3682b1;
}

.note-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  pointer-events: auto;
}

.note {
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
}

.loss-popup {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #fff0f0;
  border: 2px solid #d32f2f;
  padding: 30px 40px;
  text-align: center;
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  animation: fadeInScale 0.4s ease-out;
}

.loss-title {
  color: #d32f2f;
  font-size: 26px;
  font-weight: bold;
  margin-bottom: 10px;
}

.loss-popup p {
  font-size: 18px;
  color: #333;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@media screen and (max-width: 1024px) {
  .number-controls button {
    height: 50px;
    width: 50px;
    font-size: 1.5em;
  }
}

@media screen and (max-width: 768px) {
  h1 {
    text-align: center;
  }

  .top-controls {
    flex-direction: column;
    align-items: center;
  }

  #timer,
  #difficulty,
  #puzzleSize,
  #theme-toggle {
    min-width: 100%;
    margin-bottom: 10px;
  }

  .number-controls button {
    height: 40px;
    width: 40px;
    font-size: 1.2em;
  }

  .bottom-controls {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media screen and (max-width: 480px) {
  .bottom-controls button,
  .number-controls button {
    font-size: 0.9rem;
    padding: 8px;
  }

  .cell {
    width: 25px;
    height: 25px;
    font-size: 0.8rem;
  }

  .number-controls button {
    height: 40px;
    width: 40px;
    font-size: 1.2em;
  }
}

@media screen and (max-width: 600px) {
  .number-controls button {
    height: 30px;
    width: 30px;
    font-size: 1em;
  }
}

@media screen and (max-width: 400px) {
  .number-controls button {
    height: 30px;
    width: 30px;
    font-size: 1em;
  }
}
