:root {
  /* Board colors */
  --board-light: #e7d5b5;
  --board-dark: #be9b72;
  --select-border-color: rgba(95, 95, 95, 0.9);
  --select-color: rgba(15, 110, 58, 0.9);
  --last-move-color-border: rgba(18, 74, 18, 0.9);
  --last-move-color-background: rgba(94, 171, 98, 0.471);
  --last-move-stripe-soft: rgba(150, 150, 150, 0.332);
  --last-move-stripe-dark: #3c3b3b7a;
  --valid-move-highlight: #5656563a;
  
  /* Arrows & markers */
  --arrow-thickness: calc(var(--board-size) * 0.021);
  --arrow-color: #16a34a;
  --ctrl-arrow-color: #bd1818;
  --ctrl-circle-color-rgb: 210, 70, 70;
  --shift-arrow-color: rgb(var(--shift-circle-color-rgb));
  --circle-color-rgb: 38, 128, 79;
  --shift-circle-color-rgb: 36, 84, 132;
  --dotted-line-color-0: #d94a4a;
  --dotted-line-color-1: #2c9a62;
  --dotted-line-color-2: #2f7fbc;
  --sq-bg-fill-green: rgba(22, 163, 74, 0.571);
  --sq-bg-fill-red: rgba(239, 68, 68, 0.678);
  --sq-bg-fill-yellow: rgba(229, 176, 19, 0.84);
  --sq-bg-fill-blue: rgba(37, 99, 235, 0.62);
  --sq-bg-fill-purple: rgba(168, 85, 247, 0.58);
  --sq-bg-fill-neon: #22d3ee;

  /* Board sizing */
  --board-size: min(87vw, 75vh, 500px);
  --board-padding: 4px;
  --coord-size: calc(var(--board-size) * 0.018);

  /* Navigation sizes */
  --nav-btn-width: 50px;
  --nav-btn-size: calc(var(--board-size) * 0.09);
  --nav-btn-height: 30px;
  --nav-gap: 4px;
  --top-row-captures-width: 80%;
  --top-row-nav-width: 19%;
  --top-row-gap: 1%;

  /* Captures */
  --capture-piece-size: calc(var(--board-size) * 0.022);
  --points-size: calc(var(--board-size) * 0.029);
}

/* Board themes */
[data-theme="green"] {
  --board-light: #e7e8ce;
  --board-dark: #759654;
  --select-color: #c9ffa0;
  --last-move-color-border: rgba(94, 94, 89, 0.95);
  --last-move-color-background: rgba(123, 168, 0, 0.407);
  --arrow-color: #2d7f43;
  --circle-color-rgb: 50, 112, 57;
  --shift-circle-color-rgb: 43, 101, 145;
  --dotted-line-color-0: #cb4b4b;
  --dotted-line-color-1: #2f8d53;
  --dotted-line-color-2: #2d72a8;
  --sq-bg-fill-green: rgb(160, 235, 48);
  --sq-bg-fill-yellow: rgba(255, 227, 13, 0.836);
  --sq-bg-fill-neon: #7cffb2;
}

[data-theme="blue"] {
  --board-light: #c3d2d8;
  --arrow-color: #2f7a55;
  --board-dark: #5383a1;
  --select-color: #65d8f1;
  --last-move-color-border: rgba(64, 153, 255, 0.85);
  --last-move-color-background: rgba(173, 211, 255, 0.562);
  --circle-color-rgb: 39, 116, 79;
  --ctrl-circle-color-rgb: 153, 16, 12;
  --shift-circle-color-rgb: 39, 88, 167;
  --dotted-line-color-0: #c84e5e;
  --dotted-line-color-1: #2f8f67;
  --dotted-line-color-2: #2f77b9;
  --sq-bg-fill-yellow: rgba(234, 179, 8, 0.45);
  --sq-bg-fill-neon: #7dd3fc;
}

/* ========================================================
   CHESSBOARD LAYOUT
   ======================================================== */

.chess-wrapper { 
  position: relative; 
  display: flex; 
  justify-content: center; 
}

#board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  border-radius: 0 0 4px 4px;
  touch-action: none;  /* prevent scroll during pointer drag on touch devices */
}

.board-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: var(--board-size);
  padding: 8px 0;
}

.main-chess-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.board-container {
  width: var(--board-size);
  height: var(--board-size);
  position: relative;
  display: inline-block;
}

.daily-game-over-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-9deg) scale(0.92);
  z-index: 30;
  border: 2px solid rgba(127, 29, 29, 0.92);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: clamp(14px, 2.7vw, 18px);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff5f5;
  background: linear-gradient(135deg, rgba(190, 18, 60, 0.97) 0%, rgba(127, 29, 29, 0.97) 100%);
  box-shadow:
    0 14px 28px rgba(15, 23, 42, 0.45),
    0 0 0 3px rgba(255, 255, 255, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: transform 260ms ease, opacity 260ms ease;
}

.daily-game-over-badge.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) rotate(-9deg) scale(1);
}

.daily-game-over-badge:active {
  transform: translate(-50%, -50%) rotate(-9deg) scale(1);
}

/* Illegal move badge: quick, non-blocking board feedback tied to error sound */
.illegal-move-badge {
  position: fixed;
  z-index: 9605;
  transform: translate(-50%, -50%);
  pointer-events: none;
  user-select: none;
  padding: 5px 9px 6px;
  border-radius: 4px;
  border: 1px solid rgba(96, 22, 22, 0.9);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.04) 36%, rgba(255, 255, 255, 0) 100%),
    linear-gradient(140deg, rgba(165, 34, 34, 0.97) 0%, rgba(110, 22, 22, 0.97) 52%, rgba(82, 17, 17, 0.97) 100%);
  color: #fff6eb;
  font-family: "Palatino Linotype", "Book Antiqua", Garamond, serif;
  font-size: clamp(10px, 1.45vw, 12px);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-shadow: 0 1px 1px rgba(58, 12, 12, 0.85);
  box-shadow:
    0 8px 16px rgba(17, 24, 39, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(56, 14, 14, 0.3);
  opacity: 0;
  white-space: nowrap;
}

.illegal-move-badge.is-active {
  animation: illegalMoveBadgeFloat 1240ms cubic-bezier(0.2, 0.86, 0.28, 1) forwards;
}

@keyframes illegalMoveBadgeFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, -42%) scale(0.92);
    filter: blur(0.25px);
  }
  12% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    filter: blur(0);
  }
  72% {
    opacity: 1;
    transform: translate(-50%, -94%) scale(1.02);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -126%) scale(1.04);
  }
}

@media (prefers-reduced-motion: reduce) {
  .illegal-move-badge.is-active {
    animation: illegalMoveBadgeFade 720ms linear forwards;
  }
}

@keyframes illegalMoveBadgeFade {
  0% {
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.square {
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 0.2px 0 rgba(255, 255, 255, 0.3),
    inset 0 0.2px 0.2px 0.1px rgba(0, 0, 0, 0.08);
  position: relative;
}

.square.admin-square-target {
  background-image: radial-gradient(circle, rgba(251, 191, 36, 0.55) 0%, rgba(251, 191, 36, 0.18) 70%, transparent 100%);
  box-shadow:
    inset 0 0 0 4px rgba(245, 158, 11, 1),
    inset 0 0 0 8px rgba(251, 191, 36, 0.4),
    0 0 12px 4px rgba(251, 191, 36, 0.7),
    0 0 0 2px rgba(180, 110, 0, 0.5);
  animation: admin-square-pulse 1s ease-in-out infinite alternate;
}

@keyframes admin-square-pulse {
  from {
    box-shadow:
      inset 0 0 0 4px rgba(245, 158, 11, 1),
      inset 0 0 0 8px rgba(251, 191, 36, 0.4),
      0 0 10px 3px rgba(251, 191, 36, 0.6),
      0 0 0 2px rgba(180, 110, 0, 0.5);
  }
  to {
    box-shadow:
      inset 0 0 0 4px rgba(245, 158, 11, 1),
      inset 0 0 0 8px rgba(251, 191, 36, 0.5),
      0 0 20px 8px rgba(251, 191, 36, 0.85),
      0 0 0 2px rgba(180, 110, 0, 0.6);
  }
}

.square.challenge-square-picked {
  box-shadow:
    inset 0 0 0 3px rgba(34, 197, 94, 0.92),
    inset 0 0 0 6px rgba(34, 197, 94, 0.24);
}

.square.challenge-square-selected {
  box-shadow:
    inset 0 0 0 3px rgba(59, 130, 246, 0.94),
    inset 0 0 0 6px rgba(59, 130, 246, 0.22);
}

.light {
  background-color: var(--board-light);
  background-image:
    radial-gradient(ellipse 40% 30% at 20% 20%, rgba(255, 255, 255, 0.08) 0%, transparent 70%),
    linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.025) 100%);
}

