* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  /* Профиль «Мастерская» — классика в духе lichess: тёплый крем + зелёные поля */
  --ch-frame-border: #403d38;
  --ch-frame-bg: #262522;
  --ch-board-bg: #302e2b;
  --ch-board-inset: rgba(0, 0, 0, 0.22);
  --ch-cell-l: #eeeed2;
  --ch-cell-l-fg: #4a4a46;
  --ch-cell-d: #a8c47d;
  --ch-cell-d-fg: #eeeed2;
  --ch-sel: rgba(255, 200, 60, 0.42);
  --ch-mv-dot: rgba(40, 55, 30, 0.38);
  --ch-mv-ring: rgba(20, 28, 16, 0.35);
  --ch-mv-glow: rgba(255, 220, 100, 0.22);
  --ch-cap-b: rgba(180, 50, 40, 0.9);
  --ch-cap-bg: rgba(255, 200, 120, 0.28);
  --ch-w-fb: #fffef6;
  --ch-w1: #ffffff;
  --ch-w2: #f5f4e6;
  --ch-w3: #ffffff;
  --ch-w-drop: rgba(0, 0, 0, 0.5);
  --ch-b1: #1a2214;
  --ch-b2: #0f160c;
  --ch-b-str: rgba(245, 244, 228, 0.9);
  --ch-b-sh1: rgba(0, 0, 0, 0.28);
  --ch-b-sh2: rgba(0, 0, 0, 0.18);
  --ch-last: rgba(255, 200, 80, 0.55);
  --ch-bota1: rgba(195, 165, 115, 0.65);
  --ch-bota2: rgba(170, 140, 95, 0.35);
  --ch-botb1: rgba(180, 150, 100, 0.55);
  --ch-botb2: rgba(160, 130, 90, 0.25);
  --ch-chk: #c14d38;
  --ch-chk-b: rgba(80, 20, 10, 0.35);
  --ch-captured-bg: rgba(255, 255, 255, 0.4);
  --ch-captured-border: rgba(78, 112, 62, 0.28);
  background:
    radial-gradient(circle at top left, rgba(118, 150, 86, 0.12), transparent 26rem),
    radial-gradient(circle at bottom right, rgba(60, 55, 48, 0.35), transparent 24rem),
    #1b1a18;
  color: #d9e1f4;
  font-family: Arial, sans-serif;
}

/* Бежевый орех — спокойный низкоконтрастный бежево-коричневый вариант */
body[data-board-profile="studio-soft"] {
  --ch-frame-border: #403d38;
  --ch-frame-bg: #262522;
  --ch-board-bg: #302e2b;
  --ch-board-inset: rgba(0, 0, 0, 0.22);
  --ch-cell-l: #e8e0cf;
  --ch-cell-l-fg: #555048;
  --ch-cell-d: #cbbfa8;
  --ch-cell-d-fg: #f4eee2;
  --ch-sel: rgba(255, 200, 60, 0.42);
  --ch-mv-dot: rgba(40, 55, 30, 0.38);
  --ch-mv-ring: rgba(20, 28, 16, 0.35);
  --ch-mv-glow: rgba(255, 220, 100, 0.22);
  --ch-cap-b: rgba(180, 50, 40, 0.9);
  --ch-cap-bg: rgba(255, 200, 120, 0.28);
  --ch-w-fb: #fffef6;
  --ch-w1: #ffffff;
  --ch-w2: #f5f4e6;
  --ch-w3: #ffffff;
  --ch-w-drop: rgba(0, 0, 0, 0.5);
  --ch-b1: #1a2214;
  --ch-b2: #0f160c;
  --ch-b-str: rgba(245, 244, 228, 0.9);
  --ch-b-sh1: rgba(0, 0, 0, 0.28);
  --ch-b-sh2: rgba(0, 0, 0, 0.18);
  --ch-last: rgba(255, 200, 80, 0.55);
  --ch-bota1: rgba(195, 165, 115, 0.65);
  --ch-bota2: rgba(170, 140, 95, 0.35);
  --ch-botb1: rgba(180, 150, 100, 0.55);
  --ch-botb2: rgba(160, 130, 90, 0.25);
  --ch-chk: #c14d38;
  --ch-chk-b: rgba(80, 20, 10, 0.35);
  --ch-captured-bg: rgba(255, 255, 255, 0.4);
  --ch-captured-border: rgba(78, 112, 62, 0.28);
}

