/* A landscape table uses the middle of the screen from top to bottom.
   The same two side wings hold the hands and controls at every screen size. */
@media (orientation: landscape) {
  html:has(.bt-arena), body:has(.bt-arena) { overflow: hidden; overscroll-behavior: none; }
  #game-shell:has(.bt-arena) {
    display: block;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  #game-shell:has(.bt-arena) :is(.mast,.app-dock,.foot) { display: none; }
  #game-shell #main-content:has(.bt-arena) {
    width: 100%; max-width: none; height: 100%; margin: 0; padding: 0; overflow: hidden;
  }
  #main-content .gx-scene:has(> .bt-arena) {
    --table-top: max(2px,env(safe-area-inset-top,0px));
    --table-bottom: max(2px,env(safe-area-inset-bottom,0px));
    --table-left: env(safe-area-inset-left,0px);
    --table-right: env(safe-area-inset-right,0px);
    --table-height: calc(100dvh - var(--table-top) - var(--table-bottom));
    --table-width: calc(100vw - var(--table-left) - var(--table-right));
    --board-width: min(calc(var(--table-height) * .8), calc(var(--table-width) - 216px));
    --wing-width: calc((var(--table-width) - var(--board-width)) / 2);
    --wing-inset: clamp(4px,1.4vw,30px);
    --control-height: clamp(60px,17dvh,132px);
    --name-height: clamp(23px,6.2dvh,52px);
    --wing-card-width: min(calc(var(--wing-width) - 2 * var(--wing-inset)), calc((var(--table-height) - var(--name-height) - var(--control-height) - 5px) / 2.8), 286px);
    position: relative; display: block; width: 100%; height: 100%; padding: 0; margin: 0;
  }
  .gx-scene > .bt-arena { height: 100%; border: 0; border-radius: 0; }
  .gx-scene > .bt-arena::before {
    background:
      radial-gradient(ellipse at 50% 22%, #48503d55, transparent 74%),
      linear-gradient(90deg,#13231ff2,#2a3930ed 27%,#3a3025eb 49%,#2a3930ed 73%,#13231ff2),
      url('/art/club-table.jpg') center / cover;
  }
  .gx-scene .bt-arena .bt-playmat {
    height: 100%; width: 100%; max-width: none; margin: 0;
    padding: var(--table-top) var(--table-right) var(--table-bottom) var(--table-left);
    display: grid; gap: 0;
    grid-template: 'them board you' minmax(0,1fr) / minmax(0,1fr) var(--board-width) minmax(0,1fr);
  }
  .bt-arena .bt-board-space { height: 100%; }
  .bt-arena .bt-board-space > .bt-board-rail {
    width: 100%; max-width: none; aspect-ratio: 4 / 5; min-height: 0;
  }
  .bt-arena .bt-board {
    width: 100%; height: 100%; grid-template-rows: repeat(3,minmax(0,1fr));
    padding: clamp(3px,.9dvh,10px); gap: clamp(2px,.45dvh,5px);
  }
  .bt-arena .bt-board .bt-cell { height: 100%; min-height: 0; aspect-ratio: auto; }
  .gx-scene .bt-arena .bt-handrail {
    display: grid; grid-template: var(--name-height) minmax(0,1fr) / minmax(0,1fr);
    height: calc(100% - var(--control-height)); width: 100%; gap: 0; padding-inline: var(--wing-inset);
    align-self: start; justify-self: stretch; justify-items: center;
  }
  .bt-arena .bt-handrail .bt-playername {
    display: flex; gap: clamp(3px,1vw,14px); align-self: center; align-items: center;
    width: max-content; max-width: 100%; min-width: 0; margin: 0;
  }
  .bt-arena .bt-playername > div { min-width: 0; }
  .bt-arena .bt-playername h2 {
    white-space: nowrap; text-overflow: ellipsis; overflow: hidden;
    font: 600 clamp(13px,2.3dvh,23px)/1.05 var(--sans);
  }
  .bt-arena .bt-handrail .bt-playername strong {
    min-width: 1.45em; padding: .09em .25em .07em; border: 1px solid color-mix(in srgb,var(--edge),transparent 45%);
    border-radius: 3px; color: #fff1db; background: color-mix(in srgb,var(--team) 49%,#232925);
    font: 700 clamp(14px,2.5dvh,25px)/1 var(--sans); font-variant-numeric: tabular-nums; text-align: center;
  }
  .bt-arena .bt-playername div > span { display: none; }
  .bt-arena .bt-playername .bt-sigil { width: clamp(14px,2.8dvh,29px); height: auto; aspect-ratio: 1; }
  .gx-scene .bt-arena .bt-hand {
    width: var(--wing-card-width); height: calc(var(--wing-card-width) * 2.8);
    align-self: center; justify-self: center; container-type: inline-size;
    display: grid; grid-template: repeat(4,minmax(0,1fr)) 44.643% / minmax(0,1fr);
    gap: 0;
  }
  .gx-scene .bt-arena .bt-hand .bt-hand-slot {
    width: 100%; max-width: none; height: 125cqw; min-height: 0; margin: 0; align-self: start;
  }
  .bt-arena .bt-hand .bt-hand-slot.mine { pointer-events: none; }
  .bt-arena .bt-hand .bt-hand-slot.mine::before {
    display: block; content: ''; position: absolute; inset: 0 0 auto; height: 31%; z-index: 1; pointer-events: auto;
  }
  .bt-arena .bt-hand .bt-hand-slot.mine:not(:has(~ .mine))::before { height: 100%; }
  .bt-arena .bt-hand .card-ranks { width: 34%; font-size: clamp(12px,12.6cqw,34px); }
  .gx-scene:has(.bt-arena) .bt-heading, .gx-scene .bt-arena .bt-footer {
    position: absolute; bottom: var(--table-bottom); width: var(--wing-width); max-width: none; height: var(--control-height);
    padding: 3px var(--wing-inset) max(3px,.8dvh); margin: 0; border: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    flex-wrap: nowrap; gap: clamp(2px,.6dvh,7px); color: #fff1dd; text-align: center; background: transparent;
  }
  .gx-scene:has(.bt-arena) .bt-heading { left: var(--table-left); }
  .gx-scene .bt-arena .bt-footer {
    right: var(--table-right); display: grid; grid-template: 'turn count' auto 'action action' auto / auto auto;
    justify-items: center; align-content: center; gap: clamp(3px,.7dvh,8px) 8px;
  }
  .bt-heading .bt-menu { position: static; }
  .gx-scene:has(.bt-arena) .bt-heading h1 { font-size: clamp(15px,2.8dvh,29px); margin: 0; }
  .gx-scene:has(.bt-arena) .bt-heading > span { max-width: 100%; font-size: clamp(11px,1.9dvh,15px); color: #e9d4b6; }
  .bt-arena .bt-footer strong, .bt-arena .bt-footer::before { grid-area: turn; font: 650 clamp(13px,2.2dvh,22px)/1.1 var(--sans); }
  .bt-arena .bt-footer .bt-count { grid-area: count; margin: 0; border-left: 1px solid #8d8065; padding-left: 8px; color:#e4d4b0; font: 500 clamp(11px,1.65dvh,16px)/1.1 var(--sans); font-variant-numeric:tabular-nums; }
  .bt-arena .bt-footer .gx-button { grid-area: action; }
  .bt-arena .bt-footer [role=status] { position:absolute; width:1px; height:1px; padding:0; clip-path:inset(50%); overflow:hidden; }
  .bt-heading .bt-menu summary, .bt-arena .bt-footer .gx-button {
    display: inline-flex; align-items: center; justify-content: center; min-height: clamp(28px,5.4dvh,43px);
    max-width: 100%; padding: 4px clamp(5px,1vw,14px); line-height: 1.1; font-size: clamp(12px,2.2dvh,16px);
  }
  .bt-heading .bt-menu summary, .bt-arena .bt-footer .gx-button {
    border: 1px solid #a28355; border-radius: 4px; background: #34291f; color: #f8e7c9;
    font-family: var(--sans); font-weight: 600;
  }
  .bt-arena .bt-footer .gx-button:not(:disabled) { background: #e6c68f; color: #33291d; }
  .bt-arena .bt-footer .gx-button:disabled { color: #bdb6a5; background: #273029; border-color: #665e4c; }
  .gx-scene .bt-heading::before, .gx-scene .bt-footer::after {
    content: ''; position: absolute; height: 1px; top: 0; width: min(66%,240px);
    left: 50%; transform: translateX(-50%); background: linear-gradient(90deg,transparent,#9e875d70 24% 76%,transparent);
  }
  .gx-scene .bt-heading .bt-controls {
    position: absolute; bottom: calc(100% + 2px); top: auto; left: var(--wing-inset); right: auto;
    width: min(340px,calc(100dvw - 2 * var(--wing-inset))); max-height: calc(var(--table-height) - var(--control-height) - 4px);
    padding: 10px 12px; gap: 7px; overflow: auto; overscroll-behavior: contain; text-align: left;
  }
  .gx-scene:has(.bt-arena) > .gx-error { position:absolute; top:var(--table-top); left:var(--table-left); width:var(--wing-width); z-index:15; }
}
@media (orientation:landscape) and (max-height:550px) {
  .gx-scene:has(.bt-arena) .bt-heading h1 { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
  .gx-scene:has(.bt-arena) .bt-heading .bt-extended-rules { line-height:1.1; }
  .bt-arena .bt-playername .bt-sigil { display:none; }
  .bt-arena .bt-footer:has(.bt-clock) { column-gap: 4px; }
  .bt-arena .bt-footer:has(.bt-clock) .bt-count { padding-left: 4px; }
}
@media (orientation:landscape) and (max-width:720px) {
  #main-content .gx-scene:has(.bt-extended-rules, .bt-clock) { --control-height: clamp(74px,20dvh,92px); }
  .gx-scene .bt-arena .bt-footer:has(.bt-clock) {
    grid-template: 'turn' auto 'count' auto 'action' auto / minmax(0,1fr); row-gap: 2px;
  }
  .bt-arena .bt-footer:has(.bt-clock) .bt-count { border: 0; padding: 0; }
}
@media (orientation:landscape) and (max-aspect-ratio:3/2) {
  .bt-arena .bt-handrail .bt-playername { gap: 5px; }
  .bt-arena .bt-handrail .bt-sigil { display: none; }
}
@media (orientation:landscape) and (min-height:650px) and (min-width:980px) {
  .gx-scene .bt-arena .bt-footer {
    grid-template: 'turn count' auto 'hint hint' auto 'action action' auto / auto auto;
  }
  .bt-arena .bt-footer [role=status] {
    grid-area: hint; position: static; width: auto; height: auto; clip-path: none; max-width: 38ch;
    color: #d9d2bd; font: 400 clamp(12px,1.5dvh,15px)/1.2 var(--sans);
  }
}
