.chess-lobby,
.chess-game {
  padding-block: clamp(1.5rem, 4vw, 4rem);
}

.chess-lobby {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  gap: 2rem;
  max-width: 68rem;
}

.chess-intro, .game-heading { container-type: inline-size; }
.chess-intro h1, .game-heading h1 { white-space: nowrap; }
.chess-intro .flourish { color: var(--red); }
.chess-game { --gutter: clamp(12px, 3vw, 48px); max-width: 42rem; padding-block: clamp(1rem, 2.5vw, 2.25rem); }
.chess-intro p { overflow-wrap: anywhere; }
.chess-lead { margin: 1.25rem 0 .8rem; font-size: clamp(1.5rem, 2.5vw, 2.125rem); line-height: 1.25; }
.account-prompt { padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid #d8ceba; }
.account-prompt p { margin: .5rem 0; font: .875rem/1.5 Arial, sans-serif; }
.account-prompt a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); font: 600 .875rem/1.5 Arial, sans-serif; text-underline-offset: 3px; }
.chess-still-life { display: none; }

.chess-options {
  min-width: 0;
  padding: clamp(1.75rem, 4vw, 2.75rem) clamp(1.4rem, 4vw, 3.25rem);
}

.chess-options h2 { margin: 0 0 1rem; font-size: clamp(1.5rem, 2.5vw, 2rem); font-weight: 400; line-height: 1.15; overflow-wrap: anywhere; }
.lobby-section { padding-bottom: 1.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid #72908a; }
.chess-options select + label { margin-top: .75rem; }
.open-games { scroll-margin-top: 1rem; }
.open-games-heading, .open-games-pages { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 .75rem; }
.open-games-heading h2 { margin: 0; }
.open-games-heading a, .open-games-pages a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--gold);
  font: 600 .875rem/1.4 Arial, sans-serif;
  text-underline-offset: 3px;
}
.open-game-list { display: grid; gap: .5rem; margin: .5rem 0 0; padding: 0; list-style: none; }
.open-game-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .45rem .65rem;
  border: 1px solid #c48972;
  border-radius: 4px;
  background: rgb(48 13 19 / 32%);
  font: 600 .875rem/1.4 Arial, sans-serif;
}
.open-game-list form { max-width: 100%; }
.chess-options label,
.invite-section label { display: block; margin-bottom: .65rem; font: 600 .8125rem/1.4 Arial, sans-serif; }
.bot-picker { min-width: 0; margin: 0 0 .75rem; padding: 0; border: 0; }
.bot-picker legend { margin-bottom: .65rem; padding: 0; font: 600 .8125rem/1.4 Arial, sans-serif; }
.bot-choices-scroll { max-height: 16rem; overflow-y: auto; padding: .25rem; }
.chess-options .bot-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .625rem;
  min-height: 3.25rem;
  margin: 0;
  padding: .5rem .65rem;
  border: 1px solid #c48972;
  border-radius: 4px;
  background: rgb(48 13 19 / 32%);
  font-size: .9375rem;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: rgb(247 193 116 / 18%);
  cursor: pointer;
}
.bot-choice + .bot-choice { margin-top: .375rem; }
.bot-choice:hover { background: rgb(247 193 116 / 12%); }
.bot-choice:has(:checked) { background: rgb(247 193 116 / 20%); border-color: var(--gold); }
.bot-choice input { width: 1.125rem; height: 1.125rem; margin: 0; accent-color: var(--gold); cursor: pointer; }
.chess-options select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: .65rem .55rem;
  text-overflow: ellipsis;
  border: 1px solid #72908a;
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.4 Arial, sans-serif;
}

.chess-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  min-height: 44px;
  padding: .75rem 1rem;
  border: 1px solid #c9bda5;
  border-radius: 4px;
  color: var(--ink);
  background: transparent;
  font: 600 .875rem/1.3 Arial, sans-serif;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.chess-button:disabled { opacity: .5; cursor: wait; }
