/* =========================================================================
   НЕЙРОШАХМАТЫ — неоморфизм + минимализм
   Палитра: тёплая слоновая кость (светлая), чёрно-серая (тёмная)
   ========================================================================= */

:root {
  --bg: #E8E2D6;
  --bg-alt: #EEE9DE;
  --shadow-dark: #C6BFB0;
  --shadow-light: #FFFFFF;

  --text: #322D26;
  --text-muted: #8C8272;

  --accent: #7B3B3E;
  --accent-dark: #5E2C2E;
  --accent-soft: rgba(123, 59, 62, 0.12);

  --gold: #AD8A4E;
  --gold-soft: rgba(173, 138, 78, 0.22);

  --danger: #A1453D;
  --danger-dark: #832F2F;

  --board-light: #F0E7D8;
  --board-dark: #9C7B54;

  --home-cell-a: #EFEAE0;
  --home-cell-b: #E6DFCF;

  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;

  --sd-lg: 10px 10px 22px var(--shadow-dark), -10px -10px 22px var(--shadow-light);
  --sd-md: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
  --sd-sm: 3px 3px 7px var(--shadow-dark), -3px -3px 7px var(--shadow-light);
  --inset-lg: inset 8px 8px 16px var(--shadow-dark), inset -8px -8px 16px var(--shadow-light);
  --inset-sm: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

/* ===== ТЁМНАЯ ТЕМА – ЧЁРНО-СЕРАЯ ===== */
html.dark {
  --bg: #0d0d0d;
  --bg-alt: #181818;
  --shadow-dark: #000000;
  --shadow-light: #222222;

  --text: #e8e8e8;
  --text-muted: #888888;

  --accent: #d4a547;
  --accent-dark: #b8923a;
  --accent-soft: rgba(212, 165, 71, 0.15);

  --gold: #d4a547;
  --gold-soft: rgba(212, 165, 71, 0.2);

  --danger: #cc5555;
  --danger-dark: #e06666;

  --board-light: #5a5248;
  --board-dark: #36302a;

  --home-cell-a: #1a1a1a;
  --home-cell-b: #222222;

  --sd-lg: 8px 8px 20px #000000, -4px -4px 20px #2a2a2a;
  --sd-md: 5px 5px 14px #000000, -3px -3px 14px #2a2a2a;
  --sd-sm: 3px 3px 8px #000000, -2px -2px 8px #2a2a2a;
  --inset-lg: inset 6px 6px 12px #000000, inset -6px -6px 12px #2a2a2a;
  --inset-sm: inset 3px 3px 6px #000000, inset -3px -3px 6px #2a2a2a;
}
html.dark .modal-overlay { background: rgba(0, 0, 0, 0.75); }
html.dark .msg-assistant { box-shadow: var(--sd-sm); }

/* ===== АКЦЕНТНЫЕ ЦВЕТОВЫЕ СХЕМЫ ===== */
:root[data-accent="gold"]   { --accent: #AD8A4E; --accent-dark: #8C6F3C; --accent-soft: rgba(173,138,78,0.16); --gold: #AD8A4E; --gold-soft: rgba(173,138,78,0.22); --achv-modal-bg: rgba(30, 28, 22, 0.92); }
:root[data-accent="maroon"] { --accent: #7B3B3E; --accent-dark: #5E2C2E; --accent-soft: rgba(123,59,62,0.16);  --gold: #C08A56; --gold-soft: rgba(192,138,86,0.22); --achv-modal-bg: rgba(35, 26, 26, 0.93);}
:root[data-accent="blue"]   { --accent: #2B5FA8; --accent-dark: #204A85; --accent-soft: rgba(43,95,168,0.16);  --gold: #4D7FC9; --gold-soft: rgba(77,127,201,0.22); --achv-modal-bg: rgba(24, 28, 40, 0.93);}
:root[data-accent="green"]  { --accent: #2F7D4F; --accent-dark: #235F3C; --accent-soft: rgba(47,125,79,0.16);  --gold: #4FA070; --gold-soft: rgba(79,160,112,0.22); --achv-modal-bg: rgba(24, 34, 28, 0.93)}

html.dark[data-accent="gold"]   { --accent: #d4a547; --gold: #d4a547; --achv-modal-bg-dark: rgba(20, 18, 14, 0.95);}
html.dark[data-accent="maroon"] { --accent: #c9707a; --gold: #c9707a; --achv-modal-bg-dark: rgba(26, 18, 18, 0.96);}
html.dark[data-accent="blue"]   { --accent: #5b8fd9; --gold: #5b8fd9; --achv-modal-bg-dark: rgba(17, 18, 26, 0.96);}
html.dark[data-accent="green"]  { --accent: #5fbf85; --gold: #5fbf85; --achv-modal-bg-dark: rgba(15, 20, 17, 0.96);}

/* ===== ОФОРМЛЕНИЕ ДОСКИ ===== */
:root[data-board-style="classic"] { --board-light: #F0E7D8; --board-dark: #9C7B54; }
:root[data-board-style="mono"]    { --board-light: #E9E9E9; --board-dark: #8A8A8A; }
:root[data-board-style="contrast"]{ --board-light: #FFFFFF; --board-dark: #1A1A1A; }
html.dark[data-board-style="classic"] { --board-light: #5a5248; --board-dark: #36302a; }
html.dark[data-board-style="mono"]    { --board-light: #4a4a4a; --board-dark: #232323; }
html.dark[data-board-style="contrast"]{ --board-light: #FFFFFF; --board-dark: #000000; }

:root[data-board-style="contrast"] .notation-322f9 { opacity: 0.9 !important; font-weight: 800 !important; }
:root[data-board-style="mono"] .square-55d63.highlight-select { box-shadow: inset 0 0 0 3px #666; }

/* ===== ОТКЛЮЧЕНИЕ ЭФФЕКТОВ СВЕЧЕНИЯ ===== */
html.no-glow .home-play-text:hover { text-shadow: none; }
html.no-glow .home-oval:has(.home-play-text:hover) { box-shadow: 0 0 0 1px rgba(255,255,255,0.20), inset 0 0 0 1px rgba(0,0,0,0.04), var(--sd-lg); }
html.no-glow .home-queen { text-shadow: none; }
html.no-glow .square-55d63.highlight-move::after { box-shadow: none; }

/* ===== ПОНИЖЕННАЯ ПРОИЗВОДИТЕЛЬНОСТЬ ===== */
html.perf-low * { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
}
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.icon-btn {
  padding: 8px 12px;
  font-size: 16px;
  line-height: 1;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; color: var(--text); }

button {
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
}
textarea, input {
  font-family: var(--font-body);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

* { scrollbar-width: thin; scrollbar-color: var(--shadow-dark) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--shadow-dark); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }

/* =========================================================================
   Общие неоморфные поверхности
   ========================================================================= */
.neumorphic-raised {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--sd-lg);
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}
.neumorphic-inset {
  background: var(--bg);
  border-radius: var(--radius-md);
  box-shadow: var(--inset-lg);
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

/* =========================================================================
   Кнопки
   ========================================================================= */
.btn {
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--sd-md);
  transition: box-shadow 0.15s ease, transform 0.1s ease, color 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { box-shadow: var(--inset-sm); transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: var(--sd-md); pointer-events: none; }

.btn-sm { padding: 8px 14px; font-size: 13px; }

.btn-primary { color: var(--accent-dark); }
.btn-primary:active { color: var(--accent); }
.btn-primary {
  transition: box-shadow 0.15s ease, transform 0.1s ease, color 0.15s ease,
    background-color 0.25s ease;
}
.btn-primary.btn-primary-active {
  color: #F4EFE4;
  background: var(--accent);
  box-shadow: 6px 6px 14px var(--shadow-dark), -3px -3px 10px rgba(255,255,255,0.4);
  animation: askBtnPulse 0.35s ease;
}
.btn-primary.btn-primary-active:active { box-shadow: inset 4px 4px 8px var(--accent-dark), inset -4px -4px 8px rgba(255,255,255,0.15); }
@keyframes askBtnPulse {
  0% { transform: scale(0.94); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.btn-accent {
  background: var(--accent);
  color: #F4EFE4;
  box-shadow: 6px 6px 14px var(--shadow-dark), -3px -3px 10px rgba(255,255,255,0.4);
}
.btn-accent:active { box-shadow: inset 4px 4px 8px var(--accent-dark), inset -4px -4px 8px rgba(255,255,255,0.15); }

.btn-danger { color: var(--danger-dark); }
.btn-danger:active { color: var(--danger); }

.btn-ghost { color: var(--text-muted); }

/* =========================================================================
   Каркас приложения
   ========================================================================= */
.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px;
  margin-bottom: 26px;
}
.logo { font-size: 26px; letter-spacing: 0.3px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.badge {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-alt);
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: var(--inset-sm);
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 540px) 1fr;
  gap: 26px;
  align-items: start;
}

/* =========================================================================
   Карточка доски
   ========================================================================= */
.board-card {
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.board-frame {
  padding: 18px;
  display: flex;
  justify-content: center;
}

#board {
  width: min(460px, 100%);
  /* chessboard.js вешает touchmove на window, а там Chrome делает обработчик
     пассивным — preventDefault не срабатывает и вместо перетаскивания фигуры
     листается страница. Запрещаем жесты браузера прямо над доской. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
/* Фигура, которую тащат, живёт в body, вне #board */
img.piece-417db { -webkit-user-drag: none; -webkit-touch-callout: none; }

.board-b72b1 {
  border: none !important;
  border-radius: 10px;
  overflow: hidden;
}
.white-1e1d7 { background-color: var(--board-light) !important; }
.black-3c85d { background-color: var(--board-dark) !important; }
.notation-322f9 { font-family: var(--font-body) !important; font-weight: 600; opacity: 0.55; }

.square-55d63.highlight-select {
  box-shadow: inset 0 0 0 3px var(--gold);
}
.square-55d63.highlight-move::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 26%; height: 26%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--gold-soft);
  border: 2px solid var(--gold);
  pointer-events: none;
}
.square-55d63.highlight-capture::after {
  width: 78%; height: 78%;
  background: transparent;
}
.square-55d63.highlight-check {
  box-shadow: inset 0 0 0 4px var(--danger);
  animation: pulse-check 1.1s ease-in-out infinite;
}
@keyframes pulse-check {
  0%, 100% { box-shadow: inset 0 0 0 4px var(--danger); }
  50% { box-shadow: inset 0 0 0 2px var(--danger); }
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 6px;
}
.status-text { font-weight: 600; font-size: 15px; }

.thinking { display: flex; gap: 5px; }
.thinking span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: bounce 1s infinite ease-in-out;
}
.thinking span:nth-child(2) { animation-delay: 0.15s; }
.thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-6px); opacity: 1; }
}

.connection-banner {
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  box-shadow: var(--inset-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.connection-banner p { margin: 0; font-size: 13.5px; color: var(--danger-dark); line-height: 1.4; }

.captured-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.captured-group {
  flex: 1;
  min-width: 160px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  box-shadow: var(--inset-sm);
  padding: 10px 14px;
}
.captured-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.captured-pieces { font-size: 20px; letter-spacing: 2px; min-height: 26px; }

.controls-row { display: flex; gap: 12px; }
.controls-row .btn { flex: 1 1 0; text-align: center; }
.controls-row .btn-danger:hover { box-shadow: var(--sd-md), 0 0 18px var(--danger); }
.controls-row .btn-ghost:hover { box-shadow: var(--sd-md), 0 0 18px var(--accent-soft); }

.move-list-wrap {
  max-height: 190px;
  overflow-y: auto;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  box-shadow: var(--inset-sm);
  padding: 10px 8px;
}
.move-list { display: flex; flex-direction: column; gap: 2px; }
.move-row {
  display: grid;
  grid-template-columns: 32px 1fr 1fr;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s;
}
.move-row:hover {
  background: var(--accent-soft);
}
.move-row:nth-child(odd) { background: rgba(0,0,0,0.02); }
.move-num { color: var(--text-muted); }
.move-white, .move-black { font-weight: 600; }

/* =========================================================================
   Карточка чата
   ========================================================================= */
.chat-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 560px;
  max-height: 700px;
}
.chat-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.chat-header h2 { font-size: 20px; }
.chat-hint { font-size: 12px; color: var(--text-muted); }

.chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 4px 16px;
  background: var(--bg-alt);
  border-radius: var(--radius-md);
  box-shadow: var(--inset-sm);
  margin-bottom: 14px;
  min-height: 100px;
}

.msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-user {
  align-self: flex-end;
  background: var(--accent-soft);
  color: var(--text);
  border-bottom-right-radius: 4px;
}
.msg-assistant {
  align-self: flex-start;
  background: var(--bg);
  box-shadow: var(--sd-sm);
  border-bottom-left-radius: 4px;
}
.msg-system {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  text-align: center;
  max-width: 100%;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input-row textarea {
  flex: 1;
  resize: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--bg);
  box-shadow: var(--inset-sm);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.4;
}
.chat-input-row textarea::placeholder { color: var(--text-muted); }

/* =========================================================================
   Модалки
   ========================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(50, 45, 38, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  max-height: 90vh;
  overflow-y: auto;
  width: 100%;
  max-width: 420px;
  padding: 34px 30px;
  text-align: center;
}
.modal.wide { max-width: 520px; text-align: left; }
.modal h2 { text-align: center; font-size: 24px; margin-bottom: 8px; }
.modal.wide h2 { text-align: left; }
.modal-sub { color: var(--text-muted); font-size: 14px; margin: 6px 0 22px; text-align: center; }
.modal.wide .modal-sub { text-align: left; }

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal.wide .modal-actions { flex-direction: row; justify-content: flex-end; }
.modal-actions .btn { width: 100%; }
.modal.wide .modal-actions .btn { width: auto; }

/* =========================================================================
   Модалка сложности
   ========================================================================= */
.difficulty-modal .diff-section { margin: 18px 0; }
.diff-section-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.color-choice-row, .diff-choice-row { display: flex; gap: 10px; }
.color-choice-btn, .diff-choice-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--text);
  box-shadow: var(--sd-sm);
  border: 2px solid transparent;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.color-choice-btn:hover, .diff-choice-btn:hover { transform: translateY(-1px); }
.color-choice-btn.is-active, .diff-choice-btn.is-active {
  box-shadow: var(--inset-sm);
}
.color-choice-swatch {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  flex-shrink: 0;
}
.color-choice-white { background: #F6F1E6; }
.color-choice-black { background: #2A241D; border-color: #2A241D; }
.color-choice-btn.is-active[data-color="w"] { border-color: var(--gold); }
.color-choice-btn.is-active[data-color="b"] { border-color: var(--accent); }

.diff-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.diff-easy .diff-dot   { background: #5FAE6E; }
.diff-medium .diff-dot { background: #D9A441; }
.diff-hard .diff-dot   { background: #C0574F; }
.diff-easy.is-active   { border-color: #5FAE6E; }
.diff-medium.is-active { border-color: #D9A441; }
.diff-hard.is-active   { border-color: #C0574F; }

/* =========================================================================
   Режим «Против персонажей»
   ========================================================================= */
.beta-tag {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-alt);
  box-shadow: var(--inset-sm);
  padding: 3px 8px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 8px;
}
.character-modal { max-width: 560px; }

.char-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-alt);
  box-shadow: var(--inset-sm);
  padding: 5px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}
.char-tab {
  flex: 1;
  padding: 10px 8px;
  border-radius: calc(var(--radius-sm) - 4px);
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.char-tab.is-active {
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--sd-sm);
}

.char-tab-panel { margin-bottom: 8px; }

.char-text-input, .char-textarea {
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  background: var(--bg);
  box-shadow: var(--inset-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
}
.char-textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.char-text-input::placeholder, .char-textarea::placeholder { color: var(--text-muted); }

.char-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.char-example-chip {
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--sd-sm);
  transition: color 0.15s ease, box-shadow 0.15s ease;
}
.char-example-chip:hover { color: var(--accent-dark); box-shadow: var(--inset-sm); }

.char-setup-error {
  color: var(--danger-dark);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
}

/* ---- Карточка персонажа ---- */
.character-card-modal { max-width: 660px; }
.char-card-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 30px 0;
  color: var(--text-muted);
  font-size: 13.5px;
}
.char-card-loading .thinking { justify-content: center; }

.char-card-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}
.char-card-icon {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  border-radius: 50%;
  background: var(--bg-alt);
  box-shadow: var(--inset-sm);
  color: var(--accent);
}
.char-card-headtext { flex: 1; min-width: 0; }
.char-card-headtext h2 { font-size: 24px; margin-bottom: 4px; text-align: left; }
.char-card-desc { color: var(--text-muted); font-size: 14.5px; margin: 0; line-height: 1.45; }
.char-card-elo {
  flex-shrink: 0;
  align-self: flex-start;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-dark);
  background: var(--accent-soft);
  padding: 7px 13px;
  border-radius: 999px;
  white-space: pre-line;
  text-align: right;
  line-height: 1.35;
}

.char-card-section-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 16px 0 10px;
}

.char-card-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 4px;
}
.char-bar-row {
  display: grid;
  grid-template-columns: 108px 1fr 104px;
  align-items: center;
  gap: 10px;
}
.char-bar-label { font-size: 13px; color: var(--text); font-weight: 600; }
.char-bar-track {
  height: 9px;
  border-radius: 999px;
  background: var(--bg-alt);
  box-shadow: var(--inset-sm);
  overflow: hidden;
  cursor: help;
}
.char-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.char-bar-value {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-align: right;
}

.char-card-style, .char-card-tone {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin: 0 0 8px;
}
.char-card-tone { color: var(--text-muted); font-style: italic; font-size: 13px; }

.char-card-phrases-wrap { margin-top: 4px; }
.char-card-phrases {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.char-card-phrase {
  display: block;
  font-size: 13.5px;
  font-style: italic;
  color: var(--text);
  background: var(--bg-alt);
  box-shadow: var(--inset-sm);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  line-height: 1.4;
}

.char-card-opponent-note {
  display: flex;
  gap: 9px;
  margin-top: 18px;
  margin-bottom: 28px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}

.char-card-opponent-icon { flex-shrink: 0; color: var(--accent); }
.char-card-opponent-icon .achv-icon { width: 17px; height: 17px; display: block; }

.char-card-actions { flex-wrap: wrap; }

/* ---- Реплика персонажа в чате ---- */
.msg-character {
  align-self: flex-start;
  background: var(--bg);                /* такой же фон, как у ассистента */
  box-shadow: var(--sd-sm);            /* тень как у ассистента */
  border: 1px solid rgba(255,255,255,0.06); /* лёгкая граница, как в тёмной теме */
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom-left-radius: 4px;
  padding: 10px 14px;   
}
.msg-character-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gold); 
}
.msg-character-text {
  font-style: italic; 
  color: var(--text);
}
/* ---- Итоговая карточка партии против персонажа ---- */
.character-result-block { margin-bottom: 18px; }
.char-result-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.char-result-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--bg-alt);
  box-shadow: var(--inset-sm);
  font-size: 22px;
  color: var(--accent);
}
.char-result-name { font-weight: 700; font-size: 16px; flex: 1; }
.char-result-mood { color: var(--gold); }
.char-result-mood .achv-icon { width: 26px; height: 26px; display: block; }
.char-result-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13.5px;
  padding: 9px 12px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  box-shadow: var(--inset-sm);
  margin-bottom: 10px;
}
.char-result-comment {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
  font-style: italic;
  margin: 0;
}

/* =========================================================================
   Анализ партии
   ========================================================================= */
.analysis-block { margin-bottom: 20px; }
.analysis-loading { font-size: 13.5px; color: var(--text-muted); font-style: italic; }
.analysis-content { display: flex; flex-direction: column; gap: 10px; }
.analysis-stat {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  padding: 8px 12px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  box-shadow: var(--inset-sm);
}
.analysis-stat .muted { color: var(--text-muted); font-weight: 400; font-size: 12px; }
.analysis-comment { font-size: 13.5px; line-height: 1.6; color: var(--text); }
.analysis-disclaimer { font-size: 11.5px; color: var(--text-muted); font-style: italic; }
.analysis-refining { display: flex; gap: 6px; }
.analysis-refining .achv-icon { flex-shrink: 0; width: 14px; height: 14px; }
.analysis-raw {
  white-space: pre-wrap;
  font-size: 12px;
  background: var(--bg-alt);
  padding: 10px;
  border-radius: var(--radius-sm);
  box-shadow: var(--inset-sm);
}
.analysis-error { color: var(--danger-dark); font-size: 13.5px; }

.analysis-progress-label {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
}

.move-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--sd-sm);
  border: 1px solid transparent;
  transition: transform 0.15s ease;
}
.move-card:hover { transform: translateY(-2px); }
.move-card-best  { background: rgba(60, 170, 90, 0.14);  border-color: rgba(60, 170, 90, 0.35); }
.move-card-worst { background: rgba(220, 60, 60, 0.12); border-color: rgba(220, 60, 60, 0.32); }
.move-card-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); }
.move-card-label .achv-icon { width: 16px; height: 16px; }
.move-card-best .achv-icon { color: rgb(60, 170, 90); }
.move-card-worst .achv-icon { color: rgb(220, 60, 60); }
.move-card-san   { font-weight: 700; font-size: 15px; }

.mini-board { width: 240px; max-width: 100%; margin: 0 auto 16px; }

#moveDetailComment {
  background: var(--bg-alt);
  padding: 12px;
  border-radius: var(--radius-sm);
  box-shadow: var(--inset-sm);
}

/* =========================================================================
   ЭКРАН ЗАГРУЗКИ
   ========================================================================= */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
.loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-screen.is-seamless { background: transparent; }
.loading-screen.is-seamless .loading-board-bg { display: none; }

.loading-board-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  --cell: calc(100vh / 24);
  background-color: var(--home-cell-a);
  background-image:
    linear-gradient(45deg, var(--home-cell-b) 25%, transparent 25%, transparent 75%, var(--home-cell-b) 75%),
    linear-gradient(45deg, var(--home-cell-b) 25%, transparent 25%, transparent 75%, var(--home-cell-b) 75%);
  background-size: calc(var(--cell) * 2) calc(var(--cell) * 2);
  background-position: 0 0, var(--cell) var(--cell);
  filter: blur(2px);
}

