/* ===== Chess (classic, flat) ===== */
.g-chess .chess-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
/* the move list scrolls inside its own box; it must never widen the layout (that pushed the board off screen mid-game) */
.g-chess .chess-main, .g-chess .chess-side { min-width: 0; }
@media (min-width: 1200px) { .g-chess .chess-wrap { grid-template-columns: minmax(0, 560px) minmax(220px, 1fr); align-items: start; } }
.g-chess .chess-main { display: grid; gap: 10px; justify-items: center; }
.g-chess .chess-main .prow { width: 100%; max-width: 560px; }
.g-chess .board { position: relative; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr));
  aspect-ratio: 1; width: min(100%, 560px, calc(100svh - 300px)); min-width: 280px; border-radius: 10px; overflow: hidden; user-select: none; -webkit-user-select: none; }
.g-chess .sq { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; }
.g-chess .sq.l { background: #ebecd0; }
.g-chess .sq.d { background: #779556; }
.g-chess .sq .co { position: absolute; font-size: 10px; font-weight: 700; pointer-events: none; }
.g-chess .sq.l .co { color: #779556; }
.g-chess .sq.d .co { color: #ebecd0; }
.g-chess .sq .co.f { right: 3px; bottom: 1px; }
.g-chess .sq .co.r { left: 3px; top: 1px; }
.g-chess .sq.last::before { content: ""; position: absolute; inset: 0; background: rgba(255, 255, 51, .42); }
.g-chess .sq.sel::before { content: ""; position: absolute; inset: 0; background: rgba(255, 255, 51, .6); }
.g-chess .sq.check::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(235, 40, 40, .95) 0%, rgba(235, 40, 40, .55) 40%, transparent 75%); }
.g-chess .sq.tgt.mv::after { content: ""; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(0, 0, 0, .18); pointer-events: none; }
.g-chess .sq.tgt.cap::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 5px rgba(0, 0, 0, .18); pointer-events: none; }
.g-chess .sq[data-a] { cursor: pointer; }
.pz { width: 90%; height: 90%; position: relative; z-index: 2; pointer-events: none; transition: transform .15s var(--ease-out); overflow: visible; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, .25)); }
.pz path, .pz circle { stroke-linejoin: round; stroke-linecap: round; }
.pz.w { fill: #ffffff; stroke: #2a2a2a; stroke-width: 1.5; }
.pz.b { fill: #2a2a2a; stroke: #111; stroke-width: 1.5; }
.pz .ln { fill: none; }
.pz.w .ln { stroke: #2a2a2a; }
.pz.b .ln { stroke: #e8e8e8; stroke-width: 1.2; }
.pz .ln.thick { stroke-width: 2.2; }
.pz.w .eye { fill: #2a2a2a; stroke: none; }
.pz.b .eye { fill: #e8e8e8; stroke: none; }
.g-chess .sq.sel .pz { transform: scale(1.06); }
.pz.mini { width: 15px; height: 15px; margin-right: -4px; filter: none; vertical-align: middle; }
.taken { display: inline-flex; margin-left: 6px; vertical-align: middle; }
.g-chess .chess-side .status-line { text-align: left; font-size: 14px; margin: 0; }
.g-chess .moves { min-width: 0; max-width: 100%; display: flex; gap: 6px 14px; overflow-x: auto; white-space: nowrap; padding: 10px 12px; margin-top: 8px; border-radius: 12px; background: var(--panel-2);
  font-size: 13px; font-weight: 600; color: var(--muted); scrollbar-width: none; }
@media (min-width: 1200px) { .g-chess .moves { flex-wrap: wrap; white-space: normal; max-height: 380px; overflow-y: auto; } }
.g-chess .moves span b { color: var(--dim); margin-right: 6px; }
.g-chess .moves span:last-child { color: #fff; }
.promo { display: flex; justify-content: center; gap: 8px; margin-top: 18px; }
.promo button { width: 68px; height: 68px; border-radius: 14px; display: grid; place-items: center; background: #ebecd0; }
.promo button:hover { background: #f6f7e6; }
.promo .pz { width: 54px; height: 54px; }

/* one screen: the board takes whatever height is left after the two player rows */
body.in-game .g-chess .chess-wrap { height: 100%; gap: 6px; align-content: start; }
body.in-game .g-chess .chess-main { gap: 6px; }
body.in-game .g-chess .board { width: min(100%, calc(var(--app-h, 100svh) - 262px)); min-width: 0; }
body.in-game .g-chess .chess-side .status-line { text-align: center; }
body.in-game .g-chess .moves { margin-top: 4px; padding: 6px 10px; }
@media (max-width: 1199px) { body.in-game .g-chess .chess-side .t-micro { display: none; } }

/* wide screens (desktop / full screen): a big centred board with the players above and below,
   status and the move list in a fixed side panel next to it */
@media (min-width: 900px) {
  body.in-game .g-chess { --bs: min(calc(var(--app-h, 100svh) - 210px), calc(100vw / var(--ui-z, 1) - 480px), 820px); }
  body.in-game .g-chess .chess-wrap { grid-template-columns: var(--bs) 300px; justify-content: center; align-content: center; align-items: center; gap: 24px; }
  body.in-game .g-chess .chess-main { gap: 8px; }
  body.in-game .g-chess .chess-main .prow { width: var(--bs); max-width: none; }
  body.in-game .g-chess .board { width: var(--bs); border-radius: 12px; }
  body.in-game .g-chess .sq .co { font-size: 12px; }
  body.in-game .g-chess .chess-side { display: flex; flex-direction: column; height: calc(var(--bs) + 112px); min-height: 0; padding: 18px; border-radius: 18px; background: var(--panel-2); }
  body.in-game .g-chess .chess-side .status-line { text-align: left; font-size: 16px; min-height: 22px; }
  body.in-game .g-chess .chess-side .t-micro { display: block; margin: 16px 0 8px !important; }
  body.in-game .g-chess .moves { flex: 1; min-height: 0; max-height: none; margin: 0; padding: 6px; display: grid; grid-template-columns: 1fr; grid-auto-rows: max-content; gap: 2px;
    overflow-y: auto; white-space: normal; background: rgba(0, 0, 0, .22); font-size: 14px; scrollbar-width: thin; }
  body.in-game .g-chess .moves span { padding: 6px 10px; border-radius: 8px; }
  body.in-game .g-chess .moves span:nth-child(odd) { background: rgba(255, 255, 255, .035); }
  body.in-game .g-chess .moves span b { display: inline-block; min-width: 26px; }
}
