:root {
  --gold: #cda45b;
  --gold-bright: #f0c978;
  --ink: #140e09;
  --paper: #eee0bf;
  --red: #ff6a55;
  --blue: #7fa8ff;
  --font-chinese: "Noto Serif SC", "Songti SC", "STSong", serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  overflow-x: hidden;
  background: radial-gradient(circle at 50% 42%, #382516 0, #17100b 44%, #090706 100%);
  font-family: var(--font-chinese);
  color: var(--paper);
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  /* three.js 会以 px 写内联宽高；浏览器缩放/字体放大时会撑破视口，故强制锁定到视口 */
  width: 100% !important;
  height: 100% !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  cursor: grab;
  touch-action: none;
}
#scene:active { cursor: grabbing; }

.hud-top, #panel, #hintBar, .battle-controls, .demo-trigger { transition: opacity 0.18s ease, visibility 0.18s ease; }
body.general-cinematic-active .hud-top,
body.general-cinematic-active .online-side-controls,
body.general-cinematic-active #panel,
body.general-cinematic-active #hintBar,
body.general-cinematic-active .battle-controls,
body.general-cinematic-active .demo-trigger {
  opacity: 0;
  visibility: hidden;
}

/* ---------- 首帧加载 / 错误兜底 ---------- */
#bootScreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  color: #f0ce8d;
  background:
    radial-gradient(circle at 50% 48%, rgba(129, 70, 31, 0.38), transparent 25%),
    linear-gradient(145deg, #21150d, #080706 72%);
  transition: opacity 0.65s ease, visibility 0.65s ease;
}
#bootScreen::before {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(205, 164, 91, 0.28);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
#bootScreen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-emblem { display: flex; align-items: center; gap: 18px; font-family: var(--font-chinese); font-size: 54px; font-weight: 900; }
.boot-emblem span:first-child { color: #ef755d; text-shadow: 0 0 25px rgba(218, 62, 38, 0.55); }
.boot-emblem span:last-child { color: #9bbbea; text-shadow: 0 0 25px rgba(77, 124, 199, 0.55); }
.boot-emblem i { width: 1px; height: 46px; background: linear-gradient(transparent, #d4ad62, transparent); transform: rotate(24deg); }
#bootText { font-size: 14px; letter-spacing: 6px; color: rgba(240, 224, 191, 0.72); }
.boot-line { width: 210px; height: 2px; overflow: hidden; background: rgba(205, 164, 91, 0.16); }
.boot-line b { display: block; width: 42%; height: 100%; background: linear-gradient(90deg, transparent, #edbd63, transparent); animation: bootSweep 1.4s ease-in-out infinite; }
#bootScreen.error #bootText { max-width: 520px; text-align: center; color: #ff9e88; line-height: 1.8; }
#bootScreen.error .boot-line b { background: #b94a36; animation: none; }
@keyframes bootSweep { from { transform: translateX(-120%); } to { transform: translateX(340%); } }
.noscript { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; background: #140e09; color: #f0c978; }

.demo-trigger {
  position: fixed;
  left: 50%;
  bottom: 64px;
  z-index: 25;
  transform: translateX(-50%);
  padding: 10px 24px;
  color: #2a1608;
  font: 700 14px/1 var(--font-chinese);
  letter-spacing: 3px;
  background: linear-gradient(145deg, #f1ce83, #b8873e);
  border: 1px solid #ffdf99;
  border-radius: 999px;
  box-shadow: 0 8px 30px rgba(190, 126, 48, 0.36);
  cursor: pointer;
}
.demo-trigger:hover { filter: brightness(1.1); }

/* ---------- 顶部 HUD ---------- */
.hud-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 28px;
  background: linear-gradient(180deg, rgba(12, 8, 6, 0.9), rgba(12, 8, 6, 0));
  pointer-events: none;
  z-index: 10;
}
.hud-top > * { pointer-events: auto; }

.seal {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #a02318, #6d1512);
  border: 2px solid var(--gold);
  border-radius: 8px;
  font-family: var(--font-chinese);
  font-size: 30px;
  font-weight: 900;
  color: #ffd9a0;
  box-shadow: 0 4px 18px rgba(160, 35, 24, 0.45);
  transform: rotate(-4deg);
}

.brand h1 {
  font-family: var(--font-chinese);
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--gold-bright);
  text-shadow: 0 2px 12px rgba(201, 162, 90, 0.35);
  line-height: 1.1;
}
.brand p {
  font-size: 12px;
  letter-spacing: 4px;
  color: rgba(232, 220, 192, 0.55);
  margin-top: 2px;
}

.turn {
  margin-left: auto;
  padding: 8px 22px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 3px;
  transition: all 0.4s ease;
}
.turn.red {
  color: #ffd9c8;
  background: rgba(160, 35, 24, 0.35);
  box-shadow: 0 0 18px rgba(255, 90, 60, 0.25), inset 0 0 12px rgba(255, 90, 60, 0.12);
}
.turn.black {
  color: #d4e4ff;
  background: rgba(30, 50, 80, 0.4);
  box-shadow: 0 0 18px rgba(80, 130, 255, 0.25), inset 0 0 12px rgba(80, 130, 255, 0.12);
}

.actions { display: flex; gap: 10px; }
.actions button {
  font-family: var(--font-chinese);
  font-size: 14px;
  letter-spacing: 2px;
  padding: 8px 16px;
  color: var(--gold-bright);
  background: rgba(201, 162, 90, 0.08);
  border: 1px solid rgba(201, 162, 90, 0.5);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.actions button:hover {
  background: rgba(201, 162, 90, 0.22);
  box-shadow: 0 0 14px rgba(201, 162, 90, 0.3);
  transform: translateY(-1px);
}

/* 房间左侧竖排：桌面人机/双人/联机共用同一容器和样式；手机联机另有横排覆盖 */
#onlineSideControls { display: none; }
body.room-side-controls #onlineSideControls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: fixed;
  top: 96px;
  left: 14px;
  z-index: 11;
  width: 96px;
  padding: 8px;
  box-sizing: border-box;
  background: linear-gradient(150deg, rgba(40, 24, 14, 0.88), rgba(12, 10, 9, 0.86));
  border: 1px solid rgba(205, 164, 91, 0.38);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
body.room-side-controls #onlineSideControls > * {
  width: 100%;
  box-sizing: border-box;
}
body.room-side-controls #onlineSideControls .turn {
  margin-left: 0;
  padding: 8px 4px;
  font-size: 13px;
  letter-spacing: 1px;
  text-align: center;
  border-radius: 6px;
}
body.room-side-controls #onlineSideControls button {
  justify-content: center;
  text-align: center;
  padding: 8px 6px;
  font-size: 13px;
  letter-spacing: 1px;
}
/* 复盘按钮（入口 + 操作）在左侧列永远排在原按钮之后，绝不置顶。
   用 flex order 而非 DOM 顺序控制，避免 initReview 早于 syncOnlineSideControls 导致复盘按钮抢占首位。 */
body.room-side-controls #onlineSideControls > #btnReview,
body.room-side-controls #onlineSideControls > .rv-ctl { order: 10 !important; }

/* 房间顶部：操作组靠最右；联机隐藏“返回房间”，人机/双人保留“大厅 + 返回房间 + 全屏图标” */
body.room-side-controls .hud-top .actions { margin-left: auto; }
body.online-mode #btnReturnRoom { display: none; }
body.room-side-controls #btnBackToLobby { order: 2; }
body.room-side-controls #btnReturnRoom { order: 3; }
body.room-side-controls #btnFullscreen {
  order: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  padding: 6px;
  letter-spacing: 0;
}
#btnFullscreen .fullscreen-icon {
  display: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
body.room-side-controls #btnFullscreen .btn-text { display: none; }
body.room-side-controls #btnFullscreen .icon-enter { display: block; }
body.room-side-controls #btnFullscreen.is-active .icon-enter { display: none; }
body.room-side-controls #btnFullscreen.is-active .icon-exit { display: block; }
.repo-link,
.return-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 500 14px/1 var(--font-chinese);
  letter-spacing: 1px;
  padding: 8px 14px;
  color: var(--gold-bright);
  text-decoration: none;
  background: rgba(201, 162, 90, 0.08);
  border: 1px solid rgba(201, 162, 90, 0.5);
  border-radius: 6px;
  transition: all 0.25s ease;
}
.repo-link:hover,
.return-link:hover {
  background: rgba(201, 162, 90, 0.22);
  box-shadow: 0 0 14px rgba(201, 162, 90, 0.3);
  transform: translateY(-1px);
}

/* ---------- 联机对局计时（局时/步时/读秒，仅提示不判负） ---------- */
.chess-clock {
  position: fixed;
  top: 88px;
  right: 28px;
  z-index: 12;
  display: grid;
  gap: 4px;
  min-width: 132px;
  padding: 8px 12px;
  font-family: var(--font-chinese);
  color: var(--paper);
  background: linear-gradient(110deg, rgba(57, 34, 18, 0.92), rgba(13, 12, 12, 0.9));
  border: 1px solid rgba(205, 164, 91, 0.38);
  border-right: 3px solid #9c3927;
  border-radius: 4px 9px 9px 4px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.32);
}
.chess-clock[hidden] { display: none; }
.clock-side {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 5px;
  border: 1px solid transparent;
  transition: background 0.25s ease, border-color 0.25s ease;
}
.clock-side .clock-name { font-size: 12px; letter-spacing: 2px; opacity: 0.7; }
.clock-side .clock-main {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}
.clock-side .clock-step { font-size: 11px; letter-spacing: 1px; opacity: 0.75; text-align: right; min-width: 62px; }
.clock-side.red.active {
  background: rgba(160, 35, 24, 0.28);
  border-color: rgba(255, 90, 60, 0.5);
  box-shadow: inset 0 0 12px rgba(255, 90, 60, 0.12);
}
.clock-side.black.active {
  background: rgba(30, 50, 80, 0.4);
  border-color: rgba(80, 130, 255, 0.5);
  box-shadow: inset 0 0 12px rgba(80, 130, 255, 0.12);
}
.clock-side.overtime .clock-step { color: #ff9a6c; font-weight: 700; opacity: 1; }
.clock-side.paused { opacity: 0.55; }
.clock-vs { text-align: center; font-size: 10px; letter-spacing: 4px; color: rgba(205, 164, 91, 0.7); }

/* ---------- 对弈军令 ---------- */
.battle-controls {
  position: fixed;
  top: 88px;
  left: 26px;
  z-index: 12;
  display: grid;
  gap: 6px;
  padding: 6px;
  color: var(--paper);
  background:
    linear-gradient(110deg, rgba(57, 34, 18, 0.92), rgba(13, 12, 12, 0.9)),
    repeating-linear-gradient(90deg, transparent 0 18px, rgba(238, 199, 117, 0.05) 19px 20px);
  border: 1px solid rgba(205, 164, 91, 0.38);
  border-left: 3px solid #9c3927;
  border-radius: 4px 9px 9px 4px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.32), inset 0 0 22px rgba(205, 164, 91, 0.04);
  /* 避免持续变化的 WebGL 画布与实时背景模糊发生跨 GPU 合成闪烁。 */
}
.control-row { display: flex; align-items: center; }
.visual-row, .ai-row { min-height: 38px; padding-top: 6px; border-top: 1px solid rgba(205, 164, 91, 0.18); }
.visual-row { align-items: flex-end; gap: 8px; }
.battle-controls button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 5px 11px;
  color: inherit;
  font-family: var(--font-chinese);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.battle-controls button:hover { background: rgba(232, 192, 112, 0.1); }
.actions button.undo-urgent {
  color: #fff3d6;
  background: linear-gradient(135deg, #b3402e, #d98b2b);
  border-color: rgba(255, 220, 150, 0.7);
  box-shadow: 0 0 0 1px rgba(255, 220, 150, 0.5), 0 0 18px rgba(217, 139, 43, 0.45);
}
.actions button.undo-urgent:hover { background: linear-gradient(135deg, #c64a35, #e89a32); }
.battle-controls small {
  display: block;
  margin-bottom: 3px;
  color: rgba(238, 224, 191, 0.5);
  font-size: 9px;
  line-height: 1;
  letter-spacing: 2px;
}
.battle-controls b { display: block; font-size: 13px; line-height: 1; letter-spacing: 2px; }
.mode-picker, .visual-picker { display: grid; align-content: center; gap: 4px; }
.mode-picker > small, .visual-picker > small { margin: 0 0 0 3px; }
.mode-options, .visual-options { display: flex; gap: 3px; }
.battle-controls .mode-option {
  min-height: 29px;
  padding: 6px 10px;
  color: rgba(238, 224, 191, 0.6);
  font-size: 12px;
  line-height: 1;
  letter-spacing: 1px;
  border: 1px solid transparent;
}
.battle-controls .visual-option {
  min-height: 29px;
  padding: 6px 9px;
  color: rgba(238, 224, 191, 0.6);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 1px;
  border: 1px solid transparent;
}
.battle-controls .mode-option.active,
.battle-controls .visual-option.active {
  color: #ffe0a0;
  background: linear-gradient(145deg, rgba(153, 48, 31, 0.72), rgba(96, 29, 22, 0.62));
  border-color: rgba(240, 190, 97, 0.68);
  box-shadow: inset 0 0 13px rgba(255, 180, 76, 0.1), 0 0 10px rgba(157, 48, 27, 0.2);
}
.motion-choice { display: grid; align-content: center; gap: 4px; padding-right: 4px; }
.motion-choice small { margin: 0; }
.motion-choice select {
  min-width: 58px;
  padding: 5px 6px;
  color: #f3d99f;
  font: 600 11px/1 var(--font-chinese);
  background: #21160f;
  border: 1px solid rgba(205, 164, 91, 0.34);
  border-radius: 4px;
}
.motion-choice select:focus-visible { border-color: rgba(240, 190, 97, 0.78); box-shadow: 0 0 0 2px rgba(240, 190, 97, 0.12); outline: none; }
.ai-controls {
  display: flex;
  align-items: stretch;
}
.ai-controls[hidden] { display: none; }
.ai-choice { display: grid; align-content: center; gap: 4px; padding: 0 9px; }
.ai-choice + .ai-choice { border-left: 1px solid rgba(205, 164, 91, 0.14); }
.ai-choice small { margin: 0; }
.ai-choice select {
  min-width: 72px;
  color: #f3d99f;
  font: 600 11px/1 var(--font-chinese);
  background: #21160f;
  border: 1px solid rgba(205, 164, 91, 0.34);
  border-radius: 4px;
  padding: 5px 7px;
  cursor: pointer;
  outline: none;
}
.ai-choice select:focus { border-color: rgba(240, 190, 97, 0.78); box-shadow: 0 0 0 2px rgba(240, 190, 97, 0.1); }
.ai-choice select:disabled { opacity: 0.5; cursor: wait; }
.ai-status {
  align-self: center;
  width: 7px;
  height: 7px;
  margin: 0 7px 0 2px;
  border-radius: 50%;
  background: #846c45;
  box-shadow: 0 0 0 3px rgba(132, 108, 69, 0.12);
}
.ai-status.ready { background: #7cbd79; box-shadow: 0 0 11px rgba(124, 189, 121, 0.7); }
.ai-status.thinking { background: #f0c978; animation: aiPulse 0.8s ease-in-out infinite alternate; }
.ai-status.error { background: #e1634c; box-shadow: 0 0 11px rgba(225, 99, 76, 0.65); }
@keyframes aiPulse { to { opacity: 0.35; transform: scale(0.72); } }

html[data-motion="simple"] .chip,
html[data-motion="simple"] #checkBanner.show,
html[data-motion="off"] .chip,
html[data-motion="off"] #checkBanner.show,
html[data-motion="off"] .ai-status { animation: none; }

body.classic-view #scene { cursor: default; }

/* ---------- 联机军帐 ---------- */
.online-dialog {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  max-width: 100vw;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: radial-gradient(circle at 50% 42%, rgba(75, 39, 20, 0.3), rgba(5, 4, 3, 0.82));
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.online-dialog.show { opacity: 1; visibility: visible; pointer-events: auto; }
.online-card {
  position: relative;
  width: min(430px, 100%);
  max-width: 100%;
  min-width: 0;
  margin: auto;
  flex: 0 1 auto;
  padding: 34px 38px 36px;
  color: var(--paper);
  text-align: center;
  background:
    linear-gradient(145deg, rgba(64, 39, 22, 0.98), rgba(16, 13, 11, 0.98)),
    repeating-linear-gradient(0deg, transparent 0 23px, rgba(238, 199, 117, 0.04) 24px);
  border: 1px solid rgba(232, 192, 112, 0.5);
  border-radius: 3px 16px 3px 16px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.62), inset 0 0 50px rgba(205, 164, 91, 0.05);
  transform: translateY(14px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.online-dialog.show .online-card { transform: translateY(0) scale(1); }
.online-card::before,
.online-card::after {
  content: "";
  position: absolute;
  width: 52px;
  height: 1px;
  top: 19px;
  background: var(--gold);
}
.online-card::before { left: 18px; }
.online-card::after { right: 18px; }
.online-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 30px;
  height: 30px;
  color: rgba(238, 224, 191, 0.55);
  font-size: 24px;
  line-height: 1;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.online-seal {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  color: #ffd59a;
  font: 900 28px/1 var(--font-chinese);
  background: #7f2018;
  border: 2px solid #d4a75e;
  box-shadow: 0 0 22px rgba(180, 48, 30, 0.35);
  transform: rotate(-4deg);
}
.online-kicker { color: rgba(232, 192, 112, 0.58); font-size: 10px; letter-spacing: 0.5em; }
.online-card h2 {
  margin: 6px 0 10px;
  color: var(--gold-bright);
  font: 900 30px/1.3 var(--font-chinese);
  letter-spacing: 5px;
}
.online-message { min-height: 42px; color: rgba(238, 224, 191, 0.62); font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.online-message.error { color: #ff9c86; }
.online-create { margin-top: 10px; text-align: left; }
.online-create label { display: block; margin-bottom: 6px; color: rgba(238, 224, 191, 0.46); font-size: 10px; letter-spacing: 3px; }
.online-create input,
.online-join input {
  box-sizing: border-box;
  min-width: 0;
  padding: 11px 12px;
  color: #f4dfb3;
  font: 700 17px/1 monospace;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  background: rgba(5, 6, 8, 0.54);
  border: 1px solid rgba(205, 164, 91, 0.36);
  border-radius: 5px;
  outline: none;
}
.online-create input { width: 100%; }
.online-create input::placeholder,
.online-join input::placeholder { color: rgba(238, 224, 191, 0.3); font-family: var(--font-chinese); letter-spacing: 0; }
.online-create input:focus,
.online-join input:focus { border-color: #e2b765; box-shadow: 0 0 0 2px rgba(226, 183, 101, 0.12); }
.online-primary,
.online-join button,
.room-ticket button {
  color: #231508;
  font: 600 13px/1 var(--font-chinese);
  letter-spacing: 2px;
  background: linear-gradient(145deg, #efcf89, #b9853e);
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}
.online-primary { width: 100%; margin-top: 15px; padding: 13px; }
.online-primary:disabled,
.online-join button:disabled { opacity: 0.45; cursor: wait; }
.online-or { display: flex; align-items: center; gap: 12px; margin: 17px 0; color: rgba(238, 224, 191, 0.3); font-size: 11px; }
.online-or::before, .online-or::after { content: ""; flex: 1; height: 1px; background: rgba(205, 164, 91, 0.2); }
.online-join { text-align: left; }
.online-join label { display: block; margin-bottom: 7px; color: rgba(238, 224, 191, 0.46); font-size: 10px; letter-spacing: 3px; }
.online-join > div { display: flex; gap: 8px; }
.online-join input { flex: 1; }
.online-join button { padding: 0 15px; }
.room-ticket {
  margin-top: 20px;
  padding: 17px;
  background: rgba(8, 11, 14, 0.48);
  border: 1px dashed rgba(232, 192, 112, 0.42);
}
.room-ticket small { display: block; color: rgba(238, 224, 191, 0.44); font-size: 9px; letter-spacing: 3px; }
.room-ticket strong { display: block; margin: 6px 0; color: #ffd98f; font: 800 30px/1 monospace; letter-spacing: 0.22em; overflow-wrap: anywhere; word-break: break-all; }
.room-ticket p { margin-bottom: 12px; color: rgba(238, 224, 191, 0.67); font-size: 12px; }
.room-ticket button { padding: 9px 14px; }
.online-back {
  margin-top: 18px;
  padding: 9px 13px;
  color: rgba(238, 224, 191, 0.64);
  font: 500 11px/1 var(--font-chinese);
  letter-spacing: 2px;
  background: transparent;
  border: 1px solid rgba(205, 164, 91, 0.3);
  border-radius: 5px;
  cursor: pointer;
}
.online-back:hover { color: #f5d99d; border-color: rgba(232, 192, 112, 0.6); }
.ai-status.online { background: #72c8dd; box-shadow: 0 0 11px rgba(114, 200, 221, 0.72); }
.ai-status.waiting { background: #e4b75f; animation: aiPulse 0.9s ease-in-out infinite alternate; }

/* ---------- 战利品侧栏 ---------- */
#panel {
  position: fixed;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  width: 132px;
  padding: 18px 14px;
  background: linear-gradient(155deg, rgba(35, 23, 14, 0.94), rgba(10, 10, 12, 0.93));
  border: 1px solid rgba(201, 162, 90, 0.35);
  border-radius: 10px;
  z-index: 10;
}
.cap-block h3 {
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--gold);
  text-align: center;
  margin-bottom: 10px;
  font-weight: 600;
}
.divider {
  height: 1px;
  margin: 14px 4px;
  background: linear-gradient(90deg, transparent, rgba(201, 162, 90, 0.5), transparent);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  min-height: 30px;
}
.chip {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 600;
  animation: chipIn 0.35s ease backwards;
}
.chip.black { background: #232f3d; color: #cfe0f5; border: 1px solid #5a708c; }
.chip.red { background: #5c1212; color: #ffd9a0; border: 1px solid #a05040; }
.chip .none, .none { color: rgba(232, 220, 192, 0.3); font-size: 14px; }
@keyframes chipIn {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------- 将军横幅 ---------- */
#checkBanner {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-family: var(--font-chinese);
  font-size: 84px;
  font-weight: 900;
  color: #ff5040;
  text-shadow: 0 0 30px rgba(255, 60, 40, 0.8), 0 0 80px rgba(255, 60, 40, 0.4);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
  transition: all 0.25s cubic-bezier(0.2, 1.6, 0.4, 1);
}
#checkBanner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  animation: bannerShake 0.5s ease;
}
@keyframes bannerShake {
  0%, 100% { margin-left: 0; }
  25% { margin-left: -6px; }
  75% { margin-left: 6px; }
}

/* ---------- 帅 / 将击杀电影特写 ---------- */
#generalCinematic {
  --cinematic-color: 255, 190, 86;
  position: fixed;
  inset: 0;
  z-index: 24;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.16s ease, visibility 0.16s ease;
}
#generalCinematic[data-side="black"] { --cinematic-color: 128, 180, 255; }
#generalCinematic.active { opacity: 1; visibility: visible; }
#generalCinematic::before,
#generalCinematic::after {
  content: "";
  position: absolute;
  z-index: 4;
  left: 0;
  width: 100%;
  height: clamp(34px, 7vh, 74px);
  background: #050403;
  box-shadow: 0 0 34px rgba(0, 0, 0, 0.92);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#generalCinematic::before { top: 0; transform: translateY(-105%); }
#generalCinematic::after { bottom: 0; transform: translateY(105%); }
#generalCinematic.active::before,
#generalCinematic.active::after { transform: translateY(0); }
.cinematic-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 44%, transparent 18%, rgba(5, 3, 2, 0.16) 48%, rgba(2, 1, 1, 0.9) 100%),
    linear-gradient(90deg, rgba(var(--cinematic-color), 0.2), transparent 28%, transparent 72%, rgba(var(--cinematic-color), 0.16));
}
.cinematic-speedlines {
  position: absolute;
  inset: -35%;
  opacity: 0;
  background: repeating-conic-gradient(from 90deg at 50% 50%, rgba(var(--cinematic-color), 0) 0deg 4deg, rgba(var(--cinematic-color), 0.12) 4.2deg 4.45deg);
  transform: scale(1.15) rotate(-4deg);
  mix-blend-mode: screen;
}
#generalCinematic.active .cinematic-speedlines { animation: cinematicLines 1.1s ease-out both; }
.cinematic-title {
  position: absolute;
  z-index: 3;
  left: clamp(28px, 7vw, 110px);
  bottom: clamp(48px, 9vh, 96px);
  display: flex;
  align-items: flex-end;
  gap: 22px;
  color: rgb(var(--cinematic-color));
  filter: drop-shadow(0 0 18px rgba(var(--cinematic-color), 0.48));
  transform: translateX(-30px) skewX(-7deg);
  opacity: 0;
}
#generalCinematic.active .cinematic-title { animation: cinematicTitle 1.05s 0.12s cubic-bezier(0.18, 0.9, 0.2, 1) both; }
.cinematic-title span {
  font-family: var(--font-chinese);
  font-size: clamp(112px, 19vw, 240px);
  font-weight: 900;
  line-height: 0.72;
  text-shadow: 3px 3px 0 rgba(20, 8, 2, 0.8), 0 0 42px rgba(var(--cinematic-color), 0.5);
}
.cinematic-title small {
  padding: 7px 13px;
  border-top: 1px solid rgba(var(--cinematic-color), 0.72);
  border-bottom: 1px solid rgba(var(--cinematic-color), 0.42);
  font-size: clamp(11px, 1.3vw, 17px);
  letter-spacing: 0.45em;
  white-space: nowrap;
}
.cinematic-flash {
  position: absolute;
  z-index: 5;
  inset: 0;
  opacity: 0;
  background: rgb(var(--cinematic-color));
  mix-blend-mode: screen;
}
#generalCinematic.impact .cinematic-flash { animation: cinematicFlash 0.34s ease-out; }
#generalCinematic.impact { animation: cinematicShake 0.28s linear; }
@keyframes cinematicLines {
  0% { opacity: 0; transform: scale(1.35) rotate(-7deg); }
  28% { opacity: 0.55; }
  100% { opacity: 0.08; transform: scale(0.98) rotate(0); }
}
@keyframes cinematicTitle {
  0% { opacity: 0; transform: translateX(-46px) skewX(-12deg) scale(1.08); }
  42%, 82% { opacity: 1; transform: translateX(0) skewX(-7deg) scale(1); }
  100% { opacity: 0.74; transform: translateX(9px) skewX(-5deg) scale(0.98); }
}
@keyframes cinematicFlash { 0% { opacity: 0.82; } 18% { opacity: 0.42; } 100% { opacity: 0; } }
@keyframes cinematicShake {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-7px, 3px); }
  42% { transform: translate(6px, -3px); }
  66% { transform: translate(-3px, 2px); }
  84% { transform: translate(2px, -1px); }
}

/* ---------- 底部提示 ---------- */
#hintBar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 24px);
  z-index: 10;
}
#hint {
  font-size: 13px;
  letter-spacing: 2px;
  color: rgba(238, 224, 191, 0.68);
  background: rgba(20, 13, 8, 0.9);
  border: 1px solid rgba(201, 162, 90, 0.2);
  border-radius: 999px;
  padding: 8px 22px;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}
#hint.error { color: #ffad99; border-color: rgba(225, 99, 76, 0.46); }

.hint-btn {
  font-family: var(--font-chinese);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 3px;
  padding: 8px 18px;
  color: #1a1208;
  background: linear-gradient(145deg, #f1ce83, #c9a25a);
  border: 1px solid #ffdf99;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 4px 18px rgba(201, 162, 90, 0.4);
  animation: hintPulse 1.8s ease-in-out infinite;
  transition: transform 0.2s ease, filter 0.2s ease;
}
.hint-btn:hover { transform: translateY(-2px); filter: brightness(1.12); }
.hint-btn:active { transform: translateY(0); }
.hint-btn[hidden] { display: none; }
.hint-btn.thinking {
  color: rgba(240, 201, 120, 0.7);
  background: rgba(20, 13, 8, 0.9);
  border-color: rgba(201, 162, 90, 0.5);
  box-shadow: none;
  animation: none;
  cursor: wait;
}
@keyframes hintPulse {
  0%, 100% { box-shadow: 0 4px 18px rgba(201, 162, 90, 0.4); }
  50% { box-shadow: 0 4px 28px rgba(240, 201, 120, 0.7); }
}

/* ---------- 终局遮罩 ---------- */
#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, rgba(6, 8, 12, 0.55), rgba(6, 8, 12, 0.92));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
  z-index: 30;
}
#overlay.show { opacity: 1; pointer-events: auto; }
.overlay-card {
  text-align: center;
  transform: translateY(14px);
  transition: transform 0.6s ease;
}
#overlay.show .overlay-card { transform: translateY(0); }
#resultText {
  font-family: var(--font-chinese);
  font-size: 110px;
  font-weight: 900;
  letter-spacing: 14px;
  color: var(--red);
  text-shadow: 0 0 50px rgba(255, 90, 60, 0.4);
}
#resultSub {
  font-size: 17px;
  letter-spacing: 8px;
  color: rgba(232, 220, 192, 0.6);
  margin: 10px 0 36px;
}
#btnAgain {
  font-family: var(--font-chinese);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 6px;
  padding: 14px 44px;
  color: #1a1208;
  background: linear-gradient(145deg, #e8c070, #c9a25a);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 6px 30px rgba(201, 162, 90, 0.4);
  transition: all 0.25s ease;
}
#btnAgain:hover { transform: translateY(-2px); box-shadow: 0 10px 36px rgba(201, 162, 90, 0.55); }
.overlay-secondary {
  display: block;
  margin: 16px auto 0;
  font-family: var(--font-chinese);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 5px;
  padding: 10px 32px;
  color: rgba(232, 220, 192, 0.78);
  background: transparent;
  border: 1px solid rgba(232, 192, 112, 0.42);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.overlay-secondary:hover {
  color: var(--gold-bright);
  border-color: rgba(240, 201, 120, 0.85);
  background: rgba(232, 192, 112, 0.08);
}

/* 重开/求和/认输确认弹窗：同意或拒绝（默认隐藏，仅 .show 时显示） */
#restartDialog,
#drawDialog,
#resignDialog {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, rgba(6, 8, 12, 0.6), rgba(6, 8, 12, 0.94));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 32;
}
#restartDialog.show,
#drawDialog.show,
#resignDialog.show { opacity: 1; pointer-events: auto; }
#restartDialog .overlay-card,
#drawDialog .overlay-card,
#resignDialog .overlay-card { transform: translateY(10px); }
#restartDialog.show .overlay-card,
#drawDialog.show .overlay-card,
#resignDialog.show .overlay-card { transform: translateY(0); }
#restartDialog h2,
#drawDialog h2,
#resignDialog h2 {
  font-family: var(--font-chinese);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 6px;
  color: var(--gold-bright);
  text-shadow: 0 0 30px rgba(240, 201, 120, 0.35);
}
.restart-dialog-sub {
  font-size: 16px;
  letter-spacing: 3px;
  color: rgba(232, 220, 192, 0.72);
  margin: 14px 0 30px;
}
#btnRestartAccept,
#btnDrawAccept,
#btnResignConfirm {
  font-family: var(--font-chinese);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 5px;
  padding: 12px 36px;
  color: #1a1208;
  background: linear-gradient(145deg, #e8c070, #c9a25a);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 6px 30px rgba(201, 162, 90, 0.4);
  transition: all 0.25s ease;
}
#btnRestartAccept:hover,
#btnDrawAccept:hover,
#btnResignConfirm:hover { transform: translateY(-2px); box-shadow: 0 10px 36px rgba(201, 162, 90, 0.55); }

@media (max-width: 760px) {
  /* 顶部两个浮层严格等高：统一高度变量 + 内部行均分，避免靠内容撑高导致的像素漂移 */
  :root { --hud-panel-h: 78px; --online-hud-h: 50px; }
  .brand p { display: none; }
  .hud-top { gap: 9px; padding: 10px 12px; }
  .seal { width: 42px; height: 42px; font-size: 25px; }
  .brand h1 { font-size: 23px; letter-spacing: 3px; }
  .turn { padding: 7px 11px; font-size: 12px; letter-spacing: 1px; }
  .actions { gap: 5px; }
  .actions button { padding: 7px 9px; font-size: 12px; letter-spacing: 1px; }
  /* 手机端棋盘几乎铺满宽度，竖排侧栏会压住棋子；改为 HUD 下方横排，绝不遮挡棋盘 */
  /* 与右上计时框顶部对齐、等高、等视觉重量，中间留约 20px 缝，按钮铺满框内不留白 */
  body.online-mode #onlineSideControls {
    display: flex;
    position: fixed;
    z-index: 11;
    top: 62px;
    left: 10px;
    right: auto;
    width: calc(100vw - 196px);
    height: var(--online-hud-h);
    box-sizing: border-box;
    flex-direction: row;
    flex-wrap: nowrap;
    align-content: stretch;
    justify-content: space-between;
    align-items: stretch;
    gap: 4px;
    padding: 4px 6px;
    background: linear-gradient(150deg, rgba(40, 24, 14, 0.88), rgba(12, 10, 9, 0.86));
    border: 1px solid rgba(205, 164, 91, 0.38);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  }
  body.online-mode #onlineSideControls > * { width: auto; flex: 1 1 0; box-sizing: border-box; white-space: nowrap; }
  body.online-mode #onlineSideControls .turn { display: flex; align-items: center; justify-content: center; padding: 4px 2px; font-size: 11px; letter-spacing: 0; }
  body.online-mode #onlineSideControls button { padding: 4px 2px; font-size: 11px; letter-spacing: 0; }
  /* 经典大字 + 联机：提示条压在等高浮层下方、整行居中，远离棋盘；棋盘尺寸不变 */
  body.classic-view.online-mode #hintBar {
    top: 130px;
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100vw - 20px);
    justify-content: center;
  }
  body.online-mode #btnFullscreen { width: 32px; padding: 5px; }
  body.online-mode #btnFullscreen .fullscreen-icon { width: 16px; height: 16px; }
  /* 手机端顶部按钮已占满，且移动端浏览器多不支持网页全屏 API，故不显示全屏按钮 */
  #btnFullscreen { display: none; }
  /* 手机联机：红方行棋/换边/重开 回到顶部一排、大厅左侧，缩小以容纳 */
  body.online-top-controls #turnBadge { margin-left: 0; padding: 6px 8px; font-size: 11px; letter-spacing: 0; white-space: nowrap; }
  body.online-top-controls #btnCam,
  body.online-top-controls #btnRestart { padding: 6px 8px; font-size: 11px; letter-spacing: 0; white-space: nowrap; }
  .actions button.undo-urgent {
    color: #fff3d6;
    background: linear-gradient(135deg, #b3402e, #d98b2b);
    border-color: rgba(255, 220, 150, 0.7);
    box-shadow: 0 0 0 1px rgba(255, 220, 150, 0.5), 0 0 18px rgba(217, 139, 43, 0.45);
  }
  .actions button.undo-urgent:hover { background: linear-gradient(135deg, #c64a35, #e89a32); }
  .repo-link { display: none; }
  .return-link { padding: 7px 9px; font-size: 12px; letter-spacing: 0; }
  .online-dialog { padding: 10px; }
  .online-card { padding: 26px 20px 22px; }
  .online-card h2 { font-size: 26px; margin: 4px 0 8px; }
  .online-seal { width: 42px; height: 42px; margin-bottom: 10px; font-size: 24px; }
  .online-kicker { letter-spacing: 0.35em; }
  .online-message { min-height: 36px; font-size: 12px; }
  .online-create { margin-top: 8px; }
  .online-primary { margin-top: 12px; padding: 12px; }
  .online-or { margin: 13px 0; }
  .room-ticket { margin-top: 16px; padding: 14px; }
  .room-ticket strong { font-size: 26px; }
  .online-back { margin-top: 14px; }
  .chess-clock { top: 66px; right: 10px; min-width: 106px; padding: 4px 6px; gap: 1px; height: var(--online-hud-h); grid-template-rows: repeat(2, 1fr); align-items: stretch; }
  .clock-side { gap: 4px; padding: 2px 4px; align-items: center; }
  .clock-side .clock-name { font-size: 10px; letter-spacing: 0; }
  .clock-side .clock-main { font-size: 15px; }
  .clock-side .clock-step { font-size: 10px; min-width: 50px; }
  .clock-vs { font-size: 9px; letter-spacing: 1px; }
  .battle-controls { top: 66px; left: 10px; padding: 3px 3px 4px; gap: 2px; max-width: 168px; height: var(--hud-panel-h); grid-template-rows: repeat(3, 1fr); align-items: stretch; }
  .battle-controls .visual-row, .battle-controls .ai-row { min-height: 0; padding-top: 1px; gap: 2px; }
  .battle-controls button { min-height: 20px; padding: 1px 3px; gap: 3px; }
  .battle-controls small { display: none; }
  .battle-controls b { font-size: 11px; letter-spacing: 1px; }
  .battle-controls .mode-option { min-height: 20px; padding: 1px 3px; font-size: 9px; }
  .battle-controls .visual-option { min-height: 20px; padding: 1px 3px; font-size: 9px; }
  .visual-row { gap: 3px; }
  .motion-choice { padding-right: 0; }
  .motion-choice select { min-width: 52px; padding: 1px 3px; font-size: 10px; }
  .ai-choice { padding: 0 4px; }
  .ai-choice select { min-width: 64px; max-width: 78px; padding: 1px 4px; font-size: 10px; }
  .battle-controls select { padding: 1px; font-size: 10px; }
  #panel { display: none; }
  #checkBanner { font-size: 56px; }
  #hintBar { bottom: 12px; gap: 6px; max-width: calc(100vw - 16px); }
  /* 经典大字手机端棋盘几乎占满高度：提示条移到棋盘上方空白区，避免压住底部棋子 */
  body.classic-view #hintBar { top: 100px; bottom: auto; }
  #hint { padding: 7px 12px; text-align: center; font-size: 11px; letter-spacing: 1px; }
  .hint-btn { padding: 7px 12px; font-size: 11px; letter-spacing: 1px; }
  #resultText { font-size: 64px; }
  .cinematic-title { left: 24px; bottom: 72px; gap: 12px; }
  .cinematic-title small { letter-spacing: 0.2em; }
  /* 大厅：覆盖房间里的 fixed/等高约束，改为卡片内静态流式布局 */
  .lobby { padding: 12px; align-items: start; }
  .lobby-card { padding: 22px 20px 24px; }
  .lobby-head { margin-bottom: 20px; }
  .lobby-brand .seal { width: 44px; height: 44px; font-size: 26px; }
  .lobby-title h1 { font-size: 24px; letter-spacing: 4px; }
  .lobby-title p { font-size: 11px; letter-spacing: 2px; }
  #lobby .battle-controls { position: static; top: auto; left: auto; height: auto; max-width: none; grid-template-rows: none; padding: 0; }
  #lobby .battle-controls small { display: block; }
  #lobby .battle-controls button { min-height: 40px; font-size: 12px; }
  #lobby .mode-options, #lobby .visual-options { display: grid; }
  #lobby .visual-row { grid-template-columns: 1fr 1fr; }
  #lobby .classic-board-choice { grid-column: 1 / -1; }
  #lobby .ai-row { grid-template-columns: 3fr 1fr; }
  #lobby .ai-controls { flex-direction: column; gap: 8px; }
  #lobby .ai-controls .ai-choice { flex: 0 0 auto; }
  #lobby .ai-choice + .ai-choice { border-left: 0; padding-top: 8px; border-top: 1px solid rgba(205, 164, 91, 0.14); }
  #lobby .battle-controls select { min-height: 40px; font-size: 12px; max-width: none; }
  .lobby-actions { grid-template-columns: 1fr 1fr; margin-top: 20px; padding-top: 16px; }
  .lobby-btn.lobby-primary { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .brand { display: none; }
  .hud-top { justify-content: space-between; }
}

/* 矮屏（多为手机横屏）：进一步压缩军帐卡片，配合可滚动容器确保内容不被裁切 */
@media (max-height: 540px) {
  .online-dialog { padding: 8px; }
  .online-card { padding: 16px 20px 14px; }
  .online-seal { width: 34px; height: 34px; margin-bottom: 6px; font-size: 20px; }
  .online-kicker { display: none; }
  .online-card h2 { font-size: 22px; margin: 2px 0 6px; }
  .online-message { min-height: 0; font-size: 12px; line-height: 1.5; }
  .online-create { margin-top: 6px; }
  .online-create label { margin-bottom: 4px; }
  .online-primary { margin-top: 9px; padding: 10px; }
  .online-or { margin: 10px 0; }
  .room-ticket { margin-top: 12px; padding: 11px; }
  .room-ticket strong { font-size: 22px; margin: 4px 0; }
  .room-ticket p { margin-bottom: 8px; }
  .online-back { margin-top: 10px; }
  .lobby { padding: 8px; }
  .lobby-card { padding: 16px 18px 18px; }
  .lobby-head { margin-bottom: 12px; }
  .lobby-brand .seal { width: 36px; height: 36px; font-size: 22px; }
  .lobby-title h1 { font-size: 20px; letter-spacing: 3px; }
  #lobby .battle-controls { gap: 8px; }
  #lobby .control-row { gap: 8px; }
  #lobby .visual-row, #lobby .ai-row { padding-top: 8px; }
  #lobby .battle-controls button, #lobby .battle-controls select { min-height: 34px; padding: 5px 8px; }
  .lobby-actions { margin-top: 12px; padding-top: 10px; }
  .lobby-btn { min-height: 36px; padding: 6px 10px; }
}

/* ---------- 对弈大厅（进入战场前的设置入口） ---------- */
.lobby {
  position: fixed;
  inset: 0;
  z-index: 28;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* 最顶层深色半透明区域平铺到全屏，覆盖层降到 50% 不透明；背景图模糊后透出；卡片内部元素不动 */
  background:
    linear-gradient(150deg, rgba(64, 39, 22, 0.5), rgba(15, 12, 10, 0.5)),
    #140e09;
  backdrop-filter: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}
/* 背景图独立成层，铺满全屏、盖在深色兜底之上，位于卡片内容之下 */
.lobby::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: url('../assets/155940-pieces-blur3.jpeg?v=20261122.37') center / cover no-repeat;
}
body.lobby-open .lobby { opacity: 1; visibility: visible; pointer-events: auto; }

.lobby-card {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  max-width: 100%;
  min-width: 0;
  margin: auto;
  padding: 30px 36px 32px;
  color: var(--paper);
  /* 卡片区域已平铺到全屏，卡片本身改为透明容器，只承载内部元素；元素布局一律不动 */
  background: none;
  border: 1px solid transparent;
  border-radius: 18px;
  box-shadow: none;
}
.lobby-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  pointer-events: none;
}

.lobby-head { text-align: center; margin-bottom: 26px; }
.lobby-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.lobby-brand .seal {
  width: 52px; height: 52px;
  flex: 0 0 auto;
  font-size: 30px;
}
.lobby-title { text-align: left; }
.lobby-title h1 {
  font-family: var(--font-chinese);
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--gold-bright);
  text-shadow: 0 2px 12px rgba(201, 162, 90, 0.35);
  line-height: 1.1;
}
.lobby-title p {
  font-size: 12px;
  letter-spacing: 4px;
  color: rgba(232, 220, 192, 0.55);
  margin-top: 2px;
}

/* 大厅内重置设置控件：从房间浮层改为卡片内静态布局（不影响房间里的同名元素） */
#lobby .battle-controls {
  position: static;
  inset: auto;
  z-index: auto;
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: none;
  height: auto;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  grid-template-rows: none;
}
#lobby .control-row { display: grid; align-items: end; gap: 14px; }
#lobby .mode-row { grid-template-columns: 1fr; }
#lobby .visual-row { grid-template-columns: 1fr 1fr 1fr; min-height: 0; padding-top: 14px; border-top: 1px solid rgba(205, 164, 91, 0.18); }
#lobby .ai-row { grid-template-columns: 3fr 1fr; min-height: 0; padding-top: 14px; border-top: 1px solid rgba(205, 164, 91, 0.18); }
#lobby .ai-controls { width: 100%; }
#lobby .ai-controls .ai-choice { flex: 1 1 0; min-width: 0; }
/* 三种模式始终保留引擎/谋略配置行，绿点固定在右侧 1/4，不单独占一行 */
#lobby .battle-controls small { font-size: 10px; letter-spacing: 2px; margin-bottom: 5px; }
#lobby .mode-options, #lobby .visual-options { display: grid; gap: 8px; }
#lobby .mode-options { grid-template-columns: repeat(3, 1fr); }
#lobby .visual-options { grid-template-columns: 1fr; }
#lobby .battle-controls button {
  justify-content: center;
  text-align: center;
  min-height: 44px;
  padding: 9px 10px;
  font-size: 13px;
  border: 1px solid rgba(205, 164, 91, 0.28);
}
/* 未选中的模式/棋盘画面按钮背景与“返回房间”一致；选中红色态和 hover 效果保持不变 */
#lobby .battle-controls .mode-option:not(.active),
#lobby .battle-controls .visual-option:not(.active) {
  background: rgba(34, 22, 14, 0.85);
}
#lobby .battle-controls .mode-option:not(.active):hover,
#lobby .battle-controls .visual-option:not(.active):hover {
  background: rgba(232, 192, 112, 0.12);
}
/* 恢复原版选中态：红色渐变 + 金边 + 内发光，三种模式按钮与棋盘画面按钮一致 */
#lobby .battle-controls .mode-option.active,
#lobby .battle-controls .visual-option.active {
  color: #ffe0a0;
  background: linear-gradient(145deg, rgba(153, 48, 31, 0.72), rgba(96, 29, 22, 0.62));
  border-color: rgba(240, 190, 97, 0.68);
  box-shadow: inset 0 0 13px rgba(255, 180, 76, 0.1), 0 0 10px rgba(157, 48, 27, 0.2);
}
/* 经典棋盘下拉框选中“经典大字”时，只给下拉框红色选中态，标签文字保持默认色不变红 */
#lobby .classic-board-choice.active select {
  color: #ff7a66;
  background: linear-gradient(145deg, rgba(153, 48, 31, 0.72), rgba(96, 29, 22, 0.62));
  border-color: rgba(240, 190, 97, 0.68);
  box-shadow: inset 0 0 13px rgba(255, 180, 76, 0.1), 0 0 10px rgba(157, 48, 27, 0.2);
}
/* 下拉项选中即显示朱红色强调，和按钮选中态同一色系 */
#lobby .battle-controls select option { color: #f3d99f; background: #21160f; }
#lobby .battle-controls select option:checked { color: #ff7a66; background: #7a261d; }
/* 收起状态下，下拉框顶部显示的已选值用朱红文字 + 深红底；“未选择”保持原色 */
#lobby .battle-controls select:not(:has(option[value=""]:checked)) {
  color: #ff7a66;
  background-color: rgba(122, 38, 29, 0.55);
}
#lobby .motion-choice, #lobby .classic-board-choice, #lobby .ai-choice { display: grid; align-content: end; gap: 5px; }
/* 棋盘画面行三列标签同一行对齐：visual-picker 也用 end 对齐并统一标签外边距 */
#lobby .visual-row .visual-picker { display: grid; align-content: end; gap: 5px; }
#lobby .classic-board-choice small, #lobby .motion-choice small, #lobby .ai-choice small { margin: 0; }
#lobby .visual-picker > small { margin: 0; }
#lobby .battle-controls select {
  width: 100%;
  min-height: 44px;
  padding: 9px 10px;
  font-size: 13px;
  color: #f3d99f;
  background: #21160f;
  border: 1px solid rgba(205, 164, 91, 0.34);
  border-radius: 5px;
  cursor: pointer;
  outline: none;
}
/* 原生 select 在 Chrome/Windows 会用系统渲染覆盖 color，必须接管外观，收起态红字才会真正显示 */
#lobby .battle-controls select {
  -webkit-appearance: none;
  appearance: none;
  color-scheme: dark;
  background-image:
    linear-gradient(45deg, transparent 50%, #f0d59a 50%),
    linear-gradient(135deg, #f0d59a 50%, transparent 50%);
  background-position: calc(100% - 15px) calc(50% - 2px), calc(100% - 10px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 26px;
}
#lobby .battle-controls select:focus { border-color: rgba(240, 190, 97, 0.78); box-shadow: 0 0 0 2px rgba(240, 190, 97, 0.1); }
#lobby .ai-status { width: 9px; height: 9px; margin: 0; }

.lobby-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 12px;
  margin-top: 12px;
  padding-top: 20px;
  border-top: 1px solid rgba(205, 164, 91, 0.25);
}
.lobby-btn {
  min-height: 46px;
  padding: 10px 12px;
  font-family: var(--font-chinese);
  font-size: 14px;
  letter-spacing: 2px;
  color: #f0d59a;
  background: rgba(34, 22, 14, 0.85);
  border: 1px solid rgba(205, 164, 91, 0.42);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.lobby-btn:hover { background: rgba(232, 192, 112, 0.12); border-color: rgba(240, 190, 97, 0.72); }
.lobby-btn.lobby-primary {
  color: #2a1608;
  font-weight: 700;
  background: linear-gradient(145deg, #f1ce83, #c29143);
  border-color: #ffdf99;
  box-shadow: 0 8px 26px rgba(190, 126, 48, 0.34);
}
.lobby-btn.lobby-primary:hover { filter: brightness(1.08); }

/* 手机端大厅沿用电脑端行列结构：只缩放尺寸，不改变三列 / 3fr 1fr 布局 */
@media (max-width: 760px), (max-height: 540px) {
  #lobby .visual-row { grid-template-columns: 1fr 1fr 1fr; }
  #lobby .classic-board-choice { grid-column: auto; }
  #lobby .ai-row { grid-template-columns: 3fr 1fr; }
  #lobby .ai-controls { flex-direction: row; gap: 0; }
  #lobby .ai-controls .ai-choice { flex: 1 1 0; min-width: 0; }
  #lobby .ai-choice + .ai-choice { border-left: 1px solid rgba(205, 164, 91, 0.14); border-top: 0; padding-top: 0; }
  .lobby-actions { grid-template-columns: 1fr 1fr 1.4fr; }
  .lobby-btn.lobby-primary { grid-column: auto; }
  .lobby-btn {
    font-size: clamp(11px, 3vw, 12px);
    letter-spacing: 0;
    padding: 8px 4px;
    min-height: 40px;
    white-space: nowrap;
  }
  /* 大厅基础样式把下拉框重设为桌面尺寸，这里在手机端重新缩小字号/留白与自绘箭头，
     避免“未选择”“godogpaw”在窄屏下被截断；三列 / 3fr 1fr 结构不变 */
  #lobby .battle-controls select {
    font-size: 10px;
    padding: 6px 6px;
    padding-right: 16px;
    background-position: calc(100% - 9px) calc(50% - 1px), calc(100% - 4px) calc(50% - 1px);
    background-size: 4px 4px, 4px 4px;
  }
  /* 手机端对弈模式/棋盘画面按钮文字强制单行，避免“3D 战场”在窄列里折行 */
  #lobby .battle-controls button {
    white-space: nowrap;
  }
  #lobby .battle-controls .mode-option,
  #lobby .battle-controls .visual-option {
    font-size: 11px;
    padding: 6px 4px;
    letter-spacing: 0;
  }
}

