:root {
  --bg: #f9f9f9;
  --grid-bg: #fff;
  --grid-border: #ccc;
  --highlight: #e0f7fa;
  --highlight-focus: #b2dfdb;
  --prefilled-bg: #eee;
  --btn-bg: #f4f4f5;
  --btn-border: #e4e4e7;
  --btn-hover-bg: #e4e4e7;
  --btn-hover-border: #d4d4d8;
  --btn-active-bg: #d4d4d8;
  --btn-active-border: #c4c4cc;
  --btn-focus-ring: #a855f7;
  --font: sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
  margin: 0;
  overflow-x: hidden;
}

.container {
  text-align: center;
  padding: 0.5rem;
  max-width: 100vw;
  box-sizing: border-box;
}

.grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 2px;
  margin: 1rem auto;
  width: 100%;
  max-width: 360px;
  padding: 0.5rem;
  box-sizing: border-box;
}

.grid input {
  aspect-ratio: 1;
  width: 100%;
  font-size: 1.1rem;
  border: 1px solid var(--grid-border);
  box-sizing: border-box;
  text-align: center;
  background-color: var(--grid-bg);
  min-width: 36px;
  min-height: 36px;
}

.grid input:nth-child(3n + 1) {
  border-left: 2px solid #000;
}
.grid input:nth-child(n + 1):nth-child(-n + 9),
.grid input:nth-child(n + 28):nth-child(-n + 36),
.grid input:nth-child(n + 55):nth-child(-n + 63) {
  border-top: 2px solid #000;
}
.grid input:nth-child(9n) {
  border-right: 2px solid #000;
}
.grid input:nth-child(n + 73) {
  border-bottom: 2px solid #000;
}

.grid input.prefilled {
  background-color: var(--prefilled-bg);
  font-weight: bold;
}

.grid input.highlight-row,
.grid input.highlight-col,
.grid input.highlight-box {
  background-color: var(--highlight);
}

.grid input:focus {
  outline: 2px solid #00796b;
  background-color: var(--highlight-focus);
}

.controls {
  margin-top: 1rem;
  padding: 0 0.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

button {
  appearance: none;
  background-color: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: #111827;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

button:hover {
  background-color: var(--btn-hover-bg);
  border-color: var(--btn-hover-border);
}

button:active {
  background-color: var(--btn-active-bg);
  border-color: var(--btn-active-border);
}

button:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--btn-focus-ring);
}
