/* ================= Chess board + pieces — shared by the game (/covua/), game replays (/covua/van/<id>) and classic games (/covua/ky-pho/) =================
   Board / piece-set colours are set on :root by the game (main.js applyTheme); pages outside the game use the defaults below. */
:root {
  --light: #f0d9b5;
  --dark: #b58863;
  --pw: #fff;
  --pws: #1b1b1b;
  --pb: #1b1b1b;
  --pbs: #f2f2f2;
  --cl: #b58863;
  --cd: #f0d9b5;
  --fr1: #2b2116;
  --fr2: #4a3a26;
  --gw: none;
  --gb: none;
  --pwg: transparent;
  --pbg: transparent;
}

/* Bàn cờ: khung vuông, 4 lớp chồng nhau. container-type → cỡ quân theo bề rộng bàn (cqw). */
.board-wrap {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  container-type: inline-size;
  box-shadow: 0 0 0 6px var(--fr1), 0 0 0 7px var(--fr2), 0 16px 40px rgba(0, 0, 0, .55);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}
.board { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq { position: relative; min-width: 0; min-height: 0; background: var(--light); }
.sq.d { background: var(--dark); }
.sq .coord { position: absolute; font-size: 2.2cqw; font-weight: 800; opacity: .8; pointer-events: none; color: var(--cl); }
.sq.d .coord { color: var(--cd); }
.sq .coord.f { right: 4%; bottom: 2%; }
.sq .coord.r { left: 4%; top: 2%; }
.sq.last::after { content: ''; position: absolute; inset: 0; background: rgba(255, 214, 51, .42); }
.sq.sel::after { content: ''; position: absolute; inset: 0; background: rgba(75, 200, 120, .55); }
.sq.hover { box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .75); }
.sq.check::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 40, 40, .95) 0%, rgba(230, 20, 20, .6) 35%, transparent 72%);
  animation: checkPulse 1s ease-in-out infinite;
}
@keyframes checkPulse { 50% { opacity: .55; transform: scale(.92); } }
.sq .dot { position: absolute; left: 35%; top: 35%; width: 30%; height: 30%; border-radius: 50%; background: rgba(15, 30, 15, .3); z-index: 2; }
.sq .dot.faint { opacity: 0; }
.sq .ring { position: absolute; inset: 3%; border-radius: 50%; border: 0.8cqw solid rgba(15, 30, 15, .32); z-index: 2; }

.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.arw { stroke: rgba(40, 140, 255, .82); stroke-width: .17; stroke-linecap: round; }
.arw-h { fill: rgba(40, 140, 255, .82); }