/* 手机端自绘下拉面板：替代系统原生底部白底选择器，保持控件原位与深色朱红风格 */
.mobile-select-panel {
  position: fixed;
  z-index: 60;
  padding: 4px;
  color-scheme: dark;
  background: #21160f;
  border: 1px solid rgba(240, 190, 97, 0.68);
  border-radius: 6px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65), inset 0 0 12px rgba(255, 180, 76, 0.08);
}
.mobile-select-options { display: grid; gap: 2px; }
.mobile-select-option {
  min-height: 38px;
  padding: 8px 12px;
  font-family: var(--font-chinese);
  font-size: 12px;
  color: #f3d99f;
  text-align: left;
  white-space: nowrap;
  background: rgba(34, 22, 14, 0.95);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
}
.mobile-select-option.selected {
  color: #ff7a66;
  background: #7a261d;
  border-color: rgba(240, 190, 97, 0.5);
}

@media (prefers-reduced-motion: reduce) {
  .boot-line b, .chip, #checkBanner.show, .ai-status { animation: none; }
}

/* ===== 大厅账号 / 会员 / 天梯布局（新增，不改动原有控件规则） ===== */
/* 卡片沿用 xqcn 原版通透质感：透明底、无阴影，仅加宽以容纳左右两栏 */
.lobby-card {
  width: min(1040px, 100%);
  /* 高度跟随内容自适应：右栏再高也只会把卡片撑高，不会溢出并覆盖卡片下边框 */
  max-height: none;
  overflow: visible;
  padding: 30px 36px 32px;
  background: none;
  border-color: transparent;
  box-shadow: none;
}
.lobby-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
  align-items: start;
}
.lobby-main { min-width: 0; }
.lobby-head { margin-bottom: 26px; }
.lobby-side {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 20px;
  background: linear-gradient(155deg, rgba(30, 20, 13, 0.52), rgba(13, 9, 6, 0.66));
  border: 1px solid rgba(205, 164, 91, 0.28);
  border-radius: 14px;
}
.profile-strip {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(205, 164, 91, 0.2);
}
.profile-avatar {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  flex: 0 0 auto;
  font-family: var(--font-chinese);
  font-size: 21px;
  color: #2a1608;
  background: linear-gradient(145deg, #f1ce83, #b8843d);
  border: 1px solid rgba(255, 231, 176, 0.7);
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
.profile-meta { flex: 1 1 auto; min-width: 0; }
.profile-name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.profile-name-row strong {
  overflow: hidden;
  font-size: 14px;
  color: var(--gold-bright);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-title {
  flex: 0 1 auto;
  overflow: hidden;
  font-size: 10px;
  font-style: normal;
  color: #d4a843;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 战绩与退出登录按钮同一行：战绩靠左、按钮靠右，避免按钮挤到账号/会员那一行 */
.profile-score-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.profile-score { display: block; font-size: 11px; color: rgba(232, 220, 192, 0.6); }
.profile-score-row .side-link { padding: 3px 7px; font-size: 10px; }
.vip-badge {
  padding: 1px 6px;
  font-size: 10px;
  color: #3d2117;
  background: linear-gradient(135deg, #ffe9a8, #d4a017);
  border-radius: 999px;
  white-space: nowrap;
}
.side-link {
  flex: 0 0 auto;
  padding: 5px 8px;
  font-size: 11px;
  color: #f0d59a;
  background: transparent;
  border: 1px solid rgba(205, 164, 91, 0.45);
  border-radius: 5px;
  cursor: pointer;
}
.side-link:hover { background: rgba(232, 192, 112, 0.12); }
.side-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.side-tab {
  padding: 9px 6px;
  font-family: var(--font-chinese);
  font-size: 13px;
  letter-spacing: 1px;
  color: rgba(232, 220, 192, 0.68);
  background: rgba(34, 22, 14, 0.8);
  border: 1px solid rgba(205, 164, 91, 0.22);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.side-tab:hover { color: #ffe0a0; border-color: rgba(240, 190, 97, 0.45); }
.side-tab.active {
  color: #ffe6b0;
  background: linear-gradient(145deg, rgba(153, 48, 31, 0.75), rgba(96, 29, 22, 0.65));
  border-color: rgba(240, 190, 97, 0.65);
  box-shadow: inset 0 1px 0 rgba(255, 226, 164, 0.14);
}
.side-panel { min-height: 214px; }
.side-panel[hidden] { display: none; }
.side-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: 1px;
  color: rgba(232, 220, 192, 0.7);
  border-bottom: 1px solid rgba(205, 164, 91, 0.18);
}
.side-mini {
  padding: 2px 7px;
  font-size: 10px;
  color: var(--gold-bright);
  background: transparent;
  border: 1px solid rgba(205, 164, 91, 0.35);
  border-radius: 4px;
  cursor: pointer;
}
.lb-list { max-height: 236px; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.lb-list li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding: 6px 2px;
  font-size: 12px;
  border-bottom: 1px solid rgba(205, 164, 91, 0.1);
}
.lb-list .lb-rank { color: var(--gold); font-weight: 700; }
.lb-list .lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-list .lb-score { font-size: 11px; color: rgba(232, 220, 192, 0.62); }
.lb-list .lb-me { color: #ff9b84; }
.lb-empty { display: block !important; color: rgba(232, 220, 192, 0.5); }
.vip-summary { margin: 4px 0 12px; font-size: 12px; line-height: 1.6; color: #f3d99f; }
.side-actions { display: grid; gap: 8px; }
.side-btn {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
  color: #f0d59a;
  background: rgba(34, 22, 14, 0.9);
  border: 1px solid rgba(205, 164, 91, 0.42);
  border-radius: 5px;
  cursor: pointer;
}
.side-btn:hover { background: rgba(232, 192, 112, 0.12); }
.side-btn-gold { color: #2a1608; font-weight: 700; background: linear-gradient(145deg, #f1ce83, #c29143); border-color: #ffdf99; }
.side-note { margin: 10px 0 0; font-size: 10px; line-height: 1.6; color: rgba(232, 220, 192, 0.48); }

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 58;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(9, 6, 4, 0.78);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.dialog-overlay.show { opacity: 1; visibility: visible; pointer-events: auto; }
.dialog-card {
  position: relative;
  width: min(380px, 100%);
  padding: 24px 26px 26px;
  color: var(--paper);
  background: linear-gradient(155deg, #2c1c12, #17100b);
  border: 1px solid rgba(240, 190, 97, 0.4);
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}
.dialog-card h2 { margin: 0 0 14px; font-family: var(--font-chinese); font-size: 20px; color: var(--gold-bright); text-align: center; }
.dialog-close {
  position: absolute;
  top: 8px; right: 12px;
  padding: 2px 8px;
  font-size: 22px;
  line-height: 1;
  color: rgba(232, 220, 192, 0.65);
  background: none;
  border: 0;
  cursor: pointer;
}
.dialog-desc { margin: 0 0 12px; font-size: 12px; line-height: 1.6; color: rgba(232, 220, 192, 0.7); }
.dialog-error { min-height: 18px; margin: 0 0 8px; font-size: 12px; color: #ff8a75; text-align: center; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.auth-tab {
  padding: 7px;
  font-size: 13px;
  color: rgba(232, 220, 192, 0.7);
  background: rgba(34, 22, 14, 0.85);
  border: 1px solid rgba(205, 164, 91, 0.3);
  border-radius: 5px;
  cursor: pointer;
}
.auth-tab.active { color: #ffe0a0; background: rgba(153, 48, 31, 0.6); border-color: rgba(240, 190, 97, 0.6); }
.dialog-form { display: grid; gap: 10px; }
.dialog-form[hidden] { display: none; }
.dialog-form label { display: grid; gap: 5px; font-size: 11px; color: rgba(232, 220, 192, 0.7); }
.dialog-form input {
  min-height: 38px;
  padding: 8px 10px;
  font-size: 13px;
  color: #f3d99f;
  background: #21160f;
  border: 1px solid rgba(205, 164, 91, 0.34);
  border-radius: 5px;
  outline: none;
}
.dialog-form input:focus { border-color: rgba(240, 190, 97, 0.8); }
.dialog-primary {
  min-height: 40px;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 700;
  color: #2a1608;
  background: linear-gradient(145deg, #f1ce83, #c29143);
  border: 1px solid #ffdf99;
  border-radius: 5px;
  cursor: pointer;
}

@media (max-width: 760px) {
  .lobby-card { padding: 22px 20px 24px; }
  .lobby-shell { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .lobby-side { grid-template-columns: minmax(0, 1fr); }
  .lb-list { max-height: 180px; }
}
@media (max-width: 520px) {
  .lobby-card { padding: 16px 18px 18px; }
}

/* 联机计时面板：座位名字小字可见即可，不换行、不加粗，避免挤高面板遮挡文本 */
#clockRed .clock-name,
#clockBlack .clock-name {
  max-width: 92px;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0;
  opacity: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#clockRed .clock-name { color: rgba(255, 176, 156, 0.92); }
#clockBlack .clock-name { color: rgba(233, 220, 192, 0.92); }
@media (max-width: 760px) {
  .chess-clock { top: 62px; height: var(--online-hud-h); min-width: 96px; padding: 3px 5px; gap: 0; }
  .clock-side { padding: 1px 2px; gap: 3px; }
  #clockRed .clock-name,
  #clockBlack .clock-name { max-width: 52px; font-size: 9px; }
  .clock-side .clock-main { font-size: 13px; }
  .clock-side .clock-step { font-size: 9px; min-width: 42px; }
  .clock-vs { display: none; }
}

/* 桌面端联机：左右 HUD 统一顶边、等高、小字横条，和手机端同一套视觉 */
@media (min-width: 761px) {
  :root { --desktop-hud-top: 88px; --desktop-hud-h: 50px; }
  body.room-side-controls #onlineSideControls {
    flex-direction: row;
    top: var(--desktop-hud-top);
    left: 28px;
    right: auto;
    width: min(560px, calc(100vw - 320px));
    height: var(--desktop-hud-h);
    gap: 4px;
    padding: 4px 6px;
    align-items: stretch;
  }
  body.room-side-controls #onlineSideControls > * {
    width: auto;
    flex: 1 1 0;
    min-width: 0;
    white-space: nowrap;
  }
  body.room-side-controls #onlineSideControls .turn,
  body.room-side-controls #onlineSideControls button {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 4px 2px;
    font-size: 11px;
    letter-spacing: 0;
  }
  .chess-clock {
    top: var(--desktop-hud-top);
    right: 28px;
    height: var(--desktop-hud-h);
    min-width: 170px;
    padding: 3px 6px;
    gap: 0;
    grid-template-rows: repeat(2, 1fr);
    align-items: stretch;
  }
  .clock-side { padding: 1px 3px; gap: 4px; align-items: center; }
  #clockRed .clock-name,
  #clockBlack .clock-name { max-width: 64px; font-size: 11px; }
  .clock-side .clock-main { font-size: 14px; }
  .clock-side .clock-step { font-size: 10px; min-width: 48px; }
  .clock-vs { display: none; }
}

/* ===== 棋力评测（快速匹配）新增层：沿用大厅按钮质感，不改动既有布局 ===== */
.match-cta.matching { opacity: .75; cursor: progress; }
.match-hint {
  margin: 8px 2px 0;
  font-size: 12px;
  line-height: 1.5;
  color: #b9a88c;
  text-align: center;
  min-height: 18px;
}
.qili-reason { font-size: 12px; color: #c4a882; margin: 8px 0 0; }

/* ===== 对局左侧栏：6 个按钮靠近左边框纵向排列（联机 / 棋力评测进房后统一） ===== */
@media (min-width: 761px) {
  body.room-side-controls #onlineSideControls {
    flex-direction: column !important;
    left: 14px !important;
    width: 104px !important;
    height: auto !important;
    gap: 6px !important;
    padding: 8px !important;
    align-items: stretch !important;
  }
  body.room-side-controls #onlineSideControls > * {
    flex: 0 0 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    white-space: nowrap !important;
  }
  body.room-side-controls #onlineSideControls .turn,
  body.room-side-controls #onlineSideControls button {
    min-height: 34px;
    padding: 7px 4px !important;
    font-size: 12px !important;
  }
}

/* ===== xq 风格会员 / 天梯侧栏（追加层，只改视觉，不动交互入口） ===== */
.lobby-side { gap: 12px; }
.side-tabs { display: none !important; }
.lobby-side > .side-panel {
  min-height: 0;
  padding: 14px;
  background: #2c1810;
  border: 1px solid #5a3a28;
  border-radius: 14px;
}
#sideMember { order: 1; border-color: #8a6b32 !important; box-shadow: inset 0 0 0 1px rgba(255, 214, 120, 0.18); }
#sideLeaderboard { order: 2; }
.lobby-side > .side-panel .side-panel-head {
  margin-bottom: 6px;
  padding-bottom: 6px;
  color: #d4a843;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  border-bottom: 0;
}
#sideMember .vip-summary { margin: 2px 0 10px; font-size: 11px; line-height: 1.55; color: #d8c39a; }
#sideMember .side-actions { display: flex; flex-direction: column; gap: 8px; }
#sideMember .side-btn-gold { order: 0; width: 100%; min-height: 34px; border-radius: 8px; font-size: 13px; }
#sideMember #btnVipRedeem { order: 1; min-height: 26px; font-size: 11px; }
.side-note { display: none; }
.lb-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.lb-table th { padding: 2px; color: #d4a843; font-weight: 400; text-align: left; }
.lb-table td { padding: 3px 2px; border-top: 1px solid #3d2117; }
.lb-table td:first-child { width: 32px; }
.lb-table th:last-child, .lb-table td:last-child { text-align: right; }
.lb-table td:last-child { color: #8b7355; font-size: 11px; }
.lb-table tr.lb-me td:nth-child(2) { color: #ff9b84; }
.lb-list { max-height: 236px; }
.lb-empty { padding: 6px 0; color: #8b7355; }

/* ===== 房间段位完整显示：姓名+段位不再被 64px 截断 ===== */
#clockRed .clock-name, #clockBlack .clock-name { max-width: 154px; }
@media (min-width: 761px) {
  .chess-clock { min-width: 260px; }
  #clockRed .clock-name, #clockBlack .clock-name { max-width: 170px; }
}
@media (max-width: 760px) {
  .chess-clock { min-width: 150px; }
  #clockRed .clock-name, #clockBlack .clock-name { max-width: 106px; }
}

/* ===== 手机联机：求和移到顶部后，第二行浮层按内容收窄，不再压住右侧计时面板 ===== */
@media (max-width: 760px) {
  body.online-mode #onlineSideControls {
    width: auto !important;
    right: auto !important;
    justify-content: flex-start !important;
  }
  body.online-mode #onlineSideControls > * {
    flex: 0 0 auto !important;
    min-width: 62px;
  }
}

/* ===== 2026-11-26 大厅布局调整（仅大厅，房间模式不受影响） ===== */
/* 大厅全屏按钮已按需求移除（房间内全屏按钮不受影响） */

/* 电脑端：标题居中；左右栏上端对齐、右栏加宽 1/2（300→450）并去边框；左栏左右留白对称 */
@media (min-width: 761px) {
  #lobby .lobby-head { text-align: center; }
  #lobby .lobby-brand { justify-content: center; }
  #lobby .lobby-title { text-align: center; }
  .lobby-shell { grid-template-columns: minmax(0, 1fr) 450px; align-items: start; }
  #lobby .lobby-side { border: none; align-self: start; margin-top: 0; }
  #lobby .lobby-main { padding-inline: clamp(0px, 2vw, 24px); }
}

/* ===== 2026-11-26 08:10 大厅左右留白三等分：到屏幕左边的距离 = 左右栏间距 = 到屏幕右边的距离 ===== */
@media (min-width: 761px) {
  #lobby {
    /* 保证左栏至少约 400px；窄桌面退化为 24px，宽屏最多 160px */
    --lobby-gutter: clamp(24px, min(11vw, calc((100vw - 850px) / 3)), 160px);
    padding-inline: 0;
  }
  #lobby .lobby-card {
    width: 100%;
    max-width: none;
    padding-inline: var(--lobby-gutter);
  }
  #lobby .lobby-shell {
    grid-template-columns: minmax(0, 1fr) 450px;
    gap: var(--lobby-gutter);
  }
  #lobby .lobby-main { padding-inline: 0; }
}

/* ===== 2026-11-26 08:17 桌面端标题上移：屏幕上缘到标题 = 标题到左右栏上缘 ===== */
@media (min-width: 761px) {
  /* 卡片垂直居中时：标题文档 y=(100vh-524)/2+30，左右栏 y=(100vh-524)/2+108；
     视觉上移 X=25vh-129px 后，上下留白同为 25vh-103px（804px 视口下均为 98px）。
     仅视觉位移，不改文档流，左右栏与三等分留白保持不动。 */
  #lobby .lobby-card { overflow: visible; }
  #lobby .lobby-head { transform: translateY(calc(129px - 25vh)); }
}

/* ===== 2026-11-26 残局按钮 / 状态条 / 房间列表 / 公告栏 ===== */
#lobby .endgame-btn {
  min-height: 40px;
  padding: 8px 12px;
  font-family: var(--font-chinese);
  font-size: 13px;
  letter-spacing: 1px;
  color: #f0d59a;
  background: rgba(34, 22, 14, 0.85);
  border: 1px solid rgba(205, 164, 91, 0.42);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
#lobby .endgame-btn:hover { background: rgba(232, 192, 112, 0.14); border-color: rgba(240, 190, 97, 0.72); }
/* 状态条：位于对弈设置框内部最下方、贴着下边框之上；
   在线人数居中，绿点紧随其右侧留固定间距，彻底消除重叠 */
#lobby .battle-status-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 18px;
  margin: 12px 0 0;
  padding: 0;
  border-top: 0;
}
#lobby .online-count {
  display: inline-block;
  font-size: 12px;
  color: #b09a7d;
  letter-spacing: 1px;
  white-space: nowrap;
}
#lobby .battle-status-row .ai-status {
  display: inline-block;
  flex: 0 0 auto;
  align-self: center;
  margin: 0;
  width: 9px;
  height: 9px;
}
/* 房间列表 */
#lobby .room-list { display: grid; gap: 6px; max-height: 230px; overflow-y: auto; }
#lobby .room-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 10px; border: 1px solid rgba(205, 164, 91, 0.22);
  border-radius: 8px; background: rgba(36, 20, 9, 0.62); font-size: 12px;
}
#lobby .room-id { color: #f0c674; font-weight: 700; }
#lobby .room-meta { flex: 1 1 140px; min-width: 130px; color: #c4a882; }
#lobby .room-playing { color: #2ecc71; }
#lobby .room-waiting { color: #f0c674; }
#lobby .room-red { color: #ff9a8d; }
#lobby .room-black { color: #c4a882; }
#lobby .room-action {
  padding: 4px 10px; font-size: 11px; cursor: pointer;
  color: #f0d59a; background: rgba(34, 22, 14, 0.85);
  border: 1px solid rgba(205, 164, 91, 0.42); border-radius: 6px;
}
#lobby .room-action:hover { background: rgba(232, 192, 112, 0.14); }
/* 公告栏 */
#lobby .announce-panel { padding: 0; }
#lobby .op-banner {
  padding: 10px 12px; border: 1px solid #c9a227; border-radius: 10px;
  background: linear-gradient(135deg, #2a1a0e, #1a0f0a);
  color: #f0c674; font-size: 13px; line-height: 1.5; cursor: pointer;
  word-break: break-all; overflow: hidden;
}
#lobby .op-banner:hover { filter: brightness(1.08); }
/* 残局列表面板 */
.endgame-card { max-width: 520px; }
#lobby .endgame-list { display: grid; gap: 8px; max-height: 46vh; overflow-y: auto; }
#lobby .endgame-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; border: 1px solid rgba(205, 164, 91, 0.28);
  border-radius: 8px; background: rgba(36, 20, 9, 0.62);
}
#lobby .endgame-name { font-size: 13px; color: #f0d59a; font-weight: 700; flex: 1 1 160px; }
#lobby .endgame-goal { font-size: 11px; color: #b09a7d; flex: 1 1 100%; }
#lobby .endgame-start {
  padding: 6px 14px; font-size: 12px; cursor: pointer; color: #2a1608; font-weight: 700;
  background: linear-gradient(145deg, #f1ce83, #c29143); border: 1px solid #ffdf99; border-radius: 6px;
}

/* ===== 2026-11-26 22:14 大厅修正 ===== */
/* 1) 大厅打开时去掉右上角全屏按钮（进入对局 body 无 lobby-open，按钮照常保留） */
body.lobby-open #btnFullscreen { display: none !important; }

/* 2) 右栏与左栏真正等高，底部齐平不越界、内容完整不裁切。
   左栏内容少时在底部自然留白，两栏共享同一底边。 */
@media (min-width: 761px) {
  #lobby .lobby-shell { align-items: stretch; }
  #lobby .lobby-main { display: flex; flex-direction: column; }
  #lobby .lobby-side { align-self: stretch; }
}

/* 3) 手机端：状态条移到屏幕最下方固定显示，居中一行不重叠 */
@media (max-width: 760px) {
  #lobby .battle-status-row {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 10px;
    z-index: 30;
    margin: 0;
    pointer-events: none;
  }
  #lobby .online-count { pointer-events: auto; }
}

/* ===== 2026-11-26 22:50 状态条移到最下方主边框之上 + 右栏不再覆盖卡片下方 =====
   状态条已移出 battleControls，成为 .lobby-card 的直接子元素。 */
@media (min-width: 761px) {
  /* 电脑端：贴整个大厅卡片最下方的下边框（主边框）之上，水平居中。
     居中位置正好落在左右两栏之间的空隙，不遮挡任何面板。 */
  #lobby .battle-status-row {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 12px;
    z-index: 5;
    margin: 0;
    pointer-events: none;
  }
  #lobby .online-count { pointer-events: auto; }
  /* 按钮行紧跟设置框，不留空行（去掉上一版 space-between 造成的 92px 空隙） */
  #lobby .lobby-main { justify-content: normal; }
  /* 右栏限高：天梯榜满数据时在列表内部滚动，不再撑高整张卡片把状态条顶出屏幕。
     高度与左栏自然内容一致（约 504px），底部仍与左栏齐平、不覆盖卡片下沿。 */
  #lobby .lobby-side {
    padding-bottom: 30px;
    box-sizing: border-box;
    max-height: 504px;
    overflow-y: hidden;
    overflow-x: hidden;
  }
  /* 天梯榜列表在面板内滚动：面板高度固定，行数再多也不外溢 */
  #lobby #sideLeaderboard { display: flex; flex-direction: column; min-height: 0; }
  #lobby #lbList { flex: 1 1 auto; min-height: 0; max-height: 176px; overflow-y: auto; }
}

