/* ============================================================
   弈 · 双人棋室
   ============================================================ */
:root {
  --bg: #0a0e13;
  --bg-soft: #111820;
  --panel: rgba(20, 27, 36, .78);
  --panel-solid: #141b24;
  --line: rgba(232, 227, 216, .1);
  --line-strong: rgba(232, 227, 216, .18);
  --text: #ece7dc;
  --muted: #98a2ad;
  --faint: #6b7683;
  --gold: #d8b46a;
  --gold-strong: #f2d391;
  --gold-dim: rgba(216, 180, 106, .35);
  --red: #c94a40;
  --green: #6fbf8f;
  --danger: #e2705f;
  --radius: 18px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, .8);
  --serif: "Noto Serif SC", "Songti SC", "STSong", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  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: 52px 52px;
  -webkit-mask-image: radial-gradient(circle at 50% 24%, #000 0%, transparent 78%);
  mask-image: radial-gradient(circle at 50% 24%, #000 0%, transparent 78%);
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(58% 46% at 50% -8%, rgba(205, 154, 74, .15), transparent 72%),
    radial-gradient(42% 42% at 92% 78%, rgba(48, 102, 128, .16), transparent 72%),
    radial-gradient(46% 46% at 4% 62%, rgba(128, 55, 42, .1), transparent 72%);
}

.screen {
  position: relative;
  z-index: 1;
  animation: fade-in .5s ease both;
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================ 大厅 */
.lobby {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(20px, 6vh, 64px) 20px;
}
.lobby-inner {
  width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.brand { text-align: center; margin-bottom: 34px; }
.brand-seal {
  width: 74px;
  height: 74px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 700;
  color: #f6e7cf;
  background: linear-gradient(150deg, #b7382f, #8f2620 62%, #741c18);
  border-radius: 14px;
  transform: rotate(-3deg);
  box-shadow:
    0 16px 34px -10px rgba(160, 40, 30, .65),
    inset 0 1px 0 rgba(255, 255, 255, .28),
    inset 0 -6px 14px rgba(60, 0, 0, .35);
  position: relative;
}
.brand-seal::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1.5px solid rgba(255, 226, 196, .38);
  border-radius: 10px;
}
.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(34px, 8vw, 46px);
  letter-spacing: .12em;
  font-weight: 700;
  background: linear-gradient(180deg, #f7ead1, #d8b46a 78%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .22em;
}

.game-grid {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.game-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 16px 18px;
  text-align: left;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .012)),
    rgba(17, 24, 32, .72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform .22s cubic-bezier(.2, .7, .3, 1), border-color .22s,
    background .22s, box-shadow .22s;
  overflow: hidden;
}
.game-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120px 80px at 8% 20%, rgba(216, 180, 106, .12), transparent 70%);
  opacity: 0;
  transition: opacity .22s;
}
.game-card:hover, .game-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(216, 180, 106, .42);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .9);
  outline: none;
}
.game-card:hover::after { opacity: 1; }
.card-icon {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 13px;
  display: grid;
  place-items: center;
}
.xq-icon {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 27px;
  color: #b3261e;
  background:
    radial-gradient(circle at 34% 28%, #fffdf5, #f4e3bd 52%, #dcc089 100%);
  border: 1px solid #c49a5f;
  box-shadow: inset 0 0 0 3px rgba(255, 250, 235, .55), inset 0 0 0 4px rgba(170, 120, 60, .28);
}
.intl-icon {
  background: radial-gradient(circle at 35% 28%, #fffdf5, #f2e2c2 55%, #dcc191);
  border: 1px solid #c49a5f;
  box-shadow: inset 0 0 0 3px rgba(255, 250, 235, .55), inset 0 0 0 4px rgba(170, 120, 60, .28);
}
.intl-icon svg { width: 36px; height: 36px; }
.gomoku-icon {
  position: relative;
  background: radial-gradient(circle at 35% 28%, #fffdf5, #f2e2c2 55%, #dcc191);
  border: 1px solid #c49a5f;
  box-shadow: inset 0 0 0 3px rgba(255, 250, 235, .55), inset 0 0 0 4px rgba(170, 120, 60, .28);
}
.gomoku-icon i {
  position: absolute;
  width: 23px;
  height: 23px;
  border-radius: 50%;
}
.gomoku-icon i:first-child {
  left: 9px;
  top: 9px;
  background: radial-gradient(circle at 35% 30%, #6b7480, #1b1e23 58%, #040506);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .4);
}
.gomoku-icon i:last-child {
  right: 9px;
  bottom: 9px;
  background: radial-gradient(circle at 35% 30%, #ffffff, #f1e8d5 55%, #d7c8aa);
  border: 1px solid rgba(80, 55, 25, .35);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .22);
}
.card-copy { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 4px; }
.card-copy strong {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: .06em;
  font-weight: 700;
}
.card-copy small { color: var(--muted); font-size: 12px; letter-spacing: .04em; }
.card-arrow {
  margin-left: auto;
  color: var(--faint);
  font-size: 18px;
  transition: transform .22s, color .22s;
}
.game-card:hover .card-arrow { transform: translateX(4px); color: var(--gold-strong); }

.join-row {
  width: 100%;
  display: flex;
  gap: 10px;
  margin-top: 26px;
}
.code-input {
  flex: 1;
  min-width: 0;
  padding: 13px 16px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid var(--line);
  border-radius: 12px;
  letter-spacing: .34em;
  font-size: 15px;
  font-family: "SFMono-Regular", Consolas, "Roboto Mono", monospace;
  text-transform: uppercase;
  color: var(--gold-strong);
  transition: border-color .2s, background .2s;
}
.code-input::placeholder {
  color: var(--faint);
  letter-spacing: .12em;
  font-family: var(--sans);
  text-transform: none;
}
.code-input:focus {
  outline: none;
  border-color: rgba(216, 180, 106, .55);
  background: rgba(255, 255, 255, .055);
}
.lobby-hint {
  margin: 18px 0 0;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
  max-width: 380px;
}
.feature-row {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}
.feature-row span {
  font-size: 11px;
  color: var(--muted);
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  letter-spacing: .06em;
}

/* ============================================================ 通用控件 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font-size: 13px;
  letter-spacing: .04em;
  cursor: pointer;
  transition: border-color .16s, color .16s, background .16s, transform .12s;
  white-space: nowrap;
}
.btn:hover { border-color: rgba(216, 180, 106, .45); color: var(--gold-strong); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn.primary {
  background: linear-gradient(135deg, #e2c07a, #bd8d41);
  color: #24180a;
  font-weight: 700;
  border-color: transparent;
  box-shadow: 0 10px 24px -12px rgba(216, 180, 106, .8);
}
.btn.primary:hover { color: #180f04; filter: brightness(1.05); }
.btn.ghost { background: rgba(255, 255, 255, .025); color: var(--muted); }
.btn.danger:hover { color: #ff9d8f; border-color: rgba(226, 112, 95, .4); }
.icon-btn {
  min-width: 38px;
  height: 34px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: .16s;
}
.icon-btn:hover { color: var(--gold-strong); background: rgba(255, 255, 255, .05); }

/* ============================================================ 房间 */
.room { min-height: 100dvh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 clamp(10px, 2.6vw, 22px);
  background: rgba(9, 13, 18, .78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mini-seal {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-family: var(--serif);
  font-size: 17px;
  color: #f6e7cf;
  background: linear-gradient(150deg, #b7382f, #87231d);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}
.game-name {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: .08em;
  color: var(--text);
  white-space: nowrap;
}
.code-chip {
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(216, 180, 106, .07);
  border: 1px dashed rgba(216, 180, 106, .32);
  border-radius: 9px;
  cursor: pointer;
  transition: .16s;
}
.code-chip:hover { background: rgba(216, 180, 106, .13); border-color: rgba(216, 180, 106, .55); }
.code-label { font-size: 10px; color: var(--faint); letter-spacing: .12em; }
.code-text {
  font-family: "SFMono-Regular", Consolas, "Roboto Mono", monospace;
  font-size: 14px;
  letter-spacing: .18em;
  color: var(--gold-strong);
}
.topbar-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.net-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  margin-right: 4px;
  transition: .3s;
}
.net-dot.online { background: var(--green); box-shadow: 0 0 0 3px rgba(111, 191, 143, .12); }
.net-dot.offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(226, 112, 95, .12); }
.net-dot.connecting { background: var(--gold); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.layout {
  width: min(1060px, 100%);
  margin: 0 auto;
  padding: 18px clamp(8px, 2.4vw, 22px) 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 296px;
  gap: clamp(14px, 2.6vw, 28px);
  align-items: start;
}
.board-column { min-width: 0; display: flex; flex-direction: column; }

.seat {
  display: flex;
  align-items: center;
  gap: 9px;
  width: min(100%, var(--bw, 100%));
  min-height: 42px;
  margin-left: auto;
  margin-right: auto;
  padding: 4px 6px;
}
.seat-dot {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #2a323d;
  border: 1px solid rgba(255, 255, 255, .14);
  position: relative;
  transition: box-shadow .25s;
}
.seat.red .seat-dot {
  background: radial-gradient(circle at 35% 30%, #e46a5d, #b3261e 60%, #7d1712);
  border-color: rgba(255, 180, 160, .35);
}
.seat.black .seat-dot {
  background: radial-gradient(circle at 35% 30%, #737b88, #2c313a 58%, #111317);
  border-color: rgba(255, 255, 255, .22);
}
.seat.white .seat-dot {
  background: radial-gradient(circle at 35% 30%, #fffdf6, #e8dfc8 62%, #c9bea3);
  border-color: rgba(255, 255, 255, .45);
}
.seat.active .seat-dot { box-shadow: 0 0 0 3px rgba(216, 180, 106, .22), 0 0 14px rgba(216, 180, 106, .45); }
.seat-name { font-size: 13px; letter-spacing: .04em; color: var(--text); }
.seat-dot + .seat-name { margin-left: 1px; }
.seat-tag {
  font-size: 10px;
  color: #261a09;
  background: var(--gold);
  border-radius: 4px;
  padding: 1px 5px;
  letter-spacing: .08em;
}
.seat-tag.spectator { background: rgba(255, 255, 255, .12); color: var(--muted); }
.seat-tag.rival { background: rgba(255, 255, 255, .08); color: var(--muted); }
.seat-tag:empty { display: none; }
.seat-state {
  margin-left: auto;
  font-size: 11px;
  color: var(--faint);
  letter-spacing: .06em;
  display: flex;
  align-items: center;
  gap: 5px;
}
.seat-state.online { color: #8fbfa3; }
.seat-state.offline { color: #b78178; }
.seat-state.thinking { color: var(--gold); }

/* ------------------------------------------------------------ 棋盘外框 */
.board-shell {
  position: relative;
  width: min(100%, 620px);
  margin: 2px auto 6px;
  --bw: 360px;
}
.board {
  position: relative;
  width: 100%;
  aspect-ratio: 10 / 11;
  border-radius: 15px;
  overflow: hidden;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
}
.board.chess { aspect-ratio: 1 / 1; border-radius: 12px; }
.board.xiangqi {
  background:
    radial-gradient(120% 90% at 18% 0%, rgba(255, 248, 224, .75), transparent 55%),
    radial-gradient(100% 100% at 88% 100%, rgba(140, 84, 28, .18), transparent 60%),
    linear-gradient(150deg, #f2dcae 0%, #ecd39f 34%, #e2c188 68%, #d5ae72 100%);
  border: 1px solid rgba(120, 78, 32, .45);
  box-shadow:
    0 34px 70px -28px rgba(0, 0, 0, .95),
    0 2px 0 rgba(255, 249, 230, .35) inset,
    0 -6px 18px rgba(120, 75, 25, .22) inset,
    0 0 0 5px rgba(52, 34, 17, .55),
    0 0 0 6px rgba(216, 180, 106, .18);
}
.board.xiangqi::before,
.board.gomoku::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .55;
  background-image:
    repeating-linear-gradient(93deg, rgba(120, 74, 24, .035) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(2deg, rgba(120, 74, 24, .025) 0 1px, transparent 1px 11px);
  mix-blend-mode: multiply;
  z-index: 1;
}
.board.chess {
  background: #2a1a11;
  border: 1px solid rgba(216, 180, 106, .18);
  box-shadow:
    0 34px 70px -28px rgba(0, 0, 0, .95),
    0 0 0 5px #382516,
    0 0 0 6px rgba(216, 180, 106, .22);
}
.board.gomoku {
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background:
    radial-gradient(120% 90% at 18% 0%, rgba(255, 248, 224, .75), transparent 55%),
    radial-gradient(100% 100% at 88% 100%, rgba(140, 84, 28, .18), transparent 60%),
    linear-gradient(150deg, #f2dcae 0%, #ecd39f 34%, #e2c188 68%, #d5ae72 100%);
  border: 1px solid rgba(120, 78, 32, .45);
  box-shadow:
    0 34px 70px -28px rgba(0, 0, 0, .95),
    0 2px 0 rgba(255, 249, 230, .35) inset,
    0 -6px 18px rgba(120, 75, 25, .22) inset,
    0 0 0 5px rgba(52, 34, 17, .55),
    0 0 0 6px rgba(216, 180, 106, .18);
}
.board-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
  pointer-events: none;
}
.board-hints, .board-pieces {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.board-pieces { z-index: 4; }
.board-hints-top { z-index: 5; }
.board-hits {
  position: absolute;
  inset: 0;
  z-index: 6;
}
.hit {
  position: absolute;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}
.hit:focus-visible { outline: 2px solid rgba(216, 180, 106, .55); outline-offset: -2px; }

/* ------------------------------------------------------------ 棋子 */
.piece {
  position: absolute;
  transform: translate(-50%, -50%);
  transition:
    left .26s cubic-bezier(.22, .78, .24, 1),
    top .26s cubic-bezier(.22, .78, .24, 1),
    transform .18s ease,
    filter .18s ease,
    opacity .22s ease;
  will-change: left, top, transform;
  z-index: 3;
  pointer-events: none;
}
.piece.no-anim { transition: none !important; }
.piece.gomoku {
  width: 5.05%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
}
.piece.gomoku.black {
  background: radial-gradient(circle at 34% 27%, #8b95a2 0%, #444b55 26%, #16191e 62%, #040506 100%);
  box-shadow:
    0 3px 5px rgba(0, 0, 0, .45),
    inset 0 2px 2px rgba(255, 255, 255, .28),
    inset 0 -3px 5px rgba(0, 0, 0, .55);
}
.piece.gomoku.white {
  background: radial-gradient(circle at 34% 27%, #ffffff 0%, #fcf7ec 32%, #ece0c8 66%, #cbbb9b 100%);
  border: 1px solid rgba(110, 82, 45, .3);
  box-shadow:
    0 3px 5px rgba(40, 25, 8, .32),
    inset 0 2px 2px rgba(255, 255, 255, .9),
    inset 0 -3px 5px rgba(120, 95, 55, .22);
}
.piece.gomoku.win {
  animation: stone-win 1.15s ease-in-out infinite;
  z-index: 7;
}
.piece.gomoku.win::after {
  content: "";
  position: absolute;
  inset: -10%;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 190, 70, .95);
  box-shadow: 0 0 16px rgba(255, 170, 50, .75);
  animation: win-ring 1.15s ease-in-out infinite;
  pointer-events: none;
}
@keyframes win-ring {
  0%, 100% { opacity: .55; transform: scale(.96); }
  50% { opacity: 1; transform: scale(1.08); }
}
@keyframes stone-win {
  0%, 100% {
    filter: drop-shadow(0 0 2px rgba(242, 196, 110, .45));
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    filter: drop-shadow(0 0 11px rgba(242, 196, 110, 1));
    transform: translate(-50%, -50%) scale(1.06);
  }
}
.piece.xq {
  width: 8.8%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 34% 26%, #fffdf4 0%, #fbf1d7 24%, #f1ddb4 52%, #e0c38e 78%, #c9a269 100%);
  border: 1.5px solid #b78a4d;
  box-shadow:
    0 5px 8px -1px rgba(52, 30, 7, .45),
    0 1px 0 rgba(255, 255, 255, .75) inset,
    0 -3px 5px rgba(128, 82, 26, .25) inset;
}
.piece.xq::before {
  content: "";
  position: absolute;
  inset: 7.5%;
  border-radius: 50%;
  border: 1.5px solid rgba(160, 105, 45, .62);
  box-shadow: inset 0 0 7px rgba(120, 75, 20, .16);
}
.piece.xq::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 33% 18%, rgba(255, 255, 255, .7), transparent 43%);
  pointer-events: none;
}
.piece.xq .glyph {
  position: relative;
  z-index: 1;
  font-family: "STKaiti", "KaiTi", "Kaiti SC", "Noto Serif SC", "Songti SC", serif;
  font-weight: 700;
  font-size: calc(var(--bw, 360px) * .0555);
  line-height: 1;
  transform: translateY(-2%);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .45);
  letter-spacing: 0;
}
.piece.xq.red .glyph { color: #b0261d; }
.piece.xq.black .glyph { color: #23262c; }
.piece.chess {
  width: 11.4%;
  aspect-ratio: 1 / 1;
}
.piece.chess svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 4px 3px rgba(0, 0, 0, .38));
}
.piece.chess.white svg { filter: drop-shadow(0 4px 3px rgba(0, 0, 0, .42)) drop-shadow(0 0 1px rgba(255, 255, 255, .5)); }
.piece.chess.black svg { filter: drop-shadow(0 4px 3px rgba(0, 0, 0, .4)) drop-shadow(0 0 1.2px rgba(255, 244, 225, .5)); }
.piece.chess.selected { transform: translate(-50%, -50%) scale(1.13); z-index: 8; }
.piece.chess.selected svg { filter: drop-shadow(0 0 6px rgba(242, 211, 145, .9)) drop-shadow(0 5px 4px rgba(0, 0, 0, .4)); }
.piece.xq.selected {
  transform: translate(-50%, -50%) scale(1.1);
  z-index: 8;
  filter: drop-shadow(0 0 7px rgba(242, 196, 110, .85));
}
.piece.xq.selected::before { border-color: rgba(210, 140, 40, .95); }
.piece.spawned { opacity: 0; transform: translate(-50%, -50%) scale(.62); }
.piece.dead {
  opacity: 0;
  transform: translate(-50%, -50%) scale(.45) rotate(14deg);
  transition: opacity .28s ease, transform .28s ease;
  z-index: 2;
}
.piece.in-check {
  animation: check-pulse 1.1s ease-in-out infinite;
  z-index: 7;
}
@keyframes check-pulse {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(255, 70, 50, .5)); }
  50% { filter: drop-shadow(0 0 12px rgba(255, 76, 54, .95)); }
}

/* ------------------------------------------------------------ 提示层 */
.hint {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border-radius: 50%;
  z-index: 1;
}
.hint.last {
  background: rgba(230, 172, 74, .34);
  box-shadow: inset 0 0 0 2.5px rgba(184, 112, 18, .82), 0 0 12px rgba(216, 180, 106, .22);
  z-index: 0;
}
.board.chess .hint.last { border-radius: 7px; }
.hint.stone-last {
  background: transparent;
  box-shadow: inset 0 0 0 2.5px rgba(198, 78, 52, .95), 0 0 12px rgba(226, 112, 95, .4);
}
.hint.sel {
  background: transparent;
  box-shadow: 0 0 0 2.5px rgba(242, 211, 145, .95), 0 0 18px rgba(242, 196, 110, .5);
}
.hint.dot { background: rgba(60, 44, 18, .4); box-shadow: 0 0 0 1px rgba(255, 245, 220, .25); }
.hint.dot.chess-dot { background: rgba(30, 20, 8, .42); box-shadow: 0 0 0 1.5px rgba(255, 244, 215, .35); }
.hint.cap {
  background: transparent;
  box-shadow: inset 0 0 0 3px rgba(198, 62, 46, .9), 0 0 16px rgba(198, 62, 46, .4);
}
.hint.check {
  background: radial-gradient(circle, rgba(255, 60, 40, .38), transparent 70%);
  box-shadow: none;
}

/* ------------------------------------------------------------ 覆盖层 */
.banner {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 11, 16, .52);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fade-in .25s ease both;
}
.banner-card {
  width: min(340px, 94%);
  padding: 22px 22px 20px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(32, 41, 53, .92), rgba(18, 24, 32, .94));
  border: 1px solid rgba(216, 180, 106, .22);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 255, 255, .06);
  text-align: center;
  animation: card-in .3s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.banner.result {
  align-items: start;
  padding-top: 3%;
  background: rgba(8, 11, 16, .16);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
}
.banner.result .banner-card { width: min(318px, 92%); padding: 16px 18px 15px; background: rgba(20, 27, 36, .94); }
.banner-kicker {
  font-size: 10px;
  letter-spacing: .28em;
  color: var(--gold);
  text-transform: uppercase;
}
.banner-title {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: 24px;
  letter-spacing: .1em;
  font-weight: 700;
}
.banner-reason { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.invite-code {
  margin: 16px 0 4px;
  font-family: "SFMono-Regular", Consolas, "Roboto Mono", monospace;
  font-size: clamp(26px, 7vw, 34px);
  letter-spacing: .26em;
  padding-left: .26em;
  color: var(--gold-strong);
  text-shadow: 0 0 24px rgba(216, 180, 106, .35);
}
.invite-hint { color: var(--faint); font-size: 11px; margin: 0 0 15px; }
.banner-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.banner-actions .btn { flex: 1 1 auto; }
.banner-link {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 12px;
  cursor: pointer;
  padding: 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.waiting-dots { display: inline-flex; gap: 4px; margin-left: 5px; vertical-align: middle; }
.waiting-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold);
  animation: dot 1.2s infinite;
}
.waiting-dots i:nth-child(2) { animation-delay: .15s; }
.waiting-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot {
  0%, 60%, 100% { opacity: .2; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* ------------------------------------------------------------ 状态与操作 */
.under-board {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, var(--bw, 100%));
  margin: 4px auto 0;
  flex-wrap: wrap;
}
.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 160px;
  min-height: 36px;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: .04em;
  transition: color .2s;
}
.turn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 9px rgba(216, 180, 106, .7);
  flex: 0 0 auto;
}
.status-line.opponent .turn-dot { background: #6e7b89; box-shadow: none; }
.status-line.check { color: #ffb2a2; }
.status-line.check .turn-dot { background: #ff5d49; box-shadow: 0 0 10px rgba(255, 80, 60, .8); }
.status-line.done { color: var(--gold); }
.action-row { display: flex; gap: 6px; }
.action-row .btn { padding: 8px 13px; font-size: 12px; }

/* ------------------------------------------------------------ 侧面板 */
.side-panel {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  height: min(720px, calc(100dvh - 120px));
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .008)),
    rgba(17, 23, 31, .7);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px -30px rgba(0, 0, 0, .9);
}
.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: .12em;
  color: var(--text);
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}
.ply-count { font-family: var(--sans); font-size: 10px; color: var(--faint); letter-spacing: .08em; }
.moves {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  margin: 8px -4px 0;
  padding: 0 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .12) transparent;
}
.moves::-webkit-scrollbar { width: 4px; }
.moves::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 4px; }
.move-row {
  display: grid;
  grid-template-columns: 30px 1fr 1fr;
  gap: 4px;
  align-items: center;
  padding: 4px 2px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--muted);
}
.move-row:nth-child(odd) { background: rgba(255, 255, 255, .018); }
.move-row.current { background: rgba(216, 180, 106, .09); }
.move-no { color: var(--faint); font-size: 10px; font-variant-numeric: tabular-nums; }
.move-san { color: #c8c2b6; }
.move-san.red { color: #e08a7f; }
.move-san.white { color: #e9e3d5; }
.move-san.black { color: #9aa5b1; }
.move-san.current { color: var(--gold-strong); font-weight: 600; }
.moves-empty {
  margin: auto;
  padding: 26px 8px;
  text-align: center;
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.8;
}
.rematch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0 0;
  margin-top: 8px;
  border-top: 1px solid var(--line);
}
.rematch-bar span { font-size: 11px; color: var(--muted); }
.rematch-bar .btn { padding: 8px 12px; font-size: 12px; }
.room-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
}
.room-meta div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.room-meta span { font-size: 9px; letter-spacing: .16em; color: var(--faint); }
.room-meta b {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-meta b.gold { color: var(--gold); }

/* ------------------------------------------------------------ toast / modal */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  z-index: 100;
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(28, 36, 46, .96);
  border: 1px solid rgba(216, 180, 106, .28);
  color: var(--text);
  font-size: 12.5px;
  box-shadow: 0 16px 40px -14px rgba(0, 0, 0, .9);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  max-width: min(360px, calc(100vw - 32px));
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(226, 112, 95, .45); color: #ffc4b9; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 8, 11, .68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in .2s ease both;
}
.modal-card {
  width: min(360px, 100%);
  padding: 24px;
  border-radius: 18px;
  background: linear-gradient(180deg, #1d2732, #131a22);
  border: 1px solid rgba(216, 180, 106, .22);
  box-shadow: var(--shadow);
  text-align: center;
  animation: card-in .26s cubic-bezier(.2, .8, .3, 1) both;
}
.modal-title {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: .08em;
}
.modal-text { margin: 0 0 18px; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions .btn { flex: 1; }
.promo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.promo-choice {
  display: grid;
  place-items: center;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid rgba(120, 82, 35, .5);
  background: linear-gradient(160deg, #f2e5ca, #d9c29b);
  cursor: pointer;
  transition: .16s;
}
.promo-choice:hover { border-color: #a8772f; background: #f8eedb; transform: translateY(-1px); }
.promo-choice svg { width: 42px; height: 42px; }
.promo-choice span { font-size: 10px; color: #4b361d; margin-top: 2px; }

/* 观众标识 */
body.spectator .action-row #resignBtn,
body.spectator .action-row #drawBtn { display: none; }

/* ------------------------------------------------------------ 响应式 */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 10px;
    padding-top: 10px;
    padding-bottom: 24px;
  }
  .side-panel {
    position: static;
    height: 200px;
    max-height: 200px;
    padding: 12px 14px;
  }
  .moves { max-height: 118px; }
  .board-shell { max-width: 560px; }
  .seat { min-height: 36px; }
  .under-board { margin-top: 0; }
  .status-line { min-height: 32px; }
  .room-meta { display: none; }
  .topbar { height: 52px; gap: 8px; }
  .game-name { display: inline; font-size: 13px; }
  .code-chip { margin-left: 2px; margin-right: auto; }
  .banner { padding: 12px; }
  .banner-card { padding: 18px 18px 16px; }
}
@media (max-width: 430px) {
  .topbar { gap: 6px; }
  .code-label { display: none; }
  .code-chip { padding: 5px 9px; gap: 4px; }
  .code-text { font-size: 13px; letter-spacing: .12em; }
  .icon-btn { min-width: 30px; padding: 0 5px; font-size: 12px; }
  .game-name { font-size: 12px; }
}
@media (max-width: 380px) {
  .action-row .btn { padding: 7px 10px; }
  .seat-name { font-size: 12px; }
  .card-icon { width: 46px; height: 46px; }
}
@media (min-width: 901px) and (max-height: 760px) {
  .topbar { height: 50px; }
  .layout { padding-top: 10px; }
  .side-panel { top: 62px; height: calc(100dvh - 80px); }
  .seat { min-height: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
