.game-body {
  color-scheme: light;
  --bg: #fbfaf4;
  --surface: rgba(255, 255, 255, .86);
  --surface-strong: #ffffff;
  --text: #142127;
  --muted: #65747a;
  --border: rgba(20, 33, 39, .13);
  --primary: #0f8fb8;
  --primary-dark: #0c4051;
  --cream: #f3f2df;
  --gold: #d7a94f;
  --shadow: 0 22px 70px rgba(12, 64, 81, .14);
  --stat-bg: #ffffff;
  --stat-text: #0c4051;
  background:
    linear-gradient(145deg, rgba(15, 143, 184, .12), transparent 34%),
    linear-gradient(28deg, rgba(215, 169, 79, .11), transparent 42%),
    linear-gradient(315deg, rgba(243, 242, 223, .46), transparent 38%),
    var(--bg);
}

.game-page {
  padding: 28px 0 12px;
}

.game-page .container {
  width: min(1240px, calc(100% - 32px));
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(420px, 700px) minmax(300px, 430px);
  gap: clamp(32px, 5vw, 72px);
  align-items: start;
}

.game-stage {
  min-width: 0;
}

.board-frame {
  position: relative;
  padding: clamp(10px, 1.5vw, 18px);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, .72);
  box-shadow: var(--shadow);
}

.board-frame::before,
.board-frame::after {
  position: absolute;
  z-index: -1;
  width: 100px;
  height: 22px;
  content: "";
  opacity: .22;
  filter: blur(10px);
  background: var(--primary);
}

.board-frame::before {
  top: 12%;
  left: -38px;
  transform: rotate(-24deg);
}

.board-frame::after {
  right: -34px;
  bottom: 8%;
  transform: rotate(18deg);
  background: var(--gold);
}

.game-board {
  direction: ltr;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 3px solid #142127;
  background: #142127;
  box-shadow: inset 0 0 0 1px rgba(20, 33, 39, .12);
}

.sudoku-cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid rgba(20, 33, 39, .22);
  border-bottom: 1px solid rgba(20, 33, 39, .22);
  border-radius: 0;
  background: #fffef8;
  color: #142127;
  font-family: "Avenir Next", Avenir, "Trebuchet MS", sans-serif;
  font-size: clamp(21px, 4.2vw, 42px);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background-color 130ms ease, color 130ms ease, box-shadow 130ms ease;
}

.sudoku-cell:nth-child(3n):not(:nth-child(9n)) {
  border-right: 3px solid #142127;
}

.sudoku-cell:nth-child(9n) {
  border-right: 0;
}

.sudoku-cell:nth-child(n + 19):nth-child(-n + 27),
.sudoku-cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom: 3px solid #142127;
}

.sudoku-cell:nth-child(n + 73) {
  border-bottom: 0;
}

.sudoku-cell:hover {
  background: #edf9fc;
}

.sudoku-cell.is-peer {
  background: #eef7f8;
}

.sudoku-cell.is-same {
  background: #d9f1f8;
}

.sudoku-cell.is-selected {
  z-index: 1;
  background: #e1f5fb;
  box-shadow: inset 0 0 0 3px var(--primary);
}

.sudoku-cell.is-fixed {
  color: #11191d;
  font-weight: 800;
}

.sudoku-cell.is-user {
  color: #078bc2;
}

.sudoku-cell.is-wrong {
  color: #b54032;
  background: #fff0ed;
}

.sudoku-cell:focus-visible {
  z-index: 2;
  outline: 3px solid #d7a94f;
  outline-offset: -4px;
}

.cell-notes {
  position: absolute;
  inset: 3px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  color: #176982;
  font-size: clamp(7px, 1.05vw, 12px);
  font-weight: 700;
  line-height: 1;
}

.cell-notes span {
  display: grid;
  place-items: center;
}

.game-controls {
  position: sticky;
  top: 22px;
  padding-top: 8px;
}

.game-controls h1 {
  margin-bottom: 10px;
  font-size: clamp(42px, 5vw, 64px);
}

.game-intro {
  max-width: 42ch;
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 17px;
}

.game-status {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 42px;
  margin-bottom: 14px;
  font-size: 17px;
  font-weight: 800;
}

.game-status > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.game-status > span + span::before {
  width: 1px;
  height: 22px;
  margin-right: 8px;
  content: "";
  background: var(--border);
}

.status-icon {
  width: 22px;
  height: 22px;
  color: var(--primary);
}

.difficulty-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-strong);
}

.difficulty-button {
  min-height: 48px;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: 800 15px/1 "Avenir Next", Avenir, sans-serif;
  cursor: pointer;
}

.difficulty-button:last-child {
  border-right: 0;
}

.difficulty-button[aria-pressed="true"] {
  background: var(--primary);
  color: #fff;
}

