/* ---------- sudoku ---------- */

#sudoku {
  --cart: var(--six-2);
  --cart-ink: var(--home-accent-ink, #211d18);
}

.sudoku-main {
  justify-content: center;
  gap: clamp(6px, 1.1dvh, 11px);
  overflow: hidden;
}

.sudoku-wrap {
  position: relative;
  width: min(100%, 340px, 48dvh);
  aspect-ratio: 1;
  flex: none;
}

.sudoku-board {
  display: grid;
  grid-template-rows: repeat(9, minmax(0, 1fr));
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--ink) 12%, transparent);
}

.sudoku-row {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  min-height: 0;
}

.sudoku-row:nth-child(3n) .sudoku-cell {
  border-bottom-width: 2px;
  border-bottom-color: var(--ink);
}

.sudoku-cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: clamp(15px, 3.4dvh, 26px);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 130ms var(--ease-out), color 130ms var(--ease-out);
}

.sudoku-cell.is-edge-right {
  border-right-width: 2px;
  border-right-color: var(--ink);
}

.sudoku-cell.is-given {
  font-weight: 800;
}

.sudoku-cell.is-entry {
  color: var(--cart);
  font-weight: 800;
}

.sudoku-cell.is-peer {
  background: color-mix(in srgb, var(--cart) 7%, transparent);
}

.sudoku-cell.is-same {
  background: color-mix(in srgb, var(--cart) 15%, transparent);
}

.sudoku-cell.is-selected {
  z-index: 1;
  background: color-mix(in srgb, var(--cart) 24%, var(--card));
  box-shadow: inset 0 0 0 2px var(--cart);
}

.sudoku-cell.is-conflict {
  background: color-mix(in srgb, #b83828 13%, transparent);
  color: #b83828;
}

.sudoku-cell.is-hint {
  animation: sudokuHint 360ms var(--ease-out);
}

.sudoku-cell:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -3px;
}

.sudoku-notes {
  position: absolute;
  inset: 1px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: clamp(6.5px, 1.2dvh, 9.5px);
  font-weight: 700;
  line-height: 1;
}

.sudoku-notes i {
  display: grid;
  place-items: center;
  font-style: normal;
}

@keyframes sudokuHint {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.09); }
}

.sudoku-pad {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: clamp(3px, 0.65vw, 6px);
  width: min(100%, 360px);
  flex: none;
}

.sudoku-pad-key {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: clamp(34px, 5dvh, 46px);
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--ink) 9%, transparent);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: clamp(13px, 1.9dvh, 17px);
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.sudoku-pad-key::after {
  content: attr(data-remaining);
  min-height: 8px;
  color: var(--muted);
  font-size: clamp(7px, 1dvh, 8.5px);
  font-weight: 700;
}

.sudoku-pad-key:hover { background: color-mix(in srgb, var(--panel) 72%, var(--card)); }
.sudoku-pad-key:active { transform: translateY(1px) scale(0.97); }
.sudoku-pad-key:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sudoku-pad-key:disabled { opacity: 0.35; cursor: default; }

.sudoku-tools {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(4px, 0.8vw, 7px);
  width: min(100%, 360px);
  flex: none;
}

.sudoku-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(32px, 4.6dvh, 42px);
  padding: 0 4px;
  border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: clamp(9.5px, 1.35dvh, 12px);
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  touch-action: manipulation;
}

.sudoku-tool:hover { background: color-mix(in srgb, var(--panel) 72%, var(--card)); }
.sudoku-tool:active { transform: translateY(1px) scale(0.98); }
.sudoku-tool:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sudoku-tool[aria-pressed="true"] {
  border-color: var(--cart);
  background: color-mix(in srgb, var(--cart) 18%, var(--panel));
  color: var(--cart);
}

.sudoku-status { min-height: 17px; }

/* ---------- result ---------- */

.sudoku-result {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--page) 76%, transparent);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  z-index: 2;
}

.sudoku-result[hidden] { display: none; }