.dark {
  background-color: var(--board-dark);
  background-image:
    radial-gradient(ellipse 30% 20% at 80% 80%, rgba(255, 255, 255, 0.04) 0%, transparent 80%),
    linear-gradient(to top, transparent 0%, rgba(255, 255, 255, 0.03) 40%);
}

/* CHESSBOARD COORDINATES */

.board-with-coords {
  display: flex;
  align-items: stretch;
  height: var(--board-size);
  max-width: var(--board-size);
  position: relative; 
}

.board-coords-container {
  display: flex;
  flex-direction: column;
  justify-content: stretch;
}

.board-with-coords,
.board-coords-container,
#board,
.coord-left,
.coord-bottom,
.coordinates {
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
}

.coord-left {
  position: absolute;
  top: 4%;
  left: 6%;
  font-size: 1em;
  font-weight: 600;
  color: var(--coord-color);
  pointer-events: none;
  z-index: 2;
}

.coord-bottom {
  position: absolute;
  bottom: 2%;
  right: 6%;
  font-size: 1em;
  font-weight: 600;
  color: var(--coord-color);
  pointer-events: none;
  z-index: 2;
}

/* IN-SQUARE COORDINATES */

.coordinates {
  position: absolute;
  top: 2px;
  left: 2px;
  font-size: .6em;
  color: rgba(0,0,0,0.5);
  pointer-events: none;
  z-index: 1;
  font-weight: bold;
  display: none;
}

.square.dark .coordinates { 
  color: rgba(255,255,255,0.7); 
}

[data-mode="light"] .coordinates { 
  color: rgba(0,0,0,0.6); 
}

[data-mode="light"] .square.dark .coordinates { 
  color: rgba(255,255,255,0.8); 
}

.board-with-coords {
  display: flex;
  align-items: stretch;
  height: var(--board-size);
  max-width: var(--board-size);
  position: relative; 
}

.board-coords-container {
  display: flex;
  flex-direction: column;
  justify-content: stretch;
}

/* ========================================================
   CHESS PIECES
   ======================================================== */

.piece {
  width: 85%;
  height: 85%;
  object-fit: contain;
  cursor: grab;
  user-select: none;
  /* No transition here — transitions on individual pieces caused a visible
     200ms "catch-up" delay on pickup. Animated moves use clones with their
     own transitions instead. */
}

.piece:active { 
  cursor: grabbing;
}

.piece[data-piece-type="pawn"] { width: 75%; height: 75%; }

.piece.piece-board-reset-fly-in {
  --board-reset-origin-x: 0px;
  --board-reset-origin-y: -80px;
  --board-reset-rotation: 0deg;
  --board-reset-delay: 0ms;
  --board-reset-duration: 760ms;
  animation: board-reset-piece-fly-in var(--board-reset-duration) cubic-bezier(0.17, 0.84, 0.24, 1) var(--board-reset-delay) both;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.28));
}

@keyframes board-reset-piece-fly-in {
  0% {
    transform: translate(var(--board-reset-origin-x), var(--board-reset-origin-y)) rotate(var(--board-reset-rotation)) scale(0.4);
    opacity: 0;
  }
  64% {
    transform: translate(0, -2px) rotate(0deg) scale(1.06);
    opacity: 1;
  }
  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
}

.challenge-move-result-icon {
  position: absolute;
  top: 8%;
  right: 8%;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px) scale(0.9);
  transition: opacity 180ms ease, transform 180ms ease;
}

.challenge-move-result-icon.is-clickable {
  pointer-events: auto;
  cursor: pointer;
  z-index: 45;
}

.challenge-move-result-icon.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.challenge-move-result-icon.is-correct {
  background: rgba(22, 163, 74, 0.9);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(5, 92, 45, 0.45);
}

.challenge-move-result-icon.is-wrong {
  width: 24px;
  height: 24px;
  font-size: 15px;
  font-weight: 900;
  background: rgba(220, 38, 38, 0.9);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(110, 14, 14, 0.45);
}

.square.challenge-target-hit {
  position: relative;
}

.square.challenge-target-hit::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 10px;
  border: 2px solid rgba(34, 197, 94, 0.75);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: challengeTargetHitPulse 560ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  pointer-events: none;
  z-index: 25;
}

.challenge-target-hit-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin-left: -29px;
  margin-top: -29px;
  pointer-events: none;
  z-index: 30;
  opacity: 0;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 0%, rgba(250, 204, 21, 0.95) 0 3px, transparent 4px),
    radial-gradient(circle at 100% 50%, rgba(250, 204, 21, 0.95) 0 3px, transparent 4px),
    radial-gradient(circle at 50% 100%, rgba(250, 204, 21, 0.95) 0 3px, transparent 4px),
    radial-gradient(circle at 0% 50%, rgba(250, 204, 21, 0.95) 0 3px, transparent 4px),
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.95) 0 2px, transparent 3px),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.95) 0 2px, transparent 3px),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.95) 0 2px, transparent 3px),
    radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.95) 0 2px, transparent 3px);
  animation: challengeTargetHitBurst 620ms cubic-bezier(0.16, 0.84, 0.24, 1) forwards;
}

@keyframes challengeTargetHitPulse {
  0% {
    transform: scale(0.82);
    opacity: 0.95;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  }
  70% {
    transform: scale(1.03);
    opacity: 0.78;
    box-shadow: 0 0 0 10px rgba(34, 197, 94, 0.05);
  }
  100% {
    transform: scale(1.07);
    opacity: 0;
    box-shadow: 0 0 0 14px rgba(34, 197, 94, 0);
  }
}

@keyframes challengeTargetHitBurst {
  0% {
    transform: scale(0.45) rotate(-12deg);
    opacity: 0;
  }
  20% {
    transform: scale(0.9) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: scale(1.18) rotate(12deg);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .square.challenge-target-hit::after,
  .challenge-target-hit-burst {
    animation: none;
    opacity: 0;
  }
}

.square:has(img.piece) { cursor: grab !important; }
.square:has(img.piece):active,
.square.selected:has(img.piece) { cursor: grabbing !important; }

/* Keep drag cursor invalidation board-scoped; a universal descendant rule
   forces a full-page style rematch on every pickup and drop. */
body.piece-dragging,
body.piece-dragging #board,
body.piece-dragging #board .square,
body.piece-dragging #board .piece,
body.piece-dragging .piece-drag-clone {
  cursor: grabbing !important;
}

img.piece {
  position: relative;
  z-index: 10;
}

.piece-drag-clone {
  animation: none !important;
  filter: none !important;
  opacity: 1 !important;
  transform-origin: center center;
}

@media (prefers-reduced-motion: reduce) {
  .piece.piece-board-reset-fly-in {
    animation: none;
  }
}

/* BOARD OVERLAY */
#board-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 12100;
}

#board-overlay.daily-board-loading-active {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 252, 0.52);
  backdrop-filter: blur(1.5px);
}

.daily-board-loading-mask {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.96);
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.board-reset-btn {
  position: absolute;
  right: 0;
  bottom: -34px;
  z-index: 30;
  border: 1px solid rgba(17, 24, 39, 0.18);
  background: rgba(255, 255, 255, 0.94);
  color: #374151;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
}

.board-reset-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 1);
}

/* ========================================================
   PIECE PROMOTION MODAL
   ======================================================== */

.promotion-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(11, 157, 111, 0.9);
  padding: 20px;
  border-radius: 12px;
  backdrop-filter: blur(5px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  z-index: 10001;
}

.promotion-options {
  display: flex;
  gap: 10px;
}

.promotion-options img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  border: 3px solid transparent;
}

.promotion-options img:hover {
  transform: scale(1.1);
  border-color: #ffd966;
  box-shadow: 0 0 20px rgba(255, 215, 102, 0.5);
}

/* ========================================================
   PROMOTION FLOURISH
   ======================================================== */

