/* Compact table geometry. Loaded after table themes; this is the layout owner.
   Modes come from the visible viewport in app.js, never from screen/device detection. */

/* Short wide windows share the compact sizing baseline. */
@media (max-height: 480px) {
  /* The hand is the picture on a phone: cards nearly a third of the screen tall, with the
     cards lying on the table sized apart below. */
  :root { --ch: clamp(64px, 30vh, 128px); --cw: calc(var(--ch) * 0.7); }
  @supports (height: 1dvh) { :root { --ch: clamp(64px, 30dvh, 128px); } }
  .table { gap: 4px; padding-top: 4px; }
  .topbar { height: 28px; gap: 10px; }
  .topbar .meta { font-size: 11px; }
  svg.ic { width: 20px; height: 20px; }
  .field { gap: 8px; }
  .side { gap: 4px; }
  .player { gap: 8px; }
  .player .avatar-wrap { width: 40px; height: 40px; }
  .player.me .avatar-wrap { width: 36px; height: 36px; }
  .player .nm { font-size: 15px; }
  .player .role { font-size: 12px; }
  .side .player .role { white-space: normal; } /* a narrow seat wraps its line rather than losing the score */
  .bottom-cards { gap: 14px; }
  .bottom-cards .label { font-size: 11px; }
  .bottom-cards .card-row .card { --cw: 39.2px; --ch: 56px; }
  .current { min-height: calc(clamp(72px, 21vh, 96px) + 18px); gap: 4px; }
  .current .card { --ch: clamp(72px, 21vh, 96px); --cw: calc(var(--ch) * 0.7); }
  .current .caption { font-size: 13px; }
  .foot { gap: 2px; }
  .console { min-height: 40px; gap: 8px; }
  .console .status { font-size: 14px; line-height: 1.25; white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .console .actions button.text { font-size: 14px; padding: 7px 8px; }
  .console .actions button.primary, .console .actions button.decline { font-size: 14px; padding: 8px 16px; }
  .console .actions .bidbtn { min-width: 40px; padding: 8px 0; }
  .hand { min-height: calc(var(--ch) + 16px); padding-top: 0; }
  .hand-row { --row-headroom: 16px; } /* a raised card lifts 14px and must stay off the buttons */
  .lobby .big-code { font-size: 40px; }
  /* Two settings a line, so the whole lobby sits clear of my own seat. (`.center .lobby`:
     the table carries the class too while waiting.) */
  .center .lobby { display: grid; grid-template-columns: auto auto; column-gap: 24px; row-gap: 8px; justify-content: center; justify-items: center; align-items: center; }
  .center .lobby .big-code, .center .lobby .hint, .center .lobby .row { grid-column: 1 / -1; }
  .center .lobby .hint { font-size: 13px; }
  .center .lobby .setting { white-space: nowrap; }
  .center .lobby .row { margin-top: 4px; }
  .center .lobby .house-rules { grid-column: 1 / -1; }
  .center .lobby .house-list { display: grid; grid-template-columns: repeat(2, auto); column-gap: 28px; }
  .call-picker button { width: 22px; font-size: 11px; padding: 2px 0; }
  .call-picker .suit-row { gap: 2px; }
  .sheet { top: 34px; padding: 10px 12px 12px; }
  .toast { top: 40px; }
  .center .center-body { gap: 4px; }
  .center .across { gap: 2px; }
  /* Keep the central play readable on short screens. */
  .table.four .across .player .avatar-wrap { width: 36px; height: 36px; }
  .table.four .bottom-cards { display: none; }
  .table.four .current { min-height: 72px; }
  .table.four .current .cards { padding: 2px 6px; } /* the play and its caption both fit */
  .table.four .current .card { --cw: 46.2px; --ch: 66px; }
  /* A hand that wraps (33 cards) is the whole footer: smaller cards, and my own block goes
     (on a phone it is only the avatar, which stays). */
  html:not(.phone) .foot.two-rows .console .player.me { display: none; }
  .foot.two-rows .console .status { flex: 1; }
  .foot.two-rows .hand { --ch: clamp(56px, 16vh, 66px); --cw: calc(var(--ch) * 0.7); min-height: 0; }
  @supports (height: 1dvh) { .foot.two-rows .hand { --ch: clamp(56px, 16dvh, 66px); } }
  .foot.two-rows .hand-row { --row-headroom: 16px; }
}
/* Thumb controls keep the same footprint on and off turn. */
html.phone .topbar { height: 44px; }
html.phone .topbar .tools button.icon { width: 44px; height: 44px; display: grid; place-items: center; }
html.phone .console { min-height: 44px; }
html.phone .console .actions { gap: 4px; }
html.phone .console .actions button { min-height: 44px; min-width: 44px; }
html.phone .console .actions button.primary { margin-left: 0; }
html.phone .console .status .soft { color: var(--ink-soft); }
html.phone .decision-help { font-size: 11px; line-height: 1.25; margin-top: 2px; }
/* A phone's prompt holds two lines; the called card itself says I hold it. */
html.phone .console .claim-help { display: none; }
html.phone .sheet { top: 52px; }
/* A phone's table is full to its edges, so the toast keeps off it: just above the buttons,
   where the eye already is (the client measures the footer), and in the header's empty
   middle when the phone is on its side. */
html.phone .toast { top: auto; bottom: calc(max(var(--foot-h, 0px), env(safe-area-inset-bottom, 0px)) + 10px); max-width: min(calc(100% - 32px), 360px); text-align: center; }
html.phone .table { padding: max(4px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); gap: 4px; }
html.phone .table .field { gap: 4px 8px; }
html.phone .field .side { padding: 0; }
html.phone .field .player { padding: 0; }
html.phone .table.lobby .hand { display: none; }
html.phone .table.lobby .center-body { overflow-y: auto; }

/* One profile treatment for every seat, including the local player. Position belongs
   to the seat; avatar size, reading direction, and text rhythm belong to the profile. */
html.phone .field .side { justify-content: flex-start; }
html.phone .field .seat { display: flex; width: 100%; }
html.phone .field .across .seat { justify-content: center; }
html.phone .field .side.right .seat { justify-content: flex-end; }
html.phone .field .player { flex-direction: row; align-items: flex-start; gap: 8px; width: 100%; max-width: 180px; text-align: left; }
html.phone .table .field .player .avatar-wrap,
html.phone .table .console .player.me .avatar-wrap { width: 44px; height: 44px; border-radius: 50%; filter: none; }
html.phone .table .player .avatar { inset: 6px; border-radius: 50%; background: none; transform: none; filter: none; }
html.phone .table .player .avatar svg { visibility: visible; }
html.phone .table .player .ring { inset: 2px; width: 40px; height: 40px; }
html.phone .table .player.turn .avatar-wrap::after { inset: 0; border-radius: 50%; }
html.phone .table .player .seal-badge { right: 1px; bottom: 1px; width: 17px; height: 17px; font-size: 11.5px; }
html.phone .table .player .seal-badge svg.ic { width: 11px; height: 11px; }
html.phone .table .player .seal-badge.place { right: 0; bottom: -2px; width: 14px; height: 26px; font-size: 10.5px; }
html.phone .table .player.out .avatar { opacity: 0.55; filter: grayscale(0.6); }
html.phone .table .player .mate-line { font-size: 11px; overflow: visible; } /* one word: it may run into the gap beside the seat rather than be cut */
/* Held sideways the table has no height to spare: a shuangkou partner's label sits beside
   their name rather than on a line of its own. */
html[data-layout="phone-landscape"] .table .player .ptext:has(> .mate-line) { display: grid; grid-template-columns: minmax(0, auto) auto; justify-content: start; align-items: baseline; column-gap: 6px; }
html[data-layout="phone-landscape"] .table .player .ptext:has(> .mate-line) > .mate-line { grid-area: 1 / 2; }
html[data-layout="phone-landscape"] .table .player .ptext:has(> .mate-line) > .role:not(.mate-line) { grid-column: 1 / -1; }
html.phone .table .player .avatar-wrap:has(.seal-badge)::after { --notch: radial-gradient(circle at 34.5px 34.5px, transparent 13.5px, #000 14px); }
html.phone .table .player .avatar-wrap:has(.seal-badge) .ring { --notch: radial-gradient(circle at 7.5px 32.5px, transparent 13.5px, #000 14px); }
html.phone .field .player .ptext { flex: 1; gap: 2px; padding-top: 6px; }
html.phone .field .side.right .player { flex-direction: row-reverse; text-align: right; }
html.phone .field .side.right .player .small { align-self: flex-end; }
html.phone .field .player .nm { font-size: 13px; line-height: 16px; }
html.phone .field .player .role { font-size: 11px; line-height: 14px; white-space: nowrap; }
html.phone .field .player .remaining { display: inline-flex; align-items: center; gap: 3px; height: 14px; vertical-align: top; }
html.phone .field .player .remaining svg.ic { width: 14px; height: 14px; flex: none; }
html.phone .field .player .small { align-self: flex-start; }
/* A seat's buttons fit its column: four seats share an upright phone's width three ways. */
html.phone .field .player button.small { max-width: 100%; padding-inline: 8px; }
/* Upright, between rounds, a four-seat table stacks each seat under its avatar, so a bot's
   Remove and Sit here have the column's whole width rather than what the avatar leaves. The
   side seats keep to their edges and the seat across stays centred. */
html[data-layout="phone-portrait"] .table.four:is(.lobby, [data-phase="finished"]) .field .player { flex-direction: column; align-items: flex-start; }
html[data-layout="phone-portrait"] .table.four:is(.lobby, [data-phase="finished"]) .field .side.right .player { align-items: flex-end; }
html[data-layout="phone-portrait"] .table.four:is(.lobby, [data-phase="finished"]) .field .player .ptext { width: 100%; padding-top: 0; }
html[data-layout="phone-portrait"] .table.four:is(.lobby, [data-phase="finished"]) .field .across .player { align-items: center; text-align: center; }
html[data-layout="phone-portrait"] .table.four:is(.lobby, [data-phase="finished"]) .field .across .player .ptext { align-items: center; }
html[data-layout="phone-portrait"] .table.four:is(.lobby, [data-phase="finished"]) .field .across .player .small { align-self: center; }
/* Held sideways, between rounds a bot's Remove and Sit here share a line, as they do at the seat
   across: stacked, they would take the lobby's height from under its Start button. */
html[data-layout="phone-landscape"] .table:is(.lobby, [data-phase="finished"]) .field .player { max-width: none; }
html[data-layout="phone-landscape"] .table:is(.lobby, [data-phase="finished"]) .field .player .ptext { flex-flow: row wrap; align-items: center; column-gap: 4px; }
html[data-layout="phone-landscape"] .table:is(.lobby, [data-phase="finished"]) .field .player .ptext > :not(button) { flex-basis: 100%; }
html[data-layout="phone-landscape"] .table:is(.lobby, [data-phase="finished"]) .field .side.right .player .ptext { justify-content: flex-end; }

/* Large, scrollable partner choices work in landscape as well as portrait, and in a short
   desktop window, where the jokers' row would otherwise be cut off. */
html.phone .table.choosing-partner .hand { display: none; }
.table.choosing-partner .center-body { overflow-y: auto; overscroll-behavior-y: contain; }
html.phone .table.choosing-partner .center-body > * { flex-shrink: 0; margin-block: 0; }
html.phone .call-picker { width: 100%; }
html.phone .call-picker .suit-row { display: flex; flex-wrap: wrap; justify-content: center; width: 100%; gap: 4px; margin-bottom: 10px; }
html.phone .call-picker button { width: 44px; min-width: 44px; min-height: 44px; padding: 4px 0; font-size: 15px; }
html.phone .call-picker .suit-row > .suit { width: 100%; font-size: 18px; }
html.phone .call-picker .suit-row.jokers { display: grid; grid-template-columns: 1fr 1fr; }
html.phone .call-picker .jokers button { width: 100%; }
html.phone .call-picker .title { font-size: 13px; }
html.phone .call-hand { display: block; margin: 10px 0; border-block: 1px solid var(--line); padding: 8px 0; }
html.phone .call-hand summary { min-height: 44px; padding: 12px 0; font-size: 13px; cursor: pointer; }
html.phone .call-hand .mini { justify-content: center; gap: 5px; }
html.phone .call-hand .mini .card + .card { margin-left: 0; }

/* Portrait uses the full table: opponents across the top, the play in the middle,
   and balanced rows of readable cards within reach of the action buttons. */
html[data-layout="phone-portrait"] .table { padding-top: max(6px, env(safe-area-inset-top)); gap: 8px; }
html[data-layout="phone-portrait"] .field { gap: 10px 8px; }
html[data-layout="phone-portrait"] .topbar { gap: 4px; }
html[data-layout="phone-portrait"] .topbar .meta { font-size: var(--text-micro); }
html[data-layout="phone-portrait"] .topbar .meta .dot { margin-inline: 3px; }
html[data-layout="phone-portrait"] .topbar .tools { gap: 0; }
/* A narrow header keeps four firecrackers; the seal still carries the whole stake. */
html[data-layout="phone-portrait"] .stakes .cracker:nth-child(n+5) { display: none; }
html[data-layout="phone-portrait"] .stake-seal { min-width: 24px; height: 20px; padding: 0 4px; font-size: 11px; }
html[data-layout="phone-portrait"] .side { justify-content: flex-start; gap: 5px; }
html[data-layout="phone-portrait"] .field .player { gap: 4px; }
html[data-layout="phone-portrait"] .player .nm { font-size: 13px; }
html[data-layout="phone-portrait"] .player .role { font-size: 11px; }
html[data-layout="phone-portrait"] .table.four .center .across { gap: 5px; }
html[data-layout="phone-portrait"] .center .center-body { gap: 8px; }
html[data-layout="phone-portrait"] .bottom-cards { min-height: 0; }
/* Full faces need physical room for their indices. Eight bottom cards form two rows
   instead of shrinking their type; the called partner stays alongside the group. */
html[data-layout="phone-portrait"] .bottom-cards .card-row .card { --cw: 50.4px; --ch: 72px; }
html[data-layout="phone-portrait"] .table.four .bottom-cards { gap: 8px; }
html[data-layout="phone-portrait"] .table.four .bottom-cards .card-row .card { --cw: 42px; --ch: 60px; }
html[data-layout="phone-portrait"] .table.four .bottom-cards .bottom { display: grid; grid-template-columns: repeat(4, max-content); gap: 4px; }
html[data-layout="phone-portrait"] .table.four .bottom-cards .card-row .card + .card { margin-left: 0; }
html[data-layout="phone-portrait"] .table.four.called .center-body { gap: 8px; }
html[data-layout="phone-portrait"] .table.four.called .bottom-cards { flex-shrink: 0; }
html[data-layout="phone-portrait"] .table.four.called .bottom-cards .group { gap: 4px; }
html[data-layout="phone-portrait"] .bottom-cards .label { font-size: var(--text-micro); }
html[data-layout="phone-portrait"] .current { min-height: 0; gap: 5px; container-type: inline-size; }
html[data-layout="phone-portrait"] .current .cards { padding: 4px 8px; max-width: 100%; flex-shrink: 0; }
/* The play grows with the upright table, and a long one (--n cards, each overlapping half the
   last) shrinks to fit across it rather than scroll. */
html[data-layout="phone-portrait"] .table .current .card { --play-ch: clamp(58px, 14dvh, 124px); --ch: min(var(--play-ch), max(44px, (100cqw - 16px) * 2 / (var(--n, 1) + 1) / 0.7)); --cw: calc(var(--ch) * 0.7); }
html[data-layout="phone-portrait"] .table.four .current .card { --play-ch: clamp(54px, 11dvh, 100px); }
html[data-layout="phone-portrait"] .current .caption { font-size: 12px; }
/* My avatar and the status share a line; the buttons take the next one. */
html[data-layout="phone-portrait"] .console { flex-wrap: wrap; align-items: center; gap: 5px 8px; }
html[data-layout="phone-portrait"] .console .status { flex: 1 1 0; min-height: 34px; font-size: 14px; white-space: normal; display: flex; flex-direction: column; justify-content: center; }
html[data-layout="phone-portrait"] .console .actions { flex: 0 0 100%; display: flex; width: 100%; gap: 3px; }
html[data-layout="phone-portrait"] .console .actions:empty { display: none; }
html[data-layout="phone-portrait"] .console .actions button { flex: 1; margin: 0; padding: 9px 5px; font-size: 14px; }
html[data-layout="phone-portrait"] .console .actions.playing #play { min-width: 90px; }
html[data-layout="phone-portrait"] .hand, html[data-layout="phone-portrait"] .foot.two-rows .hand { --ch: clamp(62px, 15dvh, 132px); --cw: calc(var(--ch) * 0.7); min-height: 0; } /* the tallest a card may be: the client fits the rows to the width */
html[data-layout="phone-portrait"] .hand-row, html[data-layout="phone-portrait"] .foot.two-rows .hand-row { --row-headroom: 14px; }
html[data-layout="phone-portrait"] .center .lobby { gap: 9px; }
html[data-layout="phone-portrait"] .center .lobby .big-code { font-size: 44px; }
html[data-layout="phone-portrait"] .lobby .hint { font-size: 13px; }
html[data-layout="phone-portrait"] .lobby .setting { font-size: 13px; }
html[data-layout="phone-portrait"] .lobby .row { gap: 4px; flex-wrap: wrap; justify-content: center; }
html[data-layout="phone-portrait"] .partner-hand { --pch: 62px; padding: 6px 10px 8px; }
/* Upright, the table's sheets rise from the bottom like the home page's, within the thumb's reach. */
html[data-layout="phone-portrait"] .sheet { top: auto; bottom: 0; left: 0; right: 0; width: 100%; max-height: 82%; border-radius: 18px 18px 0 0; padding-bottom: max(18px, env(safe-area-inset-bottom, 0px)); box-shadow: 0 -12px 40px rgba(12, 20, 42, 0.28), 0 0 0 1px var(--line); animation: sheetUp var(--motion-panel) ease-out; }
@media (prefers-reduced-motion: reduce) {
  html[data-layout="phone-portrait"] .sheet { animation: none; }
}
html[data-layout="phone-portrait"] .style-choice.card-choice { padding: 10px; gap: 8px; min-height: 90px; font-size: 12px; }
html[data-layout="phone-portrait"] .deck-preview .card { --cw: 37.8px; --ch: 54px; }
/* The flat portrait footer stays at the safe bottom edge: turn information and actions sit
   above the cards, as in landscape. Keeping the status height steady prevents selection from moving the hand. */
html.phone .console .status { min-height: 44px; height: 44px; display: flex; flex-direction: column; justify-content: center; }
html.phone .table[data-phase="bidding"] .console .status { height: 64px; min-height: 64px; }
html.phone .table[data-phase="bidding"] .status-detail { white-space: normal; flex-shrink: 0; }
html.phone .table.spotlight .console .status { background: none; box-shadow: none; }
html.phone .console .actions { min-height: 44px; }

/* Landscape phones are the primary table: a shallow opponent row, the full-width
   play area, and a bounded hand/action area. Card size follows available play space. */
html[data-layout="phone-landscape"] .table .center-body { container-type: size; display: flex; flex-direction: column; gap: 4px; }
/* The lobby scrolls above its Start row (style.css), and its settings share lines, as many as
   fit, the folded house rules among them: most lobbies fit whole. */
html.phone[data-layout="phone-landscape"] .table.lobby .center-body { overflow: hidden; }
html[data-layout="phone-landscape"] .center .lobby { display: flex; gap: 6px; }
html[data-layout="phone-landscape"] .center .lobby-main { flex-flow: row wrap; justify-content: center; gap: 4px 20px; }
html[data-layout="phone-landscape"] .center .lobby-main > :is(.big-code, .hint, .house-rules[open]) { flex-basis: 100%; max-width: none; }
html[data-layout="phone-landscape"] .center .lobby-main .house-list { width: fit-content; margin-inline: auto; }
html[data-layout="phone-landscape"] .center .lobby .big-code { font-size: 32px; }
html[data-layout="phone-landscape"] .center .lobby .row { margin-top: 0; }
html[data-layout="phone-landscape"] .table .bottom-cards { display: flex; }
html.phone[data-layout="phone-landscape"] .table:not(.choosing-partner) .center-body > .bottom-cards { margin-block: auto; }
html[data-layout="phone-landscape"] .table[data-phase="playing"]:not(.called) .bottom-cards { display: none; }
/* A called card stays in view through the play: on the table's left, beside it (the bottom
   cards are in History). The play keeps clear of it on both sides, so it stays centred. */
html[data-layout="phone-landscape"] .table.called .center-body { position: relative; }
html[data-layout="phone-landscape"] .table.called .bottom-cards { position: absolute; left: 0; top: 50%; translate: 0 -50%; margin: 0; }
html[data-layout="phone-landscape"] .table.called .bottom-cards .group:not(.find) { display: none; }
html[data-layout="phone-landscape"] .table.called .bottom-cards .find { flex-direction: row; gap: 8px; }
html[data-layout="phone-landscape"] .table.called .bottom-cards .find .label { display: block; max-width: 6em; text-align: right; }
html.phone[data-layout="phone-landscape"] .table.called .bottom-cards .card-row .card { --ch: clamp(24px, calc(100cqh - 30px), 56px); }
html[data-layout="phone-landscape"] .table.called .current { padding-inline: 136px; }
html[data-layout="phone-landscape"] .table .current:empty { display: none; }
html.phone[data-layout="phone-landscape"] .table .current { flex: none; width: 100%; min-height: 0; gap: 3px; margin-block: auto; }
html.phone[data-layout="phone-landscape"] .table .current .cards { flex-shrink: 0; padding: 4px 8px; }
html.phone[data-layout="phone-landscape"] .table .current .card { --ch: clamp(28px, calc(100cqh - 30px), 90px); --cw: calc(var(--ch) * 0.7); }
html[data-layout="phone-landscape"] .current .caption { font-size: 12px; line-height: 16px; }
html[data-layout="phone-landscape"] .hand { --ch: clamp(56px, calc(var(--app-height) * .26), 132px); --cw: calc(var(--ch) * .7); min-height: 0; padding: 0; }
html[data-layout="phone-landscape"] .foot.two-rows .hand { --ch: clamp(48px, calc(var(--app-height) * .16), 84px); }
html[data-layout="phone-landscape"] .hand-row { --row-headroom: 16px; }
html[data-layout="phone-landscape"] .console { gap: 8px; padding-block: 0; }
html[data-layout="phone-landscape"] .console .status { font-size: 13px; line-height: 1.25; white-space: normal; }
html[data-layout="phone-landscape"] .console .actions { margin-left: auto; }
html[data-layout="phone-landscape"] .console .actions button { font-size: 14px; padding: 8px; }
html[data-layout="phone-landscape"] .toast { top: max(6px, env(safe-area-inset-top)); bottom: auto; max-width: min(44vw, 380px); }
html[data-layout="phone-landscape"] .table.choosing-partner .center-body { container-type: normal; }
html[data-layout="phone-landscape"] .bottom-cards .label { display: none; }
html.phone[data-layout="phone-landscape"] .table .bottom-cards .card-row .card { --ch: clamp(24px, calc(100cqh - 8px), 72px); --cw: calc(var(--ch) * .7); }
@container (max-height: 60px) {
  html.phone[data-layout="phone-landscape"] .table .current { gap: 2px; }
  html.phone[data-layout="phone-landscape"] .table .current .caption { font-size: var(--text-micro); line-height: 12px; }
  html.phone[data-layout="phone-landscape"] .table .current .play-combo { display: none; }
  html.phone[data-layout="phone-landscape"] .table .current .cards { padding-block: 1px; }
  html.phone[data-layout="phone-landscape"] .table .current .card { --ch: clamp(24px, calc(100cqh - 18px), 40px); }
}

/* Held at the bottom edge in landscape. Equal side columns center the hand on the table
   while keeping the controls clear; only the lower card art bleeds past the viewport. */
html.phone .table.hand-docked {
  --control-width: clamp(120px, 14vw, 132px);
  --hand-crop: clamp(8px, calc(var(--app-height) * .025), 14px);
  --dock-gap: 12px;
  padding-bottom: 0;
  overflow: clip; /* cropped cards must not scroll the table when focused */
}
html.phone .table.hand-docked .foot {
  display: grid;
  grid-template-columns: var(--control-width) minmax(0, 1fr) var(--control-width);
  grid-template-rows: 44px auto;
  gap: 4px var(--dock-gap);
  align-items: end;
}
html.phone .table.hand-docked .console {
  position: relative;
  grid-column: 1 / -1; grid-row: 1 / 3; align-self: stretch;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--control-width);
  grid-template-rows: 44px minmax(0, 1fr);
  gap: 4px var(--dock-gap);
  min-height: 0; padding: 0; border: 0; background: none; box-shadow: none;
  pointer-events: none;
}
html.phone .table.hand-docked .console-main {
  grid-column: 1; grid-row: 1; display: flex; align-items: center; gap: 8px;
  min-width: 0; height: 44px; pointer-events: auto;
}
html.phone .table.hand-docked[data-phase="bidding"] .foot { grid-template-rows: 64px auto; }
html.phone .table.hand-docked[data-phase="bidding"] .console { grid-template-rows: 64px minmax(0, 1fr); }
html.phone .table.hand-docked[data-phase="bidding"] .console-main { height: 64px; }
html.phone .table.hand-docked.spotlight .console .status {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: clamp(160px, 38vw, 280px); max-width: calc(100% - 180px);
  margin: 0; padding: 0; align-items: center; text-align: center;
}
html.phone .table.hand-docked.spotlight .console .status-detail { max-width: 100%; }
html.phone .table.hand-docked .console .actions {
  grid-column: 2; grid-row: 1 / 3; align-self: end;
  display: flex; flex-direction: column; gap: 8px;
  width: 100%; margin: 0; padding-bottom: max(10px, env(safe-area-inset-bottom));
  pointer-events: auto;
}
html.phone .table.hand-docked .console .actions button {
  display: flex; align-items: center; justify-content: center;
  width: 100%; margin: 0; min-height: 44px; padding: 8px 10px;
  border-radius: 8px; font-size: 14px; line-height: 20px;
}
html.phone .table.hand-docked .console .actions button:is([data-act="hint"], [data-act="clear"]) {
  background: transparent;
  border-color: transparent; color: var(--ink-soft); box-shadow: none;
}
html.phone .table.hand-docked .console .actions button.text:hover:not(:disabled) { text-decoration: none; background: color-mix(in srgb, var(--ink) 6%, transparent); }
html.phone .table.hand-docked .actions [data-act="hint"] { grid-area: hint; gap: 6px; }
html.phone .table.hand-docked .actions [data-act="clear"] { grid-area: clear; }
html.phone .table.hand-docked .console .actions [data-act="pass"] { grid-area: pass; border-color: var(--line); background: transparent; color: var(--ink); box-shadow: none; }
html.phone .table.hand-docked .console .actions [data-act="pass"].pass-ready { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
html.phone .table.hand-docked .actions #play { grid-area: play; min-height: 52px; font-size: 16px; }
html.phone .table.hand-docked .actions #play:disabled { opacity: 1; background: color-mix(in srgb, var(--ink) 10%, transparent); border-color: transparent; color: var(--ink-faint); box-shadow: none; }
/* Hint and Clear share a quiet utility row above the two move buttons. */
html.phone .table.hand-docked .console .actions.playing {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas: "hint clear" "pass pass" "play play";
}
html.phone .table.hand-docked .console .actions.playing:not(:has([data-act="hint"])) { grid-template-areas: "clear clear" "pass pass" "play play"; }
html.phone .table.hand-docked .console .actions button:is([data-act="hint"], [data-act="clear"]) { padding: 6px 4px; gap: 3px; font-size: 12px; }
html.phone .table.hand-docked .foot > .hand {
  grid-column: 2; grid-row: 2; order: 0; align-self: end; min-width: 0;
  margin-bottom: calc(-1 * var(--hand-crop));
}
html.phone .table.hand-docked .hand { --ch: clamp(90px, calc(var(--app-height) * .34), 180px); }
/* Out of cards, my partner's hand lies where mine did, between the side columns. */
html.phone .table.hand-docked .foot > .partner-region { grid-column: 2; grid-row: 2; align-self: end; min-width: 0; }
html.phone .table.hand-docked .partner-hand { --pch: clamp(40px, calc(var(--app-height) * .13), 56px); gap: 3px; margin: 0 auto max(6px, env(safe-area-inset-bottom)); padding: 4px 10px 6px; }
html.phone .table.hand-docked .foot.two-rows .hand { --ch: clamp(64px, calc(var(--app-height) * .22), 104px); }

html[data-layout="phone-landscape"] .review .rhand { padding-block: 11px 3px; }
html[data-layout="phone-landscape"] .review .rhand .card { --cw: 25.2px; --ch: 36px; }
html[data-layout="phone-landscape"] .review .rhand .card + .card { margin-left: -8px; }
/* Learning panels use the same compact breakpoints as the table. */
@media (max-width: 600px), (max-width: 1280px) and (max-height: 600px) {
  .modal.learning-review { padding: 12px 14px 10px; }
  .learning-review .rhead { gap: 10px; margin-bottom: 10px; }
  .learning-review .rhead h3 { font-size: 18px; }
  .learning-review .review-scope { display: flex; width: 100%; }
  .learning-review .review-scope button { min-width: 0; padding-inline: 10px; white-space: normal; line-height: 1.2; }
  .learning-review .rhead .learning-seal { width: 34px; height: 34px; font-size: 20px; }
  .learning-review .learning-decision { padding: 12px; }
  .learning-review .decision-title h3 { font-size: 22px; }
  .learning-review .decision-comparison { gap: 8px; }
  .learning-review .decision-move { padding: 10px 10px 2px; }
  .learning-review .decision-move > strong { font-size: var(--text-label); }
  .learning-review .decision-move .card { --cw: 35px; --ch: 50px; }
  .learning-review .decision-lesson > p, .learning-review .decision-lesson .learning-callout { font-size: var(--text-label); }
  .learning-review .rseat { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 6px; }
  .learning-review .review-moments { display: flex; overflow-x: auto; margin: -2px; padding: 2px; scrollbar-width: none; }
  .learning-review .review-moments .moment { flex: 0 0 auto; grid-template-areas: "step label label" "step name tag"; gap: 0 8px; max-width: 78%; }
  .learning-review .moment > .severity { align-self: start; }
  .learning-review .review-footer { grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; padding-top: 8px; }
  .learning-review .review-footer .buttons { grid-column: 1 / -1; gap: 6px; }
  .learning-review .review-footer .buttons button { flex: 1 1 0; padding-inline: 8px; font-size: var(--text-caption); }
  .learning-review .review-footer .next-moment { flex-grow: 2; }
  .score-factors > div { padding: 8px 6px; }
  .score-factors strong { font-size: 22px; }
  .score-calculation > b { font-size: 22px; }
  .learning-sheet .keyboard-instructions { display: none; }
}
@media (max-width: 360px) {
  .learning-review .review-footer .buttons { flex-wrap: wrap; }
  .learning-review .review-footer .buttons .next-moment { order: -1; flex-basis: 100%; }
  .learning-review .review-scope button { font-size: var(--text-caption); }
}
/* A phone held sideways: the moments run in a row beside the scope, the footer is one row. */
@media (max-height: 500px) and (min-width: 601px) {
  .learning-review .rhead { margin-bottom: 8px; }
  .learning-review .review-overview { flex-wrap: nowrap; gap: 12px; padding-bottom: 10px; }
  .learning-review .review-overview:has(.review-moments) > .review-summary { display: none; } /* the row of moments beside it stands in for the count */
  .learning-review .decision-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
  .learning-review .review-overview > h4 { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .learning-review .review-overview > p { margin: 0; }
  .learning-review .review-scope { flex: none; width: auto; }
  .learning-review .review-scope button { padding-inline: 12px; font-size: var(--text-caption); }
  .learning-review .review-moments { flex: 1 1 0; min-width: 0; }
  .learning-review .review-moments .moment { min-height: 44px; padding-block: 3px; }
  .learning-review .moment-step { width: 28px; height: 34px; font-size: 17px; }
  .learning-review .decision-title h3 { font-size: 20px; }
  .learning-review .rseat { grid-template-columns: minmax(0, 210px) minmax(0, 1fr); gap: 0 12px; padding-top: 4px; }
  .learning-review .review-footer { grid-template-columns: auto minmax(0, 1fr) auto; }
  .learning-review .review-footer .buttons { grid-column: auto; }
  .learning-review .review-footer .buttons button { flex: none; padding-inline: 14px; }
  .learning-review .review-footer .next-moment { white-space: nowrap; }
}
@media (max-height: 520px) and (min-width: 640px) {
  .result-modal .score-explanation { margin-block: 2px; }
  .result-modal .score-explanation:not([open]) > summary { min-height: 28px; padding-block: 2px; }
  .result-modal .buttons { margin-top: 6px; }
  .result-modal .deltas .result-row { padding-block: 3px; }
  /* No room for the sides' names: a rule between them, under a title that names the winner. */
  .result-modal .deltas .side-name { display: none; }
  .result-modal .deltas .result-side + .result-side { margin-top: 2px; padding-top: 3px; border-top: 1px solid var(--line); }
  /* Why the partner was named says more than the seal, which gives it room. */
  .result-head:has(.result-note) .result-seal { display: none; }
}

/* In portrait the header has no room beside the tools: the tracker takes a row of its own. */
html[data-layout="phone-portrait"] .topbar:has(.tracker) { flex-wrap: wrap; height: auto; row-gap: 2px; }
html[data-layout="phone-portrait"] .topbar:has(.tracker) .stakes { height: 44px; } /* not the grown header's 100% */
html[data-layout="phone-portrait"] .topbar .tracker { order: 3; flex: 1 1 100%; justify-content: space-between; margin: 0 0 2px; }
html[data-layout="phone-portrait"] .tracker .tk { flex: 1; width: auto; }
@media (max-height: 480px) {
  .topbar .tracker { height: 26px; }
  .tracker .tk { width: 20px; gap: 1px; }
  .tracker .tk i { font-size: 10px; }
  .tracker .tk b { font-size: 11px; }
}
/* A short portrait screen (an SE) has no row to spare: the play in the middle keeps it. */
@media (max-height: 640px) {
  html[data-layout="phone-portrait"] .topbar .tracker { display: none; }
}