/* Сумерки над Невой — сине-серые поля (как «синие» онлайн-доски) */
body[data-board-profile="neva"] {
  --ch-frame-border: #4a5568;
  --ch-frame-bg: #232a36;
  --ch-board-bg: #2c3442;
  --ch-board-inset: rgba(0, 0, 0, 0.2);
  --ch-cell-l: #d5dce6;
  --ch-cell-l-fg: #3a4555;
  --ch-cell-d: #9cacc0;
  --ch-cell-d-fg: #e8ecf4;
  --ch-sel: rgba(255, 200, 100, 0.38);
  --ch-mv-dot: rgba(35, 48, 68, 0.35);
  --ch-mv-ring: rgba(20, 28, 42, 0.32);
  --ch-mv-glow: rgba(120, 170, 255, 0.2);
  --ch-cap-b: rgba(200, 80, 60, 0.88);
  --ch-cap-bg: rgba(255, 200, 160, 0.22);
  --ch-w-fb: #f8faff;
  --ch-w1: #ffffff;
  --ch-w2: #e8eef8;
  --ch-w3: #ffffff;
  --ch-w-drop: rgba(0, 0, 0, 0.55);
  --ch-b1: #0f141f;
  --ch-b2: #0a0e18;
  --ch-b-str: rgba(220, 230, 250, 0.92);
  --ch-b-sh1: rgba(60, 90, 130, 0.35);
  --ch-b-sh2: rgba(0, 0, 0, 0.35);
  --ch-last: rgba(255, 200, 90, 0.5);
  --ch-bota1: rgba(150, 170, 230, 0.5);
  --ch-bota2: rgba(100, 120, 200, 0.35);
  --ch-botb1: rgba(130, 150, 210, 0.45);
  --ch-botb2: rgba(90, 110, 180, 0.3);
  --ch-chk: #b84d5c;
  --ch-chk-b: rgba(60, 20, 30, 0.35);
  --ch-captured-bg: rgba(255, 255, 255, 0.4);
  --ch-captured-border: rgba(78, 112, 62, 0.28);
}

/* Окно в заливе — светлая бирюза */
body[data-board-profile="window"] {
  --ch-frame-border: #66a5a8;
  --ch-frame-bg: #d7f0ee;
  --ch-board-bg: #c3e8e7;
  --ch-board-inset: rgba(255, 255, 255, 0.42);
  --ch-cell-l: #b6dcda;
  --ch-cell-l-fg: #5e8a8a;
  --ch-cell-d: #8fc8c8;
  --ch-cell-d-fg: #2c6769;
  --ch-sel: rgba(45, 150, 158, 0.32);
  --ch-mv-dot: rgba(42, 142, 150, 0.44);
  --ch-mv-ring: rgba(12, 91, 98, 0.34);
  --ch-mv-glow: rgba(54, 180, 188, 0.2);
  --ch-cap-b: rgba(22, 136, 148, 0.68);
  --ch-cap-bg: rgba(64, 184, 190, 0.16);
  --ch-w-fb: #ffffff;
  --ch-w1: #ffffff;
  --ch-w2: #eefaf8;
  --ch-w3: #ffffff;
  --ch-w-drop: rgba(20, 80, 84, 0.5);
  --ch-b1: #122023;
  --ch-b2: #0f1a1d;
  --ch-b-str: rgba(225, 252, 250, 0.96);
  --ch-b-sh1: rgba(70, 150, 155, 0.32);
  --ch-b-sh2: rgba(0, 45, 50, 0.36);
  --ch-last: rgba(38, 132, 150, 0.35);
  --ch-bota1: rgba(52, 166, 176, 0.38);
  --ch-bota2: rgba(35, 132, 145, 0.2);
  --ch-botb1: rgba(38, 144, 156, 0.34);
  --ch-botb2: rgba(24, 112, 124, 0.18);
  --ch-chk: #b9e3df;
  --ch-chk-b: rgba(18, 124, 135, 0.4);
  --ch-captured-bg: rgba(255, 255, 255, 0.4);
  --ch-captured-border: rgba(78, 112, 62, 0.28);
}