/* floating badge */
.promotion-badge {
  position: absolute;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px 5px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.32);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.7);
  opacity: 0;
  backdrop-filter: blur(4px);
  white-space: nowrap;
}

.promotion-badge__symbol {
  font-size: 16px;
  line-height: 1;
}

.promotion-badge__label {
  font-size: 11px;
  line-height: 1;
}

.promotion-badge--white {
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.95), rgba(234, 179, 8, 0.9));
  color: #1a1a0a;
}

.promotion-badge--black {
  background: linear-gradient(135deg, rgba(109, 40, 217, 0.95), rgba(67, 20, 140, 0.92));
  color: #f5f0ff;
}

.promotion-badge.is-active {
  animation: promotionBadgeRise 1050ms cubic-bezier(0.18, 0.85, 0.22, 1) forwards;
}

@keyframes promotionBadgeRise {
  0% {
    left: var(--promo-cx);
    top:  var(--promo-cy);
    transform: translate(-50%, -50%) scale(0.7);
    opacity: 0;
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
  55% {
    left: var(--promo-cx);
    top:  calc(var(--promo-cy) - 46px);
    transform: translate(-50%, -50%) scale(1.0);
    opacity: 1;
  }
  100% {
    left: var(--promo-cx);
    top:  calc(var(--promo-cy) - 60px);
    transform: translate(-50%, -50%) scale(0.92);
    opacity: 0;
  }
}

/* burst ring */
.promotion-burst {
  position: absolute;
  z-index: 49;
  width: 0;
  height: 0;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
}

.promotion-burst--white {
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.9), 0 0 0 6px rgba(250, 204, 21, 0.4);
}

.promotion-burst--black {
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.9), 0 0 0 6px rgba(139, 92, 246, 0.4);
}

.promotion-burst.is-active {
  animation: promotionBurst 650ms cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}

@keyframes promotionBurst {
  0% {
    width: 0;
    height: 0;
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
  }
  60% {
    opacity: 0.7;
  }
  100% {
    width: 90px;
    height: 90px;
    transform: translate(-50%, -50%) scale(1);
    opacity: 0;
  }
}

/* piece glow after promotion */
.piece.promotion-piece-flare {
  animation: promotionPieceFlare 860ms cubic-bezier(0.18, 0.8, 0.28, 1);
  filter: drop-shadow(0 0 10px rgba(250, 204, 21, 0.95)) drop-shadow(0 0 20px rgba(250, 204, 21, 0.5));
}

