:root {
  --bg-color: #f0f4f8;
  --text-color: #2d3748;
  --primary-color: #4c51bf;
  --primary-hover: #434190;
  --secondary-color: #a0aec0;
  --accent-color: #ed8936;
  --board-bg: #ffffff;
  --border-color: #cbd5e0;
  --border-thick: #4a5568;
  --cell-hover: #ebf4ff;
  --cell-selected: #c3dafe;
  --cell-same-num: #e2e8f0;
  --text-user: #2b6cb0; /* User entered numbers */
  --text-error: #e53e3e;
  --font-main: "Outfit", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.container {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

header {
  text-align: center;
  background: var(--board-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

h1 {
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 15px;
  font-size: 2rem;
}

.level-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.level-display {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-direction: column;
}

#level-select {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 600;
}

.difficulty-badge {
  font-size: 0.8rem;
  padding: 2px 8px;
  background-color: var(--cell-same-num);
  border-radius: 12px;
  color: var(--text-color);
  text-transform: uppercase;
  font-weight: 600;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--primary-color);
  padding: 5px;
  border-radius: 50%;
  transition: background 0.2s;
}

.icon-btn:hover {
  background-color: var(--cell-hover);
}

.game-area {
  display: flex;
  justify-content: center;
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: 100%;
  aspect-ratio: 1;
  background-color: var(--border-thick);
  gap: 1px;
  border: 2px solid var(--border-thick);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.cell {
  background-color: var(--board-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 400;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.1s;
  position: relative;
}

.cell.initial {
  font-weight: 600;
  color: var(--text-color);
}

.cell.user-input {
  color: var(--text-user);
}

.cell.error {
  color: var(--text-error);
  background-color: #fed7d7 !important;
}

.cell.selected {
  background-color: var(--cell-selected);
}

.cell.highlighted {
  background-color: var(--cell-same-num);
}

/* Thick borders for 3x3 boxes */
.cell:nth-child(3n) {
  border-right: 1px solid var(--border-thick); /* Helper visual if gap isn't enough */
}
/* Grid gap handles most lines, but we need to adjust for the 3x3 visual */
/* Actually, best way with grid gap is to just use specific margins or pseudo elements, 
   but simplistic approach: use CSS Grid lines. */
/* Let's redo the grid border strategy slightly for robustness */
.sudoku-board {
  gap: 0;
  border: 2px solid var(--border-thick);
}
.cell {
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}
.cell:nth-child(9n) {
  border-right: none;
}
.cell:nth-last-child(-n + 9) {
  border-bottom: none;
}
/* Thick borders */
.cell:nth-child(3n) {
  border-right: 2px solid var(--border-thick);
}
.cell:nth-child(9n) {
  border-right: none;
}
/* Horizontal thick lines */
.sudoku-board {
  /* We can't easily target rows with nth-child in a pure flat list unless we know exact indices 
       19-27, 46-54. Better to use nth-child logic */
}
/* 
   Row 3 ends at index 27. Row 6 ends at 54.
   We want bottom border on cells 19-27 and 46-54? No.
   Cells 1-9 is row 1.
   Row 3: 19-27.
   Row 6: 46-54.
*/
.cell:nth-child(n + 19):nth-child(-n + 27),
.cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom: 2px solid var(--border-thick);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.num-btn {
  padding: 12px;
  font-size: 1.2rem;
  border: none;
  background-color: var(--board-bg);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  color: var(--primary-color);
  font-weight: 600;
  transition: all 0.2s;
}

.num-btn:hover {
  background-color: var(--cell-hover);
  transform: translateY(-1px);
}

.num-btn:active {
  transform: translateY(1px);
}

#erase-btn {
  color: var(--text-error);
}

.action-buttons {
  display: flex;
  gap: 10px;
}

.action-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.action-btn.primary {
  background-color: var(--primary-color);
  color: white;
}

.action-btn.secondary {
  background-color: var(--secondary-color);
  color: white;
}

.action-btn:hover {
  opacity: 0.9;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 15px;
  text-align: center; // Center text
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-content h2 {
  color: var(--primary-color);
  margin-bottom: 10px;
}

.modal-content p {
  margin-bottom: 20px;
  font-size: 1.1rem;
}

/* Media query for smaller devices */
@media (max-width: 400px) {
  .cell {
    font-size: 1.2rem;
  }
}
