/* Make the whole app fill the screen */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f9fafb;
  font-family: sans-serif;
}

/* Wrapper switches layout based on orientation */
.app {
  display: flex;
  gap: 1rem;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  padding: 1rem;
}

/* Portrait: grid on top, buttons below */
@media (orientation: portrait) {
  .app {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
  }
}

/* Landscape: grid on left, buttons on right */
@media (orientation: landscape) {
  .app {
    flex-direction: row;
    align-items: center;
    justify-content: center;
  }
}

/* Sudoku grid wrapper */
#sudokuGrid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  aspect-ratio: 1 / 1;   /* Always square */
  width: min(90vmin, 100%);  /* Fit inside screen */
  max-width: 90vmin;
  border: 3px solid #333;
}

/* Each cell */
#sudokuGrid input {
  border: 1px solid #999;
  text-align: center;
  font-size: calc(1.5vmin + 0.8rem);
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

/* Thicker borders for 3x3 boxes */
#sudokuGrid input:nth-child(3n) {
  border-right: 2px solid #333;
}
#sudokuGrid input:nth-child(27n+1),
#sudokuGrid input:nth-child(27n+10),
#sudokuGrid input:nth-child(27n+19) {
  border-top: 2px solid #333;
}
#sudokuGrid input:nth-child(n+73) {
  border-bottom: 2px solid #333;
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
  max-width: 250px;
}

button {
  padding: 0.5rem;
  font-size: 1rem;
  cursor: pointer;
}