:root {
  color-scheme: light;
  --paper: #f5f0e8;
  --card: #fffcf7;
  --ink: #282b2a;
  --muted: #6c625a;
  --line: #ded4c8;
  --rust: #ac4026;
  --rust-hover: #89301c;
  --light-square: #f0dfc5;
  --dark-square: #b97856;
  --accent: #f2b573;
  --radius: 10px;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
select,
textarea,
summary {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  color: inherit;
}
button:disabled {
  cursor: default;
  opacity: 0.45;
}
button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #a16e27;
  outline-offset: 3px;
}
button {
  border: 0;
}
a {
  color: inherit;
}
h1,
h2,
p {
  margin: 0;
}
h1,
h2 {
  font-weight: 550;
}
h2 {
  font-size: 15px;
}
svg {
  display: block;
}
[hidden] {
  display: none !important;
}
.site-header {
  max-width: 1190px;
  margin: auto;
  padding: 23px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  gap: 9px;
  align-items: center;
  text-decoration: none;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -1.2px;
}
.brand > svg {
  width: 42px;
  height: 42px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand-subtitle {
  display: block;
  font-family: Inter, "Segoe UI", sans-serif;
  letter-spacing: 2.1px;
  font-size: 8px;
  font-weight: 600;
  margin-top: 1px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 25px;
}
.connection {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}
.connection:before {
  content: "";
  height: 6px;
  width: 6px;
  border-radius: 50%;
  background: #b49a58;
}
.connection.online:before {
  background: #669161;
}
.connection.offline:before {
  background: #af5e4e;
}
.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 11px 19px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.primary {
  background: var(--rust);
  color: #fffef3;
}
.primary:hover:not(:disabled) {
  background: var(--rust-hover);
}
.secondary {
  background: transparent;
  border: 1px solid var(--line);
}
.secondary:hover:not(:disabled) {
  background: #f4e8d9;
  border-color: #bda894;
}
.workspace {
  max-width: 1190px;
  margin: auto;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(310px, 1fr);
  gap: 32px;
  padding: 26px 34px 45px;
}
.play-area {
  min-width: 0;
}
.player-seat {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-left: 27px;
  min-height: 59px;
  padding: 0 0 13px;
}
.avatar {
  display: grid;
  place-items: center;
  background: #a84229;
  color: #f9f8eb;
  border-radius: 9px;
  width: 38px;
  height: 38px;
  font-family: Georgia, serif;
  font-size: 23px;
}
.avatar.human {
  background: #e9dfd2;
  color: #493e35;
}
.player-seat strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.player-seat div > span {
  font-size: 11px;
  color: var(--muted);
}
.turn-indicator {
  margin-left: auto;
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--rust);
  display: flex;
  align-items: center;
  gap: 6px;
  visibility: hidden;
}
.turn-indicator:before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.turn-indicator.active {
  visibility: visible;
}
.thinking .turn-indicator.active:before {
  animation: breathe 1.1s ease-in-out infinite;
}
.board-layout {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 15px;
  align-items: stretch;
}
.evaluation-track {
  border: 1px solid #bca38f;
  position: relative;
  border-radius: 4px;
  background: #292c2d;
  overflow: hidden;
  min-width: 0;
}
.evaluation-track > div {
  position: absolute;
  bottom: 0;
  height: 50%;
  width: 100%;
  background: #fffdf0;
  transition: height 0.4s;
}
.evaluation-track > span {
  position: absolute;
  bottom: 8px;
  left: 50%;
  writing-mode: vertical-rl;
  font-size: 8px;
  transform: translateX(-50%) rotate(180deg);
  color: #292c2d;
  background: #fffdf0;
  padding: 3px 1px;
  font-weight: 600;
  mix-blend-mode: normal;
}
.evaluation-track.flipped > div {
  top: 0;
  bottom: auto;
}
.board-frame {
  position: relative;
  padding: 0;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 4px 13px #233d2812;
}
.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  aspect-ratio: 1;
  user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
}
.square {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--light-square);
  border-radius: 0;
  isolation: isolate;
  touch-action: none;
}
.board-coordinates {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  pointer-events: none;
}
.coordinate-cell {
  position: relative;
}
.square.dark {
  background: var(--dark-square);
}
.square.last {
  background: #f7c98c;
}
.square.dark.last {
  background: #db9f60;
}
.square.selected {
  background: #f9bf80;
  box-shadow: inset 0 0 0 3px #8a3c21;
}
.square.check {
  background: #d99077;
}
.square.legal:after {
  content: "";
  position: absolute;
  z-index: 2;
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: #542b2247;
  pointer-events: none;
}
.square.capture:after {
  width: 87%;
  height: 87%;
  background: transparent;
  border: 5px solid #542b2280;
}
.square:hover:not([aria-disabled="true"]) {
  box-shadow: inset 0 0 0 2px #68332380;
}
.square:focus-visible {
  outline: 3px solid #9c651c;
  outline-offset: -4px;
  z-index: 3;
}
.piece {
  width: 82%;
  height: 82%;
  filter: drop-shadow(0 2px 1px #223d2624);
  pointer-events: none;
}
.piece.white {
  fill: #fffdf0;
  stroke: #4b352d;
  stroke-width: 1.8;
}
.piece.black {
  fill: #2c3031;
  stroke: #171b1d;
  stroke-width: 1.4;
}
.piece * {
  stroke-linejoin: round;
  stroke-linecap: round;
}
.piece.black .detail {
  stroke: #b9b3a9;
}
.piece.white .detail {
  stroke: #6c5041;
}
.coord {
  position: absolute;
  font-size: 10px;
  font-weight: 600;
  z-index: 4;
  color: #67432c;
  pointer-events: none;
}
.dark .coord {
  color: #3a2117;
}
.rank {
  left: 5px;
  top: 4px;
}
.file {
  right: 5px;
  bottom: 3px;
}
.bottom-seat {
  padding: 17px 0 0;
  min-height: 69px;
}
.board-toolbar {
  border-top: 1px solid var(--line);
  margin: 15px 0 0 27px;
  padding-top: 15px;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
}
.board-toolbar > div {
  display: flex;
  gap: 16px;
}
.tool-button {
  background: none;
  padding: 6px 0;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  font-size: 12px;
  white-space: nowrap;
}
.tool-button > span {
  font-size: 19px;
  line-height: 1;
}
.tool-button:hover:not(:disabled) {
  color: #9e351d;
}
.sound-toggle {
  min-width: 36px;
  justify-content: center;
  color: var(--rust);
}
.sound-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sound-muted,
.sound-toggle[aria-pressed="false"] .sound-waves {
  display: none;
}
.sound-toggle[aria-pressed="false"] {
  color: var(--muted);
}
.sound-toggle[aria-pressed="false"] .sound-muted {
  display: block;
}
.board-hint {
  font-size: 10px;
  color: var(--muted);
  text-align: right;
  max-width: 155px;
  line-height: 1.5;
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-width: 0;
  padding-top: 4px;
}
.panel-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.panel-tabs {
  display: flex;
  gap: 4px;
  flex: none;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel-tabs button {
  flex: 1;
  padding: 10px;
  background: transparent;
  border-radius: 6px;
  font-size: 12px;
}
.panel-tabs button[aria-selected="true"] {
  background: var(--ink);
  color: var(--card);
}
.panel-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 19px;
}
[role="tabpanel"]:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 2px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.game-card {
  padding: 18px;
}
.mode-switch {
  padding: 4px;
  background: #efe6dc;
  display: flex;
  border-radius: 7px;
  gap: 3px;
}
.mode-switch button {
  background: none;
  flex: 1;
  font-size: 11px;
  padding: 10px 5px;
  border-radius: 5px;
  white-space: nowrap;
}
.mode-switch button[aria-pressed="true"] {
  background: var(--card);
  box-shadow: 0 1px 4px #263f2614;
  font-weight: 600;
}
.mode-switch button:hover {
  color: #9a3c24;
}
.game-status {
  padding: 25px 2px 22px;
}
h1 {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 28px;
  letter-spacing: -0.7px;
  margin: 9px 0 9px;
  line-height: 1.15;
}
.game-status p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.match-controls {
  display: flex;
  gap: 8px;
}
.match-controls > .button {
  flex: 1;
  padding-left: 10px;
  padding-right: 10px;
}
.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 17px;
}
.muted {
  color: var(--muted);
  font-size: 11px;
}
.move-columns,
.move-row {
  display: grid;
  grid-template-columns: 40px 1fr 1fr;
  gap: 4px;
  padding: 0 20px;
}
.move-columns {
  font-size: 8px;
  letter-spacing: 1.3px;
  color: var(--muted);
  padding-bottom: 12px;
  border-bottom: 1px solid #e9dfd2;
}
.move-list {
  height: 205px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #ccd2c2 transparent;
}
.move-row {
  font-size: 13px;
  line-height: 35px;
  font-variant-numeric: tabular-nums;
}
.move-row:nth-child(even) {
  background: #f6efe6;
}
.move-row > span:first-child {
  color: #6e6258;
  font-size: 11px;
}
.move-row .latest {
  color: #9e351d;
  font-weight: 700;
}
.empty-history {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 11px;
  color: #6e6258;
  font-size: 11px;
}
.moves-footer {
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #e9dfd2;
  font-size: 10px;
  color: var(--muted);
}
.text-button {
  background: none;
  padding: 4px 0;
  font-size: 11px;
  color: var(--rust);
  font-weight: 550;
  white-space: nowrap;
}
.text-button:hover {
  color: #89301c;
}
.analysis-card summary,
.position-card summary {
  padding: 16px 19px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
}
.analysis-card summary:after,
.position-card summary:after {
  content: "＋";
  margin-left: auto;
  font-size: 15px;
  font-weight: 400;
  color: var(--muted);
}
details[open] > summary:after {
  content: "−";
}
.subtle {
  font-weight: 400;
  font-size: 10px;
  color: var(--muted);
}
.analysis-content {
  padding: 0 19px 17px;
}
.analysis-numbers {
  display: grid;
  grid-template-columns: 1fr 0.7fr 1fr;
  gap: 10px;
  padding: 3px 0 16px;
}
.analysis-numbers span,
.variation > span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  margin-bottom: 7px;
}
.analysis-numbers strong {
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.4px;
}
.variation {
  border-top: 1px solid #e9dfd2;
  padding-top: 12px;
}
.variation p {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 10px;
  line-height: 1.7;
  color: #6c5041;
  overflow-wrap: anywhere;
}
.position-content {
  padding: 0 19px 18px;
}
.fen-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--muted);
}
code {
  display: block;
  overflow-wrap: anywhere;
  font-size: 10px;
  line-height: 1.7;
  background: #f1e9df;
  padding: 9px;
  margin: 6px 0 17px;
  border-radius: 5px;
}
textarea {
  resize: vertical;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  background: #fffcf7;
  font-size: 11px;
  line-height: 1.6;
  margin: 7px 0 10px;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--ink);
}
.position-content label {
  font-size: 11px;
}
.position-content .button {
  width: 100%;
  min-height: 36px;
  padding: 8px;
}
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  box-shadow: 0 4px 20px #25352c20;
  padding: 14px 20px;
  background: #fffdf5;
  border: 1px solid #c9cbb7;
  border-radius: 9px;
  font-size: 12px;
  max-width: min(90vw, 460px);
  text-align: center;
}
.toast.error {
  border-color: #ad705f;
  color: #8e4538;
}
dialog {
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 27px;
  max-width: 560px;
  width: calc(100% - 32px);
  box-shadow: 0 25px 100px #1e352d30;
}
dialog::backdrop {
  background: #1b302c66;
  backdrop-filter: blur(3px);
}
.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 25px;
}
.dialog-heading h2 {
  font-family: Georgia, serif;
  font-size: 30px;
  font-weight: 400;
  margin-top: 7px;
  letter-spacing: -0.6px;
}
.icon-button {
  background: transparent;
  font-size: 25px;
  line-height: 1;
  padding: 2px 5px;
  color: #6e6258;
}
fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 22px;
  min-width: 0;
}
legend {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 9px;
}
.choice-row {
  display: flex;
  gap: 10px;
}
.choice {
  border: 1px solid var(--line);
  padding: 13px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  cursor: pointer;
  min-width: 0;
}
.choice:has(input:checked) {
  border-color: #b65737;
  background: #f9eadb;
}
.choice input {
  accent-color: var(--rust);
  margin: 0;
  flex-shrink: 0;
}
.choice strong {
  font-size: 12px;
  font-weight: 550;
}
.time-settings {
  display: flex;
  gap: 13px;
}
.time-settings > label {
  flex: 1;
  font-size: 10px;
  color: var(--muted);
}
select {
  display: block;
  width: 100%;
  padding: 10px 26px 10px 10px;
  background: #fffaf3;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 12px;
  margin-top: 6px;
}
.field-note {
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 9px;
}
.dialog-footer {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.promotion-choices {
  display: flex;
  gap: 10px;
  margin: 22px 0;
}
.promotion-choices button {
  background: #f4e8d9;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 5px;
  flex: 1;
  font-size: 11px;
}
.promotion-choices button:hover {
  background: #f1d5b8;
}
.promotion-choices .piece {
  width: 54px;
  height: 54px;
}
#promotion-dialog {
  max-width: 420px;
}
#promotion-dialog h2 {
  font-family: Georgia, serif;
  font-size: 27px;
  margin-bottom: 9px;
}
#promotion-dialog > .button {
  width: 100%;
}
@keyframes breathe {
  50% {
    opacity: 0.25;
  }
}
@media (min-width: 1400px) {
  .workspace {
    padding-top: 37px;
  }
  .sidebar {
    gap: 18px;
  }
  .move-list {
    height: 222px;
  }
}
@media (max-width: 980px) {
  .workspace {
    gap: 25px;
    padding-left: 23px;
    padding-right: 23px;
    grid-template-columns: minmax(0, 1.5fr) minmax(285px, 1fr);
  }
  .site-header {
    padding-left: 23px;
    padding-right: 23px;
  }
  .board-hint {
    display: none;
  }
  .board-layout {
    grid-template-columns: 9px minmax(0, 1fr);
    gap: 10px;
  }
  .player-seat,
  .board-toolbar {
    margin-left: 19px;
  }
  .mode-switch button {
    font-size: 10px;
  }
}
@media (max-width: 760px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    max-width: 620px;
    gap: 27px;
    padding: 20px 19px 35px;
  }
  .site-header {
    padding: 18px 19px;
  }
  .brand {
    font-size: 28px;
  }
  .brand > svg {
    width: 34px;
    height: 34px;
  }
  .brand-subtitle {
    font-size: 7px;
    letter-spacing: 1.9px;
  }
  .header-actions {
    gap: 12px;
  }
  .header-actions > .button {
    padding: 10px 12px;
    min-height: 38px;
  }
  .connection {
    font-size: 0;
    gap: 0;
  }
  .connection:before {
    width: 7px;
    height: 7px;
  }
  .sidebar {
    gap: 14px;
    padding-top: 0;
  }
  .mode-switch button {
    font-size: 12px;
  }
  .game-status {
    padding-top: 21px;
  }
  .move-list {
    height: 190px;
  }
  .board-hint {
    display: block;
    max-width: 150px;
  }
  .player-seat {
    min-height: 56px;
  }
  .square .coord {
    font-size: 9px;
  }
  .evaluation-track > span {
    font-size: 7px;
  }
  .choice-row {
    gap: 7px;
  }
  .choice {
    padding: 10px;
    gap: 7px;
  }
  dialog {
    padding: 22px;
  }
  .dialog-heading h2 {
    font-size: 27px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Crustacean: rust, shell and ink. */
.brand > svg {
  color: var(--rust);
  width: 48px;
  height: 48px;
  stroke-width: 2.1;
}
.brand-subtitle {
  color: var(--rust);
  font-size: 8px;
  letter-spacing: 1.5px;
  margin-top: 4px;
}
.site-header {
  border-bottom: 2px solid var(--ink);
}
.live-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 19px 27px;
  font-size: 12px;
  font-weight: 650;
}
#board-state {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
#board-state.in-check {
  color: #a32f20;
  background: #f8d5c5;
  padding: 5px 8px;
  border-radius: 4px;
}
.player-seat:has(.turn-indicator.active) .avatar {
  box-shadow:
    0 0 0 3px var(--paper),
    0 0 0 4px var(--rust);
}
.game-status {
  padding: 24px 2px 18px;
}
h1 {
  font-weight: 650;
  font-size: 27px;
}
.game-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 0 20px;
  padding: 15px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  gap: 12px;
}
.game-facts dt {
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 6px;
}
.game-facts dd {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.board-frame {
  border-radius: 4px;
  box-shadow: 0 8px 24px #50352215;
}
.square.moving {
  z-index: 5;
}
.square.drag-source .piece {
  opacity: 0.2;
}
.square.drop-target {
  box-shadow: inset 0 0 0 4px #713c24;
}
.square:has(.piece):not([aria-disabled="true"]) {
  cursor: grab;
}
.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%) scale(1.08);
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 30;
  filter: drop-shadow(0 8px 6px #2b211840);
}
.drag-ghost .piece {
  width: 82%;
  height: 82%;
}
.button {
  transition:
    background 0.16s,
    transform 0.16s;
}
.button:active:not(:disabled) {
  transform: translateY(1px);
}
.move-row .latest {
  animation: move-arrival 0.25s ease-out;
}
dialog[open] {
  animation: dialog-arrival 0.18s ease-out;
}
@keyframes move-arrival {
  from {
    background: #f2c28a;
  }
  to {
    background: transparent;
  }
}
@keyframes dialog-arrival {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (max-width: 980px) {
  .live-strip {
    margin-left: 19px;
  }
}
@media (max-width: 760px) {
  .brand {
    font-size: 23px;
    letter-spacing: -0.8px;
    gap: 7px;
  }
  .brand > svg {
    width: 36px;
    height: 36px;
  }
  .brand-subtitle {
    font-size: 6px;
    letter-spacing: 1px;
  }
  .site-header {
    padding: 17px 15px;
  }
  .workspace {
    padding: 18px 12px 30px;
  }
  .live-strip {
    margin-bottom: 15px;
  }
  .board-hint {
    font-size: 10px;
    max-width: 140px;
  }
}
@media (max-width: 360px) {
  .header-actions {
    gap: 7px;
  }
  .brand {
    font-size: 21px;
  }
  .board-hint {
    display: none;
  }
}

/* Size the playing surface from both viewport dimensions on desktop. */
@media (min-width: 900px) and (min-height: 560px) {
  .site-header {
    height: 72px;
    padding: 12px 24px;
  }
  .brand {
    font-size: 26px;
  }
  .brand > svg {
    width: 40px;
    height: 40px;
  }
  .workspace {
    --board-size: min(720px, calc(100dvh - 256px));
    grid-template-columns: minmax(0, calc(var(--board-size) + 27px)) minmax(
        300px,
        340px
      );
    justify-content: center;
    align-items: start;
    grid-template-rows: minmax(0, 1fr);
    gap: 24px;
    height: calc(100dvh - 72px);
    padding: 12px 24px;
    max-width: 1190px;
  }
  .live-strip {
    min-height: 20px;
    margin-bottom: 8px;
  }
  .player-seat {
    min-height: 44px;
    padding: 0 0 8px;
  }
  .avatar {
    width: 32px;
    height: 32px;
    font-size: 20px;
  }
  .player-seat strong {
    font-size: 13px;
    line-height: 16px;
    margin-bottom: 2px;
  }
  .player-seat div > span {
    display: block;
    line-height: 14px;
  }
  .bottom-seat {
    min-height: 48px;
    padding: 8px 0;
  }
  .board-layout {
    grid-template-columns: 12px minmax(0, 1fr);
    gap: 15px;
  }
  .player-seat,
  .board-toolbar,
  .live-strip {
    margin-left: 27px;
  }
  .board-toolbar {
    margin-top: 0;
    padding-top: 0;
    min-height: 40px;
  }
  .sidebar {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 10px;
    padding-top: 0;
  }
  .game-card {
    padding: 14px;
  }
  .game-status {
    padding: 13px 0 12px;
  }
  .game-status h1 {
    font-size: 23px;
    margin: 6px 0;
  }
  .game-facts {
    padding: 10px 0;
    margin-bottom: 12px;
  }
  .panel-stack {
    overflow: hidden;
  }
  [role="tabpanel"] {
    flex: 1;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
  }
  .moves-card {
    display: flex;
    flex-direction: column;
  }
  .card-heading {
    padding: 12px 16px;
    flex: none;
  }
  .move-columns {
    padding-bottom: 8px;
    flex: none;
  }
  .move-list {
    flex: 1;
    height: auto;
    min-height: 0;
    overscroll-behavior: contain;
  }
  .moves-footer {
    padding: 8px 16px;
    flex: none;
  }
  .empty-history {
    min-height: 60px;
    gap: 5px;
  }
}

#board-pause {
  display: none;
}
dialog {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (max-width: 899px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    max-width: 600px;
    gap: 16px;
    padding: 12px max(12px, env(safe-area-inset-right))
      max(20px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }
  .site-header {
    padding: 12px max(12px, env(safe-area-inset-right)) 12px
      max(12px, env(safe-area-inset-left));
  }
  .live-strip {
    margin-bottom: 10px;
    min-height: 20px;
  }
  .player-seat {
    min-height: 44px;
    padding-bottom: 7px;
  }
  .player-seat strong {
    line-height: 16px;
    margin-bottom: 2px;
  }
  .player-seat div > span {
    display: block;
    line-height: 14px;
  }
  .avatar {
    width: 30px;
    height: 30px;
    font-size: 19px;
  }
  .bottom-seat {
    min-height: 44px;
    padding: 7px 0;
  }
  .board-toolbar {
    margin-top: 4px;
    padding-top: 0;
  }
  .board-toolbar > div {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }
  .sound-toggle {
    min-width: 44px;
  }
  #board-pause {
    display: inline-flex;
  }
  .board-hint {
    display: none;
  }
  .tool-button,
  .text-button,
  .icon-button,
  .button,
  .header-actions > .button,
  .panel-tabs button,
  .mode-switch button {
    min-height: 44px;
  }
  .icon-button {
    min-width: 44px;
  }
  .game-card {
    padding: 12px;
  }
  .game-status {
    padding: 12px 0;
  }
  .game-status h1 {
    font-size: 23px;
    margin: 5px 0;
  }
  .game-facts {
    margin-bottom: 12px;
    padding: 10px 0;
  }
  .panel-stack {
    gap: 8px;
  }
  .move-list {
    height: 160px;
  }
  textarea,
  select {
    font-size: 16px;
  }
  .position-content .button {
    min-height: 44px;
  }
  .choice {
    min-height: 62px;
  }
  .promotion-choices {
    gap: 6px;
  }
  .promotion-choices .piece {
    width: min(48px, 100%);
  }
  dialog {
    padding: 18px;
    max-height: calc(100dvh - 24px);
  }
  .dialog-heading {
    margin-bottom: 18px;
  }
  .dialog-heading h2 {
    font-size: 25px;
  }
  .toast {
    bottom: max(16px, env(safe-area-inset-bottom));
  }
}
@media (min-width: 640px) and (max-width: 899px) and (max-height: 540px) {
  .workspace {
    max-width: none;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 1fr);
  }
  .play-area {
    position: sticky;
    top: 12px;
  }
}
.result-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #282b2a59;
}
.result-card {
  width: min(100%, 320px);
  padding: clamp(16px, 3vw, 28px);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 12px 45px #282b2a40;
  text-align: center;
  animation: dialog-arrival 0.2s ease-out;
}
.result-symbol {
  display: block;
  color: var(--rust);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 3px;
  margin-bottom: 8px;
}
.result-card h2 {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 700;
  letter-spacing: -0.7px;
}
.result-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 10px 0 20px;
}
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.result-actions .button {
  min-height: 44px;
}
.result-overlay[data-outcome="win"] .result-symbol {
  color: #386243;
}
#show-result {
  margin-left: auto;
}
#result-title:focus {
  outline: none;
}
@media (max-width: 360px) {
  .result-card {
    padding: 14px;
  }
  .result-card p {
    margin: 7px 0 12px;
  }
  .result-symbol {
    margin-bottom: 4px;
    font-size: 14px;
  }
}
