@font-face {
  font-family: BoardPieces;
  src: url("./pieces.ttf") format("truetype");
  font-display: swap;
}
:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #25362e;
  background: #eeece4;
  --forest: #274b3f;
  --muted: #5d6c60;
  --line: #c9cbbf;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 240px;
}
button {
  font: inherit;
  color: inherit;
}
button:focus-visible,
.moves:focus-visible {
  outline: 3px solid #ad4e1b;
  outline-offset: 2px;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: wait;
  opacity: 0.58;
}
[hidden] {
  display: none !important;
}
.room {
  max-width: 1040px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 34px);
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.heading {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 15px;
}
.crest {
  font:
    28px/1 BoardPieces,
    serif;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--forest);
  color: #fffcf0;
}
h1,
h2,
p {
  margin: 0;
}
h1 {
  font-family: "Songti SC", "Noto Serif CJK SC", ui-serif, serif;
  font-size: clamp(21px, 3vw, 32px);
  line-height: 1.2;
  letter-spacing: 0.045em;
}
.presence {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(175px, 220px);
  align-items: start;
  gap: clamp(18px, 3vw, 36px);
}
.table {
  min-width: 0;
  width: 100%;
  max-width: min(100%, max(380px, calc(100dvh - 178px)));
  justify-self: center;
}
.rail {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  min-height: 43px;
}
.side-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1.5px solid #445047;
  border-radius: 50%;
  flex-shrink: 0;
}
.side-dot.white {
  background: #fffdf2;
}
.side-dot.black {
  background: #273b32;
  border-color: #273b32;
}
.board-hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  text-align: right;
}
.board-wrap {
  position: relative;
}
.view-controls, .view-switch {
  display: inline-flex;
  align-items: center;
}
.view-controls {
  margin-left: auto;
  gap: 8px;
}
.view-switch {
  padding: 2px;
  border: 1px solid #abb3a5;
  border-radius: 6px;
}
.view-controls button {
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  padding: 4px 9px;
  font: 600 12px/1.35 system-ui, sans-serif;
}
.view-switch [aria-pressed="true"] {
  color: #fffdef;
  background: var(--forest);
}
.view-controls button:hover:not([aria-pressed="true"]) { background: #e1e5d9; }
.view-status {
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 5px;
}
.view-status:empty { display: none; }
#board-3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  visibility: hidden;
  border-radius: 6px;
  touch-action: pan-y;
}
.board-wrap[data-view="3d"] #board-3d { visibility: visible; }
.board-wrap[data-view="3d"] { aspect-ratio: var(--scene-aspect, 1.25); }
.board-wrap[data-view="3d"] #board {
  position: absolute;
  inset: 0;
  height: 100%;
  aspect-ratio: auto;
}
.board-wrap[data-view="3d"] #board,
.board-wrap[data-view="3d"] #board-lines {
  opacity: 0;
  pointer-events: none;
}
#board-3d[data-input="move"] { touch-action: none; cursor: grab; }
#board-3d[data-input="place"] { touch-action: manipulation; cursor: crosshair; }
#board-3d[data-dragging] { cursor: grabbing; }
.board {
  aspect-ratio: 1;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 0 0 1px #748172;
  isolation: isolate;
}
.square {
  border: 0;
  border-radius: 0;
  position: relative;
  padding: 0;
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
  cursor: default;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  container-type: inline-size;
}
.square.light {
  background: #ece6cc;
  --coord: #53604d;
}
.square.dark {
  background: #74917e;
  --coord: #223e33;
}
.square.movable {
  cursor: grab;
  touch-action: none;
}
.square.last {
  background: #d1d89a;
}
.square.dark.last {
  background: #a3b876;
}
.square.selected {
  box-shadow: inset 0 0 0 4px #bf672e;
}
.square.checked {
  background: #cf9073;
}
.square:focus-visible {
  outline: 3px solid #704592;
  outline-offset: -3px;
  z-index: 2;
}
.coord {
  position: absolute;
  padding: 2px 3px;
  font: 600 clamp(8px, 13cqw, 12px) / 1 system-ui;
  color: var(--coord);
  pointer-events: none;
}
.rank {
  left: 0;
  top: 0;
}
.file {
  bottom: 0;
  right: 0;
}
.piece,
.small-piece {
  font-family:
    BoardPieces, "DejaVu Sans", "Apple Symbols", "Segoe UI Symbol", sans-serif;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
  position: relative;
  display: inline-grid;
  place-items: center;
}
.piece {
  font-size: 85cqw;
  z-index: 1;
  transform: translateY(0.14em);
}
.piece.black,
.small-piece.black {
  color: #22372f;
  filter: drop-shadow(0 1px 0 #f0efdc80);
}
.piece.white,
.small-piece.white {
  color: #fffcef;
  filter: drop-shadow(0 1px 0 #23392e66);
}
.piece.white::after,
.small-piece.white::after {
  content: attr(data-outline);
  color: #293d33;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.square.target::after {
  content: "";
  width: 23%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #214e3a80;
  position: absolute;
  z-index: 2;
}
.square.capture::after {
  content: "";
  position: absolute;
  inset: 4%;
  border: 3px solid #214e3a9e;
  border-radius: 50%;
  z-index: 2;
}
.square.drag-origin .piece {
  opacity: 0.18;
}
.drag-piece {
  position: fixed;
  margin: 0;
  z-index: 10;
  transform: translate(-50%, -56%);
  pointer-events: none;
}
.square.over {
  box-shadow: inset 0 0 0 3px #d88337;
}
.panel {
  margin-top: 43px;
  display: grid;
  gap: 24px;
  min-width: 0;
}
.controls {
  padding: 16px 0;
  border-top: 3px solid var(--forest);
  border-bottom: 1px solid var(--line);
}
.panel h2 {
  font-size: 18px;
  font-weight: 650;
  line-height: 1.5;
}
.controls p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 4px;
}
.controls p:empty {
  display: none;
}
.colors {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.colors button, #strategy-controls button,
.retry,
.promotion button {
  border: 1px solid #98a394;
  border-radius: 5px;
  background: #faf9f3;
  padding: 8px 12px;
}
.colors button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  justify-content: center;
}
.colors button:hover, #strategy-controls button:hover,
.retry:hover,
.promotion button:hover {
  background: #e4e9db;
}
.retry {
  margin-top: 10px;
}
#saved-list {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}
#saved-list .retry {
  min-height: 44px;
  margin-top: 0;
  text-align: left;
}
.move-head,
.move-row {
  display: grid;
  grid-template-columns: 2.7em 1fr 1fr;
  align-items: center;
  gap: 5px;
}
.move-head {
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  padding: 8px 0;
}
.moves {
  max-height: clamp(110px, 34dvh, 360px);
  overflow: auto;
}
.move-row {
  padding: 6px 0;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
}
.move-row span:first-child,
.empty {
  color: var(--muted);
}
.empty {
  padding: 12px 0;
  font-size: 13px;
}
.promotion {
  position: absolute;
  z-index: 5;
  background: #faf9f3;
  border: 2px solid var(--forest);
  border-radius: 9px;
  box-shadow: 0 8px 26px #102c2459;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: 95%;
  text-align: center;
  padding: 12px;
}
.promotion strong {
  font-size: 15px;
}
.promotion #promotion-options {
  display: flex;
  gap: 4px;
  margin: 8px 0;
}
.promotion #promotion-options button {
  padding: 5px;
}
.small-piece {
  font-size: 32px;
}
.promotion #cancel-promotion {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 3px 10px;
}
@media (max-width: 650px) {
  .board-wrap[data-view="3d"] { aspect-ratio: calc(var(--scene-aspect, 0.94) * 0.86); }
  .room {
    padding: 12px max(12px, env(safe-area-inset-right)) 16px
      max(12px, env(safe-area-inset-left));
  }
  .heading {
    padding-bottom: 10px;
  }
  .crest {
    width: 31px;
    height: 31px;
    font-size: 23px;
  }
  .layout {
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  .table {
    max-width: 100%;
  }
  .panel {
    width: 100%;
    margin: 0;
    gap: 14px;
  }
  .controls {
    padding: 10px 0;
  }
  .controls .colors {
    display: inline-flex;
    min-width: 185px;
  }
  .rail {
    min-height: 32px;
    font-size: 13px;
  }
  .scoresheet h2 {
    font-size: 16px;
  }
  .moves {
    max-height: 125px;
  }
}
@media (min-width: 651px) and (max-height: 560px) {
  .room {
    padding: 10px 16px;
  }
  .heading {
    padding-bottom: 6px;
  }
  .table {
    max-width: min(100%, max(280px, calc(100dvh - 105px)));
  }
  .rail {
    min-height: 26px;
  }
  .panel {
    margin-top: 26px;
  }
}
.tables {
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.tables button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 5px clamp(8px, 2vw, 16px);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  white-space: nowrap;
}
.tables button:hover {
  background: #e3e6da;
}
.tables button[aria-pressed="true"] {
  background: var(--forest);
  color: #fffdef;
}
.side-dot.red {
  background: #a14532;
  border-color: #893a29;
}
.board-wrap {
  isolation: isolate;
}
#board-lines {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  z-index: -1;
  background: #e9cf9d;
  border-radius: 5px;
  box-shadow: inset 0 0 15px #855f3222;
}
.board:not([data-game="chess"]) {
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  aspect-ratio: var(--columns) / var(--rows);
  box-shadow: 0 0 0 1px #a99170;
}
.square.point {
  background: transparent;
}
.square.point.placeable {
  cursor: crosshair;
  touch-action: manipulation;
}
.stone {
  display: block;
  position: relative;
  width: 87%;
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 1px 2px #4c371d77;
}
.stone.black {
  background: radial-gradient(
    ellipse at 34% 26%,
    #585950,
    #272c28 60%,
    #171b18
  );
  border: 1px solid #20251e;
}
.stone.white {
  background: radial-gradient(
    ellipse at 34% 26%,
    #fffef3,
    #f1eddb 65%,
    #d3cdb7
  );
  border: 1px solid #a59b81;
}
.recent .stone::after {
  content: "";
  position: absolute;
  width: 23%;
  height: 23%;
  border-radius: 50%;
  inset: 38.5%;
  background: #bd633e;
}
.recent .stone.black::after {
  background: #e8c680;
}
.checker {
  font:
    650 55cqw/1 "Songti SC",
    "Noto Serif CJK SC",
    ui-serif,
    serif;
  width: 89%;
  height: 89%;
  transform: none;
  place-items: center;
  border: 1px solid currentColor;
  outline: 1px solid currentColor;
  outline-offset: -4px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 35% 25%, #fff0c9, #eac994);
  box-shadow: 0 1px 2px #533d28aa;
}
.checker.red {
  color: #9b3627;
}
.piece.checker.black {
  color: #2e3b32;
  filter: none;
}
.point.recent .checker {
  box-shadow: 0 0 0 2px #a5652e;
}
.point.recent:empty::before {
  content: "";
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: #bb7e44;
}
.point.in-check .checker {
  background: #e9ac8c;
}
.point.selected {
  box-shadow: none;
  background: #ad653b44;
}
.checker.drag-piece {
  display: grid;
  transform: translate(-50%, -50%);
}
#rules {
  color: #5a634f;
}
@media (min-width: 651px) {
  .table {
    max-width: min(100%, max(340px, calc(100dvh - 226px)));
  }
  .table:has([data-game="xiangqi"]) {
    max-width: min(100%, max(300px, calc((100dvh - 226px) * 0.9)));
  }
}
@media (max-width: 430px) {
  .tables button {
    flex: 1;
    padding: 5px 2px;
  }
}