/* Снегопад идёт на том же фоне, что и на главном экране */
html[data-home-bg="snow"] .loading-board-bg {
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 70% 55% at 50% 48%, var(--bg-alt), var(--bg));
  background-size: auto;
  background-position: 0 0;
}
/* В рое прогресс показывают сами кони, вставшие кольцом */
html:not([data-home-bg="snow"]) .loading-ring { display: none; }

.loading-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.loading-swarm-knight {
  position: absolute;
  top: 0; left: 0;
  font-size: 30px;
  color: var(--text-muted);
  transition: transform 0.16s ease-out, color 0.3s ease;
  will-change: transform;
}
.loading-swarm-knight.is-lit { color: var(--gold); }

.loading-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.loading-knight-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: loadingKnightFloat 2.2s ease-in-out infinite;
}

.loading-knight {
  position: relative;
  width: 140px; /* у картинки широкие прозрачные поля: сам конь заметно меньше */
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
  z-index: 2;
}

.loading-ring {
  position: absolute;
  inset: 0;
  width: 140px;
  height: 140px;
  transform: rotate(-90deg);
  z-index: 1;
}
.loading-ring-track {
  fill: none;
  stroke: var(--accent-soft);
  stroke-width: 4;
}
.loading-ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 377; /* ~2πr, r=60 */
  stroke-dashoffset: 320;
  transform-origin: 70px 70px;
  animation: loadingRingSpin 1.6s linear infinite, loadingRingPulse 1.6s ease-in-out infinite;
}

