.chess-dialog {
  --chess-ink: #eaf4ef;
  --chess-muted: #a9c0b6;
  --chess-accent: #37dfa6;
  --chess-border: #3a5147;
  box-sizing: border-box;
  width: min(720px, calc(100vw - 24px));
  max-width: 100%;
  max-height: calc(100dvh - 24px);
  padding: 0 18px 20px;
  overflow-y: auto;
  border: 1px solid var(--chess-border);
  border-radius: 18px;
  background: #111b17;
  color: var(--chess-ink);
}
.chess-dialog::backdrop { background: #000b; }
.chess-dialog [hidden] { display: none !important; }
.chess-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--chess-border);
  background: #111b17;
}
.chess-header h2, .chess-room h3, .chess-lobby-view h3, .chess-dialog p { margin: 0; }
.chess-navigation-actions { display: flex; align-items: center; }
.chess-dialog button, .chess-dialog input, .chess-dialog summary { font: inherit; }
.chess-dialog button {
  box-sizing: border-box;
  min-height: 40px;
  padding: 7px 12px;
  border: 1px solid var(--chess-border);
  border-radius: 9px;
  color: inherit;
  background: #1d2c25;
  cursor: pointer;
}
.chess-dialog button.chess-icon { min-width: 42px; padding: 0; font-size: 24px; }
.chess-dialog button.chess-bell {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  min-width: 40px;
  min-height: 44px;
  border: 0;
  background: none;
  color: #46a68a;
}
.chess-bell svg { width: 22px; height: 22px; }
.chess-bell-count {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 15px;
  padding: 1px 3px;
  border-radius: 8px;
  background: #b7374a;
  color: white;
  font-size: 9px;
  line-height: 13px;
}
.chess-dialog button.chess-primary { border-color: #3cba91; background: #1c5340; }
.chess-dialog button.chess-danger { border-color: #975962; background: #512d32; }
.chess-dialog button:disabled { opacity: .58; cursor: default; }
.chess-dialog :is(button,input,summary):focus-visible { outline: 3px solid var(--chess-accent); outline-offset: 2px; }
.chess-dialog .chess-status { margin: 10px 0; color: var(--chess-muted); }
.chess-dialog .chess-status:empty { display: none; }
.chess-dialog .chess-error { color: #ffb4ad; }
.chess-lobby-view, .chess-room { display: grid; gap: 12px; margin-top: 14px; }
.chess-list { display: grid; gap: 8px; }
.chess-table-card, .chess-create, .chess-history {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--chess-border);
  border-radius: 11px;
  background: #1a2922;
}
.chess-table-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chess-table-card > div { min-width: 0; }
.chess-table-card :is(p,strong) { overflow-wrap: anywhere; }
.chess-table-card p { margin-top: 3px; color: var(--chess-muted); font-size: .87rem; }
.chess-table-card button { flex-shrink: 0; }
.chess-dialog summary { cursor: pointer; min-height: 28px; }
.chess-create .chess-form, .chess-history .chess-list { margin-top: 8px; }
.chess-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chess-field { display: grid; gap: 4px; min-width: 0; }
.chess-field input {
  box-sizing: border-box;
  min-width: 0;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--chess-border);
  border-radius: 8px;
  color: inherit;
  background: #16221d;
}
.chess-actions { display: flex; align-items: stretch; gap: 4px; }
.chess-rule { padding: 0 4px 4px; font-size: 13px; }
.chess-room { position: relative; }
.chess-money-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 18px; }
.chess-entry-amount, .chess-pot-amount, .chess-wallet-amount { font-variant-numeric: tabular-nums; }
.chess-wallet-amount { text-align: right; min-height: 18px; line-height: 18px; }
.chess-chip-layer { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 6; }
.chess-chip-flight { position: absolute; transform: translate(-50%,-50%); white-space: nowrap; border: 1px solid #c99649; border-radius: 999px; padding: 4px 8px; background: #44301f; color: #ffe0a8; font-size: 12px; font-weight: 700; box-shadow: 0 2px 6px #0005; }
.chess-chip-flight[data-arrived='true'] { color: #efffe9; background: #246444; }
.chess-turn { display: flex; align-items: center; min-height: 42px; padding: 0 4px; gap: 6px; }
.chess-turn .chess-banner { flex: 1; font-size: 13px; }
.chess-turn .chess-in-check { color: #ffa497; }
.chess-turn .chess-match-button { min-width: 104px; min-height: 38px; }
.chess-turn .chess-turn-stand { flex: none; }
.chess-turn .chess-turn-stand button.table-stand-toggle:not([hidden]) {
  width: 86px;
  min-height: 42px;
  padding: 3px 4px;
  gap: 3px;
  font-size: 11px;
}
.chess-turn .chess-turn-stand button.table-stand-toggle > span {
  min-width: 0;
  line-height: 12px;
  white-space: normal;
}
.chess-spectator-status { padding: 0 4px 4px; font-size: 12px; color: var(--chess-muted); }
.chess-spectator-voice { padding: 0 8px 4px; text-align: right; font-size: 11px; }
.chess-clocks { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; }
.chess-clocks:is(.chess-rival-clock,.chess-own-clock) { grid-template-columns:minmax(0,1fr);width:min(100%,480px);margin-inline:auto; }
.chess-clock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  align-content: start;
  gap: 2px 4px;
  min-width: 0;
  min-height: 48px;
  padding: 5px 8px;
  border-radius: 8px;
  background: #232725;
}
.chess-clock span { grid-column: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.chess-clock strong { grid-column: 1; font: 18px/1.1 'IBM Plex Mono', monospace; letter-spacing: .075em; }
.chess-clock-voice { grid-column: 2; grid-row: 1 / 3; }
.chess-clock-voice:empty { display: none; }
.chess-dialog .chess-clock-voice > button { min-width: 44px; min-height: 44px; padding: 0; }
.chess-dialog .chess-clock-voice > button[aria-pressed=true] { color: #ffe0b4; border-color: #b68c58; background: #382b1c; }
.chess-voice .table-voice-controls {
  position: relative;
  inset: auto;
  z-index: auto;
  justify-content: flex-end;
  gap: 6px;
  max-width: none;
}
.chess-voice .table-voice-status { position: absolute; top: 100%; right: 0; width: max-content; max-width: min(80vw, 300px); z-index: 2; }
.chess-voice .table-voice-people .table-voice-off-mark { display: none; }
.chess-voice .table-voice-peers { inset: 48px 0 auto auto; width: min(260px, 80vw); box-sizing: border-box; }
.chess-board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  width: min(100%, 388px, max(184px, calc(100dvh - 358px)));
  justify-self: center;
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
}
.chess-board:empty { display: none; }
.chess-dialog .chess-square, .chess-preview-board .chess-square {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  --chess-coordinate: #5d7441;
  background: #eeeed3;
}
.chess-board .chess-square[data-tone=dark] { --chess-coordinate: #f0f0d6; background: #779653; }
.chess-board .chess-square.chess-active-piece { background: #f1f0d8; }
.chess-board .chess-square.chess-active-piece[data-tone=dark] { background: #7c9d57; }
.chess-board .chess-square.chess-last-move { background: #f1ee80; }
.chess-board .chess-square.chess-last-move[data-tone=dark] { background: #bfcb4c; }
.chess-board .chess-square[aria-pressed=true] { background: #ece56a; }
.chess-board .chess-square[aria-pressed=true][data-tone=dark] { background: #adc147; }
.chess-board .chess-square.chess-checked, .chess-board .chess-square.chess-checked[data-tone=dark] { background: #dc8370; }
.chess-dialog .chess-square:focus-visible {
  outline: 3px solid #0c684b;
  outline-offset: -3px;
  z-index: 1;
}
.chess-target::after {
  position: absolute;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #515b3449;
  content: '';
  pointer-events: none;
}
.chess-target-capture::after { box-sizing: border-box; width: 89%; background: none; border: 2px solid #515b3449; }
.chess-piece {
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.chess-square > .chess-piece { position: absolute; inset: 0; }
.chess-lifted .chess-piece { visibility: hidden; }
.chess-drag-piece {
  position: fixed;
  z-index: 3;
  width: var(--chess-piece-size);
  height: var(--chess-piece-size);
  transform: translate(-50%, -50%);
}
.chess-coordinate {
  position: absolute;
  z-index: 1;
  color: var(--chess-coordinate);
  font: 700 17cqw/1 sans-serif;
  pointer-events: none;
}
.chess-square { container-type: inline-size; }
.chess-coordinate-rank { top: 4%; left: 4.5%; }
.chess-coordinate-file { right: 4.5%; bottom: 4%; }
.chess-inline-preview {
  display: grid;
  align-content: space-between;
  justify-items: center;
  min-height: 210px;
  padding: 5px 10px 7px;
  border-radius: 12px;
  background: #172720;
}
.chess-inline-preview:not(:has(.chess-preview-board > .chess-square)) { align-content: center; }
.chess-inline-preview:empty::before { content: ''; width: min(100%, 182px); aspect-ratio: 1; }
.chess-inline-preview:empty::after { content: ''; min-height: 22px; }
.chess-preview-board { width: min(100%, 182px); border-radius: 0; touch-action: auto; }
.chess-preview-status { min-height: 22px; margin: 0; font-size: 11px; color: #d1e5da; }
.chess-match[open] {
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto auto auto;
  height: min(780px, calc(100dvh - 24px));
  padding: 4px 8px;
  overflow: hidden;
  background: #101713;
  font-family: Roboto, Arial, sans-serif;
}
.chess-match .chess-header {
  grid-template-columns: 44px minmax(0,1fr) auto;
  gap: 7px;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: #101713;
}
.chess-match .chess-header h2 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; font-size: 17px; }
.chess-match button.chess-back { width: 44px; min-height: 44px; border: 0; border-radius: 50%; background: linear-gradient(#285448,#103b2c); font-size: 17px; }
.chess-match .chess-content { overflow: auto; overscroll-behavior: contain; }
.chess-match .chess-room { gap: 0; margin: 6px 0 0; }
.chess-board-space, .chess-captures { display: contents; }
.chess-match .table-voice-button { width: 42px; min-width: 42px; min-height: 42px; padding: 0; border-radius: 50%; background: linear-gradient(#36423a,#202a24); }
.chess-capture-row { display: grid; grid-template-columns: minmax(82px, 109px) minmax(0, 1fr); align-items: center; min-height: 27px; }
.chess-capture-row > span:first-child, .chess-match .chess-recent { padding: 0 4px; color: #a3b9ab; font-size: 11px; }
.chess-capture-tray {
  min-height: 27px;
  overflow: hidden;
  padding: 0 6px;
  border-radius: 5px;
  background: #b8cabd;
  color: #17251e;
  font: 19px/27px 'DejaVu Sans','Segoe UI Symbol','Apple Symbols',sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chess-capture-tray[data-color=w] { background: #263c32; color: #f4f7f2; }
.chess-match .chess-recent { min-height: 25px; line-height: 25px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chess-match .chess-actions { padding: 2px; }
.chess-actions button { flex: 1; min-width: 0; min-height: 48px; padding: 3px; text-align: center; }
.chess-command-spacer { flex: 1; min-width: 0; }
.chess-dialog button.chess-match-button { color: #eef4ef; border-color: #555; background: linear-gradient(#363636,#1b1b1b); box-shadow: inset 0 1px 2px #ffffff25, 0 1px 2px #0008; font-size: 14px; }
.chess-dialog button.chess-destructive { color: #ff5d62; }
.chess-dialog button.chess-seat[data-color=w] { background: #28533e; color: #f5fff8; }
.chess-dialog button.chess-seat[data-color=b] { background: #c0cbc2; color: #101912; }
.chess-dialog button.chess-seat { display: flex; justify-content: center; align-items: center; gap: 6px; font-size: 13px; }
.chess-dialog button.chess-seat:disabled { opacity: .45; }
.chess-seat-glyph { font: 19px/1 'Segoe UI Symbol','Apple Symbols',sans-serif; }
.chess-match .chess-draw-offer { padding: 4px; font-size: 13px; }
.chess-chat { min-width: 0; padding: 4px 6px; border-radius: 14px; background: #151e19; }
.chess-chat-log { display: grid; gap: 5px; max-height: min(124px, 20dvh); overflow: auto; }
.chess-chat-message { justify-self: start; max-width: 85%; padding: 4px 8px; border-radius: 10px; background: #26382f; overflow-wrap: anywhere; }
.chess-chat-message[data-mine=true] { justify-self: end; background: #204436; }
.chess-chat-message strong { color: var(--chess-muted); font-size: 11px; }
.chess-chat-message p { font-size: 14px; }
.chess-chat-status:not(:empty) { margin: 3px 0; font-size: 12px; color: var(--chess-muted); }
.chess-chat-form { display: flex; align-items: center; gap: 6px; }
.chess-chat-form input { flex: 1; width: 0; min-height: 44px; padding: 0 14px; border: 0; border-radius: 24px; background: #25342c; color: inherit; }
.chess-chat-form input::placeholder { color: var(--chess-muted); }
.chess-dialog button.chess-send {
  display: grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #16865b;
  color: #f4fff9;
}
.chess-send svg { width: 21px; height: 21px; }
.chess-dialog button.chess-send:disabled { opacity: .42; }
.chess-subdialog { width: min(460px, calc(100vw - 28px)); padding: 14px; }
.chess-subdialog .chess-list { margin: 10px 0; }
.chess-subdialog button.chess-history-match { text-align: left; }
.chess-history-move { padding: 7px 18px; background: #18221d; }
.chess-history-move .chess-capture-tray { display: block; width: max-content; margin-top: 3px; }
.chess-confirm-actions { display: flex; gap: 8px; justify-content: end; margin-top: 14px; }
.chess-community-options { display: grid; gap: 6px; margin-top: 14px; }
.chess-community .chess-community-options button { text-align: left; }
.chess-native-sheet[open] {
  display: flex;
  flex-direction: column;
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: #3f3f3f;
  color: #eef4ef;
  font-family: Roboto, Arial, sans-serif;
}
.chess-native-sheet::backdrop { backdrop-filter: none; }
.chess-native-sheet h3 { margin: 0; padding: 20px 24px 8px; font-size: 20px; font-weight: 400; }
.chess-native-sheet > p { padding: 0 24px 8px; }
.chess-native-sheet .chess-confirm-actions { margin: 0; padding: 8px 12px; }
.chess-native-sheet .chess-confirm-actions button {
  min-height: 40px;
  border: 0;
  background: none;
  color: #4accaa;
  font-size: 14px;
  text-transform: uppercase;
}
.chess-promotion-options, .chess-native-sheet .chess-list { overflow: auto; min-height: 0; }
.chess-promotion-options { display: grid; }
.chess-native-sheet .chess-promotion-options button, .chess-native-sheet button.chess-history-match {
  min-height: 48px;
  padding: 8px 24px;
  border: 0;
  border-radius: 0;
  background: none;
  font-size: 16px;
  font-weight: 400;
  text-align: start;
}
.chess-native-sheet .chess-list { margin: 0; gap: 0; }
.chess-history-sheet .chess-list:has(button, .chess-history-move) { background: #18221d; }
.chess-history-sheet .chess-list > p { padding: 0 24px 8px; }
.chess-native-sheet .chess-history-move { font-size: 15px; }
@media (max-width: 560px) {
  .chess-dialog { width: calc(100vw - 14px); max-height: calc(100dvh - 14px); padding: 0 11px 14px; }
  .chess-subdialog { padding: 14px; }
}
@media (max-width: 360px) {
  .chess-form { grid-template-columns: 1fr; }
  .chess-table-card { align-items: start; flex-direction: column; }
}
@media (max-height: 499px), (orientation: landscape) and (max-height: 550px) {
  .chess-inline-preview { min-height: 180px; }
  .chess-inline-preview:empty::before { content: ''; width: min(100%, 182px); aspect-ratio: 1; }
.chess-inline-preview:empty::after { content: ''; min-height: 22px; }
.chess-preview-board { width: min(100%, 152px); }
}

html:has(dialog.chess-match[open]), body:has(dialog.chess-match[open]) {
  overflow: hidden;
  overscroll-behavior: none;
}
.chess-match[open] {
  position: fixed;
  inset: var(--chess-visible-top, 0px) auto auto var(--chess-visible-left, 0px);
  width: var(--chess-visible-width, 100%);
  height: var(--chess-visible-height, 100dvh);
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: max(4px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
    max(4px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  grid-template-areas: 'header' 'room' 'status' 'retry' 'chat';
  overscroll-behavior: none;
  --chess-board-size: clamp(184px, calc(var(--chess-visible-height, 100dvh) - 395px), 388px);
}
.chess-match > :is(.chess-header, .chess-content, .chess-status, .chess-chat) {
  width: min(100%, 720px);
  box-sizing: border-box;
  justify-self: center;
}
.chess-match .chess-board {
  width: min(100%, var(--chess-board-size));
  width: round(down, min(100%, var(--chess-board-size)), 8px);
}
.chess-match .chess-room { margin-top: 0; }
.chess-match .chess-clocks:is(.chess-rival-clock, .chess-own-clock) { width: 100%; }
.chess-match .chess-clock {
  box-sizing: border-box;
  height: 43px;
  min-height: 43px;
  align-content: center;
  padding: 0 8px;
}
.chess-match .chess-clock span { line-height: 15px; }
.chess-match .chess-clock strong { letter-spacing: normal; }
.chess-match .chess-clock-voice > button { min-height: 40px; }
.chess-match .chess-turn-location:not(:has(.table-location-pin:not([hidden]))) { display: none; }
.chess-match .chess-turn-location .table-location-pin:not([hidden]) {
  position: static;
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
}
.chess-match .chess-actions :is(.chess-match-button, .chess-seat) { border-radius: 8px; }

@media (max-width: 700px), (max-width: 1024px) and (orientation: landscape) and (max-height: 500px) {
  .chess-match .chess-header { grid-area: header; min-height: 44px; }
  .chess-match .chess-content { grid-area: room; overflow: hidden; }
  .chess-match > .chess-status { grid-area: status; margin: 2px 4px; font-size: 12px; }
  .chess-match > button { grid-area: retry; }
  .chess-match > .chess-chat { grid-area: chat; }
  .chess-match .chess-room {
    height: 100%;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(4, auto) minmax(0, 1fr) repeat(5, auto);
    grid-template-areas: 'spectator' 'rule' 'turn' 'clocks' 'board' 'own-clock' 'captures' 'recent' 'actions' 'offer';
  }
  .chess-match .chess-spectator-banner { grid-area: spectator; }
  .chess-match .chess-rule { grid-area: rule; padding-bottom: 2px; font-size: 12px; }
  .chess-match .chess-clocks { grid-area: clocks; gap: 4px; }
  .chess-match .chess-own-clock { grid-area:own-clock; }
  .chess-match .chess-clock { min-height: 0; padding: 3px 6px; }
  .chess-match .chess-clock strong { font-size: 16px; }
  .chess-match .chess-turn { grid-area: turn; min-height: 30px; }
  .chess-match .chess-turn .chess-match-button { min-height: 34px; }
  .chess-match .chess-board-space {
    grid-area: board;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    container-type: size;
  }
  .chess-match .chess-board {
    width: min(100cqi, 100cqb, var(--chess-board-size));
    width: round(down, min(100cqi, 100cqb, var(--chess-board-size)), 8px);
  }
  .chess-match .chess-captures { grid-area: captures; display: grid; }
  .chess-match .chess-capture-row { min-height: 19px; }
  .chess-match .chess-capture-tray { min-height: 19px; font-size: 16px; line-height: 19px; }
  .chess-match .chess-recent { grid-area: recent; min-height: 18px; line-height: 18px; }
  .chess-match .chess-recent:empty { display: none; }
  .chess-match .chess-actions { grid-area: actions; }
  .chess-match .chess-actions button { min-height: 44px; }
  .chess-match .chess-draw-offer { grid-area: offer; }
  .chess-match .chess-chat-log { max-height: min(64px, 10dvh); }
}

@media (max-width: 700px) and (orientation: portrait) {
  .chess-match .chess-content { container: chess-match-room / size; }
  .chess-match .chess-header { min-height: 48px; gap: 0; }
  .chess-match .chess-header .table-voice-controls { gap: 6px; padding-inline: 3px; }
  @container chess-match-room (min-height: 510px) {
    .chess-match .chess-room {
      align-content: start;
      grid-template-rows: repeat(4, auto) minmax(0, max-content) repeat(5, auto);
      --chess-capture-space: 91px;
      --chess-spectator-space: 0px;
      --chess-offer-space: 0px;
    }
    .chess-match .chess-room:has(.chess-spectator-banner:not([hidden])) { --chess-spectator-space: 38px; }
    .chess-match .chess-room:has(.chess-draw-offer:not([hidden])) { --chess-offer-space: 25px; }
    .chess-match .chess-rule { padding: 4px; font-size: 13px; line-height: 18px; }
    .chess-match .chess-clocks { gap: 8px; }
    .chess-match .chess-clock {
      align-content: center;
      gap: 2px 4px;
      min-height: 43px;
      padding: 0 8px;
    }
    .chess-match .chess-clock strong { font-size: 18px; }
    .chess-match .chess-turn, .chess-match .chess-turn .chess-match-button { min-height: 42px; }
    .chess-match .chess-board-space { container-type: normal; }
    .chess-match .chess-board {
      width: min(100%, var(--chess-board-size),
        calc(100cqh - 211px - var(--chess-capture-space) - var(--chess-spectator-space) - var(--chess-offer-space)));
      width: round(down, min(100%, var(--chess-board-size),
        calc(100cqh - 211px - var(--chess-capture-space) - var(--chess-spectator-space) - var(--chess-offer-space))), 8px);
    }
    .chess-match[open] .chess-captures { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .chess-match[open] .chess-capture-row { grid-template-columns: 109px minmax(0, 1fr); min-height: 27px; }
    .chess-match[open] .chess-capture-row > span:first-child { padding: 0 4px; font-size: 11px; }
    .chess-match .chess-capture-tray { min-height: 27px; font-size: 19px; line-height: 27px; }
    .chess-match .chess-recent, .chess-match .chess-recent:empty { display: block; min-height: 25px; line-height: 25px; }
    .chess-match .chess-actions button { min-height: 48px; }
    .chess-match .chess-chat-log { max-height: 96px; }
  }
}

@media (min-width: 440px) and (max-width: 1024px) and (orientation: landscape) and (max-height: 500px) {
  .chess-match .chess-header { grid-template-columns: 44px auto minmax(0, 1fr); }
  .chess-match .chess-navigation-actions { grid-area: 1 / 2; }
  .chess-match .chess-header h2 { grid-area: 1 / 3; }
  .chess-match .chess-room {
    position: relative;
    column-gap: 8px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: repeat(6, auto) minmax(0, 1fr) auto auto;
    grid-template-areas: 'clocks spectator' 'board rule' 'board turn' 'board captures' 'board recent'
      'board .' 'board .' 'own-clock actions' 'own-clock offer';
  }
  .chess-match .chess-rule { line-height: 14px; }
  .chess-match .chess-clock { padding: 2px 6px; }
  .chess-match .chess-clock strong { font-size: 14px; }
  .chess-match .chess-turn { min-height: 25px; }
  .chess-match .chess-actions .chess-match-button { font-size: 13px; }
  .chess-match .chess-draw-offer { padding: 1px 4px; font-size: 11px; line-height: 14px; }
  .chess-match .chess-chat-log { max-height: min(50px, 8dvh); }
}

@media (max-width: 360px) and (orientation: portrait), (min-width: 440px) and (max-width: 1024px) and (orientation: landscape) and (max-height: 500px) {
  .chess-match .chess-captures { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .chess-match .chess-capture-row { grid-template-columns: auto minmax(0, 1fr); }
  .chess-match .chess-capture-row > span:first-child { padding: 0 2px; font-size: 10px; }
}

@media (min-width: 440px) and (max-width: 1024px) and (orientation: landscape) and (max-height: 350px) {
  .chess-match .chess-rule { padding-bottom: 0; }
  .chess-match .chess-clock span { line-height: 13px; }
  .chess-match .chess-turn { min-height: 20px; }
  .chess-match .chess-recent { min-height: 15px; line-height: 15px; }
}

.domino-dialog .chess-field select {
  min-width: 0;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--chess-border);
  border-radius: 8px;
  color: inherit;
  background: #16221d;
  font: inherit;
}
.domino-dialog .chess-field select:focus-visible {
  outline: 3px solid var(--chess-accent);
  outline-offset: 2px;
}
.domino-dialog .chess-create .chess-create { margin-top: 8px; }

html body .chess-match[open] {
  --chess-ink: var(--trio-ink, #eaf4ef);
  --chess-muted: var(--trio-muted, #a9c0b6);
  background: var(--trio-page, #101713);
  color: var(--chess-ink);
}
html body .chess-match .chess-clock {
  background: var(--trio-surface, #232725);
  color: var(--chess-ink);
}
html body .chess-match .chess-header button:is(.chess-back, .display-currency) {
  background: var(--trio-surface, #1d2c25);
  color: var(--chess-ink);
}

/* AppPalette also applies to controls and sheets, not only the board's page. */
html body .chess-dialog {
  --chess-ink: var(--trio-ink, #292d33);
  --chess-muted: var(--trio-muted, #4e5966);
  --chess-border: var(--trio-edge, #c7beb5);
  --chess-accent: var(--trio-success, #2d694f);
  --chess-blue-tile: #d8dce0;
  color: var(--chess-ink);
  background: var(--trio-page, #faf8f5);
}
html body[data-home-theme=dark] .chess-dialog { --chess-blue-tile: #3b4b3a; }
html body[data-home-theme=dark] .chess-match[open] { background: linear-gradient(var(--trio-page), var(--trio-page-end)); }
html body .chess-match .chess-header { color: var(--chess-ink); background: transparent; }
html body .chess-dialog button.chess-match-button {
  color: var(--chess-ink);
  border-color: var(--chess-border);
  background: var(--trio-surface, #fffdfa);
}
html body .chess-dialog button.chess-destructive, html body .chess-dialog :is(.chess-error, .chess-in-check) {
  color: var(--trio-error, #a02432);
}
html body .chess-dialog .chess-pot-amount { color: var(--trio-copper, #965339); }
html body .chess-match .chess-header button:is(.chess-back, .display-currency) {
  background: var(--chess-blue-tile);
  color: var(--trio-blue, #41576e);
}
html body .chess-match :is(.chess-recent, .chess-capture-row > span:first-child) { color: var(--chess-muted); }
html body .chess-dialog :is(input, select, .chess-chat) { background: var(--trio-surface, #fffdfa); color: var(--chess-ink); }
html body .chess-dialog .chess-chat-message { background: var(--chess-blue-tile); color: var(--chess-ink); }
html body .chess-dialog .chess-chat-message[data-mine=true] { background: var(--trio-tint, #eeecea); }
html body .chess-dialog .chess-chat-form input { background: var(--trio-tint, #eeecea); }
/* Voice notices sit under their controls inside the reserved header area. */
html body .chess-match .chess-header:has(.table-voice-status:not([hidden]):not(:empty)) { padding-bottom: 40px; }
html body .chess-match .chess-voice .table-voice-status {
  box-sizing: border-box;
  max-width: min(80vw, 300px);
  -webkit-line-clamp: 2;
  background: var(--trio-surface, #fffdfa);
  color: var(--chess-muted);
  border: 1px solid var(--chess-border);
}
