/* ================= Cờ Tướng — bàn cờ + quân + bộ xem ván =================
   Dùng chung: game (/cotuong/), trang xem lại ván (/cotuong/van/<id>), kỳ phổ (/cotuong/ky-pho/…).
   KHÔNG chép CSS bàn cờ sang chỗ khác — link file này. Màu bàn / quân đổi qua CSS vars (js/main.js applyTheme). */
:root {
  --bd-bg: linear-gradient(135deg, #f1cf8e, #e2b468);
  --bd-line: #6b3f12;
  --bd-river: #8a5420;
  --bd-frame: #7a4513;
  --pc-face: radial-gradient(circle at 35% 30%, #fff7e6, #f0d6a8);
  --pc-ring: #8a5a24;
  --pc-red: #c4161c;
  --pc-black: #1a1a1a;
}

/* ---------- bàn cờ (js/board.js) ---------- */
.board-wrap { position: relative; width: 100%; aspect-ratio: 9 / 10; border-radius: 10px; background: var(--bd-bg); box-shadow: 0 0 0 6px var(--bd-frame), 0 14px 34px rgba(0, 0, 0, .55); touch-action: none; user-select: none; margin: 6px 0; }
.xq-grid { position: absolute; inset: 0; width: 100%; height: 100%; }
.xq-grid line, .xq-grid polyline { stroke: var(--bd-line); stroke-width: .03; fill: none; vector-effect: non-scaling-stroke; }
.xq-grid line { stroke-width: 1.2px; }
.xq-grid polyline { stroke-width: 1.2px; }
.xq-grid .frame { stroke: var(--bd-line); stroke-width: 2.4px; fill: none; vector-effect: non-scaling-stroke; }
.xq-grid .river { fill: var(--bd-river); font-size: .5px; font-weight: 700; font-family: "Kaiti SC", "STKaiti", "KaiTi", serif; opacity: .85; }
.xq-marks i, .pc { position: absolute; transform: translate(-50%, -50%); }
.xq-marks i.dot { width: calc(var(--pc) * .28); height: calc(var(--pc) * .28); border-radius: 50%; background: rgba(46, 160, 67, .85); box-shadow: 0 0 0 2px rgba(255, 255, 255, .6); z-index: 3; pointer-events: none; }
.xq-marks i.hit { width: calc(var(--pc) * 1.06); height: calc(var(--pc) * 1.06); border-radius: 50%; border: 3px solid rgba(229, 72, 77, .9); z-index: 3; pointer-events: none; }
.xq-marks i.last { width: calc(var(--pc) * 1.02); height: calc(var(--pc) * 1.02); border-radius: 50%; border: 2px dashed rgba(35, 120, 255, .85); pointer-events: none; }
.pc { width: var(--pc); height: var(--pc); border-radius: 50%; display: grid; place-items: center; background: var(--pc-face); border: calc(var(--pc) * .07) solid var(--pc-ring); box-shadow: 0 3px 6px rgba(0, 0, 0, .45), inset 0 0 0 calc(var(--pc) * .05) rgba(255, 255, 255, .35); transition: transform .22s ease; z-index: 2; pointer-events: none; }
.pc span { display: grid; place-items: center; width: 82%; height: 82%; border-radius: 50%; border: 1px solid currentColor; font-family: "Kaiti SC", "STKaiti", "KaiTi", "Songti SC", serif; font-weight: 900; font-size: calc(var(--pc) * .52); line-height: 1; }
.pc.red { color: var(--pc-red); }
.pc.black { color: var(--pc-black); }
.xq.viet .pc span { width: 96%; border: 0; font-family: "Segoe UI", Roboto, Arial, sans-serif; font-size: calc(var(--pc) * .3); letter-spacing: -.5px; }
.xq.emoji .pc span { font-size: calc(var(--pc) * .5); border-width: 2px; }
.xq.emoji .pc.red span { border-color: var(--pc-red); }
.xq.emoji .pc.black span { border-color: var(--pc-black); }
.pc.sel { transform: translate(-50%, -50%) scale(1.12); box-shadow: 0 0 0 3px var(--accent, #ffcf5a), 0 8px 16px rgba(0, 0, 0, .5); z-index: 4; }
.pc.chk { box-shadow: 0 0 0 4px var(--red, #e5484d), 0 0 18px var(--red, #e5484d); animation: chk .7s ease 2; }
.pc.moving { z-index: 5; }
/* Cờ úp: covered stone — coloured back, no glyph. */
.pc.hid { background: repeating-linear-gradient(45deg, rgba(255, 255, 255, .18) 0 3px, transparent 3px 7px), var(--pc-ring); }
.pc.hid.red { box-shadow: 0 3px 6px rgba(0, 0, 0, .45), inset 0 0 0 calc(var(--pc) * .12) var(--pc-red); }
.pc.hid.black { box-shadow: 0 3px 6px rgba(0, 0, 0, .45), inset 0 0 0 calc(var(--pc) * .12) var(--pc-black); }
.pc.hid span { border: 0; }
@keyframes chk { 50% { transform: translate(-50%, -50%) scale(1.15); } }


/* ---------- bộ xem ván (js/viewer.js) ---------- */
.cv { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; margin: 14px 0; }
.cv-board { flex: 1 1 320px; max-width: 480px; padding: 8px; }
.cv-side { flex: 1 1 260px; min-width: 240px; display: flex; flex-direction: column; gap: 10px; }
.cv-nav { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cv-nav button { padding: 9px 0; border: 1px solid var(--line, #2b3646); border-radius: 10px; background: var(--panel-2, #1b2431); color: inherit; font: inherit; font-weight: 800; cursor: pointer; }
.cv-nav button[data-v=play] { grid-column: span 2; }
.cv-nav button:disabled { opacity: .35; cursor: default; }
.cv-comment { min-height: 56px; padding: 12px 14px; border-radius: 14px; background: var(--panel, #151c26); line-height: 1.55; }
.cv-comment b { color: var(--accent, #ffcf5a); margin-right: 4px; }
.cv-moves { max-height: 260px; overflow: auto; padding: 8px; border: 1px solid var(--line, #2b3646); border-radius: 14px; background: var(--panel, #151c26); line-height: 2; font-variant-numeric: tabular-nums; }
.cv-no { color: var(--muted, #93a3b8); margin: 0 2px 0 8px; font-size: 14px; }
.cv-mv { padding: 2px 7px; border: 0; border-radius: 7px; background: transparent; color: inherit; font: inherit; font-weight: 700; cursor: pointer; }
.cv-mv.r { color: #ff8f86; }
.cv-mv:hover { background: var(--panel-2, #1b2431); }
.cv-mv.cur { background: var(--accent, #ffcf5a); color: #1c1608; }
.cv-mv i { font-style: normal; font-size: 11px; margin-left: 2px; }
.cv-res { margin-left: 8px; font-weight: 900; color: var(--accent, #ffcf5a); }
.cv-glyph { align-self: flex-start; padding: 7px 12px; border: 1px solid var(--line, #2b3646); border-radius: 999px; background: transparent; color: var(--muted, #93a3b8); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.cv-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; padding: 12px 18px; border-radius: 12px; background: #1b2431; color: #e8eef6; font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
/* Phones: moves become a one-line strip right under the board, so the board never gets pushed off screen. */
@media (max-width: 700px) {
  .cv { gap: 8px; }
  .cv-board { flex-basis: 100%; padding: 6px 4px; }
  .cv-side { flex-basis: 100%; min-width: 0; gap: 8px; }
  .cv-moves { order: -1; display: flex; align-items: center; flex-wrap: nowrap; max-height: none; overflow-x: auto; overflow-y: hidden; padding: 6px; white-space: nowrap; line-height: 1.4; scrollbar-width: none; }
  .cv-moves::-webkit-scrollbar { display: none; }
  .cv-mv, .cv-no, .cv-res { flex: none; }
  .cv-mv { padding: 5px 8px; }
  .cv-comment { min-height: 0; padding: 9px 12px; font-size: 14px; }
}
