* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 30% 0%, #1b2432 0%, #0b0f16 55%, #070a0f 100%);
  color: #e5e7eb;
  font-family: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 26px 10px;
}
.brand h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 6px;
  color: #f3d9a4;
  font-weight: 700;
}
.brand p {
  margin: 4px 0 0;
  font-size: 12px;
  color: #94a3b8;
  letter-spacing: 1px;
}
.badge {
  font-size: 12px;
  color: #cbd5e1;
  border: 1px solid #334155;
  background: #0f172a;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

main {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 8px 26px 26px;
}
.board-wrap {
  flex: 1 1 720px;
  min-width: 320px;
  max-width: 780px;
  background: linear-gradient(180deg, #141b26, #0d1219);
  border: 1px solid #263041;
  border-radius: 18px;
  padding: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255,255,255,.04);
}
#board { width: 100%; height: auto; display: block; touch-action: manipulation; }

/* 棋盘线条 */
.road { stroke: #4b5563; stroke-width: 0.045; stroke-linecap: round; }
.rail { stroke: #b99a63; stroke-width: 0.11; stroke-linecap: round; opacity: .9; }
.cellbg {
  fill: #111827;
  stroke: #334155;
  stroke-width: 0.035;
  transition: fill .12s, stroke .12s;
}
.campbg { fill: #1e293b; stroke: #64748b; stroke-width: 0.04; stroke-dasharray: 0.12 0.08; }
.hqbg { fill: #3a2c25; stroke: #c08a4a; stroke-width: 0.06; }
.centerdot { fill: #94a3b8; }
.celllabel {
  fill: #64748b;
  font-size: 0.2px;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  user-select: none;
}
.seat-label {
  fill: #64748b;
  font-size: 0.5px;
  letter-spacing: 0.12px;
  text-anchor: middle;
  dominant-baseline: central;
  user-select: none;
}

/* 高亮 */
.cell.target .cellbg { fill: #14532d; stroke: #22c55e; stroke-width: 0.08; }
.cell.selected .cellbg { fill: #3b2f12; stroke: #fbbf24; stroke-width: 0.09; }
.cell.last .cellbg { stroke: #e2e8f0; stroke-width: 0.05; }

/* 棋子 */
.piece { cursor: pointer; }
.piece .disc {
  stroke: #0b1220;
  stroke-width: 0.045;
  filter: drop-shadow(0 0.04px 0.05px rgba(0,0,0,.6));
}
.piece .inner { pointer-events: none; }
.piece .ptext {
  fill: #fff;
  font-size: 0.27px;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  user-select: none;
  font-weight: 600;
}
.piece.hidden .disc { stroke-dasharray: 0.1 0.06; }
.piece.hidden .ptext { fill: #94a3b8; font-size: 0.36px; font-weight: 400; }
.piece.ally .disc { opacity: .95; }
.piece.revealed .disc { stroke: #f8fafc; stroke-width: 0.05; }
.piece.selected-piece .disc { stroke: #fbbf24; stroke-width: 0.09; }

/* 侧栏 */
.panel {
  width: 360px;
  flex: 0 0 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.status {
  min-height: 54px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #263041;
  background: #0f172a;
  color: #dbeafe;
  font-size: 13px;
  line-height: 1.55;
}
.status b { color: #f3d9a4; }
.status .lastlog {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px dashed rgba(148, 163, 184, .15);
  color: #94a3b8;
  font-size: 12px;
}

.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.controls .setup-seat {
  flex: 1 1 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #2b5478;
  background: #0d2237;
  color: #f3d9a4;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}
.controls .setup-seat.hidden { display: none; }
.controls button { flex: 1 1 86px; }
button {
  flex: 1;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #131c2b;
  color: #cbd5e1;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
}
button:hover:not(:disabled) { background: #1b2638; border-color: #475569; color: #fff; }
button.primary { background: #7c5a2a; border-color: #b98a45; color: #fff5e1; }
button.primary:hover:not(:disabled) { background: #8f6a33; }
button:disabled { opacity: .35; cursor: not-allowed; }

.players { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.player {
  border: 1px solid #263041;
  background: #0f172a;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 12px;
  color: #94a3b8;
}
.player .pname { font-size: 13px; font-weight: 600; color: #e2e8f0; display: flex; align-items: center; gap: 6px; }
.player .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.player .meta { margin-top: 3px; line-height: 1.5; }
.player.active { border-color: #f3d9a4; box-shadow: 0 0 0 1px rgba(243,217,164,.25) inset; }
.player.out { opacity: .45; text-decoration: line-through; }

.log-title { font-size: 12px; color: #64748b; letter-spacing: 1px; margin-top: 2px; }
.log {
  height: 260px;
  overflow-y: auto;
  border: 1px solid #263041;
  background: #0a0f17;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.7;
  color: #9fb0c7;
}
.log div { border-bottom: 1px dashed rgba(148,163,184,.08); padding: 2px 0; }
.log div:last-child { color: #e2e8f0; border-bottom: 0; }
.log div.lg-card { color: #e0a458; }
.log div.lg-passive { color: #8fc7a8; }
.log div.lg-dev { color: #9db4d8; }

.rules {
  border: 1px solid #263041;
  background: #0f172a;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  color: #94a3b8;
}
.rules summary { cursor: pointer; color: #cbd5e1; }
.rules ul { padding-left: 18px; line-height: 1.7; }
.rules b { color: #f3d9a4; }

@media (max-width: 1080px) {
  main { flex-direction: column; }
  .panel { width: 100%; flex-basis: auto; }
  .board-wrap { max-width: 100%; }
}

.lastline {
  stroke: #e2e8f0;
  stroke-width: 0.055;
  stroke-dasharray: 0.14 0.1;
  opacity: .7;
  pointer-events: none;
}

.cell.captured .cellbg {
  stroke: #ef4444;
  stroke-width: 0.06;
  stroke-dasharray: 0.1 0.06;
}

.head-right { display: flex; align-items: center; gap: 10px; }
.sound-btn {
  flex: none;
  width: auto;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 999px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #cbd5e1;
  background: #0f172a;
  border: 1px solid #263041;
  border-radius: 10px;
  padding: 8px 10px;
}
.check input { accent-color: #b98a45; }
.check.hidden { display: none; }

/* 外援座位选择 */
.agent-select {
  margin-left: auto;
  max-width: 70%;
  padding: 3px 4px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #111c2e;
  color: #e2e8f0;
  font-size: 12px;
}

/* 天命暗牌：按座位选择 */
.latent-wrap {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.latent-title { font-size: 12px; color: #cbd5e1; }
.latent-seats {
  display: flex;
  gap: 12px;
}
.latent-seats label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #e2e8f0;
  cursor: pointer;
}

/* 敌方棋子标记菜单 */
.mark-menu {
  position: fixed;
  z-index: 60;
  display: grid;
  grid-template-columns: repeat(4, minmax(46px, 1fr));
  gap: 4px;
  padding: 8px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55);
}
.mark-menu.hidden { display: none; }
.mark-menu button {
  padding: 5px 6px;
  font-size: 12px;
  color: #e2e8f0;
  background: #1a2536;
  border: 1px solid #2b3a4f;
  border-radius: 7px;
  cursor: pointer;
}
.mark-menu button:hover { background: #24334a; border-color: #b98a45; }
.mark-menu .mm-clear { grid-column: span 4; color: #f8b4b4; }
.mark-menu .mm-head {
  grid-column: span 4;
  font-size: 11px;
  color: #94a3b8;
  padding: 0 2px 2px;
}

/* 复盘库 */
.replay-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  overflow: auto;
  margin-bottom: 12px;
}
.replay-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #0f172a;
  border: 1px solid #263041;
  border-radius: 10px;
}
.replay-item .ri-main { flex: 1; min-width: 0; }
.replay-item .ri-name {
  font-size: 13px;
  color: #f3d9a4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.replay-item .ri-meta { font-size: 11px; color: #94a3b8; margin-top: 3px; }
.replay-item button { flex: none; width: auto; padding: 6px 12px; font-size: 12px; }
.replay-item .ri-del { color: #f8b4b4; }
.replay-empty { font-size: 12px; color: #94a3b8; padding: 14px 4px; text-align: center; }
.file-hidden { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(3, 7, 14, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-box {
  width: min(560px, 94vw);
  max-height: 88vh;
  overflow: auto;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.modal-box h2 { margin: 0 0 6px; font-size: 18px; color: #f3d9a4; letter-spacing: 2px; }
.modal-tip { margin: 0 0 12px; font-size: 12px; color: #94a3b8; line-height: 1.7; }
.seat-ai {
  margin-top: 10px;
  padding: 8px 10px 9px;
  border: 1px solid #24344d;
  border-radius: 10px;
  background: #0b1421;
}
.seat-ai-title { font-size: 12px; color: #cbd5e1; margin-bottom: 7px; }
.seat-ai-note { font-size: 10px; color: #64748b; font-weight: 400; margin-left: 4px; }
.seat-ai-rows { display: grid; gap: 5px; }
.seat-ai-row { display: flex; align-items: center; gap: 8px; }
.seat-ai-row .sn {
  width: 34px;
  flex: none;
  font-size: 12px;
  font-weight: 700;
}
.seat-ai-row select {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  border-radius: 6px;
  background: #0d2237;
  color: #f3d9a4;
  border: 1px solid #2b5478;
  font-size: 11px;
  outline: none;
  cursor: pointer;
}
.seat-ai-row .you { flex: 1; font-size: 11px; color: #64748b; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.result-card {
  border: 1px solid #24344d;
  border-radius: 10px;
  padding: 8px 10px;
  background: #0b1421;
}
.result-card.win { border-color: #3f7a4a; box-shadow: inset 0 0 0 1px rgba(63,122,74,.25); }
.result-card.out { opacity: .8; }
.rc-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.rc-seat { font-size: 13px; font-weight: 700; color: #e6edf6; }
.rc-tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #1d2b40; color: #9fb3cc; white-space: nowrap; }
.rc-tag.win { background: #17361f; color: #8ddc9b; }
.rc-tag.lose { background: #3a1c1c; color: #e79b9b; }
.rc-tag.draw { background: #2a2a3a; color: #b9b9d0; }
.rc-line { display: flex; justify-content: space-between; font-size: 12px; color: #93a4ba; margin-top: 3px; }
.rc-line b { color: #e6edf6; font-weight: 600; }
.rc-line .pos { color: #8ddc9b; }
.rc-line .neg { color: #e79b9b; }
.rc-note { margin-top: 5px; font-size: 11px; color: #7f8fa6; line-height: 1.55; }
.card-log-card { grid-column: 1 / -1; }
.result-team { margin-top: 10px; font-size: 12px; color: #cbd5e1; border-top: 1px dashed #24344d; padding-top: 8px; line-height: 1.8; }
.ai-rows { display: grid; gap: 8px; padding: 2px 0 10px; }
.ai-row { display: flex; align-items: center; gap: 10px; }
.ai-row .seat-name { width: 66px; font-size: 13px; color: #cbd5e1; }
.ai-row select {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  background: #0b1421;
  color: #f3d9a4;
  border: 1px solid #2b5478;
  font-size: 12px;
  outline: none;
}
.ai-row .seat-you { flex: 1; font-size: 12px; color: #7f8fa6; }

.cheat-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  padding: 4px 0 10px;
}
.cheat-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #cbd5e1;
  border-bottom: 1px dashed rgba(148,163,184,.12);
  padding: 4px 0;
}
.cheat-row .cname { width: 38px; }
.cheat-row .cavail { color: #64748b; font-size: 11px; width: 42px; }
.cheat-row button {
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 7px;
  font-size: 15px;
  line-height: 1;
}
.cheat-row .cnum { width: 22px; text-align: center; color: #f3d9a4; font-weight: 600; }
.modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid #263041;
}
.modal-foot #cheatTotal { margin-right: auto; color: #94a3b8; font-size: 13px; }
.modal-foot button { flex: none; width: auto; padding: 8px 16px; }

@media (max-width: 560px) {
  .cheat-list { grid-template-columns: 1fr; }
  .head-right { flex-direction: column; align-items: flex-end; gap: 6px; }
}

/* ---------- QQ 四国军棋风格 ---------- */
.board-wrap {
  background:
    radial-gradient(900px 620px at 50% 18%, #2f7455 0%, #21533e 48%, #163a2c 78%, #10291f 100%);
  border: 10px solid #3b2617;
  box-shadow:
    inset 0 0 0 2px #7a5430,
    inset 0 0 90px rgba(0, 0, 0, .45),
    0 26px 70px rgba(0, 0, 0, .55);
  padding: 14px;
}
#board {
  border-radius: 8px;
  background: transparent;
}
.hit { cursor: pointer; }
.hl { pointer-events: none; }
.qp { cursor: pointer; }
.qp-text {
  /* 2026-11-28 本站调整：原来是 KaiTi 楷体 —— 笔画细、带书法连笔，
     棋盘缩到 600px 宽时单字只有 9px 左右，糊成一片。
     换成无衬线黑体系并加重字重，配合 JS 里放大的字号与描边光晕。 */
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  font-weight: 800;
  user-select: none;
  pointer-events: none;
}
.qp-hidden .qp-back { filter: url(#none); }
.qp-selected { filter: drop-shadow(0 0 5px #ffd166); }

/* QQ 大厅配色 */
body {
  background: radial-gradient(1100px 700px at 30% 0%, #12314b 0%, #0a1a2a 55%, #06111c 100%);
}
.status { background: #0d2237; border-color: #2b5478; }
button { background: #102c44; border-color: #2b5478; }
button.primary { background: #a9792c; border-color: #e2b45a; }
.player { background: #0d2237; border-color: #24445f; }
.log { background: #071522; border-color: #24445f; }
.rules { background: #0d2237; border-color: #24445f; }
.badge { border-color: #2b5478; background: #0d2237; }

.board-stage { position: relative; width: 100%; aspect-ratio: 885 / 883; }

/* 四角阵亡清单：只列「确认阵亡」（撞出来过的），暗子死了不显示 —— 不给你金手指 */
.fallen {
  position: absolute;
  z-index: 3;
  display: none;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(17, 24, 39, .74);
  border: 1px solid rgba(148, 163, 184, .35);
  color: #e5e7eb;
  font-size: 11px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  max-width: 47%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fallen.show { display: block; }
.fallen b { font-weight: 500; color: #93c5fd; margin-right: 4px; }
.fallen .dom { color: #fcd34d; margin-left: 3px; }
.fallen .unk { color: #94a3b8; margin-left: 2px; }
.fallen.dead { opacity: .5; }
.fallen .big { color: #fca5a5; }
.fallen .bomb { color: #fdba74; }
.fallen .mine { color: #86efac; }
/* 四角贴在棋盘「十字」之外的空白角上，不要压到边框或棋子。
   （4px 会压在圆角边框上，字被边框吃掉一半） */
.fallen[data-seat="north"] { top: 16px; left: 16px; }
.fallen[data-seat="east"]  { top: 16px; right: 16px; }
.fallen[data-seat="south"] { bottom: 16px; right: 16px; }
.fallen[data-seat="west"]  { bottom: 16px; left: 16px; }
.board-rotor {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  transition: transform .28s ease;
}
.board-stage.view-east .board-rotor { transform: rotate(90deg); }
.board-stage.view-north .board-rotor { transform: rotate(180deg); }
.board-stage.view-west .board-rotor { transform: rotate(270deg); }
#board-bg {
  position: absolute;
  inset: 0;
  background: url("assets/qq_board.png") center / 100% 100% no-repeat;
  pointer-events: none;
}
#board {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
}

.board-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(8, 24, 16, .72);
  border: 1px solid rgba(226, 180, 90, .28);
  color: #cbb98f;
  font-size: 12px;
  letter-spacing: 1px;
}
.board-topbar .qq-title { color: #ffd166; font-weight: 700; letter-spacing: 3px; }
.board-stage.turn-north { box-shadow: inset 0 0 0 3px rgba(111, 154, 55, .85); border-radius: 8px; }
.board-stage.turn-east { box-shadow: inset 0 0 0 3px rgba(47, 111, 176, .9); border-radius: 8px; }
.board-stage.turn-south { box-shadow: inset 0 0 0 3px rgba(217, 121, 47, .9); border-radius: 8px; }
.board-stage.turn-west { box-shadow: inset 0 0 0 3px rgba(123, 75, 158, .9); border-radius: 8px; }

.player { display: flex; align-items: center; gap: 8px; }
.pavatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: "KaiTi", "Microsoft YaHei", serif;
  font-size: 16px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, .35);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, .35);
}
.pinfo { min-width: 0; }
.player.active .pavatar { outline: 2px solid #ffd166; outline-offset: 1px; }

.mode-select {
  flex: none;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid #2b5478;
  background: #0d2237;
  color: #f3d9a4;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.domains {
  margin: 8px 0 10px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid #2b5478;
  background: rgba(8, 24, 38, .72);
  font-size: 12px;
  color: #cbd5e1;
}
.dom-title {
  color: #7ee0c5;
  font-weight: 700;
  margin-bottom: 6px;
}
.dom-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.dom-chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  background: #12314a;
  border: 1px solid #2b5478;
  color: #f8f0dc;
  font-size: 11px;
}
.dom-note {
  margin-top: 6px;
  color: #8fa8bf;
  font-size: 11px;
  line-height: 1.35;
}

.check.disabled {
  opacity: .45;
  cursor: not-allowed;
}

.replay-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid #2b5478;
  background: rgba(8, 24, 38, .78);
  flex-wrap: wrap;
}
.replay-bar button {
  padding: 5px 9px;
  font-size: 12px;
  border-radius: 7px;
  border: 1px solid #2b5478;
  background: #0d2237;
  color: #f3d9a4;
  cursor: pointer;
}
.replay-bar button:hover { background: #173a55; }
.replay-label {
  font-size: 11px;
  color: #8fa8bf;
  margin-left: 2px;
  white-space: nowrap;
}
.replay-view.active,
.replay-side.active {
  background: #24506e;
  color: #ffffff;
  border-color: #7ec8e3;
}
#replayInfo {
  flex: 1;
  min-width: 80px;
  text-align: center;
  font-size: 12px;
  color: #cbd5e1;
  white-space: nowrap;
}

.battle-stats {
  margin: 8px 0 10px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid #2b5478;
  background: rgba(8, 24, 38, .72);
  font-size: 11px;
  color: #cbd5e1;
}
.bs-title {
  color: #7ee0c5;
  font-weight: 700;
  margin-bottom: 5px;
  font-size: 12px;
}
.bs-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  line-height: 1.6;
  border-top: 1px solid rgba(43, 84, 120, .45);
  padding-top: 3px;
  margin-top: 3px;
}
.bs-row:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.bs-name { color: #f3d9a4; white-space: nowrap; }
.bs-nums { text-align: right; color: #cbd5e1; }
.bs-nums b { color: #ffffff; }
.bs-sub { color: #8fa8bf; }

/* 阵法库搜索框 */
.modal-search {
  width: 100%;
  margin: 0 0 8px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid #3a4a5e;
  background: #1a2432;
  color: #e6edf3;
  font-size: 13px;
  box-sizing: border-box;
}
.modal-search::placeholder { color: #6b7c92; }

/* ---------- 零代参谋 ---------- */
.advice {
  margin-top: 10px;
  padding: 8px 10px 9px;
  border: 1px solid #24344d;
  border-radius: 10px;
  background: #0b1421;
}
.advice-head {
  font-size: 12px;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 6px;
}
.advice-head input { accent-color: #ffd166; }
.advice-box { margin-top: 7px; font-size: 11px; color: #cbd5e1; }
.adv-title {
  color: #ffd166;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.adv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.adv-row:hover { background: #122033; }
.adv-row.best {
  background: #16304a;
  border: 1px solid #2b5478;
}
.adv-row .mv { color: #dbe7f3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adv-row .sc {
  color: #7ee0c5;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.adv-row.guess .sc { color: #f3d9a4; }
.adv-sub { margin-top: 7px; color: #94a3b8; }
.adv-piece { color: #f8f0dc; }
.adv-list { max-height: 168px; overflow-y: auto; margin-top: 2px; }
.adv-list-inline { margin-top: 3px; }
.adv-rank {
  display: inline-block;
  margin: 2px 4px 0 0;
  padding: 1px 7px;
  border-radius: 999px;
  background: #12314a;
  border: 1px solid #2b5478;
  color: #f8f0dc;
}
.adv-rank.low { opacity: .55; }
.adv-note {
  margin-top: 6px;
  color: #8fa8bf;
  font-size: 11px;
  line-height: 1.4;
}

/* ---------- 版面：左信息 / 中棋盘 / 右操作 / 底部规则 ---------- */
main {
  display: grid;
  grid-template-columns: minmax(220px, 285px) minmax(420px, 820px) minmax(290px, 350px);
  gap: 16px;
  justify-content: center;
  align-items: start;
  padding: 8px 20px 28px;
}
.panel { width: auto; flex: none; min-width: 0; }
.board-wrap { max-width: 820px; }
.rules-wrap { grid-column: 1 / -1; }
.rules-wrap .rules { margin-top: 0; }
.panel-left .log { height: 300px; }

@media (max-width: 1240px) {
  main { grid-template-columns: minmax(0, 1fr); justify-items: stretch; }
  .rules-wrap { grid-column: auto; }
  .panel { width: auto; }
  .board-wrap { max-width: none; }
}
/* 面板内部：左栏拉满高度、玩家卡片单列、记录区吃掉剩余空间 */
.panel-left, .panel-right { align-self: stretch; }
.panel-left .players { grid-template-columns: 1fr; }
.panel-left .log { flex: 1 1 auto; height: auto; min-height: 260px; }

/* 这两块原本靠 .hidden 隐藏，但全局没有 .hidden 规则（.piece.hidden 另有含义，不能加） */
.replay-bar.hidden { display: none; }
.domains.hidden { display: none; }

/* 零代参谋：鼠标悬浮棋子的概率提示框 */
.adv-tip {
  position: fixed;
  z-index: 60;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #2b5478;
  background: rgba(8, 20, 32, .96);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .6);
  color: #dbe7f3;
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
  max-width: 280px;
}
.adv-tip.hidden { display: none; }
.tip-title { color: #ffd166; font-weight: 700; margin-bottom: 4px; }
.tip-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.tip-chip {
  padding: 1px 7px;
  border-radius: 999px;
  background: #12314a;
  border: 1px solid #2b5478;
}
.tip-chip.low { opacity: .55; }
.tip-note { margin-top: 5px; color: #8fa8bf; font-size: 11px; }

/* 悬浮框：三家并列 */
.tip-row { display: flex; align-items: flex-start; gap: 6px; margin-top: 4px; }
.tip-tag {
  flex: none;
  width: 30px;
  color: #8fa8bf;
  font-size: 11px;
  line-height: 18px;
}
.tip-chip.dim { opacity: .8; }

/* 零代等级选择 */
.advice-level {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 11px;
  color: #8fa8bf;
}
.advice-level select {
  flex: 1;
  padding: 3px 6px;
  border-radius: 7px;
  border: 1px solid #2b5478;
  background: #0d2237;
  color: #cbd5e1;
  font-size: 11px;
}

/* ===== 沙盘摆子（自定义局面 → 四家对弈） ===== */
.sandbox {
  margin-top: 10px;
  padding: 8px 10px 10px;
  border: 1px solid #2a3648;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(10,15,22,.92), rgba(6,10,16,.92));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.sandbox-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: #c8d8e8;
}
.sandbox-title { font-weight: 700; color: #ffd166; letter-spacing: .5px; }
.sandbox-spacer { flex: 1 1 auto; }
.sandbox-hint { color: #7f93a8; font-size: 11px; }
.sandbox-seats { display: flex; gap: 4px; }
.sandbox-seat {
  padding: 2px 9px; border-radius: 6px; cursor: pointer;
  border: 1px solid currentColor; background: transparent;
  font-size: 12px; font-weight: 600; opacity: .62;
}
.sandbox-seat:hover { opacity: .88; }
.sandbox-seat.on { opacity: 1; color: #08131c !important; }
.sandbox-pool {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px; max-height: 108px; overflow-y: auto;
  align-content: flex-start;
}
.sandbox-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 7px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.05);
  font-size: 12px; color: #e8f0f8; user-select: none;
}
.sandbox-chip:hover { background: rgba(255,255,255,.12); }
.sandbox-chip.picked {
  background: #ffd166; color: #1a1206; border-color: #ffd166;
  box-shadow: 0 0 0 2px rgba(255,209,102,.28);
}
.sandbox-chip.dead { opacity: .35; cursor: default; }
.sandbox-chip .n { font-weight: 700; }
.sandbox-chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.sandbox-empty { color: #7f93a8; font-size: 12px; padding: 6px 2px; }
button.mini {
  padding: 3px 10px; border-radius: 6px; font-size: 12px; cursor: pointer;
  border: 1px solid #2b5478; background: #0d2237; color: #cbd5e1;
}
button.mini:hover { background: #143049; }
button.mini.primary { border-color: #b8862b; background: #3a2a08; color: #ffd166; }
button.mini.primary:hover { background: #4a3609; }

/* ===== 三引擎参谋（零代 / 一代 / 二代 并排对比） ===== */
.adv-title .adv-seat-note {
  font-weight: 400;
  letter-spacing: 0;
  font-size: 11px;
  color: #8fa8bf;
  margin-left: 4px;
}
.adv-title .ok { color: #7ee0c5; }
.adv-engine {
  margin-top: 6px;
  padding: 5px 6px 6px;
  border: 1px solid #22303f;
  border-radius: 8px;
  background: rgba(255, 255, 255, .026);
}
.adv-eng-head {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
}
.adv-eng-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.adv-eng-name { color: #e8f0f8; font-weight: 700; }
.adv-eng-tag {
  margin-left: auto;
  color: #7f93a8;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.adv-engine .adv-row { padding: 1px 4px; }
.adv-engine .adv-row.best { background: #123048; border-color: #24486a; }
.adv-engine .adv-rank { margin: 3px 3px 0 0; padding: 0 6px; }
.adv-row .pc {
  display: inline-block;
  min-width: 13px;
  padding: 0 2px;
  margin-right: 3px;
  border-radius: 3px;
  background: #1b2a3a;
  color: #a9c0d6;
  font-size: 10px;
  text-align: center;
}
.adv-rank b.fix {
  margin-left: 3px;
  padding: 0 3px;
  border-radius: 3px;
  background: #24543f;
  color: #b6f0d0;
  font-size: 9px;
  font-weight: 700;
}
/* 猜子的证据角标：锁/吃/区/位/阵 —— 让「凭什么这么猜」直接写在脸上 */
.adv-rank b.ev {
  margin-left: 3px;
  padding: 0 3px;
  border-radius: 3px;
  background: #3a3550;
  color: #cbbdf0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: help;
}

/* ---------- 自适应：棋盘按「可用高度」定大小（2026-11-04）----------
   原来的问题：棋盘宽 = 中列宽（minmax(420,820)），窗口缩到半屏时中列被挤成 480，
   棋盘跟着小，而高度方向其实还有富余。
   现在改成：宽 = min(容器宽, 可用高 × 885/883)，即**先按高度撑满**，再让宽度兜底。
   188px 是头部 + 外边距 + 棋盘外框 + 顶栏的实测总和。 */
:root { --board-h: calc(100vh - 190px); }
.board-stage {
  /* 用 width:100% + max-width 而不是 min()：min() 一旦哪一层解析失败就静默退回 100%，
     棋盘会悄悄撑出视口；max-width 失效时至少还有 width:100% 兜底。 */
  width: 100%;
  max-width: calc((100vh - 190px) * 1.0023);
  aspect-ratio: 885 / 883;
  margin: 0 auto;
}

/* 宽屏：三列，侧栏按比例收窄，把宽度让给棋盘 */
@media (max-width: 1560px) {
  main {
    grid-template-columns: minmax(200px, 250px) minmax(360px, 820px) minmax(240px, 300px);
    gap: 12px;
    padding: 8px 14px 24px;
  }
}

/* 窄屏（约半屏 1200 以下）：棋盘独占一行放到最上面，两侧面板沉到下面，
   这样棋盘能用到整幅宽度（仍然受高度上限约束，不会溢出视口） */
@media (max-width: 1200px) {
  main { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 14px; }
  /* 单列时棋盘必须排第一：DOM 顺序是 左栏→棋盘→右栏，不调 order 的话
     左栏那张长面板会把棋盘挤到首屏之外。 */
  .board-wrap { width: 100%; max-width: none; order: -1; }
  .panel-left .log { height: 200px; min-height: 0; }
  .panel-left, .panel-right { width: 100%; max-width: 980px; }
  .panel-left .players { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-left .log { max-height: 320px; }
}

@media (max-width: 900px) {
  header { padding: 10px 14px 6px; gap: 10px; }
  .brand h1 { font-size: 20px; letter-spacing: 3px; }
  .brand p { display: none; }
  .board-wrap { border-width: 6px; padding: 8px; }
}
@media (max-height: 780px) {
  /* 矮屏只压缩留白，不藏顶栏（步数/轮到谁都在那上面） */
  /* 矮屏同理 */
  .board-wrap { border-width: 6px; padding: 8px; }
}

/* ---------- 可折叠的栏（2026-11-04）----------
   战果 / 记录 / 每家 AI 这几块是回看时才有用，默认收起，点标题展开。
   用原生 <details>：不占脚本、键盘可操作、状态也稳。 */
.fold {
  border: 1px solid #24445f;
  border-radius: 10px;
  background: #0d2237;
  overflow: hidden;
}
.fold > summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #cfe3f5;
  background: #102c44;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before {
  content: "▸";
  color: #7fa8c9;
  font-size: 11px;
  transition: transform .15s;
}
.fold[open] > summary::before { transform: rotate(90deg); }
.fold > summary:hover { color: #fff; background: #14344f; }
.fold[open] > summary { border-bottom: 1px solid #1d3a55; }
/* 内容不再自带外框，避免「框套框」 */
.fold .battle-stats, .fold .log { border: 0; border-radius: 0; background: transparent; }
.fold .log { height: 220px; overflow: auto; }
.fold .seat-ai-rows { padding: 8px 10px 10px; }