.sideline { border-top: 1px solid #bfc6b7; margin-top: 12px; padding-top: 12px; }
.sideline label { font-weight: 600; }
.sideline label span { font-size: .78rem; font-weight: 400; color: #526257; }
.sideline input { box-sizing: border-box; min-width: 0; padding: 6px 8px; border: 1px solid #a6b2a4; border-radius: 4px; background: #f8f7f0; font: inherit; color: inherit; }
.sideline h2 { font-size: 1.04rem; margin: 0 0 7px; }
.sideline p, #wager-result { margin: 6px 0; font-size: .86rem; overflow-wrap: anywhere; }
#table-talk { max-height: min(36dvh, 22rem); overflow-y: auto; }
#table-talk strong { display: block; margin-top: 9px; color: #344f43; font-size: .76rem; }
#strategy-controls { display: grid; gap: 6px; margin: 10px 0; }
#strategy-controls button { justify-self: start; }
.talk-actions { display: flex; flex-wrap: wrap; gap: 6px; }
#strategy-controls label { font-size: .83rem; }
#seat-options summary { margin-top: 10px; cursor: pointer; color: var(--forest); font-weight: 600; }
#next-agreement, #forfeit-agreement, .forfeit-shows h3 { overflow-wrap: anywhere; }
.forfeit-shows { padding-top: 9px; border-top: 3px solid var(--forest); }
.forfeit-shows article { margin: 8px 0 14px; }
.forfeit-shows summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.forfeit-shows details p { overflow-wrap: anywhere; margin: 5px 0; }
.forfeit-shows h3 { font-size: .93rem; color: #344f43; margin: 0 0 5px; }
.performance-text { white-space: pre-line; overflow-wrap: anywhere; font-size: .92rem; line-height: 1.6; }
.forfeit-shows small { display: block; margin-top: 6px; color: var(--muted); }
.forfeit-shows audio { width: 100%; height: 32px; margin-top: 6px; }