/* Ночной этюд — тёплый орех / пергамент */
body[data-board-profile="nocturne"] {
  --ch-frame-border: #5c4d3d;
  --ch-frame-bg: #2a2520;
  --ch-board-bg: #352f28;
  --ch-board-inset: rgba(0, 0, 0, 0.22);
  --ch-cell-l: #ecd9bc;
  --ch-cell-l-fg: #4a3d2e;
  --ch-cell-d: #7a5c3e;
  --ch-cell-d-fg: #f2e6d4;
  --ch-sel: rgba(255, 200, 90, 0.4);
  --ch-mv-dot: rgba(60, 42, 28, 0.35);
  --ch-mv-ring: rgba(40, 28, 18, 0.32);
  --ch-mv-glow: rgba(255, 200, 120, 0.2);
  --ch-cap-b: rgba(190, 60, 45, 0.9);
  --ch-cap-bg: rgba(255, 200, 140, 0.22);
  --ch-w-fb: #fffaf0;
  --ch-w1: #ffffff;
  --ch-w2: #f5ebe0;
  --ch-w3: #ffffff;
  --ch-w-drop: rgba(0, 0, 0, 0.55);
  --ch-b1: #1c140c;
  --ch-b2: #120c08;
  --ch-b-str: rgba(248, 236, 220, 0.9);
  --ch-b-sh1: rgba(80, 55, 35, 0.35);
  --ch-b-sh2: rgba(0, 0, 0, 0.35);
  --ch-last: rgba(255, 190, 70, 0.52);
  --ch-bota1: rgba(255, 220, 140, 0.5);
  --ch-bota2: rgba(200, 170, 100, 0.35);
  --ch-botb1: rgba(230, 200, 130, 0.45);
  --ch-botb2: rgba(180, 150, 90, 0.25);
  --ch-chk: #c24a38;
  --ch-chk-b: rgba(60, 25, 15, 0.38);
  --ch-captured-bg: rgba(255, 255, 255, 0.4);
  --ch-captured-border: rgba(78, 112, 62, 0.28);
}

/* Северный сад — светлый зелёный */
body[data-board-profile="north"] {
  --ch-frame-border: #8a7f6e;
  --ch-frame-bg: #b8a892;
  --ch-board-bg: #c3b49c;
  --ch-board-inset: rgba(255, 255, 255, 0.28);
  --ch-cell-l: linear-gradient(162deg, #efe9dc 0%, #e7dfcf 58%, #d9cfbb 100%);
  --ch-cell-l-fg: #6c655c;
  --ch-cell-d: linear-gradient(150deg, #aaaeb4 0%, #979da4 52%, #868d95 100%);
  --ch-cell-d-fg: #f1eee7;
  --ch-sel: rgba(94, 144, 82, 0.32);
  --ch-mv-dot: rgba(128, 134, 62, 0.44);
  --ch-mv-ring: rgba(72, 86, 38, 0.32);
  --ch-mv-glow: rgba(132, 160, 78, 0.2);
  --ch-cap-b: rgba(164, 96, 70, 0.68);
  --ch-cap-bg: rgba(210, 150, 95, 0.15);
  --ch-w-fb: #ffffff;
  --ch-w1: #ffffff;
  --ch-w2: #f3faec;
  --ch-w3: #ffffff;
  --ch-w-drop: rgba(46, 80, 38, 0.52);
  --ch-b1: #172017;
  --ch-b2: #101810;
  --ch-b-str: rgba(242, 250, 232, 0.96);
  --ch-b-sh1: rgba(110, 150, 100, 0.32);
  --ch-b-sh2: rgba(15, 40, 15, 0.36);
  --ch-last: rgba(92, 132, 86, 0.36);
  --ch-bota1: rgba(108, 156, 94, 0.38);
  --ch-bota2: rgba(78, 126, 72, 0.2);
  --ch-botb1: rgba(96, 140, 86, 0.34);
  --ch-botb2: rgba(70, 118, 66, 0.18);
  --ch-chk: #d4dcc6;
  --ch-chk-b: rgba(126, 78, 66, 0.4);
  --ch-captured-bg: rgba(255, 255, 255, 0.4);
  --ch-captured-border: rgba(78, 112, 62, 0.28);
}

.layout {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
  padding: 24px 24px 8px;
}

.game-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-area {
  display: flex;
  flex-direction: column;
  width: 280px;
}

.clock-panel {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: min(82vw, 560px);
}

.clock-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #2e3557;
  border-radius: 10px;
  background: rgba(22, 29, 56, 0.92);
  color: #c4ccee;
  padding: 10px 12px;
}

.clock-card.active {
  border-color: rgba(255, 212, 71, 0.78);
  box-shadow: 0 0 18px rgba(255, 212, 71, 0.18);
}

body.bot-thinking .clock-card.active {
  border-color: rgba(120, 190, 255, 0.85);
  box-shadow: 0 0 22px rgba(100, 170, 255, 0.28);
  animation: bot-clock-pulse 0.9s ease-in-out infinite;
}

@keyframes bot-clock-pulse {
  0%,
  100% {
    box-shadow: 0 0 16px rgba(100, 170, 255, 0.22);
  }
  50% {
    box-shadow: 0 0 26px rgba(130, 200, 255, 0.38);
  }
}

.clock-card strong {
  color: #edf2ff;
  font-size: 20px;
  letter-spacing: 0.5px;
}

.captured-bar {
  width: min(82vw, 560px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 4px 0;
  font-size: 13px;
  color: #a8b0c8;
}

.captured-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  line-height: 1.35;
}

.captured-label {
  flex: 0 0 auto;
  min-width: 7.5rem;
  color: #8a94b0;
}

.captured-glyphs {
  flex: 1 1 auto;
  font-size: clamp(16px, 3.5vw, 26px);
  line-height: 1;
  letter-spacing: 0.06em;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols2", "Apple Symbols", "Arial Unicode MS", sans-serif;
  color: #d0d6e8;
  min-height: 1.2em;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.02em 0.12em;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--ch-captured-bg, rgba(238, 238, 210, 0.12));
  border: 1px solid var(--ch-captured-border, rgba(118, 150, 86, 0.3));
}