/* ===== 2026-11-26 23:25 会员入口不丢失 + 房间列表任意数量不越界 =====
   根因：grid 容器在 max-height:504px 下压缩面板，房间列表(最多230px)溢出压住下方会员面板，
   且 overflow:hidden 直接裁掉会员入口。改为自然堆叠 + 右栏内滚动，所有面板都保留且可见。 */
@media (min-width: 761px) {
  #lobby .lobby-side {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    max-height: 504px;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    padding-bottom: 30px;
  }
  #lobby .lobby-side > * { flex: 0 0 auto; }
  /* 资料条 → 会员 → 天梯榜 → 房间列表：会员与天梯首屏可见，房间列表滚动查看 */
  #lobby .lobby-side > .profile-strip { order: -2 !important; }
  #lobby #sideMember { order: -1 !important; }
  #lobby #sideLeaderboard { order: 0 !important; }
  #lobby #sideRooms { order: 1 !important; }
  /* 房间列表、天梯榜各显示 5 行，超过部分在面板内滚动（实测：房间行 42px+间距 6px、天梯行 24px+表头 21.5px） */
  #lobby #roomList { max-height: 234px; overflow-y: auto; }
  #lobby #lbList { max-height: 142px; overflow-y: auto; }
  /* 细滚动条：房间列表与天梯排行榜完全同款（6px / 金棕 rgba(205,164,91,0.45) / 圆角 3px） */
  #lobby #roomList, #lobby #lbList { scrollbar-width: thin; scrollbar-color: rgba(205,164,91,0.45) transparent; }
  #lobby #roomList::-webkit-scrollbar, #lobby #lbList::-webkit-scrollbar { width: 6px; }
  #lobby #roomList::-webkit-scrollbar-track, #lobby #lbList::-webkit-scrollbar-track { background: transparent; border-radius: 3px; }
  #lobby #roomList::-webkit-scrollbar-thumb, #lobby #lbList::-webkit-scrollbar-thumb { background: rgba(205,164,91,0.45); border-radius: 3px; }
}

