/* ENH-058 phone review revision.  A seat owns its header and its hand.  The
   viewer-relative top/bottom hands are rows; left/right hands are suit stacks.
   The four trick positions are separate, equally sized spaces in the centre. */
@media (max-width:560px), (max-height:560px) and (min-width:561px) and (max-width:1100px) {
  /* A rapid second confirmation tap is an activation, not browser double-tap zoom.
     Pinch zoom remains available; keyboard card activation is unchanged. */
  body.table-mode #app .hand-slot [data-card] { touch-action:manipulation; }
  body.table-mode #app .felt[data-fit-layout=play] {
    display:grid!important;
    grid-template-areas:"north north north" "west centre east" "south south south" "actions actions actions"!important;
    grid-template-columns:minmax(105px,27%) minmax(0,1fr) minmax(105px,27%)!important;
    grid-template-rows:100px minmax(0,1fr) 100px 44px!important;
    gap:4px!important;
    align-items:stretch;
    padding:4px!important;
    overflow:hidden;
  }
  body.table-mode #app .felt[data-fit-layout=play] .seat {
    position:relative!important;
    inset:auto!important;
    display:flex!important;
    width:100%!important;
    height:100%;
    min-width:0!important;
    max-width:none!important;
    min-height:0;
    flex-direction:column;
    align-items:stretch!important;
    align-self:stretch!important;
    justify-self:stretch!important;
    gap:0;
    margin:0!important;
    transform:none!important;
  }
  body.table-mode #app .felt[data-fit-layout=play] #seat-2 { grid-area:north!important; }
  body.table-mode #app .felt[data-fit-layout=play] #seat-1 { grid-area:west!important; }
  body.table-mode #app .felt[data-fit-layout=play] #seat-3 { grid-area:east!important; }
  body.table-mode #app .felt[data-fit-layout=play] #seat-0 { grid-area:south!important; }
  body.table-mode #app .felt[data-fit-layout=play] .plate-slot {
    position:static!important;
    display:block!important;
    width:100%!important;
    min-width:0;
    height:28px;
    flex:none;
  }
  body.table-mode #app .felt[data-fit-layout=play] .nameplate {
    width:100%;height:28px;min-height:28px;
    padding:1px 4px;font-size:11px;overflow:hidden;
  }
  body.table-mode #app .felt[data-fit-layout=play] .nameplate .pos { min-width:24px;font-size:17px; }
  body.table-mode #app .felt[data-fit-layout=play] .seat.turn-due { outline:0!important;animation:none!important; }
  body.table-mode #app .felt[data-fit-layout=play] .seat.turn-due :is(.nameplate,.hand-slot) {
    outline:2px solid #e5c34b;outline-offset:-2px;animation:gui-turn-reminder 5s ease-in-out infinite;
  }
  @media (prefers-reduced-motion:reduce) {
    body.table-mode #app .felt[data-fit-layout=play] .seat.turn-due :is(.nameplate,.hand-slot) { animation:none; }
  }
  body.table-mode #app .felt[data-fit-layout=play] #phone-felt-actions {
    grid-area:actions;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));
    gap:4px;min-width:0;min-height:0;padding:1px 0;
  }
  body.table-mode #app .felt[data-fit-layout=play] #phone-felt-actions[hidden] { display:none!important; }
  body.table-mode #app .felt[data-fit-layout=play] #phone-felt-actions button {
    min-width:0;min-height:40px;height:40px;padding:2px 4px;font-size:12px;
    color:var(--gui-ink);background:var(--gui-soft);border:1px solid var(--gui-line);border-radius:6px;
  }
  body.table-mode #app .felt[data-fit-layout=play] #phone-felt-actions button:disabled { opacity:.58; }
  body.table-mode #app.on #gui-play-actions { overflow:hidden; }
  body.table-mode #app.on #gui-play-actions button { flex:1 1 0;min-width:0; }
  body.table-mode #app.on #gui-play-actions button[hidden] { display:none!important; }
  body.table-mode #board-panel .contractline { grid-column:3!important;justify-self:start; }
  body.table-mode #board-panel .tricksummary { grid-column:4!important;justify-self:end; }
  body.table-mode #app.on #board-panel,
  body.table-mode #app.on:has(.felt[data-fit-layout]) #board-panel { grid-template-columns:auto auto minmax(0,1fr) auto; }
  body.table-mode #board-panel .phone-viewer-seat {
    grid-column:2;grid-row:1;align-self:end;justify-self:start;
    padding:1px 4px;color:#fff;font:800 12px/1.2 var(--gui-face),system-ui,sans-serif;
    white-space:nowrap;
  }
  body.table-mode #board-panel .panel-vulnerability { align-self:start;margin-bottom:14px; }
  body.table-mode #app .felt[data-fit-layout=bidding] #auction-panel:not(.collapsed) {
    min-height:min(212px,100%);max-height:calc(3 * 48px + 68px);
    overflow-y:auto;overscroll-behavior:contain;
  }
  body.table-mode #app .felt[data-fit-layout=bidding] #auction-panel .cap {
    position:sticky;top:0;z-index:3;min-height:32px;margin-bottom:0;background:#f7f4ec;
  }
  body.table-mode #app .felt[data-fit-layout=bidding] #auction-panel table.auction th {
    position:sticky;top:32px;z-index:2;background:#f7f4ec;
  }
  body.table-mode #app .felt[data-fit-layout=bidding] #auction-panel table.auction th.vulnerable {
    background:#a9221b;color:#fff;
  }
  body.table-mode #app .felt[data-fit-layout=bidding] #auction-panel table.auction,
  body.table-mode #app .felt[data-fit-layout=bidding] #auction-panel table.auction :is(th,td) {
    font-size:20px;
  }
  body.table-mode #app .felt[data-fit-layout=bidding] #auction-panel table.auction td {
    height:48px;padding:4px 3px;
  }
  body.table-mode #app .felt[data-fit-layout=bidding] #auction-panel .auctioncall {
    min-height:42px;
  }
  body.table-mode #app .felt[data-fit-layout=play] .hand-slot {
    position:static!important;
    display:none;
    width:100%!important;
    min-width:0!important;
    max-width:none!important;
    height:auto!important;
    min-height:0;
    overflow:visible!important;
    grid-area:auto!important;
    margin:0;
  }
  body.table-mode #app .felt[data-fit-layout=play] .fit-visible-hand .hand-slot { display:block; }
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .hand-slot {
    height:72px!important;
  }
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .diagramhand {
    display:flex!important;box-sizing:border-box;width:100%!important;min-width:0!important;
    height:72px!important;min-height:72px!important;
    align-items:center;justify-content:center;flex-direction:row!important;flex-wrap:wrap;
    gap:1px clamp(5px,1.5vw,8px);padding:2px 4px;overflow:hidden!important;
  }
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .diagramrow {
    display:flex!important;min-width:0;align-items:center;flex:0 1 auto;gap:1px;
  }
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .diagramrow>.slbl {
    display:block!important;width:auto;min-width:15px;flex:0 0 auto;font-size:18px;
  }
  :root[data-hand-display=diagram] body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .diagramrank {
    display:grid;min-width:20px;min-height:44px;place-items:center;flex:0 1 auto;
    padding:0 1px;color:#17222b!important;border:0;background:transparent;
    font:800 25px/1 var(--gui-face),system-ui,sans-serif;
  }
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .diagramrow:has(.slbl.red) .diagramrank { color:#a92e34!important; }
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .diagramrank::after { content:none!important; }
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .hand.horizontal {
    box-sizing:border-box;width:100%!important;min-width:0;
    height:72px!important;min-height:72px!important;overflow:hidden!important;
  }
  :root[data-hand-display=cards] body.table-mode #app .felt[data-fit-cards=cards]
    :is(#seat-0,#seat-2) .hand.horizontal .card.suit-start:not(:first-child) { margin-left:13px; }
  :root[data-hand-display] body.table-mode #app .felt[data-fit-layout=play][data-phase] :is(#seat-1,#seat-3) .hand-slot {
    max-height:calc(100% - 28px);
    height:auto!important;
  }
  :root[data-hand-display] body.table-mode #app .felt[data-fit-layout=play][data-phase] :is(#seat-1,#seat-3) .diagramhand {
    display:flex!important;
    box-sizing:border-box;
    width:100%!important;
    min-width:0!important;
    height:auto!important;
    min-height:0!important;
    max-height:none;
    flex-direction:column!important;
    gap:3px;
    padding:4px 2px!important;
    overflow:visible!important;
  }
  :root[data-hand-display] body.table-mode #app .felt[data-fit-layout=play][data-phase] :is(#seat-1,#seat-3) .diagramrow {
    display:flex!important;
    width:100%;min-width:0;
    min-height:32px;
    align-items:center;
    flex-wrap:wrap!important;
    gap:0 1px;
    overflow:visible!important;
  }
  :root[data-hand-display] body.table-mode #app .felt[data-fit-layout=play][data-phase] :is(#seat-1,#seat-3) .diagramrow>.slbl {
    display:block!important;
    width:17px;min-width:17px;
    flex:0 0 17px;
    font-size:17px;
  }
  :root[data-hand-display] body.table-mode #app .felt[data-fit-layout=play][data-phase] :is(#seat-1,#seat-3) .diagramrank {
    display:inline-grid!important;
    width:auto!important;min-width:22px!important;
    height:39px!important;min-height:39px!important;
    place-items:center;
    flex:0 0 auto!important;
    padding:0 1px!important;
    color:#17222b!important;
    border:0!important;
    background:transparent!important;
    font:800 25px/1 var(--gui-face),system-ui,sans-serif!important;
    overflow:visible!important;
  }
  :root[data-hand-display] body.table-mode #app .felt[data-fit-layout=play][data-phase] :is(#seat-1,#seat-3) .diagramrow:has(.slbl.red) .diagramrank { color:#a92e34!important; }
  :root[data-hand-display] body.table-mode #app .felt[data-fit-layout=play][data-phase] :is(#seat-1,#seat-3) .diagramrank::after { content:none!important; }
  :root[data-hand-display] body.table-mode #app .felt[data-fit-layout=play][data-phase] :is(#seat-1,#seat-3) .diagramvoid { display:block!important; }
  /* A declarer sees their own hand and exposed dummy in the same horizontal
     format. The dummy wraps within its compass column without losing a card. */
  :root[data-hand-display=diagram] body.table-mode #app .felt[data-fit-layout=play][data-phase=play][data-declarer-view=true]
    :is(#seat-1,#seat-3).fit-visible-hand .diagramhand {
    flex-direction:row!important;flex-wrap:wrap!important;align-content:start;
  }
  :root[data-hand-display=diagram] body.table-mode #app .felt[data-fit-layout=play][data-phase=play][data-declarer-view=true]
    :is(#seat-1,#seat-3).fit-visible-hand .diagramrow { display:contents!important; }
  :root[data-hand-display=cards] body.table-mode #app .felt[data-fit-layout=play][data-phase=play][data-declarer-view=true]
    :is(#seat-1,#seat-3).fit-visible-hand .hand.horizontal {
    display:flex;flex-wrap:wrap;width:100%;height:auto;min-height:0;gap:2px;overflow:visible;
  }
  :root[data-hand-display=cards] body.table-mode #app .felt[data-fit-layout=play][data-phase=play][data-declarer-view=true]
    :is(#seat-1,#seat-3).fit-visible-hand .hand.horizontal .card {
    flex:0 0 30px!important;width:30px!important;min-width:30px!important;
    height:40px!important;min-height:40px!important;
  }
  body.table-mode #app .felt[data-fit-layout=play] #mid {
    position:relative!important;
    inset:auto!important;
    display:grid;
    grid-area:centre!important;
    width:100%!important;
    height:100%!important;
    min-width:0;
    min-height:0!important;
    place-items:center;
    overflow:visible;
    transform:none!important;
  }
  body.table-mode #app .felt[data-fit-layout=play] .trickpad {
    position:relative;
    width:226px!important;
    max-width:100%;
    min-width:140px!important;
    height:min(100%,290px)!important;
    min-height:0!important;
    flex:none;
  }
  body.table-mode #app .felt[data-fit-layout=play] .trickpad .slot { position:absolute;transform:none!important; }
  body.table-mode #app .felt[data-fit-layout=play] .trickpad .slot.p2 { top:0;left:50%;right:auto;bottom:auto;transform:translateX(-50%)!important; }
  body.table-mode #app .felt[data-fit-layout=play] .trickpad .slot.p0 { bottom:0;left:50%;right:auto;top:auto;transform:translateX(-50%)!important; }
  body.table-mode #app .felt[data-fit-layout=play] .trickpad .slot.p1 { top:50%;left:0;right:auto;bottom:auto;transform:translateY(-50%)!important; }
  body.table-mode #app .felt[data-fit-layout=play] .trickpad .slot.p3 { top:50%;right:0;left:auto;bottom:auto;transform:translateY(-50%)!important; }
  body.table-mode #app .felt[data-fit-layout=play] .trickpad .card {
    display:grid;
    box-sizing:border-box;
    width:78px!important;
    height:94px!important;
    min-height:94px!important;
    place-items:center;
    padding:2px!important;
    border:1px solid #afbbb6!important;
    background:#fffdf8;
    --card-rank-size:29px;
    --card-suit-size:31px;
  }
  body.table-mode #app .felt[data-fit-layout=play] .trickpad .card .idx {
    position:static;display:flex;align-items:center;justify-content:center;
    flex-direction:column;gap:2px;transform:none;
  }
  body.table-mode #app .felt[data-fit-layout=play] .trickpad .card .idx :is(.is,.ir) { font-size:29px!important;line-height:1; }
  body.table-mode #app .felt[data-fit-layout=play] .trickpad .card .is { order:0; }
  body.table-mode #app .felt[data-fit-layout=play] .trickpad .card .ir { order:1; }
  body.table-mode #app .felt[data-fit-layout=play] #auction-panel.play-open,
  body.table-mode #app .felt[data-fit-layout=play] #auction-panel.auctionpanel.play-open.avoid-top {
    position:fixed;z-index:1000;top:50%;right:8px;left:8px;
    width:auto;max-height:70dvh;transform:translateY(-50%);overflow:auto;
  }
  /* Reference2's three working rows: seven levels, five strains, special calls. */
  body.table-mode #app .felt[data-fit-layout=bidding] .bidcontrols {
    display:grid;
    grid-template-columns:repeat(7,minmax(0,1fr));
    grid-template-rows:repeat(3,44px);
    gap:3px;
  }
  body.table-mode #app .felt[data-fit-layout=bidding] .bidprimary { display:contents; }
  body.table-mode #app .felt[data-fit-layout=bidding] .bidprimary .level {
    grid-row:1!important;min-width:0;width:auto;min-height:44px;
  }
  body.table-mode #app .felt[data-fit-layout=bidding] .bidprimary .level[data-level="1"] { grid-column:1!important; }
  body.table-mode #app .felt[data-fit-layout=bidding] .bidprimary .level[data-level="2"] { grid-column:2!important; }
  body.table-mode #app .felt[data-fit-layout=bidding] .bidprimary .level[data-level="3"] { grid-column:3!important; }
  body.table-mode #app .felt[data-fit-layout=bidding] .bidprimary .level[data-level="4"] { grid-column:4!important; }
  body.table-mode #app .felt[data-fit-layout=bidding] .bidprimary .level[data-level="5"] { grid-column:5!important; }
  body.table-mode #app .felt[data-fit-layout=bidding] .bidprimary .level[data-level="6"] { grid-column:6!important; }
  body.table-mode #app .felt[data-fit-layout=bidding] .bidprimary .level[data-level="7"] { grid-column:7!important; }
  body.table-mode #app .felt[data-fit-layout=bidding] .bidstrains {
    grid-column:1/8!important;grid-row:2!important;
    display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:3px;
    min-width:0;margin:0;padding:0;
  }
  body.table-mode #app .felt[data-fit-layout=bidding] .bidprimary :is(.dbl,.rdbl) { grid-column:1/4!important;grid-row:3!important;min-width:0; }
  body.table-mode #app .felt[data-fit-layout=bidding] .bidprimary .pass { grid-column:4/8!important;grid-row:3!important;min-width:0; }

  /* History and Kibitzing use the same positional hand rule. */
  body.history-replay-mode #history-screen .replaytable :is(.dealhand.w,.dealhand.e) .diagramhand {
    display:flex;flex-direction:column;width:100%;height:auto;min-height:0;
    gap:3px;padding:3px;overflow:visible;
  }
  body.history-replay-mode #history-screen .replaytable :is(.dealhand.w,.dealhand.e) .diagramrow {
    display:flex;min-height:22px;align-items:center;flex-wrap:wrap;overflow:visible;
  }
  body.history-replay-mode #history-screen .replaytable :is(.dealhand.w,.dealhand.e) .diagramrank {
    min-width:12px;min-height:21px;padding:0 1px;font-size:14px;
  }
  .kb-hand:is([data-position="w"],[data-position="e"]) .kb-suits {
    display:flex;flex-direction:column;gap:3px;padding:3px;overflow:visible;
  }
  .kb-hand:is([data-position="w"],[data-position="e"]) .kb-suit-row {
    display:flex;min-height:22px;align-items:center;gap:2px;
  }
  .kb-hand:is([data-position="w"],[data-position="e"]) .kb-suit-symbol { display:inline;flex:0 0 16px;font-size:17px; }
  .kb-hand:is([data-position="w"],[data-position="e"]) .kb-ranks { display:flex;min-width:0;flex-wrap:wrap;gap:0 2px;overflow:visible; }
  .kb-hand:is([data-position="w"],[data-position="e"]) .kb-rank { display:inline;min-width:0;min-height:0;font-size:14px; }
  .kb-hand:is([data-position="w"],[data-position="e"]) .kb-card-suit { display:none; }
  .kb-hand:is([data-position="w"],[data-position="e"]) .kb-card-rank { display:inline; }
  .kb-hand:is([data-position="w"],[data-position="e"]) .kb-rank::after { content:none; }
}

