/* =========================================================
   Шахматы — тёплая, спокойная типографика в духе Claude
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --bg: #F5F2EA;
  --panel: #FFFFFF;
  --panel-soft: #FAF7F0;
  --ink: #23201A;
  --ink-2: #5E584D;
  --ink-3: #968E7F;
  --line: #E8E1D3;
  --line-strong: #D9D0BE;
  --accent: #C2603F;
  --accent-ink: #A44D30;
  --accent-soft: #F7E8DF;
  --green: #4F7350;
  --green-soft: #E8F0E4;
  --amber: #A97C22;
  --amber-soft: #F8EFD9;
  --red: #B0452E;
  --red-soft: #F8E4DE;

  --sq-light: #F1EADA;
  --sq-dark: #B99B74;

  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --radius: 18px;
  --shadow-sm: 0 1px 2px rgba(35, 30, 22, .05);
  --shadow-md: 0 1px 2px rgba(35, 30, 22, .04), 0 14px 34px -22px rgba(52, 40, 24, .45);
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(900px 600px at 12% -8%, #FCF8F0 0%, rgba(252, 248, 240, 0) 62%),
    radial-gradient(800px 560px at 105% 4%, #F7EFE5 0%, rgba(247, 239, 229, 0) 58%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------------------------------------------------------
   Шапка
   --------------------------------------------------------- */
.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px 28px 34px;
  padding-bottom: calc(34px + env(safe-area-inset-bottom, 0px));
}

button, input, .btn, .act, .mv, .color-btn, .mode-tab, .mobile-tab {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding-bottom: 22px;
}

.brand { display: flex; align-items: center; gap: 13px; }

