/* online.css is intentionally standalone and doesn't depend on the platform homepage styles */
@import url("./Font/noto-sans-tc/index.css");
@import url("./Font/noto-serif-tc/index.css");

@font-face {
  font-family: "FofCCSetoFont";
  src:
    local("setofont"),
    url("./setofont.woff2") format("woff2"),
    url("./setofont.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "FofCCHansFont";
  src:
    local("xingyelangmanyuzhouwenrou"),
    url("./xingyelangmanyuzhouwenrou.woff2") format("woff2"),
    url("./xingyelangmanyuzhouwenrou.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #f4efe3;
  --panel: rgba(255, 251, 243, 0.97);
  --line: #5c3d1f;
  --board: #e5c38b;
  --grid: #402715;
  --text: #4e3219;
  --muted: #87684f;
  --accent: #b86e34;
  --red: #b23a2d;
  --black: #212121;
  --green: #507b4d;
  --gold: #d1a35f;
  --fog: rgba(38, 31, 25, 0.42);
  --shadow: 0 10px 24px rgba(222, 193, 150, 0.16);
  --captured-track-gap: 5px;
  --captured-track-padding-y: 6px;
  --captured-track-padding-x: 8px;
  --captured-piece-size: 30px;
  --captured-piece-font-size: 17px;
  --lobby-list-card-height: auto;
  --room-players-card-height: auto;
  --board-panel-height: auto;
  --chat-card-height: auto;
  --fofcc-hant-body-font: "FofCCSetoFont", "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  --fofcc-hans-body-font: "FofCCHansFont", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Source Han Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  font-family: var(--fofcc-hant-body-font);
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(250, 219, 154, 0.7), transparent 18rem),
    radial-gradient(circle at bottom left, rgba(166, 214, 205, 0.55), transparent 20rem),
    linear-gradient(180deg, #fbf7ef 0%, #f0e4cf 100%);
}

html[lang="zh-Hans"] body {
  font-family: var(--fofcc-hans-body-font);
}

html[lang="zh-Hans"] {
  --captured-piece-font-size: 16px;
}

body {
  padding: 14px 14px 10px;
  overflow-x: hidden;
}

body a {
  color: inherit;
  text-decoration: none;
}

body a:visited {
  color: inherit;
}

body.utility-modal-open {
  overflow-x: hidden;
}

.page-shell {
  width: 100%;
  display: flex;
  justify-content: center;
}

.hero-block h1 {
  margin: 0;
  font-size: clamp(34px, 3vw, 48px);
  line-height: 1.05;
}

.subtitle {
  margin: 12px 0 0;
  font-size: 18px;
  line-height: 1.7;
  color: var(--muted);
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(522px, 576px) minmax(216px, 270px);
  gap: 7px;
  align-items: start;
  justify-content: center;
}

.board-column,
.side-panel {
  display: grid;
  gap: 6px;
}

.board-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  align-self: stretch;
}

.board-panel,
.panel-block {
  border: 1px solid rgba(108, 76, 46, 0.15);
  background: var(--panel);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.board-panel {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 0 auto;
  min-height: 0;
  height: auto;
  overflow: visible;
}

.captured-panel {
  display: grid;
  gap: 12px;
}

.board-zone-list {
  display: grid;
  gap: 8px;
}

.board-captured-panel {
  border-top: none;
  padding-top: 0;
  margin-top: -2px;
}

.board-captured-panel h2 {
  font-size: 15px;
  margin-bottom: 0;
}

.board-captured-panel h2:empty {
  display: none;
}

.board-captured-panel h2:empty + .board-zone-list {
  padding-top: 8px;
}

.captured-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.captured-row + .captured-row {
  margin-top: 0;
}

.captured-label {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.captured-track {
  min-height: 44px;
  padding: var(--captured-track-padding-y) var(--captured-track-padding-x);
  border-radius: 18px;
  background: rgba(184, 110, 52, 0.06);
  display: flex;
  flex-wrap: wrap;
  gap: var(--captured-track-gap);
  align-items: center;
}

.captured-empty {
  font-size: 13px;
  color: var(--muted);
}

.captured-piece {
  width: var(--captured-piece-size);
  height: var(--captured-piece-size);
  min-width: var(--captured-piece-size);
  min-height: var(--captured-piece-size);
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid currentColor;
  background: rgba(255, 253, 246, 0.96);
  box-shadow: 0 3px 8px rgba(112, 79, 48, 0.08);
  font-size: var(--captured-piece-font-size);
  font-weight: 700;
}

.captured-piece.red {
  color: var(--red);
}

.captured-piece.black {
  color: #2b2b2b;
}

.captured-piece.white {
  color: #6b6257;
}

.captured-piece.concealed-source {
  filter: brightness(0.84) saturate(0.84);
  background: rgba(239, 232, 220, 0.96);
}

.captured-piece.identity-hidden {
  position: relative;
  overflow: hidden;
  color: transparent;
  border: 0;
  background: transparent url("./jieqi-plum-back.png?v=20260517-07") center / cover no-repeat;
  box-shadow: none;
  filter: none;
}

.captured-piece-flyout {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 70;
  pointer-events: none;
  will-change: transform, opacity;
}

.board-zone-group {
  display: grid;
  gap: 8px;
}

.board-zone-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.board-zone-group-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.board-zone-items {
  min-height: 52px;
  padding: 8px 10px;
  border-radius: 18px;
  background: rgba(184, 110, 52, 0.06);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.board-zone-empty {
  font-size: 13px;
  color: var(--muted);
}

.board-zone-item {
  min-width: 34px;
  min-height: 34px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(108, 76, 46, 0.16);
  background: rgba(255, 253, 246, 0.96);
  color: var(--text);
  box-shadow: 0 4px 10px rgba(112, 79, 48, 0.08);
  font-size: 15px;
  font-weight: 700;
  padding: 4px 10px;
}

.board-zone-item.captured-piece {
  width: var(--captured-piece-size);
  height: var(--captured-piece-size);
  min-width: var(--captured-piece-size);
  min-height: var(--captured-piece-size);
  padding: 0;
  border-radius: 50%;
}

.board-zone-item.interactive {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.board-zone-item.interactive:hover {
  transform: translateY(-1px);
  border-color: rgba(184, 110, 52, 0.42);
  box-shadow: 0 6px 14px rgba(112, 79, 48, 0.14);
}

.board-zone-item.armed {
  border-color: rgba(184, 110, 52, 0.58);
  background: rgba(255, 241, 222, 0.98);
  box-shadow: 0 8px 18px rgba(112, 79, 48, 0.18);
}

.board-zone-item.interactive:disabled {
  cursor: default;
  opacity: 0.52;
  transform: none;
  box-shadow: 0 4px 10px rgba(112, 79, 48, 0.08);
}

.board-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 0;
}

.turn-badge {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turn-badge.red {
  background: linear-gradient(135deg, #cc5644, #9f3026);
}

.turn-badge.black {
  background: linear-gradient(135deg, #4b4b4b, #1c1c1c);
}

.turn-badge.white {
  background: #ffffff;
  color: #4c433a;
}

.turn-badge.neutral {
  background: linear-gradient(135deg, #8a6846, #5c3d1f);
  color: #fff3e3;
}

.turn-badge.draw {
  background: linear-gradient(135deg, #8a6846, #5c3d1f);
  color: #fff3e3;
}

.turn-badge.waiting {
  background: linear-gradient(135deg, #8e7b56, #6e5d3b);
  color: #fff7e8;
}

.turn-badge:empty {
  display: none;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: end;
}

.compact-toolbar {
  display: grid;
  gap: 10px;
}

.side-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  justify-content: stretch;
  justify-items: stretch;
  width: 100%;
}

.side-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
}

.side-action-row .ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 88px;
  max-width: 100%;
  padding-inline: 18px;
  flex: 0 1 auto;
}

body[data-active-game-id="gomoku"] .side-actions > .side-action-row:first-child {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 10px;
}

body[data-active-game-id="gomoku"] .side-actions > .side-action-row:first-child .ghost-btn {
  width: 100%;
  min-width: 0;
  max-width: none;
  flex: 0 0 auto;
}

.side-action-row--settled-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.side-action-row--settled-actions .ghost-btn {
  width: 100%;
  min-width: 0;
  max-width: none;
  padding-inline: 12px;
  white-space: nowrap;
}

.side-action-row--coordinate-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.side-action-row--coordinate-actions .ghost-btn {
  width: 100%;
  min-width: 0;
  max-width: none;
  padding-inline: 12px;
  white-space: nowrap;
}

.game-record-panel {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(112, 84, 53, 0.12);
}

.game-record-panel-head {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.game-record-action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.game-record-action-row .ghost-btn {
  width: 100%;
  min-width: 0;
  max-width: none;
  padding-inline: 12px;
  white-space: nowrap;
}

.action-card {
  gap: 10px;
}

.profile-head.action-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 10px;
  row-gap: 10px;
}

.profile-head.action-card-head .panel-toggle-btn {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
}

.profile-head.action-card-head .turn-badge {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: stretch;
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  padding-inline: 16px;
  font-size: 17px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.35;
}

.action-card-body {
  padding-top: 0;
}

.decision-panel {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 22px;
  background: rgba(184, 110, 52, 0.08);
  border: 1px solid rgba(184, 110, 52, 0.16);
  margin-bottom: 12px;
}

.action-chain-panel {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 246, 231, 0.94);
  border: 1px solid rgba(184, 110, 52, 0.18);
  margin-bottom: 12px;
}

.action-chain-summary,
.action-chain-detail {
  margin: 0;
}

.action-chain-summary {
  font-size: 13px;
  line-height: 1.5;
  font-weight: 800;
  color: #8b4c1e;
}

.action-chain-detail {
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

.decision-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.decision-panel-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.decision-description {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

.decision-selection-summary {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: #8b4c1e;
  font-weight: 700;
}

.decision-options {
  display: grid;
  gap: 10px;
}

.decision-selection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.decision-option-btn {
  width: 100%;
  justify-content: flex-start;
  padding-inline: 16px;
  text-align: left;
}

.decision-option-btn.armed {
  border-color: rgba(184, 110, 52, 0.4);
  background: rgba(255, 244, 228, 0.98);
  box-shadow: 0 8px 18px rgba(112, 79, 48, 0.14);
}

.decision-option-btn.selected {
  border-color: rgba(184, 110, 52, 0.48);
  background: rgba(255, 239, 213, 0.98);
  box-shadow: 0 8px 18px rgba(112, 79, 48, 0.16);
}

.decision-option-btn-label {
  display: block;
  font-weight: 800;
}

.decision-option-btn-note {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.ghost-btn,
.text-btn {
  border: none;
  cursor: pointer;
  font: inherit;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(107, 79, 51, 0.08);
  color: var(--text);
  transition: 0.18s ease;
  white-space: nowrap;
}

.ghost-btn:hover {
  background: rgba(107, 79, 51, 0.14);
}

.ghost-btn.active {
  background: rgba(184, 110, 52, 0.14);
  color: #8b4c1e;
}

.ghost-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.danger-btn {
  color: #9f3026;
  background: rgba(178, 58, 45, 0.08);
}

.danger-btn:hover {
  background: rgba(178, 58, 45, 0.14);
}

.text-btn {
  color: var(--accent);
  background: transparent;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 576px;
  margin: 0 auto;
  aspect-ratio: 9 / 10;
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(248, 225, 180, 0.24), rgba(219, 182, 122, 0.14)),
    #f7edd8;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

body.in-room[data-active-game-id="fog_xiangqi"] .canvas-wrap,
body.in-room[data-active-game-id="jieqi"] .canvas-wrap {
  max-width: 508px;
}

body[data-active-game-family="gomoku"] .canvas-wrap {
  aspect-ratio: 1 / 1;
}

body[data-active-game-family="dark_chess"] .canvas-wrap {
  max-width: 980px;
  aspect-ratio: 2 / 1;
  background:
    linear-gradient(180deg, rgba(241, 212, 162, 0.34), rgba(196, 148, 81, 0.18)),
    #e2be84;
}

body[data-active-game-family="dark_chess"] .board-panel {
  padding: 8px;
}

.replay-controls {
  display: grid;
  grid-template-columns: 48px 48px minmax(0, 1fr) 48px 48px;
  gap: 10px;
  align-items: center;
  width: 100%;
  max-width: 576px;
  margin: 0 auto;
}

body[data-active-game-family="dark_chess"] .replay-controls {
  max-width: 840px;
}

.replay-controls.hidden {
  display: none;
}

.replay-btn {
  min-height: 44px;
  padding: 0;
  font-size: 24px;
  font-weight: 700;
}

.chevron-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 0;
}

.chevron-icon-btn::before,
.chevron-icon-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15px;
  height: 15px;
  display: block;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 15px 15px;
  transform: translate(-50%, -50%);
}

.chevron-icon-btn::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 15 15' fill='none'%3E%3Cpath d='M9.75 2.85L5.55 7.5L9.75 12.15' stroke='%23735B44' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.chevron-icon-btn--right::before {
  transform: translate(-50%, -50%) scaleX(-1);
}

.chevron-icon-btn--single {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chevron-icon-btn--double {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chevron-icon-btn--double::before {
  left: calc(50% - 5px);
}

.chevron-icon-btn--double::after {
  left: calc(50% + 5px);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 15 15' fill='none'%3E%3Cpath d='M9.75 2.85L5.55 7.5L9.75 12.15' stroke='%23735B44' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.chevron-icon-btn--double.chevron-icon-btn--right::before,
.chevron-icon-btn--double.chevron-icon-btn--right::after {
  transform: translate(-50%, -50%) scaleX(-1);
}

.replay-status {
  min-width: 0;
  text-align: center;
}

.replay-step {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.replay-move {
  margin-top: 4px;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#boardCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

body[data-active-game-family="dark_chess"] #boardCanvas {
  cursor: pointer;
}

.overlay-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 24px;
  max-width: min(calc(100% - 28px), 760px);
  border-radius: 999px;
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.04em;
  color: #fff;
  background: rgba(64, 39, 21, 0.86);
  box-shadow: 0 10px 24px rgba(48, 30, 18, 0.22);
  pointer-events: none;
  z-index: 2;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
}

.overlay-message.red {
  background: rgba(178, 58, 45, 0.9);
  color: #ffe8e3;
}

.overlay-message.black {
  background: rgba(33, 33, 33, 0.9);
  color: #f3f3f3;
}

.overlay-message.white {
  background: rgba(244, 240, 231, 0.94);
  color: #51463b;
}

.overlay-message.neutral {
  background: rgba(92, 61, 31, 0.9);
  color: #fff3e3;
}

.overlay-message.draw {
  background: rgba(92, 61, 31, 0.9);
  color: #fff3e3;
}

.overlay-message.hidden {
  display: none;
}

.confirm-dialog-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(39, 27, 16, 0.34);
  z-index: 20;
}

.confirm-dialog-backdrop.hidden {
  display: none;
}

.utility-modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px 16px;
  background: rgba(39, 27, 16, 0.34);
  z-index: 18;
}

.utility-modal-backdrop.hidden {
  display: none;
}

.utility-modal-shell {
  position: relative;
  width: min(92vw, 560px);
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  gap: 0;
}

.utility-modal-title {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.utility-modal-card {
  padding: 14px 16px 16px;
  box-shadow: none;
}

.utility-modal-card[hidden] {
  display: none !important;
}

.confirm-dialog {
  width: fit-content;
  min-width: min(88vw, 360px);
  max-width: min(96vw, 520px);
  display: grid;
  gap: 16px;
  padding: 20px 18px 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 248, 240, 0.98), rgba(252, 243, 232, 0.98));
  box-shadow: 0 18px 42px rgba(78, 53, 33, 0.2);
}

.confirm-dialog-text {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.55;
  text-align: center;
  white-space: nowrap;
}

.confirm-dialog-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.confirm-dialog-actions.confirm-left {
  flex-direction: row-reverse;
}

@media (max-width: 640px) {
  .overlay-message {
    max-width: min(calc(100% - 24px), 560px);
    padding: 0 20px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .confirm-dialog {
    width: min(92vw, 420px);
    min-width: 0;
  }

  .confirm-dialog-text {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

.panel-block {
  padding: 9px 10px 11px;
}

.panel-block h2 {
  margin: 0 0 5px;
  font-size: 18px;
}

.facts {
  display: grid;
  gap: 8px;
  margin: 0;
}

.facts div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-end;
  padding-top: 5px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(112, 84, 53, 0.12);
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  font-weight: 700;
}

.facts dd.red {
  color: var(--red);
}

.facts dd.black {
  color: var(--black);
}

.facts dd.white {
  color: #6b6257;
}

.tips {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.history-block {
  min-height: 182px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.history-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.history-list {
  margin: 0;
  padding-left: 22px;
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.history-list li {
  padding-right: 8px;
  cursor: pointer;
}

.history-list li.current {
  color: var(--text);
  font-weight: 700;
}

.history-list li.reviewing {
  color: #8b4c1e;
  font-weight: 700;
}

.record-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.mini-btn {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

/* 確保 html/body 撐滿視窗 */
html, body {
  height: 100%;
  margin: 0;
}

/* 作者樣式可能覆蓋瀏覽器預設 hidden，因此全域補強一次。 */
[hidden] {
  display: none !important;
}

/* page-shell 和 app-layout 撐滿全高 */
.page-shell.online-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: stretch;
  gap: 8px;
}

.app-layout.online-layout {
  flex: 1;
  min-height: 0;
  height: auto;
  width: 100%;
  max-width: none;
}

.platform-switch-bar {
  width: 100%;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: minmax(260px, auto) minmax(0, 1fr) minmax(220px, 320px);
  align-items: center;
  gap: 18px;
  overflow: hidden;
}

.platform-switch-bar .brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.platform-switch-bar .brand-lockup:visited,
.platform-switch-bar .brand-lockup:hover,
.platform-switch-bar .brand-lockup:focus-visible {
  color: inherit;
  text-decoration: none;
}

.platform-switch-bar .brand-emblem {
  width: 48px;
  height: 48px;
  padding: 5px;
  border-radius: 15px;
  border: 1px solid rgba(108, 76, 46, 0.18);
  background: linear-gradient(145deg, rgba(255, 249, 240, 0.96), rgba(245, 229, 202, 0.9));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.platform-switch-bar .brand-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.platform-switch-bar .brand-title {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.platform-switch-bar .brand-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.platform-utility-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.platform-switch-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.platform-utility-btn {
  min-height: 42px;
  padding: 0 22px;
  font-weight: 800;
}

.platform-utility-btn.active {
  background: rgba(184, 110, 52, 0.16);
  color: #8b4c1e;
}

.platform-profile-btn {
  min-height: 42px;
  padding: 0 18px;
  font-weight: 800;
  white-space: nowrap;
}

.platform-game-select-control {
  width: min(100%, 180px);
  max-width: 180px;
  min-width: 140px;
  justify-self: end;
}

.online-layout {
  grid-template-columns:
    minmax(180px, 220px)
    minmax(200px, 235px)
    minmax(0, 1fr)
    minmax(175px, 215px)
    minmax(190px, 240px);
  justify-content: stretch;
  align-items: stretch;
  height: 100%;
  min-width: 0;
}

body.in-room[data-active-game-family="xiangqi"] .online-layout {
  grid-template-columns:
    minmax(180px, 220px)
    minmax(188px, 222px)
    minmax(0, 1fr)
    minmax(205px, 248px)
    minmax(184px, 225px);
  min-width: 0;
}

body.in-room[data-active-game-family="dark_chess"] .online-layout {
  grid-template-columns:
    minmax(180px, 210px)
    minmax(188px, 228px)
    minmax(0, 1.02fr)
    minmax(210px, 250px)
    minmax(205px, 238px);
  min-width: 0;
}

.lobby-room-rail,
.left-rail,
.board-column,
#rightRail,
#chatRail {
  height: 100%;
  min-height: 0;
  align-self: stretch;
  overflow: hidden;
}

.lobby-room-rail {
  grid-column: 1;
}

.left-rail {
  grid-column: 2;
}

.board-column {
  grid-column: 3;
}

#rightRail {
  grid-column: 4;
}

#chatRail {
  grid-column: 5;
}

/* 第二欄 left-rail 撐滿高度 */
.left-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  align-self: stretch;
  height: 100%;
  overflow: hidden;
  background: transparent;
}

.lobby-create-row {
  display: none;
}

body.online-lobby .lobby-create-row {
  display: flex;
}

.lobby-create-btn {
  width: 100%;
  min-height: 44px;
  justify-content: center;
}

.room-list-actions {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.room-list-create-btn {
  width: 100%;
  min-height: 42px;
  justify-content: center;
}

#roomPlayersCard {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow: hidden;
}

#roomPlayersCard.collapsed {
  flex: 0 0 auto;
  min-height: auto;
  height: auto;
}

#roomPlayersCardBody {
  flex: 1 1 auto;
  min-height: 0;
  justify-content: flex-start;
}

#roomPlayersCardBody > .facts {
  flex: 0 0 auto;
}

.local-ai-diagnostics-panel {
  width: 100%;
  padding: 16px 18px 18px;
  display: none;
  gap: 14px;
  overflow: hidden;
}

body.in-room .local-ai-diagnostics-panel:not([hidden]) {
  display: grid;
}

.local-ai-diagnostics-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.local-ai-diagnostics-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.local-ai-diagnostics-body {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.local-ai-summary-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 7px;
}

.local-ai-summary-grid--compact {
  gap: 6px;
}

.local-ai-metric {
  flex: 0 1 138px;
  min-width: 104px;
  max-width: 220px;
  min-height: 42px;
  padding: 7px 9px;
  border: 1px solid rgba(108, 76, 46, 0.12);
  border-radius: 8px;
  background: rgba(255, 247, 232, 0.72);
  display: grid;
  align-content: center;
  gap: 2px;
}

.local-ai-summary-grid--compact .local-ai-metric {
  flex-basis: 128px;
  min-height: 40px;
}

.local-ai-metric--short {
  flex-basis: 92px;
  min-width: 78px;
  max-width: 128px;
}

.local-ai-metric--long {
  flex-basis: 210px;
  min-width: 150px;
  max-width: 300px;
}

.local-ai-metric-label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.local-ai-metric-value {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.local-ai-metric-value--truncate {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: normal;
}

.local-ai-diagnostics-section {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.local-ai-diagnostics-section h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.25;
}

.local-ai-section-switcher {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.local-ai-section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.local-ai-section-hint {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.local-ai-section-tab {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid rgba(108, 76, 46, 0.18);
  border-radius: 999px;
  background: rgba(245, 236, 222, 0.82);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.15;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease;
}

.local-ai-section-tab:hover,
.local-ai-section-tab:focus-visible {
  border-color: rgba(184, 110, 52, 0.34);
  background: rgba(250, 239, 220, 0.96);
}

.local-ai-section-tab--active {
  border-color: rgba(184, 110, 52, 0.44);
  background: rgba(184, 110, 52, 0.16);
  color: #7b431f;
}

.local-ai-section-content {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.local-ai-subheading {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.25;
}

.local-ai-candidate-table {
  display: grid;
  grid-template-columns: 52px minmax(118px, 0.74fr) repeat(23, minmax(42px, 0.28fr)) minmax(150px, 0.8fr);
  width: 100%;
  border: 1px solid rgba(108, 76, 46, 0.14);
  border-radius: 8px;
  overflow-x: hidden;
  min-width: 0;
}

.local-ai-vision-board {
  display: grid;
  position: relative;
  gap: 0;
  width: min(440px, 100%);
  max-width: 440px;
  margin: 0 auto;
  border: 2px solid rgba(108, 76, 46, 0.34);
  border-radius: 8px;
  background: rgba(226, 190, 126, 0.24);
  min-width: 0;
  overflow: hidden;
}

.local-ai-vision-board-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.local-ai-vision-board-panel {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.local-ai-vision-board-panel .local-ai-vision-board {
  width: min(440px, 100%);
  margin: 0 auto;
}

.local-ai-vision-river {
  grid-column: 1 / -1;
  padding: 6px 0;
  border-top: 1px solid rgba(108, 76, 46, 0.34);
  border-bottom: 1px solid rgba(108, 76, 46, 0.34);
  background: rgba(226, 190, 126, 0.62);
  color: rgba(82, 53, 28, 0.82);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.2;
  text-align: center;
}

.local-ai-vision-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 0;
  padding: 3px 2px;
  border-right: 1px solid rgba(108, 76, 46, 0.2);
  border-bottom: 1px solid rgba(108, 76, 46, 0.2);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  overflow: hidden;
}

.local-ai-vision-cell > * {
  position: relative;
  z-index: 1;
}

.local-ai-vision-cell--right-edge {
  border-right: 0;
}

.local-ai-vision-cell--bottom-edge {
  border-bottom: 0;
}

.local-ai-vision-cell--visible {
  background: rgba(46, 125, 78, 0.18);
  color: #21462f;
}

.local-ai-vision-cell--hidden {
  background: rgba(222, 219, 210, 0.74);
  color: var(--text);
}

.local-ai-vision-cell--point-marker::before {
  content: "";
  position: absolute;
  inset: 18%;
  z-index: 0;
  background:
    linear-gradient(rgba(108, 76, 46, 0.5), rgba(108, 76, 46, 0.5)) left top / 11px 2px no-repeat,
    linear-gradient(rgba(108, 76, 46, 0.5), rgba(108, 76, 46, 0.5)) left top / 2px 11px no-repeat,
    linear-gradient(rgba(108, 76, 46, 0.5), rgba(108, 76, 46, 0.5)) right top / 11px 2px no-repeat,
    linear-gradient(rgba(108, 76, 46, 0.5), rgba(108, 76, 46, 0.5)) right top / 2px 11px no-repeat,
    linear-gradient(rgba(108, 76, 46, 0.5), rgba(108, 76, 46, 0.5)) left bottom / 11px 2px no-repeat,
    linear-gradient(rgba(108, 76, 46, 0.5), rgba(108, 76, 46, 0.5)) left bottom / 2px 11px no-repeat,
    linear-gradient(rgba(108, 76, 46, 0.5), rgba(108, 76, 46, 0.5)) right bottom / 11px 2px no-repeat,
    linear-gradient(rgba(108, 76, 46, 0.5), rgba(108, 76, 46, 0.5)) right bottom / 2px 11px no-repeat;
  pointer-events: none;
}

.local-ai-vision-cell--palace-diag-a::after,
.local-ai-vision-cell--palace-diag-b::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.local-ai-vision-cell--palace-diag-a::after {
  background: linear-gradient(45deg, transparent calc(50% - 1px), rgba(108, 76, 46, 0.44) 50%, transparent calc(50% + 1px));
}

.local-ai-vision-cell--palace-diag-b::after {
  background: linear-gradient(135deg, transparent calc(50% - 1px), rgba(108, 76, 46, 0.44) 50%, transparent calc(50% + 1px));
}

.local-ai-vision-cell--palace-diag-a.local-ai-vision-cell--palace-diag-b::after {
  background:
    linear-gradient(45deg, transparent calc(50% - 1px), rgba(108, 76, 46, 0.44) 50%, transparent calc(50% + 1px)),
    linear-gradient(135deg, transparent calc(50% - 1px), rgba(108, 76, 46, 0.44) 50%, transparent calc(50% + 1px));
}

.local-ai-vision-cell-key,
.local-ai-vision-cell-score {
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
}

.local-ai-vision-cell-count {
  font-size: 14px;
  font-weight: 900;
  line-height: 1.05;
  white-space: nowrap;
}

.local-ai-piece-instance-table {
  display: grid;
  grid-template-columns: 54px 54px 76px minmax(132px, 1.05fr) 72px minmax(92px, 0.85fr) 76px 46px repeat(5, minmax(58px, 0.5fr)) 54px minmax(150px, 0.85fr);
  border: 1px solid rgba(108, 76, 46, 0.14);
  border-radius: 8px;
  overflow-x: hidden;
  min-width: 0;
}

.local-ai-score-component-table {
  display: grid;
  grid-template-columns: minmax(96px, 0.8fr) minmax(92px, 0.7fr) 66px minmax(130px, 0.9fr) minmax(210px, 1.35fr) 56px minmax(260px, 1.4fr);
  border: 1px solid rgba(108, 76, 46, 0.14);
  border-radius: 8px;
  overflow-x: auto;
  min-width: 0;
}

.local-ai-decision-flow-table {
  display: grid;
  grid-template-columns: 44px 70px minmax(118px, 0.8fr) 66px 72px minmax(170px, 1.05fr) minmax(150px, 0.95fr) minmax(160px, 1fr) 70px;
  border: 1px solid rgba(108, 76, 46, 0.14);
  border-radius: 8px;
  overflow-x: auto;
  min-width: 0;
}

.local-ai-risk-table {
  display: grid;
  grid-template-columns: 42px 64px 82px minmax(132px, 0.95fr) 64px repeat(2, minmax(78px, 0.6fr));
  border: 1px solid rgba(108, 76, 46, 0.14);
  border-radius: 8px;
  overflow-x: auto;
  min-width: 0;
}

.local-ai-threat-projection-table {
  display: grid;
  grid-template-columns: 42px minmax(118px, 0.8fr) minmax(92px, 0.55fr) repeat(3, minmax(58px, 0.36fr)) minmax(92px, 0.55fr);
  border: 1px solid rgba(108, 76, 46, 0.14);
  border-radius: 8px;
  overflow-x: hidden;
  min-width: 0;
}

.local-ai-choice-table {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 52px 88px 88px 58px 70px 84px minmax(130px, 1.2fr);
  border: 1px solid rgba(108, 76, 46, 0.1);
  border-radius: 8px;
  overflow-x: auto;
  min-width: 0;
}

.local-ai-rule-inference-table {
  display: grid;
  grid-template-columns:
    minmax(92px, 0.72fr)
    50px
    minmax(86px, 0.68fr)
    minmax(118px, 0.86fr)
    minmax(118px, 0.86fr)
    46px
    46px
    68px
    minmax(136px, 0.9fr)
    minmax(110px, 0.72fr)
    minmax(110px, 0.72fr)
    54px
    minmax(170px, 1fr);
  border: 1px solid rgba(108, 76, 46, 0.14);
  border-radius: 8px;
  overflow-x: hidden;
  min-width: 0;
}

.local-ai-rule-inference-table .local-ai-candidate-head,
.local-ai-rule-inference-table .local-ai-candidate-cell {
  padding: 7px 8px;
  align-items: flex-start;
  font-size: 12px;
  line-height: 1.35;
}

.local-ai-rule-inference-table .local-ai-particle-assumptions {
  font-family: inherit;
  font-size: 12px;
}

.local-ai-particle-table {
  display: grid;
  grid-template-columns: 56px 78px minmax(140px, 0.8fr) 72px minmax(420px, 2.2fr);
  border: 1px solid rgba(108, 76, 46, 0.14);
  border-radius: 8px;
  overflow-x: auto;
  min-width: 0;
}

.local-ai-candidate-head,
.local-ai-candidate-cell {
  min-height: 38px;
  padding: 8px 9px;
  border-right: 1px solid rgba(108, 76, 46, 0.1);
  border-bottom: 1px solid rgba(108, 76, 46, 0.1);
  display: flex;
  align-items: center;
  min-width: 0;
  overflow-wrap: anywhere;
}

.local-ai-candidate-head {
  color: var(--muted);
  background: rgba(184, 110, 52, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.local-ai-candidate-cell {
  color: var(--text);
  background: rgba(255, 251, 243, 0.72);
  font-size: 13px;
  line-height: 1.35;
}

.local-ai-candidate-rank,
.local-ai-candidate-score {
  font-weight: 900;
}

.local-ai-position-confidence-cell {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 4px;
}

.local-ai-position-confidence-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 6px;
  border: 1px solid rgba(108, 76, 46, 0.12);
  border-radius: 999px;
  background: rgba(255, 247, 232, 0.88);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.local-ai-position-confidence-chip--unallocated {
  color: var(--muted);
  background: rgba(245, 236, 222, 0.8);
}

.local-ai-piece-value-label,
.local-ai-piece-value-piece {
  font-weight: 900;
}

.local-ai-piece-value-piece {
  color: var(--accent);
  justify-content: center;
}

.local-ai-piece-value-formula {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.25;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.local-ai-score-formula {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.25;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.local-ai-opponent-reply {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  white-space: normal;
  word-break: break-word;
}

.local-ai-piece-instance-status {
  font-weight: 900;
}

.local-ai-mini-heading {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  margin-top: 8px;
}

.local-ai-particle-assumptions {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.local-ai-candidate-action {
  color: var(--accent);
  font-weight: 800;
}

.local-ai-candidate-rule {
  color: var(--red);
  font-weight: 900;
}

.local-ai-event-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.local-ai-event-item {
  min-width: 0;
  border: 1px solid rgba(108, 76, 46, 0.12);
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(242, 250, 244, 0.62);
}

.local-ai-event-title {
  color: var(--green);
  font-weight: 900;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.local-ai-event-detail {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.local-ai-muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.lobby-room-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: stretch;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* 右側欄撐滿高度，改用 flex 縱向排列 */
#rightRail {
  align-self: stretch;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: transparent;
  gap: inherit;
}

#chatRail {
  align-self: stretch;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: transparent;
  gap: inherit;
}

.info-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-card-body {
  padding-top: 0;
}

.leaderboard-card {
  min-height: 0;
  overflow: hidden;
}

.leaderboard-card-body {
  padding-top: 0;
}

.leaderboard-list {
  display: grid;
  gap: 10px;
  max-height: min(48vh, 420px);
  overflow: auto;
  padding-right: 2px;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(184, 110, 52, 0.08);
}

.leaderboard-rank {
  min-width: 0;
  padding: 0;
  color: #8b4c1e;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.leaderboard-main {
  min-width: 0;
  display: block;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.leaderboard-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-score {
  flex: 0 0 auto;
  color: #8b4c1e;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}

.language-switch {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  width: 100%;
}

.font-select-control {
  display: grid;
  gap: 4px;
  width: 100%;
}

.font-select-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.font-select-input {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid rgba(122, 91, 59, 0.18);
  background: rgba(255, 251, 243, 0.95);
  color: var(--text);
  font: inherit;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

select.font-select-input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.25 4.5L6 8.25L9.75 4.5' stroke='%23735B44' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px 12px;
}

.font-select-input:focus {
  border-color: rgba(184, 110, 52, 0.45);
  box-shadow: 0 0 0 3px rgba(184, 110, 52, 0.12);
}

.language-switch .ghost-btn.active {
  background: rgba(191, 83, 52, 0.14);
  border-color: rgba(191, 83, 52, 0.3);
  color: var(--accent-strong);
}

.audio-control {
  display: grid;
  gap: 5px;
  width: 100%;
  max-width: 560px;
  justify-self: start;
}

.audio-control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 184px;
  align-items: end;
  gap: 10px;
  width: 100%;
}

.audio-control-row--with-style {
  grid-template-columns: minmax(0, 1fr) auto 160px;
  align-items: center;
  column-gap: 8px;
}

.page-link-control {
  display: grid;
  gap: 6px;
  width: 100%;
}

.page-link-label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
}

.page-link-list {
  display: grid;
  gap: 6px;
  width: 100%;
}

.page-link-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.audio-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  width: 100%;
}

.audio-control-label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.05;
  transform: translateY(2px);
}

.audio-control-value {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.audio-control-inline-value {
  min-width: 50px;
  text-align: right;
  align-self: center;
  margin-left: -2px;
  transform: translateX(-10px);
}

.sound-volume-slider {
  width: min(100%, 320px);
  accent-color: var(--accent);
  cursor: pointer;
}

.audio-control-row .sound-volume-slider {
  flex: none;
  min-width: 0;
  width: 100%;
  max-width: none;
}

.sound-style-control {
  width: 160px;
  min-width: 160px;
  justify-self: start;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  gap: 6px;
  margin-left: -4px;
}

.sound-style-select {
  min-width: 0;
  width: 100%;
}

.sound-preview-btn {
  min-width: 38px;
  width: 38px;
  padding: 0;
  justify-self: end;
  font-size: 12px;
  font-weight: 900;
}

.audio-control:not(.audio-control--with-style) .sound-volume-slider {
  max-width: 300px;
}

@media (max-width: 760px) {
  .audio-control {
    max-width: 100%;
  }

  .audio-control-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .audio-control-row--with-style {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .audio-control-row--with-style .sound-style-control {
    grid-column: 1 / -1;
    width: min(160px, 100%);
    min-width: 0;
    margin-left: 0;
  }

  .audio-control:not(.audio-control--with-style) .sound-volume-slider,
  .audio-control--with-style .sound-volume-slider {
    max-width: 100%;
  }
}

.info-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(184, 110, 52, 0.12);
  color: #8b4c1e;
  font-size: 12px;
  font-weight: 800;
}

.info-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  color: var(--text);
  line-height: 1.65;
  font-size: 14px;
}

.info-note {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(184, 110, 52, 0.08);
  color: var(--muted);
  line-height: 1.6;
  font-size: 13px;
}

#rightRail .profile-card {
  flex-shrink: 0;
}

#chatRail .chat-block {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

#chatRail .chat-list {
  flex: 1;
  min-height: 0;
  max-height: none;
}

/* history-block 固定不撐高 */
#rightRail .history-block {
  flex-shrink: 0;
}

.online-hero .subtitle {
  font-size: 15px;
}

.online-hero {
  padding-bottom: 18px;
}

.online-hero .hero-tags {
  gap: 8px;
}

.online-hero .hero-tags span {
  padding: 10px 16px;
}

.form-stack {
  display: grid;
  gap: 6px;
}

.auto-name-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.text-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(108, 76, 46, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font: inherit;
  padding: 0 12px;
  outline: none;
}

.text-input:focus {
  border-color: rgba(184, 110, 52, 0.55);
  box-shadow: 0 0 0 3px rgba(184, 110, 52, 0.12);
}

.room-action-row {
  display: flex;
  gap: 6px;
}

.primary-btn {
  background: rgba(184, 110, 52, 0.16);
  color: #8b4c1e;
  font-weight: 700;
}

.primary-btn:hover {
  background: rgba(184, 110, 52, 0.24);
}

.room-meta {
  margin-top: 0;
}

.timer-urgent {
  color: #9f3026;
}

.room-meta dd.online {
  color: #2f6d42;
}

.room-meta dd.offline {
  color: #9f3026;
}

.room-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.room-list-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.room-toggle-btn {
  min-width: 56px;
  height: 32px;
  padding: 0 12px;
}

.room-list-head h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text);
}

.room-list {
  margin-top: 6px;
  min-height: 360px;
  max-height: none;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 4px;
  align-content: start;
  flex: 1;
}

.room-list-actions[hidden] {
  display: none !important;
}

.room-list.hidden {
  display: none !important;
}

.room-list-panel {
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.standalone-room-list-panel {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bulletin-section {
  display: grid;
  gap: 6px;
  padding-bottom: 0;
}

#bulletinCard.collapsed {
  gap: 0;
}

#bulletinCard.collapsed .bulletin-section {
  gap: 0;
  padding-bottom: 0;
}

.bulletin-head {
  margin-bottom: 0;
}

.bulletin-body[hidden] {
  display: none !important;
}

.bulletin-text {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(184, 110, 52, 0.08);
}

.joined-only {
  display: none;
}

.lobby-only {
  display: none;
}

.joined-only[hidden] {
  display: none !important;
}

.lobby-only[hidden] {
  display: none !important;
}

body.in-room .joined-only {
  display: block;
}

body.online-lobby .lobby-only {
  display: block;
}

body.in-room .joined-only.board-panel {
  display: flex;
}

body.in-room .joined-only.action-card {
  display: flex;
  flex-direction: column;
}

body.in-room .replay-controls {
  display: grid;
}

body.in-room .replay-controls.hidden {
  display: none !important;
}

body.online-lobby .left-rail,
body.online-lobby #rightRail {
  display: none;
}

body.in-room #rightRail {
  display: flex;
}

.lobby-note-panel {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(184, 110, 52, 0.08);
  color: var(--muted);
  line-height: 1.6;
}

.lobby-note-panel {
  display: grid;
  gap: 12px;
}

body.windowed-mode .page-shell.online-shell {
  justify-content: flex-start;
}

body.windowed-mode .online-layout {
  transform-origin: top left;
  transform: scale(var(--windowed-room-scale, 1));
  width: max(var(--windowed-room-base-width, 1360px), calc(100% / var(--windowed-room-scale, 1)));
  height: calc(var(--windowed-room-available-height, 720px) / var(--windowed-room-scale, 1));
  gap: 12px;
  justify-content: start;
}

body.windowed-mode.in-room[data-active-game-family="xiangqi"] .online-layout {
  grid-template-columns: 220fr 222fr 620fr 248fr 225fr;
}

body.windowed-mode.in-room[data-active-game-family="dark_chess"] .online-layout {
  grid-template-columns: 210fr 228fr 572fr 250fr 238fr;
}

body.windowed-mode .left-rail,
body.windowed-mode #rightRail,
body.windowed-mode #chatRail {
  gap: 10px;
}

body.windowed-mode .left-rail .panel-block,
body.windowed-mode #rightRail .panel-block,
body.windowed-mode #chatRail .panel-block {
  padding: 10px 10px 12px;
}

body.windowed-mode .left-rail .online-hero {
  padding-bottom: 12px;
}

body.windowed-mode .online-hero .subtitle {
  font-size: 14px;
  line-height: 1.55;
}

body.windowed-mode .online-hero .hero-tags {
  margin-top: 14px;
  gap: 6px;
}

body.windowed-mode .online-hero .hero-tags span {
  min-height: 34px;
  padding: 0 12px;
}

body.windowed-mode .board-panel {
  padding: 8px;
}

body.windowed-mode .board-column .canvas-wrap {
  max-width: none;
}

body.windowed-mode .lobby-room-rail,
body.windowed-mode .left-rail,
body.windowed-mode .board-column,
body.windowed-mode #rightRail {
  max-height: none;
  height: 100%;
}

body.windowed-mode .board-column {
  overflow: hidden;
}

body.windowed-mode .tips {
  font-size: 13px;
  line-height: 1.45;
}

body.windowed-mode .profile-name {
  font-size: 24px;
}

.profile-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.profile-head h2 {
  margin: 0;
}

.profile-head-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
}

.panel-toggle-btn {
  min-width: 64px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(184, 110, 52, 0.12);
  color: #8b4c1e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  flex-shrink: 0;
  margin-left: auto;
  transition: background 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.panel-toggle-btn:hover,
.panel-toggle-btn:focus-visible {
  background: rgba(184, 110, 52, 0.2);
  box-shadow: 0 6px 14px rgba(107, 79, 51, 0.14);
  outline: none;
}

.profile-card.collapsed {
  gap: 0;
}

.profile-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 0;
  min-height: 0;
}

#moveTimerCardBody,
#statusCardBody {
  padding-top: 6px;
}

.profile-card-body[hidden],
.bulletin-body[hidden] {
  display: none !important;
}

.profile-card.collapsed .profile-card-body {
  display: none;
}

.profile-tag {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(184, 110, 52, 0.12);
  color: #8b4c1e;
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.profile-main {
  display: grid;
  gap: 4px;
}

.profile-name {
  font-size: 24px;
  font-weight: 900;
  color: var(--text);
  line-height: 1.2;
  word-break: break-word;
}

.profile-subtitle {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.profile-auth-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(184, 110, 52, 0.06);
  min-width: 0;
  overflow: visible;
}

.google-signin-mount {
  --google-signin-button-render-width: 260px;
  --google-signin-provider-frame-width: 280px;
  --google-signin-provider-frame-height: 44px;
  width: var(--google-signin-provider-frame-width);
  height: var(--google-signin-provider-frame-height);
  min-height: var(--google-signin-provider-frame-height);
  max-width: 100%;
  min-width: 0;
  overflow: visible;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  border-radius: 999px;
  outline: none;
  box-shadow: none;
}

.google-signin-mount[hidden] {
  display: none !important;
}

.google-signin-mount > div {
  display: block;
  width: var(--google-signin-provider-frame-width) !important;
  min-width: var(--google-signin-provider-frame-width) !important;
  max-width: none !important;
}

.google-signin-mount > div > div:first-child {
  display: none !important;
}

.google-signin-mount iframe {
  display: block;
  width: var(--google-signin-provider-frame-width) !important;
  min-width: var(--google-signin-provider-frame-width) !important;
  max-width: none !important;
  margin: 0 !important;
  transform: none !important;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 999px !important;
}

.google-signin-mount .nsm7Bb-HzV7m-LgbsSe {
  border-radius: 999px !important;
}

.google-signin-mount .nsm7Bb-HzV7m-LgbsSe:focus,
.google-signin-mount .nsm7Bb-HzV7m-LgbsSe:focus-visible,
.google-signin-mount .nsm7Bb-HzV7m-LgbsSe:focus-within {
  outline: none !important;
  box-shadow: none !important;
}

.google-signin-mount:focus,
.google-signin-mount:focus-visible,
.google-signin-mount:focus-within,
.google-signin-mount > div:focus,
.google-signin-mount > div:focus-visible,
.google-signin-mount iframe:focus,
.google-signin-mount iframe:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

.profile-auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.auth-switch-btn {
  justify-self: start;
}

.auth-switch-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.profile-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.profile-stat-pill {
  width: 100%;
  padding: 6px 9px;
  border-radius: 16px;
  background: rgba(184, 110, 52, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  line-height: 1.2;
}

#profileRatingPill[hidden] {
  display: none !important;
}

.profile-stat-pill-wide {
  grid-column: 1 / -1;
}

.profile-stat-label {
  color: var(--muted);
  font-weight: 700;
}

.profile-stat-value {
  color: var(--text);
  font-weight: 800;
  font-size: 16px;
}

.room-card {
  border: 1px solid rgba(108, 76, 46, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  padding: 14px 14px 12px;
  display: grid;
  gap: 10px;
  box-shadow: 0 10px 24px rgba(112, 79, 48, 0.06);
}

.room-card.current {
  border-color: rgba(184, 110, 52, 0.36);
  background: rgba(255, 247, 236, 0.88);
}

.room-card.joinable {
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.room-card.joinable:hover {
  transform: translateY(-1px);
  border-color: rgba(184, 110, 52, 0.28);
  box-shadow: 0 14px 28px rgba(112, 79, 48, 0.1);
}

.room-card.full {
  opacity: 0.84;
}

.room-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.room-card-code {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.06em;
}

.online-player-name {
  font-size: 15px;
  letter-spacing: 0.02em;
}

.room-card-status {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: #8b4c1e;
  background: rgba(184, 110, 52, 0.14);
}

.room-card-status.live {
  color: #2f6d42;
  background: rgba(93, 189, 134, 0.18);
}

.room-card-status.full {
  color: #8f2f2a;
  background: rgba(173, 76, 66, 0.14);
}

.room-slots {
  display: grid;
  gap: 8px;
}

.room-slot {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  font-size: 14px;
  color: var(--muted);
}

.room-slot-label {
  font-weight: 800;
  color: #8b4c1e;
}

.room-slot-label[data-seat="red"] {
  color: #b23a2d;
}

.room-slot-label[data-seat="black"] {
  color: #2d2d2d;
}

.room-slot-label[data-seat="white"] {
  color: #6b6257;
}

.room-slot-name {
  min-width: 0;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-slot-name.empty {
  color: rgba(108, 76, 46, 0.54);
  font-weight: 600;
}

.room-card-action {
  display: flex;
}

.room-card-action .ghost-btn {
  width: 100%;
}

.room-empty {
  border-radius: 18px;
  background: rgba(184, 110, 52, 0.08);
  color: var(--muted);
  text-align: center;
  padding: 14px 12px;
  line-height: 1.6;
}

.chat-block {
  --chat-font-size: 15px;
  min-height: 240px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-head h2 {
  margin: 0;
  font-size: 18px;
}

.chat-font-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-font-controls .panel-toggle-btn {
  margin-left: 0;
}

.chat-font-btn {
  min-width: 36px;
  height: 32px;
  padding: 0 8px;
  font-size: 18px;
  line-height: 1;
}

.chat-clear-btn {
  min-width: 56px;
  height: 32px;
  padding: 0 10px;
}

.chat-list {
  min-height: 160px;
  max-height: 240px;
  overflow: auto;
  border-radius: 18px;
  background: rgba(184, 110, 52, 0.06);
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  align-content: start;
  justify-items: stretch;
  grid-auto-rows: max-content;
}

.chat-item {
  width: 100%;
  min-width: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  line-height: 1.4;
  font-size: var(--chat-font-size);
  word-break: break-word;
  align-self: start;
}

.chat-item.self {
  background: transparent;
}

.chat-item.system {
  background: transparent;
  color: var(--muted);
}

.chat-item.system.seat-resolution-notice {
  font-size: calc(var(--chat-font-size) * 1.2);
  font-weight: 800;
  color: #8b4c1e;
  white-space: pre-line;
  word-break: keep-all;
}

.chat-meta {
  display: block;
  margin-bottom: 2px;
  font-size: calc(var(--chat-font-size) * 1.08);
  font-weight: 700;
  color: var(--muted);
}

.chat-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

@media (max-width: 1180px) {
  .chat-list {
    max-height: 240px;
  }

  .local-ai-summary-grid,
  .local-ai-summary-grid--compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .local-ai-event-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .platform-switch-bar {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .platform-utility-nav {
    width: 100%;
    justify-content: flex-start;
    justify-self: stretch;
  }

  .platform-switch-controls {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .platform-game-select-control {
    max-width: 220px;
    min-width: 0;
    width: 100%;
    justify-self: stretch;
  }

  .local-ai-summary-grid,
  .local-ai-summary-grid--compact,
  .local-ai-vision-board-pair,
  .local-ai-event-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .local-ai-section-tabs {
    gap: 5px;
  }

  .local-ai-section-tab {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 13px;
  }

  .local-ai-candidate-table {
    grid-template-columns: 44px minmax(96px, 0.74fr) repeat(23, minmax(34px, 0.28fr)) minmax(120px, 0.8fr);
  }

  .local-ai-vision-cell {
    padding: 2px;
  }

  .local-ai-vision-river {
    padding: 5px 0;
    font-size: 14px;
  }

  .local-ai-vision-cell-count {
    font-size: 12px;
  }

  .local-ai-piece-instance-table {
    grid-template-columns: 46px 48px 64px minmax(112px, 1.05fr) 64px minmax(78px, 0.85fr) 66px 38px repeat(5, minmax(48px, 0.5fr)) 48px minmax(120px, 0.85fr);
  }

  .local-ai-score-component-table {
    grid-template-columns: minmax(84px, 0.8fr) minmax(76px, 0.7fr) 56px minmax(108px, 0.9fr) minmax(170px, 1.35fr) 48px minmax(220px, 1.4fr);
  }

  .local-ai-decision-flow-table {
    grid-template-columns: 38px 58px minmax(96px, 0.8fr) 58px 64px minmax(132px, 1.05fr) minmax(118px, 0.95fr) minmax(126px, 1fr) 62px;
  }

  .local-ai-risk-table {
    grid-template-columns: 38px 58px 76px minmax(112px, 0.95fr) 58px repeat(2, minmax(66px, 0.6fr));
  }

  .local-ai-choice-table {
    grid-template-columns: minmax(96px, 1fr) 48px 78px 78px 52px 64px 76px minmax(112px, 1.2fr);
  }

  .local-ai-particle-table {
    grid-template-columns: 50px 70px minmax(110px, 0.8fr) 64px minmax(320px, 2.2fr);
  }
}
