: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;
}

/* 房间顶部：操作组靠最右；联机隐藏“返回房间”，人机/双人保留“大厅 + 返回房间 + 全屏图标” */
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: 60px; }
  .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: 66px;
    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;
  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 { grid-column: 2; justify-self: center; margin: 0; width: 9px; height: 9px; }

.lobby-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 12px;
  margin-top: 26px;
  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;
  }
}

@media (prefers-reduced-motion: reduce) {
  .boot-line b, .chip, #checkBanner.show, .ai-status { animation: none; }
}
