:root {
  --bg: #f4f0e8;
  --card: #fffaf0;
  --ink: #2c241d;
  --muted: #7c6f64;
  --accent: #6d5dfc;
  --accent-soft: #e5e2ff;
  --danger: #c0392b;
  --good: #247a3d;
  --line: #cfc5b8;
  --heavy: #2c241d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #ffffff 0, var(--bg) 42%, #e8dfd1 100%);
}

button, select {
  font: inherit;
}

.app {
  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-weight: 700;
  font-size: .74rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.3rem, 8vw, 4.6rem);
  letter-spacing: -.06em;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span, .controls, .side-panel {
  background: rgb(255 250 240 / .8);
  border: 1px solid rgb(44 36 29 / .12);
  box-shadow: 0 12px 30px rgb(44 36 29 / .08);
}

.stats span {
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 800;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border-radius: 20px;
  margin-bottom: 18px;
}

.controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-weight: 700;
  font-size: .82rem;
}

select, button {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
}

select {
  background: white;
  color: var(--ink);
  min-width: 140px;
}

button {
  cursor: pointer;
  background: var(--ink);
  color: white;
  font-weight: 800;
  transition: transform .12s ease, opacity .12s ease;
}

button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); opacity: .78; }

.game-wrap {
  display: grid;
  grid-template-columns: minmax(280px, 560px) minmax(220px, 1fr);
  gap: 18px;
  align-items: start;
}

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  aspect-ratio: 1;
  background: var(--heavy);
  border: 3px solid var(--heavy);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgb(44 36 29 / .16);
}

.cell {
  display: grid;
  place-items: center;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--accent);
  font-size: clamp(1.1rem, 5vw, 2.2rem);
  font-weight: 850;
  border-radius: 0;
  padding: 0;
}

.cell:nth-child(3n) { border-right: 3px solid var(--heavy); }
.cell:nth-child(9n) { border-right: 0; }
.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 3px solid var(--heavy); }

.cell.given {
  color: var(--ink);
  background: #f1eadf;
  cursor: default;
}

.cell.selected { background: var(--accent-soft); }
.cell.related { background: #f8f4ec; }
.cell.conflict { color: var(--danger); background: #ffece9; }
.cell.correct { color: var(--good); }

.side-panel {
  border-radius: 20px;
  padding: 16px;
}

.message {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
  min-height: 2.8em;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.number-pad button {
  min-height: 58px;
  font-size: 1.25rem;
  background: white;
  color: var(--ink);
  border: 1px solid rgb(44 36 29 / .12);
}

.number-pad .wide {
  grid-column: 1 / -1;
  background: var(--accent);
  color: white;
}

@media (max-width: 760px) {
  .hero { align-items: start; flex-direction: column; }
  .game-wrap { grid-template-columns: 1fr; }
  .controls > button { flex: 1; }
}
