/* Playing geometry is sized from the viewport, never from the current move.
   Keep this after the visual themes and mobile tile artwork. Larger reference
   panels overlay the table; the board, decision rail, and rack keep their slots. */
@media screen {
  .is-playing .game-workspace {
    --control-height: max(44px, 2.75rem);
    --decision-height: calc(2 * var(--control-height) + 42px);
    --rack-height: calc(var(--control-height) + 180px);
    --play-dock-size: calc(var(--decision-height) + var(--rack-height) + 20px + env(safe-area-inset-bottom, 0px));
  }
  .is-playing .table-column { overflow-anchor: none; scrollbar-gutter: stable; }
  .is-playing .board-stage {
    flex: 1 0 290px; min-height: 290px;
  }
  .is-playing .play-dock {
    flex: 0 0 var(--play-dock-size); height: var(--play-dock-size); max-height: none;
    display: grid; grid-template-rows: var(--decision-height) var(--rack-height);
    gap: 6px; padding-block: 6px max(4px, env(safe-area-inset-bottom)); overflow: visible;
  }
  .rack-action-anchor { position: absolute; }
  .decision-zone { position: relative; width: min(100%, 1120px); min-width: 0; min-height: 0; margin-inline: auto; }
  .is-playing .game-turn-controls, .is-playing .preplay-panel {
    width: 100%; height: 100%; min-height: 0; max-width: none; margin: 0;
  }
  .is-playing .game-turn-controls { display: grid; grid-template-rows: minmax(0,1fr) auto; padding: 4px 8px; gap: 4px; }
  .is-playing .game-turn-controls[hidden], .is-playing .preplay-panel[hidden] { display: none; }
  .is-playing .turn-action-summary { width: 100%; min-height: 0; height: auto; overflow: visible; gap: 8px; }
  .is-playing .turn-action-summary p { flex-wrap: wrap; min-width: 0; margin: 0; }
  .is-playing .turn-action-summary span[data-turn-prompt] { display: inline; overflow: visible; white-space: normal; text-overflow: clip; }
  .is-playing .turn-action-buttons { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: repeat(2, var(--control-height)); justify-content: stretch; justify-items: center; gap: 4px; width: 100%; }
  .turn-primary-actions { position: relative; --pending-tile-height: var(--turn-button-height,var(--control-height)); display: grid; grid-template-columns: minmax(0, 1fr) 5.5rem; gap: 6px; width: min(100%, 29rem); }
  .is-playing .turn-primary-actions > .game-button { width: 100%; min-width: 0; height: var(--control-height); margin: 0; padding: 4px 8px; font-size: .85rem; line-height: 1.2; }
  /* The pending tile sits inside the existing main-button footprint. The
     overlay cannot intercept taps, and never adds a grid cell or row. */
  .is-playing .turn-primary-actions .latest-discard { position: absolute; z-index: 1; inset: 50% auto auto 8px; transform: translateY(-50%); display: block; width: calc(var(--pending-tile-height) / 1.45); height: var(--pending-tile-height); min-width: 0; min-height: 0; max-width: none; margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none; pointer-events: none; }
  .is-playing .turn-primary-actions .latest-discard[hidden] { display: none; }
  .is-playing .turn-primary-actions .latest-discard .latest-discard-tile { display: block; width: 100%; height: 100%; flex-basis: auto; }
  .is-playing .turn-primary-actions .latest-discard > span:not(.mini-game-tile) { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .is-playing .turn-primary-actions:has(.latest-discard:not([hidden])) > [data-next-move] { padding-left: calc(var(--pending-tile-height) / 1.45 + 20px); }
  .is-playing .quick-coach-button { gap: .3em; }
  .is-playing .quick-coach-button > span { flex: none; width: 1.35em; height: 1.35em; line-height: 1; }
  .turn-aux-actions { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 4px; width: min(100%, 50rem); }
  .is-playing .turn-aux-actions > .game-button, .is-playing .turn-secondary-actions .game-button { width: 100%; height: var(--control-height); min-width: 0; padding: 3px 5px; font-size: .75rem; line-height: 1.2; }
  .is-playing .turn-secondary-actions { display: block; grid-column: 2; grid-row: 1; }
  .turn-aux-actions > [data-claim-discard] { grid-column: 1; grid-row: 1; }
  .turn-aux-actions > [data-table-joker] { grid-column: 3; grid-row: 1; }
  .turn-aux-actions > [data-open-blank-exchange] { grid-column: 4; grid-row: 1; }
  .turn-aux-actions > [data-undo-move] { grid-column: 5; grid-row: 1; }
  /* Hidden actions still reserve their cells, but cannot be focused or announced. */
  .is-playing .turn-primary-actions > [hidden], .is-playing .turn-aux-actions > button[hidden],
  .is-playing .turn-secondary-actions:has([hidden]) { display: block; visibility: hidden; pointer-events: none; }
  .is-playing .player-rack-panel { position: relative; width: min(100%,1120px); height: 100%; min-height: 0; display: grid; grid-template-rows: var(--control-height) 128px 44px; gap: 4px; align-content: start; }
  .is-playing .player-rack-panel:has(.full-player-rack:empty) { display: grid; }
  .is-playing .player-rack-heading { height: var(--control-height); min-height: 0; margin: 0; }
  .is-playing .player-rack-heading > div:first-child { min-width: 0; }
  .is-playing .player-rack-heading h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .is-playing .rack-heading-tools { flex-wrap: nowrap; min-width: 0; }
  .is-playing .rack-heading-tools select { width: 15rem; max-width: 100%; }
  .is-playing .rack-heading-tools :is(.rack-standard-button, .rack-sort-row)[hidden] { display: none; }
  .is-playing .player-hand-row { height: 128px; min-height: 0; margin: 0; align-items: start; justify-content: start; gap: 8px; }
  /* An inset frame leaves the full row available to the movement buttons.
     Their size must follow this reserved row, not the TV-wide button minimum. */
  .is-playing .rack-selection-controls { height: 44px; min-height: 0; margin: 0; padding: 0 6px; border: 0; box-shadow: inset 0 0 0 1px #acbdac; flex-wrap: nowrap; overflow: auto; }
  .is-playing .rack-selection-controls > strong { flex: 1; min-width: 0; }
  .is-playing .rack-selection-controls > button { flex: none; height: 100%; min-height: 0; padding-block: 0; }
  .is-playing .rack-selection-controls .rack-touch-hint { display: none; }
  .is-playing .joker-exchanges { position: absolute; z-index: 12; left: 0; right: 0; bottom: calc(100% + var(--decision-height) + 46px); max-height: min(260px, 40dvh); overflow: auto; margin: 0; box-shadow: 0 8px 24px #052a2355; }

  /* The call result and pond always occupy the same cells. Resolving a discard
     cannot widen the pond or scatter old tiles. */
  /* Perimeter walls and fixed inner seat bands keep public sets separate from
     the discard field. A seat's whole strip opens its full-size tile view. */
  .is-playing .mahjong-table {
    --opponent-row-height: 112px; --seat-column: clamp(104px,8vw,140px);
    --table-wall-size: max(12px,.75rem); --human-row-height: 44px;
    grid-template-columns: var(--table-wall-size) var(--seat-column) minmax(0,1fr) var(--seat-column) var(--table-wall-size);
    grid-template-rows: var(--table-wall-size) var(--opponent-row-height) minmax(0,1fr) var(--human-row-height) var(--table-wall-size);
    grid-template-areas: ". farwall farwall farwall ." "leftwall left opponent right rightwall" "leftwall left center right rightwall" "leftwall left human right rightwall" ". nearwall nearwall nearwall .";
    gap: 5px; padding: 6px;
  }
  .is-playing .mahjong-table::before { content: none; }
  .is-playing .game-wall { position: relative; inset: auto; transform: none; width: 100%; height: 100%; min-width: 0; min-height: 0; align-self: stretch; justify-self: stretch; }
  .is-playing .wall-north { grid-area: farwall; }
  .is-playing .wall-south { grid-area: nearwall; }
  .is-playing .wall-west { grid-area: leftwall; }
  .is-playing .wall-east { grid-area: rightwall; }
  .is-playing :is(.wall-north,.wall-south) .wall-stack { height: 100%; min-width: 0; }
  .is-playing :is(.wall-east,.wall-west) .wall-stack { width: 100%; min-height: 0; }
  .is-playing .table-center { display: grid; grid-template-columns: minmax(0,min(180px,30%)) minmax(0,1fr); grid-template-rows: minmax(0,1fr); align-items: start; justify-items: center; gap: 10px; }
  .is-playing .table-center .draw-source, .is-playing .table-center .discard-resolution { grid-column: 1; grid-row: 1; align-self: start; margin: 0; }
  .is-playing .table-center .draw-source { display: none; }
  .is-playing .table-center .table-discards { grid-column: 2; grid-row: 1; height: 100%; min-width: 0; display: block; overflow: auto; }
  .is-playing .discard-resolution { width: 100%; max-height: 100%; min-width: 0; overflow: auto; align-content: center; margin: 0; padding: 8px; }
  .discard-caption-compact { display: none; }
  .is-playing .discard-pond { grid-column: 1; grid-row: 2; min-height: 0; }
  .is-playing :is(.shared-discard-pile,.loose-discard-pile) > header { justify-content: flex-end; }
  .is-playing .mahjong-table .table-player { container-type: size; display: block; align-self: stretch; justify-self: stretch; width: 100%; height: 100%; min-width: 0; min-height: 0; max-width: none; max-height: none; padding: 0; overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .is-playing .player-table-strip { --seat-run: 100cqw; --seat-tile-width: min(20px,calc((var(--seat-run) - 58px) / 14)); display: grid; grid-template-rows: 24px 34px minmax(0,1fr); gap: 3px; align-content: start; justify-items: center; width: 100%; height: 100%; min-width: 44px; min-height: 44px; padding: 0 4px; border: 0; border-radius: 5px; background: transparent; color: #e1eadd; font: inherit; cursor: zoom-in; }
  .is-playing .player-table-strip:hover { background: #c3d9c40a; }
  .is-playing .player-table-strip:focus-visible { outline: 2px solid #fff2cb; outline-offset: -2px; }
  .is-playing .table-player .player-heading { grid-row: 1; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 24px; margin: 0; padding: 0; border-radius: 0; background: transparent; font-size: .75rem; font-weight: 600; letter-spacing: .02em; text-transform: none; }
  .is-playing .table-player .player-heading small { font-size: .6rem; color: #b9ccbe; }
  .is-playing .table-player .player-identity { display: inline-flex; align-items: baseline; gap: .2em; padding: 0; background: transparent; white-space: nowrap; }
  .is-playing .table-player.is-active .player-heading { box-shadow: none; }
  .is-playing .table-player.is-active .player-identity { color: #ffe6ad; box-shadow: inset 0 -1px #e5c783; }
  .is-playing .table-player .mini-player-rack { grid-row: 2; display: flex; flex-wrap: nowrap; justify-content: center; align-items: center; min-width: 0; width: 100%; height: 34px; padding: 0; overflow: hidden; }
  .is-playing .table-player .mini-player-rack .mini-game-tile { width: var(--seat-tile-width); height: calc(var(--seat-tile-width) * 1.45); flex-basis: var(--seat-tile-width); }
  .is-playing .table-player .mini-exposures { grid-column: 1; grid-row: 3; display: flex; flex-wrap: nowrap; align-items: start; justify-content: center; width: 100%; height: 100%; min-width: 0; min-height: 0; max-height: none; margin: 0; padding: 3px 4px 5px; border: 0; gap: 8px; overflow: hidden; }
  .is-playing .table-player .mini-exposure { flex: 0 1 auto; min-width: 0; border: 0; background: transparent; box-shadow: none; padding: 0; gap: 2px; }
  .is-playing .table-player .mini-exposure-label { color: #dbe9dc; font-size: .55rem; font-weight: 600; letter-spacing: .04em; }
  .is-playing .table-player .mini-exposure-tiles { flex-wrap: nowrap; gap: 1px; }
  .is-playing .table-player .mini-exposure .mini-game-tile { width: var(--seat-tile-width); height: calc(var(--seat-tile-width) * 1.45); flex-basis: var(--seat-tile-width); }
  .is-playing .table-player .mini-exposures[hidden], .is-playing .table-player.is-human :is(.mini-player-rack,.mini-exposures) { display: none; }
  .is-playing .table-player.is-human .player-table-strip { display: flex; align-items: center; justify-content: center; }
  /* Rotate the full strip together. Its outer row is the name; public tiles
     face the seated player and stay inside the wall as seats rotate. */
  .is-playing :is(.player-east,.player-west) .player-table-strip { --seat-run: 100cqh; position: absolute; left: 50%; top: 50%; width: 100cqh; height: 100cqw; transform: translate(-50%,-50%) rotate(var(--seat-label-angle)); grid-template-rows: minmax(0,1fr) 34px 24px; }
  .is-playing :is(.player-east,.player-west) .player-heading { grid-row: 3; }
  .is-playing :is(.player-east,.player-west) .mini-exposures { grid-row: 1; align-items: end; }
  .is-playing .player-west { --seat-label-angle: 90deg; }
  .is-playing .player-east { --seat-label-angle: -90deg; }
  .is-playing .wall-readout { height: 28px; min-height: 28px; overflow: hidden; }

  /* Deal actions share the fixed decision rail: keep dice beside their legend
     and Coach beside the main action instead of creating extra button rows. */
  .is-playing [data-deal-panel] { height: 100%; }
  .is-playing [data-deal-panel] .preplay-stage { height: 100%; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .is-playing [data-deal-panel] .preplay-copy .game-kicker { display: none; }
  .is-playing [data-deal-panel] .preplay-action { display: grid; grid-template-rows: minmax(min-content, 1fr) auto; gap: 4px; }
  .is-playing .deal-action-summary { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .is-playing [data-deal-panel] .deal-action-summary p { margin: 0; }
  .is-playing .deal-action-summary .wall-dice { flex: none; }
  .is-playing .deal-actions { grid-row: 2; display: flex; align-items: stretch; gap: 6px; }
  .is-playing .deal-actions > .game-button { min-width: 0; min-height: 44px; margin: 0; padding: 4px 8px; line-height: 1.2; }
  .is-playing .deal-actions > .game-button-primary { flex: 1; }
}

@media screen and (min-width: 701px) and (min-height: 501px), screen and (min-width: 1101px) {
  /* Phase context belongs in the existing toolbar, leaving the felt clear.
     Its four fixed labels occupy the same slot throughout the hand. */
  .is-playing .game-toolbar { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 12px; }
  .is-playing .game-toolbar h2 { max-width: 100%; }
  .is-playing .game-toolbar-actions { justify-self: end; }
  .is-playing .game-phase-track { position: static; transform: none; z-index: auto; align-self: center; justify-content: center; white-space: nowrap; gap: .6rem; }
  /* Give the explanation the space left by compact desktop buttons. The
     decision rail keeps its height, so changing turns cannot move the rack. */
  .is-playing .game-turn-controls { --turn-button-height: max(36px, 1.75rem); grid-template-rows: minmax(0, 1fr) auto; }
  .is-playing .turn-action-summary { height: auto; overflow: visible; gap: 8px; }
  .is-playing .turn-action-summary p { flex-wrap: wrap; gap: 2px 8px; }
  .is-playing .turn-action-summary strong { flex: 0 0 auto; max-width: 100%; line-height: 1.2; }
  .is-playing .turn-action-summary span[data-turn-prompt] { flex: 1 1 0; white-space: normal; overflow: visible; text-overflow: clip; font-size: .75rem; line-height: 1.25; }
  .is-playing .turn-action-buttons { grid-template-rows: repeat(2, var(--turn-button-height)); }
  .is-playing .turn-primary-actions > .game-button,
  .is-playing .turn-aux-actions > .game-button,
  .is-playing .turn-secondary-actions .game-button { height: var(--turn-button-height); min-height: var(--turn-button-height); }
  /* Intrinsic control widths must not enlarge the rack's shared grid column.
     Long tracked-line names and optional controls stay inside the same rail. */
  .is-playing .player-rack-panel { --rack-tile-width: min(64px, calc((100cqw - 114px) / 14)); grid-template-columns: minmax(0,1fr); }
  .is-playing .player-rack-heading, .is-playing .player-hand-row, .is-playing .rack-selection-controls { min-width: 0; width: 100%; }
  /* A wrapped status and the focus ring belong to the header's reserved row.
     Paint it above the rack so the wood cannot tint the bottom of the ring. */
  .is-playing .player-rack-heading { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; z-index: 1; }
  .is-playing .player-rack-heading > div:first-child { display: flex; align-items: center; gap: .55rem; }
  .is-playing .player-rack-heading > div:first-child > p { flex: none; }
  .is-playing .player-rack-heading h3 { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
  .is-playing .rack-heading-tools { max-width: none; }
  .is-playing .rack-sort-row { width: min(12rem,23cqw); min-width: 0; }
  .is-playing .rack-sort-row label, .is-playing .rack-heading-tools select { width: 100%; min-width: 0; }
  .is-playing .rack-heading-tools :is(select,button,summary) { height: var(--control-height); min-height: 0; }
  .is-playing .rack-heading-tools :is(select,button,summary):focus-visible { outline: 3px solid var(--coral); outline-offset: 1px; }
  .is-playing .rack-help-disclosure { color: var(--ink); }
  .is-playing .rack-help-disclosure summary { align-items: center; gap: .35rem; white-space: nowrap; }
  .is-playing .rack-help-disclosure summary::after { content: ""; width: .4em; height: .4em; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); }
  .is-playing .rack-help-disclosure[open] summary::after { transform: rotate(225deg); }
  .is-playing .rack-help-disclosure p { color: var(--ink); }
  .is-playing .rack-selection-controls { display: grid; grid-template-columns: minmax(0,1fr) max(110px,7rem) max(110px,7rem); grid-template-rows: minmax(0,1fr); }
  .is-playing .rack-selection-controls > strong { line-height: 1.25; }
  .is-playing .concealed-rack-zone { flex: none; width: calc(var(--rack-tile-width) * var(--rack-capacity,14) + (var(--rack-capacity,14) - 1) * 6px + 20px); }
  .is-playing .full-player-rack { display: grid; grid-template-columns: repeat(var(--rack-capacity,14), var(--rack-tile-width)); gap: 6px; width: 100%; max-width: none; height: 126px; min-height: 126px; margin: 0; padding: 16px 10px 9px; justify-content: start; align-content: start; overflow: visible; }
  .is-playing .full-player-rack .game-tile { width: var(--rack-tile-width); max-width: none; height: calc(var(--rack-tile-width) * 84 / 58); flex: none; }
  .is-playing .full-player-rack .game-tile.is-drawn { margin-left: 0; }
  .is-playing .user-exposures { flex: 0 1 auto; width: max-content; max-width: none; height: auto; max-height: 126px; min-height: 0; overflow: auto; align-self: start; align-content: start; }
  .is-playing .user-exposure-heading { flex-wrap: nowrap; white-space: nowrap; }
  .is-playing .user-exposure-sets { flex-wrap: nowrap; justify-content: start; }
  .is-playing .user-exposure-sets > .mini-exposure { flex: 0 0 auto; }
  .is-playing .user-exposures .mini-exposure-tiles { flex-wrap: nowrap; }
  .is-playing .call-decision { bottom: calc(var(--dock-height) - var(--decision-height) + 8px); }
  .is-playing .preplay-panel { overflow: auto; }
  .is-playing .preplay-stage { height: 100%; }
  .is-playing .preplay-copy, .is-playing .preplay-action { padding: 6px 10px; }
  .is-playing .preplay-action { position: relative; align-content: start; }
  .is-playing .preplay-copy h3 { margin: 0 0 3px; }
  .is-playing .preplay-copy p, .is-playing .preplay-action p { margin: 0 0 4px; }
}

@media screen and (max-width: 1100px) {
  .is-playing .game-toolbar { grid-template-columns: auto minmax(0,1fr); }
  .is-playing .game-toolbar > div:first-child { display: none; }
  .is-playing .latest-discard { flex-direction: column; padding: 6px; gap: 4px; }
  .is-playing .latest-discard strong { font-size: .85rem; }
  .is-playing .discard-caption-full { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .is-playing .discard-caption-compact { display: inline; }
  .is-playing .discard-resolution { font-size: .65rem; line-height: 1.2; }
  .is-playing .discard-resolution > span { display: none; }
}

@media screen and (max-width: 700px), screen and (max-width: 1100px) and (max-height: 500px) {
  .is-playing .game-phase-track { display: none; }
  .is-playing .game-workspace { --control-height: 44px; --decision-height: 148px; --rack-height: 202px; --play-dock-size: calc(var(--decision-height) + var(--rack-height) + 20px + env(safe-area-inset-bottom,0px)); }
  .is-playing .table-column { scrollbar-gutter: auto; }
  /* Let the board use the height left by the fixed controls and rack. A 370px
     minimum forced short phones to scroll the table whenever focus moved to an
     action. Keep a readable floor for unusually short or enlarged-rack views. */
  .is-playing .board-stage { min-height: 260px; flex-basis: 260px; }
  .is-playing .mahjong-table { --opponent-row-height: 44px; --human-row-height: 44px; --seat-column: 52px; --table-wall-size: 8px; gap: 3px; padding: 3px; }
  /* Share the existing count-header row with call results, reclaiming the old
     status column without moving discards when a result appears or clears. */
  .is-playing .table-center { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(0,1fr); gap: 0; }
  .is-playing .table-center .table-discards { grid-column: 1; }
  .is-playing .table-center .discard-resolution { position: absolute; inset: 0 auto auto 0; width: calc(100% - 64px); height: 14px; padding: 0 4px; border: 0; background: transparent; justify-content: start; text-align: left; }
  .is-playing .table-center .discard-resolution > strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .is-playing :is(.shared-discard-pile,.loose-discard-pile) > header { height: 14px; margin: 0; padding: 0; align-items: center; }
  .is-playing .table-center:has(.is-by-player) .table-discards { padding-top: 14px; }
  .is-playing .table-center:has(.is-by-player) .discard-resolution { width: 100%; }
  /* Fit two complete 44px inspection rows on short phones. Inset outlines
     keep the tighter spacing from clipping focus or the most recent tile. */
  .is-playing .shared-discard-pile > div { row-gap: 2px; padding-block: 1px; scroll-padding-top: 1px; }
  .is-playing .shared-discard-pile .discard-stack { outline-offset: -2px; }
  .is-playing .discard-scroll-hint { display: none; }
  .is-playing .latest-discard { padding: 3px; gap: 4px; }
  .is-playing .latest-discard strong { font-size: .7rem; }
  .is-playing .latest-discard small { display: none; }
  /* Smaller faces leave the phone table calmer. Keep the inspection targets
     and loose-tile landing slots intact; grouped rows use measured heights. */
  .is-playing .discard-pile .mini-game-tile { width: calc(var(--discard-tile-width) * .8); height: calc(var(--discard-tile-width) * 1.16); flex-basis: calc(var(--discard-tile-width) * .8); }
  .is-playing .discard-stack { min-height: 44px; }
  .is-playing .discard-stack > b { min-width: 20px; padding: 2px 3px; font-size: 11px; }
  .is-playing .player-table-strip { --seat-tile-width: min(13px,calc((var(--seat-run) - 58px) / 14)); grid-template-rows: 18px minmax(0,1fr); gap: 0; padding: 0 2px; }
  .is-playing .table-player .player-heading { height: 18px; font-size: .625rem; }
  .is-playing .table-player .player-heading small, .is-playing .table-player .compact-player-status, .is-playing .table-player .mini-player-rack { display: none; }
  .is-playing .table-player .mini-exposures { grid-row: 2; padding: 3px 2px 4px; gap: 6px; align-items: start; }
  .is-playing .table-player .mini-exposure-label { display: none; }
  .is-playing .table-player.is-dead .compact-player-status { display: inline; margin-left: 5px; font-size: .6rem; }
  .is-playing .table-player .tile-corner { font-size: 8px; top: 1px; left: 1px; }
  .is-playing :is(.player-east,.player-west) .player-table-strip { grid-template-rows: minmax(0,1fr) 18px; }
  .is-playing :is(.player-east,.player-west) .player-heading { grid-row: 2; }
  .is-playing :is(.player-east,.player-west) .mini-exposures { grid-row: 1; align-items: end; }
  /* The compact rack hides its exposure dock. Keep your public tiles inside
     the near wall, with the same inspection target as the other seats. */
  .is-playing .table-player.is-human .player-table-strip { display: grid; grid-template-rows: minmax(0,1fr) 18px; }
  .is-playing .table-player.is-human .player-heading { grid-row: 2; }
  .is-playing .table-player.is-human .mini-exposures:not([hidden]) { display: flex; grid-row: 1; align-items: end; }
  .is-playing .game-workspace:has([data-preplay-panel]:not([hidden])) .table-player.is-human { display: block; }
  .is-playing .wall-readout { height: 50px; min-height: 50px; }
  .is-playing .joker-exchanges { bottom: calc(100% + var(--decision-height) + 68px); }
  .is-playing .game-turn-controls { padding: 3px; gap: 3px; }
  .is-playing .turn-primary-actions { width: 100%; grid-template-columns: minmax(0,1fr) 76px; gap: 4px; }
  .is-playing .turn-primary-actions > .game-button { font-size: .75rem; }
  .is-playing .turn-aux-actions { gap: 3px; }
  .is-playing .turn-aux-actions > .game-button, .is-playing .turn-secondary-actions .game-button { padding: 2px; font-size: .8rem; line-height: 1.1; }
  .is-playing .rack-heading-tools .game-button, .is-playing .rack-heading-tools select { font-size: .8rem; }
  /* Guided calls open one claim menu. Use the adjacent empty action cell to
     fit the tile name; Table Play still shows its separate Mahjong button. */
  .is-playing .is-call-action .turn-aux-actions > [data-claim-discard] { grid-column: 1 / span 2; }
  .is-playing .player-rack-panel { display: grid; grid-template-rows: 64px 134px; gap: 3px; }
  .is-playing .player-rack-heading { height: 64px; gap: 2px; }
  .is-playing .rack-heading-tools { height: 44px; }
  .is-playing .rack-heading-tools select { width: 100%; }
  .is-playing .player-hand-row { height: 134px; }
  .is-playing .concealed-rack-zone { flex: none; width: 100%; }
  .is-playing .full-player-rack { height: 133px; min-height: 133px; grid-auto-rows: 51px; align-content: start; }
  .is-playing .preplay-panel { padding: 0; overflow: auto; }
  .is-playing .preplay-stage { position: relative; display: block; }
  .is-playing .preplay-copy { padding: 3px 6px; }
  .is-playing .preplay-copy p { font-size: .8rem; }
  .is-playing .preplay-action { padding: 3px 6px; }
  .is-playing [data-deal-panel] .preplay-stage { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 50px minmax(min-content, 1fr); gap: 0; }
  .is-playing [data-deal-panel] .preplay-copy > div { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .is-playing [data-deal-panel] .preplay-copy h3 { flex: 1; margin: 0; }
  .is-playing [data-deal-panel] .preplay-instructions:not([open]) { flex: 0 0 92px; }
  .is-playing [data-deal-panel] .preplay-instructions > summary { min-height: 44px; line-height: 1.2; }
  .is-playing .deal-action-summary p { font-size: .7rem; line-height: 1.25; }
  .is-playing .deal-actions > .game-button { font-size: .75rem; }
  .is-playing .turn-action-summary p { display: block; font-size: .75rem; line-height: 1.25; }
  .is-playing .turn-action-summary strong { display: inline; margin-right: .4em; font-size: .75rem; line-height: inherit; }
  .is-playing .turn-action-summary span[data-turn-prompt] { display: inline; font-size: inherit; line-height: inherit; }
  .is-playing .game-workspace.rack-enlarged { --rack-height: 400px; --play-dock-size: calc(var(--decision-height) + var(--rack-height) + 20px); }
  .is-playing .game-workspace.rack-enlarged .player-rack-panel { grid-template-rows: 64px 286px 44px; }
  .is-playing .game-workspace.rack-enlarged .full-player-rack { height: 285px; grid-auto-rows: 79px; }
  .is-playing .game-workspace.rack-enlarged .player-hand-row { height: 286px; overflow: auto; }
  .is-playing .game-workspace.rack-enlarged .rack-selection-controls { display: flex; height: 44px; }
}
@media screen and (max-width: 700px) {
  /* Clear the top wall and the side player's exposed tiles. */
  .is-playing .table-compass { top: 16px; left: calc(var(--table-wall-size) + var(--seat-column)); }
}
@media screen and (max-width: 359px) {
  /* Seven 44px tiles fit a 320px viewport once the narrow rack uses smaller
     gutters. Reserve the same two rows for 13 or 14 tiles. */
  .is-playing .game-workspace:not(.rack-enlarged) .play-dock { padding-inline: 2px; }
  .is-playing .game-workspace:not(.rack-enlarged) .full-player-rack { column-gap: 1px; padding-inline: 1px; }
  .is-playing .game-workspace:not(.rack-enlarged) .full-player-rack .game-tile { outline-offset: -2px; }
}
@media screen and (min-width: 701px) and (max-width: 1100px) and (max-height: 500px) {
  .is-playing .board-stage { min-height: 0; }
  .is-playing .play-dock { height: 100%; min-height: 0; overflow-y: auto; }
}


/* Charleston uses the same two rows throughout each exchange. On a phone the
   selected tiles get a third row; the dock itself never grows with a message. */
@media screen {
  .is-playing [data-charleston-panel] { height: 100%; }
  .is-playing .charleston-workspace {
    display: grid; height: 100%; min-height: 0; box-sizing: border-box;
    grid-template-columns: minmax(0,1fr) minmax(310px,.8fr);
    grid-template-rows: minmax(0,1fr) 44px; gap: 4px 10px; padding: 6px 10px;
    background: #fffdf7;
  }
  .is-playing .charleston-main { display: contents; }
  .is-playing .charleston-heading { grid-column: 1 / -1; grid-row: 1; margin: 0; padding: 0; gap: 8px; align-items: center; }
  .is-playing .charleston-heading > div:first-child { min-width: 0; }
  .is-playing .charleston-heading h3 { margin: 0; font: 700 1rem/1.2 var(--sans); }
  .is-playing .charleston-heading .game-kicker, .is-playing .charleston-help { display: none; }
  .is-playing .charleston-heading > div > p.charleston-instruction { display: block; margin: 2px 0 0; font: .75rem/1.25 var(--sans); }
  .is-playing .pass-direction { padding: 3px 6px; min-width: 0; }
  .is-playing .pass-direction strong { font: 700 .75rem/1.2 var(--sans); }
  .is-playing .charleston-side { grid-column: 2; grid-row: 2; display: flex; align-items: stretch; flex-wrap: nowrap; gap: 6px; padding: 0; background: transparent; }
  /* This rail stays 44px even on TVs; labels must not inherit unbounded rem
     scaling and spill below their buttons during courtesy negotiation. */
  .is-playing .charleston-side > button { min-height: 44px; height: 44px; min-width: 0; margin: 0; padding: 3px 7px; font: 700 clamp(12px,.75rem,14px)/1.2 var(--sans); white-space: normal; overflow-wrap: break-word; }
  .is-playing .charleston-side > .game-button-primary { flex: 1; }
  /* These controls must grow with the TV font scale, including the native
     select arrow and Coach icon, while keeping the action row's height fixed. */
  .is-playing .charleston-side > .quick-coach-button { flex: 0 0 max(76px, 5.25rem); }
  .is-playing .charleston-side > label { position: relative; flex: 0 0 max(88px, 6rem); min-width: 0; display: block; margin: 0; padding: 0; font-size: 0; }
  .is-playing .charleston-side > label::before { content: 'Your offer'; position: absolute; left: 7px; top: 3px; pointer-events: none; font: 600 10px/1.2 var(--sans); }
  .is-playing .charleston-side select { width: 100%; min-width: 0; height: 44px; min-height: 44px; padding: 14px 24px 2px 7px; font: 700 .8rem/1.2 var(--sans); }
  .is-playing .pass-zone { grid-column: 1; grid-row: 2; height: 44px; min-height: 44px; box-sizing: border-box; margin: 0; padding: 2px 5px; gap: 5px; }
  .is-playing .pass-placeholder { font: .75rem/1.2 var(--sans); }
  .is-playing .pass-zone .mini-game-tile, .is-playing .pass-zone .mini-tile-back { width: 24px; height: 34px; flex-basis: 24px; }
  .is-playing .courtesy-table-details { position: relative; grid-column: 1; grid-row: 2; justify-self: end; align-self: center; z-index: 10; width: max(118px, 8rem); margin: 0; padding: 0; background: #eef3e9; }
  .is-playing .courtesy-table-details > summary { display: flex; align-items: center; justify-content: center; gap: .35em; min-height: 44px; padding: 2px 4px; cursor: pointer; font: 700 .75rem/1.2 var(--sans); list-style: none; }
  .is-playing .courtesy-table-details > summary::-webkit-details-marker { display: none; }
  .is-playing .table-replies-close-label, .is-playing .courtesy-table-details[open] .table-replies-open-label { display: none; }
  .is-playing .courtesy-table-details[open] .table-replies-close-label { display: inline-flex; align-items: center; min-height: 36px; padding: 4px 10px; border: 1px solid #365b47; border-radius: 4px; background: #fffdf7; color: #234e3d; font-size: .8rem; white-space: nowrap; }
  .is-playing .charleston-workspace:has(.courtesy-table-details) .pass-zone { margin-right: calc(max(118px, 8rem) + 6px); }
  .is-playing .charleston-boundary { height: 100%; grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .is-playing .charleston-boundary .game-kicker { display: none; }
  .is-playing .charleston-boundary .preplay-action { align-content: center; }
  .is-playing .charleston-boundary .deal-actions { grid-row: auto; }
}
@media screen and (max-width: 700px), screen and (max-width: 1100px) and (max-height: 500px) {
  .is-playing .charleston-workspace { grid-template-columns: minmax(0,1fr); grid-template-rows: 52px 44px 44px; gap: 2px; padding: 2px; }
  .is-playing .charleston-heading { grid-row: 1; grid-column: 1; display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-rows: auto minmax(0,1fr); gap: 0 6px; align-items: start; }
  .is-playing .charleston-heading > div:first-child { display: contents; }
  .is-playing .charleston-heading h3 { grid-column: 1; grid-row: 1; }
  .is-playing .charleston-heading > div > p.charleston-instruction { grid-column: 1 / -1; grid-row: 2; }
  .is-playing .charleston-heading .pass-direction { grid-column: 2; grid-row: 1; }
  .is-playing .charleston-heading h3 { font-size: .8rem; }
  .is-playing .charleston-heading > div > p.charleston-instruction { font-size: .7rem; line-height: 1.25; }
  .is-playing .pass-direction { padding: 2px; flex: 0 0 auto; border: 0; background: transparent; }
  .is-playing .pass-direction span { display: none; }
  .is-playing .pass-direction strong { font-size: .65rem; }
  .is-playing .charleston-side { grid-column: 1; grid-row: 2; gap: 4px; }
  .is-playing .charleston-side > button { font-size: .75rem; }
  .is-playing .pass-zone { grid-column: 1; grid-row: 3; min-height: 44px; height: 44px; padding: 0 3px; }
  .is-playing .pass-placeholder { font-size: .7rem; }
  .is-playing .pass-zone .mini-game-tile, .is-playing .pass-zone .mini-tile-back { height: 30px; width: 22px; flex-basis: 22px; }
  .is-playing .courtesy-table-details { grid-row: 3; }
  .is-playing .charleston-boundary { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(0,1fr) 50px; }
  .is-playing .charleston-boundary .preplay-copy h3 { font-size: .85rem; }
  .is-playing .charleston-boundary .preplay-copy p { font-size: .75rem; }
  .is-playing .charleston-boundary .preplay-action { display: block; }
  .is-playing .charleston-boundary .deal-actions { height: 44px; }
  .is-playing .charleston-boundary .deal-actions > button { flex: 1; }
}

/* These are decisions, not changes to the playing surface. The blind-pass
   chooser opens automatically once, then remains available through its summary. */
@media screen {
  .is-playing .charleston-main { position: relative; }
  .is-playing .charleston-workspace { position: relative; }
  .is-playing .blind-choice { position: relative; grid-column: 1; grid-row: 2; justify-self: end; align-self: center; z-index: 10; width: max(120px, 8rem); margin: 0; padding: 0; }
  .is-playing .blind-choice > summary { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 4px 6px; color: #234e3d; font: 700 .75rem/1.3 var(--sans); cursor: pointer; list-style: none; }
  .is-playing .blind-choice > summary::after { content: " +"; margin-left: 5px; }
  .is-playing .blind-choice[open] > summary::after { content: " −"; }
  .is-playing .blind-choice[open], .is-playing .second-charleston-choice, .is-playing .courtesy-table-details[open] {
    position: fixed; z-index: 18; left: 50%; right: auto; bottom: min(calc(var(--dock-height) - var(--decision-height) + 8px), 40dvh);
    transform: translateX(-50%); width: min(680px, calc(100vw - 20px)); max-height: calc(100dvh - min(calc(var(--dock-height) - var(--decision-height) + 8px), 40dvh) - 12px);
    margin: 0; padding: 14px; overflow: auto; border: 2px solid #8aa99a; border-radius: 10px; background: #eef3e9; box-shadow: 0 8px 32px #052a2366;
  }
  .is-playing .blind-choice[open] > summary { justify-content: space-between; font-size: 1rem; }
  .is-playing .courtesy-table-details[open] > summary { position: sticky; top: -14px; z-index: 1; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #b1c3b5; background: #eef3e9; font-size: .9rem; }
  .is-playing .blind-buttons { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
  .is-playing .blind-buttons button { min-height: 44px; font-size: .8rem; }
  .is-playing .blind-buttons .quick-coach-button { grid-column: 1/-1; }
  .is-playing .second-charleston-choice { display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
  .is-playing .second-charleston-choice > :not(.table-vote-details) { flex: none; }
  .is-playing .second-charleston-choice > .game-kicker { display: none; }
  .is-playing .second-charleston-choice > h3, .is-playing .second-charleston-choice > p { margin: 0; }
  .is-playing .second-charleston-choice .table-vote-details { min-height: 44px; overflow: auto; }
  .is-playing .second-charleston-actions { margin: 0; }

  .is-playing .charleston-main:has(.blind-choice) .pass-zone { margin-right: max(124px, calc(8rem + 4px)); }
}

@media screen {
  .is-playing .preplay-instructions > summary { min-height: 36px; display: flex; align-items: center; color: #365b47; font-size: .75rem; cursor: pointer; text-decoration: underline; }
  /* The dock can be taller than the visible table on a short phone or with
     enlarged tiles. The temporary instructions still need a usable pane. */
  .is-playing .preplay-instructions[open] { --instruction-inset: min(calc(var(--dock-height) + 8px), 55dvh); position: fixed; z-index: 18; left: 50%; bottom: var(--instruction-inset); transform: translateX(-50%); width: min(560px,calc(100vw - 20px)); max-height: calc(100dvh - var(--instruction-inset) - 62px); overflow: auto; padding: 12px; border: 1px solid #8aa99a; border-radius: 8px; background: #eef3e9; box-shadow: 0 8px 24px #052a2355; }
  .is-playing .preplay-instructions[open] > summary { position: sticky; top: -12px; background: #eef3e9; text-decoration: none; }
  .is-playing .preplay-instructions[open] > summary::after { content: " −"; margin-left: auto; }
}
/* Short desktop windows use smaller tiles, chosen once for that viewport.
   They still reserve the same slots before and after a draw or selection. */
@media screen and (min-width: 701px) and (max-height: 800px) and (min-height: 501px) {
  .is-playing .game-workspace { --control-height: 44px; --decision-height: 114px; --rack-height: 176px; }
  .is-playing .board-stage { min-height: 350px; flex-basis: 350px; }
  .is-playing .game-turn-controls { gap: 2px; padding: 2px 8px; }
  .is-playing .player-rack-panel { --rack-tile-width: min(48px,calc((100cqw - 114px) / 14)); grid-template-rows: 36px 100px 32px; }
  .is-playing .player-rack-heading { height: 36px; }
  .is-playing .rack-heading-tools :is(select,button,summary) { min-height: 36px; height: 36px; }
  .is-playing .player-hand-row, .is-playing .full-player-rack { height: 100px; min-height: 100px; }
  .is-playing .user-exposures { max-height: 100px; }
  .is-playing .rack-selection-controls { height: 32px; }
  .is-playing .mahjong-table { --opponent-row-height: 96px; --seat-column: 104px; }
  .is-playing .player-table-strip { --seat-tile-width: min(16px,calc((var(--seat-run) - 58px) / 14)); grid-template-rows: 20px 24px minmax(0,1fr); gap: 2px; }
  .is-playing .table-player .player-heading { height: 20px; }
  .is-playing .table-player .mini-player-rack { height: 24px; }
  .is-playing :is(.player-east,.player-west) .player-table-strip { grid-template-rows: minmax(0,1fr) 24px 20px; }
  .is-playing .discard-pile header { padding: 2px; margin-bottom: 0; }
  .is-playing .discard-scroll-hint { margin: 0; font-size: 10px; line-height: 1.2; }
  .is-playing .discard-resolution { font-size: .7rem; line-height: 1.3; }
  .is-playing .user-exposures .mini-exposure .mini-game-tile { width: 32px; height: 46px; flex-basis: 32px; }
  .is-playing .user-exposures .mini-exposure-label { font-size: 9px; }
  .is-playing .user-exposures { padding: 4px 6px; gap: 3px; }
}


@media screen and (max-width: 700px), screen and (max-width: 1100px) and (max-height: 500px) {
  .is-playing .blind-choice:not([open]) { grid-row: 3; }
}

/* The accessible view reserves its larger rows up front. It can scroll on
   short screens without changing the default compact table. */
@media screen {
  .is-playing .rack-view-button[hidden], [data-large-table]:not([aria-pressed="true"]) > span { display: none; }
  .is-playing .game-workspace.large-table { --control-height: 54px; --decision-height: 180px; --rack-height: 242px; }
  .large-table :is(.turn-action-summary p, .preplay-action p, .preplay-copy p, .game-card-note, .game-card-key, .card-line-note, .coaching-card-line p) { font-size: 1rem; }
  .is-playing .large-table :is(.turn-primary-actions > .game-button, .turn-action-summary strong, .deal-actions > .game-button, .charleston-side > button, .blind-buttons button, .rack-heading-tools :is(button,select), .rack-selection-controls > strong) { font-size: 1rem; }
  .is-playing .large-table :is(.turn-aux-actions > .game-button, .turn-secondary-actions .game-button) { font-size: .95rem; line-height: 1.1; }
  .is-playing .large-table :is(.player-rack-heading, .rack-heading-tools :is(select,button,summary)) { height: var(--control-height); }
  .is-playing .large-table .rack-selection-controls { height: 44px; }
  .is-playing .large-table .player-rack-panel { --rack-tile-width: min(76px,calc((100cqw - 114px) / 14)); grid-template-rows: var(--control-height) 132px 44px; }
  .is-playing .large-table :is(.player-hand-row, .full-player-rack) { height: 132px; }
  .is-playing .large-table .full-player-rack .tile-corner { font-size: 1rem; }
  .is-playing .large-table .full-player-rack .game-tile small { font-size: .625rem; letter-spacing: normal; }
  .large-table .game-card-key { text-transform: none; }
  .large-table :is(.card-line-pattern, .coaching-card-line .card-line-pattern) { font-size: 1.3rem; }
}

@media screen and (min-width: 701px) and (max-width: 1100px) and (min-height: 501px) {
  .is-playing .game-workspace.large-table { --rack-height: 342px; }
  .is-playing .large-table .player-rack-panel { --rack-tile-width: 68px; grid-template-rows: var(--control-height) 232px 44px; }
  .is-playing .large-table .concealed-rack-zone { width: calc(7 * var(--rack-tile-width) + 56px); }
  .is-playing .large-table .full-player-rack { grid-template-columns: repeat(7, var(--rack-tile-width)); }
  .is-playing .large-table :is(.player-hand-row, .full-player-rack) { height: 232px; }
}

@media screen and (max-width: 700px), screen and (max-width: 1100px) and (max-height: 500px) {
  .is-playing .game-workspace.large-table.rack-enlarged { --rack-height: 426px; }
  .is-playing .large-table.rack-enlarged .player-rack-panel { grid-template-rows: 78px 286px 44px; }
  .is-playing .game-workspace.large-table .player-rack-heading {
    display: grid; grid-template: minmax(0,1fr) var(--control-height) / minmax(0,1fr);
    height: 100%; align-items: center;
  }
  .is-playing .large-table .rack-heading-tools { width: 100%; height: auto; }
  .is-playing .large-table .turn-primary-actions { grid-template-columns: minmax(0,1fr) 82px; }
  .is-playing .large-table .turn-aux-actions { grid-template-columns: 1fr 1.15fr 1fr 1fr 1fr; }
  .is-playing .large-table .turn-action-summary p { font-size: .9rem; }
  .is-playing .large-table [data-deal-panel] .preplay-stage { grid-template-rows: 56px minmax(min-content,1fr); }
  .is-playing .large-table .charleston-workspace { grid-template-rows: 61px var(--control-height) 46px; }
  .is-playing .large-table .charleston-heading > div > p.charleston-instruction { font-size: .875rem; }
  .is-playing .large-table .charleston-side > button { height: var(--control-height); }
}