.sudoku-result-card {
  width: 100%;
  padding: 15px 14px 13px;
  border: 1px solid color-mix(in srgb, var(--ink) 13%, transparent);
  border-radius: 14px;
  background: var(--sheet-bg, var(--card));
  box-shadow: 0 4px 0 color-mix(in srgb, var(--ink) 9%, transparent), 0 24px 42px -30px rgba(0, 0, 0, 0.5);
  animation: sixfoldCardIn 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.sudoku-result-card h2 {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: clamp(21px, 3.2dvh, 27px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1;
}

.sudoku-result-card > p:not(.game-tag):not(.sudoku-result-stats) {
  margin: 7px 0 0;
  color: var(--muted-strong);
  font-size: 11.5px;
  line-height: 1.35;
}

.sudoku-result-stats {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.35;
}

.sudoku-result-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
}

.sudoku-result-actions .play-btn { flex: 1; min-height: 38px; padding-inline: 10px; font-size: 11px; }
.sudoku-result-actions .result-share { width: 38px; min-width: 38px; height: 38px; padding: 0; border-radius: 11px; }

/* ---------- difficulty sheet ---------- */

.sudoku-level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.sudoku-level-option {
  display: flex;
  min-height: 62px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--ink) 13%, transparent);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.sudoku-level-option strong { font-size: 13px; font-weight: 800; }
.sudoku-level-option span { color: var(--muted); font-size: 10px; }
.sudoku-level-option:hover { border-color: var(--ink); }
.sudoku-level-option:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sudoku-level-option.is-active {
  border-color: var(--cart);
  box-shadow: inset 0 0 0 1px var(--cart);
  background: color-mix(in srgb, var(--cart) 10%, var(--card));
}

/* ---------- hub art ---------- */

.mini-sudoku {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  width: 98px;
  height: 98px;
  padding: 3px;
  border: 2px solid currentColor;
  border-radius: 8px;
  background: var(--home-stage);
}

.mini-sudoku i {
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  border-radius: 2px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-style: normal;
  font-weight: 800;
  line-height: 1;
}

.mini-sudoku i:nth-child(1),
.mini-sudoku i:nth-child(5),
.mini-sudoku i:nth-child(9) {
  background: var(--six-2);
  color: var(--home-accent-ink, #211d18);
}

/* ---------- responsive ---------- */

@media (orientation: portrait) and (max-height: 680px) {
  .sudoku-wrap { width: min(100%, 286px, 40dvh); }
  /* The short-screen board is about 237px wide, so a cell is 25px. The 3.4dvh
     digit grew to 26.2px at the 1.3 system scale, whose line box is taller
     than the cell. Keep the digit in proportion with this smaller board
     instead of shrinking the global cap. */
  .sudoku-cell { font-size: clamp(13px, 2.7dvh, 20px); }
  .sudoku-main { gap: 4px; }
  .sudoku-pad-key { min-height: 32px; }
  .sudoku-tool { min-height: 31px; }
}

@media (max-width: 380px) {
  .sudoku-wrap { width: min(100%, 278px, 42dvh); }
  .sudoku-pad { gap: 3px; }
  .sudoku-tools { gap: 4px; }
  .sudoku-tool { font-size: 9.5px; }
  .sudoku-status { font-size: 10.5px; }
}

@media (min-width: 721px) and (min-height: 700px) {
  .sudoku-main { gap: 14px; }
  .sudoku-wrap { width: min(100%, 430px, 54dvh); }
  .sudoku-cell { font-size: clamp(20px, 3.2dvh, 30px); }
  .sudoku-pad,
  .sudoku-tools { width: min(100%, 430px); }
  .sudoku-pad-key { min-height: 48px; }
  .sudoku-tool { min-height: 44px; font-size: 12px; }
  .sudoku-status { font-size: 12px; }
}

html[data-motion="reduced"] .sudoku-cell,
html[data-motion="reduced"] .sudoku-cell.is-hint,
html[data-motion="reduced"] .sudoku-pad-key,
html[data-motion="reduced"] .sudoku-tool,
html[data-motion="reduced"] .sudoku-result-card {
    animation: none;
    transition: none;
  }

/* Landscape gives the grid and the keypad their own columns. The board can
   then use the full height instead of stacking a small grid above a wide pad
   and leaving a dead band across the middle. */
@media (orientation: landscape) {
  .sudoku-shell {
    width: min(100%, 1240px);
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
    gap: 10px 28px;
    padding-top: calc(var(--sa-top) + 20px);
  }

  .sudoku-shell .play-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(210px, 20vw, 280px);
    grid-template-rows: auto auto;
    grid-template-areas:
      "board pad"
      "status tools";
    align-content: center;
    align-items: center;
    justify-items: center;
    gap: 12px 20px;
    width: 100%;
    max-width: 920px;
  }

  .sudoku-shell .board-stage {
    grid-area: board;
    width: min(100%, 560px, calc(100dvh - 152px));
    display: flex;
    justify-content: center;
    align-self: center;
    /* The shared stage uses size containment for games that measure in cqh.
       In this grid that collapses the board to zero height, so opt out. */
    container-type: normal;
  }

  .sudoku-shell .sudoku-wrap { width: 100%; }

  .sudoku-shell .play-feedback {
    grid-area: status;
    width: 100%;
    max-width: 560px;
    height: auto;
    min-height: 17px;
    align-self: start;
  }

  .sudoku-shell .sudoku-pad {
    grid-area: pad;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: clamp(210px, 20vw, 280px);
    align-self: end;
  }

  .sudoku-shell .sudoku-tools {
    grid-area: tools;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: clamp(210px, 20vw, 280px);
    align-self: start;
  }

  .sudoku-shell .sudoku-pad-key {
    min-height: clamp(46px, 6.8dvh, 58px);
    font-size: clamp(14px, 2dvh, 18px);
  }

  .sudoku-shell .sudoku-tool { min-height: 44px; font-size: 12px; }
}

