/* =========================================================
   Chess Nora (chess.html) — board, pieces, side panels
   The board colours and the piece colours come from js/chess.js
   as --sq-light / --sq-dark / --pw / --pb.
   ========================================================= */
.chess-stage { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.chess-players { display: flex; flex-direction: column; gap: 6px; width: min(100%, 560px); font-size: 0.92rem; }
.chess-players > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 26px; }
.chess-taken { display: flex; align-items: center; --pw: #fdfaf2; --pb: #22201d; }
.chess-taken .pc { width: 20px; height: 20px; margin-left: -7px; filter: none; }
.chess-taken .pc--letter { width: 18px; height: 18px; font-size: max(12px, 10px); margin-left: 2px; box-shadow: none; }
.chess-taken b { margin-left: 6px; font-size: 0.8rem; color: var(--muted); }
.chess-defs { position: absolute; }
.chess-board-wrap { position: relative; width: min(100%, 560px); container-type: inline-size; }
.chess-board {
  /* 8 equal columns AND 8 equal rows: without the rows, empty ranks were squeezed thinner than ranks with pieces */
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); aspect-ratio: 1; width: 100%;
  border-radius: 10px; overflow: hidden; border: 3px solid var(--border); user-select: none;
}
.sq { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 0; cursor: pointer; font: inherit; }
.sq--light { background: var(--sq-light); }
.sq--dark { background: var(--sq-dark); }
.sq.is-last { background-image: linear-gradient(rgba(255, 221, 51, 0.38), rgba(255, 221, 51, 0.38)); }
.sq.is-selected { background-image: linear-gradient(rgba(60, 170, 255, 0.45), rgba(60, 170, 255, 0.45)); }
.sq.is-check { background-image: linear-gradient(rgba(230, 40, 40, 0.55), rgba(230, 40, 40, 0.55)); }
.sq.is-target::after { content: ""; position: absolute; width: 28%; height: 28%; border-radius: 50%; background: rgba(0, 0, 0, 0.28); }
.sq.is-capture::after { content: ""; position: absolute; inset: 6%; border-radius: 50%; border: 0.5cqw solid rgba(0, 0, 0, 0.32); }
.sq:focus-visible { outline: 3px solid var(--primary); outline-offset: -3px; z-index: 1; }
.sq-rank, .sq-file { position: absolute; font-style: normal; font-size: max(9px, 2cqw); font-weight: 700; opacity: 0.6; color: #222; pointer-events: none; }
.sq-rank { top: 2px; left: 3px; }
.sq-file { bottom: 1px; right: 3px; }

/* Pieces: our own drawings (js/chess.js), filled with the chosen colours */
.pc { display: block; width: 84%; height: 84%; pointer-events: none; overflow: visible; transition: translate 0.2s cubic-bezier(0.3, 0.7, 0.3, 1); }
.pc-shade { fill: url(#pcShade); stroke: none; pointer-events: none; }  /* rounded look: light from the left */
.pc--outline .pc-shade { display: none; }
@media (prefers-reduced-motion: reduce) { .pc { transition: none; } }
.pc-body { stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.pc-line { fill: none; stroke-width: 1.5; stroke-linecap: round; }
.pc--w .pc-body { fill: var(--pw); stroke: #1c1c1f; }
.pc--w .pc-line { stroke: #1c1c1f; }
.pc--b .pc-body { fill: var(--pb); stroke: #000; }
.pc--b .pc-line { stroke: rgba(255, 255, 255, 0.75); }
.pc { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35)); }
.pc--outline .pc-body { fill-opacity: 0.18; stroke-width: 2.4; }
.pc--outline.pc--w .pc-body { stroke: var(--pw); fill: var(--pw); paint-order: stroke; filter: drop-shadow(0 0 1px #000); }
.pc--outline.pc--b .pc-body { stroke: var(--pb); fill: var(--pb); filter: drop-shadow(0 0 1px #fff); }
.pc--letter {
  display: grid; place-items: center; width: 8.4cqw; height: 8.4cqw; border-radius: 50%;
  font: 800 4.6cqw/1 Inter, sans-serif; text-shadow: none;
}
.pc--letter.pc--w { background: var(--pw); color: var(--pb); box-shadow: 0 0 0 0.4cqw var(--pb); }
.pc--letter.pc--b { background: var(--pb); color: var(--pw); box-shadow: 0 0 0 0.4cqw var(--pw); }

/* 3D view: the board leans back and the pieces stand up on it */
.chess-board-wrap.is-3d { perspective: 1100px; margin: -6% 0 -3%; }
.is-3d .chess-board { transform: rotateX(46deg); transform-style: preserve-3d; overflow: visible; border-width: 6px; box-shadow: 0 26px 30px -12px rgba(0, 0, 0, 0.55); }
.is-3d .sq { overflow: visible; transform-style: preserve-3d; }
.is-3d .pc { transform-origin: 50% 92%; transform: rotateX(-46deg) scale(1.22); filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.45)); }
.is-3d .sq-rank, .is-3d .sq-file { opacity: 0.45; }
/* each standing piece throws a soft shadow on its square */
.is-3d .sq:has(.pc)::before {
  content: ""; position: absolute; left: 22%; right: 6%; bottom: 8%; height: 34%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0)); transform: skewX(-24deg); pointer-events: none;
}
.chess-board-wrap:not(.is-3d) .pc { filter: drop-shadow(0 2px 1.5px rgba(0, 0, 0, 0.4)); }

.chess-promo {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3;
  display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  --pw: #fdfaf2; --pb: #22201d;
}
.chess-promo .pc { width: 2.4rem; height: 2.4rem; }
.chess-promo .pc--letter { width: 2rem; height: 2rem; font-size: 1.1rem; }
.chess-status { margin: 0; min-height: 1.5em; font-weight: 700; text-align: center; }
.chess-actions { justify-content: center; }

.chess-elo { margin: 0; font-size: 2.4rem; font-weight: 800; color: var(--primary-text); line-height: 1.1; }
.chess-moves { margin: 0; padding: 0; list-style: none; max-height: 190px; overflow: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; font-variant-numeric: tabular-nums; font-size: 0.92rem; }
.chess-top li { justify-content: space-between; }
.chess-dot { display: inline-block; width: 14px; height: 14px; margin-right: 6px; border-radius: 4px; vertical-align: -2px; border: 1px solid rgba(0, 0, 0, 0.25); }
#chessSetup .panel-title:not(:first-child) { margin-top: 16px; }
#chessSetup .field-label { margin: 10px 0 6px; }

/* Theatre / full screen: the board takes the room */
body.theatre-mode .chess-board-wrap, #chessStage:fullscreen .chess-board-wrap { width: min(100%, 86vh); }
#chessStage:fullscreen { justify-content: center; background: var(--bg); }

/* The game keeps its own small effects even on Low graphics (which switches off movement and shadows everywhere else) */
:root[data-gfx] .chess-board .pc { transition: translate 0.2s cubic-bezier(0.3, 0.7, 0.3, 1) !important; }
:root[data-gfx] .is-3d .chess-board { box-shadow: 0 26px 30px -12px rgba(0, 0, 0, 0.55) !important; }

/* Playing another person (js/chess-pvp.js) */
.chess-pvp { display: flex; flex-direction: column; gap: 10px; }
.chess-pvp > p { margin: 0; }
.pvp-row { display: flex; gap: 8px; align-items: center; }
.pvp-row input { flex: 1; min-width: 0; }
.pvp-turn { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 700; }
.pvp-clock { font-variant-numeric: tabular-nums; color: var(--primary-text); white-space: nowrap; }
.pvp-clock--big { font-size: 1.5rem; }
.pvp-clock.is-low { color: #ff5c7a; animation: pulse-text 1s infinite; }
.pvp-skips { font-style: normal; font-size: 0.82rem; color: var(--muted); }
.pvp-offer { font-weight: 700; color: var(--accent-strong); }
.pvp-ban { font-weight: 700; color: #ff5c7a; }
.pvp-wait { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.pvp-dots { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); animation: pulse-text 1s infinite; }
.pvp-top-title { margin-top: 8px; }
.pvp-top li { display: block; }
.pvp-who { display: flex; align-items: center; gap: 10px; width: 100%; padding: 4px 6px; border: 0; border-radius: 10px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.pvp-who > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pvp-who:hover, .pvp-who.is-active { background: var(--surface-2); }
.pvp-games { margin: 4px 0 8px; padding: 0 0 0 34px; list-style: none; font-size: 0.88rem; display: grid; gap: 4px; }
.pvp-games small { display: block; color: var(--muted); }
