/* 中国象棋 · 弈 —— 界面样式 */
:root {
  --ink: #12100e;
  --ink-1: #1a1714;
  --ink-2: #221d18;
  --ink-3: #2c251d;
  --line: #3b3227;
  --line-soft: #302a21;
  --paper: #ecdfc4;
  --text: #eae3d5;
  --muted: #9e9282;
  --gold: #c9a05c;
  --gold-dim: #8a6f3f;
  --red: #c0392b;
  --red-soft: #e05a45;
  --green: #5f9c78;
  --shadow: 0 18px 40px rgba(0, 0, 0, .45);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 620px at 50% -12%, #2a231b 0%, transparent 62%),
    radial-gradient(900px 500px at 100% 105%, #201a15 0%, transparent 60%),
    var(--ink);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .022) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: .5;
  z-index: 0;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0; }
button { font-family: inherit; }
[hidden] { display: none !important; }

.app {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(44, 37, 29, .78), rgba(26, 23, 20, .78));
  box-shadow: 0 10px 26px rgba(0, 0, 0, .28);
  backdrop-filter: blur(6px);
}

.brand { display: flex; align-items: center; gap: 14px; }

.seal {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(160deg, #b23a2c, #7c2118);
  border: 1px solid #d9a76a;
  color: #f6e6c8;
  font-family: "KaiTi", "STKaiti", "Songti SC", serif;
  font-size: 27px;
  letter-spacing: 1px;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, .45), 0 6px 14px rgba(0, 0, 0, .4);
}

.brand-text h1 {
  font-family: "KaiTi", "STKaiti", "Songti SC", serif;
  font-size: 26px;
  letter-spacing: 5px;
  color: #f2e6cf;
  line-height: 1.2;
}

.brand-text span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: 2.4px;
  color: var(--muted);
  text-transform: uppercase;
}

.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #2b241d, #221c16);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  letter-spacing: .5px;
  transition: border-color .18s, transform .12s, background .18s, color .18s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--gold-dim); color: #fff3dc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.small { padding: 6px 12px; font-size: 12.5px; }
.btn.ghost { background: transparent; padding: 8px 12px; }
.btn.accent {
  border-color: var(--gold-dim);
  background: linear-gradient(180deg, #40321f, #2c2317);
  color: #f0d9a8;
}
.btn.primary {
  border-color: #b08040;
  background: linear-gradient(180deg, #b4833f, #86602a);
  color: #1c1409;
  font-weight: 600;
}
.btn.primary:hover { background: linear-gradient(180deg, #c9954c, #96702f); color: #170f06; }
.btn.danger { border-color: #6b2b23; color: #e08a7c; }
.btn.danger:hover { border-color: #a4413a; color: #ffb3a5; }

.mini-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 11.5px;
  cursor: pointer;
}
.mini-btn:hover { color: var(--gold); border-color: var(--gold-dim); }

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 326px;
  gap: 18px;
  align-items: start;
}

.board-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.statusline {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(38, 32, 25, .66), rgba(24, 20, 17, .66));
}
.turn { display: flex; align-items: center; gap: 8px; font-size: 15px; letter-spacing: 1px; }
.turn .dot {
  width: 10px; height: 10px; border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .06), 0 0 12px currentColor;
}
.turn .dot.red { background: var(--red-soft); color: var(--red-soft); }
.turn .dot.black { background: #d7cbb6; color: #d7cbb6; }
.statusline .meta { color: var(--muted); font-size: 12.5px; letter-spacing: .6px; }
.statusline .clock { margin-left: auto; font-variant-numeric: tabular-nums; color: #cbbfa8; letter-spacing: 1px; }

.board-holder {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px;
  border-radius: var(--radius);
  background: radial-gradient(120% 100% at 50% 0%, #262019, #171310 78%);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
  min-height: 240px;
  overflow: hidden;
}

#boardCanvas {
  display: block;
  border-radius: 10px;
  touch-action: manipulation;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35), 0 12px 30px rgba(0, 0, 0, .38);
}

.thinking {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(18, 14, 10, .82);
  border: 1px solid var(--gold-dim);
  color: #f0d9a8;
  font-size: 12.5px;
  letter-spacing: 1px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
}
.thinking em {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold);
  animation: pulse 1s infinite ease-in-out;
}
@keyframes pulse { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }

.actionbar { display: flex; gap: 8px; justify-content: center; }

/* 双人对战：左右各自独立的悔棋 / 认输 */
.dual-actions { display: flex; gap: 12px; }
.dual-actions .side-act {
  flex: 1;
  display: flex;
  gap: 8px;
  justify-content: center;
  min-width: 0;
}
.side-buttons { display: flex; gap: 8px; justify-content: center; }
.undo-prompt {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  border-radius: 8px;
}
.undo-prompt .undo-text {
  font-size: 12.5px;
  color: var(--gold);
  white-space: nowrap;
}

/* ---------- 复盘条 ---------- */
.reviewbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(42, 35, 27, .7), rgba(24, 20, 17, .7));
}
.review-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.review-controls > button {
  width: 34px; height: 30px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #241e18;
  color: #d8cbb6;
  cursor: pointer;
  font-size: 13px;
}
.review-controls > button:hover { border-color: var(--gold-dim); color: #fff1d8; }
.review-controls > button.play {
  width: 44px;
  border-color: var(--gold-dim);
  background: linear-gradient(180deg, #3b2e1d, #292014);
  color: #f1d8a6;
  font-size: 15px;
}
.review-controls > button#rvExit { width: auto; padding: 0 12px; }
.ply-label { margin-left: 4px; font-variant-numeric: tabular-nums; color: #c9bda6; font-size: 12.5px; }
#rvSpeed {
  background: #241e18;
  border: 1px solid var(--line);
  color: #d8cbb6;
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 12.5px;
}

#rvSlider {
  width: 100%;
  appearance: none;
  height: 6px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--red) 0%, #6a5a3f 50%, #8b8b7a 100%);
  outline: none;
  cursor: pointer;
}
#rvSlider::-webkit-slider-thumb {
  appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: #f2dcae;
  border: 2px solid #7a5c2a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