/* Laptop landscape: a narrower info rail leaves more width for the enlarged
   board and pad. */
@media (orientation: landscape) and (max-width: 1100px) {
  .sudoku-shell {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 10px 20px;
  }
}

/* Short landscape phones keep the two-column idea, with smaller side controls
   so the grid stays useful on a 375px-tall viewport. */
@media (orientation: landscape) and (max-height: 520px) {
  .sudoku-shell {
    grid-template-columns: minmax(190px, 30vw) minmax(0, 1fr);
    gap: 6px 14px;
    padding-top: calc(var(--sa-top) + 10px);
  }

  .sudoku-shell .play-main {
    grid-template-columns: minmax(0, 1fr) clamp(160px, 21vw, 190px);
    gap: 8px 12px;
  }

  .sudoku-shell .board-stage {
    width: min(100%, 260px, calc(100dvh - 130px));
  }

  .sudoku-shell .sudoku-pad,
  .sudoku-shell .sudoku-tools { width: clamp(160px, 21vw, 190px); }

  .sudoku-shell .sudoku-pad-key { min-height: 34px; }
  .sudoku-shell .sudoku-tool { min-height: 30px; font-size: 9px; }
}

/* The smallest landscape screens need a narrower rail so the board and pad
   still fit side by side. */
@media (orientation: landscape) and (max-height: 420px) and (max-width: 620px) {
  .sudoku-shell {
    grid-template-columns: minmax(0, 150px) minmax(0, 1fr);
    gap: 6px 10px;
  }

  .sudoku-shell .play-main {
    grid-template-columns: minmax(0, 1fr) 128px;
    gap: 6px 8px;
  }

  .sudoku-shell .board-stage {
    width: min(100%, 190px, calc(100dvh - 125px));
  }

  .sudoku-shell .sudoku-pad,
  .sudoku-shell .sudoku-tools { width: 128px; }

  .sudoku-shell .sudoku-pad-key { min-height: 26px; font-size: 11px; }
  .sudoku-shell .sudoku-tool { min-height: 26px; font-size: 8px; }
}

/* Landscape follows the Merge composition: the square board is the anchor on
   the left, with one calm information-and-controls rail on the right. */
@media (orientation: landscape) {
  .sudoku-shell {
    width: min(100%, 1240px);
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(300px, 34vw, 470px);
    grid-template-rows: auto auto auto auto minmax(0, 1fr);
    grid-template-areas:
      "board head"
      "board status"
      "board pad"
      "board tools"
      "board foot";
    align-content: stretch;
    align-items: start;
    gap: 8px clamp(24px, 3.2vw, 48px);
    padding:
      calc(var(--sa-top) + 18px)
      calc(var(--sa-right) + 26px)
      calc(var(--sa-bottom) + 14px)
      calc(var(--sa-left) + 26px);
  }

  .sudoku-shell .play-head {
    grid-area: head;
    display: block;
    width: 100%;
    align-self: start;
  }

  .sudoku-shell .play-body { display: contents; }
  .sudoku-shell .play-main { display: contents; }

  .sudoku-shell .board-stage {
    grid-area: board;
    width: min(100%, 640px, calc(100dvh - 52px));
    min-height: 0;
    align-self: center;
    justify-self: start;
    display: flex;
    align-items: center;
    justify-content: center;
    container-type: normal;
  }

  .sudoku-shell .sudoku-wrap { width: 100%; }

  .sudoku-shell .play-feedback {
    grid-area: status;
    width: 100%;
    height: auto;
    min-height: 18px;
    align-self: start;
  }

  .sudoku-shell .play-feedback .play-status { font-size: 11.5px; }

  .sudoku-shell .sudoku-pad {
    grid-area: pad;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    align-self: start;
  }

  .sudoku-shell .sudoku-pad-key {
    min-height: clamp(42px, 6dvh, 54px);
    font-size: clamp(13px, 1.8dvh, 17px);
  }

  .sudoku-shell .sudoku-tools {
    grid-area: tools;
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    align-self: start;
  }

  .sudoku-shell .sudoku-tool { min-height: 44px; font-size: 11px; }

  .sudoku-shell .play-foot {
    grid-area: foot;
    display: flex;
    width: 100%;
    min-height: 40px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    align-self: end;
  }

  .sudoku-shell .play-foot .play-actions { display: flex; width: auto; flex: none; }
  .sudoku-shell .play-foot .play-note { display: block; flex: 1; min-width: 0; font-size: 10.5px; text-align: right; }

  .sudoku-shell .play-title-row { display: block; }
  .sudoku-shell .play-stats { width: 100%; margin-top: 16px; padding-top: 10px; gap: 8px; }
  .sudoku-shell .play-intro h1 { font-size: clamp(32px, 3.2vw, 42px); }
}