.pieces { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.piece {
  position: absolute;
  left: 0;
  top: 0;
  width: 12.5%;
  height: 12.5%;
  display: grid;
  place-items: center;
  transition: transform .22s cubic-bezier(.25, .8, .3, 1);
  will-change: transform;
}
.piece.moving, .piece.dragging { z-index: 6; }
.piece.dragging { transition: none; filter: drop-shadow(0 10px 12px rgba(0, 0, 0, .45)); }
.pc {
  position: relative;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", "Apple Symbols", serif;
  font-size: 10.4cqw;
  line-height: 1;
  pointer-events: none;
}
.pc.w { color: var(--pw); text-shadow: 0 0 1px var(--pws), 1px 0 0 var(--pws), -1px 0 0 var(--pws), 0 1px 0 var(--pws), 0 -1px 0 var(--pws), 0 .5cqw .6cqw rgba(0, 0, 0, .35); }
.pc.b { color: var(--pb); text-shadow: 0 0 1px var(--pbs), 1px 0 0 var(--pbs), -1px 0 0 var(--pbs), 0 1px 0 var(--pbs), 0 -1px 0 var(--pbs), 0 .5cqw .6cqw rgba(0, 0, 0, .35); }
.piece.dying .pc { animation: die .38s ease-in forwards; }
@keyframes die { 30% { transform: scale(1.25) rotate(-8deg); } 100% { transform: scale(.1) rotate(35deg); opacity: 0; } }
.pc.promoted { animation: promo .5s ease-out; }
@keyframes promo { 0% { transform: scale(.4); filter: brightness(2.5); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }
.pc.shake { animation: shake .45s ease-in-out; }
@keyframes shake { 20%, 60% { transform: translateX(-7%) rotate(-6deg); } 40%, 80% { transform: translateX(7%) rotate(6deg); } }
.pc.toppled { animation: topple .7s cubic-bezier(.4, 0, .6, 1.4) forwards; }
@keyframes topple { 30% { transform: rotate(-12deg); } 100% { transform: rotate(90deg) translateX(18%); opacity: .75; } }

.fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.burst { position: absolute; width: 12.5%; height: 12.5%; }
.burst i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 9px;
  margin: -4.5px;
  border-radius: 50%;
  animation: spark .6s ease-out forwards;
}
.burst.bw i { background: radial-gradient(circle, #fff 0%, #ffe08a 60%, transparent 70%); }
.burst.bb i { background: radial-gradient(circle, #ffb36b 0%, #ff4d2e 60%, transparent 70%); }
.burst::before {
  content: '';
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  border: 3px solid rgba(255, 230, 150, .9);
  animation: ring .45s ease-out forwards;
}
@keyframes spark { 0% { transform: translate(0, 0) scale(1); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
@keyframes ring { 0% { transform: scale(.3); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
.sq.zone { box-shadow: inset 0 0 0 .55cqw rgba(255, 196, 0, .85); }
.sq.zone.d { box-shadow: inset 0 0 0 .55cqw rgba(255, 214, 80, .95); }
/* kiểu bộ quân: tô gradient · phát sáng · chữ cái · emoji có đĩa màu phe */
.pc.fx-grad.w, .pc.fx-grad.b {
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; text-shadow: none;
  filter: drop-shadow(0 .03em .04em rgba(0, 0, 0, .55));
}
.pc.fx-grad.w { background-image: var(--gw); -webkit-text-stroke: .02em var(--pws); }
.pc.fx-grad.b { background-image: var(--gb); -webkit-text-stroke: .02em var(--pbs); }
.pc.fx-glow.w { text-shadow: 0 0 1px var(--pws), 1px 0 0 var(--pws), -1px 0 0 var(--pws), 0 1px 0 var(--pws), 0 -1px 0 var(--pws), 0 0 .1em var(--pwg), 0 0 .22em var(--pwg); }
.pc.fx-glow.b { text-shadow: 0 0 1px var(--pbs), 1px 0 0 var(--pbs), -1px 0 0 var(--pbs), 0 1px 0 var(--pbs), 0 -1px 0 var(--pbs), 0 0 .1em var(--pbg), 0 0 .22em var(--pbg); }
.pc.gl-letter { font-family: "Arial Black", "Segoe UI", Roboto, Arial, sans-serif; font-weight: 900; }
.piece .pc.gl-letter { font-size: 8.4cqw; }
.pc.gl-emoji {
  display: grid; place-items: center; width: 1.3em; height: 1.3em; border-radius: 50%; text-shadow: none;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.piece .pc.gl-emoji { font-size: 7.2cqw; }
.pc.gl-emoji.w { background: radial-gradient(circle at 35% 30%, #ffffff, #d5dde8); box-shadow: inset 0 0 0 .07em #ffffff, 0 .06em .12em rgba(0, 0, 0, .45); }
.pc.gl-emoji.b { background: radial-gradient(circle at 35% 30%, #5a606c, #121419); box-shadow: inset 0 0 0 .07em #000, 0 0 0 .05em #c94a4a, 0 .06em .12em rgba(0, 0, 0, .45); }
/* cờ nổ */
.burst.atomic { width: 37.5%; height: 37.5%; margin: -12.5% 0 0 -12.5%; }
.burst.atomic::before { border-width: 6px; border-color: rgba(255, 140, 40, .95); }
.burst.atomic i { width: 14px; height: 14px; margin: -7px; }
.board-wrap.quake { animation: quake .35s ease-out; }
@keyframes quake { 20% { transform: translate(-4px, 2px); } 40% { transform: translate(4px, -2px); } 60% { transform: translate(-3px, -1px); } 80% { transform: translate(2px, 1px); } }

/* ---------- game viewer (js/viewer.js): replays + classic games ---------- */
.vw { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; margin: 18px 0; }
.vw-board { flex: 1 1 340px; max-width: 520px; padding: 7px; }
.vw-side { flex: 1 1 260px; min-width: 240px; display: flex; flex-direction: column; gap: 10px; }
.vw-nav { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.vw-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; }
.vw-nav button[data-v=play] { grid-column: span 2; }
.vw-nav button:disabled { opacity: .35; cursor: default; }
.vw-comment { min-height: 64px; padding: 12px 14px; border-radius: 14px; background: var(--panel, #151c26); line-height: 1.55; }
.vw-comment b { color: var(--accent, #ffd76a); margin-right: 4px; }
.vw-moves { max-height: 300px; 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; }
.vw-no { color: var(--muted, #93a3b8); margin: 0 2px 0 8px; font-size: 14px; }
.vw-mv { padding: 2px 7px; border: 0; border-radius: 7px; background: transparent; color: inherit; font: inherit; font-weight: 700; cursor: pointer; }
.vw-mv:hover { background: var(--panel-2, #1b2431); }
.vw-mv.cur { background: var(--accent, #ffd76a); color: #1c1608; }
.vw-mv i { font-style: normal; font-size: 11px; margin-left: 2px; }
.vw-res { margin-left: 8px; font-weight: 900; color: var(--accent, #ffd76a); }
.vw-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); }
button.cta { border: 0; font: inherit; cursor: pointer; }