@media (max-width:560px) {
  body.table-mode #app .felt[data-fit-layout=play] { grid-template-columns:minmax(105px,27%) minmax(0,1fr) minmax(105px,27%)!important; }
  body.table-mode #app .felt[data-fit-layout=play]:has(#seat-1.fit-visible-hand):not(:has(#seat-3.fit-visible-hand)) {
    grid-template-columns:minmax(115px,32%) minmax(0,1fr) minmax(48px,12%)!important;
  }
  body.table-mode #app .felt[data-fit-layout=play]:has(#seat-3.fit-visible-hand):not(:has(#seat-1.fit-visible-hand)) {
    grid-template-columns:minmax(48px,12%) minmax(0,1fr) minmax(115px,32%)!important;
  }
  /* Keep the enlarged trick clear of a side dummy. The opposite declarer's
     empty felt below their label provides the extra width. */
  body.table-mode #app .felt[data-fit-layout=play]:has(#seat-1.fit-visible-hand):not(:has(#seat-3.fit-visible-hand)) .trickpad {
    left:24px;
  }
  body.table-mode #app .felt[data-fit-layout=play]:has(#seat-3.fit-visible-hand):not(:has(#seat-1.fit-visible-hand)) .trickpad {
    left:-24px;
  }
  body.table-mode #app .felt[data-fit-layout=play] .trickpad { min-height:210px!important; }
  .kb-felt {
    display:grid;
    grid-template-columns:minmax(105px,27%) minmax(0,1fr) minmax(105px,27%);
    grid-template-areas:"north north north" "west centre east" "south south south";
    grid-template-rows:78px minmax(240px,auto) 78px;
    gap:4px;min-height:0;padding:4px;overflow:hidden;
  }
  .kb-hand[data-position="n"] { grid-area:north; }
  .kb-hand[data-position="s"] { grid-area:south; }
  .kb-hand[data-position="w"] { grid-area:west;align-self:center;height:auto; }
  .kb-hand[data-position="e"] { grid-area:east;align-self:center;height:auto; }
  .kb-observed-auction,.kb-observed-trick { grid-area:centre;align-self:center;justify-self:center; }
  .kb-observed-auction { width:100%;max-height:80%; }
  .kb-observed-trick { width:min(100%,210px);height:240px;transform:none; }
  .kb-observed-trick .kb-played { width:50px;height:58px;font-size:18px; }
  .kb-observed-trick .kb-played[data-position="n"] { top:0;left:50%;transform:translateX(-50%); }
  .kb-observed-trick .kb-played[data-position="s"] { bottom:0;left:50%;transform:translateX(-50%); }
  .kb-observed-trick .kb-played[data-position="w"] { top:50%;left:0;transform:translateY(-50%); }
  .kb-observed-trick .kb-played[data-position="e"] { top:50%;right:0;transform:translateY(-50%); }
  body.history-replay-mode #history-screen .history-v2-workspace .replaytable {
    grid-template-columns:minmax(105px,27%) minmax(0,1fr) minmax(105px,27%);
    grid-template-rows:78px minmax(240px,1fr) auto 78px auto!important;
    grid-template-areas:"north north north" "west center east" "auction auction auction" "south south south" "status options actions";
  }
  body.history-replay-mode #history-screen .replaycenter { min-height:220px!important; }
}

