/* =============================================================
   Chess board styles
   Three piece sets: classic / modern / knight
   Three board themes via [data-board-theme] on a parent.
   ============================================================= */

.cboard {
  --board-size: min(72vmin, 640px);
  --light-sq: #efe6cf;
  --dark-sq: #3a4670;
  --hl-select: rgba(201, 169, 110, 0.55);
  --hl-last: rgba(125, 95, 184, 0.32);
  --hl-check: rgba(225, 70, 80, 0.5);
  --dot: rgba(125, 95, 184, 0.55);

  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: var(--board-size);
  height: var(--board-size);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 30px 70px -20px rgba(0,0,0,0.6),
              0 0 0 1px rgba(255,255,255,0.06),
              0 0 0 6px rgba(0,0,0,0.45),
              0 0 0 7px var(--gold);
  user-select: none;
  position: relative;
  font-family: "Sora", "DejaVu Sans", "Segoe UI Symbol", sans-serif;
  touch-action: manipulation;
}

/* Board theme — knight (default for our brand) */
[data-board-theme="knight"] .cboard,
.cboard {
  --light-sq: #e7d6b8;
  --dark-sq: #2d3a66;
}
[data-board-theme="classic"] .cboard {
  --light-sq: #f0d9b5;
  --dark-sq: #b58863;
}
[data-board-theme="aqua"] .cboard {
  --light-sq: #e6f4f7;
  --dark-sq: #1b6d80;
}
[data-board-theme="purple"] .cboard {
  --light-sq: #ede6f6;
  --dark-sq: #5e4a8c;
}

.csq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.12s ease;
}
.csq-light { background: var(--light-sq); }
.csq-dark { background: var(--dark-sq); }

.csq-coord {
  position: absolute;
  font-size: 0.65rem;
  font-weight: 600;
  font-family: "Sora", sans-serif;
  opacity: 0.55;
  pointer-events: none;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.csq-coord-rank { top: 2px; left: 4px; }
.csq-coord-file { bottom: 2px; right: 4px; }
.csq-light .csq-coord { color: var(--dark-sq); }
.csq-dark .csq-coord { color: var(--light-sq); }

.csq-selected { background: color-mix(in srgb, var(--hl-select), currentColor 0%) !important; box-shadow: inset 0 0 0 3px var(--gold); }
.csq-last { background: color-mix(in srgb, var(--hl-last), transparent 50%) !important; }
.csq-last.csq-light { background: color-mix(in srgb, var(--light-sq), var(--purple) 25%) !important; }
.csq-last.csq-dark { background: color-mix(in srgb, var(--dark-sq), var(--purple) 30%) !important; }
.csq-check.csq-light { background: radial-gradient(circle, rgba(225,70,80,0.65), var(--light-sq) 70%) !important; }
.csq-check.csq-dark { background: radial-gradient(circle, rgba(225,70,80,0.75), var(--dark-sq) 70%) !important; }

.csq-dot::after {
  content: "";
  position: absolute;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: var(--dot);
  pointer-events: none;
}
.csq-capture-ring::before {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  border: 4px solid var(--dot);
  pointer-events: none;
}

.cpc {
  font-family: "DejaVu Sans", "Segoe UI Symbol", "Noto Sans Symbols 2", "Apple Symbols", serif;
  font-size: calc(var(--board-size) / 8 * 0.78);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  cursor: grab;
  transition: transform 0.1s ease;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.18));
  -webkit-user-select: none;
  user-select: none;
}
.cpc:active { cursor: grabbing; transform: scale(1.05); }

/* === Classic set === */
.cpc-set-classic.cpc-w {
  color: #f8f3e8;
  text-shadow:
    -1px -1px 0 #1a1a1a, 1px -1px 0 #1a1a1a,
    -1px 1px 0 #1a1a1a, 1px 1px 0 #1a1a1a,
    0 0 2px rgba(0,0,0,0.5);
}
.cpc-set-classic.cpc-b {
  color: #1a1f2e;
  text-shadow: 0 1px 0 rgba(255,255,255,0.12);
}

/* === Modern set === */
.cpc-set-modern.cpc-w {
  color: #4fc3d9; /* aqua */
  text-shadow:
    -1px -1px 0 #04293a, 1px -1px 0 #04293a,
    -1px 1px 0 #04293a, 1px 1px 0 #04293a;
  filter: drop-shadow(0 0 8px rgba(79,195,217,0.4));
}
.cpc-set-modern.cpc-b {
  color: #1a1f2e;
  text-shadow: 0 1px 0 rgba(255,255,255,0.15);
}