.captured-glyphs .piece.captured-taken {
  position: static;
  display: inline-block;
  pointer-events: none;
  font-size: 1em;
  font-weight: 500;
  line-height: 1;
  vertical-align: middle;
}

.captured-glyphs .piece.captured-taken .piece-svg {
  width: 0.9em;
  height: 0.9em;
}

.captured-glyphs .piece.captured-taken .piece-img {
  width: 0.9em;
  height: 0.9em;
}

.board-wrap {
  position: relative;
  border: 2px solid var(--ch-frame-border);
  background: var(--ch-frame-bg);
  padding: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(82vw, 560px);
  height: min(82vw, 560px);
  max-width: calc(100vh - 56px);
  max-height: calc(100vh - 56px);
  background: var(--ch-board-bg);
  touch-action: manipulation;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--ch-board-inset);
  --ch-piece-stroke-px: 1px;
  --ch-piece-shadow: 0 0.06em 0.1em var(--ch-b-sh1), 0 0.11em 0.18em var(--ch-b-sh2);
}

.board.animating-bot-move {
  pointer-events: none;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 0;
  margin: 0;
  padding: 0;
  color: #edf2ff;
  font-size: clamp(36px, 10.5vw, 76px);
  line-height: 0.92;
  cursor: pointer;
}

.cell.light {
  background: var(--ch-cell-l);
  color: var(--ch-cell-l-fg);
}

.cell.dark {
  background: var(--ch-cell-d);
  color: var(--ch-cell-d-fg);
}

.cell.selected {
  box-shadow: inset 0 0 0 2px var(--ch-sel);
  border-radius: 1px;
}

.cell.move-target::after,
.cell.capture-target::after {
  content: "";
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 999px;
  background: var(--ch-mv-dot);
  border: 2px solid var(--ch-mv-ring);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 8px 1px var(--ch-mv-glow);
  z-index: 2;
}

.cell.capture-target::after {
  width: 74%;
  height: 74%;
  border: 3px solid var(--ch-cap-b);
  background: var(--ch-cap-bg);
  box-shadow: inset 0 0 0 1px var(--ch-mv-ring), 0 0 10px 1px var(--ch-mv-glow);
}

.piece {
  position: relative;
  z-index: 1;
  pointer-events: none;
  font-weight: 500;
  letter-spacing: 0.02em;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols2", "Apple Symbols", "Arial Unicode MS", sans-serif;
  text-rendering: optimizeLegibility;
  paint-order: stroke fill;
}

.piece--svg {
  line-height: 0;
  display: grid;
  place-items: center;
}

.piece--img {
  line-height: 0;
  display: grid;
  place-items: center;
}

.piece-svg {
  width: 0.88em;
  height: 0.88em;
  overflow: visible;
}

.piece-img {
  width: 0.9em;
  height: 0.9em;
  object-fit: contain;
  filter: drop-shadow(0 0.04em 0.08em rgba(0, 0, 0, 0.28));
}

/* Sashite: чёрный глянец и молочно-кремовые светлые фигуры */
body[data-piece-style="sashite"] .piece--img.white-piece .piece-img {
  transform: scale(1.02);
  filter:
    brightness(1.2)
    contrast(0.92)
    sepia(0.34)
    saturate(0.72)
    hue-rotate(-10deg)
    drop-shadow(0 0.09em 0.13em rgba(103, 82, 50, 0.42))
    drop-shadow(0 -0.02em 0.04em rgba(255, 255, 255, 0.5));
}

body[data-piece-style="sashite"] .piece--img.black-piece .piece-img {
  transform: scale(1.02);
  filter:
    brightness(0.36)
    contrast(1.42)
    saturate(0.62)
    hue-rotate(196deg)
    drop-shadow(0 0.1em 0.14em rgba(0, 0, 0, 0.58))
    drop-shadow(0 -0.02em 0.04em rgba(210, 225, 255, 0.28));
}

.piece-shape-main {
  fill: currentColor;
}

.piece-shape-gloss {
  fill: rgba(255, 255, 255, 0.3);
}

.piece.rotated-180 {
  transform: rotate(180deg);
}