.loading-logo {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 0.4px;
  color: var(--text);
}

.loading-status {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}
.loading-dots span {
  animation: loadingDotBlink 1.4s infinite;
  opacity: 0;
}
.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadingKnightFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes loadingRingSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes loadingRingPulse {
  0%, 100% { stroke-dashoffset: 320; }
  50% { stroke-dashoffset: 200; }
}

@keyframes loadingDotBlink {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-knight-wrap { animation: none; }
  .loading-ring-progress { animation: loadingRingSpin 1.6s linear infinite; }
}

/* =========================================================================
   ГЛАВНЫЙ ЭКРАН
   ========================================================================= */
.home-screen {
  position: fixed;
  inset: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  /* По фону кликают, ловя фигуры, — двойной клик не должен выделять текст */
  -webkit-user-select: none;
  user-select: none;
}

.home-board-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  --cell: calc(100vh / 24);
  background-color: var(--home-cell-a);
  background-image:
    linear-gradient(45deg, var(--home-cell-b) 25%, transparent 25%, transparent 75%, var(--home-cell-b) 75%),
    linear-gradient(45deg, var(--home-cell-b) 25%, transparent 25%, transparent 75%, var(--home-cell-b) 75%);
  background-size: calc(var(--cell) * 2) calc(var(--cell) * 2);
  background-position: 0 0, var(--cell) var(--cell);
}

.home-knights-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.home-figure {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  transition: transform 0.15s ease-out;
  will-change: transform;
}
.home-queen {
  color: var(--accent);
  font-size: 44px;
  font-weight: bold;
  text-shadow: 0 0 12px rgba(173, 138, 78, 0.5);
  z-index: 2;
}
.home-sputnik {
  color: var(--text-muted);
  font-size: 36px;
  opacity: 0.8;
  z-index: 1;
}
.home-board-bg {
  filter: blur(2px);          

}
.home-knights-layer .home-figure {
  filter: blur(2px);
}
#homeKnights {
  filter: blur(2px);
  opacity: 0.65;
}

.home-snow-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  filter: blur(1px);
}

/* Снегопад идёт на тёмном фоне без клеток, чуть светлее за карточкой */
.home-screen.is-snow .home-board-bg {
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 70% 55% at 50% 48%, var(--bg-alt), var(--bg));
  background-size: auto;
  background-position: 0 0;
}

#homeKnights::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.08);
  pointer-events: none;
}
.home-enemy {
  color: var(--gold);
  font-size: 32px;
  z-index: 1;
  opacity: 0;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.55));
  transition: opacity 0.2s ease-out, transform 0.45s ease-out;
}
.home-enemy.is-spawned {
  opacity: 0.85;
}
.home-enemy.is-dying {
  opacity: 0;
}

.home-topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
}
.home-logo { font-size: 24px; }

.home-center {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 24px 60px;
}

/* =========================================================================
   КАПСУЛА (овал)
   ========================================================================= */
.home-oval {
  position: relative;
  z-index: 2;
  background: var(--bg-alt);
  border-radius: 200px;
  padding: 20px 40px 20px 200px; /* место слева для коня: до кончика морды */
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-width: 780px;
  max-width: 90vw;
  overflow: hidden;           /* обрезает выступающую вниз голову */
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.10),   /* внешняя обводка */
    inset 0 0 0 1px rgba(0, 0, 0, 0.04),    /* внутренняя */
    var(--sd-lg);
  transition: box-shadow 0.4s ease, transform 0.2s ease;
}

/* Левый тусклый отблеск */
.home-oval::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 20%;
  width: 10px;
  height: 60%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0%, transparent 100%);
  border-radius: 200px;
  pointer-events: none;
  filter: blur(6px);
  opacity: 0.7;
  z-index: 2;
}

/* Правый тусклый отблеск */
.home-oval::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 25%;
  width: 8px;
  height: 50%;
  background: linear-gradient(270deg, rgba(255, 255, 255, 0.05) 0%, transparent 100%);
  border-radius: 200px;
  pointer-events: none;
  filter: blur(4px);
  opacity: 0.5;
  z-index: 2;
}

/* Подсветка овала при наведении на "Играть" */
.home-oval:has(.home-play-text:hover) {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.20),
    inset 0 0 0 1px rgba(0, 0, 0, 0.04),
    var(--sd-lg),
    0 0 30px var(--accent-soft);
}

/* Голова коня + иконка режима */
.home-knight-wrap {
  position: absolute;
  left: 32px;
  bottom: 40%;               /* центр коня около 1/3 капсулы */
  width: 140px;
  height: 140px;
  pointer-events: none;
  z-index: 3;
  display: flex;
  align-items: flex-end;
}

.knight-head {
  position: absolute;
  top: 30%;
  width: 120%;
  height: 230%;               /* реальная высота коня в 2 раза больше окна */
  object-fit: cover;
  object-position: top center;
  display: block;
}

.mode-icon-wrap {
  position: absolute;
  left: 30%;                   /* слева от коня, почти впритык */
  bottom: -28px;
  transform: translateX(-100%);
  width: 76px;
  height: 76px;
  z-index: 4;
  pointer-events: none;
}