@media (max-width:560px), (max-height:560px) and (min-width:561px) and (max-width:1100px) {
  /* Horizontal hand rules hide ordinary rank overlays. The explicit card
     confirmation face must remain visible and tappable above that hand. */
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-1,#seat-2,#seat-3) .diagramrank.action-candidate::after {
    content:attr(data-card-label)!important;
    width:max(48px,calc(var(--gui-rank) * 2.7));
  }
  /* Reserve the enlarged face's actual width in the horizontal hand. It
     must never cover another card's tap target. The one layout change is
     immediate, with no transform animation under a moving finger. */
  body.table-mode #app .felt[data-fit-layout=play] .diagramrank.action-candidate{
    flex:0 0 max(48px,calc(var(--gui-rank) * 2.7));
    width:max(48px,calc(var(--gui-rank) * 2.7));
    min-width:max(48px,calc(var(--gui-rank) * 2.7));
    transition:none
  }
  body.table-mode #app .felt[data-fit-layout=play] .fit-visible-hand:not(#seat-0) .diagramhand{
    justify-content:flex-start
  }
  body.table-mode #app .felt[data-fit-layout=play] .diagramrank.action-candidate~.diagramrank{
    transform:none;transition:none
  }
}

/* The optional phone Chat strip shortens the felt. Keep four enlarged trick
   cards separate without moving either visible hand or the action bar. */