.chess-button:hover:not(:disabled) { background: #e8deca; }
.primary-button { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.primary-button:hover:not(:disabled) { background: #395068; color: var(--paper); }
.gold-button { background: var(--gold); border-color: var(--gold); }
.gold-button:hover:not(:disabled) { background: #f5cc85; }
.lobby-section > .gold-button { justify-content: space-between; width: 100%; margin-top: 1rem; }
.chess-options .form-note { margin: .65rem 0 0; color: #ffebcf; font: .875rem/1.5 Arial, sans-serif; }
.danger-button { color: var(--red); }

.game-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .25rem clamp(.75rem, 2vw, 1.5rem);
  margin-bottom: clamp(1rem, 2vw, 1.5rem);
}

.match-title { display: flex; min-width: 0; align-items: center; gap: clamp(.5rem, 1.5vw, 1rem); }
.match-title > div { min-width: 0; }
.match-seal { flex: none; width: clamp(2rem, 4vw, 3.25rem); color: var(--red); }
.game-heading h1 { font-size: clamp(2rem, 4vw, 3rem); }
.game-heading .game-role { margin-top: .3rem; }
.game-heading .quiet-link { max-width: 100%; justify-self: end; font-weight: 600; text-align: end; overflow-wrap: anywhere; }
@container (max-width: 28rem) {
  .match-seal { display: none; }
  .game-heading h1 { font-size: clamp(1.875rem, 8cqi, 2rem); }
  .game-heading .quiet-link { align-self: start; }
}
@container (max-width: 16rem) {
  .match-title, .game-heading .quiet-link { grid-column: 1 / -1; }
  .game-heading .quiet-link { justify-self: start; text-align: start; }
}
@container (max-width: 11em) {
  .chess-intro h1, .game-heading h1 { font-size: min(2rem, 20cqi); }
}
.game-role { margin: .45rem 0 0; font: .875rem/1.4 Arial, sans-serif; color: var(--muted); overflow-wrap: anywhere; }
.quiet-link { display: inline-flex; align-items: center; gap: .65rem; min-height: 44px; color: var(--ink); font: .8125rem/1.35 Arial, sans-serif; text-underline-offset: 4px; }
.match-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: .875rem; align-items: start; }
.play-column { min-width: 0; grid-row: 2; }
.player { display: grid; position: relative; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .5rem; padding: .4rem .75rem; min-height: 44px; background: var(--ink); color: var(--paper); font: 600 .875rem/1.4 Arial, sans-serif; }
.table-ornament { display: none; }
.player[data-color="white"] { background: var(--red); }
.player > span { display: flex; align-items: center; gap: .5rem; min-width: 0; overflow-wrap: anywhere; }
.player > .clock-group { justify-self: end; }
.board-stage { container-type: inline-size; }
@container (max-width: 12rem) {
  .chess-game:not(.board-expanded) .player { grid-template-columns: minmax(0, 1fr); }
  .chess-game:not(.board-expanded) .player > span { flex-wrap: wrap; }
  .chess-game:not(.board-expanded) .player > .clock-group { justify-self: start; }
}
.computer-seat { min-width: 0; overflow-wrap: anywhere; }
.computer-seat a { color: inherit; text-underline-offset: .2em; }
.computer-seat small { display: block; color: #f4dfb8; font-size: .75rem; font-weight: normal; }
.player:has(.computer-seat) .table-ornament { display: none; }
.seat-guest, .seat-open { display: none; color: #f4dfb8; font-size: .75rem; font-weight: normal; }
.player-portrait[data-kind="guest"] ~ .seat-guest,
.player-portrait[data-kind="empty"] ~ .seat-open { display: inline; }
.chess-clock { min-width: 4.75rem; padding: .25rem .65rem; border: 1px solid #ba9a74; border-radius: 3px; font: 600 1.2rem/1 Arial, sans-serif; font-variant-numeric: tabular-nums; text-align: center; }
.player.is-turn .chess-clock { background: #f4ce88; border-color: #f4ce88; color: #263635; }
.board-frame {
  --rail: clamp(8px, 1.3vw, 16px);
  --stile: clamp(3px, 1.25vw, 16px);
  padding: var(--rail) var(--stile);
  background: var(--inlay) center top / auto var(--rail) repeat-x,
              var(--inlay) center bottom / auto var(--rail) repeat-x,
              linear-gradient(90deg, var(--ochre) 1px, var(--lacquer) 1px 22%, var(--cinnabar) 22% 66%, var(--ochre) 66% 74%, var(--lacquer) 74%) left / var(--stile) 100% no-repeat,
              linear-gradient(-90deg, var(--ochre) 1px, var(--lacquer) 1px 22%, var(--cinnabar) 22% 66%, var(--ochre) 66% 74%, var(--lacquer) 74%) right / var(--stile) 100% no-repeat, var(--lacquer);
}
.chess-board { position: relative; isolation: isolate; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); width: 100%; aspect-ratio: 1; }
.square {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.square.light { background: #edcf96; }
.square.inspected::before { content: ""; position: absolute; inset: 2px; border: 2px dashed var(--ink); pointer-events: none; }
.square.dark { background: #83a1af; }
.square.last-move { background: #e9ba68; box-shadow: inset 0 0 0 2px #866329; }
.square.selected { --selection-ink: #214f70; background: #abd6df; box-shadow: inset 0 0 0 3px var(--selection-ink); }
.square.selected::before {
  content: ""; position: absolute; inset: 3px; pointer-events: none;
  background: linear-gradient(225deg, var(--selection-ink) 48%, transparent 50%) top right / 18% 18% no-repeat,
              linear-gradient(45deg, var(--selection-ink) 48%, transparent 50%) bottom left / 18% 18% no-repeat;
}
.square.in-check { background: #de8e77; box-shadow: inset 0 0 0 3px var(--red); }
.square.legal { --legal-marker: rgb(28 44 60 / 75%); }
.square.legal::after { content: ""; position: absolute; width: 25%; aspect-ratio: 1; border-radius: 50%; background: var(--legal-marker); pointer-events: none; }
.square.legal-capture::after { width: 85%; background: transparent; border: 3px solid var(--legal-marker); }
.square:focus-visible { z-index: 1; outline: 3px solid var(--ink); outline-offset: -3px; }
.piece { display: block; width: 94%; height: 94%; pointer-events: none; }
.move-motion {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  display: grid; grid-template: repeat(8, minmax(0, 1fr)) / repeat(8, minmax(0, 1fr));
}
.square.arriving > .piece { visibility: hidden; }
.move-motion > span { display: grid; place-items: center; animation-duration: var(--move-duration, 180ms); animation-fill-mode: both; }
.sliding-figure { animation-name: chess-slide; animation-timing-function: cubic-bezier(.25,.65,.35,1); }
.captured-figure { animation-name: chess-capture; }
@keyframes chess-slide {
  from { transform: translate(var(--slide-x), var(--slide-y)); }
  to { transform: translate(0, 0); }
}
@keyframes chess-capture { 0%, 65% { opacity: 1; } to { opacity: 0; } }
.rabbit-move { --move-duration: 540ms; --hop-count: 1; --hop-time: calc(var(--move-duration) / var(--hop-count)); }
.double-hop { --move-duration: 820ms; --hop-count: 2; }
.rabbit-right { --hop-bend: 12%; --rabbit-facing: -1; }
.rabbit-move .sliding-figure { position: relative; animation-name: rabbit-travel; animation-timing-function: cubic-bezier(.35,.05,.35,1); }
.double-hop .sliding-figure { animation-name: rabbit-double-travel; }
.rabbit-move .sliding-figure > .piece { transform-origin: 50% 92%; animation: rabbit-hop var(--hop-time) var(--hop-count) both; }
.rabbit-move .sliding-figure::before {
  content: ""; position: absolute; bottom: 7%; width: 60%; height: 11%; border-radius: 50%;
  background: #332719; animation: rabbit-shadow var(--hop-time) var(--hop-count) both;
}
.rabbit-move .captured-figure { animation-name: rabbit-capture; }
@keyframes rabbit-travel {
  0%, 16% { transform: translate(var(--slide-x), var(--slide-y)); }
  82%, 100% { transform: translate(0, 0); }
}
@keyframes rabbit-double-travel {
  0%, 8% { transform: translate(0, var(--slide-y)); }
  41%, 58% { transform: translate(0, calc(var(--slide-y) / 2)); }
  91%, 100% { transform: translate(0, 0); }
}
@keyframes rabbit-hop {
  0%, 100% { transform: none; }
  16% { transform: scale(1.04, .89); animation-timing-function: ease-out; }
  46% { transform: translate(var(--hop-bend, -12%), -62%); }
  54% { transform: translate(var(--hop-bend, -12%), -62%); animation-timing-function: ease-in; }
  82% { transform: scale(1.05, .87); }
}
@keyframes rabbit-shadow {
  0%, 100% { opacity: 0; }
  16%, 82% { transform: scale(1); opacity: .44; }
  50% { transform: scale(.62); opacity: .27; }
}
@keyframes rabbit-capture { 0%, 55% { opacity: 1; } 82%, 100% { opacity: 0; } }
.leopard-move { --stride-time: 360ms; --move-duration: calc(120ms + var(--strides) * var(--stride-time)); overflow: clip; }
.leopard-move .sliding-figure { position: relative; animation-name: leopard-travel; animation-timing-function: linear; }
@keyframes leopard-travel {
  0%, 8% { transform: translate(var(--slide-x), var(--slide-y)); }
  92%, 100% { transform: translate(0, 0); }
}
.leopard-pounce { --move-duration: calc(640ms + var(--strides) * 40ms); }
.leopard-pounce .sliding-figure { animation-name: leopard-spring; animation-timing-function: cubic-bezier(.34,.07,.35,1); }
@keyframes leopard-spring {
  0%, 22% { transform: translate(var(--slide-x), var(--slide-y)); }
  82%, 100% { transform: translate(0, 0); }
}
.leopard-pounce .captured-figure { animation-name: leopard-capture; }
@keyframes leopard-capture { 0%, 64% { opacity: 1; } 82%, 100% { opacity: 0; } }
.leopard-pounce .sliding-figure::before {
  content: ""; position: absolute; bottom: 6%; width: 58%; height: 10%; border-radius: 50%;
  background: #342b26; animation: leopard-shadow var(--move-duration) both;
}
@keyframes leopard-shadow {
  0%, 100% { opacity: 0; }
  20%, 82% { opacity: .39; transform: scaleX(1); }
  52% { opacity: .2; transform: scaleX(.65); }
}
.king-move { --move-duration: 360ms; }
.king-move .sliding-figure { animation-name: king-slide; animation-timing-function: ease-in-out; }
.king-move .captured-figure { animation-name: king-capture; }
/* Brace for 100ms, hold through the glide, then straighten on the destination. */
@keyframes king-slide {
  0%, 19.444% { transform: translate(var(--slide-x), var(--slide-y)); }
  69.444%, 100% { transform: translate(0, 0); }
}
@keyframes king-capture { 0%, 50% { opacity: 1; } 69.444%, 100% { opacity: 0; } }
@keyframes king-lean {
  0%, 100% { background-position-x: 50%; }
  27.778%, 61.111% { background-position-x: var(--lean-toward); }
}
/* Two stone colours, six rows in king, queen, rook, bishop, knight, pawn order. */
[data-figure^="b"] { --figure-x: 100%; }
[data-figure$="Q"] { --figure-y: 20%; }
[data-figure$="R"] { --figure-y: 40%; }
[data-figure$="B"] { --figure-y: 60%; }
[data-figure$="N"] { --figure-y: 80%; }
[data-figure$="P"] { --figure-y: 100%; }
.stone-ready [data-figure], .chess-still-life [data-figure] {
  background: url("../chess/stone-set.3cef308d6a31.webp") var(--figure-x, 0%) var(--figure-y, 0%) / 200% 600% no-repeat;
}
.stone-ready [data-figure] > use { visibility: hidden; }
[data-figure^="w"] { filter: url("#ivory-outline"); }
.yurt-move { --move-duration: 2000ms; overflow: clip; }
.yurt-capture { --move-duration: 2100ms; }
/* Both castling tiles share the same journey, even if the king's pose sheet is still loading. */
.yurt-move .sliding-figure { animation-name: yurt-travel; animation-timing-function: ease-in-out; }
.yurt-figure { position: relative; }
.yurt-figure > .piece { transform-origin: 50% 94%; animation: yurt-fold var(--move-duration) both; }
.yurt-posed > .piece {
  background: url("../chess/yurt-pack.fc6fbd5483bb.webp") 0% var(--yurt-row, 0%) / 400% 200% no-repeat;
  animation: yurt-pack var(--move-duration) steps(1, end) both;
}
.yurt-posed > [data-figure="bR"] { --yurt-row: 100%; }
.yurt-posed use { visibility: hidden; }
.yurt-capture .captured-figure { animation-name: yurt-contact; }
.yurt-capture .yurt-figure::after {
  content: ""; position: absolute; inset: auto 5% 6%; height: 14%;
  border: 2px solid #463322; border-radius: 50%; animation: yurt-footprint var(--move-duration) both;
}
@keyframes yurt-travel {
  0%, 40% { transform: translate(var(--slide-x), var(--slide-y)); }
  60%, 100% { transform: translate(0, 0); }
}
/* Hold the cover and bare lattice for 320ms each on both squares. Only the bundle travels. */
@keyframes yurt-pack {
  0%, 95%, 100% { background-position-x: 0%; }
  5%, 79% { background-position-x: 33.3333%; }
  21%, 63% { background-position-x: 66.6667%; }
  37% { background-position-x: 100%; }
}
@keyframes yurt-fold {
  0%, 5%, 95%, 100% { transform: none; }
  21%, 79% { transform: scale(.96, .78); }
  37%, 63% { transform: scale(.90, .52); }
}
@keyframes yurt-contact { 0%, 54% { opacity: 1; } 60%, 100% { opacity: 0; } }
@keyframes yurt-footprint {
  0%, 58%, 80%, 100% { opacity: 0; }
  58% { transform: scaleX(.65); }
  63% { opacity: .65; }
  80% { transform: scaleX(1.15); }
}
.horse-move { --move-duration: 740ms; --horse-peak: -72%; --horse-compression: .94; overflow: clip; }
.horse-capture { --move-duration: 860ms; --horse-peak: -96%; --horse-compression: .86; }
.horse-move .sliding-figure { position: relative; animation-name: horse-travel; animation-timing-function: linear; }
.horse-move .sliding-figure > .piece {
  transform-origin: 50% 94%;
  animation: horse-lift var(--move-duration) both;
}
.horse-posed .sliding-figure > .piece {
  background: url("../chess/horse-jump.7d9f9f953b5a.webp") 0% var(--horse-row, 0%) / 400% 200% no-repeat;
  scale: var(--horse-facing, 1) 1;
  animation: horse-lift var(--move-duration) both, horse-poses var(--move-duration) steps(1, end) both;
}
.horse-posed .sliding-figure > [data-figure="bN"] { filter: grayscale(1) brightness(.43) contrast(1.45); }
.horse-posed .sliding-figure use { visibility: hidden; }
.horse-move .sliding-figure::before {
  content: ""; position: absolute; bottom: 7%; width: 63%; height: 12%; border-radius: 50%; background: #332719;
  animation: horse-shadow var(--move-duration) both;
}
.horse-capture .captured-figure { animation-name: horse-contact; }
@keyframes horse-travel {
  0%, 14% { transform: translate(var(--slide-x), var(--slide-y)); }
  82%, 100% { transform: translate(0, 0); }
}
@keyframes horse-lift {
  0%, 100% { transform: none; }
  14% { transform: scale(1.02, .94); animation-timing-function: ease-out; }
  47% { transform: translateY(var(--horse-peak)); animation-timing-function: ease-in; }
  80% { transform: translateY(0); }
  87% { transform: scale(1.03, var(--horse-compression)); }
}
@keyframes horse-poses {
  0%, 93%, 100% { background-position-x: 0%; }
  14% { background-position-x: 33.3333%; }
  35% { background-position-x: 66.6667%; }
  63% { background-position-x: 100%; }
}
@keyframes horse-shadow {
  0%, 100% { opacity: 0; }
  14%, 82% { opacity: .45; transform: scaleX(1); }
  47% { opacity: .24; transform: scaleX(.58); }
}
@keyframes horse-contact { 0%, 77% { opacity: 1; } 84%, 100% { opacity: 0; } }
.camel-move {
  --camel-rise: 85ms; --camel-finish: 125ms;
  --camel-arrival: calc(var(--camel-rise) + var(--camel-cycles) * var(--camel-period));
  --move-duration: calc(var(--camel-arrival) + var(--camel-finish));
  overflow: clip;
}
.camel-move .sliding-figure { animation-name: camel-travel; animation-timing-function: linear; }
@keyframes camel-travel {
  0%, 9% { transform: translate(var(--slide-x), var(--slide-y)); }
  86%, 100% { transform: translate(0, 0); }
}
.camel-capture { --camel-finish: 260ms; --camel-ending: camel-plant; }
.camel-capture .captured-figure { animation-name: camel-contact; }
@keyframes camel-contact { 0%, 76% { opacity: 1; } 88%, 100% { opacity: 0; } }
.camel-move .sliding-figure > .piece {
  background: url("../chess/bactrian-camel-poses.9c11c97684f9.webp") 57.1429% var(--camel-row, 0%) / 800% 200% no-repeat;
  transform-origin: 50% 92%; scale: calc(1.15 * var(--camel-facing, 1)) 1.15;
  animation: camel-pace var(--camel-period) steps(1, end) var(--camel-rise) var(--camel-cycles),
             camel-roll var(--camel-period) ease-in-out var(--camel-rise) var(--camel-cycles),
             var(--camel-ending, camel-fold) var(--camel-finish) steps(1, end) var(--camel-arrival) forwards;
}
.camel-move .sliding-figure use { visibility: hidden; }
@keyframes camel-pace {
  0% { background-position-x: 0%; }
  25% { background-position-x: 14.2857%; }
  50% { background-position-x: 28.5714%; }
  75%, 100% { background-position-x: 42.8571%; }
}
@keyframes camel-roll {
  0%, 50%, 100% { transform: none; }
  25% { transform: translateX(-1.8%) rotate(-3deg); }
  75% { transform: translateX(1.8%) rotate(3deg); }
}
@keyframes camel-fold {
  0% { background-position-x: 57.1429%; }
  58%, 100% { background-position-x: 100%; }
}
@keyframes camel-plant {
  0% { background-position-x: 71.4286%; }
  38% { background-position-x: 85.7143%; }
  72% { background-position-x: 57.1429%; }
  89%, 100% { background-position-x: 100%; }
}
.leopard-move .sliding-figure > .piece {
  /* Columns 0–3 are the four footfalls. Columns 4–7 are the capture poses. */
  background: url("../chess/snow-leopard-poses.226f9937e439.webp") 57.1429% var(--leopard-row, 0%) / 800% 300% no-repeat;
  transform-origin: 50% 92%; scale: calc(1.32 * var(--leopard-facing, 1)) 1.32;
  animation: leopard-walk var(--stride-time) steps(1, end) 60ms var(--strides);
}
.leopard-move .sliding-figure > [data-figure="bQ"],
.camel-move .sliding-figure > [data-figure="bB"] { filter: grayscale(.98) brightness(.63) contrast(1.42); }
.leopard-move .sliding-figure use { visibility: hidden; }
@keyframes leopard-walk {
  0% { background-position-x: 0%; }
  25% { background-position-x: 14.2857%; }
  50% { background-position-x: 28.5714%; }
  75%, 100% { background-position-x: 42.8571%; }
}
.leopard-pounce .sliding-figure > .piece {
  animation: leopard-strike var(--move-duration) steps(1, end) both, leopard-lift var(--move-duration) both;
}
@keyframes leopard-strike {
  0%, 89%, 100% { background-position-x: 57.1429%; }
  22% { background-position-x: 71.4286%; }
  37% { background-position-x: 85.7143%; }
  68% { background-position-x: 100%; }
}
@keyframes leopard-lift {
  0%, 22%, 82%, 100% { transform: translateY(0); }
  50% { transform: translateY(-37%); animation-timing-function: ease-in; }
}
.rabbit-posed .sliding-figure > .piece {
  background: url("../chess/rabbit-poses.f8e3487fc35a.webp") 0 var(--rabbit-row, 0%) / 400% 200% no-repeat;
  animation: rabbit-hop var(--hop-time) var(--hop-count) both,
             rabbit-poses var(--hop-time) steps(1, end) var(--hop-count) both;
}
.rabbit-posed.rabbit-right { --hop-bend: -12%; } /* The mirrored pose also mirrors its local X axis. */
.rabbit-posed.double-hop .sliding-figure > .piece {
  animation: rabbit-hop var(--hop-time) 2 both, rabbit-double-poses var(--move-duration) steps(1, end) both;
}
.rabbit-posed [data-figure="bP"] { --rabbit-row: 100%; }
.rabbit-posed .sliding-figure use { visibility: hidden; }
@keyframes rabbit-poses {
  0%, 95%, 100% { background-position-x: 0%; scale: 1; }
  6%, 82% { background-position-x: 33.3333%; scale: var(--rabbit-facing, 1) 1; }
  23% { background-position-x: 66.6667%; scale: var(--rabbit-facing, 1) 1; }
  62% { background-position-x: 100%; scale: var(--rabbit-facing, 1) 1; }
}
@keyframes rabbit-double-poses {
  0%, 97%, 100% { background-position-x: 0%; scale: 1; }
  3%, 41%, 91% { background-position-x: 33.3333%; scale: var(--rabbit-facing, 1) 1; }
  11.5%, 61.5% { background-position-x: 66.6667%; scale: var(--rabbit-facing, 1) 1; }
  31%, 81% { background-position-x: 100%; scale: var(--rabbit-facing, 1) 1; }
}
.king-move .noyon-lean[data-figure] {
  background-size: 1100% 200%; background-position: 50% var(--lean-row);
  animation: king-lean var(--move-duration) steps(5, end) both;
}
.king-move .noyon-lean[data-figure="wK"] { background-image: url("../chess/white-king-poses.f06a7f48730a.webp"); }
.king-move .noyon-lean[data-figure="bK"] { background-image: url("../chess/black-king-poses.de395d5ee3fb.webp"); }
@media (prefers-reduced-motion: reduce) {
  .move-motion { --move-duration: 1ms; }
}
.coordinate { position: absolute; color: #1c2b37; font: 600 .625rem/1 Arial, sans-serif; pointer-events: none; }
.coordinate.file { right: 3px; bottom: 2px; }
.coordinate.rank { left: 3px; top: 2px; }

.chess-replay { max-width: 60rem; }
.replay-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1.5rem; margin-bottom: 1rem; }
.replay-heading h1 { font-size: clamp(2rem, 5vw, 3rem); overflow-wrap: anywhere; }
.replay-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(.85rem, 2.5vw, 1.5rem); align-items: start; }
.replay-sidebar { display: grid; gap: .85rem; min-width: 0; container-type: inline-size; }
.chess-replay .square { cursor: default; }
.replay-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.replay-controls button[aria-disabled="true"] { opacity: .5; cursor: default; background: transparent; }
.replay-playback { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.replay-playback > button { flex: 1 1 8rem; min-width: 0; }
.replay-speed { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font: 600 .875rem/1.3 Arial, sans-serif; }
.replay-speed select { min-height: 44px; padding: .4rem .55rem; border: 1px solid #c9bda5; border-radius: 4px; background: var(--paper); color: var(--ink); font: inherit; }
.replay-moves { padding: 1rem; border: 1px solid #d8ceba; border-radius: 8px; background: #fffbf3; }
.replay-moves h2 { margin: 0; font-size: 1.25rem; }
.replay-moves p { margin: .5rem 0; color: var(--muted); font: .875rem/1.5 Arial, sans-serif; }
.replay-moves .move-list { max-height: 22rem; }
.replay-moves li { padding: .15rem 0; }
.replay-moves li .chess-button { min-width: 4rem; padding: .5rem; margin-inline-end: .35rem; }
.replay-moves button[aria-current="step"], .replay-moves button[aria-current="step"]:hover { background: var(--ink); color: var(--paper); }
@container (min-width: 30rem) {
  .replay-controls { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 48em) {
  .replay-layout { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
}
.board-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-top: .65rem; }
@media (max-width: 30em) {
  .chess-game:not(.board-expanded) .board-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chess-game:not(.board-expanded) .board-toolbar .quiet-link { grid-column: 1 / -1; justify-self: start; }
}
#board-view { gap: .4rem; }
#board-view svg { flex: none; }
.exit-view, .board-expanded .enter-view { display: none; }
.board-expanded .exit-view { display: inline; }
@media (min-width: 60em) and (pointer: fine) {
  .chess-game:not(.board-expanded) #board-view { display: none; }
}
.small-button { padding: .6rem .8rem; font-size: .8125rem; }
.piece-guide { margin-top: .5rem; border-block: 1px solid #cbbfa8; }
.piece-guide summary { padding: .85rem .2rem; cursor: pointer; font: 600 .875rem/1.4 Arial, sans-serif; }
.piece-guide summary::marker { color: var(--red); }
.piece-guide summary:focus-visible { outline: 2px solid var(--red); }
.piece-guide ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr)); gap: .75rem; margin: 0; padding: 0 0 1rem; list-style: none; }
.piece-guide li { display: flex; gap: .5rem; align-items: center; font-weight: bold; overflow-wrap: anywhere; }
.piece-guide svg { flex: none; width: 2.5rem; height: 2.5rem; }
.piece-guide small { display: block; color: #526963; font: .8125rem/1.4 Arial, sans-serif; }
.guide-model { display: flex; align-items: center; gap: .5rem; width: 100%; min-height: 44px; padding: 0; color: inherit; background: transparent; border: 0; font: inherit; text-align: start; cursor: pointer; }
.guide-model b { padding: .15rem .32rem; color: var(--red); border: 1px solid var(--ochre); border-radius: 3px; font: 600 .7rem/1.2 Arial, sans-serif; }
.guide-model:focus-visible { outline: 2px solid var(--red); }
.figure-dialog {
  width: min(calc(100% - 1.25rem), 27rem);
  height: min(calc(100dvh - 1.25rem), 36rem);
  max-height: calc(100dvh - 1.25rem);
  padding: 0;
  border: 1px solid var(--ochre);
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
}
.figure-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.figure-dialog::backdrop { background: rgb(9 18 27 / 72%); }
.figure-dialog header, .figure-controls { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .55rem .85rem; }
.figure-dialog header { border-bottom: 1px solid var(--ochre); }
.figure-dialog header small { color: var(--gold); font: .75rem/1.3 Arial, sans-serif; }
.figure-dialog h2 { margin: 0; font: 1.6rem/1.15 Georgia, serif; }
.figure-dialog button { width: 44px; min-height: 44px; padding: 0; flex: none; border: 1px solid #8c846e; border-radius: 4px; background: transparent; color: var(--paper); font: 1.45rem/1 Arial, sans-serif; cursor: pointer; touch-action: manipulation; }
.figure-dialog button:disabled { opacity: .4; }
.figure-dialog :focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.figure-stage { position: relative; display: grid; place-items: center; min-height: 0; background: radial-gradient(ellipse at 50% 45%, #485b61, #213643 72%, #192d3a); }
.figure-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; visibility: hidden; touch-action: none; cursor: grab; }
.figure-stage canvas:active { cursor: grabbing; }
.figure-poster { width: min(75%, 10rem); height: auto; aspect-ratio: 1; }
.figure-dialog.model-ready canvas { visibility: visible; }
.figure-dialog.model-ready .figure-poster { display: none; }
.figure-controls { border-top: 1px solid #66716f; }
.figure-controls p { margin: 0; font: .85rem/1.4 Arial, sans-serif; text-align: center; }

.match-panel { display: contents; min-width: 0; }
.match-status { grid-row: 1; position: relative; isolation: isolate; overflow: hidden; padding: .75rem 1rem; background: var(--red); color: var(--paper); border-inline-start: 4px solid var(--ochre); }
.status-knot { position: absolute; z-index: -1; right: -.25rem; top: 50%; transform: translateY(-50%); width: 5.5rem; color: var(--gold); opacity: .13; }
.connection-state { margin: 0 0 .2rem; color: #f3d59e; font: .8125rem/1.4 Arial, sans-serif; }
.match-status h2 { margin: 0; overflow-wrap: anywhere; font-size: clamp(1.375rem, 2vw, 1.75rem); font-weight: 400; line-height: 1.2; }
.rematch-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .5rem; }
#rematch-status { margin: 0; color: #ffdaa5; font: .875rem/1.4 Arial, sans-serif; }
#rematch-status:empty { display: none; }
.chess-notice { margin: .75rem 0 0; color: var(--red); font: .875rem/1.5 Arial, sans-serif; }
.chess-notice:empty { display: none; }
.piece-hint { position: sticky; bottom: .4rem; z-index: 3; margin: 0; pointer-events: none; }
.piece-hint:not(:empty) {
  padding: .5rem .75rem; border-inline-start: 3px solid var(--ochre);
  background: var(--ink); color: var(--paper); font: .9375rem/1.4 Arial, sans-serif;
}
.board-expanded .piece-hint { position: static; }
.board-expanded .piece-hint:not(:empty) { margin-bottom: .5rem; }
.match-status .chess-notice { color: #ffdaa5; }
.join-game { margin-top: 1rem; }
.join-game button { width: 100%; background: var(--gold); border-color: var(--gold); color: var(--ink); }
.join-game button:hover:not(:disabled) { background: #ffda95; color: var(--ink); }
.invite-section { grid-row: 3; }
.invite-controls { display: flex; align-items: stretch; gap: .5rem; }
.invite-controls input { min-width: 0; width: 100%; padding: .65rem; border: 1px solid #c9bda5; border-radius: 4px; background: var(--paper); color: #526963; font: .8125rem/1.4 Arial, sans-serif; }
.invite-controls button { flex: none; }
.move-section { grid-row: 4; padding-top: 1rem; border-top: 1px solid #d8ceba; }
.move-section h3 { margin: 0 0 .65rem; font: 600 .8125rem/1.4 Arial, sans-serif; }
.move-list { margin: 0; max-height: 12rem; overflow-y: auto; padding-inline-start: 2rem; font: .875rem/1.8 Arial, sans-serif; font-variant-numeric: tabular-nums; }
.move-list:empty::before { content: attr(data-empty-text); display: block; margin-left: -2rem; color: var(--muted); font-size: .8125rem; }
.move-list { overflow-anchor: none; overscroll-behavior: contain; }
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 2.75rem; }
.history-heading h3 { margin: 0; }
#latest-move { margin-inline-start: .4em; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-follow { min-height: 44px; padding: .25rem .5rem; font: 600 .8125rem/1.25 Arial, sans-serif; color: var(--ink); border: 0; background: transparent; text-decoration: underline; cursor: pointer; }
.board-settings { grid-row: 5; margin-block: .65rem; }
.quick-moves:not([hidden]) { display: flex; align-items: center; gap: .65rem; min-height: 44px; margin: .5rem 0; cursor: pointer; font: 600 .9rem/1.3 Arial, sans-serif; }
.quick-moves input { flex: none; width: 1.125rem; height: 1.125rem; margin: 0; accent-color: var(--ink); }
.quick-moves small { display: block; font-size: .78rem; font-weight: normal; }
.clock-check { color: #ffdf97; font: 700 .8rem/1.2 Arial, sans-serif; }
.game-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .375rem .5rem; padding: .375rem; background: var(--paper); }
.game-actions:not(:has(> button:not([hidden]))) { display: none; }
@media (orientation: landscape) and (min-width: 32em) and (max-height: 32em) {
  .chess-game:not(.board-expanded) .play-column { --board-width: min(64%, calc(100svh - 4rem)); }
  .chess-game:not(.board-expanded) .board-stage {
    display: grid;
    grid-template-columns: var(--board-width) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    align-items: start;
  }
  .chess-game:not(.board-expanded) .board-frame { grid-area: 1 / 1 / 3 / 2; }
  .chess-game:not(.board-expanded) .player { grid-column: 2; }
  .chess-game:not(.board-expanded) .game-actions { width: var(--board-width); padding-inline: 0; }
}
.promotion-dialog { width: min(calc(100% - 2rem), 24rem); max-height: calc(100dvh - 2rem); padding: 1.25rem; border: 1px solid #d8ceba; border-radius: 8px; background: var(--paper); color: var(--ink); }
.promotion-dialog::backdrop { background: rgb(10 35 37 / 48%); }
.promotion-dialog h2 { margin: 0 0 1rem; font-size: 1.75rem; font-weight: 400; }
.promotion-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.promotion-choices button { display: grid; justify-items: center; align-content: center; gap: .15rem; min-height: 48px; padding: .5rem; border: 1px solid #c9bda5; border-radius: 4px; background: var(--paper); color: var(--ink); font: 600 1rem/1.3 Arial, sans-serif; cursor: pointer; }
.promotion-choices svg { width: clamp(2rem, 8vh, 3.5rem); aspect-ratio: 1; }
.promotion-role { color: var(--muted); font-weight: normal; }
.promotion-role::first-letter { text-transform: uppercase; }
@media (max-height: 28rem) and (orientation: landscape) {
  .promotion-dialog { width: min(calc(100% - 2rem), 34rem); padding: .75rem; }
  .promotion-choices { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.promotion-choices button:hover { background: var(--gold); }

@media (min-width: 48em) {
  .table-ornament { position: absolute; left: 50%; transform: translateX(-50%); display: block; width: 4rem; height: 1.7rem; }
  .chess-lobby { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: clamp(1.5rem, 4vw, 4rem); align-items: center; }
  .chess-still-life { display: flex; align-items: end; justify-content: center; margin-top: 2rem; width: min(100%, 20rem); padding-bottom: 12px; background: var(--inlay) center bottom / auto 8px repeat-x; }
  .chess-still-life [data-figure] { display: block; width: 27%; aspect-ratio: 1; }
  .chess-still-life [data-figure="wK"] { width: 36%; }
}

@media (min-width: 60em) {
  .chess-game { max-width: 64rem; }
  .match-layout { grid-template-columns: minmax(0, 1.6fr) minmax(18rem, 1fr); gap: clamp(1.5rem, 3vw, 2.5rem); }
  .play-column { grid-row: auto; }
  .match-panel { display: block; border: 1px solid #cfbfa2; background: #fcf6e9; }
  .match-status { padding: 1.35rem 1.35rem calc(1.35rem + 10px); border: 0; background: var(--red) var(--inlay) center bottom / auto 10px repeat-x; }
  .invite-section, .move-section { margin: 1.25rem; }
  .move-list { max-height: 16rem; }
  .board-settings { margin: 1.25rem; }
}

/* Board view keeps play fixed while the match details scroll independently. */
.match-details { display: contents; }
.board-view-only, .seat-you, #share-invite { display: none; }
html.board-view-open { --table-ink: #172b3f; overflow: hidden; overscroll-behavior: none; background: var(--table-ink); }
.board-view-open body { background: var(--table-ink); }
.board-view-open .masthead, .board-view-open main > .ribbon, .board-view-open footer,
.board-expanded .game-heading, .board-expanded .quiet-link, .board-expanded .standard-view,
.board-expanded .account-prompt, .board-expanded .table-ornament { display: none; }
.board-expanded .board-view-only, .board-expanded .seat-you { display: inline-block; }

.chess-game.board-expanded {
  position: fixed;
  inset: 0;
  z-index: 10;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--table-ink);
}
.board-expanded .match-layout {
  height: 100%;
  min-height: 18rem;
  grid-template:
    "status"  auto
    "stage"   minmax(0, max-content)
    "actions" auto
    "details" minmax(4.75rem, 1fr)
    "tools"   auto / minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
}
.board-expanded .play-column, .board-expanded .match-panel { display: contents; }
.board-expanded .match-status {
  grid-area: status;
  padding: .55rem 3.6rem .6rem 1rem;
  background: var(--table-ink);
  color: var(--paper);
  border: 0;
}
.board-expanded .status-knot {
  z-index: auto;
  width: 2rem;
  right: .9rem;
  color: var(--gold);
  opacity: .85;
}
.board-expanded .connection-state { display: flex; align-items: center; gap: .4rem; margin: 0 0 .12rem; font-size: .75rem; }
.board-expanded .connection-state::before { content: ""; flex: none; width: .45rem; height: .45rem; border-radius: 50%; background: var(--gold); }
.board-expanded.is-connected .connection-state::before { background: #99ccb0; }
.board-expanded .match-status h2 { font-size: clamp(1.2rem, 5vw, 1.5rem); line-height: 1.18; }

.board-expanded .board-stage {
  --clock-row: max(38px, 2.4rem);
  grid-area: stage;
  container-type: size;
  contain-intrinsic-block-size: calc(100vw + 2 * var(--clock-row));
  display: grid;
  align-content: start;
  justify-items: center;
  grid-template-columns: minmax(0, 1fr);
}
.board-expanded .board-stage > * { width: min(100cqi, calc(100cqb - 2 * var(--clock-row))); }
.board-expanded .board-frame { --rail: 2px; --stile: 2px; }
.board-expanded .player {
  height: var(--clock-row);
  min-height: 0;
  padding: .15rem .8rem;
  background: #30465a;
  color: #fff7e6;
}
.board-expanded .computer-seat a {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: 1.15;
}
.board-expanded .computer-seat small { display: none; }
.board-expanded .player[data-color="white"] { background: #713134; }
.board-expanded .seat-you { padding-inline-start: .5rem; border-inline-start: 1px solid #ffffff60; color: #f4dfb8; font-size: .75rem; font-weight: normal; }
.board-expanded .chess-clock { padding: .15rem .5rem; border-color: transparent; font-size: 1.375rem; }
.board-expanded .is-turn .chess-clock { border-color: var(--gold); }

.board-expanded .match-details {
  container-type: size;
  grid-area: details;
  display: block;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: .65rem clamp(.75rem, 3vw, 1.25rem);
  background: var(--paper);
  color: var(--ink);
}
.board-expanded .match-feedback:has(form:not([hidden]), [role="alert"], #notice:not(:empty)) { margin-bottom: .6rem; }
.board-expanded .match-details :is(.chess-notice, .join-game) { margin: 0; }
.board-expanded .invite-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .35rem .6rem;
  margin: 0;
}
.board-expanded .invite-section label, .board-expanded .move-section h3 {
  margin: 0;
  font: 600 1rem/1.25 Georgia, "Times New Roman", serif;
}
.board-expanded .invite-controls { display: contents; }
.board-expanded #copy-link { grid-area: 1 / 2; background: var(--ink); border-color: var(--ink); color: var(--paper); }
.board-expanded #copy-link:hover { background: #395068; }
.board-expanded #share-invite:not([hidden]) { display: inline-flex; grid-area: 1 / 1; color: var(--ink); background: var(--gold); border-color: var(--ochre); }
@container (max-width: 24rem) {
  .board-expanded .invite-section:has(#share-invite:not([hidden])) #copy-link { width: 44px; padding: 0; }
  .board-expanded .invite-section:has(#share-invite:not([hidden])) #copy-link span.board-view-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}
.board-expanded .invite-section:has(#share-invite:not([hidden])) label,
.board-expanded .invite-controls input:not(.manual-copy) { display: none; }
.board-expanded .invite-controls input { grid-column: 1 / -1; background: #fff8e9; }
.board-expanded #invite-notice { grid-column: 1 / -1; color: var(--ink); }
.board-expanded .move-section { padding: 0; margin: 0; border: 0; }
.board-expanded .move-list { max-height: clamp(2rem, calc(100cqh - 3rem), 12rem); }
.board-expanded .board-settings { margin: .65rem 0 0; }
.board-expanded .move-list:empty { padding: 0; }
.board-expanded .move-list:empty::before { margin: 0; }
.board-expanded[data-match-status="waiting"] .move-section,
.board-expanded .match-details:has(.join-game:not([hidden])) .invite-section,
.board-expanded:not([data-match-status="waiting"]) .invite-section { display: none; }
.board-expanded .game-actions { grid-area: actions; }
.board-expanded .piece-guide { margin-top: .65rem; border-bottom: 0; }
.board-expanded .piece-guide summary { min-height: 44px; }
.board-expanded .piece-guide ul { grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.25rem), 1fr)); }
.board-expanded .piece-guide li { font-size: .9375rem; }
.board-expanded .piece-guide svg { width: 2rem; height: 2rem; }

.board-expanded .board-toolbar {
  grid-area: tools;
  position: sticky;
  inset-block-end: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  padding: .25rem;
  border-top: 1px solid #536170;
  background: var(--table-ink);
}
.board-expanded .board-toolbar button { gap: .4rem; padding: .35rem; border: 0; border-radius: 0; color: var(--paper); }
.board-expanded .board-toolbar button + button { border-inline-start: 1px solid #536170; }
.board-expanded .board-toolbar svg { flex: none; color: var(--gold); }
.board-expanded .board-toolbar button:hover, .board-expanded .board-toolbar button:active { background: #33495c; }
.board-expanded .board-toolbar button:focus-visible { outline-color: var(--gold); outline-offset: -3px; }

@media (orientation: portrait) and (max-height: 36em) {
  .board-expanded .match-layout { grid-template-rows: auto minmax(0, max-content) auto minmax(3.5rem, 1fr) auto; }
  .board-expanded .match-status { padding-block: .35rem; }
  .board-expanded .match-details { padding-block: .35rem; }
  .board-expanded .game-actions, .board-expanded .board-toolbar { padding-block: 0; }
}

@media (orientation: landscape) {
  .board-expanded .match-layout {
    --panel-width: clamp(12rem, calc(100vw - 100dvh), 26rem);
    container-type: size;
    min-height: 14rem;
    grid-template:
      "board status"  auto
      "board top"     auto
      "board bottom"  auto
      "board details" minmax(0, 1fr)
      "actions tools" auto / minmax(0, 1fr) var(--panel-width);
    max-width: calc(100dvh + 26rem);
    margin-inline: auto;
  }
  .board-expanded .board-stage { display: contents; }
  .board-expanded .board-stage > * { width: 100%; }
  .board-expanded .board-frame {
    grid-area: board;
    place-self: end center;
    width: auto;
    height: min(100%, calc(100cqi - var(--panel-width)));
    aspect-ratio: 1;
    contain: size;
  }
  .board-expanded .match-layout:not(:has(.game-actions > button:not([hidden]))) .board-frame {
    grid-row-end: -1;
    align-self: center;
  }
  .board-expanded .player:has(+ .board-frame) { grid-area: top; }
  .board-expanded .board-frame + .player { grid-area: bottom; }
  .board-expanded .match-status h2 { font-size: 1.125rem; }
}

@media (orientation: landscape) and (max-height: 19em) {
  .board-expanded .match-status { padding-block: .35rem; }
  .board-expanded .match-details { padding-block: .35rem; }
}
