/* 国际象棋（ADR-0205）：木头棋盘（深浅两种木头的格子）、自己画的棋子、两边的人。
   两边的人、开局弹层、状态这几样借用 gomoku.css 的 .gm-* 样子（同一页都装着）；满屏的样子和五子棋 body.gm-full 一样，这里叫 body.ch-full */
.ch-head {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
  margin: 4px 0 8px;
  font-size: 15px;
}

.ch-head span { color: var(--muted); font-size: 13px; }

/* 棋子：白子象牙色、黑子乌木色，描一圈深色边 */
.ch-pc { display: block; overflow: visible; }
.ch-pc .body { stroke-width: 3; stroke-linejoin: round; }
.ch-pc .line { fill: none; stroke-width: 2.6; stroke-linecap: round; }
.ch-pc.w .body { fill: #fbf6ea; stroke: #2e2216; }
.ch-pc.w .line { stroke: #2e2216; }
.ch-pc.w .eye { fill: #2e2216; }
.ch-pc.b .body { fill: #2b2420; stroke: #0e0a07; }
.ch-pc.b .line { stroke: #d9cbb2; }
.ch-pc.b .eye { fill: #e9dcc4; }

/* 大厅卡片上的小图标：深色木头上一匹白马 */
.ch-icon { padding: 5px; background: linear-gradient(135deg, #7a4b26, #4b2c14); }
.ch-icon .ch-pc { width: 100%; height: 100%; }

/* 下棋的桌面 */
.ch-wrap {
  position: relative;
  margin: 12px -4px;
  padding: 16px 14px 24px;
  border-radius: 24px;
  background:
    radial-gradient(ellipse 80% 70% at 50% 35%, rgba(255, 244, 222, 0.9), rgba(255, 244, 222, 0) 70%),
    linear-gradient(#e9cfa6, #d9b583);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 10px 22px rgba(90, 55, 20, 0.18);
}

/* 木头棋盘：一圈深色木框，看得到厚度 */
.ch-frame {
  position: relative;
  padding: 2.6%;
  border-radius: 8px;
  background:
    repeating-linear-gradient(92deg, rgba(255, 220, 170, 0.06) 0 3px, rgba(60, 30, 10, 0.08) 3px 7px),
    linear-gradient(135deg, #8a5630, #5e3519);
  box-shadow: inset 0 0 0 1px rgba(255, 220, 170, 0.3), 0 3px 0 #4f2c13, 0 7px 0 #3d210e,
    0 10px 3px rgba(40, 20, 6, 0.45), 0 22px 30px rgba(60, 30, 10, 0.35);
}

.ch-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(30, 14, 4, 0.6);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.ch-sq {
  position: relative;
  min-width: 0;
  min-height: 0;
}

/* 浅色是枫木、深色是胡桃木，各带一点顺着的木纹 */
.ch-sq.light {
  background:
    repeating-linear-gradient(88deg, rgba(160, 110, 50, 0.07) 0 2px, transparent 2px 6px),
    linear-gradient(160deg, #f2dcb3, #e6c896);
}

.ch-sq.dark {
  background:
    repeating-linear-gradient(88deg, rgba(50, 25, 8, 0.1) 0 2px, transparent 2px 5px),
    linear-gradient(160deg, #b98352, #a06c3f);
}

.ch-board.can .ch-sq { cursor: pointer; }

/* 上一步：从哪到哪亮一层淡黄；点中的子亮一层绿；被将军的王底下一团红光 */
.ch-sq.last::before, .ch-sq.picked::before, .ch-sq.check::before {
  content: "";
  position: absolute;
  inset: 0;
}

.ch-sq.last::before { background: rgba(255, 214, 80, 0.42); }
.ch-sq.picked::before { background: rgba(110, 170, 70, 0.55); }
.ch-sq.check::before { background: radial-gradient(circle, rgba(230, 40, 20, 0.95) 0, rgba(230, 40, 20, 0.55) 40%, rgba(230, 40, 20, 0) 72%); }

.ch-sq > .ch-pc {
  position: absolute;
  inset: 3%;
  width: 94%;
  height: 94%;
  filter: drop-shadow(0 2px 1.5px rgba(30, 14, 4, 0.45));
}

.ch-sq > .ch-pc.moved { z-index: 3; }
.ch-sq > .ch-pc.sliding { transition: transform 220ms cubic-bezier(.3, .7, .4, 1); }

/* 能走的格子：中间一个小点；能吃的：一圈环 */
.ch-dot, .ch-ring {
  position: absolute;
  z-index: 2;
  pointer-events: none;
}

.ch-dot {
  left: 50%;
  top: 50%;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(30, 60, 20, 0.42);
  transform: translate(-50%, -50%);
}

.ch-ring {
  inset: 4%;
  border: 0.32em solid rgba(30, 60, 20, 0.45);
  border-radius: 50%;
}

/* 格子边上的字母、数字（a 到 h、1 到 8） */
.ch-rank, .ch-file {
  position: absolute;
  z-index: 1;
  font-size: clamp(9px, 2.2vmin, 14px);
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
}

.ch-rank { left: 4%; top: 4%; }
.ch-file { right: 5%; bottom: 4%; }
.ch-sq.light .ch-rank, .ch-sq.light .ch-file { color: #9a6a3c; }
.ch-sq.dark .ch-rank, .ch-sq.dark .ch-file { color: #f1dcb6; }

/* 下完了：棋盘正中一块牌子 */
.ch-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  display: grid;
  gap: 4px;
  justify-items: center;
  min-width: 56%;
  padding: 14px 22px;
  border-radius: 16px;
  background: rgba(255, 250, 240, 0.94);
  box-shadow: 0 10px 30px rgba(40, 20, 6, 0.4);
  color: #1a1814;
  text-align: center;
  transform: translate(-50%, -50%);
  animation: ch-pop 320ms cubic-bezier(.3, .7, .4, 1.3) both;
}

.ch-banner b { font-size: clamp(22px, 6vmin, 34px); font-weight: 700; }
.ch-banner span { font-size: 15px; line-height: 1.4; }
.ch-banner.win b { color: #b2452f; }
.ch-banner.lose b { color: #4b4036; }

@keyframes ch-pop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* 吃到的子：名字下面小小一排 */
.ch-taken {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: 18px;
}

.ch-taken .ch-pc.mini { width: 18px; height: 18px; margin-right: -5px; }
.ch-taken b { margin-left: 8px; color: var(--muted); font-size: 12px; font-weight: 600; }

/* 兵升变：四个子挑一个 */
.ch-promo {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 8px 0 12px;
}

.ch-promo-btn {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, #f2dcb3, #e6c896);
  color: #1a1814;
  font-size: 15px;
  cursor: pointer;
}

.ch-promo-btn .ch-pc { width: 56px; height: 56px; }

/* 介绍页的示意图：一角木头棋盘，白后将死黑王 */
.art-chess { background: linear-gradient(135deg, #7a4b26, #4b2c14); }

.art-chboard {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  height: 86%;
  aspect-ratio: 1;
  box-shadow: 0 0 0 4px #5e3519, 0 8px 18px rgba(20, 10, 2, 0.5);
  transform: translate(-50%, -50%);
}

.art-sq { position: relative; display: block; }
.art-sq.light { background: #ecd3a8; }
.art-sq.dark { background: #ad7748; }
.art-sq.check { background: radial-gradient(circle, rgba(230, 40, 20, 0.9), rgba(230, 40, 20, 0) 72%), #ecd3a8; }
.art-sq .ch-pc { position: absolute; inset: 4%; width: 92%; height: 92%; }

@media (prefers-reduced-motion: reduce) {
  .ch-sq > .ch-pc.sliding { transition: none; }
  .ch-banner { animation: none; }
}

/* 满屏大棋盘（和五子棋一样，ADR-0174 2026-11-06 后续）：整页是暖灯下的木桌，棋盘边到边铺满；
   竖着放不下按高度放到最大，宽屏最大 860 像素；两边的人收成细条、和棋盘一样宽，整块在中间 */
body.ch-full {
  --ink: #1a1814;
  --muted: #6b5a45;
  --paper: rgba(255, 250, 240, 0.82);
  --line: rgba(90, 60, 30, 0.22);
  background:
    radial-gradient(ellipse 90% 55% at 50% 42%, rgba(255, 244, 222, 0.95), rgba(255, 244, 222, 0) 72%),
    linear-gradient(#e9cfa6, #d2a974);
  background-attachment: fixed;
  color: var(--ink);
}

body.ch-full main {
  width: 100%;
  max-width: none;
  padding-top: calc(4px + env(safe-area-inset-top));
  padding-right: 0;
  padding-left: 0;
}

body.ch-full #view-chess {
  --ch-size: max(280px, min(100vw, calc(100dvh - 420px), 860px));
  align-items: center;
  min-height: calc(100dvh - 150px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

body.ch-full #view-chess > .top,
body.ch-full #view-chess > .ch-head {
  width: min(calc(100% - 24px), var(--ch-size));
}

body.ch-full #view-chess > .ch-head { margin: 0 0 6px; }

body.ch-full #ch-root {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
}

body.ch-full #ch-root .gm-player,
body.ch-full #ch-root .gm-status,
body.ch-full #ch-root .gm-note {
  width: min(calc(100% - 16px), var(--ch-size));
}

body.ch-full #ch-root .gm-player {
  min-height: 52px;
  padding: 6px 10px;
  box-shadow: 0 2px 6px rgba(90, 55, 20, 0.12);
}

body.ch-full #ch-root .gm-player.turn {
  border-color: #e0a640;
  box-shadow: 0 0 0 3px var(--gold-soft);
}

body.ch-full .ch-wrap {
  width: var(--ch-size);
  margin: 8px 0;
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

body.ch-full .ch-frame {
  padding: 2.4%;
  border-radius: 6px;
}

body.ch-full .gm-status { margin-top: 8px; }