@keyframes promotionPieceFlare {
  0%   { transform: scale(1.0); }
  30%  { transform: scale(1.22) rotate(2deg); }
  60%  { transform: scale(1.10) rotate(-1deg); }
  100% { transform: scale(1.0) rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
  .promotion-badge.is-active,
  .promotion-burst.is-active,
  .piece.promotion-piece-flare {
    animation: none;
    opacity: 0;
  }
}

/* ========================================================
   SELECTION, MOVES AND HIGHLIGHTS
   ======================================================== */

#board.piece-selected .square:hover::after,
.square.selected::after {
  content: "";
  position: absolute;
  inset: 1px;
  border: 3.5px solid var(--select-border-color);
  pointer-events: none;
  border-radius: 0;
  mask:
    linear-gradient(90deg, transparent 0 20%, #000 20% 80%, transparent 80% 100%),
    linear-gradient(0deg, transparent 0 20%, #000 20% 80%, transparent 80% 100%);
  mask-composite: exclude;
}

.last-move {
  background:
    repeating-linear-gradient(
      45deg,
      var(--last-move-color-background) 0px,
      var(--last-move-color-background) 9px,
      var(--last-move-stripe-soft) 9px,
      var(--last-move-stripe-dark) 10px
    );
  background-size: 20px 20px;
}

.move-highlight::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(35%);
  height: calc(35%);
  border-radius: 50%;
  background: var(--valid-move-highlight);
  z-index: 12;
  pointer-events: none;
}

.move-highlight:hover {
  cursor: pointer;
}


/* ========================================================
   DRAWING TOOLS - ARROWS AND CIRCLES AND IMAGES
   ======================================================== */

.chess-emoji {
  width: 100%;
  height: 100%;
}

/* ========================================================
   EMOJI PICKER MODAL
   ======================================================== */

.emoji-picker-modal {
  position: fixed;
  background: #222;
  color: #e8e8e8;
  border: 1px solid #444;
  border-radius: 10px;
  padding: 12px;
  z-index: 10000;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.7);
  width: 276px;
  display: none;
  user-select: none;
}
.emoji-picker-modal[data-open="true"] { display: block; }

.emoji-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.emoji-picker-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.emoji-picker-close {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
}
.emoji-picker-close:hover { color: #fff; }

.emoji-picker-section-label {
  display: block;
  font-size: 11px;
  color: #888;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Emoji thumbnail grid */
.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin-bottom: 12px;
}
.emoji-picker-tile {
  width: 44px;
  height: 44px;
  cursor: grab;
  border: 2px solid transparent;
  border-radius: 7px;
  padding: 5px;
  background: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s, background 0.12s;
}
.emoji-picker-tile:hover { border-color: #323232; background: #3c3c3c; }
.emoji-picker-tile.is-selected { border-color: #f0a020; background: #3a2e00; }
.emoji-picker-tile img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }

/* 3×3 placement grid */
.emoji-picker-placement-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}
.emoji-picker-cell {
  height: 62px;
  border: 2px dashed #444;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  background: #1a1a1a;
  transition: border-color 0.12s, background 0.12s;
}
.emoji-picker-cell:hover,
.emoji-picker-cell.drag-over {
  border-color: #f0a020;
  background: #2a200a;
}
.emoji-picker-cell.has-emoji { border-style: solid; border-color: #555; }
.emoji-picker-cell-label {
  font-size: 16px;
  color: #555;
  pointer-events: none;
}
.emoji-picker-cell img {
  width: 68%;
  height: 68%;
  object-fit: contain;
  pointer-events: none;
}

/* Remove button on filled cell */
.emoji-picker-cell-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #b03030;
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
  border: none;
  padding: 0;
  z-index: 1;
}
.emoji-picker-cell-remove:hover { background: #d04040; }

/* Footer buttons */
.emoji-picker-actions {
  display: flex;
  gap: 8px;
}
.emoji-picker-btn {
  flex: 1;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: opacity 0.12s;
}
.emoji-picker-btn:hover { opacity: 0.85; }
.emoji-picker-btn.is-clear { background: #5a2020; color: #ffaaaa; }
.emoji-picker-btn.is-close { background: #3a3a3a; color: #ddd; }

.circle, .circle-ctrl, .circle-shift { 
  position: relative;
  --marker-rgb: var(--circle-color-rgb);
}

/* Large ring marker that touches each side of the square */
.circle::before, 
.circle-ctrl::before, 
.circle-shift::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border-radius: 50%;
  z-index: 23;
  pointer-events: none;
  border: 3.2px solid rgba(var(--marker-rgb), 0.98);
  background: transparent;
  box-shadow: none;
}

.circle::before { 
  --marker-rgb: var(--circle-color-rgb);
  border-width: 4px;
}
.circle-ctrl::before { 
  --marker-rgb: var(--ctrl-circle-color-rgb);
  border-width: 4px;
  box-shadow: none;
}
.circle-shift::before { 
  --marker-rgb: var(--shift-circle-color-rgb);
  border-width: 4px;
}

.circle::after,
.circle-ctrl::after,
.circle-shift::after {
  content: none;
}

.circle {
  --marker-rgb: var(--circle-color-rgb);
}

.circle-ctrl::after {
  --marker-rgb: var(--ctrl-circle-color-rgb);
}

.circle-ctrl {
  --marker-rgb: var(--ctrl-circle-color-rgb);
}

.circle-shift::after {
  --marker-rgb: var(--shift-circle-color-rgb);
}

.circle-shift {
  --marker-rgb: var(--shift-circle-color-rgb);
}

/* Square background fill (B + right-click) lives on the square layer so pieces stay on top. */
.sq-bg-fill   { background-color: var(--sq-bg-fill-green) !important; background-image: none !important; }
.sq-bg-fill-2 { background-color: var(--sq-bg-fill-red) !important; background-image: none !important; }
.sq-bg-fill-3 { background-color: var(--sq-bg-fill-yellow) !important; background-image: none !important; }
.sq-bg-fill-4 { background-color: var(--sq-bg-fill-blue) !important; background-image: none !important; }
.sq-bg-fill-5 { background-color: var(--sq-bg-fill-purple) !important; background-image: none !important; }
.sq-bg-fill-6 {
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: inset 0 0 0 3px var(--sq-bg-fill-neon), 0 0 14px 3px var(--sq-bg-fill-neon) !important;
}
.sq-bg-fill-7 { /* Fire: ember glow */
  background-color: transparent !important;
  background-image: radial-gradient(circle, rgba(255, 166, 0, 0.85) 0%, rgba(220, 38, 38, 0.7) 75%) !important;
}
.sq-bg-fill-8 { /* Ice: frosted diagonal crystal pattern */
  background-color: transparent !important;
  background-image: repeating-linear-gradient(135deg, rgba(224, 242, 254, 0.55) 0px, rgba(224, 242, 254, 0.55) 6px, rgba(56, 189, 248, 0.45) 6px, rgba(56, 189, 248, 0.45) 12px) !important;
}
.sq-bg-fill-9 { /* Voltage rail: amber double-outline glow */
  background-color: transparent !important;
  background-image: none !important;
  box-shadow:
    inset 0 0 0 2px #fff36a,
    inset 0 0 0 5px #ffb800,
    inset 0 0 10px 2px rgba(255, 184, 0, 0.88),
    0 0 12px 3px rgba(255, 214, 10, 0.72) !important;
}
.sq-bg-fill-10 { /* Aurora: color-shift gradient */
  background-color: transparent !important;
  background-image: linear-gradient(120deg, rgba(139, 92, 246, 0.75), rgba(56, 189, 248, 0.75), rgba(236, 72, 153, 0.75)) !important;
}
.sq-bg-fill-11 { /* Reactor frame: acid-green nested outline */
  background-color: transparent !important;
  background-image: none !important;
  box-shadow:
    inset 0 0 0 2px #d7ff3f,
    inset 0 0 0 5px #00f58a,
    inset 0 0 0 7px rgba(9, 66, 43, 0.76),
    inset 0 0 12px 4px rgba(0, 255, 132, 0.82),
    0 0 13px 3px rgba(57, 255, 20, 0.7) !important;
}
.sq-bg-fill-12 { /* Neon portal: high-voltage dual-color static frame */
  background-color: rgba(250, 245, 255, 0.68) !important;
  background-image: none !important;
  box-shadow:
    inset 0 0 0 3px #ff00ae,
    inset 0 0 0 6px #dfff00,
    inset 0 0 8px 3px rgba(255, 0, 174, 0.9),
    0 0 8px 2px #dfff00,
    0 0 18px 5px rgba(255, 0, 174, 0.95) !important;
}
.sq-bg-fill-13 { /* Analysis paper: blue ruled grid */
  background-color: rgba(186, 230, 253, 0.9) !important;
  background-image: repeating-linear-gradient(0deg, transparent 0 9px, rgba(30, 64, 175, 0.42) 9px 11px) !important;
  box-shadow: inset 0 0 0 2px rgba(30, 64, 175, 0.42) !important;
}
.sq-bg-fill-14 { /* Prism frame: pink, white, and cyan neon outline */
  background-color: transparent !important;
  background-image: none !important;
  box-shadow:
    inset 0 0 0 2px #fff7ff,
    inset 0 0 0 5px #ff2bd6,
    inset 0 0 0 7px #66f7ff,
    inset 0 0 11px 4px rgba(255, 43, 214, 0.8),
    0 0 14px 3px rgba(102, 247, 255, 0.74) !important;
}
.sq-bg-fill-15 { /* Silver Plate: brushed metal with engraved border */
  background-color: transparent !important;
  background-image: linear-gradient(135deg, rgba(226, 232, 240, 0.85) 0%, rgba(148, 163, 184, 0.85) 45%, rgba(203, 213, 225, 0.85) 55%, rgba(100, 116, 139, 0.85) 100%) !important;
  box-shadow: inset 0 0 0 2px rgba(241, 245, 249, 0.9), inset 0 0 0 4px rgba(71, 85, 105, 0.6) !important;
}

/* Dark page mode: increase marker fill visibility and keep hue separation clean.
   data-mode="dark" is on <body>, so we scope to body[data-mode="dark"].            */
body[data-mode="dark"] {
  --last-move-color-border: rgba(190, 226, 190, 0.92);
  --last-move-color-background: rgba(120, 199, 124, 0.623);
  --last-move-stripe-soft: rgb(6, 123, 29);
  --last-move-stripe-dark: rgba(35, 180, 30, 1);
  --arrow-color: #0d7a3a;
  --ctrl-arrow-color: #991212;
  --ctrl-circle-color-rgb: 180, 45, 45;
  --circle-color-rgb: 45, 140, 85;
  --shift-circle-color-rgb: 40, 96, 150;
  --dotted-line-color-0: #f06a6a;
  --dotted-line-color-1: #58c686;
  --dotted-line-color-2: #67afe8;
  --sq-bg-fill-green: rgb(54, 183, 101);
  --sq-bg-fill-red: rgba(235, 60, 60, 0.8);
  --sq-bg-fill-yellow: rgba(245, 255, 48, 0.834);
  --sq-bg-fill-blue: rgba(59, 130, 246, 0.75);
  --sq-bg-fill-purple: rgba(192, 132, 252, 0.7);
  --sq-bg-fill-neon: #67e8f9;
}

body[data-mode="dark"] .sq-bg-fill-6 {
  background-color: rgba(207, 250, 254, 0.72) !important;
}

body[data-mode="dark"] .sq-bg-fill-12 {
  background-color: rgba(250, 245, 255, 0.82) !important;
}

/* Dark page + green board.
   Keep selector compatible across engines by targeting body under html[data-theme]. */
html[data-theme="green"] body[data-mode="dark"] {
  --last-move-color-border: rgba(220, 236, 165, 0.92);
  --last-move-color-background: rgba(176, 216, 88, 0.52);
  --last-move-stripe-soft: rgba(236, 245, 203, 0.16);
  --last-move-stripe-dark: rgba(64, 76, 31, 0.24);
  --circle-color-rgb: 98, 182, 105;
  --shift-circle-color-rgb: 102, 169, 219;
  --dotted-line-color-0: #f18585;
  --dotted-line-color-1: #67c07e;
  --dotted-line-color-2: #7ab5e3;
  --sq-bg-fill-green: rgba(130, 251, 49, 0.836);
  --sq-bg-fill-red: rgba(248, 51, 51, 0.67);
  --sq-bg-fill-yellow: rgba(249, 237, 68, 0.844);
  --sq-bg-fill-neon: #8cffc7;
}

/* Dark page + blue board. */
html[data-theme="blue"] body[data-mode="dark"] {
  --last-move-color-border: rgba(196, 226, 255, 0.95);
  --last-move-color-background: rgba(123, 191, 248, 0.48);
  --last-move-stripe-soft: rgba(229, 242, 255, 0.16);
  --last-move-stripe-dark: rgba(29, 73, 105, 0.24);
  --circle-color-rgb: 86, 187, 151;
  --shift-circle-color-rgb: 110, 173, 229;
  --dotted-line-color-0: #f38a97;
  --dotted-line-color-1: #62c8a4;
  --dotted-line-color-2: #78baee;
  --sq-bg-fill-green: rgba(52, 211, 153, 0.58);
  --sq-bg-fill-red: rgba(251, 113, 133, 0.58);
  --sq-bg-fill-yellow: rgba(255, 176, 56, 0.72);
  --sq-bg-fill-neon: #93e8ff;
}

.arrow-wrapper {
  position: absolute;
  inset: 0;
  --drawn-arrow-opacity: 0.76;
  pointer-events: none;
  contain: layout style;
}

.arrow {
  position: absolute;
  height: var(--arrow-thickness, 1.2vmin);
  background: var(--arrow-color, #ff6b35);
  transform-origin: 0 50%;
  pointer-events: none;
  z-index: 52;
  opacity: var(--drawn-arrow-opacity, 0.76);
}

.arrow::after {
  content: none;
}

.arrow-head {
  position: absolute;
  height: var(--arrow-thickness, 1.2vmin);
  background: transparent;
  transform-origin: 0 50%;
  pointer-events: none;
  z-index: 60;
  opacity: var(--drawn-arrow-opacity, 0.76);
}

.arrow-target-cap {
  position: absolute;
  height: var(--arrow-thickness, 1.2vmin);
  background: var(--arrow-color, #ff6b35);
  transform-origin: 0 50%;
  pointer-events: none;
  z-index: 59;
  opacity: var(--drawn-arrow-opacity, 0.76);
  /* Fade-in along travel direction so the raised segment feels like it emerges from the piece. */
  -webkit-mask-image: linear-gradient(to right, rgba(0, 0, 0, 0.22) 0%, rgba(0, 0, 0, 0.65) 52%, rgba(0, 0, 0, 1) 100%);
  mask-image: linear-gradient(to right, rgba(0, 0, 0, 0.22) 0%, rgba(0, 0, 0, 0.65) 52%, rgba(0, 0, 0, 1) 100%);
}

.arrow-head::after {
  content: "";
  position: absolute;
  --arrow-head-length: calc(var(--arrow-thickness, 1.2vmin) * 1.67);
  right: calc(var(--arrow-head-length) * -1);
  top: 50%;
  width: 0;
  height: 0;
  border-left: var(--arrow-head-length) solid var(--arrow-color, #ff6b35);
  border-top: var(--arrow-thickness, 1.2vmin) solid transparent;
  border-bottom: var(--arrow-thickness, 1.2vmin) solid transparent;
  transform: translateY(-50%);
  z-index: 1;
}

.arrow-wrapper[data-mode="ctrl"] .arrow,
.arrow-wrapper[data-mode="ctrl"] .arrow-head,
.arrow-wrapper[data-mode="ctrl"] .arrow-target-cap { --arrow-color: var(--ctrl-arrow-color); }

.arrow-wrapper[data-mode="shift"] .arrow,
.arrow-wrapper[data-mode="shift"] .arrow-head,
.arrow-wrapper[data-mode="shift"] .arrow-target-cap { --arrow-color: var(--shift-arrow-color); }

.arrow-wrapper[data-mode="line"] .arrow,
.arrow-wrapper[data-mode="line"] .arrow-head,
.arrow-wrapper[data-mode="line"] .arrow-target-cap { --arrow-color: #8a2be2; --arrow-thickness: 1vmin; }

/* ── Dotted arrow base ─────────────────────────────────────── */
.arrow-wrapper[data-mode="dotted-line"] .arrow,
.arrow-wrapper[data-mode="dotted-line"] .arrow-head,
.arrow-wrapper[data-mode="dotted-line"] .arrow-target-cap {
  --arrow-color: var(--dotted-line-color-0);
  --arrow-thickness: 0.88vmin;
}

/* Dotted shaft: small tight circles, gap equals dot size */
.arrow-wrapper[data-mode="dotted-line"] .arrow {
  background:
    radial-gradient(circle closest-side, var(--arrow-color) 85%, transparent 100%)
    left center / calc(var(--arrow-thickness) * 1.05) 100% repeat-x;
  filter: drop-shadow(0 0 0.8px var(--arrow-color));
}

/* Arrowhead inherits --arrow-color via border — slightly larger than default */
.arrow-wrapper[data-mode="dotted-line"] .arrow-head::after {
  --arrow-head-length: calc(var(--arrow-thickness, 0.88vmin) * 2.1);
  border-left:   var(--arrow-head-length) solid var(--arrow-color);
  border-top:    calc(var(--arrow-thickness, 0.88vmin) * 1.28) solid transparent;
  border-bottom: calc(var(--arrow-thickness, 0.88vmin) * 1.28) solid transparent;
  right: calc(var(--arrow-head-length) * -1);
  filter: drop-shadow(0 0 1px var(--arrow-color));
}

.arrow-wrapper[data-mode="point-comment"] .arrow,
.arrow-wrapper[data-mode="point-comment"] .arrow-head,
.arrow-wrapper[data-mode="point-comment"] .arrow-target-cap {
  --arrow-color: #0ea5a5;
  --arrow-thickness: 1.34vmin;
  --arrow-target-cap-scale: 1.35;
}

.arrow-wrapper[data-mode="point-comment"] .arrow,
.arrow-wrapper[data-mode="point-comment"] .arrow-target-cap {
  z-index: 12030;
}

.arrow-wrapper[data-mode="point-comment"] .arrow-head {
  z-index: 12031;
}
.arrow-wrapper[data-mode="castling"] {
  z-index: 12220;
}

.arrow-wrapper[data-mode="castling"] .arrow,
.arrow-wrapper[data-mode="castling"] .arrow-head,
.arrow-wrapper[data-mode="castling"] .arrow-target-cap {
  --arrow-color: #198dff;
  --arrow-thickness: 0.96vmin;
}

.arrow-wrapper[data-mode="castling"] .arrow {
  border-radius: 999px;
  background: linear-gradient(90deg, #0f6ac4 0%, #1f9cff 55%, #6bc6ff 100%);
  box-shadow:
    0 0 0 1px rgba(8, 20, 33, 0.45),
    0 0 10px rgba(26, 141, 255, 0.58);
}

.arrow-wrapper[data-mode="castling"] .arrow-head {
  width: calc(var(--arrow-thickness, 0.96vmin) * 2.55);
  overflow: visible;
}

.arrow-wrapper[data-mode="castling"] .arrow-head::before {
  content: "";
  position: absolute;
  right: calc(var(--arrow-thickness, 0.96vmin) * -0.62);
  top: 50%;
  width: 0;
  height: 0;
  background: transparent;
  border-left: calc(var(--arrow-thickness, 0.96vmin) * 2.42) solid rgba(6, 24, 44, 0.9);
  border-top: calc(var(--arrow-thickness, 0.96vmin) * 1.18) solid transparent;
  border-bottom: calc(var(--arrow-thickness, 0.96vmin) * 1.18) solid transparent;
  transform: translateY(-50%);
  filter: drop-shadow(0 0 1px rgba(6, 24, 44, 0.95));
}

.arrow-wrapper[data-mode="castling"] .arrow-head::after {
  right: calc(var(--arrow-thickness, 0.96vmin) * -0.46);
  width: 0;
  height: 0;
  background: transparent;
  border-left: calc(var(--arrow-thickness, 0.96vmin) * 2.12) solid #2aa4ff;
  border-top: calc(var(--arrow-thickness, 0.96vmin) * 1.02) solid transparent;
  border-bottom: calc(var(--arrow-thickness, 0.96vmin) * 1.02) solid transparent;
  transform: translateY(-50%);
  filter: drop-shadow(0 0 0.75px rgba(8, 20, 33, 0.95)) drop-shadow(0 0 4px rgba(26, 141, 255, 0.55));
}

.arrow-wrapper[data-mode="castling"] .arrow-target-cap {
  opacity: 0.98;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(18, 110, 194, 0.28) 0%, rgba(31, 157, 255, 0.7) 72%, rgba(87, 198, 255, 0.96) 100%);
}
.arrow.no-arrowhead::after,
.arrow-head.no-arrowhead::after { display: none !important; }

.castling-label-badge {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 0.14rem 0.42rem;
  border-radius: 999px;
  background: rgba(8, 20, 33, 0.9);
  color: #f8fafc;
  border: 1px solid rgba(34, 211, 238, 0.95);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1;
  pointer-events: none;
  z-index: 12020;
}

.point-comment-chip {
  position: absolute;
  left: 0;
  top: 0;
  padding: 0.7rem 0.8rem 0.72rem;
  border-radius: 0.42rem;
  background:
    linear-gradient(160deg, #fff4a3 0%, #ffe67b 54%, #f7d85d 100%),
    linear-gradient(180deg, rgba(255,255,255,0.32), rgba(255,255,255,0) 35%);
  border: 1px solid rgba(134, 103, 20, 0.74);
  color: #3d2c06;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.28;
  text-align: left;
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.28);
  z-index: 12025;
  white-space: pre-wrap;
  overflow: visible;
  word-break: break-word;
  -webkit-font-smoothing: antialiased;
  transition: opacity 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.point-comment-chip[data-square-id] {
  min-width: 10%;
  pointer-events: auto;
  cursor: grab;
  user-select: none;
}

.point-comment-chip[data-square-id].is-dragging {
  cursor: grabbing;
  opacity: 0.88;
  transition: none;
}

.point-comment-chip-body {
  position: relative;
  z-index: 1;
  white-space: pre-wrap;
  max-height: 22vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(134,103,20,0.4) transparent;
}

.point-comment-chip[data-square-id]:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.3);
}

.arrow-wrapper .point-comment-chip {
  --chip-rotate-deg: 0deg;
  transform: translate(-50%, -50%) rotate(var(--chip-rotate-deg));
  transform-origin: 50% 50%;
  max-width: min(24vw, 210px);
  pointer-events: none;
}

.point-comment-chip::before {
  content: "";
  position: absolute;
  right: -10px;
  top: -23px;
  width: 30px;
  height: 30px;
  background: url('./images/callout_emojis/pin.webp') center / contain no-repeat;
  transform: rotate(7deg);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
  z-index: 2;
}

@media (max-width: 768px) {
  .point-comment-chip[data-preview-tag="daily-preview-side-note"] {
    display: none;
  }
}

.arrow-seq-badge {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  background: rgba(10, 16, 26, 0.88);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.38);
  pointer-events: none;
  z-index: 31;
}

.arrow-wrapper[data-mode="ctrl"] .arrow-seq-badge {
  border-color: var(--ctrl-arrow-color);
}

.arrow-wrapper[data-mode="shift"] .arrow-seq-badge {
  border-color: var(--shift-arrow-color);
}

.circle-seq-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  background: rgba(10, 16, 26, 0.88);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.9);
  font-size: 0.76rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.38);
  pointer-events: none;
  z-index: 31;
}

.circle-ctrl .circle-seq-badge {
  border-color: rgba(var(--ctrl-circle-color-rgb), 0.95);
}

.circle-shift .circle-seq-badge {
  border-color: rgba(var(--shift-circle-color-rgb), 0.95);
}

.arrow-wrapper, .circle, .circle-ctrl, .circle-shift {
  transition: opacity 0.2s ease;
}

/* CHESS PIECE STATES */
.square.king-in-check,
.square.king-in-checkmate {
  background: 
    radial-gradient(ellipse 80% 80% at center, rgba(255,10,10,0.97) 0%, rgba(180,15,15,0.95) 50%, rgba(120,5,5,0.93) 100%),
    radial-gradient(circle 25% at center, rgba(255,255,255,0.15) 0%, transparent 50%);
  box-shadow: inset 0 0 70px rgba(255,20,20,0.96), inset 0 0 0 2px rgba(255,100,100,0.4);
}

.square.king-in-stalemate {
  background: 
    radial-gradient(ellipse 80% 80% at center, rgba(45, 124, 242, 0.97) 0%, rgba(26, 15, 180, 0.95) 50%, rgba(5, 5, 120, 0.93) 100%),
    radial-gradient(circle 25% at center, rgba(255,255,255,0.15) 0%, transparent 50%);
  box-shadow: inset 0 0 70px rgba(20, 55, 255, 0.96), inset 0 0 0 2px rgba(100, 165, 255, 0.4);
}

/* ========================================================
   CAPTURE STRIP ABOVE CHESSBOARD (INCLDES THE NAV BACK/FORWARD BUTTONS)
   ======================================================== */

.top-row {
  display: flex;
  align-items: center;
  gap: calc(var(--board-size) * 0.015);
  width: 100%;
  max-width: var(--board-size);
  margin-bottom: 8px;
}

.captured-pieces-section {
  display: flex;
  align-items: center;
  flex-grow: 1;
  gap: 3px;
}

.captured-pieces-list {
  flex-grow: 1;  /* Takes ALL remaining space AFTER points */
  order: 2;      /* Forces pieces AFTER points */
  display: flex;
  gap: 1px;
  overflow: visible;
}

.captured-pieces-list img {
  width: var(--capture-piece-size);
  height: var(--capture-piece-size);
  flex-shrink: 0;
}

body[data-mode="dark"] .captured-pieces-list img {
  filter: none;
}

body[data-mode="dark"] .captured-pieces-list img[data-color="white"] {
  /* Keep white pieces visible on dark backgrounds without changing color */
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.95)) drop-shadow(0 0 2px rgba(0, 0, 0, 0.85));
}

body[data-mode="dark"] .captured-pieces-list img[data-color="black"] {
  /* Preserve black piece identity while improving contrast in dark mode */
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 1));
  border-radius: 50%;
  position: relative;
  z-index: 2;
}