#rvSlider::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: #f2dcae; border: 2px solid #7a5c2a;
}

.chart-wrap {
  position: relative;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  background: #15120f;
}
#evalCanvas { display: block; width: 100%; height: 96px; cursor: crosshair; }
.chart-legend {
  position: absolute; right: 8px; top: 6px;
  display: flex; gap: 10px;
  font-size: 10.5px; color: var(--muted);
  pointer-events: none;
}
.chart-legend .lg::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 4px; vertical-align: 1px;
}
.chart-legend .lg.red::before { background: var(--red-soft); }
.chart-legend .lg.black::before { background: #b9ad97; }
.chart-legend .lg.zero::before { background: #6a6a60; }

.analysis {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(15, 12, 10, .45);
}
.ana-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px; letter-spacing: 1px; color: var(--gold);
  margin-bottom: 6px;
}
.ana-progress { color: var(--muted); letter-spacing: 0; font-size: 11.5px; }
.ana-body { font-size: 12.5px; line-height: 1.75; color: #cdc2ae; }
.ana-body p + p { margin-top: 4px; }
.ana-body b { color: #f0d9a8; font-weight: 600; }
.ana-body .bad { color: #e78a76; }
.ana-body .good { color: #8fc4a1; }
.muted { color: var(--muted); }

/* ---------- 侧栏 ---------- */
.side-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.panel {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(35, 29, 23, .72), rgba(22, 18, 15, .72));
  padding: 12px 14px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .25);
}
.panel.grow { display: flex; flex-direction: column; min-height: 260px; max-height: calc(100vh - 470px); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head h2 {
  font-family: "KaiTi", "STKaiti", "Songti SC", serif;
  font-size: 16px; letter-spacing: 3px; color: #e9dcc2;
}
.panel-head .count {
  display: inline-block; margin-left: 4px; padding: 0 6px;
  border-radius: 999px; border: 1px solid var(--line);
  font-size: 11px; color: var(--muted); letter-spacing: 0;
}
.hint-inline { font-size: 11px; color: var(--muted); }

.players { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.player {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .02);
  transition: border-color .2s, background .2s;
}
.player.active { border-color: var(--gold-dim); background: rgba(201, 160, 92, .08); }
.player .pinfo { display: flex; align-items: baseline; gap: 8px; }
.player .pinfo b { font-size: 14px; letter-spacing: 2px; }
.player .sub { font-size: 11px; color: var(--muted); }
#playerRed b { color: var(--red-soft); }
#playerBlack b { color: #dcd1bb; }
.ptag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.ptag.ai { border-color: #4b6a58; color: #8fc4a1; }

.captured { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px dashed var(--line-soft); }
.cap-row { display: flex; align-items: center; gap: 8px; }
.cap-label { font-size: 11px; color: var(--muted); width: 58px; flex: 0 0 auto; }
.cap-pieces { display: flex; flex-wrap: wrap; gap: 3px; min-height: 18px; }
.cap-piece {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: "KaiTi", "STKaiti", serif; font-size: 12px;
  background: #e7d8b8; color: #8c2b22; border: 1px solid #9c7b48;
}
.cap-piece.black { background: #d9cdb7; color: #241f19; }

.moves { overflow-y: auto; flex: 1; padding-right: 4px; display: flex; flex-direction: column; gap: 2px; }
.moves::-webkit-scrollbar { width: 6px; }
.moves::-webkit-scrollbar-thumb { background: #3d3428; border-radius: 4px; }
.moves .empty { color: var(--muted); font-size: 12.5px; padding: 14px 4px; }
.mv {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 7px; border-radius: 7px;
  cursor: pointer; border: 1px solid transparent;
  font-size: 13px;
}
.mv:hover { background: rgba(201, 160, 92, .08); }
.mv.current { background: rgba(201, 160, 92, .16); border-color: var(--gold-dim); }
.mv .idx { width: 22px; color: #756a5b; font-variant-numeric: tabular-nums; font-size: 11.5px; }
.mv .nota { font-family: "KaiTi", "STKaiti", serif; font-size: 15px; letter-spacing: 1px; }
.mv.red .nota { color: #e5836f; }
.mv.black .nota { color: #ddd1b9; }
.mv .cap-mark { font-size: 10.5px; color: var(--muted); }
.badge {
  font-size: 10.5px; padding: 1px 6px; border-radius: 4px; letter-spacing: .5px;
  border: 1px solid var(--line); color: var(--muted);
}
.badge.best { border-color: #4f7a62; color: #8fc4a1; background: rgba(95, 156, 120, .1); }
.badge.good { border-color: #50707a; color: #93bcc9; background: rgba(90, 140, 160, .1); }
.badge.bad { border-color: #7a4038; color: #e09384; background: rgba(160, 70, 60, .1); }
.badge.worst { border-color: #93513f; color: #ffab97; background: rgba(190, 70, 50, .16); }

.footnote { text-align: center; color: #6f6557; font-size: 11.5px; letter-spacing: .4px; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 6, 5, .72);
  backdrop-filter: blur(7px);
  animation: fade .18s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid #493c2b;
  background:
    radial-gradient(120% 90% at 50% 0%, #2e261d, #1a1612 72%);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .05);
  animation: pop .22s cubic-bezier(.2, .9, .3, 1.1);
  overflow: hidden;
}
@keyframes pop { from { transform: translateY(12px) scale(.97); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-card.narrow { width: min(430px, 100%); }
.modal-card.wide { width: min(760px, 100%); }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h2 {
  font-family: "KaiTi", "STKaiti", "Songti SC", serif;
  font-size: 21px; letter-spacing: 4px; color: #f2e4c9;
}
.close {
  width: 30px; height: 30px;
  border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--muted);
  font-size: 17px; line-height: 1; cursor: pointer;
}
.close:hover { color: #fff; border-color: var(--gold-dim); }

.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-body.scroll { max-height: min(64vh, 560px); }
.modal-body::-webkit-scrollbar { width: 8px; }
.modal-body::-webkit-scrollbar-thumb { background: #3b3226; border-radius: 5px; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line-soft);
}

.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block; margin-bottom: 8px;
  font-size: 12px; letter-spacing: 2px; color: var(--muted);
}
.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  gap: 6px; padding: 5px;
  border: 1px solid var(--line-soft); border-radius: 10px;
  background: rgba(0, 0, 0, .22);
}
.segmented button {
  padding: 9px 6px;
  border-radius: 7px; border: 1px solid transparent;
  background: transparent; color: #c6bba7;
  cursor: pointer; font-size: 13.5px; letter-spacing: 1px;
  transition: all .16s;
}
.segmented button:hover { color: #f5e7cc; }
.segmented button.active {
  border-color: var(--gold-dim);
  background: linear-gradient(180deg, #463620, #2f2617);
  color: #f3dcae;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
.hint { margin-top: 8px; font-size: 11.5px; color: var(--muted); line-height: 1.6; }

.over-reason {
  text-align: center; font-size: 13px; color: var(--gold); letter-spacing: 2px; margin-bottom: 14px;
}
.over-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding: 12px; border: 1px solid var(--line-soft); border-radius: 10px;
  background: rgba(0, 0, 0, .2);
}
.over-stats div { text-align: center; }
.over-stats b { display: block; font-size: 18px; color: #f0dfbd; font-weight: 600; }
.over-stats span { font-size: 11px; color: var(--muted); letter-spacing: 1px; }
#overTitle { font-family: "KaiTi", "STKaiti", serif; font-size: 25px; letter-spacing: 3px; }

/* ---------- 开始页 ---------- */
.start-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1000px 620px at 50% 6%, #2c2419 0%, transparent 62%),
    linear-gradient(180deg, #141109, #0c0a08);
}
.start-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .028) 1px, transparent 1px);
  background-size: 34px 34px;
  opacity: .55;
  pointer-events: none;
}
.start-inner {
  position: relative;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: fade .5s ease-out;
}
.start-seal {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: linear-gradient(160deg, #b23a2c, #74201a);
  border: 1px solid #d9a76a;
  color: #f6e6c8;
  font-family: "KaiTi", "STKaiti", "Songti SC", serif;
  font-size: 54px;
  box-shadow: inset 0 0 22px rgba(0, 0, 0, .5), 0 14px 34px rgba(0, 0, 0, .55);
}
.start-inner h1 {
  font-family: "KaiTi", "STKaiti", "Songti SC", serif;
  font-size: clamp(40px, 7vw, 74px);
  letter-spacing: 16px;
  text-indent: 16px;
  color: #f4e6c8;
  text-shadow: 0 8px 26px rgba(0, 0, 0, .6);
  line-height: 1.15;
}
.start-sub {
  color: var(--muted);
  letter-spacing: 3px;
  font-size: 12.5px;
}
.start-btn {
  margin-top: 20px;
  padding: 14px 58px;
  font-size: 17.5px;
  letter-spacing: 9px;
  text-indent: 9px;
  border-radius: 12px;
  border: 1px solid #b08040;
  background: linear-gradient(180deg, #b4833f, #86602a);
  color: #1c1409;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
  transition: transform .14s, background .18s;
}
.start-btn:hover { background: linear-gradient(180deg, #c9954c, #96702f); transform: translateY(-2px); }
.start-btn:active { transform: translateY(0); }
.start-links { display: flex; gap: 22px; margin-top: 8px; }
.start-links button {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12.5px;
  letter-spacing: 2px;
}
.start-links button:hover { color: var(--gold); }

/* ---------- 双棋盘 ---------- */
.board-holder.dual {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
.board-wrap {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
  padding-top: 18px;
  align-items: center;
  justify-content: center;
}
.board-wrap[hidden] { display: none !important; }
.board-tag {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(18, 14, 10, .78);
  font-size: 10.5px;
  letter-spacing: 1px;
  color: var(--muted);
  pointer-events: none;
  z-index: 2;
}
.board-tag.red { color: #e5836f; border-color: #6b2b23; }
.board-tag.black { color: #d9ceb8; }

/* ---------- 残局编辑器 ---------- */
.editbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--gold-dim);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(48, 39, 26, .86), rgba(24, 20, 17, .86));
}
.edit-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.edit-title {
  font-family: "KaiTi", "STKaiti", serif;
  font-size: 15px;
  letter-spacing: 2px;
  color: #f0d9a8;
}
.edit-name {
  flex: 1;
  min-width: 140px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #1c1814;
  color: var(--text);
  font-size: 12.5px;
}
.edit-palette { display: flex; flex-wrap: wrap; gap: 6px; }
.edit-piece {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: "KaiTi", "STKaiti", serif;
  font-size: 19px;
  cursor: pointer;
  border: 1px solid #9c7b48;
  background: #e7d8b8;
  color: #8c2b22;
  transition: transform .12s, outline-color .12s;
}
.edit-piece:hover { transform: translateY(-1px); }
.edit-piece.black { background: #d9cdb7; color: #241f19; }
.edit-piece.active { outline: 2px solid var(--gold); outline-offset: 2px; }
.edit-piece.erase {
  width: auto;
  padding: 0 13px;
  border-radius: 9px;
  background: #241e18;
  color: var(--muted);
  border-color: var(--line);
  font-family: inherit;
  font-size: 12.5px;
}
.edit-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.segmented.mini { display: inline-grid; grid-auto-flow: column; padding: 3px; }
.segmented.mini button { padding: 5px 14px; font-size: 12.5px; }

.confirm-msg {
  font-size: 13.5px;
  line-height: 1.7;
  color: #ded3bd;
  text-align: center;
  padding: 6px 0 2px;
}

.mini-field { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.mini-field select {
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #1c1814;
  color: var(--text);
  font-size: 12.5px;
}
.filebtn {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 8px 15px;
  border-radius: 9px;
  border: 1px dashed var(--gold-dim);
  background: rgba(201, 160, 92, .07);
  color: #eddcb6;
  cursor: pointer;
  font-size: 13px;
  transition: all .16s;
}
.filebtn:hover { background: rgba(201, 160, 92, .16); }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.filebtn.small { padding: 6px 12px; font-size: 12.5px; }

/* 存档列表 */
.lib-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.lib-list { display: flex; flex-direction: column; gap: 8px; }
.lib-empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 26px 0; }
.lib-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line-soft); border-radius: 10px;
  background: rgba(255, 255, 255, .02);
}
.lib-item:hover { border-color: var(--gold-dim); }
.lib-main { flex: 1; min-width: 0; }
.lib-title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.lib-title .res { font-weight: 600; }
.lib-title .res.red { color: var(--red-soft); }
.lib-title .res.black { color: #d9ceb8; }
.lib-title .res.draw { color: var(--muted); }
.lib-sub { margin-top: 3px; font-size: 11px; color: var(--muted); letter-spacing: .4px; }
.lib-acts { display: flex; gap: 6px; }

/* 提示条 */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 80;
  padding: 9px 18px; border-radius: 999px;
  background: rgba(30, 24, 18, .95);
  border: 1px solid var(--gold-dim);
  color: #f0dfbd; font-size: 12.5px; letter-spacing: .6px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .5);
  animation: rise .22s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 返回游戏中心 ---------- */
.home-btn {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--gold-dim);
  background: rgba(30, 24, 18, .92);
  color: #f0dfbd;
  text-decoration: none;
  font-size: 12.5px;
  letter-spacing: .5px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .45);
  backdrop-filter: blur(6px);
  transition: border-color .16s, color .16s;
}
.home-btn:hover { border-color: var(--gold); color: #fff2d6; }

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .side-col { flex-direction: row; flex-wrap: wrap; }
  .side-col .panel { flex: 1 1 320px; }
  .panel.grow { max-height: 300px; }
}

@media (max-width: 820px) {
  .board-holder.dual { flex-direction: column; }
  .board-holder.dual .board-wrap { width: 100%; }
}

@media (max-width: 640px) {
  .app { padding: 12px 12px 20px; gap: 12px; }
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .top-actions { justify-content: space-between; }
  .btn { padding: 8px 12px; }
  .brand-text h1 { font-size: 22px; letter-spacing: 3px; }
  .statusline { flex-wrap: wrap; gap: 8px; }
  .statusline .clock { margin-left: 0; }
  .side-col { flex-direction: column; }
  .over-stats { grid-template-columns: repeat(3, 1fr); }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
  .home-btn { left: 10px; bottom: 10px; padding: 7px 12px; font-size: 12px; }
}