@media (max-width:560px) {
  body.table-mode.chat-enabled:not(.phone-table-chat-hidden) #app .felt[data-fit-layout=play] .trickpad {
    min-width:234px!important;
  }
  body.table-mode.chat-enabled:not(.phone-table-chat-hidden) #app .felt[data-fit-layout=play]:has(#seat-1.fit-visible-hand):not(:has(#seat-3.fit-visible-hand)) .trickpad {
    left:25px;
  }
  body.table-mode.chat-enabled:not(.phone-table-chat-hidden) #app .felt[data-fit-layout=play]:has(#seat-3.fit-visible-hand):not(:has(#seat-1.fit-visible-hand)) .trickpad {
    left:-25px;
  }
  body.table-mode.chat-enabled:not(.phone-table-chat-hidden) #app .felt[data-fit-layout=play] {
    gap:2px!important;
    padding:2px!important;
  }
}

@media (max-width:400px) and (min-height:500px) {
  body.table-mode #app .felt[data-fit-layout=play] {
    grid-template-rows:128px minmax(0,1fr) 128px 44px!important;
  }
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .hand-slot,
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .diagramhand,
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .hand.horizontal {
    height:100px!important;min-height:100px!important;
  }
}

@media (max-height:560px) and (min-width:561px) and (max-width:1100px) {
  /* The short landscape rail becomes display:contents. Keep status feedback
     out of the grid so its expiry cannot change the felt height mid-trick. */
  body.table-mode #app.on>.rail>#table-notices {
    position:fixed;z-index:50;left:2px;right:auto;bottom:4px;top:auto;
    width:148px;max-height:min(40vh,120px);
  }
  body.table-mode #app .felt[data-fit-layout=play] {
    grid-template-columns:minmax(150px,23%) minmax(0,1fr) minmax(150px,23%)!important;
    grid-template-rows:56px minmax(0,1fr) 56px 40px!important;
  }
  body.table-mode #app .felt[data-fit-layout=play]:has(#seat-1.fit-visible-hand):not(:has(#seat-3.fit-visible-hand)) {
    grid-template-columns:minmax(220px,30%) minmax(0,1fr) minmax(80px,12%)!important;
  }
  body.table-mode #app .felt[data-fit-layout=play]:has(#seat-3.fit-visible-hand):not(:has(#seat-1.fit-visible-hand)) {
    grid-template-columns:minmax(80px,12%) minmax(0,1fr) minmax(220px,30%)!important;
  }
  /* The hidden north hand needs only its label when dummy is at a side seat.
     Give that saved height to the own horizontal hand, keeping full card faces
     on the felt without reducing the central trick or moving actions above it. */
  body.table-mode #app .felt[data-fit-layout=play][data-phase=play]:has(#seat-1.fit-visible-hand,#seat-3.fit-visible-hand) {
    grid-template-rows:45px minmax(0,1fr) 67px 40px!important;
  }
  body.table-mode #app .felt[data-fit-layout=play][data-phase=play]:has(#seat-1.fit-visible-hand,#seat-3.fit-visible-hand)
    #seat-0 :is(.hand-slot,.diagramhand,.hand.horizontal) { height:44px!important;min-height:44px!important; }
  :root[data-hand-display=diagram] body.table-mode #app .felt[data-fit-layout=play][data-phase=play]:has(#seat-1.fit-visible-hand,#seat-3.fit-visible-hand)
    #seat-0 .diagramhand { height:44px!important;min-height:44px!important; }
  :root[data-hand-display=diagram] body.table-mode #app .felt[data-fit-layout=play][data-phase=play]:has(#seat-1.fit-visible-hand,#seat-3.fit-visible-hand)
    #seat-0 .diagramrow { height:40px!important;min-height:40px!important; }
  :root[data-hand-display=cards] body.table-mode #app .felt[data-fit-layout=play][data-phase=play]:has(#seat-1.fit-visible-hand,#seat-3.fit-visible-hand)
    #seat-0 .hand.horizontal .card { height:40px!important;min-height:40px!important; }
  body.table-mode #app .felt[data-fit-layout=play] #phone-felt-actions button { min-height:36px;height:36px; }
  body.table-mode #app .felt[data-fit-layout=play] .plate-slot,
  body.table-mode #app .felt[data-fit-layout=play] .nameplate { height:23px;min-height:23px; }
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .hand-slot,
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .diagramhand,
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .hand.horizontal { height:33px!important;min-height:33px!important; }
  :root[data-hand-display=diagram] body.table-mode #app .felt[data-fit-layout=play]
    :is(#seat-0,#seat-2) .diagramhand { height:33px!important;min-height:33px!important; }
  :root[data-hand-display=diagram] body.table-mode #app .felt[data-fit-layout=play]
    :is(#seat-0,#seat-2) .diagramrow { height:29px!important;min-height:29px!important; }
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .diagramrank {
    height:29px!important;min-height:29px!important;
  }
  body.table-mode #app .felt[data-fit-layout=play] :is(#seat-0,#seat-2) .hand.horizontal .card {
    height:29px!important;min-height:29px!important;
  }
  body.table-mode #app .felt[data-fit-layout=play] .trickpad {
    width:260px!important;max-width:none!important;height:min(100%,200px)!important;
  }
  body.table-mode #app .felt[data-fit-layout=play] .trickpad .card { width:68px!important;height:78px!important;min-height:78px!important; }
  .kb-felt {
    display:grid;
    grid-template-columns:minmax(150px,23%) minmax(0,1fr) minmax(150px,23%);
    grid-template-areas:"north north north" "west centre east" "south south south";
    grid-template-rows:54px minmax(0,1fr) 54px;
    gap:3px;padding:3px;
  }
  .kb-hand[data-position="n"] { grid-area:north; }
  .kb-hand[data-position="s"] { grid-area:south; }
  .kb-hand[data-position="w"] { grid-area:west;align-self:center;height:auto; }
  .kb-hand[data-position="e"] { grid-area:east;align-self:center;height:auto; }
  .kb-observed-auction,.kb-observed-trick { grid-area:centre;align-self:center;justify-self:center; }
  .kb-observed-auction { width:100%;max-height:100%; }
  .kb-observed-trick { width:min(100%,250px);height:180px;transform:none; }
  .kb-observed-trick .kb-played { width:48px;height:50px;font-size:16px; }
  .kb-observed-trick .kb-played[data-position="n"] { top:0;left:50%;transform:translateX(-50%); }
  .kb-observed-trick .kb-played[data-position="s"] { bottom:0;left:50%;transform:translateX(-50%); }
  .kb-observed-trick .kb-played[data-position="w"] { top:50%;left:0;transform:translateY(-50%); }
  .kb-observed-trick .kb-played[data-position="e"] { top:50%;right:0;transform:translateY(-50%); }
  :root[data-hand-display=diagram] .kb-hand[data-position="n"] .kb-suits {
    display:flex;height:30px;min-height:30px;align-items:center;justify-content:center;
    gap:8px;padding:1px 4px;overflow:hidden;white-space:nowrap;
  }
  :root[data-hand-display=diagram] .kb-hand[data-position="n"] .kb-suit-row,
  :root[data-hand-display=diagram] .kb-hand[data-position="n"] .kb-ranks {
    display:flex;min-width:0;align-items:center;gap:2px;
  }
  :root[data-hand-display=diagram] .kb-hand[data-position="n"] .kb-suit-symbol { display:inline;font-size:16px; }
  :root[data-hand-display=diagram] .kb-hand[data-position="n"] .kb-rank {
    display:inline;min-width:0;min-height:0;padding:0;color:#17222b;
    border:0;background:transparent;font:800 15px/1 Inter,system-ui,sans-serif;
  }
  :root[data-hand-display=diagram] .kb-hand[data-position="n"] .kb-rank.red { color:#b51f37; }
  :root[data-hand-display=diagram] .kb-hand[data-position="n"] .kb-rank::after { content:none; }
  :root[data-hand-display=diagram] .kb-hand[data-position="n"] .kb-card-suit { display:none; }
  :root[data-hand-display=diagram] .kb-hand[data-position="n"] .kb-card-rank { display:inline; }
  :root[data-hand-display=cards] .kb-hand[data-position="n"] .kb-suits.kb-card-hand { height:30px;min-height:30px; }
  :root[data-hand-display=cards] .kb-hand[data-position="n"] .kb-suits.kb-card-hand .kb-rank { min-height:26px; }
  body.history-replay-mode #history-screen .history-v2-workspace .replaytable {
    grid-template-columns:190px minmax(180px,1fr) 190px 142px;
    grid-template-rows:54px minmax(0,1fr) 58px!important;
    grid-template-areas:"north north north actions" "west center east actions" "south south south actions";
  }
  body.history-replay-mode #history-screen .replaytable .dealhand.n { grid-area:north; }
  body.history-replay-mode #history-screen .replaytable .dealhand.w { grid-area:west; }
  body.history-replay-mode #history-screen .replaytable .dealhand.e { grid-area:east; }
  body.history-replay-mode #history-screen .replaytable .dealhand.s { grid-area:south; }
  :root[data-hand-display] body.history-replay-mode #history-screen .replaytable .dealhand.n .diagramhand {
    display:flex!important;height:29px!important;min-height:29px!important;
    align-items:center;justify-content:center;flex-direction:row!important;
    gap:8px;padding:1px 4px;overflow:hidden;
  }
  :root[data-hand-display] body.history-replay-mode #history-screen .replaytable .dealhand.n .diagramrow {
    display:flex!important;min-width:0;min-height:27px;align-items:center;gap:1px;
  }
  :root[data-hand-display] body.history-replay-mode #history-screen .replaytable .dealhand.n .diagramrow>.slbl {
    display:block!important;width:auto;min-width:15px;font-size:16px;
  }
  :root[data-hand-display] body.history-replay-mode #history-screen .replaytable .dealhand.n .diagramrank {
    display:grid;width:auto;min-width:12px;height:27px;min-height:27px;
    place-items:center;flex:0 1 auto;padding:0 1px;color:#17222b!important;
    border:0;background:transparent;font:800 15px/1 Inter,system-ui,sans-serif;
  }
  :root[data-hand-display] body.history-replay-mode #history-screen .replaytable .dealhand.n .diagramrow:has(.slbl.red) .diagramrank { color:#b51f37!important; }
  :root[data-hand-display] body.history-replay-mode #history-screen .replaytable .dealhand.n .diagramrank::after { content:none!important; }
  body.history-replay-mode #history-screen .replaytable .dealhand.n .hand.horizontal { height:29px;min-height:29px; }
  body.history-replay-mode #history-screen .replaycenter { min-height:160px!important; }
  body.history-replay-mode #history-screen .replay-auction-surface { grid-area:center;align-self:start; }
  body.history-replay-mode #history-screen .replay-dd-inline { position:absolute;left:195px;bottom:61px; }
}

