/* Раздел «Играть» (docs/games.md): лобби, партия, партия с ботом, анализ - app/games,
   бандл games.min.js. Цвета - переменные темы сайта (--surface-1, --text-1, ...,
   public/stylesheets/common.css): тёмная тема html[data-theme='dark'] меняет их сама,
   здесь - только свои акценты. Доска - старый Chessground (/cg/assets/s.min.css). */

.gm-page {
  --gm-accent: #2563eb;
  --gm-accent-text: #ffffff;
  --gm-accent-soft: rgba(37, 99, 235, 0.1);
  --gm-win: #16a34a;
  --gm-lose: #dc2626;
  --gm-warn-bg: #fff7e6;
  --gm-warn-border: #f5d49a;
  --gm-clock-bg: #eef1f5;
  --gm-clock-run-bg: #1f2937;
  --gm-clock-run-text: #ffffff;
  --gm-inaccuracy: #56b4e9; /* как у lichess */
  --gm-mistake: #e69f00;
  --gm-blunder: #df5353;
  --gm-graph-bg: #5b6470;
  --gm-graph-fill: #f4f5f7;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 16px 40px;
  color: var(--text-1, #1f2328);
  box-sizing: border-box;
}

html[data-theme='dark'] .gm-page {
  --gm-accent: #4f8cff;
  --gm-accent-soft: rgba(79, 140, 255, 0.16);
  --gm-win: #4ade80;
  --gm-lose: #f87171;
  --gm-warn-bg: rgba(245, 158, 11, 0.12);
  --gm-warn-border: rgba(245, 158, 11, 0.35);
  --gm-clock-bg: rgba(255, 255, 255, 0.07);
  --gm-clock-run-bg: #e5e7eb;
  --gm-clock-run-text: #0b1220;
  --gm-graph-bg: #1c2433;
  --gm-graph-fill: #9aa4b2;
  color-scheme: dark;
}

.gm-page *,
.gm-page *::before,
.gm-page *::after {
  box-sizing: border-box;
}

/* ---------- общее ---------- */
.gm-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.gm-h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  margin: 0 0 4px;
}
.gm-lead {
  margin: 0;
  color: var(--text-2, #6b7280);
}
.gm-head-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding-top: 6px;
}
.gm-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2, #f6f7f9);
  border: 1px solid var(--border, #e5e7eb);
  font-size: 0.85rem;
  white-space: nowrap;
}
.gm-conn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
}
.gm-conn-dot.is-open {
  background: #22c55e;
}
.gm-conn-dot.is-connecting {
  background: #f59e0b;
}
.gm-conn-dot.is-offline {
  background: #ef4444;
}
.gm-h2 {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0 0 4px;
}
.gm-muted {
  color: var(--text-2, #6b7280);
}
.gm-small {
  font-size: 0.875rem;
}
.gm-card {
  background: var(--surface-1, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 16px;
  min-width: 0;
}
.gm-card p {
  margin: 0 0 12px;
}
.gm-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--gm-accent-soft);
  color: var(--gm-accent);
  font-size: 0.78rem;
  white-space: nowrap;
}
.gm-error {
  color: var(--gm-lose);
  margin: 6px 0;
}
.gm-link {
  color: var(--link, #1d4ed8);
}
.gm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.gm-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  margin: 0 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--surface-2, #f6f7f9);
  font-size: 0.92rem;
}
.gm-banner.is-warn,
.gm-banner.is-offline {
  background: var(--gm-warn-bg);
  border-color: var(--gm-warn-border);
}

