:root {
  color-scheme: light;
  --paper: oklch(96% 0.018 82);
  --paper-deep: oklch(91.5% 0.025 82);
  --board: oklch(99% 0.009 82);
  --ink: oklch(25% 0.018 60);
  --ink-soft: oklch(48% 0.018 60);
  --line: oklch(77% 0.025 70);
  --line-strong: oklch(39% 0.026 60);
  --cinnabar: oklch(53% 0.16 34);
  --cinnabar-deep: oklch(44% 0.15 34);
  --cinnabar-wash: oklch(91% 0.045 35);
  --jade-wash: oklch(89% 0.03 205);
  --jade-strong: oklch(69% 0.07 205);
  --error: oklch(54% 0.18 24);
  --radius-xs: 6px;
  --radius-sm: 12px;
  --radius-lg: 18px;
  --radius-round: 999px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Noto Sans SC", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  background: var(--paper);
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  color: var(--ink);
  background-color: var(--paper);
}

button {
  color: inherit;
  font: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in oklch, var(--cinnabar) 55%, white);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 200;
  padding: 10px 14px;
  color: white;
  background: var(--ink);
  border-radius: var(--radius-xs);
  transform: translateY(-160%);
  transition: transform 140ms var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------- 页面骨架：一整屏，无滚动 ---------- */

