/* 弈境棋馆 · 视觉样式 */
:root {
  --ink: #12100d;
  --ink-2: #191510;
  --panel: #211c15;
  --panel-2: #2a241b;
  --ivory: #f5ecd9;
  --ivory-2: #e8dcc3;
  --paper: #f6eedd;
  --gold: #c8a15f;
  --gold-light: #e4c487;
  --gold-dim: rgba(200, 161, 95, 0.5);
  --red: #b93b2e;
  --red-dark: #8d2a20;
  --green: #7fa36b;
  --text: #eee4d1;
  --muted: #a1957f;
  --dim: #7c725f;
  --line: rgba(200, 161, 95, 0.18);
  --line-soft: rgba(200, 161, 95, 0.1);
  --font-serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", "Source Han Serif SC", serif;
  --font-kai: "ChessBrush", "STXingkai", "华文行楷", "Xingkai SC", "KaiTi", "楷体", "Kaiti SC", "STKaiti", "Noto Serif SC", serif;
  --font-sans: "Inter", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --radius: 18px;
}

@font-face {
  font-family: "ChessBrush";
  src: url("/fonts/xingkai-subset.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 700px at 78% -10%, rgba(176, 123, 56, 0.16), transparent 60%),
    radial-gradient(900px 600px at 0% 100%, rgba(120, 52, 34, 0.16), transparent 65%),
    var(--ink);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
input { outline: none; }
.hidden { display: none !important; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.screen { position: relative; z-index: 2; min-height: 100dvh; }

/* ---------------------------------------------------------------- 启动遮罩 */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--ink);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
.boot-screen.done { opacity: 0; visibility: hidden; }
.boot-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(150deg, var(--red), var(--red-dark));
  color: var(--ivory);
  font-family: var(--font-serif);
  font-size: 34px;
  box-shadow: 0 20px 50px rgba(185, 59, 46, 0.35);
  animation: bootPulse 1.6s ease-in-out infinite;
}
.boot-text { color: var(--muted); font-size: 13px; letter-spacing: 0.16em; }
@keyframes bootPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ---------------------------------------------------------------- 大厅 */
.landing {
  display: flex;
  flex-direction: column;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 56px);
}

.landing-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.deco-char {
  position: absolute;
  right: -3vw;
  top: -12vh;
  font-family: var(--font-serif);
  font-size: min(62vw, 780px);
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px rgba(200, 161, 95, 0.09);
  user-select: none;
}
.deco-ring {
  position: absolute;
  border: 1px solid rgba(200, 161, 95, 0.08);
  border-radius: 50%;
}
.deco-ring.r1 { width: 46vw; height: 46vw; right: -10vw; bottom: -18vw; }
.deco-ring.r2 { width: 26vw; height: 26vw; left: -8vw; top: 18vh; }

.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 8px;
  position: relative;
  z-index: 2;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-seal {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(150deg, var(--red), var(--red-dark));
  color: var(--ivory);
  font-family: var(--font-serif);
  font-size: 26px;
  box-shadow: 0 8px 24px rgba(185, 59, 46, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-family: var(--font-serif); font-size: 20px; letter-spacing: 0.14em; }
.brand-text small { font-size: 9px; letter-spacing: 0.28em; color: var(--dim); margin-top: 4px; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(32, 27, 20, 0.6);
  color: var(--gold-light);
  display: grid;
  place-items: center;
  font-size: 17px;
  transition: 0.2s ease;
}
.icon-btn:hover { border-color: var(--gold-dim); background: rgba(48, 40, 29, 0.8); }
.icon-btn.muted { color: var(--dim); opacity: 0.7; }

.landing-main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.78fr);
  gap: clamp(32px, 5vw, 80px);
  align-items: center;
  padding: clamp(24px, 5vh, 64px) 0;
  position: relative;
  z-index: 2;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 22px;
  font-size: 11px;
  letter-spacing: 0.32em;
  color: var(--gold);
  text-transform: uppercase;
}
.eyebrow span { width: 36px; height: 1px; background: var(--gold-dim); }

