:root {
  /* Теплая классическая палитра "Шашечный Клуб": слоновая кость, орех, зеленое сукно и терракота */
  --bg-main: #f4ede1;
  --bg-card: #fffdf8;
  --bg-card-elevated: #f7f1e5;
  --border-color: #dcd0bc;
  --border-strong: #c4b397;

  --text-main: #2b1d12;
  --text-muted: #6e5a47;

  /* Благородное клубное сукно и терракота */
  --primary: #1e5e41;
  --primary-hover: #154730;
  --accent: #9e3b24;
  --accent-hover: #7f2d1a;
  --brass: #b07d2b;
  --danger: #b91c1c;

  /* Классическая деревянная доска (клен + махагон) */
  --board-border: #3d1e10;
  --cell-light: #f6e7cb;
  --cell-dark: #934b24;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Georgia', 'PT Serif', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, serif;
  background-color: var(--bg-main);
  background-image:
    radial-gradient(circle at 15% 15%, rgba(212, 185, 140, 0.35) 0%, transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(186, 152, 104, 0.28) 0%, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button,
input,
.online-pill,
.user-meta,
.stats-row,
.moves-list,
.clock-box {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, sans-serif;
}

.hidden {
  display: none !important;
}

/* ================= TOPBAR ================= */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.75rem;
  background: #2c1a10;
  color: #f9f3e8;
  border-bottom: 3px solid #b58942;
  box-shadow: 0 4px 16px rgba(43, 29, 18, 0.18);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background: #b58942;
  color: #2c1a10;
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.brand-title {
  font-weight: 700;
  font-size: 1.15rem;
  color: #fcf6ea;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: #d6c3a5;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.online-status {
  font-size: 0.84rem;
  color: #e6d7be;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.download-apk-link {
  text-decoration: none;
  white-space: nowrap;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: rgba(255, 250, 240, 0.1);
  border: 1px solid rgba(212, 163, 73, 0.45);
  padding: 0.32rem 0.8rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.user-chip:hover {
  background: rgba(255, 250, 240, 0.18);
}

.user-avatar {
  font-size: 1.35rem;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.user-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: #fff8eb;
}

.user-elo {
  font-size: 0.76rem;
  color: #f6c453;
  font-weight: 700;
}

/* ================= BUTTONS & INPUTS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1.15rem;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.16s ease;
  color: #fff;
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm {
  padding: 0.44rem 0.85rem;
  font-size: 0.82rem;
  border-radius: 8px;
}

.btn-lg {
  padding: 1.05rem 1.4rem;
  font-size: 1.05rem;
  border-radius: 14px;
  width: 100%;
}

.btn-block {
  width: 100%;
}

/* Изумрудное клубное сукно */
.btn-primary {
  background: linear-gradient(145deg, #246e4c, #184e35);
  border: 1px solid #133e2a;
  box-shadow: 0 4px 12px rgba(24, 78, 53, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-primary:hover {
  background: linear-gradient(145deg, #2b8059, #1e5e41);
}

/* Терракотово-бордовый акцент */
.btn-accent {
  background: linear-gradient(145deg, #b3442a, #8f311b);
  border: 1px solid #752512;
  box-shadow: 0 4px 10px rgba(143, 49, 27, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-accent:hover {
  background: linear-gradient(145deg, #c64d31, #9e3b24);
}

.btn-secondary {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: #ede3d0;
  border-color: #9e886b;
}

.btn-outline {
  background: #fffdf9;
  border: 1px solid var(--border-strong);
  color: var(--text-main);
}
.btn-outline:hover {
  background: #f3ead8;
}

.btn-danger {
  background: #fff1f0;
  border: 1px solid #e5a39e;
  color: #a8201a;
}
.btn-danger:hover {
  background: #b91c1c;
  border-color: #991b1b;
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  color: var(--text-main);
  background: rgba(110, 90, 71, 0.1);
}

input[type='text'],
input[type='password'] {
  background: #ffffff;
  border: 1.5px solid var(--border-strong);
  color: var(--text-main);
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type='text']:focus,
input[type='password']:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 94, 65, 0.15);
}

/* ================= MAIN CONTAINER & VIEWS ================= */
.main-container {
  flex: 1;
  max-width: 1260px;
  width: 100%;
  margin: 0 auto;
  padding: 1.35rem;
}

.view {
  display: none;
}
.view.active {
  display: block;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.4rem;
  box-shadow:
    0 8px 24px rgba(74, 49, 28, 0.08),
    0 2px 6px rgba(74, 49, 28, 0.05);
}

/* ================= LOBBY VIEW ================= */
.lobby-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 1.35rem;
}

.lobby-column {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.hero-badge {
  display: inline-block;
  background: #f7ebd2;
  color: #8a5612;
  border: 1px solid #dec089;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin-bottom: 0.65rem;
}

.hero-card h1 {
  font-size: 1.75rem;
  margin-bottom: 0.45rem;
  color: #2b180a;
}

.hero-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.2rem;
  line-height: 1.5;
}

.btn-icon {
  font-size: 1.75rem;
}
.btn-main-text {
  font-size: 1.1rem;
  font-weight: 800;
  text-align: left;
}
.btn-sub-text {
  font-size: 0.78rem;
  font-weight: 400;
  opacity: 0.92;
  text-align: left;
}

.searching-box {
  margin-top: 0.9rem;
  padding: 0.95rem 1.1rem;
  background: #edf7f2;
  border: 1.5px solid #96ccb3;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(30, 94, 65, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.searching-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  color: #154730;
}

.searching-actions {
  display: flex;
  gap: 0.5rem;
}

/* Friend section */
.friend-section,
.bot-section {
  margin-top: 1.35rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border-color);
}

.friend-section h3,
.bot-section h3 {
  font-size: 1.02rem;
  margin-bottom: 0.85rem;
  color: #3a2312;
}

.friend-controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.join-code-group {
  display: flex;
  flex: 1;
  gap: 0.5rem;
}

.join-code-group input {
  flex: 1;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.room-invite-box {
  margin-top: 0.85rem;
  padding: 1rem;
  background: #fdf6e9;
  border: 1.5px solid #dfc18d;
  border-radius: 12px;
}

.invite-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  margin-bottom: 0.55rem;
}

.room-code-badge {
  font-size: 1.15rem;
  color: #8f311b;
  background: #fff;
  border: 1px solid #d5b47c;
  padding: 0.2rem 0.7rem;
  border-radius: 6px;
  letter-spacing: 0.1em;
}

.invite-link-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.invite-link-row input {
  flex: 1;
  font-size: 0.84rem;
}

.invite-waiting-hint {
  font-size: 0.82rem;
  color: #6b4c2b;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* Bot section */
.bot-difficulty-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}

.bot-card {
  background: var(--bg-card-elevated);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.22rem;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s;
}

.bot-card:hover {
  border-color: #b89f7d;
}

.bot-card.selected {
  border-color: var(--primary);
  background: #ebf5f0;
  box-shadow: 0 3px 10px rgba(30, 94, 65, 0.12);
}

.bot-emoji {
  font-size: 1.55rem;
}

.bot-card small {
  color: #9e3b24;
  font-weight: 700;
}

.bot-color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.color-selector {
  display: flex;
  gap: 0.35rem;
}

.color-btn {
  background: var(--bg-card-elevated);
  border: 1.5px solid var(--border-color);
  color: var(--text-main);
  padding: 0.42rem 0.7rem;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.color-btn.selected {
  border-color: #9e3b24;
  background: #faece8;
  color: #7f2d1a;
}

/* Rules card */
.rules-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.75rem;
  color: #3a2312;
}

.rules-list {
  padding-left: 1.2rem;
  color: #4a3728;
  font-size: 0.88rem;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Profile card */
.profile-top {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  margin-bottom: 1rem;
}

.profile-avatar-lg {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  background: var(--bg-card-elevated);
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.profile-details {
  flex: 1;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-name-row h2 {
  font-size: 1.25rem;
  color: #2b180a;
}

.guest-tag {
  background: #ece2d0;
  color: #5c4732;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.admin-tag {
  background: #8f311b;
  color: #fff8eb;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.admin-mini-tag {
  background: #8f311b;
  color: #fff8eb;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.35rem;
}

.banned-tag {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #f87171;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.35rem;
}

.lb-item.banned-row {
  background: #fff5f5;
  border-color: #f5b8b8;
}

.admin-actions {
  display: inline-flex;
  gap: 0.3rem;
  margin-left: 0.35rem;
}

.lb-name-block {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.lb-name-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.btn-accept-green {
  background: #16a34a;
  border: 1px solid #15803d;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.35);
}

.btn-accept-green:hover {
  background: #15803d;
}

.offer-sent-tag {
  font-size: 0.72rem;
  color: #8a5209;
  background: #fdf3dc;
  border: 1px solid #e2c07d;
  padding: 0.12rem 0.45rem;
  border-radius: 5px;
}

/* Компактная карточка Новая партия справа */
.compact-hero-card {
  padding: 1.05rem 1.2rem;
}

.compact-section {
  margin-top: 0.85rem !important;
  padding-top: 0.8rem !important;
}

.compact-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.compact-bots {
  gap: 0.45rem;
  margin-bottom: 0.6rem;
}

.compact-bots .bot-card {
  padding: 0.42rem 0.5rem;
  border-radius: 8px;
}

/* Управление игроками внутри меню Настройки для суперадмина */
.admin-users-section {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-users-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 210px;
  overflow-y: auto;
}

.admin-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.65rem;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.85rem;
}

.admin-user-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.rank-badge {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.84rem;
  font-weight: 700;
  color: #1e5e41 !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.elo-big-box {
  text-align: right;
  background: linear-gradient(135deg, #fdf5e6, #f7e6c4);
  border: 1.5px solid #d9b675;
  padding: 0.5rem 0.9rem;
  border-radius: 12px;
}

.elo-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #8a5209;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.elo-label {
  font-size: 0.72rem;
  color: #755835;
  font-weight: 600;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.95rem;
}

.stat-item {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.6rem;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.stat-item strong {
  font-size: 1.18rem;
}
.stat-item span {
  font-size: 0.74rem;
  color: var(--text-muted);
}
.stat-item.win strong { color: #196b45; }
.stat-item.draw strong { color: #8a5612; }
.stat-item.loss strong { color: #b91c1c; }

.guest-upgrade-banner {
  background: #fbf3e4;
  border: 1px solid #d4b882;
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: #593e1c;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.quick-user-buttons {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.preset-users-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

/* Leaderboard */
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 360px;
  overflow-y: auto;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.lb-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.58rem 0.8rem;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.88rem;
}

.lb-item.me {
  border: 1.5px solid var(--primary);
  background: #ebf5f0;
}

.lb-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.lb-rank {
  width: 26px;
  font-weight: 800;
  color: var(--text-muted);
}
.lb-rank.top-1 { color: #b87b14; }
.lb-rank.top-2 { color: #576375; }
.lb-rank.top-3 { color: #9c4a1a; }

.lb-elo {
  font-weight: 800;
  color: #8a5209;
}

/* ================= GAME VIEW & CHECKERS BOARD ================= */
.game-layout {
  display: grid;
  grid-template-columns: minmax(320px, 560px) 1fr;
  gap: 1.5rem;
  align-items: start;
  justify-content: center;
}

.board-area {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  padding: 0.65rem 1rem;
  border-radius: 12px;
  box-shadow: 0 3px 10px rgba(74, 49, 28, 0.06);
}

.player-bar.active-turn {
  border-color: var(--primary);
  background: #f2faf6;
  box-shadow: 0 0 0 3px rgba(30, 94, 65, 0.14);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.player-avatar {
  font-size: 1.65rem;
}

.player-name-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.player-elo-badge {
  background: #f5e6c8;
  color: #7d4b0c;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.12rem 0.5rem;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.captured-counters {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.clock-box {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.35rem;
  font-weight: 800;
  background: #2c1a10;
  color: #fdf5e6;
  border: 2px solid #96703c;
  padding: 0.32rem 0.75rem;
  border-radius: 8px;
}

.clock-box.low-time {
  background: #7f1d1d;
  color: #fecaca;
  border-color: #ef4444;
  animation: pulseDot 1s infinite;
}

.turn-status-banner {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
  background: #efe6d5;
  border: 1px solid #d4c3a3;
  color: #3a2410;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.turn-status-banner.must-capture {
  background: #fce8e6;
  border-color: #e09189;
  color: #9e2318;
}

/* Шашечная доска (Орех + Клен + Латунный кант) */
.board-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 560px;
  margin: 0 auto;
}

.board-outer {
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #4a2511, #2e1508);
  padding: 14px;
  border-radius: 14px;
  border: 2px solid #230f05;
  box-shadow:
    0 18px 36px rgba(43, 24, 10, 0.35),
    inset 0 2px 3px rgba(255, 224, 178, 0.22);
}

.board-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 3px solid #c59b5f;
  border-radius: 4px;
  overflow: hidden;
  user-select: none;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell.light {
  background: var(--cell-light);
}

.cell.dark {
  background: var(--cell-dark);
  cursor: pointer;
}

.cell.selected {
  background: linear-gradient(135deg, #d99b26, #b87914) !important;
}

.cell.last-move {
  box-shadow: inset 0 0 0 4px rgba(250, 204, 21, 0.8);
}

.cell.must-capture-piece {
  box-shadow: inset 0 0 0 4px #ef4444;
}

/* Координаты на краях доски */
.coord-rank {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 0.66rem;
  font-weight: 800;
  opacity: 0.8;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.coord-file {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.66rem;
  font-weight: 800;
  opacity: 0.8;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.cell.light .coord-rank,
.cell.light .coord-file {
  color: #7c4220;
}

.cell.dark .coord-rank,
.cell.dark .coord-file {
  color: #f6e7cb;
}

/* Шашки (Точеная слоновая кость и Глубокое эбеновое/вишневое дерево) */
.piece {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  z-index: 2;
}

.piece.white {
  background: radial-gradient(circle at 35% 30%, #fffdf7, #f3e5c8 62%, #d8c298 100%);
  border: 2px solid #b59b6d;
  box-shadow:
    0 5px 0 #9c8153,
    0 7px 12px rgba(28, 14, 5, 0.48),
    inset 0 2px 4px rgba(255, 255, 255, 0.85);
}

.piece.black {
  background: radial-gradient(circle at 35% 30%, #5c2c20, #2e130c 65%, #170804 100%);
  border: 2px solid #421d14;
  box-shadow:
    0 5px 0 #120603,
    0 7px 12px rgba(20, 8, 3, 0.65),
    inset 0 2px 3px rgba(255, 195, 160, 0.22);
}

/* Внутренний точеный ободок классической шашки */
.piece.white::after {
  content: '';
  width: 66%;
  height: 66%;
  border-radius: 50%;
  border: 2px solid rgba(156, 129, 83, 0.45);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

.piece.black::after {
  content: '';
  width: 66%;
  height: 66%;
  border-radius: 50%;
  border: 2px solid rgba(180, 110, 85, 0.35);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* Дамка (золотая корона) */
.piece.king::before {
  content: '♛';
  position: absolute;
  font-size: 1.38rem;
  color: #d97706;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
  z-index: 3;
}

.piece.black.king::before {
  color: #fbbf24;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

.piece.selectable:hover {
  transform: translateY(-3px) scale(1.04);
}

/* Подсветка доступного поля для хода / прыжка */
.move-hint {
  width: 34%;
  height: 34%;
  border-radius: 50%;
  background: rgba(46, 204, 113, 0.92);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 3;
}

.move-hint.capture-hint {
  width: 44%;
  height: 44%;
  background: rgba(220, 38, 38, 0.94);
  box-shadow: 0 0 12px rgba(220, 38, 38, 0.9);
  border: 2.5px solid #fff;
}

.move-hint.intermediate-hint {
  width: 32%;
  height: 32%;
  background: rgba(245, 158, 11, 0.95);
  border: 2px dashed #fff;
}

/* ================= GAME SIDEBAR ================= */
.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.game-meta-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.game-mode-tag {
  font-size: 0.82rem;
  font-weight: 700;
  color: #184e35;
  background: #e6f4ed;
  border: 1px solid #a9d8c0;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.board-tools {
  display: flex;
  gap: 0.35rem;
}

.pause-alert {
  background: #fef3c7;
  border: 1.5px solid #d97706;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #78350f;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.draw-offer-alert {
  background: #fdf4e3;
  border: 1.5px solid #dfbe7f;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: #6b4710;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.draw-offer-actions {
  display: flex;
  gap: 0.4rem;
}

.action-buttons-row,
.post-game-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.action-buttons-row.three-cols {
  grid-template-columns: repeat(3, 1fr);
}

/* Moves history */
.moves-card h4,
.chat-card h4 {
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
  color: #3a2312;
}

.chat-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.chat-header-row h4 {
  margin-bottom: 0;
}

.moves-list {
  max-height: 170px;
  overflow-y: auto;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-family: monospace;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.move-pair {
  display: grid;
  grid-template-columns: 36px 1fr 1fr;
  padding: 0.18rem 0;
  border-bottom: 1px solid rgba(110, 90, 71, 0.12);
}

.move-num {
  color: var(--text-muted);
}

.move-capture {
  color: #b91c1c;
  font-weight: 700;
}

/* Chat */
.chat-messages {
  height: 175px;
  overflow-y: auto;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.65rem;
  margin-bottom: 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.chat-msg {
  line-height: 1.35;
  word-break: break-word;
}

.chat-msg strong {
  color: #8f311b;
}

.chat-msg.my-msg strong {
  color: #184e35;
}

.chat-msg.system-msg {
  color: #6e5a47;
  font-style: italic;
  background: rgba(181, 137, 66, 0.12);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
}

.chat-time {
  color: #9a8570;
  font-size: 0.72rem;
  margin-right: 0.25rem;
}

.chat-msg.bot-msg {
  background: #eef4ee;
  border-left: 3px solid #1e5e41;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
}

.chat-msg.bot-msg strong {
  color: #1e5e41;
}

.bot-text {
  white-space: pre-wrap;
}

.stats-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
  font-size: 0.85rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.lb-item.selectable {
  cursor: pointer;
}

.lb-item.stat-selected {
  outline: 2px solid var(--accent);
}

.quick-emojis {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
}

.emoji-btn {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 0.28rem 0.58rem;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}
.emoji-btn:hover {
  background: #ede1cc;
  border-color: var(--primary);
}

.chat-form {
  display: flex;
  gap: 0.45rem;
}

.chat-form input {
  flex: 1;
  padding: 0.45rem 0.75rem;
}

/* ================= MODALS ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(38, 23, 12, 0.62);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-card {
  background: var(--bg-card);
  border: 2px solid var(--border-strong);
  border-radius: 18px;
  max-width: 440px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(38, 23, 12, 0.35);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #ebe1cf;
  padding: 0.25rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.auth-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
}

.auth-tab.active {
  background: #fffdf9;
  color: var(--text-main);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.auth-note {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.auth-form label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

.avatar-picker {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.av-option {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid var(--border-color);
  background: var(--bg-card-elevated);
  font-size: 1.3rem;
  cursor: pointer;
}

.av-option.selected {
  border-color: var(--primary);
  background: #e6f4ed;
}

.form-error {
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #f87171;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.82rem;
}

.modal-footer-guest {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

/* Result modal */
.result-modal-card {
  text-align: center;
}

.result-icon {
  font-size: 3.4rem;
  margin-bottom: 0.4rem;
}

.elo-change-box {
  margin: 1.25rem 0;
  padding: 1rem;
  background: var(--bg-card-elevated);
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.elo-change-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.elo-change-numbers {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font-size: 1.4rem;
}

.elo-delta {
  font-size: 0.95rem;
  font-weight: 800;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
}
.elo-delta.positive {
  background: #dcfce7;
  color: #166534;
}
.elo-delta.negative {
  background: #fee2e2;
  color: #991b1b;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.8rem;
}

.rematch-hint {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
}

.toast {
  background: #2c1a10;
  border: 1.5px solid #b58942;
  color: #fff8eb;
  padding: 0.75rem 1.05rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  box-shadow: 0 8px 20px rgba(43, 24, 10, 0.35);
}

/* ================= ABOUT SECTION & FOOTER ================= */
.btn-icon-gear {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(212, 163, 73, 0.45);
  background: rgba(255, 250, 240, 0.1);
  color: #f3e8d2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.2s;
}

.btn-icon-gear:hover {
  background: rgba(255, 250, 240, 0.22);
  transform: rotate(30deg);
}

.btn-xs {
  padding: 0.22rem 0.55rem;
  font-size: 0.74rem;
  border-radius: 6px;
}

.sub-counter {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Индикаторы онлайн / офлайн (зеленый и красный кружки) */
.status-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.status-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.online {
  background-color: #16a34a;
  border: 1.5px solid #14532d;
}

.status-dot.offline {
  background-color: #dc2626;
  border: 1.5px solid #7f1d1d;
}

.filter-tabs {
  display: flex;
  gap: 0.25rem;
  background: #ebe1cf;
  padding: 0.2rem;
  border-radius: 8px;
}

.filter-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}

.filter-tab.active {
  background: #fffdf9;
  color: var(--text-main);
}

.lb-right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.lb-rank-sub {
  color: #6e5a47;
  margin-left: 6px;
}

.lb-record {
  color: #856f5b;
  font-size: 0.78rem;
}

/* Список текущих партий (наблюдение на главном экране) */
.live-games-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 280px;
  overflow-y: auto;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.live-game-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.live-game-players {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.live-pair {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.piece-mini {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.piece-mini.white {
  background: #fffdf7;
  border: 1.5px solid #8c734b;
}

.piece-mini.black {
  background: #2e130c;
  border: 1.5px solid #170804;
}

.elo-mini {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.vs-sep {
  color: var(--text-muted);
  margin: 0 0.15rem;
}

.live-meta {
  display: flex;
  gap: 0.85rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* Режим наблюдателя в партии */
.spectators-badge {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.spectator-controls {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.spectator-note {
  font-size: 0.82rem;
  color: #6b4710;
  background: #fdf4e3;
  border: 1px solid #dfbe7f;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Модальное окно настроек и правил */
.modal-card-wide {
  max-width: 540px;
}

.settings-tabs {
  grid-template-columns: repeat(3, 1fr);
}

.settings-pane {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.admin-setting-row {
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1.5px solid #e5a39e;
}

.challenge-text {
  margin: 0.85rem 0 0.4rem;
  font-size: 0.95rem;
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.hero-card h2 {
  font-size: 1.35rem;
  margin-bottom: 0.85rem;
  color: #2b180a;
}

.version-badge {
  background: #f5e6c8;
  color: #7d4b0c;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.about-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.9rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.developer-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card-elevated);
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.dev-label {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.dev-name {
  font-size: 0.96rem;
  color: #2b180a;
}

.about-modal-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.about-logo-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.about-logo-row h4 {
  font-size: 1.12rem;
  margin-bottom: 0.2rem;
}

.about-modal-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.developer-highlight {
  background: linear-gradient(135deg, #fdf5e6, #f7e6c4);
  border: 1.5px solid #d9b675;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.92rem;
  color: #3a2312;
}

.developer-highlight strong {
  font-size: 1.05rem;
  color: #7f2d1a;
}

.app-footer {
  text-align: center;
  padding: 0.9rem 1rem;
  border-top: 1px solid var(--border-color);
  background: rgba(255, 253, 248, 0.7);
  color: var(--text-muted);
  font-size: 0.84rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}

.app-footer strong {
  color: var(--text-main);
}

/* ================= RESPONSIVE (MOBILE READY) ================= */
@media (max-width: 920px) {
  .lobby-grid,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .main-container {
    padding: 0.75rem;
  }

  .topbar {
    padding: 0.6rem 0.85rem;
  }

  .online-pill {
    display: none;
  }

  .board-outer {
    padding: 8px;
  }
}