.points {
  font-size: var(--points-size);
  font-weight: 700;
  border-radius: 4px;
  min-width: calc(var(--points-size) * 2.8);
  height: calc(var(--points-size) * 2);
  text-align: center;
  align-content: center;
  color: var(--text-primary);
  flex-shrink: 0;
  line-height: calc(var(--points-size) * 1);
}

.captured-piece.new {
  animation: captureSlideNew 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.captured-piece-seq-enter {
  animation: capturedPieceSeqEnter 0.24s cubic-bezier(0.22, 0.88, 0.28, 1);
}

.captured-piece-seq-removing {
  animation: capturedPieceSeqRemove 0.2s cubic-bezier(0.32, 0.8, 0.36, 1) forwards;
}

.capture::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 6px;
  border: 2px solid rgba(255, 60, 60, 0.95);
  box-shadow: 0 0 10px rgba(255, 60, 60, 0.35);
  pointer-events: none;
}

.capture:hover {
  cursor: pointer;
}

.captures-strip {
  width: 100%;
  max-width: var(--board-size);
  display: flex;
  align-items: center;
  height: calc(var(--board-size) * 0.058);
  flex-shrink: 0;
  gap: calc(var(--board-size) * 0.015);
}

.black-captures { 
  flex: 1; 
}

.move-nav {
  flex: 0 0 var(--top-row-nav-width);
  display: flex;
  gap: calc(var(--board-size) * 0.009);
  justify-content: flex-end;
  align-items: center;
  padding: 0;
  width: calc(var(--nav-btn-size) * 3.4);
}