/* A phone replay may be taller than the visible viewport.  The transport,
   speed and Double Dummy controls remain reachable by ordinary page scroll. */
@media (max-width:560px), (max-height:560px) and (min-width:561px) and (max-width:1100px) {
  body.history-replay-mode #history-screen.replaying {
    height:calc(100dvh - var(--history-top,var(--topbar-clearance,58px)));
    overflow-y:auto!important;overscroll-behavior-y:contain;
  }
  body.history-replay-mode #history-screen.replaying .lobby-inner,
  body.history-replay-mode #history-screen.replaying .historydetail,
  body.history-replay-mode #history-screen.replaying .historyworkspace,
  body.history-replay-mode #history-screen.replaying .history-v2-shell {
    height:auto!important;overflow:visible!important;
  }
  body.history-replay-mode #history-screen.replaying .history-v2-layout {
    overflow:visible!important;
  }
  .sheet.lasttricksheet .lasttrickgrid {
    grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;
  }
  .sheet.lasttricksheet .lasttrickplay { width:100%;padding:5px 2px; }
  .sheet.lasttricksheet .lasttrickplay .card {
    width:60px;height:88px;--card-rank-size:29px;--card-suit-size:31px;
  }
}

@media (max-width:560px), (max-height:560px) and (min-width:561px) and (max-width:1100px) {
  body.history-replay-mode #history-screen .replaycenter {
    position:relative!important;inset:auto!important;grid-area:center!important;
    width:100%!important;height:100%!important;
    align-self:stretch;justify-self:stretch;overflow:visible;
  }
  body.history-replay-mode #history-screen .replaycenter .card { width:48px;height:58px; }
  body.history-replay-mode #history-screen .replaycenter .n { top:4px; }
  body.history-replay-mode #history-screen .replaycenter .s { bottom:4px; }
  body.history-replay-mode #history-screen .replaycenter .w { left:4px; }
  body.history-replay-mode #history-screen .replaycenter .e { right:4px; }
}