.piece.moving-hidden {
  opacity: 0;
}

.bot-moving-piece {
  position: absolute;
  z-index: 20;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  line-height: 0.92;
  pointer-events: none;
  will-change: transform;
  transform: translate3d(0, 0, 0) scale(1.05);
  animation: bot-piece-slide 0.82s cubic-bezier(0.22, 0.74, 0.25, 1) forwards;
}

@keyframes bot-piece-slide {
  0% {
    transform: translate3d(0, 0, 0) scale(1.08);
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.35));
  }
  72% {
    transform: translate3d(var(--bot-piece-dx), var(--bot-piece-dy), 0) scale(1.08);
    filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.38));
  }
  100% {
    transform: translate3d(var(--bot-piece-dx), var(--bot-piece-dy), 0) scale(1);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
  }
}

/* Старые движки: плоский тёплый / тёмный тон */
.piece.white-piece {
  font-weight: 700;
  color: var(--ch-w-fb);
  text-shadow: 0 0.05em 0.08em rgba(0, 0, 0, 0.7), 0 0 0.04em rgba(0, 0, 0, 0.55);
}

.piece.black-piece {
  font-weight: 700;
  text-rendering: geometricPrecision;
  color: var(--ch-b1);
  -webkit-text-fill-color: var(--ch-b2);
  -webkit-text-stroke: var(--ch-piece-stroke-px) var(--ch-b-str);
  text-shadow: var(--ch-piece-shadow);
}