/* === Knight (medieval) set === */
.cpc-set-knight.cpc-w {
  color: #d4ba7a; /* gold */
  text-shadow:
    -1px -1px 0 #3d2a05, 1px -1px 0 #3d2a05,
    -1px 1px 0 #3d2a05, 1px 1px 0 #3d2a05;
  filter: drop-shadow(0 0 10px rgba(201,169,110,0.5));
}
.cpc-set-knight.cpc-b {
  color: #5e4a8c; /* deep purple */
  text-shadow:
    -1px -1px 0 #1a0e35, 1px -1px 0 #1a0e35,
    -1px 1px 0 #1a0e35, 1px 1px 0 #1a0e35;
  filter: drop-shadow(0 0 8px rgba(125,95,184,0.45));
}

/* Promotion picker */
.promo-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 26, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.promo-card {
  background: var(--navy-rich);
  border: 1px solid var(--border-on-dark-strong);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow-soft);
  max-width: 90%;
}
.promo-title {
  font-family: "Sora", sans-serif;
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--gold);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 1rem;
}
.promo-pieces { display: flex; gap: 0.5rem; }
.promo-piece {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-on-dark);
  border-radius: 8px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  transition: all 0.15s ease;
  cursor: pointer;
}
.promo-piece:hover { border-color: var(--gold); background: rgba(201,169,110,0.08); }
.promo-piece .cpc { font-size: 3rem; width: auto; height: auto; }
.promo-piece-label { font-size: 0.7rem; font-family: "Sora", sans-serif; letter-spacing: 0.08em; text-transform: uppercase; }

/* === Eval bar === */
.evalbar {
  width: 18px;
  border-radius: 4px;
  background: var(--midnight);
  border: 1px solid var(--border-on-dark);
  overflow: hidden;
  position: relative;
  align-self: stretch;
  min-height: 240px;
}
.evalbar-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, var(--parchment) 0%, #d4c89f 100%);
  transition: height 0.4s ease;
}
.evalbar-mid {
  position: absolute;
  left: -2px; right: -2px;
  top: 50%;
  border-top: 1px dashed rgba(255,255,255,0.25);
}
.evalbar-num {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 4px;
  font-size: 0.6rem;
  font-family: "Sora", sans-serif;
  font-weight: 600;
  color: var(--midnight);
  z-index: 2;
  letter-spacing: 0.02em;
}
.evalbar-num.t-dark { color: var(--text); bottom: auto; top: 4px; }

/* === Move list === */
.movelist {
  background: var(--navy-rich);
  border: 1px solid var(--border-on-dark);
  border-radius: var(--r-card);
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.movelist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-on-dark);
  font-family: "Sora", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}
.movelist-rows {
  display: grid;
  grid-template-columns: 32px 1fr 1fr;
  padding: 0.4rem 0.5rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85rem;
  gap: 2px 8px;
  overflow-y: auto;
  flex: 1;
  max-height: 280px;
}
.movelist-rows .mn { color: var(--text-faint); text-align: right; padding-right: 4px; padding-top: 4px; padding-bottom: 4px; }
.movelist-rows .mv {
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.movelist-rows .mv:hover { background: rgba(255,255,255,0.04); }
.movelist-rows .mv.empty { color: var(--text-faint); }
.movelist-empty { padding: 1rem; color: var(--text-muted); font-size: 0.9rem; font-style: italic; }

/* === Captured strip === */
.captured-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  min-height: 28px;
  align-items: center;
}
.captured-strip .cpc {
  font-size: 1.4rem;
  width: auto;
  height: auto;
  filter: none;
  text-shadow: none;
  color: var(--text-muted);
  cursor: default;
}
.captured-strip .mat-diff {
  font-family: "Sora", sans-serif;
  font-size: 0.8rem;
  color: var(--gold);
  margin-left: 0.5rem;
}

/* === Game over modal === */
.gover-card {
  background: linear-gradient(180deg, var(--navy-rich), #08122e);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow-soft), var(--shadow-glow-gold);
  text-align: center;
  max-width: 400px;
}

/* small board variant (hero) */
.cboard-mini {
  --board-size: min(58vmin, 480px);
  border-radius: 6px;
  box-shadow: 0 24px 60px -16px rgba(0,0,0,0.6),
              0 0 0 1px rgba(255,255,255,0.06),
              0 0 0 4px rgba(0,0,0,0.4),
              0 0 0 5px var(--gold);
}

/* Responsive */
@media (max-width: 720px) {
  .cboard {
    --board-size: min(88vw, 430px);
    border-radius: 6px;
    box-shadow: 0 20px 50px -22px rgba(0,0,0,0.7),
                0 0 0 1px rgba(255,255,255,0.08),
                0 0 0 4px rgba(0,0,0,0.45),
                0 0 0 5px var(--gold);
  }
  .evalbar { display: none; }
  .csq-coord { font-size: 0.55rem; }
}

@media (max-width: 380px) {
  .cboard { --board-size: min(86vw, 340px); }
  .cpc { font-size: calc(var(--board-size) / 8 * 0.72); }
}