.mode-icon {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.mode-icon.active {
  opacity: 1;
  transform: scale(1);
}

/* Кнопка "Играть" */
.home-play-text {
  font-family: "Cormorant Garamond", serif;
  font-weight: 600;
  font-size: 45px;
  letter-spacing: 0.25em;
  /* Посередине между конём и режимами. Разрядка добавляет пустоту и после
     последней буквы, такой же отступ слева возвращает слово в центр. */
  margin-inline: auto;
  padding-left: 0.25em;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: color 0.25s, text-shadow 0.25s;
}
.home-play-text:hover {
  color: var(--accent);
  text-shadow: 0 0 30px var(--accent-soft);
}

/* Переключатель режимов */
.home-mode-select {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  flex-direction: column;
  position: relative;
}

/* Выделение режима. Положение задаёт JS, он же анимирует переезд на новый режим */
.home-mode-pill {
  position: absolute;
  left: 0;
  right: 0;
  border-radius: 40px;
  background: var(--bg-alt);
  box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
  pointer-events: none;
}

.home-mode-btn {
  position: relative;
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 8px 16px;
  border-radius: 40px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  box-shadow: none;
}
.home-mode-btn.is-active {
  color: var(--accent);
}
.home-mode-btn:not(.is-active):hover {
  color: var(--text);
}

/* =========================================================================
   ИКОНКА НАСТРОЕК (2D, белая на главном экране / контурная в приложении)
   ========================================================================= */
.settings-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  padding: 0;
  transition: background 0.2s ease, transform 0.3s ease;
}
.settings-icon-btn svg {
  width: 22px;
  height: 22px;
  transition: transform 0.3s ease;
}
.settings-icon-btn:hover svg { transform: rotate(35deg); }
.settings-icon-btn:active { transform: scale(0.92); }

.home-topbar .settings-icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.home-topbar .settings-icon-btn svg { fill: var(--text); }
html:not(.dark) .home-topbar .settings-icon-btn:hover { background: rgba(0, 0, 0, 0.06); }

.topbar .settings-icon-btn { box-shadow: none; }
.topbar .settings-icon-btn:hover { box-shadow: var(--sd-sm); }
.topbar .settings-icon-btn svg { fill: var(--text); }

/* =========================================================================
   ПАНЕЛЬ НАСТРОЕК — выдвижная справа
   ========================================================================= */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}
.settings-overlay.open { pointer-events: auto; }

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 10, 8, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.settings-overlay.open .settings-backdrop { opacity: 1; }

.settings-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 34%;
  min-width: 380px;
  max-width: 440px;
  background: rgba(20, 17, 14, 0.72);
  color: #F4EFE4;
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.22, 0.9, 0.24, 1);
}
.settings-overlay.open .settings-panel { transform: translateX(0); }
html.dark .settings-panel { background: rgba(10, 10, 10, 0.78); }

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px;
  border-bottom: 1px solid rgba(244, 239, 228, 0.12);
  flex-shrink: 0;
}
.settings-header h2 { font-size: 22px; color: #F4EFE4; }
.settings-close-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(244, 239, 228, 0.1);
  color: #F4EFE4;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s ease;
}
.settings-close-btn:hover { background: rgba(244, 239, 228, 0.2); }

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 26px 40px;
}

.settings-group { margin-top: 26px; }
.settings-group:first-child { margin-top: 6px; }
.settings-group-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(244, 239, 228, 0.45);
  margin-bottom: 12px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(244, 239, 228, 0.08);
}
.settings-row:last-child { border-bottom: none; }
.settings-row.column { flex-direction: column; align-items: stretch; gap: 10px; }
.settings-row-label { font-size: 13.5px; font-weight: 600; }
.settings-row-desc { font-size: 11.5px; color: rgba(244, 239, 228, 0.5); margin-top: 2px; }
.settings-row-top { display: flex; justify-content: space-between; align-items: baseline; }

/* Переключатель тема с иконкой солнце/луна */
.theme-switch-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(244, 239, 228, 0.1);
  border-radius: 999px;
  padding: 7px 16px;
  color: #F4EFE4;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s ease;
}
.theme-switch-btn:hover { background: rgba(244, 239, 228, 0.18); }
.theme-switch-btn .theme-switch-icon .achv-icon { width: 16px; height: 16px; display: block; }

/* Тумблер (toggle) */
.toggle-switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; inset: 0;
  background: rgba(244, 239, 228, 0.18);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #F4EFE4;
  border-radius: 50%;
  transition: transform 0.2s ease;
}
.toggle-switch input:checked + .toggle-slider { background: var(--gold); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Акцентные цвета */
.accent-swatches { display: flex; gap: 10px; }
.accent-swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.accent-swatch:hover { transform: scale(1.1); }
.accent-swatch.is-active { border-color: #F4EFE4; }
.accent-swatch.is-active::after {
  content: '✓';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.accent-gold { background: #AD8A4E; }
.accent-maroon { background: #7B3B3E; }
.accent-blue { background: #2B5FA8; }
.accent-green { background: #2F7D4F; }

/* Оформление доски */
.board-style-row { display: flex; gap: 8px; flex-wrap: wrap; }
.board-style-btn {
  flex: 1;
  min-width: 96px;
  background: rgba(244, 239, 228, 0.06);
  border: 2px solid transparent;
  color: #F4EFE4;
  border-radius: 12px;
  padding: 10px 8px;
  font-size: 11.5px;
  line-height: 1.3;
  text-align: center;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.board-style-btn:hover { background: rgba(244, 239, 228, 0.12); }
.board-style-btn.is-active { border-color: var(--gold); background: rgba(244, 239, 228, 0.14); }
.board-style-btn:disabled,
.board-style-row.is-disabled .board-style-btn {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.analysis-mode-lock-note { color: var(--gold); }

/* Ползунки */
.settings-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px;
  border-radius: 999px;
  background: rgba(244, 239, 228, 0.18);
  outline: none;
}
.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(244, 239, 228, 0.15);
}
.settings-slider::-moz-range-thumb {
  width: 16px; height: 16px; border: none; border-radius: 50%;
  background: var(--gold); cursor: pointer;
}
.slider-value { font-size: 12px; color: rgba(244, 239, 228, 0.55); }

/* Кастомный селект для настроек */
.settings-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: rgba(244, 239, 228, 0.08);
  /* Светлая SVG-стрелка, вписывающаяся в дизайн */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23F4EFE4' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  color: #F4EFE4;
  border: 1px solid rgba(244, 239, 228, 0.1);
  border-radius: 10px;
  padding: 10px 36px 10px 14px; /* отступ справа под стрелку */
  font-size: 13px;
  font-weight: 500;
  /* Неоморфная внутренняя тень (придаёт объём) */
  box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.4), 
              inset -2px -2px 4px rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.2s ease;
}
.settings-select:hover {
  background-color: rgba(244, 239, 228, 0.14);
}
.settings-select:focus-visible {
  outline: none;
  border-color: var(--gold);
  box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.4), 
              inset -2px -2px 4px rgba(255, 255, 255, 0.05),
              0 0 0 2px var(--gold-soft);
}
/* Стилизация раскрывающегося списка (опций) */
.settings-select option {
  background-color: #1a1a1a;
  color: #F4EFE4;
  padding: 8px;
  font-weight: 400;
}

.settings-about { font-size: 12.5px; color: rgba(244, 239, 228, 0.6); line-height: 1.7; }
.settings-about a { color: var(--gold); text-decoration: none; }
.settings-about a:hover { text-decoration: underline; }

/* Силуэты коней сквозь размытие панели настроек — задаём лёгкое просвечивание фона */
.settings-panel { backdrop-filter: blur(2px); }

@media (max-width: 720px) {
  .settings-panel { width: min(100vw, 420px); min-width: unset; max-width: unset; }
}

/* =========================================================================
   Toast
   ========================================================================= */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-alt);
  color: var(--text);
  padding: 16px 28px;
  border-radius: 60px;
  box-shadow: var(--sd-lg);
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================================================
   Адаптив
   ========================================================================= */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .chat-card { min-height: 420px; max-height: none; }
}

@media (max-width: 720px) {
  .app { padding: 16px 12px 40px; }
  .topbar { flex-direction: column; gap: 12px; padding: 16px; }
  .board-card, .chat-card { padding: 16px; }
  .modal.wide .modal-actions { flex-direction: column; }
  .modal.wide .modal-actions .btn { width: 100%; }
  .color-choice-row, .diff-choice-row { flex-wrap: wrap; }
}

/* Капсула на главном экране: в узком варианте (планшеты и мобильные) конь
   и переключатель режимов переезжают под кнопку "Играть". Порог поднят до
   880px — при min-width:780px у .home-oval это единственный способ не
   получить горизонтальное переполнение на портретных планшетах (iPad и т.п.,
   ширина 721–866px), где обычный десктопный вид ещё не помещается. */
@media (max-width: 880px) {
  .home-oval {
    padding: 20px 24px;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    border-radius: 80px;
    justify-content: center;
    min-width: unset;
    width: 90%;          /* % от контейнера, а не от вьюпорта — паддинг .home-center уже учтён, переполнения не будет */
    max-width: 480px;
    overflow: visible;   /* обрезаем не саму капсулу, а только коня (см. .home-knight-wrap ниже) */
  }
  .home-knight-wrap {
    position: relative;
    left: auto;
    bottom: auto;
    width: 120px;
    height: 112px;
    margin-bottom: -22px;
    overflow: hidden;     /* конь — картинка выше своей рамки (height:230%), без обрезки он наезжает на "ИГРАТЬ" и режимы ниже */
    /* вместо резкого среза шея коня плавно растворяется над "ИГРАТЬ" */
    -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
  }
  .knight-head {
    top: -14%;
    left: -10%;           /* картинка шире рамки на 20% — центрируем */
    object-position: 53% top;  /* конь на картинке чуть правее центра */
  }
  .mode-icon-wrap {
    bottom: 6px;
    width: 32px;
    height: 32px;
  }
  .home-play-text {
    margin-top: -10px;
    font-size: 36px;
  }
  .home-mode-select {
    margin-left: 0;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }
  .home-mode-btn {
    font-size: 12px;
    padding: 6px 12px;
  }
  .home-oval::before,
  .home-oval::after {
    display: none;   /* на малых экранах отблески убираем */
  }
}

/* Короткие/альбомные экраны (мобильные в landscape, невысокие окна браузера) —
   .home-screen зафиксирован и не скроллится, поэтому на маленькой высоте
   капсула должна сжаться и прижаться кверху, а не обрезаться. */
@media (max-height: 560px) {
  .home-screen { overflow-y: auto; }
  .home-topbar { padding: 12px 20px; }
  .home-center { padding: 6px 20px 20px; justify-content: flex-start; }
  .home-oval { padding: 14px 20px; gap: 8px; }
  .home-knight-wrap { width: 56px; height: 64px; margin-bottom: -6px; overflow: hidden; }
  .home-play-text { font-size: 26px; margin-top: -4px; }
  .home-mode-btn { padding: 5px 10px; }
}

/* =========================================================================
   АНИМАЦИИ ХОДОВ И ВЗЯТИЙ
   ========================================================================= */
.square-55d63.last-move-src,
.square-55d63.last-move-dst { position: relative; }
.square-55d63.last-move-src::before,
.square-55d63.last-move-dst::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 1;
  transition: opacity 1.5s ease-out;
}
.square-55d63.last-move-src::before { background: rgba(173, 138, 78, 0.3); }
.square-55d63.last-move-dst::before { background: rgba(173, 138, 78, 0.5); }
.square-55d63.last-move-src.is-fading::before,
.square-55d63.last-move-dst.is-fading::before { opacity: 0; }

.square-55d63.capture-flash-red {
  animation: flash-red 0.7s ease-out;
}
@keyframes flash-red {
  0% { background: rgba(255, 50, 50, 0.8); }
  70% { background: rgba(255, 50, 50, 0.3); }
  100% { background: transparent; }
}
.square-55d63.capture-flash-green {
  animation: flash-green 0.7s ease-out;
}
@keyframes flash-green {
  0% { background: rgba(50, 200, 50, 0.8); }
  70% { background: rgba(50, 200, 50, 0.3); }
  100% { background: transparent; }
}

#fakeProgress {
  animation: fadeInProgress 0.4s ease;
}
@keyframes fadeInProgress {
  0% { opacity: 0; transform: scaleY(0.5); }
  100% { opacity: 1; transform: scaleY(1); }
}