/* ===== 2026-11-27 房间列表移到左栏 + 匹配成功弹窗 + 右栏滚动条配色 ===== */
@media (min-width: 761px) {
  /* 房间面板移到左栏、与上方按钮左右对齐：继承左栏宽度，顶部留间距 */
  #lobby .lobby-room-panel {
    margin-top: 16px;
    min-height: 0;
    padding: 14px;
    background: #2c1810;
    border: 1px solid #5a3a28;
    border-radius: 14px;
  }
  /* 右栏（天梯/会员）滚动条 = 天梯排行榜滚动条同款（rgba(205,164,91,0.45) / 6px / 圆角 3px） */
  #lobby .lobby-side { scrollbar-width: thin; scrollbar-color: rgba(205,164,91,0.45) transparent; }
  #lobby .lobby-side::-webkit-scrollbar { width: 6px; }
  #lobby .lobby-side::-webkit-scrollbar-track { background: transparent; border-radius: 3px; }
  #lobby .lobby-side::-webkit-scrollbar-thumb { background: rgba(205,164,91,0.45); border-radius: 3px; }
  #lobby .lobby-side::-webkit-scrollbar-thumb:hover { background: rgba(205,164,91,0.45); }
}
@media (max-width: 760px) {
  #lobby .lobby-room-panel { margin-top: 14px; min-height: 0; padding: 14px; background: #2c1810; border: 1px solid #5a3a28; border-radius: 14px; }
}

