/* ------------------------------------------------------------------
   PDX chess board (chessui.js, wave 12). DG//OS look, docs/STYLE-GUIDE.md:
   near-black panel, chamfers, mono labels, volt for you and the chosen
   piece, cyan for where it may go, hot for check and danger. Pieces are
   the solid Unicode glyphs, coloured: white ones pale with a dark edge,
   black ones dark with a pale edge, so both read on both squares.
   ------------------------------------------------------------------ */
.chess {
  --bs: min(calc(100vw - 40px), calc(100dvh - 350px), 420px);
  --c: 14px;
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: 8px; background: rgba(3, 4, 7, .78); overflow: auto;
  font-family: var(--font-mono);
}
.chess[hidden] { display: none; }
.chess-box {
  display: flex; flex-direction: column; gap: 12px; max-width: 100%;
  padding: 14px 12px; background: var(--panel); border: 1px solid var(--line-2);
  clip-path: polygon(0 0, calc(100% - var(--c)) 0, 100% var(--c), 100% 100%, var(--c) 100%, 0 calc(100% - var(--c)));
  color: var(--text);
}
.chess-left { display: flex; flex-direction: column; gap: 8px; }
.chess-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.chess-who { margin: 0; font: 700 14px/1.2 var(--font-display); letter-spacing: .06em; text-transform: uppercase; color: var(--volt); }
.chess-side { margin: 0; font: 500 11px/1.2 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.chess-label { margin: 0; font: 500 10px/1.2 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

.chess-board {
  flex: none; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); width: var(--bs); height: var(--bs);
  border: 1px solid var(--line-2); touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.chess-board.is-off { filter: saturate(.55) brightness(.85); }
.chess-sq { position: relative; overflow: hidden; min-height: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.chess-sq.is-light { background: #aab2cc; }
.chess-sq.is-dark { background: #5b6485; }
.chess-sq.is-last::before { content: ''; position: absolute; inset: 0; background: rgba(230, 255, 43, .38); }
.chess-sq.is-sel::before { content: ''; position: absolute; inset: 0; background: rgba(230, 255, 43, .8); }
.chess-sq.is-check::before { content: ''; position: absolute; inset: 0; background: rgba(255, 42, 109, .75); }
.chess-sq.is-cur { outline: 3px solid var(--cyan); outline-offset: -3px; z-index: 1; }
/* Where the picked-up piece may go: a square dot, or a corner-cut frame on a capture (no circles). */
.chess-sq.is-go::after { content: ''; position: absolute; width: 26%; height: 26%; background: rgba(5, 6, 10, .62); border: 2px solid var(--cyan); }
.chess-sq.is-cap::after { content: ''; position: absolute; inset: 0; border: 3px solid var(--hot); }
.chess-pc {
  position: relative; z-index: 1; font-size: calc(var(--bs) / 8 * .8); line-height: 1; pointer-events: none;
  font-family: 'Segoe UI Symbol', 'DejaVu Sans', 'Noto Sans Symbols 2', 'Apple Symbols', sans-serif;
}
.chess-pc.is-w { color: #fff; text-shadow: 1px 0 #0b0d14, -1px 0 #0b0d14, 0 1px #0b0d14, 0 -1px #0b0d14, 1px 1px #0b0d14, -1px -1px #0b0d14, 1px -1px #0b0d14, -1px 1px #0b0d14; }
.chess-pc.is-b { color: #0b0d14; text-shadow: 1px 0 #e6e9f5, -1px 0 #e6e9f5, 0 1px #e6e9f5, 0 -1px #e6e9f5; }
.chess-rank, .chess-file { position: absolute; z-index: 1; font: 700 9px/1 var(--font-mono); font-style: normal; opacity: .7; pointer-events: none; color: #0b0d14; }
.chess-rank { left: 2px; top: 2px; }
.chess-file { right: 2px; bottom: 2px; }

.chess-status { margin: 0; min-height: 2.6em; padding: 7px 9px; font: 600 12px/1.3 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--cyan); background: var(--bg-2); border-left: 3px solid var(--cyan); }
.chess-status.is-check, .chess-status.is-lose { color: var(--hot); border-color: var(--hot); }
.chess-status.is-win { color: var(--volt); border-color: var(--volt); }
.chess-promo, .chess-ask { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.chess-right { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chess-moves {
  list-style: none; margin: 0; padding: 6px 8px; height: 76px; overflow-y: auto; background: var(--bg-2); border: 1px solid var(--line);
  font: 500 12px/1.6 var(--font-mono); white-space: pre; columns: 2; column-gap: 12px;
}
.chess-moves b { color: var(--dim); font-weight: 500; }
.chess-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.chess-btn {
  --c: 8px; padding: 9px 12px; border: 0; cursor: pointer; background: var(--volt); color: #000;
  font: 700 11px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase;
  clip-path: polygon(0 0, calc(100% - var(--c)) 0, 100% var(--c), 100% 100%, var(--c) 100%, 0 calc(100% - var(--c)));
}
.chess-btn:hover { background: #fff; }
.chess-btn:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--volt), inset 0 0 0 6px #000; }
.chess-btn.is-hot { background: var(--hot); color: #000; }
.chess-btn.is-hot:hover { background: #fff; }
.chess-btn:disabled { opacity: .35; cursor: default; background: var(--line-2); }
.chess-keys { margin: 0; font: 500 10px/1.5 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
@media (pointer: coarse) { .chess-keys { display: none; } }

@media (min-width: 820px) and (min-height: 560px) {
  .chess { --bs: min(calc(100dvh - 190px), 600px); }
  .chess-box { flex-direction: row; gap: 18px; padding: 18px 20px; }
  .chess-right { width: 230px; }
  .chess-moves { height: auto; flex: 1; min-height: 120px; columns: 1; }
}
