/* ==========================================================================
   国际象棋
   ========================================================================== */

/* 统一宽度：模式标签（共用 .mode-tabs）与下方内容列（状态栏 / 棋盘 / 控制区 / 规则）等宽 */
.chs-app {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  width: min(94vw, 620px);
  margin: 0 auto;
}

.chs {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}

.chs-slot:empty { display: none; }

/* ------------------------------ 状态栏 ---------------------------------- */

.chs-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

.chs-turn { display: inline-flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; }

.chs-turn-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.14);
  transition: background .25s, box-shadow .25s;
}
.chs-turn-dot.is-white {
  background: radial-gradient(circle at 32% 28%, #ffffff, #e5e7eb 62%, #9ca3af);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.chs-turn-dot.is-black {
  background: radial-gradient(circle at 32% 28%, #6b7280, #111827 62%, #000);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16);
}
.chs-turn-dot.is-finished { background: rgba(255, 255, 255, 0.08); box-shadow: none; }

.chs-meta { font-size: 12.5px; color: var(--text-mute); font-variant-numeric: tabular-nums; }

/* ------------------------------ 结果横幅 -------------------------------- */

.chs-banner {
  padding: 16px 18px;
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid rgba(139, 92, 246, 0.4);
  background: linear-gradient(120deg, rgba(139, 92, 246, 0.18), rgba(34, 211, 238, 0.1));
  animation: chs-banner-in .28s cubic-bezier(.2, .8, .3, 1);
}
.chs-banner[hidden] { display: none; }
.chs-banner.is-white { border-color: rgba(226, 232, 240, 0.55); }
.chs-banner.is-black { border-color: rgba(148, 163, 184, 0.45); }
.chs-banner.is-draw { border-color: rgba(251, 191, 36, 0.4); }

@keyframes chs-banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.chs-banner-title { font-size: 18px; font-weight: 700; }
.chs-banner-detail { margin-top: 6px; font-size: 13px; color: var(--text-dim); }
.chs-banner-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.chs-banner-actions:empty { display: none; }

/* ------------------------------ 吃子明细 -------------------------------- */

.chs-captured {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.03);
}
.chs-captured[hidden] { display: none; }

.chs-captured-group { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.chs-captured-label { font-size: 12px; color: var(--text-mute); white-space: nowrap; }
.chs-captured-items { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chs-captured-none { font-size: 12px; color: var(--text-mute); }

.chs-mini {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 16px;
  font-style: normal;
  line-height: 1;
  border-radius: 6px;
}
.chs-mini.is-white { color: #f1f5f9; }
.chs-mini.is-black { color: #94a3b8; }

/* ------------------------------- 棋盘 ----------------------------------- */

.chs-board-wrap { display: grid; place-items: center; width: 100%; }

.chs-board {
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1px solid rgba(70, 45, 20, 0.6);
  background:
    radial-gradient(120% 120% at 20% 0%, rgba(255, 255, 255, 0.35), transparent 55%),
    linear-gradient(155deg, #7a5330, #5c3d22);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.16),
    0 26px 54px -26px rgba(0, 0, 0, 0.92);
  overflow: hidden;
}

.chs-squares {
  position: absolute;
  inset: 2.4%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 4px;
  overflow: hidden;
}

.chs-cell {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chs-cell.is-light { background: #edd7b0; }
.chs-cell.is-dark { background: #b07a4b; }

.chs-piece {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: clamp(20px, 5vw, 40px);
  line-height: 1;
  transition: transform .16s, filter .16s;
  user-select: none;
}
.chs-piece.is-none { font-size: 0; }
.chs-piece.is-white {
  color: #ffffff;
  text-shadow:
    0 0 1px #1f2937, 0 0 1px #1f2937,
    0 1px 2px rgba(0, 0, 0, 0.55),
    0 0 2px rgba(31, 41, 55, 0.9);
}
.chs-piece.is-black {
  color: #1b2430;
  text-shadow:
    0 0 1px rgba(255, 255, 255, 0.75),
    0 1px 2px rgba(0, 0, 0, 0.45);
}

/* 可走落点提示 */
.chs-cell.is-target::after {
  content: "";
  position: absolute;
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.5);
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.45);
  pointer-events: none;
}
/* 可吃的敌子：红圈提示 */
.chs-cell.is-capture::after {
  width: 88%;
  height: 88%;
  border-radius: 50%;
  background: transparent;
  border: 2px dashed rgba(220, 38, 38, 0.9);
  box-shadow: none;
}
.chs-cell.is-capture .chs-piece { filter: drop-shadow(0 0 3px rgba(220, 38, 38, 0.75)); }

/* 选中 */
.chs-cell.is-selected { box-shadow: inset 0 0 0 3px rgba(139, 92, 246, 0.95); }
.chs-cell.is-selected .chs-piece { transform: scale(1.06); }
/* 最近一步 */
.chs-cell.is-last { box-shadow: inset 0 0 0 2px rgba(14, 116, 144, 0.85); }
/* 被将军的王 */
.chs-cell.is-check { box-shadow: inset 0 0 0 3px rgba(239, 68, 68, 0.95); }
.chs-cell.is-check .chs-piece { animation: chs-check-pulse 1.1s ease-in-out infinite; }
@keyframes chs-check-pulse {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(239, 68, 68, 0.9)); }
  50% { filter: drop-shadow(0 0 9px rgba(239, 68, 68, 0.95)); }
}

/* ------------------------------ 升变浮层 -------------------------------- */

.chs-promo {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(6, 9, 18, 0.82);
  backdrop-filter: blur(2px);
  animation: chs-banner-in .2s ease-out;
}
.chs-promo[hidden] { display: none; }
.chs-promo-title { font-size: 13.5px; font-weight: 600; color: var(--text-dim); }

.chs-promo-options { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.chs-promo-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 62px;
  padding: 10px 6px;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: transform .16s, background .2s, border-color .2s;
}
.chs-promo-btn:hover { background: rgba(139, 92, 246, 0.22); border-color: rgba(139, 92, 246, 0.6); transform: translateY(-1px); }
.chs-promo-glyph { font-size: 26px; line-height: 1; }
.chs-promo-label { font-size: 12px; color: var(--text-mute); }
.chs-promo.is-white .chs-promo-glyph { color: #ffffff; text-shadow: 0 0 1px #1f2937, 0 0 1px #1f2937; }
.chs-promo.is-black .chs-promo-glyph { color: #1b2430; text-shadow: 0 0 1px rgba(255, 255, 255, 0.75); }

/* ------------------------------- 控制区 --------------------------------- */

.chs-controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chs-controls:empty { display: none; }

/* ------------------------------ 房间模式 -------------------------------- */

.chs-lobby {
  display: grid;
  gap: 18px;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}
.chs-lobby > .chs-notice { grid-column: 1 / -1; }

.chs-card {
  display: flex;
  flex-direction: column;
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
}
.chs-card h3 { margin: 0 0 6px; font-size: 16px; }
.chs-card p.hint { margin: 0 0 16px; font-size: 12.5px; line-height: 1.6; color: var(--text-mute); }

.chs-field { display: block; margin-bottom: 14px; }
.chs-field > span { display: block; margin-bottom: 7px; font-size: 12.5px; color: var(--text-dim); }

.chs-input {
  width: 100%;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(6, 9, 18, 0.55);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.chs-input:focus { border-color: rgba(139, 92, 246, 0.7); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); }
.chs-input::placeholder { color: var(--text-mute); }

.chs-input.is-room {
  letter-spacing: 0.22em;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
}

.chs-lobby-actions { display: flex; gap: 10px; margin-top: auto; }
.chs-lobby-actions .btn { flex: 1 1 auto; }

.chs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

.chs-room-code { display: flex; align-items: center; gap: 10px; }
.chs-room-code small { font-size: 12px; color: var(--text-mute); }
.chs-room-code b { font-size: 22px; letter-spacing: 0.16em; }

.chs-seats { display: flex; flex-wrap: wrap; gap: 10px; }

.chs-seat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-dim);
}
.chs-seat.is-me { color: var(--text); border-color: rgba(139, 92, 246, 0.45); background: rgba(139, 92, 246, 0.14); }
.chs-seat.is-offline { opacity: 0.55; }
.chs-seat.is-empty { opacity: 0.6; }

.chs-seat-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.18);
}
.chs-seat-dot.is-white { background: radial-gradient(circle at 32% 28%, #ffffff, #e5e7eb 62%, #9ca3af); }
.chs-seat-dot.is-black { background: radial-gradient(circle at 32% 28%, #6b7280, #111827 62%, #000); }

.chs-seat-info { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.chs-seat-info b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chs-seat-info small { font-size: 11.5px; color: var(--text-mute); }

.chs-copy { padding: 6px 12px; font-size: 12px; border-radius: 999px; }

.chs-wait { font-size: 12.5px; color: var(--text-dim); }

.chs-notice {
  padding: 11px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(251, 191, 36, 0.32);
  background: rgba(251, 191, 36, 0.1);
  color: #fcd88a;
}
.chs-notice[hidden] { display: none; }
.chs-notice.is-error { border-color: rgba(251, 113, 133, 0.4); background: rgba(251, 113, 133, 0.12); color: #fda4af; }

@media (max-width: 640px) {
  .chs-status { flex-direction: column; align-items: flex-start; gap: 10px; }
  .chs-lobby { gap: 12px; }
  .chs-card { padding: 15px; }
  .chs-board { width: min(94vw, 440px); }
}