/* 匹配成功弹窗：金色对战卡片 + 双方段位 + 倒计时进度条 */
.match-overlay { z-index: 70; }
.match-card {
  width: min(440px, 100%);
  padding: 28px 30px 26px;
  text-align: center;
  background: linear-gradient(155deg, #33200f 0%, #1b1109 60%, #2a1a0e 100%);
  border: 1px solid rgba(240, 190, 97, 0.55);
  box-shadow: 0 0 0 1px rgba(240,190,97,0.12), 0 28px 80px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,230,170,0.12);
  animation: matchPop 0.42s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}
@keyframes matchPop {
  0% { opacity: 0; transform: translateY(18px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.match-emblem {
  width: 62px; height: 62px; margin: 0 auto 10px;
  display: grid; place-items: center;
  font-size: 32px; color: #2a1608;
  background: radial-gradient(circle at 35% 30%, #ffe6a8, #d4a843 60%, #a9782c);
  border: 2px solid #ffe3a0; border-radius: 50%;
  box-shadow: 0 0 26px rgba(240,190,97,0.55), inset 0 2px 6px rgba(255,255,255,0.4);
  animation: matchPulse 1.6s ease-in-out infinite;
}
@keyframes matchPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(240,190,97,0.4), inset 0 2px 6px rgba(255,255,255,0.4); }
  50% { box-shadow: 0 0 34px rgba(240,190,97,0.8), inset 0 2px 6px rgba(255,255,255,0.4); }
}
.match-card h2 { margin: 0 0 4px; font-size: 26px; letter-spacing: 3px; text-shadow: 0 0 18px rgba(240,190,97,0.45); }
.match-subtitle { margin: 0 0 18px; font-size: 12px; color: #b9a88c; letter-spacing: 1px; }
.match-duel { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-bottom: 16px; }
.match-side {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 8px;
  background: rgba(40, 24, 13, 0.7);
  border: 1px solid rgba(205,164,91,0.32); border-radius: 10px;
}
.match-side-tag { font-size: 11px; color: #9a8468; letter-spacing: 2px; }
.match-side strong { font-size: 20px; font-family: var(--font-chinese); letter-spacing: 2px; }
.match-side:first-child strong { color: #ff8b7a; }
.match-side:last-child strong { color: #e8d9b8; }
.match-side-title { font-size: 12px; color: #d4a843; }
.match-vs { font-family: var(--font-chinese); font-size: 18px; font-weight: 700; color: var(--gold-bright); text-shadow: 0 0 12px rgba(240,190,97,0.5); }
.match-room { margin: 0 0 14px; font-size: 12px; color: #a89270; }
.match-room b { color: #f0c978; font-size: 14px; letter-spacing: 2px; }
.match-progress { height: 5px; margin-bottom: 10px; background: rgba(205,164,91,0.18); border-radius: 3px; overflow: hidden; }
.match-progress > span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #a9782c, #f0c978); border-radius: 3px; transform-origin: left center; animation: matchCountdownBar 2s linear both; }
@keyframes matchCountdownBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.match-countdown { margin: 0; font-size: 11px; color: #8b7355; }
.match-countdown span { color: #f0c978; font-weight: 700; }

/* 2026-11-27 以左栏高度为基准：左栏不限高，右栏拉伸与左栏等高（内容超出时右栏内部滚动） */
@media (min-width: 761px) {
  #lobby .lobby-shell { align-items: stretch; }
  #lobby .lobby-main { max-height: none !important; overflow-y: visible !important; padding-right: 0; }
  #lobby .lobby-side {
    max-height: none !important;
    overflow-y: auto !important;
    align-self: stretch;
  }
}

/* ===== 2026-11-27 全局统一所有滚动条：与残局页/天梯榜同款金棕色细滚动条 ===== */
/* scrollbar-width 不继承，必须落到 * 才能让每个滚动容器都与残局页页面滚动条一致。 */
* { scrollbar-width: thin; scrollbar-color: rgba(205,164,91,0.45) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; border-radius: 3px; }
*::-webkit-scrollbar-thumb { background: rgba(205,164,91,0.45); border-radius: 3px; }

/* ===== 2026-11-27 残局闯关下拉框 + 左栏控件尺寸统一（桌面/手机全部一样） ===== */
/* 残局下拉框与「人机引擎 / 敌军谋略」同一列对齐规则 */
#lobby .endgame-choice { display: grid; align-content: end; gap: 5px; min-width: 0; }
#lobby .endgame-choice small { margin: 0; }
#lobby .endgame-choice select { width: 100%; }

/* 左栏所有按钮与下拉框统一高度/内边距：桌面 44px */
#lobby .battle-controls button,
#lobby .battle-controls select,
#lobby .lobby-btn {
  box-sizing: border-box;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  padding-top: 9px;
  padding-bottom: 9px;
  font-size: 13px;
}
/* 手机端：全部统一 40px，字号/内边距一致 */
@media (max-width: 760px), (max-height: 540px) {
  #lobby .battle-controls button,
  #lobby .battle-controls select,
  #lobby .lobby-btn {
    height: 40px;
    min-height: 40px;
    max-height: 40px;
    padding-top: 6px;
    padding-bottom: 6px;
    font-size: 12px;
  }
  #lobby .battle-controls .mode-option,
  #lobby .battle-controls .visual-option { font-size: 11px; padding-left: 4px; padding-right: 4px; }
  #lobby .battle-controls select { padding-left: 6px; padding-right: 16px; background-position: calc(100% - 9px) calc(50% - 1px), calc(100% - 4px) calc(50% - 1px); background-size: 4px 4px, 4px 4px; }
  .lobby-btn { padding-left: 10px; padding-right: 10px; }
}
/* 矮屏单独压到 36px，仍保持全部一致 */
@media (max-height: 540px) {
  #lobby .battle-controls button,
  #lobby .battle-controls select,
  #lobby .lobby-btn {
    height: 36px;
    min-height: 36px;
    max-height: 36px;
    padding-top: 5px;
    padding-bottom: 5px;
  }
}

/* 左栏各行统一三等分：人机引擎 / 敌军谋略 / 残局闯关 等宽；底部三个按钮等宽 */
#lobby .ai-row { grid-template-columns: 2fr 1fr; }
#lobby .lobby-actions { grid-template-columns: 1fr 1fr 1fr; }
#lobby .lobby-btn.lobby-primary { grid-column: auto; }
@media (max-width: 760px), (max-height: 540px) {
  #lobby .ai-row { grid-template-columns: 2fr 1fr; }
  #lobby .lobby-actions { grid-template-columns: 1fr 1fr 1fr; }
  #lobby .lobby-btn.lobby-primary { grid-column: auto; }
  #lobby .ai-controls { flex-direction: row; gap: 0; }
  #lobby .ai-controls .ai-choice { flex: 1 1 0; min-width: 0; }
  #lobby .ai-choice + .ai-choice { border-left: 1px solid rgba(205,164,91,0.14); border-top: 0; padding-top: 0; }
}

/* 左栏四行严格三等分：所有按钮/下拉框宽高完全一致（label 内边距清零、控件 border-box） */
#lobby .battle-controls *, #lobby .lobby-actions * { box-sizing: border-box; }
#lobby .mode-row, #lobby .visual-row, #lobby .ai-row, #lobby .lobby-actions { grid-template-columns: repeat(3, 1fr); gap: 8px; }
#lobby .ai-controls { display: contents; }
#lobby .ai-choice, #lobby .endgame-choice, #lobby .motion-choice, #lobby .classic-board-choice, #lobby .visual-picker {
  padding: 0; min-width: 0; gap: 5px; align-content: end; display: grid;
}
#lobby .ai-choice + .ai-choice { border-left: 1px solid rgba(205,164,91,0.14); padding-left: 8px; }
#lobby .battle-controls button, #lobby .battle-controls select, #lobby .lobby-btn { width: 100%; }
@media (max-width: 760px), (max-height: 540px) {
  #lobby .mode-row, #lobby .visual-row, #lobby .ai-row, #lobby .lobby-actions { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  #lobby .ai-choice + .ai-choice { padding-left: 6px; }
}

/* 修正：mode-row 外层三等分，内层 mode-options 自身三列铺满；AI 两列各占 1fr 且去分隔内边距 */
#lobby .mode-row { grid-template-columns: 1fr; }
#lobby .mode-picker { min-width: 0; }
#lobby .mode-options { grid-template-columns: repeat(3, 1fr); width: 100%; }
#lobby .ai-choice + .ai-choice { border-left: 1px solid rgba(205,164,91,0.14); padding-left: 0; }
@media (max-width: 760px), (max-height: 540px) {
  #lobby .mode-row { grid-template-columns: 1fr; }
  #lobby .mode-options { grid-template-columns: repeat(3, 1fr); width: 100%; }
  #lobby .ai-choice + .ai-choice { padding-left: 0; }
}

/* 修正：残局弹层在 #lobby 之外（body 直接子元素），原 #lobby 前缀选择器不生效。
   用全局选择器重定义，使 12 局列表整齐排列、按钮不与文字挤在一起。 */
.endgame-card { max-width: 560px; }
.endgame-list { display: grid; gap: 8px; max-height: 54vh; overflow-y: auto; }
.endgame-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 12px;
  padding: 9px 12px; border: 1px solid rgba(205, 164, 91, 0.28);
  border-radius: 8px; background: rgba(36, 20, 9, 0.62);
}
.endgame-name { grid-column: 1; font-size: 13px; color: #f0d59a; font-weight: 700; }
.endgame-goal { grid-column: 1; font-size: 11px; color: #b09a7d; }
.endgame-start {
  grid-column: 2; grid-row: 1 / 3;
  padding: 7px 14px; font-size: 12px; cursor: pointer; color: #2a1608; font-weight: 700;
  background: linear-gradient(145deg, #f1ce83, #c29143); border: 1px solid #ffdf99; border-radius: 6px;
}

/* ===== 2026-11-27 全站隐藏所有滚动条：保留滚动功能，仅隐藏滚动条本体 ===== */
/* 用 !important 覆盖前面所有 thin + 金棕 专门规则；滚动仍可用（overflow 不变）。 */
html, body, *, *::before, *::after {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}
*::-webkit-scrollbar,
*::-webkit-scrollbar-track,
*::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-thumb:hover,
*::-webkit-scrollbar-corner {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}

/* ===== AI 复盘层（只作用于复盘开启时，不改动既有对局布局） ===== */
/* AI 复盘层：电脑端面板放在右下空白区，避开右上计时面板、右侧战利栏与经典大字棋盘 */
#reviewPanel {
  display: none;
  position: fixed;
  right: 22px;
  bottom: 18px;
  top: auto;
  z-index: 32;
  width: 240px;
  box-sizing: border-box;
  padding: 10px 12px;
  background: linear-gradient(155deg, rgba(35, 23, 14, 0.96), rgba(10, 10, 12, 0.95));
  border: 1px solid rgba(205, 164, 91, 0.4);
  border-radius: 10px;
  color: #e8d4ad;
}
#reviewPanel .rv-head {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #f0c674;
  margin-bottom: 5px;
}
#reviewPanel .rv-status {
  font-size: 11px;
  color: #d4a843;
  margin: 3px 0;
  min-height: 14px;
}
#reviewPanel .rv-curve {
  display: block;
  width: 100%;
  height: 78px;
  background: #120a06;
  border: 1px solid #3d2117;
  border-radius: 6px;
}
#reviewPanel .rv-detail {
  font-size: 11px;
  color: #c4a882;
  margin-top: 5px;
  min-height: 15px;
  line-height: 1.4;
}
#reviewPanel .rv-mobile-bar { display: none; }
/* 复盘按钮统一深色主题，不使用浏览器默认浅色样式 */
#btnReview, #reviewPanel button, .review-result-btn {
  background: linear-gradient(150deg, rgba(58, 38, 22, 0.96), rgba(28, 20, 14, 0.96));
  color: #f0c978;
  border: 1px solid rgba(205, 164, 91, 0.5);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
}
#reviewPanel button:hover, .review-result-btn:hover { background: #6b4a2a; color: #fff; }
#reviewPanel button.active { background: #8e44ad; color: #fff; }
/* 2026-12-01 复盘按钮高亮：电脑端试走等操作按钮挂在 #onlineSideControls，
   不在 #reviewPanel 内，原高亮规则命中不到；此处补同款高亮，与手机端视觉一致。 */
#onlineSideControls > button.active {
  background: #8e44ad !important;
  color: #fff !important;
  border-color: rgba(205, 164, 91, 0.9) !important;
}
body.review-open .review-result-btn { display: none; }
.review-result-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  font-size: 12px;
}