@keyframes captureSlideNew {
  0% { 
    transform: translateX(-15px) scale(0.7) rotate(-15deg);
    opacity: 0;
  }
  60% { 
    transform: translateX(2px) scale(1.05) rotate(2deg);
    opacity: 0.9;
  }
  100% { 
    transform: translateX(0) scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* NAVIGATION / HISTORY / BACK / FORWARD BUTTONS */

.nav-btn {
  background-color: var(--nav-btn-bg);
  width: var(--nav-btn-size); 
  height: calc(var(--nav-btn-size) * 0.8);
  border: 1px solid var(--nav-btn-border);
  border-radius: 15px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
}

.nav-btn:hover {
    box-shadow: 0 2.5px 3px rgba(8, 12, 33, 0.4);
}

/* ─── Board Callout Overlays ────────────────────────────────────────────── */

.square.board-callout-square {
  outline: 3px solid var(--callout-border, #facc15);
  outline-offset: -3px;
  background-blend-mode: multiply;
}

.square.board-callout-square[data-callout-color="yellow"]  { --callout-border: #facc15; background-color: rgba(250,204,21,0.25); }
.square.board-callout-square[data-callout-color="green"]   { --callout-border: #22c55e; background-color: rgba(34,197,94,0.25); }
.square.board-callout-square[data-callout-color="red"]     { --callout-border: #ef4444; background-color: rgba(239,68,68,0.25); }
.square.board-callout-square[data-callout-color="blue"]    { --callout-border: #3b82f6; background-color: rgba(59,130,246,0.25); }
.square.board-callout-square[data-callout-color="purple"]  { --callout-border: #a855f7; background-color: rgba(168,85,247,0.25); }
.square.board-callout-square[data-callout-color="orange"]  { --callout-border: #f97316; background-color: rgba(249,115,22,0.25); }

body[data-mode="dark"] .square.board-callout-square {
  background-blend-mode: normal;
  background-image: linear-gradient(180deg, rgba(255,255,255,0.42), rgba(255,255,255,0.12));
}

body[data-mode="dark"] .square.board-callout-square[data-callout-color="yellow"]  { --callout-border: #facc15; background-color: rgba(255, 245, 170, 0.82); }
body[data-mode="dark"] .square.board-callout-square[data-callout-color="green"]   { --callout-border: #22c55e; background-color: rgba(187, 247, 204, 0.78); }
body[data-mode="dark"] .square.board-callout-square[data-callout-color="red"]     { --callout-border: #ef4444; background-color: rgba(255, 205, 205, 0.76); }
body[data-mode="dark"] .square.board-callout-square[data-callout-color="blue"]    { --callout-border: #3b82f6; background-color: rgba(191, 219, 254, 0.74); }
body[data-mode="dark"] .square.board-callout-square[data-callout-color="purple"]  { --callout-border: #a855f7; background-color: rgba(233, 213, 255, 0.72); }
body[data-mode="dark"] .square.board-callout-square[data-callout-color="orange"]  { --callout-border: #f97316; background-color: rgba(254, 215, 170, 0.72); }

.square.od-blunder-flash {
  animation: od-blunder-square-flash 0.9s ease-out;
}

@keyframes od-blunder-square-flash {
  0% {
    box-shadow: inset 0 0 0 0 rgba(220, 38, 38, 0.9), 0 0 0 0 rgba(239, 68, 68, 0.45);
    background-color: rgba(239, 68, 68, 0.04);
  }
  18% {
    box-shadow: inset 0 0 0 3px rgba(220, 38, 38, 0.98), 0 0 0 10px rgba(239, 68, 68, 0.22);
    background-color: rgba(239, 68, 68, 0.28);
  }
  100% {
    box-shadow: inset 0 0 0 0 rgba(220, 38, 38, 0), 0 0 0 0 rgba(239, 68, 68, 0);
    background-color: transparent;
  }
}

.board-callout-label {
  /* Legacy — kept for safety but no longer generated */
  display: none;
}

/* Floating callout chips — rendered at body level, above pieces */
.board-callout-chip {
  position: fixed;
  z-index: 9500;
  transform: translate(-50%, -100%);
  margin-top: -4px;              /* small gap above the square edge */
  padding: 2px 6px 3px;
  background: rgba(12, 12, 16, 0.92);
  border: 1.5px solid var(--chip-border, #facc15);
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.7);
  /* tiny downward triangle */
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
}

body[data-mode="dark"] .board-callout-chip {
  background: rgba(39, 47, 62, 0.78);
  color: #f8fafc;
  border-color: var(--chip-border, #facc15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.32);
}

body[data-mode="dark"] .board-callout-chip::after {
  border-top-color: var(--chip-border, #facc15);
}

.board-callout-chip::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--chip-border, #facc15);
}

.board-callout-chip[data-callout-color="yellow"]  { --chip-border: #facc15; }
.board-callout-chip[data-callout-color="green"]   { --chip-border: #22c55e; }
.board-callout-chip[data-callout-color="red"]     { --chip-border: #ef4444; }
.board-callout-chip[data-callout-color="blue"]    { --chip-border: #3b82f6; }
.board-callout-chip[data-callout-color="purple"]  { --chip-border: #a855f7; }
.board-callout-chip[data-callout-color="orange"]  { --chip-border: #f97316; }

.board-callout-badge {
  position: fixed;
  z-index: 9501;
  transform: translate(-50%, -100%);
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  color: transparent;
  cursor: pointer;
  background: transparent;
  box-shadow: none;
}

.board-callout-badge::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow:
    0 0 0 1.5px rgba(255,255,255,0.92),
    0 2px 8px rgba(0,0,0,0.32);
}

.board-callout-badge[data-badge-kind="engine-1"]::before {
  content: none;
}

.board-callout-badge[data-badge-kind="engine-1"] {
  width: auto;
  min-width: 50px;
  height: 21px;
  padding: 0 8px;
  box-sizing: border-box;
  border-radius: 999px;
  border: 1px solid rgba(21, 128, 61, 0.8);
  color: #f4fff7;
  font-size: 0.82em;
  font-weight: 400;
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
  letter-spacing: 0;
  white-space: nowrap;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 44%),
    linear-gradient(132deg, #4ade80 0%, #22c55e 48%, #15803d 100%);
  text-shadow: 0 1px 1px rgba(20, 83, 45, 0.76);
  overflow: hidden;
}

.board-callout-badge[data-badge-kind="engine-2"]::before {
  background: radial-gradient(circle at 30% 30%, #fdba74 0%, #f97316 55%, #c2410c 100%);
}

.board-callout-badge[data-badge-kind="engine-3"]::before {
  background: radial-gradient(circle at 30% 30%, #93c5fd 0%, #3b82f6 55%, #1d4ed8 100%);
}

.board-callout-badge[data-badge-kind="blunder"] {
  min-width: 36px;
  height: 21px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(127, 29, 29, 0.76);
  color: #fff8f8;
  font-size: 0.88em;
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
  letter-spacing: 0.06em;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 44%),
    linear-gradient(132deg, #ef4444 0%, #dc2626 48%, #991b1b 100%);
  text-shadow: 0 1px 1px rgba(69, 10, 10, 0.72);
  transform: translate(-50%, -100%);
  overflow: hidden;
}

.board-callout-badge[data-badge-kind="blunder"]::before {
  content: none;
}

.board-callout-badge[data-badge-kind="blunder"]::after {
  content: none;
}

.board-callout-badge[data-badge-kind="gm-move"] {
  min-width: 36px;
  height: 21px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(30, 64, 175, 0.76);
  color: #f8fbff;
  font-size: 0.88em;
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
  letter-spacing: 0.06em;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 44%),
    linear-gradient(132deg, #60a5fa 0%, #3b82f6 48%, #1d4ed8 100%);
  text-shadow: 0 1px 1px rgba(15, 23, 42, 0.72);
  transform: translate(-50%, -100%);
  overflow: hidden;
}

.board-callout-badge[data-badge-kind="gm-move"]::before {
  content: none;
}

.board-callout-badge[data-badge-kind="gm-move"]::after {
  content: none;
}

.board-callout-badge[data-badge-kind="bad-move"] {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.board-callout-badge[data-badge-kind="bad-move"]::before {
  background: radial-gradient(circle at 30% 30%, #fca5a5 0%, #ef4444 55%, #b91c1c 100%);
}

.board-callout-badge[data-badge-kind="bad-move"]::after {
  content: none;
}

.board-callout-badge:focus-visible {
  outline: 2px solid rgba(255,255,255,0.95);
  outline-offset: 2px;
}

.board-callout-tooltip {
  position: fixed;
  z-index: 9502;
  max-width: min(220px, calc(100vw - 16px));
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(11, 15, 25, 0.96);
  border: 1px solid rgba(255,255,255,0.12);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  box-shadow: 0 12px 28px rgba(0,0,0,0.36);
  pointer-events: none;
}

.board-callout-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 10px;
  height: 10px;
  background: rgba(11, 15, 25, 0.96);
  border-left: 1px solid rgba(255,255,255,0.12);
  border-top: 1px solid rgba(255,255,255,0.12);
  transform: translateX(-50%) rotate(45deg);
}

.board-callout-tooltip[data-placement="top"]::after {
  bottom: -6px;
}

.board-callout-tooltip[data-placement="bottom"]::after {
  top: -6px;
}

/* Callout pick mode: crosshair cursor on every square */
.board-container.callout-pick-active .square {
  cursor: crosshair !important;
}

.board-container.callout-pick-active .square:hover {
  outline: 2px dashed rgba(99, 179, 237, 0.9);
  outline-offset: -2px;
}

.board-container.global-callout-edit-active .square {
  cursor: cell !important;
}

.board-container.global-callout-edit-active .square:hover {
  outline: 2px dashed rgba(250, 204, 21, 0.95);
  outline-offset: -2px;
}

.board-container.point-comment-edit-active .square {
  cursor: copy !important;
}

.board-container.point-comment-edit-active .square:hover {
  outline: 2px dashed rgba(20, 184, 166, 0.95);
  outline-offset: -2px;
}

.board-callout-editor {
  position: fixed;
  z-index: 2147483501; /* above admin workbench panels */
  width: min(220px, calc(100vw - 24px));
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(14, 18, 28, 0.96);
  box-shadow: 0 14px 30px rgba(0,0,0,0.42);
  backdrop-filter: blur(10px);
  display: none;
}

.board-callout-editor[data-open="true"] {
  display: block;
}

.board-callout-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.board-callout-editor-title {
  color: #f5f7fb;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.board-callout-editor-close {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.8);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.board-callout-editor-input {
  width: 100%;
  min-width: 0;
  margin-bottom: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.board-callout-editor-rank {
  width: 100%;
  min-width: 0;
  margin-bottom: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.board-callout-editor-rank option {
  color: #111827;
  background: #ffffff;
}

.board-callout-editor-input:focus {
  outline: none;
  border-color: rgba(250,204,21,0.9);
  box-shadow: 0 0 0 2px rgba(250,204,21,0.18);
}

.board-callout-editor-rank:focus {
  outline: none;
  border-color: rgba(250,204,21,0.9);
  box-shadow: 0 0 0 2px rgba(250,204,21,0.18);
}

.board-callout-editor-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.board-callout-editor-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.24);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.board-callout-editor-swatch:hover {
  transform: translateY(-1px);
}

.board-callout-editor-swatch.is-selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.16);
}

.board-callout-editor-swatch[data-color="yellow"] { background: #facc15; }
.board-callout-editor-swatch[data-color="green"]  { background: #22c55e; }
.board-callout-editor-swatch[data-color="red"]    { background: #ef4444; }
.board-callout-editor-swatch[data-color="blue"]   { background: #3b82f6; }
.board-callout-editor-swatch[data-color="purple"] { background: #a855f7; }
.board-callout-editor-swatch[data-color="orange"] { background: #f97316; }

.board-callout-editor-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.board-callout-editor-btn {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
}

.board-callout-editor-btn.is-save {
  border-color: rgba(250,204,21,0.45);
  background: rgba(250,204,21,0.16);
  color: #fff4bf;
}

.board-callout-editor-btn.is-remove {
  color: rgba(255,255,255,0.82);
}

.board-callout-editor-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Arrow triangles inside */
.nav-btn::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Enlarged thicker arrows for stronger presence */
#prev-move::before {
  border-width: 10px 14px 10px 0;
  border-color: transparent rgb(var(--nav-btn-arrow-color)) transparent transparent;
}

#next-move::before {
  border-width: 10px 0 10px 14px;
  border-color: transparent transparent transparent rgb(var(--nav-btn-arrow-color));
}

.nav-btn:active {
  transform: translateY(2px);
  background: linear-gradient(180deg, #505a74 0%, #3f485b 100%);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Flip Board Button */
.flip-btn {
  font-size: calc(var(--nav-btn-size) * 0.6);
  color: rgb(var(--nav-btn-arrow-color));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  line-height: 1;
  padding: 0;
  user-select: none;
}

/* Override arrow styling for flip button */
.flip-btn::before {
  display: none;
}

/* =========================================================
  CHECKMATE MODAL
   ========================================================= */

#checkmate-modal {
  position: absolute !important;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 70px;
  padding: 6px 12px;
  background: linear-gradient(135deg, rgba(255, 20, 20, 0.97), rgba(180, 15, 15, 0.95));
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-align: center;
  z-index: 100;
  pointer-events: none;
  box-shadow: 
    0 4px 20px rgba(255, 20, 20, 0.7),
    0 2px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
  animation: checkmateSlide 0.5s ease-in-out 1;
}

@keyframes checkmateSlide {
  0%, 100% { 
    transform: translateX(-50%) translateY(0px) scale(1);
    box-shadow: 
      0 4px 20px rgba(255, 20, 20, 0.7),
      0 2px 8px rgba(0, 0, 0, 0.3);
  }
  50% { 
    transform: translateX(-50%) translateY(-4px) scale(1.05);
    box-shadow: 
      0 8px 30px rgba(255, 20, 20, 0.9),
      0 4px 12px rgba(0, 0, 0, 0.4);
  }
};

/* =========================================================
   STALEMATE BADGE  (½ over each king)
   ========================================================= */

.stalemate-badge {
  position: absolute;
  z-index: 102;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  /* deep charcoal with a warm tint — maximum contrast against both white and black pieces */
  background: radial-gradient(circle at 35% 30%, #4a3f6b 0%, #1c1730 55%, #0d0b1a 100%);
  border: 2.5px solid rgba(255, 215, 80, 0.9);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.7),
    0 0 0 4px rgba(255, 200, 40, 0.22),
    0 8px 24px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  /* centered on the king square */
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  transition: none;
}

.stalemate-badge__half {
  font-size: 21px;
  font-weight: 900;
  /* bright gold — pops on the dark bg and both piece colors */
  color: #fcd34d;
  line-height: 1;
  text-shadow:
    0 0 6px rgba(255, 200, 40, 0.8),
    0 1px 3px rgba(0, 0, 0, 0.9);
  letter-spacing: -0.02em;
}

.stalemate-badge__score {
  font-size: 16px;
  letter-spacing: 0.02em;
}

.checkmate-score-badge {
  width: 54px;
  height: 34px;
  border-radius: 11px;
  border-width: 2px;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  position: absolute;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 22% 24%, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0) 40%),
    linear-gradient(145deg, #111827 0%, #1f2937 52%, #0b1220 100%);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.62),
    0 0 0 3px rgba(245, 158, 11, 0.18),
    0 8px 18px rgba(0, 0, 0, 0.68),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

body[data-mode="light"] .checkmate-score-badge {
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.74),
    0 0 0 3px rgba(37, 99, 235, 0.24),
    0 9px 20px rgba(15, 23, 42, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.26);
}

.checkmate-score-badge::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  z-index: 0;
}

.checkmate-score-badge::after {
  content: "";
  position: absolute;
  left: -18%;
  top: -95%;
  width: 46%;
  height: 250%;
  transform: rotate(21deg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
  z-index: 0;
  pointer-events: none;
}

.checkmate-score-badge--white {
  border-color: rgba(226, 232, 240, 0.98);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.98) 58%, rgba(226, 232, 240, 0.98) 100%);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.14),
    0 0 0 3px rgba(255, 255, 255, 0.28),
    0 8px 18px rgba(15, 23, 42, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.checkmate-score-badge--black {
  border-color: rgba(248, 113, 113, 0.98);
}

.checkmate-score-badge__text {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  color: #ffffff;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  text-shadow:
    0 0 6px rgba(255, 255, 255, 0.26),
    0 1px 3px rgba(0, 0, 0, 0.9);
}

.checkmate-score-badge--white .checkmate-score-badge__text {
  color: #0f172a;
  text-shadow:
    0 1px 2px rgba(255, 255, 255, 0.72),
    0 0 0 rgba(0, 0, 0, 0);
}

.checkmate-score-badge--black .checkmate-score-badge__text {
  color: #fee2e2;
}

.checkmate-score-badge.is-active {
  animation: checkmateScoreRise 4.4s cubic-bezier(0.22, 0.85, 0.28, 1) forwards;
}

@keyframes checkmateScoreRise {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 0;
  }
  10% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.18);
  }
  18% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  72% {
    transform: translate(-50%, calc(-50% - 48px)) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, calc(-50% - 62px)) scale(0.9);
    opacity: 0;
  }
}

.stalemate-badge.is-active {
  animation: stalemateBadgeRise 4.5s cubic-bezier(0.22, 0.85, 0.28, 1) forwards;
}

@keyframes stalemateBadgeRise {
  0% {
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 0;
  }
  8% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }
  16% {
    transform: translate(-50%, -50%) scale(1.0);
    opacity: 1;
  }
  75% {
    transform: translate(-50%, calc(-50% - 38px)) scale(1.0);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, calc(-50% - 52px)) scale(0.88);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stalemate-badge.is-active {
    animation: none;
    opacity: 0;
  }

  .checkmate-score-badge.is-active {
    animation: none;
    opacity: 0;
  }
}

.board-point-comment-editor {
  width: auto;
  max-width: calc(100vw - 24px);
  z-index: 100500;
}

.board-point-comment-editor-text {
  display: block;
  min-width: 180px;
  min-height: 110px;
  max-width: min(420px, calc(100vw - 56px));
  max-height: min(320px, calc(100vh - 180px));
  resize: both;
  overflow: hidden;
  box-sizing: border-box;
  margin-bottom: 10px;
  padding: 0.9rem 0.95rem 0.88rem;
  border-radius: 0.42rem;
  border: 1px solid rgba(134, 103, 20, 0.74);
  background:
    linear-gradient(160deg, #fff4a3 0%, #ffe67b 54%, #f7d85d 100%),
    linear-gradient(180deg, rgba(255,255,255,0.32), rgba(255,255,255,0) 35%);
  color: #3d2c06;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.28;
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.2);
}

.board-point-comment-editor-text::placeholder {
  color: rgba(83, 61, 6, 0.7);
}

.board-point-comment-editor-text:focus {
  outline: none;
  border-color: rgba(134, 103, 20, 0.9);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

@keyframes capturedPieceSeqEnter {
  0% {
    transform: translateY(-6px) scale(0.86);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes capturedPieceSeqRemove {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(5px) scale(0.88);
    opacity: 0;
  }
}