/* The online table on the shared table UI (features/table-ui, docs/ux/table-v2-spec.md).
   Only what this table needs on top of the shared CSS; loads after client.css, so it wins ties.
   One block per card (docs/ux/table-v2-spec.md §7): edit only your own block (anything else: ask the UX lead).
   Dead rules in client.css for markup that's gone are removed in the cleanup PR, not here. */

/* [board] C03 — board: land summary row and the permanents grid --------------- */
.op-board .tui-grid, .me-board .tui-grid { display: grid; grid-template-columns: repeat(auto-fill, var(--cw)); justify-content: start; align-items: start; align-content: start; min-height: 0; padding: 4px; background: none; }
.op-board .tui-grid.empty, .me-board .tui-grid.empty { display: none; }
.op-board .tui-grid > .pile-grp, .me-board .tui-grid > .pile-grp { width: var(--tui-card-w); }
.op-board .tui-mana, .me-board .tui-mana { min-height: 44px; width: 100%; }

/* [phone] C06 — phone portrait shell: dock, hand, your strip, seat strip ------ */
/* Stopgap styles for the S0 components (seat chips, dock, sheet pill) until C04/C05 style them in features/table-ui. */
body.in-game { overflow: hidden; }
/* Card sizes: the old table set --cw and --hw on .tb; client.css still sizes cards from them. */
.tui[data-table="mp"] { --cw: clamp(46px, 4.4vw, 84px); --hw: clamp(64px, 5.8vw, 110px); }
.tui[data-opps="1"] .op { --cw: clamp(40px, 3.6vw, 68px); }
.tui[data-opps="2"] .op { --cw: clamp(34px, 3vw, 58px); }
@media (max-width: 860px) and (orientation: portrait), (max-width: 860px) and (min-height: 501px) { .tui[data-table="mp"] { --cw: 44px; --hw: 66px; } .tui[data-opps] .op { --cw: 44px; } } /* an opponent's card is a real 44px wide (it is tapped to target and to block; spec rule 6), not a 36px card with a larger hit area */
/* C21: the online table sizes its cards from --cw and --hw (not the tokens), so a tablet held upright scales them the same way (44px to 58px, the same 1.31 as the board token). Opponents' cards never go below the phone's 44px (C22, spec rule 6). */
@media (min-width: 600px) and (max-width: 899px) and (min-height: 501px) {
  .tui[data-table="mp"] { --cw: clamp(44px, min(6.4vw, 5.2vh), 58px); --hw: var(--tui-hand-card-w); }
  .tui[data-opps] .op { --cw: clamp(44px, min(5.2vw, 4.2vh), 48px); }
}
.tui[data-table="mp"] { padding: 0; }
.tui-top .tui-chip { flex: 0 1 auto; min-width: var(--tui-tap); max-width: 11em; overflow: hidden; box-sizing: border-box; display: inline-flex; align-items: center; gap: 5px; min-width: var(--tui-tap); min-height: var(--tui-tap); padding: 0 8px 0 5px; border-radius: 999px; border: 1px solid var(--tui-line); background: var(--tui-panel-2); color: inherit; font: inherit; font-size: 13px; }
.tui-top .tui-chip.tui-focus { border-color: var(--tui-seat, var(--tui-accent)); background: var(--tui-panel); }
.tui-top .tui-chip.tui-active { box-shadow: inset 0 -3px 0 var(--tui-seat, var(--tui-accent)); }
.tui-top .tui-chip.tui-prio .tui-life { color: var(--tui-gold); }
.tui-av { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--tui-seat, var(--tui-line)); color: #0b0e12; font-size: 12px; font-weight: 700; }
.tui-chip-name { max-width: 6em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tui-step, .tui-more { flex: none; box-sizing: border-box; min-height: var(--tui-tap); min-width: var(--tui-tap); padding: 0 10px; border-radius: 999px; border: 1px solid var(--tui-line); background: var(--tui-panel-2); color: inherit; font: inherit; font-size: 13px; }
.tui-step { flex: 0 1 auto; min-width: 0; margin-left: auto; max-width: 8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tui-steps-pop { position: absolute; left: 0; right: 0; top: 100%; z-index: 60; padding: 6px 8px; background: var(--tui-panel); border-bottom: 1px solid var(--tui-line); box-shadow: 0 10px 30px rgba(0, 0, 0, .6); }
.tui-steps-pop .phases { flex-wrap: wrap; border-radius: var(--tui-radius); }
.tui-steps-pop .ph { min-height: var(--tui-tap); padding: 0 12px; }
.tui-dock-in { flex-wrap: nowrap; height: var(--tui-dock-h); } /* one row: C04's dock wraps when the prompt is long, which moved the main button */
.tui-dock-status { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; line-height: 16px; } /* the timer and the prompt side by side (C04's status is a 2-line clamp) */
.tui-dock-status .prompt { min-width: 0; max-height: 32px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
/* waiting on someone else: the main button's spot shows a disabled "Waiting" in every mode, so the spot never looks empty (#106) */
.tui-dock-main.idle, .tui-dock-main.tui-idle { visibility: visible; font-size: 0; opacity: .55; }
.tui-dock-main.tui-idle::after { content: 'Waiting'; font-size: 13px; }
.tui-dock .tmr-slot, .tui-dock .tmr { flex: none; white-space: nowrap; }
.tui-dock .act-bar { display: block; flex: none; margin: 0; padding: 0; height: auto; max-width: none; border: 0; border-radius: 0; background: none; backdrop-filter: none; } /* the old bar's frame: the dock is the frame now */
.act-bar.passing { background: rgba(58, 42, 12, .9); }
.tui-pill { box-sizing: border-box; position: absolute; top: 0; transform: translateY(-50%); min-height: var(--tui-tap); padding: 0 16px; border-radius: 999px; border: 1px solid var(--tui-line); background: var(--tui-panel-2); color: var(--tui-text); font: inherit; font-size: 13px; box-shadow: 0 2px 10px rgba(0, 0, 0, .5); }
.tui-dock .decide, .tui-dock .selbar { flex: none; margin: 0; max-height: 34dvh; overflow: auto; }
@media (max-width: 860px) and (orientation: portrait), (max-width: 860px) and (min-height: 501px) { .tui[data-table="mp"] .tui-dock { max-height: 50dvh; overflow-y: auto; } } /* online, phone upright: a tall decision scrolls inside the dock (was in the shared layout.css, which clipped vs-computer's floating selection bar) */
.tui-opps > .op { min-height: 0; overflow: auto; margin: 0; }
.tui-mine { min-height: 0; padding: 0; border: 0; }
.tui-mine > .me { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin: 0; }
.tui-mine .me-main { flex: 1 1 auto; min-height: 0; overflow: auto; }
.tui-me { gap: 8px; }
.tui-me-life { display: inline-flex; align-items: center; gap: 4px; min-height: var(--tui-tap); padding: 0 6px; border-radius: var(--tui-radius); }
.tui-me-life.hl { background: rgba(79, 140, 255, .18); box-shadow: inset 0 0 0 2px var(--tui-accent); }
.tui-me-life.chosen { box-shadow: inset 0 0 0 2px var(--tui-good); }
.tui-me-btn { min-width: var(--tui-tap); min-height: var(--tui-tap); padding: 0 8px; }
.tui-me-n { white-space: nowrap; font-size: 13px; }
.tui-hand { background: var(--tui-bg); }
.tui-hand-in { display: flex; align-items: flex-end; }
.tui-hand-cards { flex: 1; min-width: 0; display: flex; gap: 4px; overflow-x: auto; padding: 4px 6px; height: calc(var(--tui-hand-card-w) * 1.395 + 8px); scrollbar-width: none; }
.tui-hand-toggle { flex: none; min-width: var(--tui-tap); min-height: var(--tui-tap); align-self: center; }
.tui-hand-cards .cs { --cw: var(--tui-hand-card-w); margin: 0; flex: none; }
.tui-hand-cards .cc { transform: none; }
.tui-hand-empty { align-self: center; color: var(--tui-muted); }
@media (max-width: 860px) and (orientation: portrait), (max-width: 860px) and (min-height: 501px) { .tui-opps .op-head { padding: 4px 8px; } .tui-mine .me-head, .tui-mine .zone-pile { display: none; } .tui-mine .me-zones { width: auto; } }
/* Desktop keeps the old bar and rails: the seat strip is for phones (landscape: the block below). */
@media (min-width: 900px) and (min-height: 501px) { .tui-top .tui-chip, .tui-top > .tui-step, .tui-top > .tui-more { display: none; } .tui-top .tui-bar { display: block; flex: 1; min-width: 0; } }

/* C17: the attack and block pickers in the decision panel are tap targets (44 px; they were 40). */
@media (max-width: 860px) and (orientation: portrait) { .tui-dock .decide .dc-item select { min-height: var(--tui-tap, 44px); min-width: 44px; } }

/* [sheets] C09 — sheets: stack, log, chat, zones; opponent focus -------------- */
@media (max-width: 860px) and (orientation: portrait), (max-width: 860px) and (min-height: 501px) {
  /* A decision dialog (mulligan, bottom, X, modes, scry…, marked data-decision by dialog()) is a bottom sheet: still a modal <dialog>,
     pinned to the bottom edge, with its footer sticky. Help, settings, report and zone dialogs keep today's look. */
  #dlg[data-decision] { margin: auto 0 0; inset-inline: 0; width: 100%; max-width: 100%; max-height: 75dvh; overflow: auto; border-radius: var(--tui-radius) var(--tui-radius) 0 0; border-width: 1px 0 0; padding: 12px 12px 0; }
  #dlg[data-decision]::backdrop { background: rgba(4, 6, 8, .25); backdrop-filter: none; }
  #dlg[data-decision] .dlg-foot { position: sticky; bottom: 0; z-index: 1; margin: 12px -12px 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #121820; border-top: 1px solid var(--tui-line); }
  #dlg[data-decision] .dlg-foot button { min-height: 44px; min-width: 44px; }
  #dlg[data-decision] label { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 6px 4px; box-sizing: border-box; }
  #dlg[data-decision] input[type="checkbox"], #dlg[data-decision] input[type="radio"] { width: 24px; height: 24px; flex: none; margin: 0; }
}

@media (max-width: 860px) and (orientation: portrait), (max-width: 860px) and (min-height: 501px) {
  /* The stack, log and chat are in the sheet on a phone (sheetRegionHTML), so the side column stays empty. */
  .tui-side { display: none; }
  /* A floor for the sheet (its height is 62dvh minus the dock and the hand): its tabs and one stack row, so a tall hand or selection bar can't squeeze it away. */
  .tui-sheet { min-height: calc(var(--tui-tap) + 110px); }
  /* Inside the sheet: the table's own stack, log, chat and zone markup, without its side-column chrome. */
  .tui-sheet-body .stack { position: static; max-height: none; background: none; border: 0; padding: 0; }
  .tui-sheet-body .st-item { margin-bottom: 6px; }
  .tui-sheet-body .log-list, .tui-sheet-body .chat-log { max-height: none; overflow: visible; }
  .tui-sheet-body .chat-box { display: flex; flex-direction: column; gap: 8px; }
  .tui-sheet-body .chat-form { display: flex; gap: 6px; }
  .tui-sheet-body .chat-form input { flex: 1; min-width: 0; min-height: var(--tui-tap); }
  .tui-sheet-body .chat-form button, .tui-sheet-body .emote, .tui-sheet-body .zone-row button { min-height: var(--tui-tap); min-width: var(--tui-tap); }
  .tui-sheet-body .emotes { display: flex; flex-wrap: wrap; gap: 6px; }
  .zone-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-left: 3px solid var(--seat, var(--tui-line)); padding-left: 8px; }
  .zone-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* [landscape] C11 — phone on its side ----------------------------------------- */
/* One screen: a chip per player in the left rail, the focused opponent's board over yours, the turn row on top,
   then the hand; the right column holds the log or Recent, the status line and the dock (main button and ⏭ ⋯). */
@media (orientation: landscape) and (max-height: 500px) {
  .tui[data-table="mp"] { --cw: 36px; --hw: 48px; --tui-hand-card-w: 48px; padding: max(4px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); gap: 4px; grid-template-rows: auto minmax(0, 1fr) auto var(--tui-hand-h-land); grid-template-areas: "rail top side" "rail boards side" "rail me side" "rail hand dock"; }
  .tui[data-opps] .op { --cw: 26px; }
  .tui-me { display: none; } /* your board's own header has your life and zones; the stack is in the right column */
  .tui-boards { grid-template-rows: minmax(0, 0.65fr) 0 minmax(0, 1fr); gap: 4px; }
  .tui-opps .op-hand, .tui-opps .op-board .row.empty { display: none; }
  .tui-opps .op-board .row { padding-top: 0; }
  .tui-opps .grp-n { top: 0; right: 0; } /* the ×N badge sits on the card: the row has no room above it now */
  .tui-opps .op-head { padding: 0 8px 0 12px; gap: 6px; min-height: 0; font-size: 13px; }
  .tui-opps .op-head .op-counts .cnt:not(.lib):not(.zbtn):not(.poison):not(.rad):not(.energy):not(.experience):not(.pctr) { display: none; } /* the rail chip has their hand and life; the library stays */
  .tui-opps .op-head .zbtn { position: relative; min-height: 0; height: 24px; min-width: 0; padding: 0 6px; }
  .tui-opps .op-head .zbtn::after { content: ''; position: absolute; inset: -10px min(-3px, calc((44px - 100%) / -2)); } /* the visible chip is small, the touch target is 44px */
  .tui-opps .op-head .life { font-size: 15px; padding: 0 8px; }
  .tui-opps .op-head .avatar, .tui-opps .op-head .av { width: 22px; height: 22px; font-size: 11px; }
  .tui-opps .op-body { padding: 0 8px 1px 12px; overflow: auto; }
  /* the land summary is a slim bar here (the touch target is still 44px), so the permanents under it have the room */
  /* the land summary sits beside the opponent's permanents, on their row (no row of its own: a landscape phone has no height to give) */
  .tui-opps .op-board { display: flex; flex-direction: row; flex-wrap: nowrap; align-items: flex-start; gap: 4px; }
  .tui-opps .op-board .tui-grid { flex: 1 1 auto; min-width: 0; }
  .tui-opps .op-board .tui-mana { order: 2; flex: none; width: auto; min-width: 64px; height: 34px; margin: 1px 0 0; }
  /* your piles: Library, Graveyard and Exile are three short rows beside your board, all of them on screen */
  .tui-mine .me-zones { width: auto; min-width: 88px; gap: 4px; align-items: stretch; justify-content: flex-start; overflow: hidden; }
  .tui-mine .zone-pile { flex-direction: row; align-items: center; justify-content: flex-start; gap: 5px; height: 28px; min-height: 0; padding: 0 4px; }
  .tui-mine .zone-pile { position: relative; }
  .tui-mine .zone-pile::after { content: ''; position: absolute; inset: -8px 0; } /* 28px to look at, 44px to tap */
  .tui-mine .zone-pile .zp-card { flex: none; width: 20px; height: 28px; overflow: hidden; }
  .tui-mine .zone-pile span { font-size: 10.5px; text-align: left; white-space: nowrap; }
  .op-board .tui-mana, .me-board .tui-mana { position: relative; min-height: 26px; padding-block: 0; font-size: 12px; }
  .op-board .tui-mana::after, .me-board .tui-mana::after { content: ''; position: absolute; inset: -9px 0; }
  .tui-top { display: flex; padding: 0; border: 0; background: none; }
  /* the step bar fits whole: the active player is the rail's lit chip (the dot stays, the words are for screen readers), and the steps are tighter,
     with three-letter names where the strip is narrow (a phone's width of 800px or less) */
  .tui-top .whose span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tui-top .bar .ph { flex: 1 0 auto; padding: 0 4px; min-width: 0; min-height: 30px; } /* a stop toggle, not a main control: the turn row stays short so the boards keep their height (pending the lead's ruling on landscape touch sizes) */
  .tui-top .bar .phases { gap: 0; pointer-events: none; flex: 1 1 auto; } /* the strip shows where the turn is; a tap on it opens the steps (44px each, to set a stop) */
  .tui-top .bar .phases-box { position: relative; flex: 1 1 auto; min-width: 0; display: flex; }
  .tui-top .bar .steps-open { display: block; position: absolute; inset: 0; width: 100%; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 999px; background: none; }
  .tui-top .bar .steps-open::after { content: ''; position: absolute; inset: -6px 0; }

  .tui-top .tui-chip, .tui-top > .tui-step, .tui-top > .tui-more, .tui-top .tui-seatstrip { display: none; } /* the phone's strip (step pill, ⋯) is not for a phone on its side */
  .tui-top .tui-bar { display: block; flex: 1; min-width: 0; }
  .tui-rail, .tui-side { padding: 0; background: none; border: 0; }
  /* the rail: a chip for every player, the focused opponent marked */
  .tui-players { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
  .tui-rail .tui-chip { box-sizing: border-box; width: 100%; min-height: var(--tui-tap); display: flex; align-items: center; gap: 6px; padding: 0 8px 0 5px; border-radius: var(--tui-radius); border: 1px solid var(--tui-line); border-left: 3px solid var(--tui-seat, var(--tui-line)); background: var(--tui-panel-2); color: inherit; font: inherit; font-size: 13px; text-align: left; }
  .tui-rail .tui-chip.tui-focus { background: var(--tui-panel); border-color: var(--tui-seat, var(--tui-accent)); }
  .tui-rail .tui-chip.tui-active { box-shadow: inset 0 -3px 0 var(--tui-seat, var(--tui-accent)); }
  .tui-rail .tui-chip.tui-prio .tui-life { color: var(--tui-gold); }
  .tui-rail .tui-chip.hl { box-shadow: inset 0 0 0 2px var(--tui-accent); }
  .tui-rail .tui-chip-name { flex: 1 1 auto; min-width: 0; max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tui-rail .tui-chip-n { flex: none; font-size: 12px; white-space: nowrap; }
  .tui-rail .tui-chip { flex-wrap: wrap; align-content: center; }
  .tui-rail .tui-chip-sum { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 0 8px; padding: 0 0 3px 30px; font-size: 11px; color: var(--tui-muted); white-space: nowrap; }
  .tui-rail .tui-chip-sum small { margin-left: 2px; color: #ffcf8a; }
  .tui-side .tab-row button { min-width: 44px; padding-inline: 2px; font-size: 12px; overflow: visible; text-overflow: clip; }
  /* the dock cell is small: the main button and ⏭ ⋯ stay in it; the prompt sits on the foot of the right column and a decision or selection over the foot of the centre */
  .tui-dock { position: relative; height: var(--tui-hand-h-land); min-height: 0; background: none; border: 0; overflow: visible; }
  .tui-dock .act-bar { flex: 1 1 auto; min-height: 0; }
  .tui-dock-in { height: 100%; display: grid; grid-template-columns: var(--tui-tap) minmax(0, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: var(--tui-gap); padding: 0; }
  .tui-dock-in .pass-opts { grid-area: 1 / 1; }
  .tui-dock-in .act-menu { grid-area: 2 / 1; }
  .tui-dock-in .tui-dock-main { grid-area: 1 / 2 / 3 / 3; align-self: stretch; height: auto; width: auto; min-width: 0; white-space: normal; line-height: 1.15; overflow: hidden; }
  .tui-dock-in .tui-dock-btn { position: relative; align-self: stretch; height: auto; min-height: 0; min-width: 0; width: 100%; margin: 0; padding: 0; } /* (client.css gives ⏭ a -8px margin: it must not reach under the hand) */
  .tui-dock-in .tui-dock-btn::after { content: ""; position: absolute; inset: -6px; } /* the buttons are half the cell tall; the touch target is 44px */
  .tui-side { padding-bottom: 40px; box-sizing: border-box; } /* room for the status line on the foot of the column */
  .tui-dock-status { position: absolute; left: 0; right: 0; bottom: 100%; box-sizing: border-box; height: 38px; padding: 2px 6px; font-size: 12px; line-height: 14px; background: var(--tui-panel); border-top: 1px solid var(--tui-line); }
  .tui-dock .decide, .tui-dock .selbar { position: fixed; z-index: 30; right: max(6px, env(safe-area-inset-right)); width: var(--tui-side-w-land); box-sizing: border-box; bottom: calc(var(--tui-hand-h-land) + 44px); max-height: calc(100dvh - var(--tui-hand-h-land) - 56px); overflow: auto; background: var(--tui-panel); border: 1px solid var(--tui-line); border-radius: var(--tui-radius); } /* over the log, never over a board you pick from */
  .tui-pill { display: none; } /* the stack is in the right column */
  .tui-dock .decide .dc-item select, .tui-dock .decide .dc-item .x, .tui-dock .decide .chip-btn { min-height: var(--tui-tap, 44px); min-width: 44px; } /* the attack and block panels' selects and ✕ (#1084 did the portrait phone) */
}

@media (orientation: landscape) and (max-height: 500px) and (max-width: 800px) {
  .tui-top .bar .ph { font-size: 0; padding: 0 3px; }
  .tui-top .bar .ph::before { content: attr(data-short); font-size: 11px; }
}

/* [desktop] C14 — desktop / tablet: top bar, rails, inspector ----------------- */
@media (min-width: 900px) and (min-height: 501px) {
  .tui[data-table="mp"] { --cw: clamp(38px, min(4.4vw, 6vh), 84px); } /* yours: sized by the shorter of the width and the height */
  /* Card sizes by the number of opponents (the old table's sizes; C03 may move them onto the tokens). */
  .tui[data-table="mp"] .tui-opps .op { --cw: clamp(40px, 3.6vw, 68px); }
  .tui[data-table="mp"][data-seats="3"] .tui-opps .op, .tui[data-table="mp"][data-seats="4"] .tui-opps .op { --cw: clamp(34px, 2.6vw, 52px); }
  .tui[data-table="mp"][data-seats="5"] .tui-opps .op, .tui[data-table="mp"][data-seats="6"] .tui-opps .op { --cw: clamp(26px, 1.9vw, 38px); }
  /* Quadrants (layout.css [C-quad]): every board is a cell of the boards area, and board.css sizes its cards from the cell (--tui-card-w, from the permanent count); --tui-board-chrome is what a board spends above them. */
  .tui[data-table="mp"][data-layout="quad"] .tui-opps .op, .tui[data-table="mp"][data-layout="quad"] .tui-mine { --cw: var(--tui-card-w); }
  .tui[data-table="mp"][data-layout="quad"] .tui-opps .op { --tui-board-chrome: 132px; }
  .tui[data-table="mp"][data-layout="quad"] .tui-mine { --tui-board-chrome: 114px; --tui-board-chrome-w: 150px; }
  /* Your zones on the board's right edge (desktop Q8): library, graveyard, exile and your COMMAND ZONE are compact rows at every window height. At 900px tall and more the piles used to be
     full-size cards and pushed the graveyard, the exile and the command zone off the bottom of the board (the commander could not be cast without zooming the browser out). */
  .tui[data-layout="quad"] .tui-mine .me-zones { width: auto; min-width: 104px; gap: 4px; align-items: stretch; justify-content: flex-start; overflow: visible; }
  .tui[data-layout="quad"] .tui-mine .zone-pile { flex-direction: row; align-items: center; justify-content: flex-start; gap: 6px; height: 28px; min-height: 0; padding: 0 4px; position: relative; }
  .tui[data-layout="quad"] .tui-mine .zone-pile::after { content: ''; position: absolute; inset: -8px 0; }
  .tui[data-layout="quad"] .tui-mine .zone-pile .zp-card { flex: none; width: 20px; height: 28px; overflow: hidden; }
  .tui[data-layout="quad"] .tui-mine .zone-pile span { font-size: 11px; text-align: left; white-space: nowrap; }
  .tui[data-layout="quad"] .tui-mine .me-cmd { flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 6px; margin: 4px 0 0; }
  .tui[data-layout="quad"] .tui-mine .me-cmd .lbl { font-size: 11px; color: var(--tui-muted); }
  .tui[data-layout="quad"] .tui-mine .me-cmd .cs { --cw: 46px; }
  /* An opponent's COMMAND ZONE (desktop quad): a column at the right of the board's body, like yours, not a row under the permanents. Under twelve or so permanents the row was below the
     board's bottom edge (the quadrant scrolls) and the commander was cut off; now it is always in view, a 64px card (the touch target), with the permanents' columns narrowed to leave room. */
  .tui[data-layout="quad"] .tui-opps .op.has-cmd { --tui-board-chrome-w: 84px; }
  .tui[data-layout="quad"] .tui-opps .op-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "hand hand" "board cmd"; column-gap: 8px; align-content: start; }
  .tui[data-layout="quad"] .tui-opps .op-hand { grid-area: hand; }
  .tui[data-layout="quad"] .tui-opps .op-board { grid-area: board; min-width: 0; }
  .tui[data-layout="quad"] .tui-opps .op-cmd { grid-area: cmd; flex-direction: column; flex-wrap: nowrap; align-items: flex-start; gap: 2px; margin: 4px 0 0; width: 64px; }
  .tui[data-layout="quad"] .tui-opps .op-cmd .lbl { font-size: 9px; letter-spacing: .04em; }
  .tui[data-layout="quad"] .tui-opps .op-cmd .cs { --cw: 64px; }
  /* 3-4 seats on a window under 820px tall: the opponents' face-down hand row gives its height to the cards (the head has the hand count) */
  @media (max-height: 820px) {
    .tui[data-table="mp"][data-layout="quad"]:is([data-seats="3"], [data-seats="4"]) .tui-opps .op-hand { display: none; }
    .tui[data-table="mp"][data-layout="quad"]:is([data-seats="3"], [data-seats="4"]) .tui-opps .op { --tui-board-chrome: 112px; }
  }
  .tui-mine .me-head .zbtn { position: relative; min-height: 0; height: 24px; min-width: 0; padding: 0 6px; }
  .tui-mine .me-head .zbtn::after { content: ''; position: absolute; inset: -10px min(-3px, calc((44px - 100%) / -2)); } /* the visible button is small, the touch target is 44px */
  /* 3-4 seats on a window under 1500px wide: a board is about 500px wide, so your zone piles (the head's graveyard and exile buttons open them) give their column to the cards */
  @media (max-width: 1500px) {
    .tui[data-table="mp"][data-layout="quad"]:is([data-seats="3"], [data-seats="4"]) .tui-mine .me-zones .zone-pile { display: none; }
    .tui[data-table="mp"][data-layout="quad"]:is([data-seats="3"], [data-seats="4"]) .tui-mine .me-zones { min-width: 0; }
    .tui[data-table="mp"][data-layout="quad"]:is([data-seats="3"], [data-seats="4"]) .tui-mine { --tui-board-chrome-w: 0px; }
    /* ...but the command zone stays: its card alone (the label is in its tooltip), a 44px column; the card is 44px wide, the touch target */
    .tui[data-table="mp"][data-layout="quad"]:is([data-seats="3"], [data-seats="4"]) .tui-mine.has-cmd { --tui-board-chrome-w: 48px; }
    .tui[data-table="mp"][data-layout="quad"]:is([data-seats="3"], [data-seats="4"]) .tui-mine .me-cmd { flex-direction: column; align-items: flex-start; gap: 0; margin: 0; }
    .tui[data-table="mp"][data-layout="quad"]:is([data-seats="3"], [data-seats="4"]) .tui-mine .me-cmd .lbl { display: none; }
    .tui[data-table="mp"][data-layout="quad"]:is([data-seats="3"], [data-seats="4"]) .tui-mine .me-cmd .cs { --cw: 44px; }
  }
  .tui[data-table="mp"][data-seats="5"] .op-hand, .tui[data-table="mp"][data-seats="6"] .op-hand { display: none; } /* the face-down hand row: the count is in the header */
  /* Six players are two rows of opponents: give them more of the height. */
  .tui[data-table="mp"][data-seats="5"] .tui-boards, .tui[data-table="mp"][data-seats="6"] .tui-boards { grid-template-rows: minmax(0, 1fr) minmax(150px, .4fr); } /* yours gives way first, down to a 150px floor */
  .tui[data-table="mp"][data-seats="3"] .tui-boards, .tui[data-table="mp"][data-seats="4"] .tui-boards { grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  /* Five or six opponents: a one-line header and a land row of at most 28px, so the permanents under them show. */
  .tui[data-table="mp"][data-seats="5"] .tui-opps .op-head, .tui[data-table="mp"][data-seats="6"] .tui-opps .op-head { flex-wrap: nowrap; gap: 4px; padding: 2px 6px 2px 8px; overflow: hidden; }
  .tui[data-table="mp"][data-seats="5"] .tui-opps .op-counts, .tui[data-table="mp"][data-seats="6"] .tui-opps .op-counts { flex-wrap: nowrap; flex: 0 1 auto; min-width: 0; gap: 2px; font-size: 11px; overflow: hidden; }
  .tui[data-table="mp"][data-seats="5"] .tui-opps .op-counts .lib, .tui[data-table="mp"][data-seats="6"] .tui-opps .op-counts .lib, .tui[data-table="mp"][data-seats="5"] .tui-opps .op-counts .zbtn, .tui[data-table="mp"][data-seats="6"] .tui-opps .op-counts .zbtn { display: none; }
  .tui[data-table="mp"][data-seats="5"] .tui-opps .op-name, .tui[data-table="mp"][data-seats="6"] .tui-opps .op-name { max-width: 5em; }
  .tui[data-table="mp"][data-seats="5"] .tui-opps .life, .tui[data-table="mp"][data-seats="6"] .tui-opps .life { font-size: 15px; padding: 1px 6px; }
  .tui-opps .op-board .tui-mana { min-height: 0; height: 28px; padding: 0 8px; }
  /* Your zone piles fit the column on a short window (the Exile pile and its label were cut at 768px). */
  .tui-mine .me-zones { gap: 4px; overflow: hidden; }
  @media (max-height: 900px) {
    .tui-mine .me-zones { width: auto; min-width: 104px; align-items: flex-start; justify-content: center; }
    .tui-mine .zone-pile { flex-direction: row; align-items: center; gap: 6px; }
    .tui-mine .zp-card { width: 22px; height: 31px; flex: none; }
    .tui-mine .zone-pile span { font-size: 11px; text-align: left; white-space: nowrap; }
  }
  .tui-top .tui-seatstrip { display: none; } /* the seat strip is the phone's top bar (C04's seats.css would show it again) */
  /* The top bar is one row at every desktop width: the steps give way (they scroll), the rest keeps its size. */
  .tui-bar > .bar { flex-wrap: nowrap; width: 100%; min-width: 0; box-sizing: border-box; height: calc(var(--tui-top-h-desk) - 8px); padding-top: 0; padding-bottom: 0; }
  .tui-bar .phases { flex: 1 1 auto; min-width: 0; }
  .tui-bar .whose { flex: 0 1 auto; min-width: 0; max-width: 16em; }
  .tui-bar .bar-tools { flex: none; }
  /* The rail: C04's chips (seats.css); only the line height, the focus ring and the turn colour are ours. */
  .tui-players .tui-chip { min-height: 40px; }
  .tui-players .tui-chip.tui-focus { box-shadow: 0 0 0 1px var(--tui-seat, var(--tui-accent)); }
  .tui-players .tui-chip.tui-active .tui-chip-name { color: var(--tui-gold); }
}
@media (min-width: 900px) and (max-width: 1150px) and (min-height: 501px) { .tui-bar .prio, .tui-bar .report-btn .lbl-wide { display: none; } }
/* A narrow dock column (tablet landscape): the prompt gets its own row above the buttons, so the timer and the main button keep their room. */
@media (min-width: 900px) and (max-width: 1150px) and (min-height: 501px) { .tui-dock-in { flex-wrap: wrap; height: auto; align-content: flex-end; } .tui-dock-status { order: -1; flex: 1 0 100%; } }

/* [polish] C19 — online layout polish from the #1100 readiness run ------------- */
.phases-box { display: contents; } /* landscape makes it a box with a button over the step strip */
.steps-open { display: none; }
/* Phone upright: the Stack pill shows only while something is on the stack, and it has a row of its own between the boards, so it never covers a card or the land summary. */
@media (max-width: 860px) and (orientation: portrait), (max-width: 860px) and (min-height: 501px) {
  .tui-split.has-stack { height: var(--tui-tap); align-items: center; }
  .tui-split.has-stack .tui-pill { position: static; transform: none; }
}

/* [card] desktop Q4 (#1250), the quadrant layout: a battlefield card reads at a glance, as on the vs-computer table (arena-v2.css [card]). The power/toughness plate is bigger and stays level
   when the card is tapped; so do the counters, the ATK / BLK badge (with the name of what it blocks when the card is wide enough) and a tab for what is attached to it. The card turns 90deg
   and each of these turns back -90deg around its own centre, at the corner that is the visible one after the turn (a tapped card's local top-right is its visible bottom-right, and so on).
   Nothing here is outside the desktop media query, so the phone's cards are as they were. */
.cb-t, .hosted, .cs-name { display: none; }
@media (min-width: 900px) and (min-height: 501px) {
  /* the card's name on one line across its top (Q6): a card's own printed name is about 6px on a small card. It sits on the slot, outside the card, so a tapped card's stays level;
     what else sits at a card's top (the ATK / BLK badge, a narrow card's counters) starts under it (--nm-h) */
  .tui[data-layout="quad"] .cs { --nm-h: calc(max(9px, var(--cw) * .13) * 1.25 + 2px); }
  .tui[data-layout="quad"] .cs .cs-name { display: block; position: absolute; z-index: 3; left: 0; top: 0; width: var(--cw); box-sizing: border-box; padding: 1px 3px; border-radius: 3px 3px 0 0; background: rgba(8, 10, 14, .86); color: #f1f3f6; font-size: max(9px, calc(var(--cw) * .13)); font-weight: 650; line-height: 1.25; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
  .tui[data-layout="quad"] .cs.tapped .cs-name { width: 100%; top: calc(var(--cw) * .1975); border-radius: 3px; }
  .tui[data-layout="quad"] .cs .pt { font-size: max(12px, 20cqw); padding: 0 max(4px, 5cqw); border-width: 1.5px; border-radius: 6px; right: 3%; bottom: 3%; box-shadow: 0 1px 4px rgba(0, 0, 0, .7); }
  .tui[data-layout="quad"] .cs .ctrs { flex-direction: row; flex-wrap: wrap; max-width: 58%; left: 3%; bottom: 3%; }
  .tui[data-layout="quad"] .cs .cb { left: 3%; top: calc(3% + var(--nm-h)); gap: 3px; padding: 0 5px; border: 0; color: #fff; font-weight: 800; max-width: 94%; }
  .tui[data-layout="quad"] .cs .cb.atk { background: var(--tui-bad); }
  .tui[data-layout="quad"] .cs .cb.blk { background: var(--tui-accent); }
  .tui[data-layout="quad"] .cs .cb-t { display: inline; font-size: max(10px, 12cqw); letter-spacing: .03em; }
  .tui[data-layout="quad"] .cs .cb em { display: none; font-weight: 600; }
  @container (min-width: 84px) { .tui[data-layout="quad"] .cs .cb em { display: inline; } }
  .tui[data-layout="quad"] .cs .att { display: none; } /* the host shows its attachment now */
  /* the counters sit at the top right (under the name): at the bottom left they ran into the power/toughness plate on a small card, and on a bigger one with a wide plate such as 16/16 ("+1 3" and "3/4" read "+13/4") */
  .tui[data-layout="quad"] .cs:not(.tapped) .ctrs { left: auto; right: 3%; bottom: auto; top: calc(3% + var(--nm-h)); max-width: 50%; justify-content: flex-end; }
  .tui[data-layout="quad"] .cs .hosted { display: block; position: absolute; left: 3%; right: 3%; top: 50%; transform: translateY(-50%); z-index: 2; font-size: max(9px, 11cqw); text-align: center; background: rgba(10, 12, 15, .88); color: #d8d0f4; border: 1px solid #6b5aa8; border-radius: 5px; padding: 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
  /* a tapped card is dimmed (client.css); what sits on it is lifted back, so the plate and the counters stay as bright as an untapped card's */
  .tui[data-layout="quad"] .cs.tapped:not(.atk) :is(.pt, .ctrs, .cb, .hosted) { filter: brightness(1.47) saturate(1.4); }
  /* a tapped card: each overlay is centred where the visible corner is after the card turns, then turns back (-90deg) about its own centre */
  .tui[data-layout="quad"] .cs.tapped :is(.pt, .ctrs, .cb, .hosted) { right: auto; bottom: auto; transform: translate(-50%, -50%) rotate(-90deg); }
  .tui[data-layout="quad"] .cs.tapped .pt { left: calc(50% + var(--cw) * .33); top: calc(50% - var(--cw) * .3975); }
  .tui[data-layout="quad"] .cs.tapped .ctrs { left: calc(var(--cw) * .83); top: calc(100% - var(--cw) * .22); max-width: calc(var(--cw) * .9); }
  .tui[data-layout="quad"] .cs.tapped .cb { left: calc(var(--nm-h) + 10px); top: calc(100% - 4px); max-width: calc(var(--cw) * 1.395 - 8px); transform: translate(-50%, -50%) rotate(-90deg) translateX(50%); } /* anchored by its visible left edge (Q6): centred, a long BLK badge slid over the card to the left */
  .tui[data-layout="quad"] .cs.tapped .hosted { left: 50%; top: 50%; width: calc(var(--cw) * .9); max-width: none; right: auto; }
  /* a tapped card: its counters go to the visible top right, under the level name (local left is the visible top, local top the visible right): at the visible bottom left they met the plate */
  .tui[data-layout="quad"] .cs.tapped .ctrs { left: calc(var(--nm-h) + 10px); top: 24px; max-width: none; }
  /* a card under 60px wide is 84px tall at most: its name, badge and plate leave no room for the attachment's tab (it is still in the card's tooltip and the inspector) */
  @container (max-width: 59px) { .tui[data-layout="quad"] .cs .hosted { display: none; } }
}

/* [state] desktop Q9, the quadrant layout: who has priority, whose turn it is, the phase and the stack read from across the table. Chat gives up about a third of its height
   (it no longer follows new messages down, see syncChat in client.js) and the stack takes it: bigger faces and text, and it grows to fill the right column. */
@media (min-width: 900px) and (min-height: 501px) {
  .tui[data-table="mp"] .tui-side .tabs, .tui[data-table="mp"] .side .tabs { flex: 0 0 auto; height: max(150px, min(calc((100dvh - 410px) * .65), max(233px, 22dvh))); } /* (1440p: chat stays about 22% of the window; the stack gets the rest) */
  .tui[data-table="mp"] .stack { flex: 1 1 auto; max-height: none; min-height: 130px; padding: 10px; border-color: rgba(120, 160, 255, .45); }
  .tui[data-table="mp"] .stack.is-empty { flex: 0 0 auto; min-height: 0; }
  .tui[data-table="mp"] .stack .side-title { font-size: 13px; color: #cfe0ff; letter-spacing: .08em; }
  .tui[data-table="mp"] .st-face { width: clamp(64px, 8.4vh, 136px); } /* the stack's cards and words grow with the window's height (1366x768 as it was) */
  .tui[data-table="mp"] .st-text { font-size: clamp(15px, 1.4vh, 24px); }
  .tui[data-table="mp"] .bar .turn { font-size: 15px; }
  .tui[data-table="mp"] .bar .turn b { font-size: 26px; }
  .tui[data-table="mp"] .bar .ph { font-size: 14px; padding: 5px 11px; }
  .tui[data-table="mp"] .bar .ph.on { font-weight: 800; box-shadow: 0 0 0 2px #fff3, 0 2px 14px rgba(79, 140, 255, .7); }
  .tui[data-table="mp"] .bar .whose { font-size: 16px; padding: 3px 12px; border-radius: 999px; background: color-mix(in srgb, var(--seat, #4f8cff) 22%, transparent); border: 1px solid var(--seat, #4f8cff); }
  .tui[data-table="mp"] .bar .prio { font-size: 16px; padding: 4px 14px; border-width: 2px; }
  .tui[data-table="mp"] .bar .prio-l { font-size: 12px; }
  .tui[data-table="mp"] .bar .prio.me { background: color-mix(in srgb, var(--seat) 30%, #000); box-shadow: 0 0 12px var(--seat); }
}