/* The bid explanation counter is available to assistive technology without
   consuming a visual line.  Give the bidding hand the released vertical space. */
@media (max-width:560px), (max-height:560px) and (min-width:561px) and (max-width:1100px) {
  body.table-mode #app .felt[data-fit-layout=bidding] #bidbox {
    max-height:225px!important;overflow-y:auto;
  }
  body.table-mode #app .felt[data-fit-layout=bidding] #seat-0 .hand-slot,
  body.table-mode #app .felt[data-fit-layout=bidding] #seat-0 .diagramhand {
    height:72px!important;min-height:72px!important;
  }
  :root[data-hand-display=diagram] body.table-mode #app .felt[data-fit-layout=bidding] #seat-0 .diagramhand {
    display:flex!important;flex-wrap:wrap;align-content:center;justify-content:center;
    gap:2px 8px;overflow:hidden!important;
  }
  :root[data-hand-display=diagram] body.table-mode #app .felt[data-fit-layout=bidding] #seat-0 .diagramrow {
    display:flex!important;min-height:30px;height:30px;align-items:center;
  }
  :root[data-hand-display=diagram] body.table-mode #app .felt[data-fit-layout=bidding] #seat-0 .diagramrank {
    min-width:20px;height:30px;min-height:30px;
    font:800 23px/1 var(--gui-face),system-ui,sans-serif;
  }
  :root[data-hand-display=cards] body.table-mode #app .felt[data-fit-layout=bidding] #seat-0 .hand.horizontal {
    height:72px!important;min-height:72px!important;
  }
  :root[data-hand-display=cards] body.table-mode #app .felt[data-fit-layout=bidding] #seat-0 .hand.horizontal .card {
    height:64px;min-height:64px;
  }
  :root[data-hand-display=cards] body.table-mode #app .felt[data-fit-layout=bidding] #seat-0 .hand.horizontal .card .idx .is {
    font-size:clamp(18px,4.55vw,20px);
  }
  :root[data-hand-display=cards] body.table-mode #app .felt[data-fit-layout=bidding] #seat-0 .hand.horizontal .card .idx .ir {
    font-size:clamp(16px,4.1vw,18px);
  }
}
@media (max-width:560px) {
  body.table-mode #app .felt[data-fit-layout=bidding] #bidbox { margin-bottom:24px!important; }
  /* Before the first deal there are no hands to reserve space for. Keep the
     owner controls visible and let the waiting message use the full felt width. */
  body.table-mode #app .felt[data-fit-layout=waiting] {
    grid-template-columns:repeat(2,minmax(0,1fr));
    grid-template-rows:auto auto minmax(0,1fr) auto;
    grid-template-areas:"top top" "left right" "mid mid" "bottom bottom";
  }
  body.table-mode #app .felt[data-fit-layout=waiting] :is(#seat-1,#seat-3) {
    position:relative;inset:auto;transform:none;width:100%;max-width:100%;
    align-self:start;justify-self:stretch;
  }
  body.table-mode #app .felt[data-fit-layout=waiting] #mid {
    grid-area:mid;display:grid;place-items:center;width:100%;min-width:0;
  }
  body.table-mode #app .felt[data-fit-layout=waiting] #mid>.centerinfo {
    width:min(300px,92%);max-width:92%;padding:10px 12px;
  }
  body.table-mode #app .felt[data-fit-layout=waiting] #mid>.centerinfo .big {
    font-size:clamp(18px,5vw,24px);line-height:1.2;
  }
}