@supports (background-clip: text) or (-webkit-background-clip: text) {
  .piece.white-piece {
    color: transparent;
    background: linear-gradient(158deg, var(--ch-w1) 0%, var(--ch-w1) 58%, var(--ch-w2) 82%, var(--ch-w3) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
    filter: drop-shadow(0 0.08em 0.1em var(--ch-w-drop)) drop-shadow(0 0 0.035em rgba(0, 0, 0, 0.5));
  }
}

/* Вариант 2: Силуэт (плоские фигуры, контрастные как вырезанные) */
body[data-piece-style="silhouette"] .piece.white-piece:not(.piece--svg):not(.piece--img) {
  color: #f3f4f8;
  -webkit-text-fill-color: #f3f4f8;
  -webkit-text-stroke: calc(var(--ch-piece-stroke-px) * 0.95) rgba(80, 84, 98, 0.75);
  background: none !important;
  filter: drop-shadow(0 0.04em 0.06em rgba(0, 0, 0, 0.28));
  text-shadow: none;
}

body[data-piece-style="silhouette"] .piece.black-piece:not(.piece--svg):not(.piece--img) {
  color: #0b0f16;
  -webkit-text-fill-color: #0b0f16;
  -webkit-text-stroke: calc(var(--ch-piece-stroke-px) * 0.9) rgba(198, 205, 222, 0.42);
  filter: drop-shadow(0 0.05em 0.08em rgba(0, 0, 0, 0.35));
  text-shadow: none;
}

/* Вариант 3: Глянец (блики и более объёмные тона) */
body[data-piece-style="glossy"] .piece.white-piece:not(.piece--svg):not(.piece--img) {
  color: transparent;
  background: linear-gradient(178deg, #fffef8 0%, #f4e8cb 44%, #dcc49a 62%, #f7ead5 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: calc(var(--ch-piece-stroke-px) * 0.86) rgba(92, 74, 46, 0.45);
  filter:
    drop-shadow(0 0.07em 0.1em rgba(95, 72, 34, 0.32))
    drop-shadow(0 -0.02em 0.03em rgba(255, 255, 255, 0.4));
  text-shadow: none;
}

body[data-piece-style="glossy"] .piece.black-piece:not(.piece--svg):not(.piece--img) {
  color: transparent;
  background: linear-gradient(175deg, #5c6470 0%, #1f2834 42%, #090d13 70%, #2f3641 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: calc(var(--ch-piece-stroke-px) * 0.92) rgba(210, 220, 236, 0.48);
  filter:
    drop-shadow(0 0.07em 0.1em rgba(0, 0, 0, 0.45))
    drop-shadow(0 -0.02em 0.03em rgba(210, 220, 236, 0.3));
  text-shadow: none;
}

body[data-piece-style="silhouette"] .piece--svg.white-piece {
  color: #eef1f8;
  filter: drop-shadow(0 0.04em 0.06em rgba(0, 0, 0, 0.28));
}

body[data-piece-style="silhouette"] .piece--svg.black-piece {
  color: #0b0f16;
  filter: drop-shadow(0 0.05em 0.08em rgba(0, 0, 0, 0.35));
}

body[data-piece-style="silhouette"] .piece--svg .piece-shape-gloss {
  fill: rgba(255, 255, 255, 0.08);
}

body[data-piece-style="glossy"] .piece--svg.white-piece {
  color: #d7bb88;
  filter:
    drop-shadow(0 0.07em 0.1em rgba(95, 72, 34, 0.32))
    drop-shadow(0 -0.02em 0.03em rgba(255, 255, 255, 0.4));
}

body[data-piece-style="glossy"] .piece--svg.black-piece {
  color: #1a212d;
  filter:
    drop-shadow(0 0.07em 0.1em rgba(0, 0, 0, 0.45))
    drop-shadow(0 -0.02em 0.03em rgba(210, 220, 236, 0.3));
}

body[data-piece-style="glossy"] .piece--svg .piece-shape-gloss {
  fill: rgba(245, 250, 255, 0.42);
}

/* Снятые фигуры — те же тона, что и фигуры на доске (чёрные тёмные, белые светлые) */
.captured-glyphs .piece.captured-taken.black-piece {
  font-weight: 700;
  color: var(--ch-b1);
  -webkit-text-fill-color: var(--ch-b2);
  background: none !important;
  -webkit-text-stroke: 0.55px var(--ch-b-str);
  paint-order: stroke fill;
  text-shadow: 0 0.03em 0.06em var(--ch-b-sh2), 0 0 0.02em var(--ch-b-sh1);
  filter: none !important;
}

.captured-glyphs .piece.captured-taken.white-piece {
  font-weight: 700;
  color: var(--ch-w-fb) !important;
  background: none !important;
  -webkit-background-clip: border-box !important;
  background-clip: border-box !important;
  -webkit-text-fill-color: var(--ch-w1) !important;
  -webkit-text-stroke: 0.45px rgba(30, 35, 28, 0.35);
  paint-order: stroke fill;
  text-shadow: 0 0.05em 0.08em rgba(0, 0, 0, 0.35);
  filter: none !important;
}

.last-move {
  position: relative;
  z-index: 2;
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.62),
    inset 0 0 0 5px rgba(255, 218, 86, 0.98),
    inset 0 0 0 7px rgba(0, 0, 0, 0.5);
}

.bot-last-move {
  animation: bot-move-pulse 1.8s ease-out;
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.62),
    inset 0 0 0 5px rgba(130, 220, 255, 0.98),
    inset 0 0 0 7px rgba(0, 0, 0, 0.5),
    0 0 16px rgba(90, 190, 255, 0.42);
}

@keyframes bot-move-pulse {
  0% {
    box-shadow:
      inset 0 0 0 2px rgba(0, 0, 0, 0.52),
      inset 0 0 0 5px rgba(190, 245, 255, 1),
      inset 0 0 0 7px rgba(0, 0, 0, 0.42),
      0 0 22px rgba(120, 220, 255, 0.6);
  }
  100% {
    box-shadow:
      inset 0 0 0 2px rgba(0, 0, 0, 0.62),
      inset 0 0 0 5px rgba(130, 220, 255, 0.98),
      inset 0 0 0 7px rgba(0, 0, 0, 0.5),
      0 0 16px rgba(90, 190, 255, 0.42);
  }
}

.check {
  background: var(--ch-chk) !important;
  box-shadow: inset 0 0 0 1px var(--ch-chk-b);
}

.panel {
  width: 280px;
  background: rgba(22, 29, 56, 0.92);
  border: 1px solid #2e3557;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
  font-size: 14px;
  line-height: 1.35;
}

h1,
h2 {
  margin: 0 0 12px;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 15px;
  margin-top: 16px;
}

.stat {
  margin-bottom: 6px;
  line-height: 1.35;
}

.stat span {
  color: #e6ecfb;
  font-weight: 700;
}

.bot-metrics-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  letter-spacing: -0.01em;
}

.move-history-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #2e3557;
  font-size: 13px;
}

.move-history-prev {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  margin-bottom: 8px;
}

.move-history-label {
  color: #9aa8cf;
  font-weight: 600;
}

.move-history-last {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 700;
  font-size: 14px;
  color: #fff8dc;
  letter-spacing: 0.02em;
}

.move-history-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7f8bb7;
  margin-bottom: 4px;
}

.move-history-hint {
  margin: 0 0 8px;
  font-size: 11px;
  line-height: 1.35;
  color: #7a87ad;
}

.move-history-list {
  max-height: 168px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(8, 10, 20, 0.55);
  border: 1px solid #2a3558;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
}

.move-history-pair {
  padding: 2px 0;
  border-bottom: 1px solid rgba(46, 53, 87, 0.45);
}

.move-history-pair:last-child {
  border-bottom: none;
}

.move-history-pair--last {
  background: rgba(255, 210, 90, 0.12);
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: 4px;
}