.brand-mark {
  width: 46px; height: 46px; flex: none;
  display: grid; place-items: center;
  border-radius: 14px;
  background: linear-gradient(150deg, #FFFFFF, #FBF5EA);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--accent-ink);
}
.brand-mark svg {
  width: 25px; height: 25px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -.012em;
  line-height: 1.05;
}

.brand p {
  margin: 3px 0 0;
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}

.topbar-actions { display: flex; gap: 9px; }

/* ---------------------------------------------------------
   Кнопки
   --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 15px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: #FFFFFF;
  color: var(--ink);
  font-size: 13.5px; font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, transform .06s ease, box-shadow .16s ease, opacity .16s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: #FBF7EF; border-color: #CEC4B0; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: default; pointer-events: none; }
.btn.primary {
  background: linear-gradient(180deg, #363129, #272320);
  border-color: #272320;
  color: #FBF7EF;
}
.btn.primary:hover { background: linear-gradient(180deg, #423B31, #2E2A25); border-color: #2E2A25; }
.btn.wide { width: 100%; }
.btn.big { padding: 13px 18px; font-size: 14.5px; border-radius: 13px; }
.btn.small { padding: 7px 11px; font-size: 12.5px; border-radius: 10px; }
.btn .ic { width: 16px; height: 16px; }
.btn.icon-only { width: 40px; padding-left: 0; padding-right: 0; }
.btn.icon-only .ic { width: 18px; height: 18px; }

.ic {
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}

.icon-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 15px;
  transition: background .14s, color .14s, border-color .14s;
}
.icon-btn:hover { background: var(--panel-soft); border-color: var(--line); color: var(--ink); }
.icon-btn .ic { width: 16px; height: 16px; }

/* ---------------------------------------------------------
   Раскладка
   --------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 356px;
  gap: 36px;
  align-items: start;
}

.board-col { width: 100%; display: flex; flex-direction: column; }

.side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 18px; }

/* ---------------------------------------------------------
   Карточки
   --------------------------------------------------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 17px 15px;
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 11px;
}
.card-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: .005em;
}

.pill {
  font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 20px;
  padding: 3px 9px;
  letter-spacing: .01em;
}

/* ---------------------------------------------------------
   Игроки
   --------------------------------------------------------- */
.player {
  display: flex; align-items: center; gap: 11px;
  padding: 6px 4px;
}

.avatar {
  width: 40px; height: 40px; flex: none;
  border-radius: 13px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  display: grid; place-items: center;
  overflow: hidden;
}
.avatar svg { width: 27px; height: 27px; }
.avatar.tint-black { background: linear-gradient(160deg, #FFFFFF, #F4EDE1); }
.avatar.tint-white { background: linear-gradient(160deg, #FFFDF8, #F0E6D4); }

.player-main { min-width: 0; flex: 1; }

.player-line { display: flex; align-items: center; gap: 8px; min-width: 0; }

.player-name {
  font-size: 14px; font-weight: 600; letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.elo {
  font-size: 10.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 2px 6px;
  flex: none;
}

.captured { display: flex; align-items: center; height: 18px; margin-top: 1px; }
.captured .piece-svg { width: 18px; height: 18px; margin-left: -5px; opacity: .9; }
.captured .piece-svg:first-child { margin-left: 0; }

.material {
  font-size: 11.5px; font-weight: 650;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  flex: none;
}
.material.plus { color: var(--green); }

.thinking { display: inline-flex; gap: 3px; align-items: center; margin-left: 2px; }
.thinking i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.05s infinite ease-in-out;
}
.thinking i:nth-child(2) { animation-delay: .14s; }
.thinking i:nth-child(3) { animation-delay: .28s; }

@keyframes bounce {
  0%, 100% { opacity: .28; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2.5px); }
}

/* ---------------------------------------------------------
   Доска
   --------------------------------------------------------- */
.board-row { display: flex; gap: 12px; align-items: stretch; }

.eval-col {
  width: 18px; flex: none;
  display: flex; flex-direction: column; gap: 7px;
  padding: 1px 0 0;
}

.eval-bar {
  position: relative;
  flex: 1;
  min-height: 120px;
  border-radius: 9px;
  overflow: hidden;
  background: #3B342B;
  box-shadow: inset 0 0 0 1px rgba(20, 15, 8, .35), 0 3px 10px -4px rgba(40, 30, 18, .3);
}
.eval-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 50%;
  background: linear-gradient(180deg, #FFFDF6 0%, #F2E9D7 100%);
  transition: height .5s cubic-bezier(.25, .9, .3, 1);
}
.eval-bar::after {
  content: '';
  position: absolute; left: 0; right: 0; top: 50%;
  height: 1px;
  background: rgba(194, 96, 63, .75);
}
.eval-num {
  font-size: 10px; font-weight: 700;
  text-align: center;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

.board-frame {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 12px;
  border-radius: 24px;
  background: linear-gradient(155deg, #FFFFFF 0%, #FBF6EC 55%, #F6EFE2 100%);
  border: 1px solid #EAE2D3;
  box-shadow:
    0 1px 1px rgba(52, 40, 24, .04),
    0 30px 60px -38px rgba(52, 40, 24, .55),
    0 6px 16px -12px rgba(52, 40, 24, .22);
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--sq-light);
  box-shadow: inset 0 0 0 1px rgba(60, 45, 25, .16);
  touch-action: none;
  user-select: none;
}

.squares {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}
.sq { position: relative; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }

.coord {
  position: absolute;
  font-size: 9.5px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: .02em;
  color: rgba(70, 52, 30, .42);
  pointer-events: none;
}
.sq.dark .coord { color: rgba(255, 247, 232, .62); }
.coord.file { right: 4px; bottom: 4px; }
.coord.rank { left: 4px; top: 4px; }

/* фигуры */
.pieces { position: absolute; inset: 0; pointer-events: none; }

.piece {
  position: absolute; top: 0; left: 0;
  width: 12.5%; height: 12.5%;
  transition: transform .19s cubic-bezier(.2, .85, .3, 1);
  will-change: transform;
  pointer-events: auto;
  cursor: grab;
  z-index: 2;
}
.piece svg {
  width: 100%; height: 100%; display: block;
  transform: scale(1.075);
  transform-origin: 50% 84%;
  filter: drop-shadow(0 2px 1.5px rgba(40, 30, 15, .22));
}
.piece.dragging {
  transition: none;
  z-index: 9;
  cursor: grabbing;
  transform-origin: center;
}
.piece.dragging svg { filter: drop-shadow(0 8px 10px rgba(40, 30, 15, .3)); }
.piece.flying { transition: none; z-index: 8; pointer-events: none; }
.piece.is-captured { animation: captured .2s ease forwards; }
.piece.is-captured svg { transition: transform .2s, opacity .2s; }
@keyframes captured {
  to { opacity: 0; }
}

.piece.white, .tint-white {
  --fill: #FCF8EF;
  --stroke: #3A342B;
  --detail: #94805F;
  --detail-fill: #3A342B;
}
.piece.black, .tint-black {
  --fill: #38322B;
  --stroke: #14110D;
  --detail: #CBBDA4;
  --detail-fill: #CBBDA4;
}

.pc-body {
  fill: var(--fill);
  stroke: var(--stroke);
  stroke-width: 2.5;
  stroke-linejoin: round;
}
.pc-detail { stroke: var(--detail); stroke-width: 2.2; fill: none; }
.pc-detail-fill { fill: var(--detail-fill); stroke: none; }
.piece-svg { display: block; }
.piece-svg .pc-body { fill: var(--fill); stroke: var(--stroke); stroke-width: 2.5; stroke-linejoin: round; }

/* подсветки */
.marks { position: absolute; inset: 0; pointer-events: none; }
.mark { position: absolute; top: 0; left: 0; width: 12.5%; height: 12.5%; }
.mark.last { background: rgba(194, 96, 63, .15); box-shadow: inset 0 0 0 2px rgba(194, 96, 63, .18); }
.mark.sel { background: rgba(194, 96, 63, .26); box-shadow: inset 0 0 0 2px rgba(194, 96, 63, .45); }
.mark.dot::after {
  content: ''; position: absolute; inset: 36%;
  border-radius: 50%;
  background: rgba(48, 38, 26, .26);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .28);
}
.mark.cap::after {
  content: ''; position: absolute; inset: 6%;
  border-radius: 50%;
  border: 3.5px solid rgba(48, 38, 26, .24);
}
.mark.check {
  background: radial-gradient(circle at 50% 50%, rgba(190, 62, 38, .5) 0%, rgba(190, 62, 38, 0) 72%);
}
.mark.hint { box-shadow: inset 0 0 0 3px rgba(194, 96, 63, .8); border-radius: 8px; }

.arrows {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 3;
}

/* ---------------------------------------------------------
   Действия под доской
   --------------------------------------------------------- */
.board-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 2px 0; }

.act {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 13px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .72);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: all .15s ease;
  backdrop-filter: blur(4px);
}
.act .ic { width: 15px; height: 15px; }
.act:hover { background: #FFFFFF; color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.act:active { transform: translateY(1px); }
.act:disabled { opacity: .4; pointer-events: none; }
.act.danger:hover { color: var(--red); border-color: #EBC7BB; background: #FCF3EF; }

.status-line {
  padding: 9px 4px 0;
  font-size: 12.5px;
  color: var(--ink-3);
  min-height: 18px;
}

/* ---------------------------------------------------------
   Тренер
   --------------------------------------------------------- */
.coach-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
  min-height: 42px;
}
.coach-text b { color: var(--ink); font-weight: 650; }

.hint-card {
  margin-top: 12px;
  border-radius: 13px;
  border: 1px solid #EFD9CB;
  background: linear-gradient(160deg, #FDF5EF, #FBF1E7);
  padding: 11px 12px;
  animation: fadeUp .25s ease both;
}
.hint-top { display: flex; align-items: center; gap: 8px; }
.hint-badge {
  font-size: 9.5px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent-ink);
}
.hint-top strong {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.hint-eval {
  margin-left: auto;
  font-size: 11.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
  background: rgba(194, 96, 63, .1);
  padding: 2px 7px;
  border-radius: 6px;
}
.hint-why { margin: 7px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.hint-alts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.hint-alt {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: rgba(255, 255, 255, .8);
  border: 1px solid #EFE2D4;
  border-radius: 7px;
  padding: 2px 7px;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------
   Партия / ходы
   --------------------------------------------------------- */
.head-actions { display: flex; align-items: center; gap: 4px; }
.nav-group { display: flex; gap: 1px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 9px; padding: 1px; }
.nav-group .icon-btn { width: 24px; height: 24px; border-radius: 7px; }

.moves {
  max-height: 228px;
  overflow-y: auto;
  margin: 0 -6px;
  padding: 0 6px 2px;
  scrollbar-width: thin;
  scrollbar-color: #DDD3C2 transparent;
}
.moves::-webkit-scrollbar { width: 7px; }
.moves::-webkit-scrollbar-thumb { background: #E0D6C5; border-radius: 4px; }
.moves::-webkit-scrollbar-track { background: transparent; }

.mn-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr;
  align-items: center;
  gap: 2px;
  border-radius: 8px;
}
.mn-num {
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: right;
  padding-right: 7px;
  font-variant-numeric: tabular-nums;
}
.mv {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 7px;
  border: none; background: none;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  min-height: 26px;
  transition: background .12s, color .12s;
}
.mv:hover { background: var(--panel-soft); }
.mv.current { background: var(--accent-soft); color: var(--accent-ink); }
.mv .g {
  font-size: 9.5px;
  font-weight: 800;
  line-height: 14px;
  padding: 0 3px;
  border-radius: 4px;
  letter-spacing: -.02em;
}

.g-best { color: #3F6B45; background: #E4EFE0; }
.g-excellent { color: #4B6E4A; background: #E9F0E3; }
.g-good { color: #6B7350; background: #EFF1E2; }
.g-inaccuracy { color: #99701C; background: #F7EDD5; }
.g-mistake { color: #A95B2A; background: #F9E6D8; }
.g-blunder { color: #A53D2A; background: #F8E0DA; }

.empty {
  padding: 14px 4px 8px;
  font-size: 12.5px;
  color: var(--ink-3);
  text-align: center;
}

.live-btn { margin-top: 10px; width: 100%; }

/* ---------------------------------------------------------
   Оценка партии
   --------------------------------------------------------- */
.acc-pair { display: flex; gap: 9px; margin-bottom: 10px; }
.acc {
  flex: 1;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px 11px 8px;
  display: flex; flex-direction: column; gap: 1px;
  min-width: 0;
}
.acc-label {
  font-size: 9.5px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acc-val {
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.15;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}
.acc-val small { font-family: var(--sans); font-size: 11px; color: var(--ink-3); font-weight: 600; }

#graph {
  display: block;
  width: 100%;
  height: 104px;
  border-radius: 11px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.review-summary {
  margin: 9px 0 0;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-2);
}
.review-summary b { color: var(--ink); font-weight: 650; }

.review-bar {
  position: relative;
  margin-top: 9px;
  height: 27px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex; align-items: center;
}
.review-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(194, 96, 63, .18), rgba(194, 96, 63, .3));
  transition: width .2s ease;
}
.review-text {
  position: relative;
  font-size: 11px;
  font-weight: 650;
  color: var(--ink-2);
  padding-left: 10px;
  font-variant-numeric: tabular-nums;
}
.review-cancel {
  position: relative;
  margin-left: auto;
  margin-right: 3px;
  border: none; background: none;
  font-size: 11px; font-weight: 600;
  color: var(--accent-ink);
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 6px;
}
.review-cancel:hover { background: rgba(194, 96, 63, .1); }

.legend {
  display: flex; flex-wrap: wrap; gap: 5px 9px;
  margin-top: 10px;
  font-size: 10.5px;
  color: var(--ink-3);
}
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }

/* ---------------------------------------------------------
   Подвал
   --------------------------------------------------------- */
.foot {
  margin-top: 30px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-3);
  display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center;
}
.dot-sep { opacity: .5; }

/* ---------------------------------------------------------
   Модальное окно настройки
   --------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0;
  z-index: 50;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(38, 32, 23, .42);
  backdrop-filter: blur(7px);
  animation: fade .2s ease;
}
.overlay[hidden] { display: none; }

.modal {
  position: relative;
  width: min(470px, 100%);
  background: #FDFBF5;
  border: 1px solid #E9E1D1;
  border-radius: 24px;
  padding: 26px 26px 24px;
  box-shadow: 0 40px 90px -32px rgba(30, 22, 12, .6);
  animation: pop .28s cubic-bezier(.2, .9, .3, 1);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: all .14s ease;
}
.modal-close:hover { background: var(--panel-soft); border-color: var(--line); color: var(--ink); }
.modal-close .ic,
.modal-close svg { width: 16px; height: 16px; }
.modal-close[hidden] { display: none; }

.eyebrow {
  margin: 0;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
}

.modal h2 {
  margin: 7px 0 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -.015em;
  line-height: 1.15;
}
.modal-sub { margin: 9px 0 0; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }

.field { margin-top: 22px; }
.field-label { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); }

.color-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; margin-top: 9px; }
.color-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  padding: 12px 6px 10px;
  border-radius: 14px;
  border: 1.5px solid var(--line-strong);
  background: #FFFFFF;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.color-btn .piece-svg { width: 32px; height: 32px; }
.color-btn .dice { width: 26px; height: 26px; margin: 3px 0; color: var(--ink-2); stroke-width: 1.6; }
.color-btn:hover { border-color: #C9BFA9; background: #FDFAF3; }
.color-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(194, 96, 63, .12);
}

.elo-head { display: flex; align-items: baseline; justify-content: space-between; }
.elo-value {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  margin: 8px 0 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 4px;
  background: linear-gradient(90deg, #E7DCC8, #D6BE9E);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  background: #FFFDF8;
  border: 2.5px solid var(--accent);
  box-shadow: 0 3px 8px -2px rgba(70, 40, 20, .35);
}
input[type="range"]::-moz-range-track {
  height: 6px; border-radius: 4px;
  background: linear-gradient(90deg, #E7DCC8, #D6BE9E);
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #FFFDF8;
  border: 2.5px solid var(--accent);
  box-shadow: 0 3px 8px -2px rgba(70, 40, 20, .35);
}

.elo-scale {
  display: flex; justify-content: space-between;
  font-size: 10px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  padding: 0 2px;
  margin-top: 2px;
}

.opponent-desc {
  margin-top: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
  min-height: 62px;
}
.opponent-desc strong { font-size: 13px; color: var(--ink); font-weight: 650; }

.modal .btn.big { margin-top: 22px; }

/* ---------------------------------------------------------
   Финал партии
   --------------------------------------------------------- */
.result-layer {
  position: absolute;
  inset: 12px;
  z-index: 5;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: rgba(250, 246, 238, .74);
  backdrop-filter: blur(3px);
  animation: fade .25s ease;
  padding: 18px;
}
.result-layer[hidden] { display: none; }

.result-card {
  width: min(330px, 100%);
  text-align: center;
  background: #FFFDF8;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 24px 20px;
  box-shadow: 0 30px 60px -28px rgba(40, 30, 15, .55);
  animation: pop .3s cubic-bezier(.2, .9, .3, 1);
}
.result-card h2 {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 500;
  letter-spacing: -.015em;
}
.result-sub { margin: 7px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.result-actions { display: flex; gap: 8px; margin-top: 18px; }
.result-actions .btn { flex: 1; }

/* ---------------------------------------------------------
   Превращение пешки
   --------------------------------------------------------- */
.promo {
  position: fixed; inset: 0;
  z-index: 55;
  display: grid; place-items: center;
  background: rgba(38, 32, 23, .38);
  backdrop-filter: blur(4px);
  animation: fade .15s ease;
}
.promo[hidden] { display: none; }

.promo-card {
  background: #FFFDF8;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px 18px 18px;
  box-shadow: 0 30px 70px -26px rgba(30, 22, 12, .6);
  text-align: center;
  animation: pop .22s cubic-bezier(.2, .9, .3, 1);
}
.promo-title {
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 11px;
}
.promo-row { display: flex; gap: 8px; }
.promo-btn {
  width: 64px; height: 64px;
  border-radius: 14px;
  border: 1.5px solid var(--line-strong);
  background: #FFFFFF;
  display: grid; place-items: center;
  cursor: pointer;
  transition: all .13s ease;
}
.promo-btn:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }
.promo-btn .piece-svg { width: 48px; height: 48px; }

/* ---------------------------------------------------------
   Тост
   --------------------------------------------------------- */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  transform: translateY(14px);
  opacity: 0;
  pointer-events: none;
  background: #282420;
  color: #FBF7EE;
  border-radius: 13px;
  padding: 11px 17px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 22px 46px -20px rgba(0, 0, 0, .7);
  transition: opacity .22s ease, transform .22s ease;
  max-width: min(90vw, 440px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast b { color: #F3C9A8; }

/* ---------------------------------------------------------
   Режимы игры: онлайн, вдвоём, комната
   --------------------------------------------------------- */
.mode-tabs {
  display: flex;
  gap: 4px;
  margin-top: 18px;
  padding: 4px;
  border-radius: 12px;
  background: #F2ECE0;
  border: 1px solid var(--line);
}
.mode-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 6px;
  border-radius: 9px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.mode-tab:hover { color: var(--ink); }
.mode-tab.active {
  background: #FFFFFF;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(35, 30, 22, .09);
}

.pane-note {
  margin-top: 18px;
  padding: 14px;
  border-radius: 13px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
}
.pane-note strong { color: var(--ink); font-size: 13.5px; font-weight: 650; }

.online-name { margin-top: 18px; }
.online-name input {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #FFFFFF;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.online-name input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194, 96, 63, .12);
}

.online-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
.online-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}
.online-card strong { font-size: 13.5px; }
.online-card > span {
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-2);
  flex: 1;
}
.online-card .btn { margin-top: 6px; }
.join-row { display: flex; gap: 6px; }
.join-row input {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: #FFFFFF;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.join-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194, 96, 63, .12);
}
.online-note {
  margin-top: 12px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-3);
}

.room-waiting {
  margin-top: 16px;
  padding: 16px 14px;
  border-radius: 14px;
  text-align: center;
  background: linear-gradient(160deg, #FDF6EF, #FBF0E4);
  border: 1px solid #EFD9CB;
  animation: fadeUp .25s ease both;
}
.room-code {
  font-family: var(--serif);
  font-size: 30px;
  letter-spacing: .16em;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}
.room-waiting-text {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.room-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }

.room-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 7px 10px;
  border-radius: 11px;
  border: 1px dashed var(--line-strong);
  background: rgba(255, 255, 255, .6);
  font-size: 12px;
  color: var(--ink-2);
}
.room-pill {
  flex: none;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #FFFFFF;
  background: var(--green);
  border-radius: 5px;
  padding: 2px 6px;
}
.room-pill.off { background: var(--ink-3); }
.room-pill.warn { background: var(--amber); }
.room-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.room-link {
  flex: none;
  border: none;
  background: none;
  padding: 4px 6px;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-ink);
  cursor: pointer;
}
.room-link:hover { background: var(--accent-soft); }
.room-link.danger { color: var(--red); }
.room-link.danger:hover { background: var(--red-soft); }

/* чат */
.chat-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 128px;
  overflow-y: auto;
  margin-bottom: 8px;
  scrollbar-width: thin;
}
.chat-log:empty { display: none; }
.chat-msg {
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-2);
  word-break: break-word;
}
.chat-msg b { color: var(--ink); font-weight: 650; }
.chat-msg.mine { text-align: right; }
.chat-msg.sys { text-align: center; color: var(--ink-3); font-style: italic; }
.chat-form { display: flex; gap: 6px; }
.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: #FFFFFF;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
}
.chat-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194, 96, 63, .12);
}

.mobile-tabs { display: none; }

/* ---------------------------------------------------------
   Аккаунт, друзья, рейтинг
   --------------------------------------------------------- */
.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  max-width: 200px;
  padding: 4px 13px 4px 5px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #FFFFFF;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .15s ease, border-color .15s ease;
}
.account-chip:hover { background: #FBF7EF; border-color: #CEC4B0; }
.account-avatar {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 17px;
  line-height: 1;
}
.account-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-chip.signed .account-avatar {
  background: linear-gradient(160deg, #FDF2EA, #F5E1D4);
  border: 1px solid #EFD9CB;
}

.account-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.account-inline:hover { background: #FFFFFF; border-color: var(--line-strong); color: var(--ink); }
.account-inline + .account-inline { margin-left: 8px; }
.account-inline .ic { width: 15px; height: 15px; }
.account-inline span:first-child { font-size: 15px; line-height: 1; }

.account-modal { width: min(520px, 100%); }
.account-tabs { margin-top: 16px; }
.account-pane { margin-top: 16px; display: flex; flex-direction: column; gap: 13px; }

.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-avatar {
  width: 60px; height: 60px;
  flex: none;
  display: grid; place-items: center;
  font-size: 32px;
  border-radius: 50%;
  background: linear-gradient(160deg, #FDF2EA, #F3E2D4);
  border: 1px solid #EFD9CB;
}
.profile-headline { min-width: 0; }
.profile-name {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-rating { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.profile-rating b { color: var(--accent-ink); font-size: 16px; font-family: var(--serif); }

.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.stat {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 8px 4px;
  text-align: center;
}
.stat b { display: block; font-family: var(--serif); font-size: 18px; line-height: 1.15; }
.stat span { font-size: 9px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }

.profile-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

#profileBio {
  width: 100%;
  margin-top: 7px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #FFFFFF;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  resize: vertical;
}
#profileBio:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194, 96, 63, .12);
}

.profile-history { display: flex; flex-direction: column; gap: 5px; }
.history-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--panel-soft);
  font-size: 12px;
  color: var(--ink-2);
}
.history-row .res { font-weight: 700; width: 16px; text-align: center; }
.history-row .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-win { color: var(--green); }
.res-loss { color: var(--red); }
.res-draw { color: var(--amber); }

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.avatar-opt {
  height: 38px;
  border-radius: 10px;
  border: 1.5px solid var(--line-strong);
  background: #FFFFFF;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all .12s ease;
}
.avatar-opt:hover { border-color: #C9BFA9; }
.avatar-opt.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px rgba(194, 96, 63, .12); }

#authName,
#authPass {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #FFFFFF;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#authName::placeholder,
#authPass::placeholder { color: var(--ink-3); }
#authName:focus,
#authPass:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194, 96, 63, .12);
}
#authForm #authSubmit { margin-top: 18px; }

.auth-error {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 12.5px;
  line-height: 1.4;
}
.auth-error[hidden] { display: none; }

.friend-add { display: flex; gap: 8px; }
.friend-add input {
  flex: 1;
  min-width: 0;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #FFFFFF;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.friend-add input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194, 96, 63, .12);
}
.friend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}
.friend-row + .friend-row { margin-top: 6px; }
.friend-avatar {
  width: 34px; height: 34px;
  flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 18px;
  background: #FFFFFF;
  border: 1px solid var(--line);
}
.friend-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.friend-rating { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.friend-actions { margin-left: auto; display: flex; gap: 3px; }
.dot-online { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; }
.dot-online.off { background: var(--line-strong); }
.tab-badge {
  margin-left: 5px;
  display: inline-block;
  min-width: 15px;
  padding: 1px 4px;
  border-radius: 8px;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 9.5px;
  line-height: 13px;
}

.leaderboard { display: flex; flex-direction: column; gap: 3px; }
.lb-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13px;
}
.lb-row.me { background: var(--accent-soft); }
.lb-rank { width: 20px; text-align: right; color: var(--ink-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.lb-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-rating { font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-games { font-size: 11px; color: var(--ink-3); min-width: 44px; text-align: right; }

.account-hint {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-3);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
}
.account-hint[hidden] { display: none; }

/* ---------------------------------------------------------
   Учёба и озвучка
   --------------------------------------------------------- */
.btn.icon-only.on {
  background: var(--accent-soft);
  border-color: #E8CFC1;
  color: var(--accent-ink);
}

.learn-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid #EADFD0;
  background: linear-gradient(180deg, #FFFDF9, #FBF4EA);
  box-shadow: var(--shadow-sm);
}
.learn-bar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.learn-bar-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
.learn-bar-task { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.learn-bar-actions { display: flex; gap: 6px; flex: none; }

.learn-modal { width: min(660px, 100%); }
.learn-courses { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.learn-course h3 {
  margin: 0 0 7px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.learn-course h3 .learn-level {
  color: var(--ink-3);
  font-weight: 600;
  letter-spacing: .05em;
}

.learn-lesson {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #FFFFFF;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.learn-lesson:hover { border-color: #D8CCB8; background: #FCF8F1; }
.learn-lesson + .learn-lesson { margin-top: 6px; }
.learn-lesson-icon {
  width: 26px; height: 26px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
}
.learn-lesson.done .learn-lesson-icon { background: #E4F1E6; color: #2F7A45; }
.learn-lesson-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.learn-lesson-text b { font-size: 13.5px; }
.learn-lesson-text span { font-size: 11.5px; color: var(--ink-3); }

.learn-practice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}
.learn-practice h3 { margin: 0; font-family: var(--serif); font-size: 19px; }
.learn-practice p { margin: 3px 0 0; font-size: 12px; color: var(--ink-2); }
.learn-progress { color: var(--accent-ink) !important; font-weight: 700; }
.learn-register { margin: 14px 0 0; font-size: 12px; color: var(--ink-3); }
.learn-register[hidden] { display: none; }
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------------------------------------------------------
   Анимации
   --------------------------------------------------------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.app { animation: fade .35s ease both; }

/* ---------------------------------------------------------
   Адаптив
   --------------------------------------------------------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .board-col { max-width: 560px; margin: 0 auto; }
  .side { position: static; max-width: 560px; margin: 0 auto; width: 100%; }
  .app { padding: 20px 18px 30px; }
}

@media (min-width: 1001px) and (max-height: 900px) {
  .app { padding-top: 16px; padding-bottom: 22px; }
  .topbar { padding-bottom: 14px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
  .brand-mark svg { width: 22px; height: 22px; }
  .board-col { max-width: max(430px, calc(100vh - 330px)); margin: 0 auto; }
  .board-actions { padding-top: 10px; }
  .foot { margin-top: 16px; }
}

@media (max-width: 760px) {
  .desktop-only { display: none !important; }
  .mobile-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    position: sticky;
    top: 8px;
    z-index: 6;
    background: rgba(252, 249, 242, .88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--line);
    border-radius: 13px;
    box-shadow: var(--shadow-sm);
  }
  .mobile-tab {
    flex: 1;
    min-height: 42px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
  }
  .mobile-tab.active {
    background: #FFFFFF;
    color: var(--ink);
    box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(35, 30, 22, .08);
  }
  .side[data-tab="game"] .coach-card,
  .side[data-tab="game"] .analysis-card { display: none; }
  .side[data-tab="coach"] .game-card,
  .side[data-tab="coach"] .analysis-card { display: none; }
  .side[data-tab="analysis"] .coach-card,
  .side[data-tab="analysis"] .game-card { display: none; }
  .online-grid { grid-template-columns: 1fr; }
  .board-actions .act { min-height: 44px; }
  .modal { padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px)); }
  .room-bar { flex-wrap: wrap; }
}

@media (max-width: 620px) {
  .toast {
    left: 50%;
    right: auto;
    transform: translate(-50%, 14px);
    max-width: calc(100vw - 28px);
  }
  .toast.show { transform: translate(-50%, 0); }
  .app { padding: 14px 12px 26px; padding-bottom: calc(26px + env(safe-area-inset-bottom, 0px)); }
  .topbar-actions .btn.icon-only { flex: 0 0 46px; }
  .account-name { display: none; }
  .account-chip { width: 44px; padding: 4px; justify-content: center; flex: none; }
  #btnLearn span { display: none; }
  #btnLearn { flex: 0 0 46px; padding: 0; justify-content: center; }
  .learn-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .learn-bar-actions { justify-content: stretch; }
  .learn-bar-actions .btn { flex: 1; }
  .learn-practice { flex-direction: column; align-items: flex-start; }
  .account-inline + .account-inline { margin-left: 0; margin-top: 8px; }
  .profile-stats { grid-template-columns: repeat(2, 1fr); }
  .avatar-grid { gap: 4px; }
  .avatar-opt { height: 34px; font-size: 17px; }
  h1 { font-size: 21px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
  .brand p { font-size: 9.5px; }
  .topbar { flex-wrap: wrap; gap: 10px; padding-bottom: 16px; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1; }
  .board-frame { padding: 8px; border-radius: 20px; }
  .eval-col { width: 14px; }
  .board-actions .act { flex: 1; justify-content: center; }
  .act span { display: inline; }
  .player-name { font-size: 13px; }
  .moves { max-height: 190px; }
  .modal { padding: 22px 18px; }
  .footer { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
