/* @section: design-system */
:root {
  color-scheme: light;
  --bg: #f4efe5;
  --bg-deep: #dfd0b6;
  --surface: #fffaf0;
  --surface-strong: #fff3d2;
  --ink: #2d261b;
  --muted: #766a5a;
  --line: #d7c3a0;
  --line-strong: #6d5738;
  --primary: #2f6f68;
  --primary-dark: #1d4d49;
  --accent: #d88738;
  --danger: #b84a44;
  --ok: #3f7c4d;
  --given: #efe1c5;
  --selected: #f6d98b;
  --related: #f8ecd0;
  --shadow: 0 22px 70px rgba(83, 62, 31, 0.18);
  --radius-xl: 28px;
  --radius-md: 16px;
  --radius-sm: 10px;
  font-family: Arial, Helvetica, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(216, 135, 56, 0.22), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(47, 111, 104, 0.18), transparent 26%),
    linear-gradient(135deg, var(--bg), #efe3cc 55%, var(--bg-deep));
}

button, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.game-shell {
  width: min(1280px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 54px) 0;
  display: grid;
  grid-template-columns: minmax(230px, 0.85fr) minmax(360px, 1.25fr) minmax(210px, 0.7fr);
  align-items: start;
  gap: clamp(16px, 2.5vw, 30px);
}

.intro-panel, .board-panel, .rules-panel {
  border: 1px solid rgba(109, 87, 56, 0.22);
  background: rgba(255, 250, 240, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.intro-panel {
  border-radius: var(--radius-xl);
  padding: clamp(22px, 3vw, 34px);
  position: sticky;
  top: 24px;
  overflow: hidden;
}

.intro-panel::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -72px;
  bottom: -72px;
  border-radius: 36px;
  border: 28px solid rgba(47, 111, 104, 0.08);
  transform: rotate(18deg);
}

.brand-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin-bottom: 28px;
  border-radius: 22px;
  background: var(--ink);
  color: var(--surface);
  font-weight: 900;
  letter-spacing: -0.08em;
  box-shadow: 0 14px 30px rgba(45, 38, 27, 0.22);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 16px;
  font-size: clamp(1.225rem, 3vw, 2.45rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.lead {
  color: var(--muted);
  line-height: 1.72;
  font-size: 1.02rem;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 26px 0 18px;
}

.status-strip > div {
  padding: 12px 10px;
  border-radius: 16px;
  background: rgba(255, 243, 210, 0.82);
  border: 1px solid rgba(216, 135, 56, 0.18);
}

.status-label {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}
.status-strip strong { font-size: 1.15rem; }
.tip {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--primary-dark);
  line-height: 1.6;
  font-weight: 700;
}

.board-panel {
  border-radius: 34px;
  padding: clamp(16px, 3vw, 28px);
}

.topbar, .top-actions, .utility-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.topbar { justify-content: space-between; margin-bottom: 18px; }

.select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 900;
}
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 36px 0 14px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.ghost-button, .tool-button, .button {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  font-weight: 900;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.ghost-button {
  color: var(--primary-dark);
  background: rgba(47, 111, 104, 0.1);
}
.ghost-button:hover, .tool-button:hover, .button:hover { transform: translateY(-1px); }

.sudoku-board {
  width: min(100%, 590px);
  aspect-ratio: 1;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  background: var(--line-strong);
  border: 3px solid var(--line-strong);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--line-strong), 0 18px 42px rgba(45, 38, 27, 0.18);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--primary-dark);
  font-size: clamp(1.12rem, 4vw, 2rem);
  font-weight: 900;
  user-select: none;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}
.cell:nth-child(3n) { border-right-color: var(--line-strong); }
.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-color: var(--line-strong); }
.cell.given { background: var(--given); color: var(--ink); }
.cell.related { background: var(--related); }
.cell.selected { background: var(--selected); transform: scale(0.98); }
.cell.same-number { color: var(--accent); }
.cell.error { background: #f7d5d2; color: var(--danger); animation: shake 180ms ease-in-out 2; }
.cell.solved { color: var(--ok); }

.notes {
  width: 82%;
  height: 82%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  color: var(--muted);
  font-size: clamp(0.42rem, 1.4vw, 0.72rem);
  font-weight: 800;
  line-height: 1;
  text-align: center;
}
.notes span { display: grid; place-items: center; }

.controls { margin-top: 18px; }
.number-pad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 8px;
}
.number-button {
  min-height: clamp(42px, 6vw, 58px);
  border: 0;
  border-radius: 16px;
  background: var(--ink);
  color: var(--surface);
  font-size: 1.2rem;
  font-weight: 900;
  transition: transform 140ms ease, background 140ms ease;
}
.number-button:hover { transform: translateY(-2px); background: var(--primary-dark); }
.utility-row { justify-content: center; margin-top: 12px; }
.tool-button { background: var(--surface-strong); color: var(--ink); }
.tool-button[aria-pressed="true"], .tool-button.highlight { background: var(--accent); color: #fff; }
.button { background: var(--primary); color: #fff; }

.rules-panel {
  border-radius: var(--radius-xl);
  padding: 24px;
}
.rules-panel h2 { margin-bottom: 14px; font-size: 1.2rem; }
.rules-panel ol { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.75; }
.mini-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  background: var(--ink);
  color: var(--surface);
}
.mini-card strong, .mini-card span { display: block; }
.mini-card span { margin-top: 6px; color: #eadcc4; line-height: 1.55; }

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(45, 38, 27, 0.42);
  z-index: 10;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(420px, 100%);
  padding: 34px;
  border-radius: 30px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}
.modal-card h2 { font-size: 2rem; margin-bottom: 12px; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(4px); }
}

@media (max-width: 1040px) {
  .game-shell { grid-template-columns: 1fr; }
  .intro-panel { position: static; }
  .intro-panel, .rules-panel { display: grid; grid-template-columns: 1fr; }
  .status-strip { max-width: 540px; }
}

@media (max-width: 620px) {
  .game-shell { width: min(100% - 18px, 560px); padding: 10px 0 18px; }
  .intro-panel, .board-panel, .rules-panel { border-radius: 22px; padding: 16px; }
  .brand-mark { width: 56px; height: 56px; margin-bottom: 18px; border-radius: 18px; }
  .status-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .status-strip > div { padding: 9px 7px; }
  .topbar { align-items: stretch; }
  .select-wrap, .top-actions { width: 100%; justify-content: space-between; }
  .top-actions > button { flex: 1; }
  .sudoku-board { border-radius: 12px; border-width: 2px; }
  .number-pad { grid-template-columns: repeat(9, 1fr); gap: 4px; }
  .number-button { min-height: 38px; border-radius: 11px; font-size: 1rem; }
  .tool-button { flex: 1; padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