.move-history-num {
  color: #7f8bb7;
  font-weight: 600;
  min-width: 1.75rem;
  display: inline-block;
}

.move-history-white {
  color: #e8ecff;
  font-weight: 700;
}

.move-history-black {
  color: #b8caf5;
  font-weight: 600;
}

.move-history-list .move-history-start {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 6px 8px;
  border: 1px solid #3a4568;
  border-radius: 6px;
  background: rgba(24, 32, 58, 0.9);
  color: #c8d2f0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  text-align: center;
}

.move-history-list button.move-history-movable {
  display: inline;
  width: auto;
  max-width: 100%;
  margin: 0;
  padding: 1px 5px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  text-align: left;
  vertical-align: baseline;
}

.move-history-list .move-history-movable:hover,
.move-history-list .move-history-start:hover {
  background: rgba(48, 62, 102, 0.45);
}

.move-history-list .move-history-movable--active,
.move-history-list .move-history-start.move-history-movable--active {
  background: rgba(255, 210, 90, 0.2);
  border-color: rgba(255, 210, 90, 0.42);
}

.move-history-empty {
  color: #7f8bb7;
  font-style: italic;
}

.mobile-move-history-section {
  display: none;
  width: min(94vw, 520px);
}

.controls ul {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.35;
}

.controls li {
  margin-bottom: 4px;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
}

.setting-row--inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setting-row--inline input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

select {
  width: 100%;
  border: 1px solid #45568f;
  border-radius: 8px;
  background: #10162b;
  color: #d9e1f4;
  padding: 10px 12px;
  font-size: 14px;
}

button {
  margin-top: 16px;
  width: 100%;
  border: none;
  border-radius: 8px;
  background: #4a8bff;
  color: #edf2ff;
  padding: 10px 12px;
  font-size: 15px;
  cursor: pointer;
}

button:hover {
  background: #6ca2ff;
}

.mobile-stats,
.mobile-info-toggle,
.mobile-info-panel {
  display: none;
}

.app-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 12px 0 6px;
  color: #7f8bb7;
  font-size: 13px;
}

.app-footer .footer-sep,
.mobile-app-footer .footer-sep {
  opacity: 0.45;
  user-select: none;
  padding: 0 6px;
}

.app-footer .footer-game,
.mobile-app-footer .footer-game {
  color: #b4c0e0;
  font-weight: 600;
}

.footer-lab-link {
  color: inherit;
  text-decoration: none;
  transition: color 160ms ease;
}

.footer-lab-link:hover {
  color: #b4c0e0;
}

.footer-lab-link .footer-brand {
  color: #d9e1f4;
  font-weight: 400;
  letter-spacing: -0.4px;
}

.footer-lab-link:hover .footer-brand {
  color: #edf2ff;
}

.footer-lab-link .brand-off {
  color: #4a8bff;
}