/* ---------- кнопки ---------- */
.gm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 14px;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 8px;
  background: var(--surface-2, #f6f7f9);
  color: var(--text-1, #1f2328);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.gm-btn:hover {
  border-color: var(--gm-accent);
  color: var(--text-1, #1f2328);
  text-decoration: none;
}
.gm-btn:focus-visible,
.gm-quick:focus-visible,
.gm-bot:focus-visible,
.gm-seg-btn:focus-visible,
.gm-move:focus-visible {
  outline: 2px solid var(--gm-accent);
  outline-offset: 2px;
}
.gm-btn:disabled {
  opacity: 0.5;
  cursor: default;
  border-color: var(--border, #d1d5db);
}
.gm-btn-primary,
.gm-btn-primary:hover {
  background: var(--gm-accent);
  border-color: var(--gm-accent);
  color: var(--gm-accent-text);
}
.gm-btn-primary:hover {
  filter: brightness(1.08);
}
.gm-btn-danger,
.gm-btn-danger:hover {
  background: var(--gm-lose);
  border-color: var(--gm-lose);
  color: #fff;
}
.gm-btn-sm {
  min-height: 30px;
  padding: 3px 10px;
  font-size: 0.875rem;
}
.gm-btn-wide {
  width: 100%;
}
.gm-btn-icon {
  min-width: 40px;
  padding: 6px 10px;
  font-size: 1.15rem;
}
.gm-x {
  border: 0;
  background: transparent;
  color: var(--text-2, #6b7280);
  font-size: 1.4rem;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
}
.gm-x:hover {
  color: var(--text-1, #1f2328);
}

.gm-seg {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 8px;
  overflow: hidden;
  max-width: 100%;
}
.gm-seg-btn {
  flex: 1 1 auto;
  min-height: 34px;
  padding: 4px 12px;
  border: 0;
  border-right: 1px solid var(--border, #d1d5db);
  background: var(--surface-1, #fff);
  color: var(--text-1, #1f2328);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.gm-seg-btn:last-child {
  border-right: 0;
}
.gm-seg-btn.is-on {
  background: var(--gm-accent);
  color: var(--gm-accent-text);
  font-weight: 700;
}

.gm-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--gm-accent-soft);
  border-top-color: var(--gm-accent);
  border-radius: 50%;
  animation: gm-spin 0.8s linear infinite;
  flex: 0 0 auto;
}
@keyframes gm-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- формы ---------- */
.gm-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gm-form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.gm-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  margin: 0;
}
.gm-field-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.82rem;
  line-height: 1.35;
}
.gm-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2, #6b7280);
}
.gm-input,
.gm-select {
  width: 100%;
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 8px;
  background: var(--surface-1, #fff);
  color: var(--text-1, #1f2328);
  font: inherit;
  font-size: 0.95rem;
}
.gm-input:focus,
.gm-select:focus {
  outline: none;
  border-color: var(--gm-accent);
  box-shadow: 0 0 0 3px var(--gm-accent-soft);
}
.gm-select:disabled {
  opacity: 0.55;
}
html[data-theme='dark'] .gm-page .gm-input,
html[data-theme='dark'] .gm-page .gm-select,
html[data-theme='dark'] .gm-modal .gm-input,
html[data-theme='dark'] .gm-modal .gm-select {
  background: #111c33;
  color: #e5e7eb;
  border-color: #2b3b5c;
}
/* раскрытый список рисует браузер - пунктам явные цвета */
html[data-theme='dark'] .gm-select option {
  background-color: #1f2630;
  color: #e8ecf1;
}
.gm-link-box {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}
.gm-link-input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

/* ---------- окно ---------- */
.gm-modal {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.5);
}
.gm-modal-card {
  width: min(100%, 460px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--surface-1, #fff);
  color: var(--text-1, #1f2328);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
html[data-theme='dark'] .gm-modal {
  color-scheme: dark;
}
.gm-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.gm-modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0;
}
.gm-modal .gm-muted {
  margin: 0 0 4px;
}

/* ---------- лобби ---------- */
.gm-lobby-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.gm-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.gm-quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.gm-quick {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 72px;
  padding: 8px 4px;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 10px;
  background: var(--surface-2, #f6f7f9);
  color: var(--text-1, #1f2328);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.gm-quick:hover {
  border-color: var(--gm-accent);
}
.gm-quick:active {
  transform: scale(0.98);
}
.gm-quick:disabled {
  opacity: 0.6;
  cursor: default;
}
.gm-quick.is-on {
  border-color: var(--gm-accent);
  background: var(--gm-accent-soft);
}
.gm-quick-tc {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.1;
}
.gm-quick-perf {
  font-size: 0.8rem;
  color: var(--text-2, #6b7280);
}
.gm-quick .gm-spinner {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 12px;
  height: 12px;
}
.gm-waiting {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--gm-accent-soft);
}
.gm-waiting-text {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.gm-seeks {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.gm-seek {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--border, #e5e7eb);
}
.gm-seek:first-child {
  border-top: 0;
}
.gm-seek-name {
  flex: 1 1 140px;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}
.gm-seek-tc {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.gm-bot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0 12px;
}
.gm-bot {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 10px;
  background: var(--surface-1, #fff);
  color: var(--text-1, #1f2328);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.gm-bot:hover {
  border-color: var(--gm-accent);
}
.gm-bot.is-on {
  border-color: var(--gm-accent);
  background: var(--gm-accent-soft);
  box-shadow: inset 0 0 0 1px var(--gm-accent);
}
.gm-bot-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.gm-bot-name {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gm-bot-rating {
  font-size: 0.8rem;
  color: var(--text-2, #6b7280);
}
.gm-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #6b7280;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.gm-bot-opts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.gm-mygames-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.gm-mygame {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-top: 1px solid var(--border, #e5e7eb);
  color: inherit;
  text-decoration: none;
}
.gm-mygames-list li:first-child .gm-mygame {
  border-top: 0;
}
.gm-mygame:hover {
  background: var(--surface-2, #f6f7f9);
  color: inherit;
  text-decoration: none;
}
.gm-mygame-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}
.gm-mygame-opp {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gm-mygame-meta {
  font-size: 0.8rem;
  color: var(--text-2, #6b7280);
}
.gm-mygame-link {
  flex: 0 0 auto;
  font-size: 0.85rem;
  color: var(--link, #1d4ed8);
}
.gm-res {
  flex: 0 0 auto;
  min-width: 96px;
  padding: 2px 8px;
  border-radius: 6px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--surface-2, #f6f7f9);
  color: var(--text-2, #6b7280);
}
.gm-res.is-win {
  background: rgba(22, 163, 74, 0.14);
  color: var(--gm-win);
}
.gm-res.is-loss {
  background: rgba(220, 38, 38, 0.12);
  color: var(--gm-lose);
}

/* ---------- партия: раскладка ---------- */
.gm-game-grid {
  display: grid;
  grid-template-columns: minmax(0, 620px) minmax(280px, 380px);
  gap: 20px;
  justify-content: center;
  align-items: start;
}
.gm-board-col {
  min-width: 0;
}
.gm-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  background: var(--surface-1, #fff);
}

/* ---------- доска ---------- */
.gm-board {
  width: 100%;
}
.gm-board-box {
  position: relative;
  width: 100%;
}
/* Chessground ставит класс cg-board-wrap на этот элемент; s.min.css даёт ему 400x400 */
.gm-board .gm-cg.cg-board-wrap,
.gm-board .gm-cg {
  width: 100%;
  height: 0;
  padding-bottom: 100%;
  background-size: cover;
  border-radius: 4px;
}
.gm-board .gm-cg.cg-board-wrap svg {
  position: absolute;
  top: 0;
  left: 0;
}
/* подписи полей - внутри доски (в s.min.css они висят снаружи) */
.gm-board .cg-board-wrap coords {
  z-index: 3;
  font-size: 10px;
  font-weight: 700;
  opacity: 0.85;
  color: rgba(0, 0, 0, 0.7);
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.8);
  pointer-events: none;
}
.gm-board .cg-board-wrap coords.ranks {
  right: 2px;
  top: 1px;
  width: 10px;
  text-align: right;
}
.gm-board .cg-board-wrap coords.ranks coord {
  transform: none;
}
.gm-board .cg-board-wrap coords.files {
  bottom: 0;
  left: 3px;
  /* s.min.css даёт width: 100% - со сдвигом на 3 px строка вылезала за доску, а на
     телефоне доска во всю ширину - и за экран (прокрутка вбок) */
  width: calc(100% - 3px);
  height: 14px;
  text-transform: none;
  text-align: left;
}

/* выбор фигуры при превращении */
.gm-promo.cg-board {
  z-index: 10;
  background: rgba(15, 23, 42, 0.45);
  cursor: default;
}
.gm-promo-col {
  position: absolute;
  width: 12.5%;
  height: 50%;
  display: flex;
  flex-direction: column;
}
.gm-promo-btn {
  flex: 0 0 25%;
  width: 100%;
  padding: 4%;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 55%, #d6dbe3 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: border-radius 0.12s, background 0.12s;
}
.gm-promo-btn:hover,
.gm-promo-btn:focus-visible {
  border-radius: 6px;
  background: #fde68a;
  outline: none;
}
.gm-promo.cg-board .gm-promo-btn piece {
  position: static;
  display: block;
  width: 100%;
  height: 100%;
  transform: none;
  background-size: cover;
}

/* ---------- игроки, часы ---------- */
.gm-player {
  display: flex;
  align-items: center;
  gap: 10px;
  /* высота - всегда под имя и строку подписи («Бот думает…», «Вы», точность): иначе при
     появлении подписи панель росла и доска под ней скакала */
  min-height: 52px;
  padding: 6px 2px;
}
.gm-piece-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #6b7280;
  vertical-align: -1px;
  margin-right: 4px;
}
.gm-piece-dot.is-white {
  background: #ffffff;
}
.gm-piece-dot.is-black {
  background: #111827;
}
html[data-theme='dark'] .gm-piece-dot.is-black {
  border-color: #9aa4b2;
}
.gm-player-main {
  flex: 1 1 auto;
  min-width: 0;
}
.gm-player-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}
.gm-player-nick {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* огонёк у ника: в сети / не в сети */
.gm-online {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.gm-online.is-on {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
}
.gm-online.is-off {
  background: #9ca3af;
  box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.2);
}
html[data-theme='dark'] .gm-online.is-off {
  background: #6b7280;
}
.gm-player.is-active .gm-player-name {
  color: var(--gm-accent);
}
.gm-player-off {
  font-weight: 400;
  color: var(--text-2, #6b7280);
}
/* рейтинг у ника (как lichess): «1500?», после рейтинговой партии - изменение */
.gm-rating {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--text-2, #6b7280);
}
.gm-rating-diff {
  font-weight: 700;
}
.gm-rating-diff.is-up {
  color: #15803d;
}
.gm-rating-diff.is-down {
  color: #dc2626;
}
html[data-theme='dark'] .gm-rating-diff.is-up {
  color: #4ade80;
}
html[data-theme='dark'] .gm-rating-diff.is-down {
  color: #f87171;
}
.gm-seek-rating {
  margin-left: 6px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--text-2, #6b7280);
}
.gm-tag.is-rated {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}
html[data-theme='dark'] .gm-tag.is-rated {
  background: rgba(74, 222, 128, 0.14);
  color: #4ade80;
}
.gm-player-sub {
  font-size: 0.8rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-2, #6b7280);
}
.gm-material {
  flex: 0 0 auto;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-2, #6b7280);
}
.gm-clock {
  flex: 0 0 auto;
  min-width: 92px;
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--gm-clock-bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.35rem;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.gm-clock.is-running {
  background: var(--gm-clock-run-bg);
  color: var(--gm-clock-run-text);
}
.gm-clock.is-low {
  color: var(--gm-lose);
}
.gm-clock.is-running.is-low {
  background: #b91c1c;
  color: #fff;
}
.gm-clock.is-flag {
  background: #b91c1c;
  color: #fff;
}

/* ---------- боковая панель ---------- */
.gm-status-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gm-status {
  font-size: 1.15rem;
  font-weight: 800;
}
.gm-status.is-win {
  color: var(--gm-win);
}
.gm-status.is-lose {
  color: var(--gm-lose);
}
.gm-status.is-thinking {
  color: var(--text-2, #6b7280);
}
.gm-deadline {
  font-weight: 700;
  color: var(--text-2, #6b7280);
}
.gm-deadline.is-mine {
  color: var(--gm-lose);
}
.gm-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.gm-confirm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}
.gm-offer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--gm-accent-soft);
  font-weight: 600;
}
.gm-offer > span {
  flex: 1 1 100%;
}
.gm-offer.is-gone {
  background: var(--gm-warn-bg);
  border: 1px solid var(--gm-warn-border);
}
.gm-over-score {
  margin-bottom: 2px;
  font-size: 1.1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.gm-invite {
  padding: 10px;
  border-radius: 10px;
  border: 1px dashed var(--gm-accent);
  background: var(--gm-accent-soft);
}
.gm-invite .gm-link-box {
  margin-bottom: 0;
}
.gm-botcard {
  display: flex;
  align-items: center;
  gap: 10px;
}
.gm-botcard .gm-avatar {
  width: 44px;
  height: 44px;
  font-size: 1rem;
}
.gm-botcard-name {
  font-weight: 800;
}

/* ---------- запись ходов ---------- */
.gm-moves {
  position: relative;
  max-height: 300px;
  min-height: 80px;
  overflow-y: auto;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  background: var(--surface-2, #f6f7f9);
  font-variant-numeric: tabular-nums;
}
.gm-moves-empty {
  padding: 10px;
  color: var(--text-2, #6b7280);
  font-size: 0.9rem;
}
.gm-moves-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
}
.gm-moves-row:nth-child(even) {
  background: rgba(127, 127, 127, 0.06);
}
.gm-moves-n {
  padding: 4px 6px;
  color: var(--text-2, #6b7280);
  font-size: 0.85rem;
  text-align: right;
}
.gm-move {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--text-1, #1f2328);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}
.gm-move:hover {
  background: var(--gm-accent-soft);
}
.gm-move.is-current {
  background: var(--gm-accent);
  color: var(--gm-accent-text);
}
.gm-move.is-pending {
  opacity: 0.6;
}
.gm-move.is-empty,
.gm-move.is-blank {
  color: var(--text-2, #6b7280);
  cursor: default;
}
.gm-move-mark {
  margin-left: 2px;
  font-weight: 800;
}
.gm-move.is-inaccuracy .gm-move-mark {
  color: var(--gm-inaccuracy);
}
.gm-move.is-mistake .gm-move-mark {
  color: var(--gm-mistake);
}
.gm-move.is-blunder .gm-move-mark {
  color: var(--gm-blunder);
}
.gm-move.is-current .gm-move-mark {
  color: inherit;
}
.gm-moves-result {
  padding: 6px;
  text-align: center;
  font-weight: 800;
}

/* ---------- итог поверх доски ---------- */
.gm-over {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.35);
  border-radius: 4px;
  animation: gm-fade 0.25s ease-out 0.4s both;
}
.gm-over-card {
  position: relative;
  width: min(100%, 320px);
  padding: 20px 18px 18px;
  border-radius: 14px;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--surface-1, #fff);
  color: var(--text-1, #1f2328);
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
}
.gm-over-x {
  position: absolute;
  top: 6px;
  right: 6px;
}
.gm-over-title {
  margin: 0 16px 4px;
  font-size: 1.35rem;
  font-weight: 800;
}
.gm-over.is-win .gm-over-title {
  color: var(--gm-win);
}
.gm-over.is-lose .gm-over-title {
  color: var(--gm-lose);
}
.gm-over-text {
  color: var(--text-2, #6b7280);
}
.gm-over-note {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-2, #6b7280);
}
.gm-over-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
@keyframes gm-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .gm-over,
  .gm-spinner {
    animation: none;
  }
}

/* ---------- анализ ---------- */
.gm-nav {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
}
.gm-nav .gm-btn-icon {
  flex: 1 1 0;
  max-width: 72px;
}
/* значки листания крупные (26 px), как у lichess */
.gm-nav .gm-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 4px 6px;
  line-height: 1;
}
.gm-nav .gm-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.gm-side .gm-nav {
  margin: 0 0 -6px;
}

/* ---------- действия под ходами (значки, как у lichess) ---------- */
.gm-actbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 42px;
}
.gm-act {
  flex: 1 1 0;
  max-width: 72px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2, #6b7280);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.gm-act:hover:not(:disabled),
.gm-act:focus-visible {
  background: var(--surface-2, #f1f3f5);
  color: var(--text-1, #1f2328);
}
.gm-act:focus-visible {
  outline: 2px solid var(--gm-accent);
  outline-offset: 1px;
}
.gm-act:disabled {
  opacity: 0.35;
  cursor: default;
}
/* предложение (ничья, возврат хода) уже отправлено - подсвечено */
.gm-act.is-on,
.gm-act.is-on:disabled {
  opacity: 1;
  background: var(--gm-accent-soft);
  color: var(--gm-accent);
}
.gm-act-half {
  font-size: 1.35rem;
  font-weight: 700;
}
.gm-actbar.is-confirm {
  gap: 8px;
}
.gm-actbar-q {
  font-weight: 700;
  margin-right: 4px;
}
.gm-act.is-yes {
  flex: 0 0 56px;
  color: #ffffff;
  background: #15803d;
}
.gm-act.is-yes:hover {
  background: #166534;
  color: #ffffff;
}
.gm-act.is-no {
  flex: 0 0 56px;
  color: #ffffff;
  background: #b91c1c;
}
.gm-act.is-no:hover {
  background: #991b1b;
  color: #ffffff;
}
.gm-actbar.is-strip {
  margin-top: 2px;
  border-radius: 8px;
  background: var(--gm-clock-bg);
}
html[data-theme='dark'] .gm-act:hover:not(:disabled),
html[data-theme='dark'] .gm-act:focus-visible {
  background: rgba(255, 255, 255, 0.08);
}

/* ---------- карточка партии над анализом (как у lichess) ---------- */
.gm-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gm-info-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.gm-info-perf {
  flex: 0 0 auto;
  width: 34px;
  font-size: 28px;
  text-align: center;
  color: var(--text-2, #6b7280);
}
.gm-info-meta {
  min-width: 0;
}
.gm-info-title {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  line-height: 1.25;
}
.gm-info-when {
  display: block;
  font-size: 0.8rem;
  color: var(--text-2, #6b7280);
}
.gm-info-players {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.gm-info-player {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.gm-info-name {
  font-weight: 700;
  color: inherit;
  overflow-wrap: anywhere;
}
a.gm-info-name:hover {
  color: var(--link, #1d4ed8);
}
.gm-info-rating {
  color: var(--text-2, #6b7280);
  font-variant-numeric: tabular-nums;
}
.gm-info .gm-rating-diff {
  font-variant-numeric: tabular-nums;
}
.gm-info-result,
.gm-info-tournament {
  padding-top: 10px;
  border-top: 1px solid var(--border, #e5e7eb);
}
.gm-info-result {
  color: var(--text-2, #6b7280);
}
.gm-info-tournament {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--link, #1d4ed8);
}
.gm-info-tournament .fas {
  color: #c79100;
}
html[data-theme='dark'] .gm-info-tournament .fas {
  color: #f5c84c;
}
.gm-analysis-req {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gm-progress {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2, #eef1f5);
  overflow: hidden;
}
.gm-progress span {
  display: block;
  height: 100%;
  background: var(--gm-accent);
  transition: width 0.4s;
}
.gm-graph {
  position: relative;
  width: 100%;
  height: 110px;
  border-radius: 6px;
  overflow: hidden;
}
.gm-graph-svg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.gm-graph-bg {
  fill: var(--gm-graph-bg);
}
.gm-graph-area {
  fill: var(--gm-graph-fill);
}
.gm-graph-mid {
  stroke: rgba(127, 127, 127, 0.7);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}
.gm-graph-line {
  fill: none;
  stroke: #d97706;
  stroke-width: 1.5;
}
.gm-graph-cur {
  stroke: var(--gm-accent);
  stroke-width: 2;
}
.gm-graph-hover {
  stroke: rgba(127, 127, 127, 0.8);
  stroke-width: 1;
}
.gm-graph-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  border: 1px solid #fff;
  cursor: pointer;
}
.gm-graph-dot.is-inaccuracy {
  background: var(--gm-inaccuracy);
}
.gm-graph-dot.is-mistake {
  background: var(--gm-mistake);
}
.gm-graph-dot.is-blunder {
  background: var(--gm-blunder);
}
.gm-graph-dot.is-cur {
  transform: scale(1.4);
}
.gm-summary {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.gm-summary td,
.gm-summary th {
  padding: 4px 6px;
  border-top: 1px solid var(--border, #e5e7eb);
}
.gm-summary thead th {
  border-top: 0;
}
.gm-summary thead td {
  border-top: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.gm-summary td {
  width: 34%;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.gm-summary th {
  text-align: center;
  font-weight: 400;
  color: var(--text-2, #6b7280);
}
.gm-summary tr.is-inaccuracy th {
  color: var(--gm-inaccuracy);
}
.gm-summary tr.is-mistake th {
  color: var(--gm-mistake);
}
.gm-summary tr.is-blunder th {
  color: var(--gm-blunder);
}
.gm-evalbox {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2, #f6f7f9);
}
.gm-evalbox-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.gm-eval {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  font-size: 1.05rem;
}
.gm-eval-sm {
  font-size: 0.9rem;
  margin-left: auto;
}
.gm-played {
  font-weight: 600;
}
.gm-played.is-inaccuracy {
  color: var(--gm-inaccuracy);
}
.gm-played.is-mistake {
  color: var(--gm-mistake);
}
.gm-played.is-blunder {
  color: var(--gm-blunder);
}
.gm-best,
.gm-pv {
  overflow-wrap: anywhere;
}
.gm-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  cursor: pointer;
  font-weight: 600;
}
.gm-switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--gm-accent);
}

/* ---------- узкие экраны ---------- */
@media (max-width: 991px) {
  .gm-lobby-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 860px) {
  .gm-game-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .gm-board-col {
    max-width: 620px;
    width: 100%;
    margin: 0 auto;
  }
  .gm-moves {
    max-height: 180px;
  }
}
@media (max-width: 575px) {
  .gm-page {
    padding: 10px 0 32px;
  }
  .gm-quick-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .gm-quick {
    min-height: 62px;
  }
  .gm-quick-tc {
    font-size: 1.15rem;
  }
  .gm-card,
  .gm-side {
    padding: 12px;
  }
  .gm-clock {
    min-width: 80px;
    font-size: 1.2rem;
  }
  .gm-form-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .gm-seg-btn {
    padding: 4px 7px;
    font-size: 0.85rem;
  }
  .gm-bot {
    padding: 6px;
    gap: 6px;
  }
  .gm-bot .gm-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }
  .gm-bot-name {
    white-space: normal;
    font-size: 0.85rem;
    line-height: 1.2;
  }
  .gm-res {
    min-width: 84px;
  }
  .gm-head {
    flex-direction: column;
    gap: 4px;
  }
  .gm-head-meta {
    padding-top: 0;
  }
}

/* Телефон: доска на всю ширину. Отступы дают обёртки сайта (.container 15 px, .main__content,
   .col-12 15 px - вместе 31 px с каждой стороны, доска на 320 px была 258 px); убираем их
   только на страницах с доской (не в лобби). Без :has (старые браузеры) - просто прежние отступы. */
@media (max-width: 575px) {
  .container:has(.gm-game),
  .main__content:has(.gm-game),
  .col-12:has(> #games_root .gm-game) {
    padding-left: 0;
    padding-right: 0;
  }
  .main__content:has(.gm-game) {
    margin-left: 0;
    margin-right: 0;
  }
  .gm-game .gm-player,
  .gm-game .gm-actions,
  .gm-game .gm-side {
    margin-left: 8px;
    margin-right: 8px;
  }
}

/* метка «beta» - как у «Аналитики партий» (views/mystudents/student_analytics.ejs .analytics-beta) */
.gm-beta {
  display: inline-block;
  margin-left: 8px;
  padding: 0 7px;
  border-radius: 999px;
  background: #fff3cd;
  color: #8a5a00;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.6;
  vertical-align: middle;
  letter-spacing: 0;
}
html[data-theme='dark'] .gm-beta {
  background: rgba(234, 179, 8, 0.18);
  color: #fde047;
}

/* хлебные крошки над страницами игровой (views/games/page.ejs): breadcrumb сайта, по ширине
   страницы игровой */
.gm-crumbs {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 16px 0;
}
.gm-crumbs .breadcrumb {
  margin-bottom: 0;
}
@media (max-width: 575px) {
  .gm-crumbs {
    padding: 8px 8px 0;
  }
  .gm-crumbs .breadcrumb {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }
}

/* ---------- ходы лентой на телефоне (MoveStrip, как на lichess) ----------
   До 860 px вместо колонки ходов (MoveList) и ряда кнопок анализа - лента под доской:
   в начало, назад, ходы фигурками (текущий в середине), вперёд, в конец. */
.gm-strip {
  display: none;
}
@media (max-width: 860px) {
  .gm-strip {
    display: flex;
    align-items: stretch;
    height: 42px;
    margin: 6px 0 2px;
    border-radius: 8px;
    background: var(--gm-clock-bg);
    overflow: hidden;
  }
  .gm-game .gm-moves,
  .gm-game .gm-nav {
    display: none;
  }
}
.gm-strip-btn {
  flex: 0 0 auto;
  width: 44px;
  border: 0;
  background: transparent;
  color: var(--text-1, #1f2328);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.gm-strip-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.gm-strip-btn:not(:disabled):active {
  background: rgba(0, 0, 0, 0.08);
}
.gm-strip-moves {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.gm-strip-moves::-webkit-scrollbar {
  display: none;
}
.gm-strip-n {
  flex: 0 0 auto;
  padding: 0 2px 0 6px;
  color: var(--text-2, #6b7280);
  font-size: 0.8rem;
}
.gm-strip-move {
  flex: 0 0 auto;
  border: 0;
  border-radius: 4px;
  padding: 4px 6px;
  background: transparent;
  color: var(--text-1, #1f2328);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
  cursor: pointer;
}
.gm-strip-move.is-current {
  background: var(--gm-accent);
  color: var(--gm-accent-text);
}
.gm-strip-move.is-pending {
  opacity: 0.55;
}
.gm-strip-move.is-inaccuracy .gm-move-mark {
  color: var(--gm-inaccuracy);
}
.gm-strip-move.is-mistake .gm-move-mark {
  color: var(--gm-mistake);
}
.gm-strip-move.is-blunder .gm-move-mark {
  color: var(--gm-blunder);
}
.gm-strip-move.is-current .gm-move-mark {
  color: inherit;
}
.gm-strip-empty {
  padding: 0 10px;
  color: var(--text-2, #6b7280);
  font-size: 0.85rem;
}
html[data-theme='dark'] .gm-strip-btn:not(:disabled):active {
  background: rgba(255, 255, 255, 0.1);
}

/* значок оценки хода на поле (анализ): рисунки lichess (app/games/glyphs.js), круг с тенью;
   место и размер - в Board.jsx (правый верхний угол поля, чуть за краем) */
.gm-glyph {
  position: absolute;
  z-index: 4;
  overflow: visible;
  filter: drop-shadow(0.5px 1.5px 1.5px rgba(0, 0, 0, 0.5));
  pointer-events: auto;
}