.app-shell {
  display: flex;
  width: min(100%, 980px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(clamp(10px, 4vw, 32px), env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(clamp(10px, 4vw, 32px), env(safe-area-inset-left));
  flex-direction: column;
}

.masthead {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 12px;
}

.brand-block,
.header-actions {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
  min-width: 0;
}

.brand-seal {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  flex: 0 0 auto;
  color: white;
  background: var(--cinnabar);
  border-radius: var(--radius-xs);
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 23px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px color-mix(in oklch, white 22%, transparent);
}

.brand-text {
  min-width: 0;
}

.brand-block h1,
.brand-block p {
  margin: 0;
}

.brand-block h1 {
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.brand-sub {
  margin-top: 3px !important;
  color: var(--ink-soft);
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 12.5px;
  line-height: 1.5;
}

.brand-round {
  display: block;
  margin-top: 2px !important;
  color: var(--cinnabar-deep);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  line-height: 1.3;
}

.header-actions {
  flex: 0 0 auto;
  gap: 4px;
}

.icon-button,
.quiet-button,
.tool-button,
.segmented-control button,
.difficulty-list button,
.number-pad button,
.primary-button {
  min-height: 44px;
  border: 0;
  cursor: pointer;
  transition: transform 130ms var(--ease-out), background-color 160ms var(--ease-out), color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}

.icon-button:active,
.quiet-button:active,
.tool-button:active,
.segmented-control button:active,
.difficulty-list button:active,
.number-pad button:active,
.primary-button:active {
  transform: scale(0.96);
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  color: var(--ink);
  background: transparent;
  border-radius: 50%;
}

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

.icon-button.is-muted svg path:last-child {
  opacity: 0;
}

.quiet-button {
  padding: 0 15px;
  color: var(--cinnabar-deep);
  background: var(--board);
  border-radius: var(--radius-round);
  box-shadow: 0 1px 4px color-mix(in oklch, var(--ink) 12%, transparent);
  font-size: 13px;
  font-weight: 650;
}

/* ---------- 棋盘区 ---------- */

.game-layout {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.board-column {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  align-items: center;
}

.game-status {
  display: flex;
  width: min(100%, 560px);
  flex: 0 0 auto;
  align-items: baseline;
  justify-content: center;
  gap: clamp(16px, 5vw, 40px);
  margin: 0 0 10px;
  font-variant-numeric: tabular-nums;
}

.game-status > div {
  display: grid;
  grid-template-columns: auto auto;
  gap: 7px;
  align-items: baseline;
}

.status-label {
  color: var(--ink-soft);
  font-size: 12px;
}

.game-status strong {
  min-width: 2ch;
  font-size: 16px;
  font-weight: 680;
}

.status-divider {
  width: 1px;
  height: 14px;
  align-self: center;
  background: var(--line);
}

.board-zone {
  display: grid;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  place-items: center;
  container-type: size;
}

.board-stack {
  display: flex;
  width: 100%;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sudoku-board {
  display: grid;
  width: min(100%, 560px);
  aspect-ratio: 1;
  grid-template-columns: repeat(var(--size), minmax(0, 1fr));
  grid-template-rows: repeat(var(--size), minmax(0, 1fr));
  container-type: inline-size;
  overflow: hidden;
  background: var(--line);
  border: 2px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 18px 45px color-mix(in oklch, var(--ink) 14%, transparent), 0 2px 8px color-mix(in oklch, var(--ink) 12%, transparent);
  transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
}

@supports (width: 1cqh) {
  .sudoku-board {
    width: min(100cqw, calc(100cqh - 28px), 560px);
  }
}

.sudoku-board.is-generating {
  opacity: 0.52;
  pointer-events: none;
  transform: scale(0.992);
}

.sudoku-cell {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  padding: 0;
  place-items: center;
  overflow: hidden;
  color: var(--cinnabar-deep);
  background: var(--board);
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", -apple-system, "PingFang SC", sans-serif;
  font-size: clamp(16px, 5vw, 34px);
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  touch-action: manipulation;
  user-select: none;
  transition: background-color 100ms linear, color 100ms linear;
}

@supports (width: 1cqw) {
  .sudoku-cell {
    font-size: clamp(15px, calc(100cqw / var(--size) * 0.56), 34px);
  }
}

.sudoku-cell.is-given {
  color: var(--ink);
  font-weight: 740;
}

.sudoku-cell.is-peer {
  background: color-mix(in oklch, var(--jade-wash) 55%, var(--board));
}

.sudoku-cell.is-same-value:not(.is-selected) {
  color: var(--cinnabar-deep);
  background: color-mix(in oklch, var(--cinnabar-wash) 72%, var(--board));
}

.sudoku-cell.is-selected {
  z-index: 1;
  color: var(--cinnabar-deep);
  background: var(--cinnabar-wash);
  box-shadow: inset 0 0 0 2px var(--cinnabar);
}

.sudoku-cell.is-wrong {
  color: var(--error);
  background: color-mix(in oklch, var(--error) 10%, var(--board));
}

.sudoku-cell.box-edge-right {
  border-right: 2px solid var(--line-strong);
}

.sudoku-cell.box-edge-bottom {
  border-bottom: 2px solid var(--line-strong);
}

.sudoku-cell.last-column {
  border-right: 0;
}

.sudoku-cell.last-row {
  border-bottom: 0;
}

.cell-value {
  display: block;
  line-height: 1;
}

.cell-notes {
  position: absolute;
  inset: 1px;
  display: grid;
  grid-template-columns: repeat(var(--box-cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--box-rows), minmax(0, 1fr));
  color: var(--ink-soft);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  font-size: 9px;
  font-weight: 620;
  line-height: 1;
  pointer-events: none;
}

@supports (width: 1cqw) {
  .cell-notes {
    font-size: clamp(6px, calc(100cqw / var(--size) / var(--box-cols) * 0.72), 14px);
  }
}

.cell-notes span {
  display: grid;
  min-width: 0;
  min-height: 0;
  padding-bottom: 1px;
  place-items: center;
}

.game-message {
  width: min(100%, 560px);
  flex: 0 0 auto;
  min-height: 18px;
  margin: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.4;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 底部浮动数字坞 ---------- */

.play-dock {
  display: flex;
  width: min(100%, 560px);
  flex: 0 0 auto;
  flex-direction: column;
  gap: 6px;
  margin: 10px auto 0;
  padding: 8px;
  background: color-mix(in oklch, var(--board) 80%, transparent);
  border: 1px solid color-mix(in oklch, var(--line) 62%, transparent);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 34px color-mix(in oklch, var(--ink) 13%, transparent), 0 2px 6px color-mix(in oklch, var(--ink) 8%, transparent);
  backdrop-filter: blur(18px) saturate(1.12);
  -webkit-backdrop-filter: blur(18px) saturate(1.12);
}

.play-dock.is-note-mode {
  border-color: color-mix(in oklch, var(--cinnabar) 42%, transparent);
}

.number-pad {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(var(--size), minmax(0, 1fr));
  gap: 5px;
}

.number-pad button {
  display: grid;
  min-width: 0;
  min-height: 46px;
  padding: 4px 2px;
  place-items: center;
  align-content: center;
  gap: 1px;
  color: var(--cinnabar-deep);
  background: color-mix(in oklch, var(--board) 72%, white);
  border: 1px solid color-mix(in oklch, var(--line) 55%, transparent);
  border-radius: 10px;
  box-shadow: 0 1px 2px color-mix(in oklch, var(--ink) 8%, transparent);
}

.play-dock.is-note-mode .number-pad button {
  background: color-mix(in oklch, var(--cinnabar-wash) 45%, var(--board));
  border-color: color-mix(in oklch, var(--cinnabar) 24%, transparent);
}

.number-pad button span {
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", sans-serif;
  font-size: clamp(18px, 4.4vw, 23px);
  font-weight: 680;
  line-height: 1;
}

.number-pad button small {
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 500;
  line-height: 1;
}

.number-pad button:disabled {
  opacity: 0.32;
  box-shadow: none;
}

.tool-row {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.tool-button {
  display: flex;
  min-width: 0;
  min-height: 44px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  color: var(--ink-soft);
  background: transparent;
  border-radius: 10px;
  font-size: 11px;
}

.tool-button[aria-pressed="true"] {
  color: var(--cinnabar-deep);
  background: var(--cinnabar-wash);
}

.tool-button:disabled {
  opacity: 0.35;
}

.tool-glyph {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 12px;
  font-weight: 700;
}

/* ---------- 设置抽屉 ---------- */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  opacity: 0;
  background: color-mix(in oklch, var(--ink) 42%, transparent);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: opacity 240ms var(--ease-out);
}

.drawer-backdrop[hidden] {
  display: none;
}

.drawer-backdrop.is-visible {
  opacity: 1;
}

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  display: flex;
  width: min(88vw, 360px);
  flex-direction: column;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  overflow-y: auto;
  visibility: hidden;
  background: var(--board);
  border-left: 1px solid color-mix(in oklch, var(--line) 60%, transparent);
  box-shadow: -24px 0 70px color-mix(in oklch, var(--ink) 22%, transparent);
  transform: translateX(102%);
  transition: transform 280ms var(--ease-out), visibility 0s linear 300ms;
}

.settings-drawer.is-open {
  visibility: visible;
  transform: translateX(0);
  transition: transform 280ms var(--ease-out);
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-head .icon-button {
  width: 40px;
  height: 40px;
  margin: -6px -8px 0 0;
}

.eyebrow {
  color: var(--cinnabar-deep);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.14em;
}

.drawer-head h2 {
  margin: 4px 0 0;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 25px;
  line-height: 1.3;
}

.setting-group {
  padding: 20px 0 0;
  margin: 0;
  border: 0;
}

.setting-group legend {
  margin-bottom: 10px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 640;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  background: var(--paper-deep);
  border-radius: calc(var(--radius-sm) + 3px);
}

.segmented-control button {
  min-height: 42px;
  padding: 0 8px;
  color: var(--ink-soft);
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 650;
}

.segmented-control button[aria-pressed="true"] {
  color: var(--ink);
  background: var(--board);
  box-shadow: 0 1px 4px color-mix(in oklch, var(--ink) 14%, transparent);
}

.difficulty-list {
  display: grid;
  gap: 4px;
}

.difficulty-list button {
  display: grid;
  min-height: 50px;
  grid-template-columns: 64px 1fr;
  align-items: center;
  padding: 0 12px;
  color: var(--ink-soft);
  text-align: left;
  background: transparent;
  border-radius: var(--radius-sm);
}

.difficulty-list button span {
  color: var(--ink);
  font-weight: 680;
}

.difficulty-list button small {
  font-size: 12px;
}

.difficulty-list button[aria-pressed="true"] {
  color: var(--cinnabar-deep);
  background: var(--cinnabar-wash);
}

.difficulty-list button[aria-pressed="true"] span {
  color: var(--cinnabar-deep);
}

.primary-button {
  display: flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 22px;
  padding: 0 18px;
  color: white;
  background: var(--cinnabar);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 16px color-mix(in oklch, var(--cinnabar-deep) 24%, transparent);
  font-weight: 720;
}

.primary-button:disabled {
  opacity: 0.58;
}

.primary-button svg {
  width: 18px;
  height: 18px;
}

.keyboard-note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin-top: auto;
  padding-top: 22px;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.7;
}

.keyboard-note > span {
  margin-top: 1px;
  font-size: 15px;
}

.keyboard-note p {
  margin: 0;
}

kbd {
  padding: 1px 5px;
  color: var(--ink);
  background: var(--paper-deep);
  border-radius: 3px;
  box-shadow: inset 0 -1px 0 var(--line);
  font-family: inherit;
  font-size: 10px;
}

/* ---------- 通关弹层 ---------- */

.completion-banner {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  padding: 20px;
  place-items: center;
  overflow: hidden;
  background: color-mix(in oklch, var(--ink) 50%, transparent);
}

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

.completion-sheet {
  position: relative;
  z-index: 2;
  width: min(100%, 390px);
  padding: 38px 34px 30px;
  text-align: center;
  background: var(--board);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 70px color-mix(in oklch, var(--ink) 35%, transparent);
  animation: sheet-enter 320ms var(--ease-out) both;
}

.completion-mark {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 18px;
  place-items: center;
  color: white;
  background: var(--cinnabar);
  border-radius: 50%;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 29px;
  font-weight: 700;
}

.completion-sheet h2 {
  margin: 7px 0 10px;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 28px;
}

.completion-sheet p:not(.eyebrow) {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.75;
}

.completion-sheet .primary-button {
  margin-top: 24px;
}

.celebration-piece {
  position: absolute;
  top: -16px;
  left: var(--x);
  width: 8px;
  height: 8px;
  background: var(--cinnabar-wash);
  border-radius: 2px;
  animation: celebration-fall 1.45s var(--ease-out) var(--delay) both;
}

.celebration-piece:nth-of-type(3n) {
  background: var(--jade-strong);
  border-radius: 50%;
}

.celebration-piece:nth-of-type(4n) {
  background: var(--cinnabar);
}

.cell-pop .cell-value {
  animation: value-pop 210ms var(--ease-out);
}

.cell-shake .cell-value {
  animation: value-shake 250ms ease-out;
}

.cell-hint .cell-value {
  animation: hint-reveal 360ms var(--ease-out);
}

.box-complete {
  animation: box-wash 600ms var(--ease-out);
}

@keyframes value-pop {
  0% { opacity: 0.35; transform: scale(0.78); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes value-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
}

@keyframes hint-reveal {
  0% { opacity: 0; filter: blur(3px); transform: scale(0.92); }
  100% { opacity: 1; filter: blur(0); transform: scale(1); }
}

@keyframes box-wash {
  0% { background-color: var(--board); }
  45% { background-color: var(--jade-wash); }
  100% { background-color: var(--board); }
}

@keyframes sheet-enter {
  0% { opacity: 0; transform: translateY(12px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes celebration-fall {
  0% { opacity: 0; transform: translate3d(0, -10px, 0) rotate(0); }
  10% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--drift), 105vh, 0) rotate(220deg); }
}

@media (hover: hover) {
  .icon-button:hover,
  .tool-button:hover {
    color: var(--cinnabar-deep);
    background: var(--cinnabar-wash);
  }

  .number-pad button:hover:not(:disabled),
  .quiet-button:hover {
    color: var(--cinnabar-deep);
    background: white;
    transform: translateY(-1px);
  }

  .difficulty-list button:hover,
  .segmented-control button:hover {
    color: var(--ink);
  }

  .primary-button:hover:not(:disabled) {
    background: var(--cinnabar-deep);
    transform: translateY(-1px);
  }
}

/* ---------- 手机 ---------- */

@media (max-width: 700px) {
  .app-shell {
    padding: max(10px, env(safe-area-inset-top)) max(9px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(9px, env(safe-area-inset-left));
  }

  .masthead {
    margin-bottom: 6px;
  }

  .brand-block {
    gap: 9px;
  }

  .brand-seal {
    width: 34px;
    height: 34px;
    border-radius: 5px;
    font-size: 19px;
  }

  .brand-block h1 {
    font-size: 21px;
  }

  .brand-sub {
    display: none;
  }

  .brand-round {
    display: block;
  }

  .quiet-button {
    display: none;
  }


  .game-status {
    gap: clamp(12px, 5vw, 26px);
    margin-bottom: 6px;
  }

  .status-label {
    font-size: 11px;
  }

  .game-status strong {
    font-size: 15px;
  }

  .board-stack {
    gap: 6px;
  }

  .game-message {
    min-height: 17px;
    font-size: 12px;
  }

  .play-dock {
    gap: 5px;
    margin-top: 7px;
    padding: 7px;
    border-radius: 14px;
  }

  .number-pad button {
    min-height: 44px;
    border-radius: 9px;
  }

  .number-pad button span {
    font-size: 20px;
  }

  .tool-button {
    min-height: 44px;
  }

  .keyboard-note {
    display: none;
  }
}

@media (max-width: 540px) {
  /* 9 个数字排成 5 + 4，第二行居中，避免右下留空 */
  .number-pad[data-size="9"] {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }

  .number-pad[data-size="9"] button {
    grid-column: span 2;
  }

  .number-pad[data-size="9"] button[data-value="6"] {
    grid-column: 2 / span 2;
  }
}

@media (max-height: 620px) {
  .app-shell {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }

  .masthead {
    margin-bottom: 4px;
  }

  .brand-seal {
    width: 30px;
    height: 30px;
    font-size: 17px;
  }

  .brand-block h1 {
    font-size: 19px;
  }

  .brand-sub {
    display: none;
  }

  .game-status {
    margin-bottom: 4px;
  }

  .board-stack {
    gap: 4px;
  }

  .game-message {
    min-height: 16px;
    font-size: 11.5px;
  }

  .play-dock {
    gap: 4px;
    margin-top: 6px;
    padding: 6px;
  }
}

/* 横屏：棋盘与数字坞并排，避免棋盘被压扁 */
@media (hover: none) {
  .keyboard-note {
    display: none;
  }
}

@media (max-height: 560px) {
  .settings-drawer {
    padding-top: max(14px, env(safe-area-inset-top));
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .drawer-head {
    padding-bottom: 12px;
  }

  .drawer-head h2 {
    font-size: 21px;
  }

  .setting-group {
    padding-top: 14px;
  }

  .primary-button {
    margin-top: 16px;
  }
}

@media (max-height: 560px) and (min-width: 560px) {
  .app-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "masthead masthead"
      "board dock";
    gap: 6px 18px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .masthead {
    grid-area: masthead;
    margin-bottom: 0;
  }

  .game-layout {
    grid-area: board;
    min-width: 0;
    min-height: 0;
  }

  .play-dock {
    width: 100%;
    align-self: center;
    grid-area: dock;
    margin: 0;
  }

  .number-pad[data-size="9"] {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .game-status {
    margin-bottom: 4px;
  }

  .board-stack {
    gap: 4px;
  }

  .difficulty-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .difficulty-list button {
    min-height: 44px;
    grid-template-columns: 1fr;
    padding: 0 4px;
    text-align: center;
  }

  .difficulty-list button small {
    display: none;
  }
}

@media (max-width: 360px) {
  .number-pad {
    gap: 4px;
  }

  .brand-block h1 {
    font-size: 19px;
  }
}

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