.difficulty-button:focus-visible,
.number-button:focus-visible,
.tool-button:focus-visible,
.new-game-button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

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

.number-button {
  min-height: 66px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
  font: 800 30px/1 "Avenir Next", Avenir, sans-serif;
  box-shadow: 0 5px 14px rgba(12, 64, 81, .07);
  cursor: pointer;
}

.number-button:hover,
.number-button.is-active {
  border-color: var(--primary);
  background: #e5f6fb;
  color: #087fab;
}

.number-button:disabled {
  opacity: .38;
  cursor: default;
}

.tool-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-top: 12px;
}

.tool-button {
  position: relative;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
  font: 700 13px/1.2 "Avenir Next", Avenir, sans-serif;
  cursor: pointer;
}

.tool-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.tool-button[aria-pressed="true"] {
  border-color: var(--primary);
  background: #e5f6fb;
  color: #087fab;
  box-shadow: inset 0 0 0 1px var(--primary);
}

.tool-button:disabled {
  opacity: .4;
  cursor: default;
}

.mode-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0;
}

.tool-button[aria-pressed="true"] .mode-dot {
  opacity: 1;
}

.new-game-button {
  width: 100%;
  min-height: 54px;
  margin-top: 12px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  font: 800 16px/1 "Avenir Next", Avenir, sans-serif;
  box-shadow: 0 10px 24px rgba(15, 143, 184, .22);
  cursor: pointer;
}

.new-game-button:disabled {
  opacity: .65;
  cursor: wait;
}

.game-message {
  min-height: 24px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.completion-panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid rgba(15, 143, 184, .34);
  border-radius: 10px;
  background: #e7f8f5;
  color: #0c4051;
}

.completion-panel[hidden] {
  display: none;
}

.completion-panel strong {
  display: block;
  margin-bottom: 3px;
  font-size: 17px;
}

.completion-panel p {
  margin: 0;
}

.native-promo {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 14px;
  align-items: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.native-promo > img {
  width: 54px;
  height: 54px;
  border-radius: 12px;
}

.native-promo strong {
  display: block;
  margin-bottom: 3px;
  font-size: 17px;
}

.native-promo p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.native-promo .button {
  width: fit-content;
  min-height: 42px;
  padding-inline: 14px;
  font-size: 14px;
}

.play-copy {
  max-width: 980px;
  margin: 64px auto 0;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}

.play-copy h2 {
  font-size: clamp(24px, 3vw, 30px);
}

.play-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.play-copy-intro {
  max-width: 820px;
}

.play-guide,
.play-faq {
  margin-top: 38px;
}

.play-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.play-feature-grid article {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
}

.play-feature-grid h3 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.25;
}

.play-faq details {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.play-faq details:last-child {
  border-bottom: 1px solid var(--border);
}

.play-faq summary {
  cursor: pointer;
  font-weight: 800;
}

.play-faq details[open] summary {
  margin-bottom: 8px;
}

.game-loading .game-board {
  opacity: .55;
  pointer-events: none;
}

@media (max-width: 980px) {
  .game-layout {
    grid-template-columns: minmax(0, 660px);
    justify-content: center;
  }

  .game-controls {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 18px;
  }

  .game-controls h1,
  .game-intro,
  .game-status,
  .difficulty-control,
  .new-game-button,
  .game-message,
  .completion-panel,
  .native-promo {
    grid-column: 1 / -1;
  }

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

  .tool-row {
    grid-template-columns: repeat(2, 1fr);
    margin-top: 0;
  }
}

@media (max-width: 620px) {
  .game-page { padding-top: 10px; }
  .game-layout { gap: 24px; }
  .board-frame { padding: 5px; border-radius: 8px; }
  .game-board { border-width: 2px; }
  .sudoku-cell { font-size: clamp(19px, 7.6vw, 34px); }
  .sudoku-cell:nth-child(3n):not(:nth-child(9n)) { border-right-width: 2px; }
  .sudoku-cell:nth-child(n + 19):nth-child(-n + 27),
  .sudoku-cell:nth-child(n + 46):nth-child(-n + 54) { border-bottom-width: 2px; }
  .cell-notes { inset: 1px; font-size: clamp(6px, 2.25vw, 10px); }
  .game-controls { display: block; }
  .game-controls h1 { font-size: 40px; }
  .number-button { min-height: 56px; font-size: 26px; }
  .tool-row { grid-template-columns: repeat(4, 1fr); margin-top: 10px; }
  .tool-button { min-height: 68px; font-size: 11px; }
  .native-promo { grid-template-columns: 48px 1fr; }
  .native-promo > img { width: 48px; height: 48px; }
  .play-copy { margin-top: 44px; }
  .play-feature-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .sudoku-cell { transition: none; }
}