.hero h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(42px, 5.4vw, 76px);
  line-height: 1.2;
  letter-spacing: 0.06em;
  color: var(--ivory);
  text-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--gold-light), #f0d9a8 42%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.9;
  max-width: 480px;
}
.hero-points {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  list-style: none;
  padding: 0;
  margin: 40px 0 0;
  max-width: 560px;
}
.hero-points li {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hero-points b { font-family: var(--font-serif); font-size: 16px; font-weight: 600; color: var(--ivory-2); letter-spacing: 0.06em; }
.hero-points span { font-size: 12px; color: var(--dim); }

.lobby-card {
  position: relative;
  background: linear-gradient(158deg, #f8f0de 0%, #ecdfc4 58%, #e6d5b5 100%);
  color: #2b2218;
  border-radius: 26px;
  padding: 32px;
  box-shadow:
    0 40px 90px rgba(0, 0, 0, 0.5),
    0 2px 0 rgba(255, 255, 255, 0.5) inset,
    0 0 0 1px rgba(90, 60, 30, 0.12);
  max-width: 460px;
  width: 100%;
  justify-self: end;
}
.lobby-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(90, 60, 30, 0.12);
  border-radius: 19px;
  pointer-events: none;
}
.card-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 26px;
  letter-spacing: 0.12em;
  color: #2a2016;
  font-weight: 600;
}
.card-head p { margin: 6px 0 0; color: #7a674c; font-size: 12.5px; }

.game-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 22px 0 18px;
}
.game-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(76, 52, 26, 0.16);
  background: rgba(255, 250, 238, 0.55);
  text-align: left;
  transition: 0.18s ease;
  overflow: hidden;
}
.game-card:hover { background: rgba(255, 252, 243, 0.9); border-color: rgba(140, 98, 48, 0.4); }
.game-card.selected {
  background: #fffaf0;
  border-color: var(--red);
  box-shadow: 0 6px 20px rgba(120, 60, 40, 0.16), inset 0 0 0 1px rgba(185, 59, 46, 0.24);
}
.mini-board {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  overflow: hidden;
  flex: 0 0 54px;
  box-shadow: 0 2px 6px rgba(60, 35, 15, 0.22);
}
.mini-board svg { display: block; width: 100%; height: 100%; }
.game-card-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.game-card-text strong { font-family: var(--font-serif); font-size: 15px; letter-spacing: 0.06em; color: #2c2115; }
.game-card-text span { font-size: 10px; color: #8a7556; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: none;
  place-items: center;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-style: normal;
}
.game-card.selected .game-check { display: grid; }

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  margin-bottom: 14px;
  border-radius: 13px;
  background: rgba(120, 90, 55, 0.08);
  border: 1px solid rgba(76, 52, 26, 0.12);
}
.mode-btn {
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: 9px 6px;
  color: #7a674c;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  transition: 0.18s ease;
}
.mode-btn:hover { color: #2a2016; }
.mode-btn.selected {
  background: #fffaf0;
  color: #2a2016;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(90, 60, 30, 0.14);
}

.ai-level { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.ai-level-label { font-size: 11px; letter-spacing: 0.12em; color: #8a7556; }
.level-chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.level-chip {
  border: 1px solid rgba(76, 52, 26, 0.18);
  background: rgba(255, 252, 244, 0.65);
  border-radius: 9px;
  padding: 8px 2px;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: #6d5a42;
  transition: 0.18s ease;
}
.level-chip:hover { border-color: rgba(140, 98, 48, 0.45); background: #fffdf7; }
.level-chip.selected {
  background: linear-gradient(160deg, #b93b2e, #8d2a20);
  border-color: transparent;
  color: #fff4e4;
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(150, 44, 33, 0.28);
}
.level-hint { margin: 0; font-size: 10.5px; color: #a08a68; }
.ai-hint { margin-top: 12px; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field span { font-size: 11px; letter-spacing: 0.12em; color: #8a7556; }
.field input, .join-row input {
  width: 100%;
  border: 1px solid rgba(76, 52, 26, 0.2);
  background: rgba(255, 252, 244, 0.8);
  border-radius: 12px;
  padding: 12px 14px;
  color: #2b2117;
  transition: 0.18s ease;
}
.field input::placeholder, .join-row input::placeholder { color: #b09b7c; }
.field input:focus, .join-row input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(185, 59, 46, 0.12);
  background: #fffdf8;
}

.primary-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 15px 20px;
  border: none;
  border-radius: 13px;
  background: linear-gradient(160deg, #c04536, #972c21);
  color: #fff7e8;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  box-shadow: 0 14px 32px rgba(150, 44, 33, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: 0.2s ease;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 18px 38px rgba(150, 44, 33, 0.4); }
.primary-btn:active { transform: translateY(0); }
.primary-btn i { font-style: normal; transition: transform 0.2s ease; }
.primary-btn:hover i { transform: translateX(4px); }
.primary-btn:disabled { opacity: 0.6; transform: none; }

.or-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: #a08a68;
  font-size: 10.5px;
  letter-spacing: 0.1em;
}
.or-line::before, .or-line::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(76, 52, 26, 0.14);
}
.join-row { display: flex; gap: 8px; }
.join-row input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-weight: 600;
  font-size: 14px;
  padding-left: 16px;
}
.join-btn {
  border: 1px solid rgba(76, 52, 26, 0.26);
  background: rgba(255, 252, 244, 0.8);
  border-radius: 12px;
  padding: 0 20px;
  color: #3a2c1c;
  font-weight: 600;
  letter-spacing: 0.08em;
  transition: 0.18s ease;
}
.join-btn:hover { background: #fffdf8; border-color: var(--red); color: var(--red); }
.lobby-hint { margin: 14px 0 0; font-size: 10.5px; color: #a08a68; text-align: center; line-height: 1.7; }

.landing-footer {
  display: flex;
  justify-content: space-between;
  padding: 22px 0 28px;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.22em;
  border-top: 1px solid var(--line-soft);
  position: relative;
  z-index: 2;
}

/* ---------------------------------------------------------------- 对局页 */
.game-screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.game-top {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 clamp(12px, 3vw, 28px);
  background: rgba(18, 16, 13, 0.82);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
}
.ghost-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 12px;
  letter-spacing: 0.06em;
  transition: 0.18s ease;
  white-space: nowrap;
}
.ghost-btn:hover { color: var(--ivory); border-color: var(--gold-dim); background: rgba(200, 161, 95, 0.06); }

.room-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px 5px 14px;
  background: rgba(33, 28, 21, 0.9);
  border: 1px solid var(--line);
  border-radius: 999px;
  min-width: 0;
}
.game-tag {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--gold);
  white-space: nowrap;
}
.room-code {
  border: none;
  background: transparent;
  color: var(--ivory);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.2em;
  padding: 2px 4px;
  border-radius: 6px;
  transition: 0.18s ease;
}
.room-code:hover { color: var(--gold-light); background: rgba(200, 161, 95, 0.1); }
.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--green);
  padding: 4px 9px;
  background: rgba(127, 163, 107, 0.08);
  border-radius: 999px;
  white-space: nowrap;
}
.conn-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(127, 163, 107, 0.8); }
.conn-pill.offline { color: #d88a72; background: rgba(216, 138, 114, 0.1); }
.conn-pill.offline i { background: #d88a72; box-shadow: 0 0 8px rgba(216, 138, 114, 0.7); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
.top-actions { display: flex; align-items: center; gap: 8px; }

.game-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 348px;
  gap: clamp(16px, 2.4vw, 32px);
  align-items: start;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 32px) 34px;
}

.play-area {
  width: 100%;
  max-width: 600px;
  justify-self: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-radius: 13px;
  border: 1px solid var(--line-soft);
  background: rgba(33, 28, 21, 0.6);
  transition: 0.2s ease;
}
.player-bar.self { border-color: rgba(200, 161, 95, 0.28); background: rgba(40, 33, 24, 0.72); }
.player-bar.turn-active { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(200, 161, 95, 0.15), 0 8px 24px rgba(0, 0, 0, 0.25); }
.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 16px;
  background: rgba(200, 161, 95, 0.1);
  border: 1px solid var(--line);
  color: var(--gold-light);
}
.avatar.red { background: linear-gradient(150deg, #b93b2e, #8d2a20); color: #fff3e2; border-color: transparent; }
.avatar.black { background: linear-gradient(150deg, #35302a, #1c1914); color: #e9dfcb; border-color: rgba(200, 161, 95, 0.3); }
.avatar.white { background: linear-gradient(150deg, #f4ead4, #d8c7a2); color: #4a3a25; border-color: transparent; }
.avatar.guest { background: rgba(120, 110, 90, 0.12); color: var(--dim); }
.avatar.ai { font-family: var(--font-sans); font-size: 11px; letter-spacing: 0.02em; background: linear-gradient(150deg, #4a3b28, #2a2118); color: var(--gold-light); border-color: rgba(200, 161, 95, 0.35); }
.player-meta { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; flex: 1; }
.player-meta strong { font-family: var(--font-serif); font-size: 15px; letter-spacing: 0.04em; color: var(--ivory-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-meta span { font-size: 10.5px; color: var(--dim); letter-spacing: 0.03em; }
.color-chip {
  font-size: 10px;
  letter-spacing: 0.14em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.color-chip.red { color: #e4907f; border-color: rgba(228, 144, 127, 0.3); background: rgba(185, 59, 46, 0.1); }
.color-chip.black { color: #c9bca4; }
.color-chip.white { color: #f3e8d0; border-color: rgba(243, 232, 208, 0.28); background: rgba(243, 232, 208, 0.06); }

.board-frame {
  position: relative;
  border-radius: 14px;
  padding: clamp(5px, 1.2vw, 10px);
  background:
    linear-gradient(150deg, rgba(96, 68, 42, 0.55), rgba(42, 29, 18, 0.85) 42%, rgba(23, 17, 11, 0.95));
  box-shadow:
    0 40px 80px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(226, 194, 130, 0.3),
    inset 0 0 0 1px rgba(0, 0, 0, 0.6);
  container-type: inline-size;
}
.board {
  position: relative;
  width: 100%;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.board.chess { aspect-ratio: 1 / 1; }
.board.xiangqi { aspect-ratio: 10 / 11; background: #edddba; }

/* 国际象棋 */
.chess-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
}
.chess-square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.chess-square.light { background: linear-gradient(155deg, #f0e2c6, #e5d2ae); }
.chess-square.dark { background: linear-gradient(155deg, #8b6242, #6f4a30); }
.chess-square::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(60, 35, 15, 0.06);
}
.chess-square.last::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(230, 178, 76, 0.5);
  box-shadow:
    inset 0 0 0 2.5px rgba(244, 202, 112, 0.85),
    inset 0 0 14px rgba(226, 178, 82, 0.45);
  z-index: 1;
}
.chess-square.selected::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(72, 120, 90, 0.3);
  box-shadow: inset 0 0 0 3px rgba(110, 168, 128, 0.9);
  z-index: 1;
}
.chess-square.check {
  background: radial-gradient(circle, rgba(200, 40, 30, 0.85), rgba(150, 24, 18, 0.55) 62%, transparent 78%) !important;
  animation: squareCheckGlow 1.1s ease-in-out infinite;
}
@keyframes squareCheckGlow {
  0%, 100% { box-shadow: inset 0 0 8px rgba(255, 70, 45, 0.35); }
  50% { box-shadow: inset 0 0 24px rgba(255, 40, 20, 0.85); }
}
.chess-piece {
  position: relative;
  z-index: 2;
  font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2", serif;
  font-size: clamp(22px, 9.6cqw, 56px);
  line-height: 1;
  transform: translateY(-1%);
  transition: transform 0.12s ease;
  pointer-events: none;
}
.chess-square.legal:hover .chess-piece { transform: translateY(-5%) scale(1.03); }
.chess-piece.white-piece {
  color: #fdf6e6;
  -webkit-text-stroke: 0.9px rgba(58, 37, 20, 0.7);
  text-shadow:
    0 1px 0 rgba(68, 46, 26, 0.55),
    0 2px 4px rgba(35, 22, 10, 0.5);
}
.chess-piece.black-piece {
  color: #17130e;
  -webkit-text-stroke: 0.9px rgba(252, 244, 225, 0.65);
  text-shadow:
    0 1px 0 rgba(255, 250, 232, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.4);
}
.chess-square.last .chess-piece.just-moved { animation: piecePop 0.26s ease; }
@keyframes piecePop {
  0% { transform: scale(0.86); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.legal-dot {
  position: absolute;
  z-index: 1;
  width: 26%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(38, 82, 56, 0.45);
  box-shadow: 0 0 0 1px rgba(226, 240, 214, 0.2);
  pointer-events: none;
}
.legal-capture {
  position: absolute;
  z-index: 1;
  inset: 10%;
  border-radius: 50%;
  border: 3px solid rgba(38, 82, 56, 0.55);
  pointer-events: none;
}
.chess-square.legal { cursor: pointer; }

/* 中国象棋 */
.xq-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.xq-layer { position: absolute; inset: 0; }
.xq-river {
  font-family: var(--font-kai);
  font-size: 70px;
  font-weight: 600;
  letter-spacing: 26px;
  fill: #57341a;
  opacity: 0.95;
}
.xq-piece {
  position: absolute;
  width: 9.5%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-kai);
  font-weight: 600;
  font-size: 5.9cqw;
  line-height: 1;
  color: #a3261b;
  background: radial-gradient(circle at 34% 26%, #fffaf0 0%, #f6ead0 40%, #e3cda3 78%, #d3b788 100%);
  box-shadow:
    0 3px 6px rgba(62, 36, 14, 0.4),
    0 1px 2px rgba(62, 36, 14, 0.3),
    inset 0 0 0 1.5px rgba(255, 253, 245, 0.9),
    inset 0 0 0 3px rgba(146, 104, 55, 0.22),
    inset 0 0 0 4.5px rgba(255, 250, 235, 0.5),
    inset 0 0 0 5.5px rgba(146, 104, 55, 0.18);
  user-select: none;
  cursor: pointer;
  z-index: 3;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.xq-piece::before {
  content: "";
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  opacity: 0.4;
  pointer-events: none;
}
.xq-piece::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 6.5%, rgba(138, 98, 50, 0.55) 0 3.4%, transparent 4.3%),
    radial-gradient(circle at 50% 93.5%, rgba(138, 98, 50, 0.55) 0 3.4%, transparent 4.3%),
    radial-gradient(circle at 6.5% 50%, rgba(138, 98, 50, 0.55) 0 3.4%, transparent 4.3%),
    radial-gradient(circle at 93.5% 50%, rgba(138, 98, 50, 0.55) 0 3.4%, transparent 4.3%);
}
.xq-piece.black {
  color: #1d1912;
  background: radial-gradient(circle at 34% 26%, #fdf9ee 0%, #f0e7d2 40%, #dccbb0 78%, #cbb592 100%);
}
.xq-piece:hover { transform: translate(-50%, -50%) scale(1.04); }
.xq-piece.selected {
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow:
    0 8px 16px rgba(30, 15, 5, 0.45),
    0 0 0 3px rgba(200, 161, 95, 0.9),
    0 0 22px rgba(228, 196, 135, 0.55),
    inset 0 0 0 2px rgba(255, 253, 245, 0.8);
  z-index: 6;
}
.xq-piece.check {
  animation: checkPulse 1s ease-in-out infinite;
  color: #c32216;
}
@keyframes checkPulse {
  0%, 100% { box-shadow: 0 3px 6px rgba(62, 36, 14, 0.38), 0 0 0 2px rgba(200, 40, 30, 0.6), inset 0 0 0 2px rgba(255, 253, 245, 0.75); }
  50% { box-shadow: 0 3px 6px rgba(62, 36, 14, 0.38), 0 0 0 5px rgba(200, 40, 30, 0.25), 0 0 20px rgba(200, 40, 30, 0.55), inset 0 0 0 2px rgba(255, 253, 245, 0.75); }
}
.xq-piece.just-moved { animation: xqPop 0.28s ease; }
@keyframes xqPop {
  0% { transform: translate(-50%, -50%) scale(0.82); }
  65% { transform: translate(-50%, -50%) scale(1.04); }
  100% { transform: translate(-50%, -50%) scale(1); }
}
.xq-mark {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
}
.xq-mark.dot {
  width: 2.4%;
  aspect-ratio: 1;
  background: rgba(45, 90, 62, 0.75);
  box-shadow: 0 0 0 2px rgba(245, 236, 217, 0.55);
}
.xq-mark.ring {
  width: 8.6%;
  aspect-ratio: 1;
  border: 2px solid rgba(45, 90, 62, 0.75);
  box-shadow: 0 0 0 2px rgba(245, 236, 217, 0.35);
}
.xq-mark.last {
  width: 9.2%;
  aspect-ratio: 1;
  border: 1.5px dashed rgba(178, 108, 52, 0.75);
  box-shadow: 0 0 0 3px rgba(224, 179, 94, 0.18);
}
.xq-mark.sel {
  width: 10.2%;
  aspect-ratio: 1;
  border: 2px solid rgba(200, 161, 95, 0.75);
}
.xq-dot-hint { cursor: pointer; }
.xq-hit {
  position: absolute;
  width: 8.8%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 4;
  background: transparent;
  cursor: pointer;
}

/* 回合条 */
.turn-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 34px;
  padding: 4px 14px;
}
.turn-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 10px rgba(185, 59, 46, 0.7);
  transition: 0.2s ease;
}
.turn-dot.white { background: #f3e8d0; box-shadow: 0 0 10px rgba(243, 232, 208, 0.6); }
.turn-dot.black { background: #4b443a; box-shadow: 0 0 10px rgba(0, 0, 0, 0.6); }
.turn-label { font-size: 12px; letter-spacing: 0.1em; color: var(--muted); }
.check-label {
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: #f0a08e;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(185, 59, 46, 0.16);
  border: 1px solid rgba(185, 59, 46, 0.35);
  animation: checkBlink 1.2s ease-in-out infinite;
}
@keyframes checkBlink { 50% { opacity: 0.55; } }

/* 盘面遮罩 */
.board-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(16, 13, 10, 0.52);
  backdrop-filter: blur(3px);
  border-radius: 5px;
  animation: fadeIn 0.25s ease;
}
.board-overlay.pass-through { background: transparent; backdrop-filter: none; pointer-events: none; }
@keyframes fadeIn { from { opacity: 0; } }
.overlay-card {
  background: linear-gradient(160deg, #f8f0de, #eaddc0);
  color: #2a2117;
  border-radius: 18px;
  padding: 26px 28px;
  text-align: center;
  max-width: 340px;
  width: 100%;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  pointer-events: auto;
}
.overlay-eyebrow { font-size: 10px; letter-spacing: 0.26em; color: #9a8261; text-transform: uppercase; }
.overlay-title { font-family: var(--font-serif); font-size: 26px; letter-spacing: 0.12em; margin: 8px 0 4px; color: #2a2117; }
.overlay-desc { font-size: 12px; color: #7d694c; margin: 0 0 18px; line-height: 1.7; }
.wait-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 30px;
  letter-spacing: 0.28em;
  padding: 10px 0 8px;
  color: #9c3226;
  font-weight: 700;
}
.overlay-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.overlay-actions .ghost-btn { color: #6b573b; border-color: rgba(76, 52, 26, 0.25); }
.overlay-actions .ghost-btn:hover { color: #2a2117; border-color: #9c3226; background: rgba(155, 50, 38, 0.06); }
.result-seal {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
  font-family: var(--font-serif);
  font-size: 28px;
  color: #fff6e6;
  background: linear-gradient(150deg, #b93b2e, #8d2a20);
  box-shadow: 0 10px 26px rgba(150, 44, 33, 0.35);
}
.result-seal.draw { background: linear-gradient(150deg, #7f7565, #4d463a); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3); }
.result-seal.win { background: linear-gradient(150deg, #c8a15f, #8f6a2f); color: #2a2117; box-shadow: 0 10px 26px rgba(200, 161, 95, 0.35); }
.wait-spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(155, 50, 38, 0.18);
  border-top-color: #9c3226;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.wait-hint { font-size: 11px; color: #927a5a; margin-top: 12px; }
.wait-actions { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.wait-actions button {
  border: 1px solid rgba(76, 52, 26, 0.24);
  background: rgba(255, 252, 244, 0.7);
  border-radius: 9px;
  padding: 7px 13px;
  color: #4b3924;
  font-size: 11px;
}
.wait-actions button:hover { border-color: #9c3226; color: #9c3226; }

/* ---------------------------------------------------------------- 侧栏 */
.side-panel {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  height: min(660px, calc(100dvh - 110px));
  min-height: 420px;
  border-radius: var(--radius);
  border: 1px solid var(--line-soft);
  background:
    linear-gradient(180deg, rgba(37, 31, 23, 0.94), rgba(26, 22, 17, 0.96));
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.panel-actions {
  display: flex;
  gap: 8px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.danger-btn, .accent-btn {
  flex: 1;
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  transition: 0.18s ease;
}
.danger-btn {
  border: 1px solid rgba(185, 59, 46, 0.34);
  background: rgba(185, 59, 46, 0.08);
  color: #e79b8d;
}
.danger-btn:hover { background: rgba(185, 59, 46, 0.18); border-color: rgba(185, 59, 46, 0.6); }
.accent-btn {
  border: 1px solid rgba(200, 161, 95, 0.45);
  background: linear-gradient(160deg, rgba(200, 161, 95, 0.24), rgba(200, 161, 95, 0.1));
  color: var(--gold-light);
}
.accent-btn:hover { background: rgba(200, 161, 95, 0.3); }
.accent-btn.waiting { color: var(--muted); border-color: var(--line); background: rgba(255, 255, 255, 0.02); }
.danger-btn:disabled, .accent-btn:disabled, .ghost-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.accent-btn:disabled:hover { background: rgba(200, 161, 95, 0.12); }

.tabs { display: flex; border-bottom: 1px solid var(--line-soft); }
.tab {
  flex: 1;
  position: relative;
  border: none;
  background: transparent;
  padding: 13px 0 11px;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.16em;
  transition: 0.18s ease;
}
.tab:hover { color: var(--muted); }
.tab.active { color: var(--gold-light); }
.tab.active::after {
  content: "";
  position: absolute;
  left: 26%;
  right: 26%;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.chat-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--red);
  vertical-align: 2px;
  box-shadow: 0 0 8px rgba(185, 59, 46, 0.8);
}

.pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
.move-list {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 10px 12px 24px;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(200, 161, 95, 0.25) transparent;
}
.move-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.move-row:nth-child(odd) { background: rgba(255, 255, 255, 0.014); }
.move-row.latest { background: rgba(200, 161, 95, 0.09); box-shadow: inset 0 0 0 1px rgba(200, 161, 95, 0.13); }
.move-no { font-size: 10px; color: var(--dim); font-family: ui-monospace, Consolas, monospace; }
.move-cell {
  font-family: var(--font-serif);
  font-size: 14px;
  letter-spacing: 0.05em;
  color: var(--ivory-2);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.move-cell.empty { color: rgba(255, 255, 255, 0.12); }
.move-dot { width: 5px; height: 5px; border-radius: 50%; flex: 0 0 auto; }
.move-dot.r, .move-dot.w { background: #e6d8ba; }
.move-dot.b { background: #6d6352; }
.move-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  font-size: 11.5px;
  color: var(--dim);
  line-height: 1.8;
  pointer-events: none;
}
.move-empty.hidden { display: none; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(200, 161, 95, 0.25) transparent;
}
.chat-item { display: flex; flex-direction: column; gap: 3px; max-width: 100%; }
.chat-name { font-size: 10px; letter-spacing: 0.06em; color: var(--dim); }
.chat-name.red { color: #de8f7f; }
.chat-name.white { color: #ede0c4; }
.chat-text {
  align-self: flex-start;
  max-width: 92%;
  padding: 9px 12px;
  border-radius: 4px 12px 12px 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.035);
  font-size: 13px;
  color: var(--text);
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-item.mine .chat-text {
  background: rgba(200, 161, 95, 0.12);
  border-color: rgba(200, 161, 95, 0.18);
}
.chat-item.system {
  align-items: center;
  text-align: center;
  padding: 2px 0;
}
.chat-item.system .chat-text {
  background: transparent;
  border: none;
  color: var(--dim);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  max-width: 100%;
}
.chat-form {
  display: flex;
  gap: 7px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line-soft);
  background: rgba(15, 12, 9, 0.25);
}
.chat-form input {
  flex: 1;
  min-width: 0;
  border-radius: 9px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.035);
  padding: 10px 12px;
  color: var(--text);
  font-size: 12.5px;
}
.chat-form input::placeholder { color: var(--dim); }
.chat-form input:focus { border-color: var(--gold-dim); background: rgba(255, 255, 255, 0.05); }
.chat-form button {
  border: 1px solid rgba(200, 161, 95, 0.35);
  background: rgba(200, 161, 95, 0.12);
  color: var(--gold-light);
  border-radius: 9px;
  padding: 0 15px;
  font-size: 12px;
  letter-spacing: 0.05em;
}
.chat-form button:hover { background: rgba(200, 161, 95, 0.22); }

/* ---------------------------------------------------------------- 弹窗 / 提示 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 8, 6, 0.66);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
}
.modal-card {
  background: var(--paper);
  color: #2b2218;
  border-radius: 20px;
  padding: 26px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  animation: modalIn 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes modalIn { from { transform: translateY(12px) scale(0.96); opacity: 0; } }
.modal-card h3 {
  font-family: var(--font-serif);
  font-size: 20px;
  letter-spacing: 0.1em;
  margin: 0 0 8px;
  font-weight: 600;
}
.modal-card p { margin: 0; color: #7d694c; font-size: 13px; line-height: 1.8; }
.promotion-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 20px;
}
.promo-btn {
  border: 1px solid rgba(76, 52, 26, 0.18);
  background: #fffaf0;
  border-radius: 12px;
  padding: 10px 4px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: 0.16s ease;
}
.promo-btn span:first-child {
  font-family: "Segoe UI Symbol", "Apple Symbols", serif;
  font-size: 34px;
  line-height: 1;
  color: #2b2218;
}
.promo-btn span:last-child { font-size: 10px; color: #8a7556; letter-spacing: 0.08em; }
.promo-btn:hover { border-color: var(--red); color: var(--red); transform: translateY(-2px); background: #fffdf8; }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; }
.modal-actions button { flex: 1; padding: 10px; }
.modal-actions .ghost-btn { color: #6b573b; border-color: rgba(76, 52, 26, 0.25); }
.modal-actions .ghost-btn:hover { color: #2a2117; border-color: #9c3226; }

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}
.toast {
  background: rgba(34, 28, 20, 0.96);
  border: 1px solid rgba(200, 161, 95, 0.3);
  color: var(--ivory-2);
  border-radius: 999px;
  padding: 9px 20px;
  font-size: 12px;
  letter-spacing: 0.04em;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  animation: toastIn 0.25s ease;
}
.toast.error { border-color: rgba(185, 59, 46, 0.5); color: #f0b3a6; }
.toast.fade { opacity: 0; transform: translateY(6px); transition: 0.3s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* 桌面端按视口高度收缩棋盘，尽量让整盘与双方棋手栏一屏可见 */
@media (min-width: 1081px) {
  .play-area:has(.board.xiangqi) {
    max-width: clamp(320px, calc((100dvh - 315px) * 0.9), 600px);
  }
  .play-area:has(.board.chess) {
    max-width: clamp(320px, calc(100dvh - 315px), 600px);
  }
}

/* ---------------------------------------------------------------- 响应式 */
@media (max-width: 1080px) {
  .landing-main { grid-template-columns: 1fr; gap: 40px; }
  .lobby-card { justify-self: start; max-width: 520px; }
  .hero h1 { font-size: clamp(40px, 7vw, 60px); }
  .game-layout { grid-template-columns: 1fr; max-width: 680px; }
  .side-panel { position: static; height: auto; min-height: 0; }
  .pane { height: 300px; flex: none; }
  .pane#pane-chat { height: 330px; }
  .play-area { max-width: 580px; }
}

@media (max-width: 720px) {
  .landing { padding: 0 18px; }
  .landing-header { padding-top: 18px; }
  .brand-text strong { font-size: 17px; }
  .brand-seal { width: 40px; height: 40px; font-size: 22px; }
  .landing-main { padding: 28px 0 40px; gap: 32px; }
  .hero h1 { font-size: clamp(36px, 10vw, 48px); line-height: 1.25; }
  .hero-sub { font-size: 13.5px; margin-top: 16px; }
  .hero-points { gap: 10px; margin-top: 26px; }
  .hero-points b { font-size: 13.5px; }
  .hero-points span { font-size: 10.5px; }
  .lobby-card { padding: 24px 20px; border-radius: 22px; max-width: 100%; }
  .game-picker { grid-template-columns: 1fr; }
  .landing-footer { font-size: 9px; padding: 16px 0 22px; }
  .deco-char { font-size: 100vw; opacity: 0.6; }

  .game-top { height: 56px; gap: 8px; padding: 0 10px; }
  .game-tag { display: none; }
  .room-pill { padding-left: 10px; gap: 6px; }
  .room-code { font-size: 12px; }
  .conn-pill span { display: none; }
  .conn-pill { padding: 4px 7px; }
  #copy-link-btn { padding: 7px 10px; font-size: 11px; }
  .top-actions .icon-btn { width: 34px; height: 34px; }
  #back-btn { padding: 7px 10px; font-size: 11px; }
  .game-layout { padding: 12px 10px 24px; gap: 14px; }
  .player-bar { padding: 7px 10px; border-radius: 11px; }
  .avatar { width: 30px; height: 30px; flex-basis: 30px; font-size: 14px; border-radius: 8px; }
  .player-meta strong { font-size: 13.5px; }
  .player-meta span { font-size: 10px; }
  .board-frame { padding: 5px; border-radius: 10px; }
  .xq-piece { font-size: 5.1cqw; }
  .pane { height: 260px; }
  .pane#pane-chat { height: 300px; }
  .overlay-card { padding: 20px 18px; max-width: 300px; }
  .overlay-title { font-size: 22px; }
  .wait-code { font-size: 26px; }
  .toast-stack { bottom: 16px; }
}

@media (max-width: 400px) {
  .game-picker { grid-template-columns: 1fr; }
  .hero-points { grid-template-columns: 1fr; gap: 0; }
  .hero-points li { flex-direction: row; align-items: baseline; gap: 8px; padding: 8px 0; }
  .hero-points li + li { border-top: 1px solid var(--line-soft); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------------- 自定义棋局 */
.mode-switch { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mode-btn { font-size: 12px; padding: 9px 3px; letter-spacing: 0.06em; }

.setup-mode .player-bar,
.setup-mode .turn-bar { display: none; }
.setup-mode .side-panel { height: auto; min-height: 0; max-height: calc(100dvh - 110px); }

.setup-tools {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  overflow-y: auto;
}
.setup-head { display: flex; flex-direction: column; gap: 5px; }
.setup-head strong {
  font-family: var(--font-kai);
  font-size: 18px;
  letter-spacing: 0.16em;
  color: var(--gold-light);
}
.setup-head span { font-size: 11px; line-height: 1.6; color: var(--dim); }

.piece-palette { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.palette-piece {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(200, 161, 95, 0.32);
  background: radial-gradient(circle at 35% 28%, #fdf4e1, #ddc9a7 72%, #bda27c);
  color: #a3261b;
  font-family: var(--font-kai);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  box-shadow: inset 0 -2px 3px rgba(90, 60, 30, 0.28), 0 2px 5px rgba(0, 0, 0, 0.35);
  transition: 0.16s ease;
}
.palette-piece.black { color: #241d16; }
.palette-piece:hover { transform: translateY(-1px); border-color: var(--gold-dim); }
.palette-piece.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(226, 178, 82, 0.6), 0 7px 16px rgba(0, 0, 0, 0.45);
  transform: translateY(-1px);
}
.palette-chess {
  border-radius: 8px;
  border-color: rgba(200, 161, 95, 0.22);
  background: linear-gradient(160deg, #6a5540, #40301f);
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", serif;
  font-size: 18px;
}
.palette-chess.white-piece { color: #faf2df; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.65), 0 2px 3px rgba(0, 0, 0, 0.5); }
.palette-chess.black-piece {
  color: #17120d;
  background: linear-gradient(160deg, #d6c2a0, #a68d68);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.setup-row { display: flex; align-items: center; gap: 10px; }
.setup-label { flex: 0 0 30px; font-size: 11px; letter-spacing: 0.1em; color: var(--dim); }
.setup-seg { display: flex; flex: 1; gap: 6px; }
.setup-seg button {
  flex: 1;
  padding: 9px 0;
  border-radius: 9px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
  transition: 0.16s ease;
}
.setup-seg button.selected {
  border-color: transparent;
  background: linear-gradient(160deg, #d8b06a, #b98a44);
  color: #241a10;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(180, 130, 60, 0.32);
}
.setup-note {
  margin: 0;
  padding-top: 2px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--dim);
}
.setup-actions { display: flex; gap: 8px; margin-top: auto; }
.setup-actions .ghost-btn { flex: 1; }
.setup-actions .accent-btn { flex: 1.4; }

/* ---------------------------------------------------------------- 走子悬浮动效 */
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.move-ghost {
  position: absolute;
  z-index: 8;
  display: grid;
  place-items: center;
  pointer-events: none;
  will-change: transform, filter;
  filter: drop-shadow(0 12px 9px rgba(28, 16, 6, 0.38));
}
.move-ghost > .xq-piece {
  position: static;
  width: 100%;
  height: 100%;
  transform: none;
  transition: none;
  animation: none;
  cursor: default;
}
.move-ghost > .chess-piece {
  position: static;
  transform: none;
  transition: none;
}
.move-ghost.victim {
  z-index: 6;
}

/* ---------------------------------------------------------------- 将军 / 绝杀 水墨字 */
@font-face {
  font-family: 'YijingFraktur';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/unifrakturcook.woff2') format('woff2');
}
@font-face {
  font-family: 'YijingBrush';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/zhimangxing-0.woff2') format('woff2');
  unicode-range: U+26, U+3c, U+d7, U+4e4e, U+4e61, U+4e71, U+4ebf, U+4f26, U+5012, U+51ac, U+51b0, U+51b2, U+51b7, U+5218, U+521a, U+5220, U+5237, U+523b, U+526f, U+5385, U+53bf, U+53e5, U+53eb, U+53f3, U+53f6, U+5409, U+5438, U+54c8, U+54e5, U+552f, U+5584, U+5706, U+5723, U+5750, U+575a, U+5987-5988, U+59b9, U+59d0, U+59d4, U+5b88, U+5b9c, U+5bdf, U+5bfb, U+5c01, U+5c04, U+5c3e, U+5c4b, U+5c4f, U+5c9b, U+5cf0, U+5ddd, U+5de6, U+5de8, U+5e01, U+5e78, U+5e7b, U+5e9c, U+5ead, U+5ef6, U+5f39, U+5fd8, U+6000, U+6025, U+604b, U+6076, U+613f, U+6258, U+6263, U+6267, U+6298, U+62a2, U+62e5, U+62ec, U+6311, U+6377, U+6388-6389, U+63a2, U+63d2, U+641e, U+642d, U+654f, U+6551, U+6597, U+65cf, U+65d7, U+65e7, U+6682, U+66f2, U+671d, U+672b, U+6740, U+6751, U+6768, U+6811, U+6863, U+6982, U+6bd2, U+6cf0, U+6d0b, U+6d17, U+6d59, U+6dd8, U+6dfb, U+6e7e, U+6f6e, U+6fb3, U+706f, U+719f, U+72af, U+72d0, U+72d7, U+732b, U+732e, U+7389, U+73e0, U+7530, U+7687, U+76d6, U+76db, U+7840, U+786c, U+79cb, U+79d2, U+7a0e, U+7a33, U+7a3f, U+7a97, U+7ade-7adf, U+7b26, U+7e41, U+7ec3, U+7f3a, U+8089, U+80dc, U+811a, U+8131, U+8138, U+821e, U+8349, U+83dc, U+8457, U+867d, U+86cb, U+8a89, U+8ba8, U+8bad, U+8bef, U+8bfe, U+8c6a, U+8d1d, U+8d4f, U+8d62, U+8dd1, U+8df3, U+8f6e, U+8ff9, U+900f, U+9014, U+9057, U+9192, U+91ce, U+9488, U+94a2, U+9547, U+955c, U+95f2, U+9644, U+964d, U+96c4-96c5, U+96e8, U+96f6-96f7, U+9732, U+9759, U+9760, U+987a, U+989c, U+9910, U+996d-996e, U+9b54, U+9e21, U+9ebb, U+9f50;
}
@font-face {
  font-family: 'YijingBrush';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/zhimangxing-1.woff2') format('woff2');
  unicode-range: U+25, U+4e14, U+4e1d, U+4e3d, U+4e49, U+4e60, U+4e9a, U+4eb2, U+4ec5, U+4efd, U+4f3c, U+4f4f, U+4f8b, U+4fbf, U+5019, U+5145, U+514b, U+516b, U+516d, U+5174, U+5178, U+517b, U+5199, U+519b, U+51b3, U+51b5, U+5207, U+5212, U+5219, U+521d, U+52bf, U+533b, U+5343, U+5347, U+534a, U+536b, U+5370, U+53e4, U+53f2, U+5403, U+542c, U+547d, U+54a8, U+54cd, U+54ea, U+552e, U+56f4, U+5747, U+575b, U+5883, U+589e, U+5931, U+5947, U+5956-5957, U+5a92, U+5b83, U+5ba4, U+5bb3, U+5bcc, U+5c14, U+5c1a, U+5c3d, U+5c40, U+5c45, U+5c5e, U+5df4, U+5e72, U+5e95, U+5f80, U+5f85, U+5fb7, U+5fd7, U+601d, U+626b, U+627f, U+62c9, U+62cd, U+6309, U+63a7, U+6545, U+65ad, U+65af, U+65c5, U+666e, U+667a, U+670b, U+671b, U+674e, U+677f, U+6781, U+6790, U+6797, U+6821, U+6838-6839, U+697c, U+6b27, U+6b62, U+6bb5, U+6c7d, U+6c99, U+6d4b, U+6d4e, U+6d6a, U+6e29, U+6e2f, U+6ee1, U+6f14, U+6f2b, U+72b6, U+72ec, U+7387, U+7533, U+753b, U+76ca, U+76d8, U+7701, U+773c, U+77ed, U+77f3, U+7814, U+793c, U+79bb, U+79c1, U+79d8, U+79ef, U+79fb, U+7a76, U+7b11, U+7b54, U+7b56, U+7b97, U+7bc7, U+7c73, U+7d20, U+7eaa, U+7ec8, U+7edd, U+7eed, U+7efc, U+7fa4, U+804c, U+8058, U+80cc, U+8111, U+817e, U+826f, U+8303, U+843d, U+89c9, U+89d2, U+8ba2, U+8bbf, U+8bc9, U+8bcd, U+8be6, U+8c22, U+8c61, U+8d22, U+8d26-8d27, U+8d8a, U+8f6f, U+8f7b, U+8f83, U+8f91, U+8fb9, U+8fd4, U+8fdc, U+9002, U+94b1, U+9519, U+95ed, U+961f, U+9632-9633, U+963f, U+968f-9690, U+96be, U+9876, U+9884, U+98de, U+9988, U+9999, U+9ec4, U+ff1b;
}
@font-face {
  font-family: 'YijingBrush';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/zhimangxing-2.woff2') format('woff2');
  unicode-range: U+4e, U+201c-201d, U+3010-3011, U+4e07, U+4e1c, U+4e24, U+4e3e, U+4e48, U+4e50, U+4e5f, U+4e8b-4e8c, U+4ea4, U+4eab-4eac, U+4ecb, U+4ece, U+4ed6, U+4ee3, U+4ef6-4ef7, U+4efb, U+4f20, U+4f55, U+4f7f, U+4fdd, U+505a, U+5143, U+5149, U+514d, U+5171, U+5177, U+518c, U+51fb, U+521b, U+5229, U+522b, U+52a9, U+5305, U+5317, U+534e, U+5355, U+5357, U+535a, U+5373, U+539f, U+53bb, U+53ca, U+53cd, U+53d6, U+53e3, U+53f0, U+5458, U+5546, U+56db, U+573a, U+578b, U+57ce, U+58f0, U+590d, U+5934, U+5973, U+5b57, U+5b8c, U+5b98, U+5bb9, U+5bfc, U+5c06, U+5c11, U+5c31, U+5c55, U+5df2, U+5e03, U+5e38, U+5e76, U+5e94, U+5efa, U+5f71, U+5f97, U+5feb, U+6001, U+603b, U+60f3, U+611f, U+6216, U+624d, U+6253, U+6295, U+6301, U+6392, U+641c, U+652f, U+653e, U+6559, U+6599, U+661f, U+671f, U+672f, U+6761, U+67e5, U+6807, U+6837, U+683c, U+6848, U+6b22, U+6b64, U+6bd4, U+6c14, U+6c34, U+6c42, U+6ca1, U+6d41, U+6d77, U+6d88, U+6e05, U+6e38, U+6e90, U+7136, U+7231, U+7531, U+767e, U+76ee, U+76f4, U+771f, U+7801, U+793a, U+79cd, U+7a0b, U+7a7a, U+7acb, U+7ae0, U+7b2c, U+7b80, U+7ba1, U+7cbe, U+7d22, U+7ea7, U+7ed3, U+7ed9, U+7edf, U+7f16, U+7f6e, U+8001, U+800c, U+8272, U+8282, U+82b1, U+8350, U+88ab, U+88c5, U+897f, U+89c1, U+89c4, U+89e3, U+8a00, U+8ba1, U+8ba4, U+8bae-8bb0, U+8bbe, U+8bc1, U+8bc4, U+8bfb, U+8d28, U+8d39, U+8d77, U+8d85, U+8def, U+8eab, U+8f66, U+8f6c, U+8f7d, U+8fd0, U+9009, U+90ae, U+90fd, U+91cc-91cd, U+91cf, U+95fb, U+9650, U+96c6, U+9891, U+98ce, U+ff1f;
}

.calligraphy-flash {
  position: fixed;
  inset: 0;
  z-index: 58;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.calligraphy-flash.show { opacity: 1; }

.calligraphy-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, 0.45vw, 10px);
  font-family: "YijingBrush", "STXingkai", "华文行楷", "Xingkai SC", "KaiTi", "楷体", "STKaiti", var(--font-serif);
  font-size: clamp(68px, 9.6vw, 228px);
  font-weight: 600;
  line-height: 1;
  transform: translateY(-2%);
}

.ink-wash {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  width: 182%;
  height: 148%;
  transform: translate(-50%, -50%) rotate(-3deg);
  border-radius: 48% 52% 46% 54% / 55% 48% 52% 45%;
  background:
    radial-gradient(ellipse at 48% 50%, rgba(10, 6, 4, 0.97) 0%, rgba(14, 9, 6, 0.9) 30%, rgba(22, 14, 8, 0.52) 56%, transparent 74%),
    radial-gradient(circle at 68% 34%, rgba(12, 8, 5, 0.55) 0%, transparent 38%);
  filter: blur(3px);
  opacity: 0;
}
.calligraphy-flash.show .ink-wash {
  animation: washIn 0.85s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
@keyframes washIn {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-3deg) scale(0.68); }
  55% { opacity: 1; }
  100% { opacity: 0.96; transform: translate(-50%, -50%) rotate(-3deg) scale(1); }
}

.ink-slash {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  width: 232%;
  height: 12%;
  transform: translate(-50%, -50%) rotate(-17deg) scaleX(0);
  transform-origin: 50% 50%;
  border-radius: 50%;
  background: linear-gradient(90deg, transparent 2%, rgba(139, 28, 20, 0.9) 16%, #6d1410 46%, rgba(178, 42, 26, 0.95) 78%, transparent 98%);
  filter: url(#brush-edge-soft) blur(0.4px);
  opacity: 0;
}
.calligraphy-flash.show .ink-slash {
  animation: slashDraw 0.6s cubic-bezier(0.2, 0.7, 0.25, 1) 0.24s both;
}
@keyframes slashDraw {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-17deg) scaleX(0); }
  55% { opacity: 0.92; }
  100% { opacity: 0.78; transform: translate(-50%, -50%) rotate(-17deg) scaleX(1); }
}

.ink-deco {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  width: 190%;
  height: 152%;
  transform: translate(-50%, -50%) rotate(-2deg);
  opacity: 0;
}
.calligraphy-flash.show .ink-deco {
  animation: inkSpread 1s ease-out 0.06s both;
}
@keyframes inkSpread {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.84) rotate(-2deg); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
}

.ink-char {
  position: relative;
  z-index: 1;
  display: inline-block;
  filter: url(#brush-edge) drop-shadow(0 0 6px rgba(8, 5, 3, 0.45));
  will-change: transform, opacity, clip-path;
}
.ink-glyph {
  display: inline-block;
  background-image: linear-gradient(172deg, #fffbe6 0%, #ffeaa4 18%, #ffd263 40%, #eab043 62%, #cc8c26 82%, #9c651a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  opacity: 0;
}
.ink-char:nth-child(4) .ink-glyph { --tilt: -6deg; --dy: -7%; font-size: 1.05em; }
.ink-char:nth-child(5) .ink-glyph { --tilt: 4.5deg; --dy: 8%; font-size: 0.92em; }

.calligraphy-flash.show .ink-glyph {
  animation: inkWrite 1.05s cubic-bezier(0.22, 0.85, 0.24, 1) both;
}
.calligraphy-flash.show .ink-char:nth-child(5) .ink-glyph {
  animation-delay: 0.17s;
}
@keyframes inkWrite {
  0% {
    opacity: 0;
    clip-path: inset(0 100% 0 0);
    transform: translateY(calc(var(--dy, 0%) + 13%)) rotate(var(--tilt, 0deg)) scale(1.3);
  }
  32% { opacity: 1; clip-path: inset(0 34% 0 0); }
  68% {
    opacity: 1;
    clip-path: inset(0 -3% 0 0);
    transform: translateY(var(--dy, 0%)) rotate(var(--tilt, 0deg)) scale(0.97);
  }
  84% { transform: translateY(calc(var(--dy, 0%) - 2.5%)) rotate(var(--tilt, 0deg)) scale(1.02); }
  100% {
    opacity: 1;
    clip-path: inset(0 -6% 0 0);
    transform: translateY(var(--dy, 0%)) rotate(var(--tilt, 0deg)) scale(1);
  }
}

.ink-seal {
  position: relative;
  z-index: 1;
  align-self: flex-end;
  margin-left: clamp(6px, 1vw, 20px);
  margin-bottom: clamp(4px, 1.2vw, 18px);
  width: clamp(22px, 2.1vw, 42px);
  height: clamp(22px, 2.1vw, 42px);
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: clamp(12px, 1.2vw, 24px);
  line-height: 1;
  color: rgba(255, 244, 224, 0.95);
  background: #a3261b;
  border-radius: 3px;
  box-shadow: 0 3px 8px rgba(90, 20, 12, 0.35);
  opacity: 0;
}
.calligraphy-flash.show .ink-seal {
  animation: sealStamp 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.35) 0.74s both;
}
@keyframes sealStamp {
  from { opacity: 0; transform: rotate(12deg) scale(1.55); }
  to { opacity: 0.92; transform: rotate(6deg) scale(1); }
}

.calligraphy-flash.mate .ink-glyph {
  background-image: linear-gradient(172deg, #fff6cf 0%, #ffd98b 24%, #f0b04f 46%, #cf8430 68%, #9f3a18 100%);
}
.calligraphy-flash.mate .ink-wash {
  background:
    radial-gradient(ellipse at 50% 50%, rgba(10, 6, 4, 0.97) 0%, rgba(16, 8, 6, 0.92) 28%, rgba(96, 18, 13, 0.62) 54%, transparent 74%),
    radial-gradient(circle at 68% 34%, rgba(12, 8, 5, 0.6) 0%, transparent 38%);
}
.calligraphy-flash.mate .ink-slash { height: 16%; width: 248%; }

/* 国际象棋：中世纪花体英文 */
.calligraphy-flash.english .calligraphy-stage {
  font-family: 'YijingFraktur', 'Old English Text MT', 'UnifrakturCook', 'Engravers Old English', serif;
  font-size: clamp(44px, 6.4vw, 150px);
  font-weight: 700;
  letter-spacing: 0.03em;
  gap: 0.04em;
}
.calligraphy-flash.english .ink-char {
  filter: url(#brush-edge-soft) drop-shadow(0 0 10px rgba(8, 5, 3, 0.5));
}
.calligraphy-flash.english .ink-char:nth-child(4) .ink-glyph {
  --tilt: -2.5deg;
  --dy: 0%;
  font-size: 1em;
}
.calligraphy-flash.english .ink-char:nth-child(5) { display: none; }
.calligraphy-flash.english .ink-seal { display: none; }
.calligraphy-flash.english .ink-glyph {
  white-space: nowrap;
  background-image: linear-gradient(172deg, #fffbe6 0%, #ffeaa4 18%, #ffd263 40%, #eab043 62%, #cc8c26 82%, #9c651a 100%);
}

/* ---------------------------------------------------------------- 将军标记 */
.xq-piece.checking {
  animation: checkPulse 1s ease-in-out infinite;
  color: #c32216;
  z-index: 5;
}
.xq-piece.check,
.xq-piece.checking {
  filter: drop-shadow(0 0 7px rgba(222, 40, 24, 0.8));
}
.chess-piece.checking {
  animation: chessCheckFlash 1s ease-in-out infinite;
  color: #e03a24;
}
.chess-square.check .chess-piece {
  animation: chessCheckFlash 1s ease-in-out infinite;
}
@keyframes chessCheckFlash {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(222, 40, 24, 0.45)); }
  50% { filter: drop-shadow(0 0 11px rgba(240, 60, 35, 0.95)); }
}

/* ---------------------------------------------------------------- 侧栏结算 */
.result-panel {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(200, 161, 95, 0.34);
  background:
    radial-gradient(120% 90% at 30% 0%, rgba(200, 161, 95, 0.14), transparent 62%),
    rgba(255, 255, 255, 0.03);
  animation: resultIn 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
@keyframes resultIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.result-head { display: flex; align-items: center; gap: 12px; }
.result-panel .result-seal {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  margin: 0;
  font-size: 22px;
  border-radius: 50%;
}
.result-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.result-eyebrow { font-size: 10px; letter-spacing: 0.14em; color: var(--dim); }
.result-title { font-family: var(--font-kai); font-size: 19px; letter-spacing: 0.1em; color: var(--gold-light); }
.result-desc { margin: 0; font-size: 11.5px; line-height: 1.55; color: var(--muted); }
.result-actions { display: flex; gap: 8px; margin-top: 12px; }
.result-actions .accent-btn { flex: 1.3; }
.result-actions .ghost-btn { flex: 1; }
.result-hint { margin: 9px 0 0; font-size: 10.5px; color: var(--dim); }



.panel-actions .ghost-btn { flex: 1; padding: 9px 4px; font-size: 12px; }

@media (max-width: 760px) {
  .setup-tools { padding: 12px; gap: 10px; }
  .piece-palette { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
  .palette-piece { font-size: 16px; }
  .palette-chess { font-size: 19px; }
}