/* Compact landscape: keep the same board-left composition, with a tighter
   rail so the 3 × 3 pad and one-row tools still fit above the thumb line. */
@media (orientation: landscape) and (max-height: 520px) {
  .sudoku-shell {
    /* Hug the board and give every spare pixel to the control rail. The old
       1fr board column left a dead band between the grid and the pad. */
    grid-template-columns: auto minmax(0, 1fr);
    gap: 5px clamp(10px, 1.8vw, 18px);
    padding:
      var(--pb-gutter-top)
      calc(var(--sa-right) + 12px)
      var(--pb-gutter-bottom)
      calc(var(--sa-left) + 12px);
  }

  .sudoku-shell .play-intro .sub { display: none; }
  /* The desktop rule adds 18px above the title row; short landscape cannot
     spare it. */
  .sudoku-shell .play-title-row { margin-top: 4px; }
  .sudoku-shell .play-intro h1 { font-size: clamp(24px, 4vw, 30px); }
  .sudoku-shell .play-stats { margin-top: 7px; padding-top: 7px; gap: 5px; }
  .sudoku-shell .play-stat strong { font-size: 17px; }
  .sudoku-shell .play-stat .label { font-size: 8px; }
  .sudoku-shell .play-feedback {
    /* Keep the grid overlay: the status line and the coach share one cell.
       Block layout stacked them and added ~14px of dead height. */
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 16px;
    height: auto;
    align-self: start;
  }
  .sudoku-shell .play-status { font-size: 9.5px; line-height: 1.2; }
  .sudoku-shell .play-feedback.has-coach { min-height: 28px; }
  .sudoku-shell .play-feedback .coach {
    height: auto;
    min-height: 26px;
    padding: 2px 4px 2px 7px;
    gap: 5px;
    border-radius: 9px;
  }
  .sudoku-shell .coach-step { min-width: 24px; height: 18px; padding-inline: 3px; font-size: 8px; }
  .sudoku-shell .coach-text { font-size: 9.5px; line-height: 1.15; }
  .sudoku-shell .coach-skip { min-width: 30px; height: 24px; padding-inline: 5px; font-size: 8.5px; }
  .sudoku-shell .sudoku-pad-key { min-height: 30px; font-size: 11px; }
  .sudoku-shell .sudoku-tool { min-height: 29px; font-size: 9px; }
  .sudoku-shell .sudoku-pad,
  .sudoku-shell .sudoku-tools { width: 100%; justify-self: stretch; }
  .sudoku-shell .play-foot { min-height: 30px; gap: 8px; }
  .sudoku-shell .play-foot .play-note { display: none; }
  .sudoku-shell .play-foot .play-btn { min-height: 30px; padding-inline: 10px; font-size: 10px; }
  .sudoku-shell .board-stage {
    width: min(calc(100dvh - 20px), 55vw);
    justify-self: start;
  }
}

/* Very short landscape screens: preserve the board, pad and the tutorial /
   status line before the footer note. */
