/* Chess — game styles */
:root {
  --sq-light: #b9bde6;
  --sq-dark: #6a70b4;
  --piece-font: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2", "DejaVu Sans", "Arial Unicode MS", serif;
}

.head-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.head-controls select { cursor: pointer; }

.chess-layout {
  display: grid; grid-template-columns: auto minmax(260px, 320px); gap: 22px;
  align-items: start; justify-content: center;
}
.board-col {
  --bw: min(560px, calc(100vw - 32px));
  width: var(--bw); min-width: 0;
}
@media (min-width: 901px) {
  .board-col { --bw: max(340px, min(560px, calc(100vh - 230px), calc(100vw - 420px))); }
}
@media (max-width: 900px) {
  .chess-layout { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 16px; }
  .side { width: 100%; max-width: 560px; }
}

/* ---- player bars ---- */
.player-bar {
  display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 4px 2px;
  font: 600 14px var(--font-display); color: var(--text); min-width: 0;
}
.player-bar .pdot { width: 14px; height: 14px; border-radius: 4px; flex: none; border: 1px solid var(--line); }
.player-bar .pdot.w { background: #f6f4ec; }
.player-bar .pdot.b { background: #15162b; border-color: #4a4f8a; }
.player-bar .pname { white-space: nowrap; }
.player-bar.turn .pname { color: var(--accent); }
.player-bar.turn .pdot { box-shadow: 0 0 0 2px var(--accent); }
.player-bar .caps {
  font-family: var(--piece-font); font-size: 17px; letter-spacing: -3px; line-height: 1;
  overflow: hidden; white-space: nowrap; text-overflow: clip; min-width: 0; flex: 0 1 auto;
}
.player-bar .caps .cw { color: #f6f4ec; text-shadow: 0 0 1px #000, 0 0 1px #000; }
.player-bar .caps .cb { color: #15162b; text-shadow: 0 0 1px #8a8fd0; }
.player-bar .adv { color: var(--muted); font-size: 13px; font-weight: 500; }
.player-bar .thinking { display: inline-flex; gap: 3px; margin-left: 2px; }
.player-bar .thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-2); animation: blink 1s infinite; }
.player-bar .thinking i:nth-child(2) { animation-delay: .15s; }
.player-bar .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

/* ---- board ---- */
.board-frame {
  padding: 0; border-radius: 12px; background: #2a2d5c;
  box-shadow: 0 0 0 1px var(--line), var(--shadow);
}
.board {
  width: var(--bw); height: var(--bw);
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  border-radius: 12px; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.sq { position: relative; display: grid; place-items: center; background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.last::before { content: ""; position: absolute; inset: 0; background: rgba(255, 204, 51, .42); }
.sq.sel::before { content: ""; position: absolute; inset: 0; background: rgba(79, 209, 197, .55); }
.sq.check::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle, rgba(255, 70, 90, .95) 0%, rgba(255, 70, 90, .55) 40%, rgba(255, 70, 90, 0) 72%);
}
.sq .coord {
  position: absolute; font: 700 calc(var(--bw) / 8 * .18) var(--font-display); pointer-events: none; z-index: 3; opacity: .85;
}
.sq .coord.rank { top: 3px; left: 4px; }
.sq .coord.file { bottom: 2px; right: 4px; }
.sq.light .coord { color: var(--sq-dark); }
.sq.dark .coord { color: var(--sq-light); }

.dot { position: absolute; z-index: 4; pointer-events: none; border-radius: 50%; }
.dot.move { width: 30%; height: 30%; background: rgba(20, 22, 50, .38); }
.dot.cap { inset: 4%; border: calc(var(--bw) / 8 * .08) solid rgba(20, 22, 50, .38); }
.sq.hover { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .7); }

.piece, .drag-ghost {
  font-family: var(--piece-font); font-size: calc(var(--bw) / 8 * .8); line-height: 1;
  position: relative; z-index: 5; pointer-events: none;
  transform: translateY(2%);
}
.piece.w, .drag-ghost.w {
  color: #fbfaf4;
  text-shadow: 1px 0 0 #1a1b33, -1px 0 0 #1a1b33, 0 1px 0 #1a1b33, 0 -1px 0 #1a1b33,
               1px 1px 0 #1a1b33, -1px -1px 0 #1a1b33, 1px -1px 0 #1a1b33, -1px 1px 0 #1a1b33,
               0 3px 5px rgba(0, 0, 0, .35);
}
.piece.b, .drag-ghost.b {
  color: #17182e;
  text-shadow: 0 0 1px rgba(255, 255, 255, .35), 0 3px 5px rgba(0, 0, 0, .35);
}
.piece.dragging { opacity: .25; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 100; margin: 0; transform: translate(-50%, -55%) scale(1.12); }
.board.locked .piece { cursor: default; }
.board:not(.locked) .sq.own { cursor: grab; }

/* ---- side ---- */
.side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.status { font: 700 20px var(--font-display); margin-bottom: 12px; }
.status.warn { color: var(--accent-3); }
.status.over { color: var(--accent); }
.note { margin: 10px 0 0; color: var(--muted); font-size: 13px; min-height: 1em; }
.note:empty { display: none; }

.moves-panel { padding: 14px 10px 10px 14px; }
.moves-head { display: flex; justify-content: space-between; font: 600 12px var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; padding-right: 6px; }
.moves {
  list-style: none; margin: 0; padding: 0 4px 0 0; max-height: 320px; overflow-y: auto;
  display: grid; grid-template-columns: 2.6em 1fr 1fr; row-gap: 2px;
  font: 500 14px var(--font-body); font-variant-numeric: tabular-nums;
}
@media (max-width: 900px) { .moves { max-height: 180px; } }
.moves li { display: contents; }
.moves .num { color: var(--muted); padding: 4px 0; }
.moves .mv { padding: 4px 8px; border-radius: 6px; }
.moves .mv.cur { background: var(--panel-2); color: var(--accent); font-weight: 700; }
.moves:empty::before { content: "No moves yet"; grid-column: 1 / -1; color: var(--muted); font-size: 13px; padding: 4px 0 8px; }

/* ---- modals ---- */
.promo-choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.promo-choices button {
  aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line); background: var(--sq-light); cursor: pointer;
  display: grid; place-items: center; padding: 0;
}
.promo-choices button:nth-child(even) { background: var(--sq-dark); }
.promo-choices button:hover { outline: 3px solid var(--accent); }
.promo-choices .piece { font-size: 46px; }
.btn-row.center { justify-content: center; }
.end-icon {
  width: 88px; height: 88px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, var(--sq-light), var(--sq-dark));
  box-shadow: 0 0 0 4px var(--panel-2), 0 8px 24px rgba(0,0,0,.35);
  font-family: var(--piece-font); font-size: 58px; line-height: 1;
}
.end-icon .piece { font-size: 58px; }
