@media (max-width: 560px) {
  html:has([data-phone-sheet][open]) { overflow: hidden; }

  html[data-skin] [data-simulator][data-mode='edit'] {
    --edit-gap: clamp(6px, 1svh, 10px);
    --tool-height: clamp(40px, 7.5svh, 50px);

    & .panel-brand :is(.panel-menu, .feedback-top, .panel-lv) { min-height: 34px; }
    & .game-section { padding: 0 14px max(10px, var(--safe-bottom)); }
    & .console {
      height: calc(100svh - var(--stage-top, 50px) - max(10px, var(--safe-bottom)));
      display: flex;
      flex-direction: column;
      gap: var(--edit-gap);
    }
    & [data-toolbar] { margin: 0; justify-content: space-between; }
    & [data-mode-switch] button { min-height: 34px; padding: 2px clamp(7px, 3vw, 16px); }
    & [data-phone-works] { display: inline-flex; align-items: center; min-height: 34px; }

    & [data-phone-steps] { display: flex; gap: 6px; }
    & [data-step] {
      flex: 1; min-width: 0; min-height: 34px; padding: 2px;
      border: 0; border-radius: var(--radius-pill);
      font: inherit; font-size: 13px; font-weight: 900;
      color: var(--sub); background: var(--soft);
    }
    & [data-step][aria-current] { color: var(--surface); background: var(--stroke); }
    & [data-step][data-complete] { color: var(--ok-ink); background: var(--ok-bg); }
    & [data-step][data-complete]::after { content: ' ✓'; }

    /* The bezel gets the space left between the steps and the tray.
       Its content box sets both limits on the 10 × 20 canvas. */
    & .bezel { flex: 1; min-height: 0; width: 100%; container-type: size; }
    & .lcd-frame { height: 100%; }
    & .lcd {
      --board-w: min(calc(50cqh - var(--stroke-w)), calc(100cqw - 112px - var(--edit-gap) - 2 * var(--stroke-w)));
      --board-h: calc(2 * var(--board-w));
      --cell: calc(var(--board-h) / 20);
      display: grid; grid-template: 'center paint' 1fr / max-content minmax(0, 1fr);
      height: 100%; gap: var(--edit-gap); align-items: start;
    }
    & [data-center] { padding: 0; align-self: center; }
    & .screen { margin: 0; }
    & [data-reserved] { font-size: clamp(9px, calc(var(--cell) * .5), 13px); line-height: 1.3; }
    & [data-empty-board] { display: none; }
    & [data-shared] { position: static; transform: none; align-self: center; min-height: 34px; padding-block: 2px; }

    & [data-paint-card] {
      align-self: stretch; padding: 0; gap: var(--edit-gap);
      background: none; border: 0; box-shadow: none;
    }
    & [data-paint-card] :is(h2, [data-tray-label]) { display: none; }
    & [data-palette] { grid-template-columns: 1fr; gap: var(--edit-gap); }
    & [data-palette] .pad-key {
      display: grid; grid-template: 'icon name' auto '. sub' auto / 18px 1fr;
      align-content: center; align-items: center; justify-items: start;
      min-height: var(--tool-height); padding: 2px 8px; gap: 0 6px;
      text-align: left; line-height: 1.12;
      border: var(--stroke-w) solid var(--stroke); box-shadow: 0 3px 0 var(--stroke);
    }
    & [data-palette] .pad-key[aria-checked='true'] { background: var(--cta); }
    & [data-palette] i { grid-area: icon; width: 16px; height: 16px; }
    & [data-palette] b { grid-area: name; font-size: 16px; }
    & [data-palette] small { display: none; }
    & [data-palette] small[data-short] { grid-area: sub; display: block; font-size: 12px; color: var(--ink); }
    & [data-history] {
      position: static; transform: none; gap: 4px; padding: 0;
      border: 0; background: none; box-shadow: none;
    }
    & [data-history] button {
      flex: 1; padding: 2px; min-height: 34px; font-size: 12px;
      border: var(--stroke-w) solid var(--stroke); border-radius: var(--radius);
      background: var(--surface);
    }
    & [data-paint-card] p[data-mobile-copy] {
      margin: auto 0 0; font-size: 13.5px; font-weight: 800; line-height: 1.35; color: var(--ink);
    }

    & [data-tray] { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
    & [data-tray] button { height: clamp(40px, 7.2svh, 48px); font-size: 11px; }
    & [data-tray] button:last-child { flex-direction: column; }
    & [data-piece][aria-pressed='true'] { border-color: var(--cta); box-shadow: 0 4px 0 var(--cta); }
    & [data-phone-next] { position: sticky; bottom: max(10px, var(--safe-bottom)); min-height: 44px; }

    & [data-phone-sheet] {
      position: fixed; inset: auto 0 0; margin: 0; width: 100%; max-width: none;
      max-height: calc(100dvh - 12px); box-sizing: border-box; overflow: auto; overscroll-behavior: contain;
      border: 0; border-top: var(--stroke-w) solid var(--stroke); border-radius: var(--radius-shell) var(--radius-shell) 0 0;
      padding: 8px 16px max(16px, var(--safe-bottom)); background: var(--surface); color: var(--ink);
      --cell: clamp(20px, 4svh, 32px);
    }
    & [data-phone-sheet]::backdrop { background: color-mix(in srgb, var(--stroke) 30%, transparent); }
    & [data-sheet-back] { min-height: 34px; margin-bottom: 6px; }
    & [data-phone-sheet] .info { position: static; padding: 0; border: 0; box-shadow: none; }
    & [data-phone-sheet] .card-label {
      display: block; position: static; align-self: start; margin: 0; padding: 0;
      font-size: 16px; color: var(--ink); background: none; box-shadow: none; border: 0;
    }
    & [data-phone-sheet] :is(button, summary) { min-height: 34px; }
    & [data-phone-sheet] [data-next-order] { --next-slot-h: clamp(34px, 6svh, 44px); }
  }
}