.footer-lab-link .brand-lab {
  color: #7fb0ff;
  font-size: 0.64em;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.footer-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.footer-wrap .app-footer {
  padding: 12px 0 6px;
}

.footer-hub-link {
  color: #4a8bff;
  font-size: 12px;
  text-decoration: none;
  transition: color 160ms ease;
}

.footer-hub-link:hover {
  color: #7fb0ff;
  text-decoration: underline;
}

.footer-feedback-link {
  color: #fbbf24;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
  text-decoration: none;
  transition: color 160ms ease;
}

.footer-feedback-link:hover {
  color: #fde68a;
  text-decoration: underline;
}

.mobile-app-footer {
  display: none;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
  z-index: 5000;
}

.overlay-content {
  position: relative;
  z-index: 1;
  width: min(90vw, 360px);
  border: 1px solid #3d4772;
  border-radius: 10px;
  background: #1b2442;
  padding: 20px;
  text-align: center;
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  body {
    overflow-x: hidden;
  }

  .game-area {
    width: min(94vw, 520px);
  }

  .layout {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100svh;
    padding: 28px 14px 12px;
    gap: 10px;
  }

  .board-wrap {
    width: 100%;
    padding: 6px;
  }

  .clock-panel {
    width: 100%;
  }

  .clock-card {
    padding: 8px 10px;
    font-size: 13px;
  }

  .clock-card strong {
    font-size: 18px;
  }

  .board {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    max-width: none;
    max-height: none;
  }

  .cell {
    /* Целые пиксели + vmin — меньше «мыла» от дробного vw */
    font-size: max(32px, min(56px, 11.5vmin));
    line-height: 1.02;
  }

  .board .piece {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    font-smooth: always;
    letter-spacing: 0;
    font-weight: 700;
  }

  .board .piece.white-piece:not(.bot-moving-piece):not(.piece--svg):not(.piece--img),
  .board .piece.black-piece:not(.bot-moving-piece):not(.piece--svg):not(.piece--img) {
    filter: none !important;
  }

  .board .piece.white-piece:not(.bot-moving-piece):not(.piece--svg):not(.piece--img) {
    color: var(--ch-w1) !important;
    background: none !important;
    -webkit-background-clip: border-box !important;
    background-clip: border-box !important;
    -webkit-text-fill-color: var(--ch-w1) !important;
    -webkit-text-stroke: 0.55px rgba(30, 35, 28, 0.42);
    paint-order: stroke fill;
    text-shadow:
      0 0 0.04em rgba(0, 0, 0, 0.45),
      0 0.06em 0.02em rgba(0, 0, 0, 0.22);
  }

  .board .piece.black-piece:not(.bot-moving-piece):not(.piece--svg):not(.piece--img) {
    color: var(--ch-b1) !important;
    -webkit-text-fill-color: var(--ch-b2) !important;
    -webkit-text-stroke: 0.55px var(--ch-b-str);
    paint-order: stroke fill;
    text-shadow: 0 0.04em 0.06em var(--ch-b-sh2);
  }

  body[data-piece-style="silhouette"] .board .piece.white-piece:not(.bot-moving-piece):not(.piece--svg):not(.piece--img) {
    color: #f2f3f8 !important;
    -webkit-text-fill-color: #f2f3f8 !important;
    -webkit-text-stroke: 0.5px rgba(70, 74, 88, 0.72) !important;
    filter: drop-shadow(0 0.04em 0.07em rgba(0, 0, 0, 0.28));
    text-shadow: none;
  }

  body[data-piece-style="silhouette"] .board .piece.black-piece:not(.bot-moving-piece):not(.piece--svg):not(.piece--img) {
    color: #0b1017 !important;
    -webkit-text-fill-color: #0b1017 !important;
    -webkit-text-stroke: 0.5px rgba(200, 208, 224, 0.4) !important;
    filter: drop-shadow(0 0.05em 0.08em rgba(0, 0, 0, 0.36));
    text-shadow: none;
  }

  body[data-piece-style="glossy"] .board .piece.white-piece:not(.bot-moving-piece):not(.piece--svg):not(.piece--img) {
    color: transparent !important;
    background: linear-gradient(178deg, #fffef8 0%, #f4e8cb 44%, #dcc49a 62%, #f7ead5 100%) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    -webkit-text-stroke: 0.5px rgba(92, 74, 46, 0.45) !important;
    filter:
      drop-shadow(0 0.07em 0.1em rgba(95, 72, 34, 0.32))
      drop-shadow(0 -0.02em 0.03em rgba(255, 255, 255, 0.4));
    text-shadow: none;
  }

  body[data-piece-style="glossy"] .board .piece.black-piece:not(.bot-moving-piece):not(.piece--svg):not(.piece--img) {
    color: transparent !important;
    background: linear-gradient(175deg, #5c6470 0%, #1f2834 42%, #090d13 70%, #2f3641 100%) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    -webkit-text-stroke: 0.5px rgba(210, 220, 236, 0.48) !important;
    filter:
      drop-shadow(0 0.07em 0.1em rgba(0, 0, 0, 0.45))
      drop-shadow(0 -0.02em 0.03em rgba(210, 220, 236, 0.3));
    text-shadow: none;
  }

  .mobile-move-history-section:not(.hidden) {
    display: block;
  }

  .captured-bar {
    width: 100%;
  }

  .captured-label {
    min-width: 6.5rem;
  }

  .side-area {
    display: none;
  }

  .panel {
    display: none;
  }

  .mobile-stats {
    display: flex;
    justify-content: space-between;
    width: 100%;
    border: 1px solid #2e3557;
    border-radius: 8px;
    background: rgba(22, 29, 56, 0.92);
    padding: 8px 10px;
    font-size: 14px;
  }

  .mobile-info-toggle {
    display: block;
    width: 100%;
    margin-top: 0;
    background: #2f3b64;
    padding: 4px 12px 7px;
    font-size: 18px;
    line-height: 1;
  }

  .mobile-info-panel {
    width: 100%;
    border: 1px solid #2e3557;
    border-radius: 8px;
    background: rgba(22, 29, 56, 0.92);
    padding: 10px;
    overflow-x: hidden;
  }

  .mobile-info-panel .setting-row--inline span {
    min-width: 0;
    flex: 1 1 auto;
    overflow-wrap: anywhere;
  }

  .mobile-info-panel.hidden {
    display: none;
  }

  .mobile-info-panel:not(.hidden) {
    display: block;
  }

  .mobile-app-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 14px;
    padding: 4px 0;
    color: #7f8bb7;
    font-size: 12px;
  }

}