/* Модалка деталей хода — большая карточка, в тон достижений/настроек */
.achv-modal-overlay .achv-modal.move-detail-modal {
  max-width: 920px;
  height: 82vh;
}
.move-detail-layout {
  display: flex;
  gap: 30px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  margin-top: 4px;
}

/* Левая часть — доска со стрелкой */
.move-detail-board-wrap {
  position: relative;
  flex: 0 0 42%;
  max-width: 420px;
  min-width: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.move-detail-board-wrap .mini-board {
  width: 100%;
  height: auto;
  aspect-ratio: 1/1;
  margin: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.move-detail-arrow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45));
}
.move-detail-arrow line { stroke-linecap: round; }

/* Правая часть — анализ нейросети, листается при большом тексте */
.move-detail-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}
.move-detail-info-head { flex-shrink: 0; }
.move-detail-info-head .modal-sub { margin: 4px 0 0; }
.move-detail-badge {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}
.move-detail-badge.is-visible { display: inline-flex; align-items: center; gap: 6px; }
.move-detail-badge .achv-icon { width: 15px; height: 15px; }
.move-detail-badge.is-best  { background: rgba(60, 170, 90, 0.18);  color: #7CD79A; border: 1px solid rgba(60, 170, 90, 0.4); }
.move-detail-badge.is-worst { background: rgba(220, 60, 60, 0.16); color: #F09090; border: 1px solid rgba(220, 60, 60, 0.4); }

.move-detail-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.move-detail-info .analysis-comment {
  background: rgba(244, 239, 228, 0.05);
  border: 1px solid rgba(244, 239, 228, 0.08);
  padding: 16px;
  border-radius: var(--radius-sm);
  box-shadow: none;
  font-size: 14.5px;
  line-height: 1.65;
  color: rgba(244, 239, 228, 0.88);
  white-space: pre-wrap;
}
.move-detail-info .analysis-loading {
  font-size: 13.5px;
  color: rgba(244, 239, 228, 0.55);
  font-style: italic;
  text-align: left;
}
.move-detail-info .analysis-loading.hidden { display: none; }

@media (max-width: 720px) {
  .achv-modal-overlay .achv-modal.move-detail-modal { height: 90vh; }
  .move-detail-layout { flex-direction: column; gap: 16px; }
  .move-detail-board-wrap { flex: 0 0 auto; max-width: 280px; margin: 0 auto; }
  .move-detail-info { flex: 1; }
}

.knight-head {
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  will-change: transform;
}

.home-oval:has(.home-play-text:hover) .knight-head {
  transform: translateY(-22px) scale(1.03);
}
/* ===== Таймеры ===== */
.timers {
  display: flex;
  gap: 16px;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.timer {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-alt);
  box-shadow: var(--inset-sm);
  transition: color 0.3s, background 0.3s;
  opacity: 0.6;
}
.timer.active {
  opacity: 1;
  color: var(--accent);
  background: var(--accent-soft);
}
.timer.warning {
  color: var(--danger);
  animation: pulse-timer 1s infinite;
}
@keyframes pulse-timer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
/* =========================================================================
   ДОСТИЖЕНИЯ (Achievements)
   ========================================================================= */

/* Toast-очередь */
#achvToastContainer {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.achv-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  max-width: 340px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-alt);
  box-shadow: var(--sd-lg);
  border: 1px solid var(--gold-soft);
  opacity: 0;
  transform: translateX(30px) scale(0.96);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.achv-toast.show { opacity: 1; transform: translateX(0) scale(1); }
.achv-toast.hide { opacity: 0; transform: translateX(30px) scale(0.96); }
.achv-toast-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--gold-soft);
  box-shadow: var(--inset-sm);
}
.achv-toast-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.achv-toast-name { font-weight: 700; color: var(--text); font-size: 14.5px; }
.achv-toast-desc { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* Модальное окно достижений — тёплое стекло, в тон панели настроек */
.achv-modal-overlay,
html.dark .achv-modal-overlay {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.achv-modal-overlay .achv-modal {
  max-width: 880px;
  width: min(92vw, calc(100vw - 40px));
  height: 84vh;
  display: flex;
  flex-direction: column;
  background: var(--achv-modal-bg, rgba(38, 33, 26, 0.68));
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid rgba(244, 239, 228, 0.14);
  box-shadow:
    0 30px 70px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
html.dark .achv-modal-overlay .achv-modal {
  background: var(--achv-modal-bg-dark, rgba(26, 23, 18, 0.78));
}

.achv-modal-header { display: flex; align-items: center; justify-content: space-between; }
.achv-modal-header h2 { font-family: var(--font-display); margin: 0; color: #F4EFE4; }
.achv-modal-overlay .modal-sub { color: rgba(244, 239, 228, 0.6); }
.achv-modal-overlay .settings-close-btn { background: rgba(244, 239, 228, 0.1); }
.achv-modal-overlay .settings-close-btn:hover { background: rgba(244, 239, 228, 0.2); }

.achv-modal-overlay ::-webkit-scrollbar-thumb { background: rgba(244, 239, 228, 0.22); }

.achv-card {
  position: relative;
  border-radius: var(--radius-md);
  padding: 16px 14px;
  background: rgba(244, 239, 228, 0.05);
  border: 1px solid rgba(244, 239, 228, 0.08);
  box-shadow: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.achv-card:hover { transform: translateY(-2px); background: rgba(244, 239, 228, 0.08); box-shadow: 0 10px 22px -12px rgba(0, 0, 0, 0.5); }

.achv-card.is-locked { opacity: 0.45; filter: grayscale(0.6); }
.achv-card.is-locked:hover { opacity: 0.7; }

.achv-card.is-unlocked {
  opacity: 1;
  filter: none;
  border: 1px solid var(--gold);
  background: linear-gradient(160deg, rgba(244, 239, 228, 0.09), var(--gold-soft));
  box-shadow: 0 10px 24px -14px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.achv-card.is-secret.is-locked { filter: grayscale(1) brightness(0.8); }

.achv-card-icon { line-height: 1; margin-bottom: 2px; color: var(--achv-tier, rgba(244, 239, 228, 0.55)); }
.achv-card-icon .achv-icon { width: 32px; height: 32px; display: block; }
.achv-toast-icon { color: var(--achv-tier, var(--gold)); }
.achv-toast-icon .achv-icon { width: 24px; height: 24px; display: block; }
.achv-tier-2   { --achv-tier: #C08A56; }
.achv-tier-5   { --achv-tier: #B4BEC8; }
.achv-tier-7   { --achv-tier: #E2B33C; }
.achv-tier-15  { --achv-tier: #5CC8DC; }
.achv-tier-50  { --achv-tier: #C57BE8; }
.achv-card-name { font-weight: 700; font-size: 14.5px; color: #F4EFE4; font-family: var(--font-display); }
.achv-card-desc { font-size: 12px; color: rgba(244, 239, 228, 0.55); line-height: 1.4; min-height: 32px; }
.achv-card-date { font-size: 11px; color: var(--gold); margin-top: 4px; font-weight: 600; }

.achv-progress {
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: rgba(244, 239, 228, 0.12);
  box-shadow: none;
  overflow: hidden;
  margin-top: 4px;
}
.achv-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  border-radius: 4px;
  transition: width 0.4s ease;
}
.achv-progress-label { font-size: 10.5px; color: rgba(244, 239, 228, 0.5); margin-top: 2px; }

@media (max-width: 640px) {
  #achvToastContainer { left: 12px; right: 12px; top: 12px; }
  .achv-toast { max-width: none; }
}
.modal.wide {
  max-height: 92vh;
}
.modal.wide .modal-actions {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--shadow-dark);
}
/* =========================================================================
   БУРГЕР-МЕНЮ И ПРОФИЛЬ
   ========================================================================= */

/* Иконка бургера — без поворота (в отличие от шестерёнки настроек) */
.menu-icon-btn:hover svg { transform: none; }
.menu-icon-btn:active svg { transform: scale(0.9); }

.menu-header { justify-content: flex-start; gap: 14px; }
.menu-back-btn { font-size: 18px; }
.side-panel-title { margin: 0; font-size: 18px; }

.menu-body { padding-top: 4px; }

/* ---- Side Panel views: единая система навигации ----
   Виден только .side-view.is-active, переключение — через navigationState
   в app.js (navigateTo/navigateBack). Переход — лёгкий fade, без zoom/bounce. */
.side-view { display: none; }
.side-view.is-active { display: block; animation: sideViewFade 0.18s ease; }
@keyframes sideViewFade {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Карточка профиля вверху меню */
.menu-profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0 22px;
  border-bottom: 1px solid rgba(244, 239, 228, 0.1);
  margin-bottom: 10px;
}
.menu-avatar {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: rgba(244, 239, 228, 0.08);
  box-shadow: inset 0 0 0 2px var(--gold);
}
.menu-profile-info { flex: 1; min-width: 0; }
.menu-profile-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: #F4EFE4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-profile-elo {
  font-size: 12.5px;
  color: var(--gold);
  font-weight: 600;
  margin-top: 2px;
}
.menu-profile-card.is-guest .menu-avatar { box-shadow: inset 0 0 0 2px rgba(244, 239, 228, 0.25); opacity: 0.75; }
.menu-auth-btn { flex-shrink: 0; }

/* Список пунктов меню */
.menu-nav { display: flex; flex-direction: column; }
.menu-nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 6px;
  border-radius: 12px;
  background: transparent;
  color: #F4EFE4;
  text-align: left;
  transition: background 0.15s ease;
}
.menu-nav-item:hover { background: rgba(244, 239, 228, 0.08); }
.menu-nav-item:active { background: rgba(244, 239, 228, 0.14); }
.menu-nav-icon { flex-shrink: 0; width: 22px; height: 22px; color: var(--gold); }
.menu-nav-icon .achv-icon { width: 22px; height: 22px; display: block; stroke-width: 1.75; }
.menu-nav-label { flex: 1; font-size: 14.5px; font-weight: 600; }
.menu-nav-arrow { flex-shrink: 0; color: rgba(244, 239, 228, 0.35); font-size: 16px; }

.menu-divider { height: 1px; background: rgba(244, 239, 228, 0.1); margin: 12px 0; }

/* Малые модалки бургер-меню (вход / профиль / достижения / статистика / о приложении) */
.achv-modal-overlay .achv-modal.menu-small-modal {
  max-width: 420px;
  width: min(92vw, calc(100vw - 40px));
  height: auto;
  max-height: 86vh;
  padding: 30px 26px;
}

.menu-field { margin-bottom: 18px; }
.menu-field .settings-row-label { display: block; margin-bottom: 8px; }
.menu-text-input {
  width: 100%;
  border-radius: 10px;
  padding: 11px 14px;
  background: rgba(244, 239, 228, 0.08);
  border: 1px solid rgba(244, 239, 228, 0.14);
  color: #F4EFE4;
  font-size: 14px;
}
.menu-text-input::placeholder { color: rgba(244, 239, 228, 0.4); }
.menu-text-input:focus-visible { outline: none; border-color: var(--gold); }

.avatar-choice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.avatar-choice-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 20px;
  background: rgba(244, 239, 228, 0.08);
  border: 2px solid transparent;
  color: #F4EFE4;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.avatar-choice-btn:hover { transform: scale(1.08); }
.avatar-choice-btn.is-active { border-color: var(--gold); background: rgba(244, 239, 228, 0.16); }

/* Большая карточка профиля в view "Профиль" */
.menu-profile-big { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0 26px; }
.menu-avatar-lg { width: 78px; height: 78px; font-size: 38px; }
.menu-profile-big-name { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: #F4EFE4; }
.menu-profile-big-elo { font-size: 13.5px; color: var(--gold); font-weight: 600; }

/* Гостевой блок в view "Профиль" — если пользователь не авторизован */
.menu-guest-box { text-align: center; padding: 4px 0 22px; }
.menu-guest-box .btn { width: 100%; margin-top: 14px; }

/* Отступ над кнопками действий внутри view (когда это не .modal-actions-контейнер) */
.menu-view-actions { margin-top: 24px; }
.menu-view-actions.btn { width: 100%; }

/* Списки статистики/достижений (переиспользуется для Stats View и запасного рендера) */
.menu-stats-list .settings-row { border-bottom-color: rgba(244, 239, 228, 0.08); }
.menu-stats-list .settings-row-label { color: #F4EFE4; }

/* Лимиты вопросов к нейросети в view "Профиль" */
.profile-quota { margin-top: 22px; }
.profile-quota .settings-row-label { color: #F4EFE4; }
.profile-quota-value { font-size: 15px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.profile-quota.is-empty .profile-quota-value { color: var(--danger); }
.profile-quota-bar { height: 6px; border-radius: 999px; background: rgba(244, 239, 228, 0.1); overflow: hidden; }
.profile-quota-bar span { display: block; height: 100%; border-radius: inherit; background: var(--gold); transition: width 0.4s ease; }
.profile-quota-buy { width: 100%; margin-top: 14px; }

/* Крупное ELO-число вверху Stats View */
.menu-stats-hero { text-align: center; padding: 6px 0 24px; }
.menu-stats-hero-value { font-family: var(--font-display); font-size: 42px; font-weight: 700; color: #F4EFE4; line-height: 1; }
.menu-stats-hero-label { margin-top: 4px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }

/* Раскрывающийся график Elo под ELO-хиро в Stats View */
#statsEloHero { cursor: pointer; user-select: none; border-radius: var(--radius-sm); transition: background 0.15s ease; }
#statsEloHero:hover, #statsEloHero:focus-visible { background: rgba(244, 239, 228, 0.06); outline: none; }
#statsEloHero::after {
  content: '▾'; display: block; margin-top: 6px; font-size: 11px; color: rgba(244,239,228,0.4);
  transition: transform 0.3s ease;
}
#statsEloHero.is-open::after { transform: rotate(180deg); }

.stats-elo-chart-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease;
  margin: 0 0 10px;
}
.stats-elo-chart-wrap.is-open { grid-template-rows: 1fr; }
.stats-elo-chart-inner { overflow: hidden; min-height: 0; position: relative; padding: 0 2px; }
.stats-elo-chart-wrap.is-open .stats-elo-chart-inner { padding: 6px 2px 16px; }

.stats-elo-chart-empty { text-align: center; padding: 10px 0; }

.stats-elo-svg { width: 100%; height: auto; display: block; overflow: visible; }
.elo-line { stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.elo-point-dot { fill: var(--gold); }
.elo-point-hit { fill: transparent; cursor: pointer; }
.elo-point:hover .elo-point-dot, .elo-point:focus-visible .elo-point-dot { r: 4.5; }
.elo-point:focus-visible .elo-point-hit { outline: none; }

.elo-tooltip {
  position: absolute; top: -4px; transform: translate(-50%, -100%);
  background: rgba(20, 18, 14, 0.92); color: #F4EFE4;
  font-size: 11.5px; line-height: 1.35; text-align: center;
  padding: 6px 9px; border-radius: 8px; white-space: nowrap;
  pointer-events: none; box-shadow: var(--sd-sm); z-index: 2;
}
.elo-tooltip[hidden] { display: none; }

/* Сводка прогресса в Achievements View */
.menu-achv-summary { text-align: center; padding: 10px 0 26px; }
.menu-achv-summary-count { font-family: var(--font-display); font-size: 30px; font-weight: 700; color: var(--gold); }
.menu-achv-bar-track {
  margin-top: 14px;
  height: 8px;
  border-radius: 6px;
  background: rgba(244, 239, 228, 0.1);
  overflow: hidden;
}
.menu-achv-bar-fill { height: 100%; background: var(--gold); border-radius: 6px; transition: width 0.4s ease; }

.menu-about { text-align: left; }
.menu-about p { margin: 0 0 8px; color: #F4EFE4; }

/* ---- Раздел "О приложении" (view-about) ---- */
.about-hero { text-align: center; padding: 4px 0 20px; }
.about-hero-icon {
  width: 52px; height: 52px; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 24px; color: var(--gold);
  background: rgba(244, 239, 228, 0.06);
  box-shadow: inset 0 0 0 1px rgba(244, 239, 228, 0.1);
}
.about-hero-name { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: #F4EFE4; }
.about-hero-tagline { font-size: 12.5px; color: var(--gold); margin-top: 2px; }
.about-hero-version { font-size: 11px; color: rgba(244, 239, 228, 0.4); margin-top: 6px; }

.about-section { margin-bottom: 20px; }
.about-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: rgba(244, 239, 228, 0.45); margin-bottom: 8px;
}
.about-section-text { font-size: 12.5px; line-height: 1.6; color: rgba(244, 239, 228, 0.75); margin: 0; }

.about-feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.about-feature {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  background: rgba(244, 239, 228, 0.05);
  font-size: 12px; color: #F4EFE4;
  transition: background 0.15s ease;
}
.about-feature:hover { background: rgba(244, 239, 228, 0.09); }
.about-feature-icon { flex-shrink: 0; color: var(--gold); }
.about-feature-icon .achv-icon { width: 17px; height: 17px; display: block; }

.about-ai-row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.about-ai-desc { font-size: 11.5px; color: rgba(244, 239, 228, 0.55); text-align: right; }

.about-tech-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.about-tech-tag {
  font-size: 11px; padding: 5px 10px; border-radius: 999px;
  background: rgba(244, 239, 228, 0.06); color: rgba(244, 239, 228, 0.7);
  box-shadow: inset 0 0 0 1px rgba(244, 239, 228, 0.08);
}

.about-link-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 4px; font-size: 13px; color: #F4EFE4; text-decoration: none;
  border-bottom: 1px solid rgba(244, 239, 228, 0.08);
  transition: color 0.15s ease;
}
.about-link-row:last-child { border-bottom: none; }
.about-link-row:hover { color: var(--gold); }
.about-link-arrow { color: rgba(244, 239, 228, 0.4); }

.about-dev-name { font-size: 14px; font-weight: 700; color: #F4EFE4; }
.about-dev-sub { font-size: 11.5px; color: rgba(244, 239, 228, 0.5); margin-top: 2px; }

#aboutFeedbackBtn { width: 100%; }

/* ---- Модалка "Обратная связь" ---- */
.feedback-modal { max-width: 420px; width: 100%; }
.feedback-form { display: flex; flex-direction: column; }
.feedback-field { margin-bottom: 16px; }
.feedback-field .settings-row-label { display: block; margin-bottom: 8px; }
.feedback-field .settings-select,
.feedback-field .menu-text-input { width: 100%; box-sizing: border-box; }
.feedback-textarea { resize: vertical; min-height: 96px; max-width: 100%; font-family: var(--font-body); }

.feedback-char-counter {
  margin-top: 4px; text-align: right; font-size: 11px; color: var(--text-muted);
}

.feedback-error {
  display: block; margin-top: 6px; font-size: 12px; color: var(--danger); min-height: 0;
}
.feedback-error:empty { display: none; }
.feedback-form-error {
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(161, 69, 61, 0.12); margin-bottom: 14px; min-height: 0;
}
.feedback-form-error[hidden] { display: none; }

.feedback-privacy-note { margin: -4px 0 16px; }

.feedback-success { text-align: center; padding: 12px 0 4px; }
.feedback-success-icon {
  width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--accent); background: var(--accent-soft);
}
.feedback-success-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: #F4EFE4; margin-bottom: 4px; }
.feedback-success .btn { margin-top: 16px; width: 100%; }

@media (max-width: 480px) {
  .feedback-modal { max-width: 100%; }
  .feedback-textarea { width: 100%; }
}

/* Кнопки и тексты внутри тёмной боковой панели и тёмных модалок бургер-меню —
   светлее ghost, мягче тени у accent, приглушённый текст modal-sub */
.achv-modal-overlay .btn-ghost,
.menu-panel .btn-ghost {
  background: rgba(244, 239, 228, 0.08);
  color: rgba(244, 239, 228, 0.75);
  box-shadow: none;
}
.achv-modal-overlay .btn-ghost:hover,
.menu-panel .btn-ghost:hover { background: rgba(244, 239, 228, 0.14); }
.achv-modal-overlay .btn-accent,
.menu-panel .btn-accent {
  box-shadow: 6px 6px 14px rgba(0, 0, 0, 0.35), -3px -3px 10px rgba(255, 255, 255, 0.06);
}
.menu-panel .modal-sub { color: rgba(244, 239, 228, 0.6); }

/* Модалка входа открывается из бургер-меню — должна быть поверх боковой
   панели, даже пока та ещё доигрывает анимацию закрытия */
#authModal {
  z-index: 260;
}
#feedbackModal {
  z-index: 260;
}
/* Покупку вопросов открывают и из профиля в боковой панели */
#buyModal {
  z-index: 260;
}
.achv-modal-overlay .achv-modal.auth-modal {
  max-width: 420px;
  border-radius: var(--radius-md);
  width: min(92vw, calc(100vw - 40px));
  height: auto;
  max-height: 90vh;
  padding: 30px 26px;
  text-align: left;
}
.auth-modal-header { margin-bottom: 4px; }
.auth-modal-header h2 { font-size: 22px; }
.auth-modal .modal-sub { margin: 6px 0 22px; text-align: left; }

.auth-provider-col { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.auth-provider-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: rgba(244, 239, 228, 0.07);
  border: 1px solid rgba(244, 239, 228, 0.14);
  color: #F4EFE4;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.05);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.auth-provider-btn:hover { background: rgba(244, 239, 228, 0.13); transform: translateY(-1px); }
.auth-provider-btn:active { transform: translateY(0); box-shadow: inset 3px 3px 8px rgba(0,0,0,0.35); }
.auth-provider-icon {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(244, 239, 228, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.auth-provider-icon svg { width: 16px; height: 16px; }
.auth-provider-vk .auth-provider-icon { background: #2787F5; }
.auth-provider-vk .auth-provider-icon svg { width: 18px; height: 18px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 20px;
  color: rgba(244, 239, 228, 0.4);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(244, 239, 228, 0.14);
}

.auth-field { text-align: left; }
.auth-field .settings-row-label { display: block; margin-bottom: 8px; }
.auth-field .menu-text-input.is-invalid {
  box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px rgba(255,255,255,0.06), 0 0 0 1px var(--danger);
}
.auth-field-error {
  display: block;
  min-height: 16px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--danger);
}

.auth-tabs {
  display: flex;
  gap: 6px;
  margin: 4px 0 18px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
}
.auth-tab {
  flex: 1;
  padding: 9px 0;
  border: none;
  border-radius: calc(var(--radius-sm) - 4px);
  background: transparent;
  color: rgba(244, 239, 228, 0.55);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.auth-tab.is-active {
  background: var(--accent);
  color: #F4EFE4;
}

.auth-form.hidden { display: none; }

.auth-password-wrap { position: relative; }
.auth-password-wrap .menu-text-input { padding-right: 44px; width: 100%; }
.auth-password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  color: #F4EFE4;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}
.auth-password-toggle .achv-icon { width: 18px; height: 18px; display: block; }
.auth-password-toggle:hover { opacity: 0.9; }
.auth-password-toggle.is-visible { opacity: 1; }

.auth-password-strength {
  margin-top: 8px;
  height: 4px;
  border-radius: 2px;
  background: rgba(244, 239, 228, 0.12);
  overflow: hidden;
}
.auth-password-strength span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--danger);
  transition: width 0.2s ease, background-color 0.2s ease;
}
.auth-password-strength[data-level="medium"] span { background: #d4a547; }
.auth-password-strength[data-level="strong"] span { background: #4caf6a; }

.auth-link-btn {
  display: block;
  margin: -10px 0 18px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 12.5px;
  cursor: pointer;
  text-align: right;
  width: 100%;
}
.auth-link-btn:hover { text-decoration: underline; }


.settings-panel.panel-expanded {
  width: 40%;
  max-width: 700px;
  min-width: 600px;
}

/* Контейнер сетки достижений */
.achv-grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 4px;
}

/* Карточки достижений внутри боковой панели (унаследованы от .achv-card) */
.achv-grid-container .achv-card {
  background: rgba(244,239,228,0.05);
  border: 1px solid rgba(244,239,228,0.08);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.achv-grid-container .achv-card.is-unlocked {
  border-color: var(--gold);
  background: linear-gradient(160deg, rgba(244,239,228,0.09), var(--gold-soft));
}
.achv-grid-container .achv-card.is-locked {
  opacity: 0.45;
  filter: grayscale(0.6);
}
/* Расширенная панель с плавной анимацией */
.settings-panel {
  transition: width 0.55s cubic-bezier(0.22, 0.9, 0.24, 1),
              transform 0.6s cubic-bezier(0.22, 0.9, 0.24, 1);
}
.settings-panel.panel-expanded {
  width: 70%;
  max-width: 800px;
  min-width: 600px;
}

/* Сетка достижений в две колонки */
.achv-grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 4px;
}

.achv-grid-container .achv-card {
  background: rgba(244,239,228,0.05);
  border: 1px solid rgba(244,239,228,0.08);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.achv-grid-container .achv-card.is-unlocked {
  border-color: var(--gold);
  background: linear-gradient(160deg, rgba(244,239,228,0.09), var(--gold-soft));
}
.achv-grid-container .achv-card.is-locked {
  opacity: 0.45;
  filter: grayscale(0.6);
}
.achv-grid-container .achv-card.is-secret.is-locked {
  filter: grayscale(1) brightness(0.8);
}
.achv-grid-container {
  perspective: 1200px;
  overflow-y: auto;
  max-height: 70vh; /* или любая другая */
  scroll-behavior: smooth; /* опционально */
}

.achv-card {
  transition: transform 0.15s ease-out, opacity 0.2s ease;
  will-change: transform, opacity;
}

/* =========================================================================
   АДАПТИВНОСТЬ — ДОПОЛНИТЕЛЬНЫЕ ИСПРАВЛЕНИЯ ДЛЯ ВСЕГО ПРИЛОЖЕНИЯ
   Идут последними в каскаде намеренно: панель ".panel-expanded" и сетка
   достижений выше в файле заданы через два класса (специфичность 0,2,0),
   поэтому переопределять их для мобильных нужно селектором той же
   специфичности, но позже по тексту файла — иначе брейкпоинт проигрывает.
   ========================================================================= */

/* Разворачивающаяся при "Достижениях" боковая панель на десктопе шире обычной
   (см. .settings-panel.panel-expanded выше, min-width: 600px) — на планшетах
   и телефонах такая ширина шире самого экрана и ломает layout. */
@media (max-width: 900px) {
  .settings-panel.panel-expanded {
    width: min(100vw, 480px);
    min-width: unset;
    max-width: unset;
  }
}

/* Сетка карточек достижений — двумя колонками только там, где для них
   реально есть место; на телефонах одна колонка читается заметно лучше. */
@media (max-width: 480px) {
  .achv-grid-container { grid-template-columns: 1fr; }
  .about-feature-grid { grid-template-columns: 1fr; }
}

/* Самые узкие телефоны (320–400px): плотнее отступы у доски и модалок,
   перенос текста в строке статуса партии и баннере переподключения,
   уже колонки в строках характеристик персонажа, чтобы бегунок не схлопывался. */
@media (max-width: 400px) {
  .app { padding: 12px 8px 32px; }
  .board-frame { padding: 10px; }
  .board-card, .chat-card { padding: 12px; }
  .modal { padding: 24px 18px; }

  .status-row { flex-wrap: wrap; row-gap: 8px; }
  .connection-banner { flex-wrap: wrap; }
  .connection-banner .btn { width: 100%; }

  .char-bar-row { grid-template-columns: 74px 1fr 56px; gap: 6px; }
  .char-bar-label { font-size: 12px; }
}

/* Короткая высота панели (мобильный landscape) — внутренние списки должны
   скроллиться, а не обрезаться фиксированной высотой панели. */
@media (max-height: 480px) {
  .achv-modal-overlay .achv-modal { height: 94vh; }
  .settings-header, .achv-modal-header { padding-top: 14px; padding-bottom: 14px; }
}

/* Подстраховка от горизонтального скролла всей страницы. */
html, body { overflow-x: hidden; }
/* =========================================================================
   ОКНО С ДОСКОЙ: контрастная доска, строки игроков, вкладки на телефоне
   ========================================================================= */
.board-card { padding: 20px; gap: 12px; }
.board-frame { padding: 10px; }
/* Доска не выше экрана: на ноутбуке 1366×768 вся карточка и поле чата
   помещаются без прокрутки. */
#board { width: min(480px, 100%, calc(100vh - 340px)); min-width: 240px; }

/* Невысокие экраны ноутбуков: поджимаем отступы над доской */
@media (min-width: 981px) and (max-height: 860px) {
  .app { padding-top: 14px; }
  .topbar { margin-bottom: 14px; }
}

/* Координаты: без прозрачности и контрастные к своей клетке */
.notation-322f9 { opacity: 1; font-size: 11px !important; }
.white-1e1d7 .notation-322f9 { color: rgba(40, 30, 22, 0.8) !important; }
.black-3c85d .notation-322f9 { color: rgba(250, 244, 233, 0.85) !important; }
html.dark .white-1e1d7 .notation-322f9 { color: rgba(250, 244, 233, 0.85) !important; }
html.dark[data-board-style="contrast"] .white-1e1d7 .notation-322f9 { color: rgba(0, 0, 0, 0.8) !important; }

/* Последний ход остаётся подсвеченным до следующего */
.square-55d63.last-move-mark { background-image: linear-gradient(var(--gold-soft), var(--gold-soft)); }

.player-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  min-height: 44px;
}
.pb-avatar {
  width: 34px; height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--bg-alt);
  box-shadow: var(--inset-sm);
  font-size: 20px;
  line-height: 1;
}
.player-bar.is-turn .pb-avatar { background: var(--accent); color: var(--bg); box-shadow: none; }
.pb-info { min-width: 0; display: grid; gap: 1px; }
.pb-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-turn {
  display: none;
  margin-left: 4px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.player-bar.is-turn .pb-turn { display: inline; }
.pb-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-material {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}
.pb-material .captured-pieces { font-size: 17px; letter-spacing: -2px; min-height: 0; color: var(--text-muted); white-space: nowrap; overflow: hidden; }
.pb-advantage { font-size: 12px; font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.player-bar .timer {
  margin-left: auto;
  flex: none;
  min-width: 72px;
  text-align: center;
  padding: 6px 12px;
  border-radius: 10px;
  font: 600 17px/1.2 var(--font-body);
  font-variant-numeric: tabular-nums;
  opacity: 1;
  color: var(--text-muted);
}
.player-bar.is-turn .timer { background: var(--accent); color: #FBF7EF; box-shadow: none; }
html.dark .player-bar.is-turn .timer { color: #1a1408; }
.player-bar .timer.warning { background: var(--danger); color: #fff; }

/* Статус партии и кнопки — одной строкой под доской */
.game-actions { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; }
.game-actions .status-row { flex: 1 1 160px; padding: 0 6px; min-height: 22px; justify-content: flex-start; }
.game-actions .controls-row { flex: none; gap: 8px; }
.game-actions .controls-row .btn { flex: none; }
.status-text { font-size: 13px; color: var(--text-muted); }

/* Ходы — одной строкой с переносом, как в нотации на бумаге */
.move-list-wrap { max-height: 76px; padding: 8px 10px; flex: none; margin-bottom: 14px; }
.move-list { flex-direction: row; flex-wrap: wrap; gap: 2px 4px; }
.move-row {
  display: inline-flex;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.move-row:nth-child(odd) { background: transparent; }
.move-row span:empty { display: none; }
.move-row:last-child { background: var(--accent-soft); color: var(--accent); }
.move-list:empty::before { content: "Ходов пока нет"; color: var(--text-muted); font-size: 13px; }

/* Чат на компьютере — высотой ровно с колонку доски, поле ввода всегда видно */
@media (min-width: 981px) {
  .layout { align-items: stretch; }
  .chat-card { contain: size; height: auto; min-height: 460px; max-height: none; }
}

.chat-quota { font-size: 12px; color: var(--text-muted); margin: -6px 2px 10px; min-height: 16px; }
.chat-quota.is-empty { color: var(--danger); }
.chat-quota-login {
  font: inherit;
  font-weight: 700;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

.mobile-tabs { display: none; }

@media (max-width: 980px) {
  /* minmax(0, 1fr) вместо 1fr: колонка может стать уже доски, и доска
     сжимается под экран при повороте телефона. */
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  #board { width: min(480px, 100%); }

  .mobile-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: var(--radius-sm);
    background: var(--bg-alt);
    box-shadow: var(--inset-sm);
  }
  .mobile-tab {
    flex: 1;
    position: relative;
    font: inherit;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 9px 0;
    border-radius: 9px;
    font-weight: 700;
    font-size: 13.5px;
    color: var(--text-muted);
  }
  .mobile-tab.is-active { background: var(--accent-soft); color: var(--accent); }
  .mobile-tab.has-unread::after {
    content: "";
    position: absolute;
    top: 8px; right: calc(50% - 46px);
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--accent);
  }
  .layout[data-mobile-tab="chat"] .move-list-wrap { display: none; }
  .layout[data-mobile-tab="moves"] .chat-card > :not(.move-list-wrap) { display: none; }
  .layout[data-mobile-tab="moves"] .move-list-wrap { max-height: 40vh; margin-bottom: 0; }
  .game-actions .controls-row { flex: 1 1 100%; }
  .game-actions .controls-row .btn { flex: 1 1 0; }

  .chat-card { min-height: 0; }
  .chat-log { max-height: 55vh; min-height: 160px; }
  .chat-input-row {
    position: sticky;
    bottom: 0;
    padding: 10px 0 calc(4px + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    z-index: 2;
  }
}

/* =========================================================================
   МОДАЛКИ: заметный выбор и читаемые кнопки
   ========================================================================= */
/* Тёмный текст на золотых кнопках тёмной темы (белый давал 2:1) */
html.dark .btn-accent,
html.dark .btn-primary.btn-primary-active { color: #1a1408; }

.color-choice-btn.is-active, .diff-choice-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: none;
}
.color-choice-btn.is-active[data-color="w"],
.color-choice-btn.is-active[data-color="b"],
.diff-easy.is-active, .diff-medium.is-active, .diff-hard.is-active { border-color: var(--accent); }
.choice-check { display: none; color: var(--accent); font-weight: 800; }
.color-choice-btn.is-active .choice-check { display: inline; }
.color-choice-black { background: #141210; border-color: var(--text-muted); }

.diff-choice-btn { flex-direction: column; gap: 2px; }
.diff-choice-name { display: inline-flex; align-items: center; gap: 6px; }
.diff-elo { font-size: 11.5px; font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.diff-choice-btn.is-active .diff-elo { color: var(--accent); }

/* Итог партии */
.result-eyebrow {
  display: block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 22px; }
.result-stat {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  box-shadow: var(--inset-sm);
}
.result-stat b { font-size: 22px; font-variant-numeric: tabular-nums; }
.result-stat span { font-size: 12px; color: var(--text-muted); }
.modal.wide .result-actions { flex-wrap: wrap; }
.modal.wide .result-actions #requestAnalysisBtn { flex: 1 1 100%; }
.modal.wide .result-actions .btn-ghost { flex: 1 1 0; }

/* =========================================================================
   Подвал главной (тарифы, оферта, реквизиты) и согласие в окне входа
   ========================================================================= */
.home-footer {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 4px 18px;
  padding: 10px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.home-footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; }
.home-footer a { color: var(--text-muted); text-decoration: none; font-weight: 600; }
.home-footer a:hover, .home-footer a:focus-visible { color: var(--text); text-decoration: underline; }

.auth-consent { margin: 14px 0 0; font-size: 12px; line-height: 1.5; color: rgba(244, 239, 228, 0.6); text-align: center; }
.auth-consent a { color: inherit; text-decoration: underline; }

/* =========================================================================
   Покупка вопросов
   ========================================================================= */
.chat-quota-buy {
  font: inherit;
  font-weight: 700;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

/* Сколько пакетов — решает сервер, поэтому колонки резиновые */
.buy-packs { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 0 0 16px; }
.buy-pack {
  display: grid;
  gap: 2px;
  justify-items: start;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--text);
  box-shadow: var(--sd-sm);
  border: 2px solid transparent;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.buy-pack.is-active { background: var(--accent-soft); border-color: var(--accent); box-shadow: none; }
.buy-pack-name { font-weight: 700; font-size: 14px; }
.buy-pack-price { font: 700 26px var(--font-display); font-variant-numeric: tabular-nums; }
.buy-pack-note { font-size: 11.5px; font-weight: 700; color: var(--accent); }
.buy-packs-loading { grid-column: 1 / -1; margin: 6px 0; font-size: 13px; color: var(--text-muted); }
.buy-legal { font-size: 12px; color: var(--text-muted); margin: 0 0 14px; line-height: 1.5; }
.buy-legal a { color: inherit; }
.buy-error { font-size: 13px; color: var(--danger); margin: 0 0 14px; }
@media (max-width: 420px) { .buy-packs { grid-template-columns: 1fr; } }