@media (max-width: 760px) {
  /* 手机端复盘面板放在顶部 HUD 下方横条，绝不覆盖中部棋盘 */
  #reviewPanel {
    right: 8px;
    left: 8px;
    top: 106px;
    bottom: auto;
    width: auto;
    max-height: none;
    overflow: visible;
    padding: 5px 8px;
    border-radius: 8px;
    z-index: 34;
  }
  #reviewPanel .rv-curve { display: none !important; }
  #reviewPanel .rv-head { display: none; }
  #reviewPanel .rv-status { font-size: 10px; margin: 0 0 2px; min-height: 12px; }
  #reviewPanel .rv-detail { font-size: 10px; margin-top: 2px; min-height: 13px; line-height: 1.3; }
  #reviewPanel .rv-mobile-bar {
    display: flex;
    flex-wrap: nowrap;
    gap: 3px;
    margin-top: 4px;
  }
  #reviewPanel .rv-mobile-bar button {
    flex: 1 1 0;
    min-width: 0;
    padding: 4px 1px;
    font-size: 10px;
    line-height: 1.1;
    letter-spacing: 0;
  }
  /* 手机端顶部第一排按钮：求和/换边/重开/大厅/复盘 统一竖排文本、统一样式。
     writing-mode 让两字按钮统一竖排；不加 min-width/flex 拉伸，避免撑高 HUD。 */
  .hud-top .actions button {
    writing-mode: vertical-rl;
    text-orientation: upright;
    -webkit-writing-mode: vertical-rl;
    padding: 5px 4px;
    font-size: 11px;
    line-height: 1.05;
    letter-spacing: 0;
    white-space: nowrap;
  }
  .hud-top .actions button .btn-text { writing-mode: vertical-rl; }
  #btnReview { padding: 5px 4px; font-size: 11px; letter-spacing: 0; }
  /* 复盘态顶部只留 求和/换边/重开/大厅/复盘 五个二字按钮，HUD 保持单行不撑高；
     认输/悔棋/返回房间在复盘期不可用，退出复盘立即恢复（与联机复盘行为一致）。 */
  body.review-open .hud-top #btnResign,
  body.review-open .hud-top #btnUndo,
  body.review-open .hud-top #btnReturnRoom { display: none !important; }
  /* 复盘时把提示文本框上移到 HUD 下方，避免被复盘面板覆盖；
     仅复盘态生效，非复盘态提示条位置完全不变。 */
  /* !important 覆盖 body.classic-view.online-mode #hintBar{top:130px} 的更高特异性规则 */
  body.review-open #hintBar,
  body.review-open.classic-view #hintBar,
  body.review-open.classic-view.online-mode #hintBar { top: 62px !important; bottom: auto !important; }
  /* 复盘态下联机操作横排与计时不可用，暂隐以腾出顶部空间给提示条，
     避免提示条与它们相互覆盖（退出复盘后立即恢复，不影响正常对局）。 */
  body.review-open.online-mode #onlineSideControls,
  body.review-open.online-mode #chessClock { display: none !important; }
}

/* ===== 2026-11-29 复盘布局再修正（桌面按钮顺序 / 面板避让） ===== */
/* 桌面复盘面板置于右下空白区：避开右上计时面板(88-138)、右侧战利栏(308-493)、
   以及经典大字棋盘(居中)和底部提示条(居中)，任何模式下都不压住既有元素。 */
@media (min-width: 761px) {
  #reviewPanel { right: 22px !important; bottom: 18px !important; top: auto !important; }
}
/* 复盘按钮在左侧列永远排在原按钮之后（order:10），绝不置顶；
   rv-ctl 由 review.js 在 createUI() 末尾统一打标，避免创建顺序导致漏标。 */
body.room-side-controls #onlineSideControls > #btnReview,
body.room-side-controls #onlineSideControls > .rv-ctl { order: 10 !important; }