@media (orientation: landscape) and (max-height: 360px) {
  .sudoku-shell { gap: 4px clamp(8px, 1.4vw, 14px); }
  .sudoku-shell .play-title-row { margin-top: 2px; }
  .sudoku-shell .play-intro h1 { font-size: 22px; }
  .sudoku-shell .play-stats { margin-top: 5px; padding-top: 5px; }
  .sudoku-shell .play-feedback { min-height: 14px; }
  .sudoku-shell .play-feedback.has-coach { min-height: 26px; }
  .sudoku-shell .play-feedback .coach { min-height: 24px; padding-block: 1px; }
  .sudoku-shell .coach-text { font-size: 9px; }
  .sudoku-shell .coach-step { display: none; }
  .sudoku-shell .coach-skip { height: 22px; }
  .sudoku-shell .sudoku-tool { min-height: 26px; font-size: 8px; }
  .sudoku-shell .sudoku-pad-key { min-height: 27px; }
  .sudoku-shell .play-foot { min-height: 26px; }
  .sudoku-shell .play-foot .play-btn { min-height: 26px; }
}

/* Very short screens cannot stack the title and stats. Put the two stats
   beside the title so the coach and footer keep their space. */
@media (orientation: landscape) and (max-height: 340px) {
  .sudoku-shell .play-title-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 6px;
  }
  .sudoku-shell .play-intro { min-width: 0; }
  .sudoku-shell .play-stats {
    width: auto;
    flex: 0 1 140px;
    min-width: 0;
    margin-top: 0;
    padding-top: 0;
    gap: 4px;
  }
  .sudoku-shell .play-stat { min-height: 32px; padding: 2px 4px; }
  .sudoku-shell .play-stat strong { font-size: 15px; }
  .sudoku-shell .play-stat .label { font-size: 7px; }
}

/* Small landscape phones need a slightly smaller board so the pad and tools
   still have a usable width beside it. */
@media (orientation: landscape) and (max-height: 420px) and (max-width: 620px) {
  .sudoku-shell { grid-template-columns: auto minmax(0, 1fr); gap: 4px 8px; padding-inline: 8px; }
  .sudoku-shell .board-stage { width: min(calc(100dvh - 16px), 50vw); }
  .sudoku-shell .sudoku-pad-key { min-height: 25px; font-size: 10px; }
  .sudoku-shell .sudoku-tool { min-height: 25px; font-size: 8px; }
}

/* 320×568 portrait: keep the board large and trim the footer chrome so the
   final row stays inside the viewport. */
@media (orientation: portrait) and (max-height: 600px) {
  .sudoku-shell { padding-top: var(--pb-gutter-top); }
  .sudoku-shell .play-intro .sub { display: none; }
  .sudoku-wrap { width: min(100%, 278px, 40dvh); }
  .sudoku-shell .play-foot { min-height: 32px; }
  .sudoku-shell .play-foot .play-btn { min-height: 32px; }
}

/* The grid, the pad and the tools together are a few pixels taller than a
   390-wide phone with a real status bar and home indicator. Shave the pad
   rows and the two gaps rather than letting the tools sit under the bottom
   band. */
@media (max-height: 900px) {
  .sudoku-main { gap: clamp(3px, 0.9dvh, 8px); }
  .sudoku-pad-key { min-height: 30px; }
  .sudoku-tool { min-height: 29px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .sudoku-shell { padding-top: calc(var(--sa-top) + 12px); }
  .sudoku-shell .play-main { gap: 6px 10px; }
  /* The board is square, so its width is what decides whether the bottom of
     the grid lands under the bottom band on a 390-tall landscape phone. */
  .sudoku-shell .sudoku-wrap { width: min(100%, 430px, calc(100dvh - 20px)); }
  /* The rail used to hand its title row 155px and push the footer 23px past a
     390-tall screen, where the fixed play frame clipped it. The cart row keeps
     its back and settings buttons; the size of those controls, the title, the
     stats gaps and the pad keys give the height back. */
  .sudoku-shell .play-cart-row { gap: 6px; }
  .sudoku-shell .games-home,
  .sudoku-shell .sudoku-settings-open { width: 30px; height: 30px; }
  .sudoku-shell .play-title-row { margin-top: 0; }
  .sudoku-shell .play-stats { margin-top: 3px; padding-top: 3px; }
  .sudoku-shell .sudoku-pad-key { min-height: 27px; }
  .sudoku-shell .sudoku-tool { min-height: 27px; }
}

/* The smaller title is for phones that need every pixel. A wide landscape
   window keeps the rail's own type and buys the same height from the pad keys
   and the stats gaps instead. */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 900px) {
  .sudoku-shell .play-intro h1 { font-size: 22px; }
}

@media (orientation: landscape) and (max-height: 520px) and (min-width: 901px) {
  .sudoku-shell .play-stats { margin-top: 0; padding-top: 0; }
  .sudoku-shell .sudoku-pad-key { min-height: 25px; }
}
