/* ══════════════════════════════════════════════════════════════
   Chess Home — Стили
   Тёмная элегантная тема с золотыми акцентами
   ══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=JetBrains+Mono:wght@400;500&family=Nunito:wght@400;500;600;700&display=swap');

:root {
  --bg-primary: #0e0f13;
  --bg-secondary: #161820;
  --bg-card: #1e2028;
  --bg-hover: #262830;
  --border: #2e3040;
  --border-light: #3a3d50;
  --text-primary: #e8e9f0;
  --text-secondary: #8a8ea8;
  --text-muted: #5a5e78;
  --accent: #c9a84c;
  --accent-dark: #a07830;
  --accent-light: #e8c870;
  --accent-glow: rgba(201, 168, 76, 0.15);
  --green: #4caf72;
  --red: #e05555;
  --blue: #5588e0;
  --purple: #8855e0;

  --board-light: #f0d9b5;
  --board-dark: #b58863;
  --board-highlight: rgba(201, 168, 76, 0.6);
  --board-move: rgba(201, 168, 76, 0.35);
  --board-check: rgba(220, 60, 60, 0.7);
  --board-legal: rgba(20, 20, 20, 0.25);

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-accent: 0 0 30px rgba(201, 168, 76, 0.2);

  --sidebar-w: 280px;
  --header-h: 60px;

  --font-display: 'Playfair Display', serif;
  --font-body: 'Nunito', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── SCROLLBAR ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── SELECTION ────────────────────────────────────────────────── */
::selection { background: var(--accent); color: #000; }

/* ── HEADER ───────────────────────────────────────────────────── */
#header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: rgba(14,15,19,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px;
  z-index: 1000; gap: 16px;
}

.logo {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  display: flex; align-items: center; gap: 8px;
  letter-spacing: 0.5px;
}

.logo-icon { font-size: 26px; }

.nav-links {
  display: flex; gap: 4px; margin-left: 16px;
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 14px; border-radius: 8px;
  font-size: 14px; font-weight: 600;
  transition: all 0.2s;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-links a.active { color: var(--accent); }

.header-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px;
}

.online-badge {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 12px;
  font-size: 13px; color: var(--text-secondary);
}

.online-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── BUTTONS ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 20px; border-radius: 8px; border: none;
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.2s; text-decoration: none;
}

.btn-primary {
  background: var(--accent); color: #0e0f13;
  box-shadow: 0 2px 12px rgba(201,168,76,0.3);
}
.btn-primary:hover {
  background: var(--accent-light);
  box-shadow: 0 4px 20px rgba(201,168,76,0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-light); }

.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-light); }

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #c04040; }

.btn-sm { padding: 5px 14px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── PAGES ────────────────────────────────────────────────────── */
#app {
  padding-top: var(--header-h);
  min-height: 100vh;
}

.page { display: none; }
.page.active { display: block; }

/* ── HOME PAGE ────────────────────────────────────────────────── */
#page-home {
  display: none;
}
#page-home.active {
  display: flex; flex-direction: column; align-items: center;
}

.hero {
  width: 100%; max-width: 1200px; margin: 0 auto;
  padding: 80px 24px 60px;
  display: flex; align-items: center; gap: 60px;
}

.hero-text { flex: 1; }

.hero-eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: 3px;
  color: var(--accent); text-transform: uppercase; margin-bottom: 16px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1.1; margin-bottom: 20px;
  color: var(--text-primary);
}

.hero-title .accent { color: var(--accent); }

.hero-subtitle {
  font-size: 17px; color: var(--text-secondary); line-height: 1.7;
  margin-bottom: 36px; max-width: 480px;
}

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.hero-visual { flex: 1; max-width: 420px; }

.mini-board-preview {
  width: 100%; aspect-ratio: 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow), var(--shadow-accent);
  border: 2px solid var(--accent-dark);
}

#hero-chess-board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}

/* ── FEATURES ────────────────────────────────────────────────── */
.features {
  width: 100%; max-width: 1200px; margin: 0 auto;
  padding: 60px 24px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 36px; text-align: center;
  margin-bottom: 48px;
  color: var(--text-primary);
}

.section-title span { color: var(--accent); }

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: all 0.3s;
}

.feature-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-accent);
  transform: translateY(-2px);
}

.feature-icon {
  font-size: 32px; margin-bottom: 16px;
  display: block;
}

.feature-card h3 {
  font-size: 18px; font-weight: 700; margin-bottom: 8px;
}

.feature-card p { color: var(--text-secondary); font-size: 14px; line-height: 1.6; }

/* ── GAME MODES ─────────────────────────────────────────────── */
.game-modes {
  width: 100%; max-width: 1200px; margin: 0 auto;
  padding: 40px 24px 80px;
}

.modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.mode-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  position: relative; overflow: hidden;
}

.mode-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  opacity: 0; transition: opacity 0.25s;
}

.mode-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.mode-card:hover::before { opacity: 1; }

.mode-icon { font-size: 36px; margin-bottom: 10px; }
.mode-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.mode-card p { font-size: 12px; color: var(--text-secondary); }

/* ── LOBBY ───────────────────────────────────────────────────── */
#page-lobby {
  padding: 24px;
  max-width: 1100px; margin: 0 auto;
}

.lobby-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  margin-top: 20px;
}

.lobby-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.panel-title {
  font-size: 15px; font-weight: 700; color: var(--accent);
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}

.challenge-list { display: flex; flex-direction: column; gap: 10px; }

.challenge-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  transition: border-color 0.2s;
}

.challenge-item:hover { border-color: var(--border-light); }

.challenge-info { flex: 1; }
.challenge-name { font-weight: 600; font-size: 14px; }
.challenge-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.time-control-select {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px;
}

.tc-btn {
  padding: 6px 14px; border-radius: 6px; font-size: 13px;
  font-weight: 600; cursor: pointer; border: 1px solid var(--border);
  background: var(--bg-secondary); color: var(--text-secondary);
  transition: all 0.2s;
}
.tc-btn.selected {
  background: var(--accent); color: #000; border-color: var(--accent);
}

/* ── CHESS BOARD ─────────────────────────────────────────────── */
#page-game {
  padding: 16px;
  display: none;
}
#page-game.active {
  display: flex; justify-content: center;
}

.game-layout {
  display: flex; gap: 20px; align-items: flex-start;
  max-width: 1000px; width: 100%;
}

.board-area { flex: none; }

.player-info {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin: 6px 0;
  background: var(--bg-card); border-radius: var(--radius);
  border: 1px solid var(--border); min-width: 400px;
}

.player-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #000; flex-shrink: 0;
}

.player-name { font-weight: 700; font-size: 14px; }
.player-rating { font-size: 12px; color: var(--text-secondary); }

.player-clock {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 22px; font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-secondary);
  padding: 4px 12px; border-radius: 6px;
  min-width: 80px; text-align: center;
}

.player-clock.active { color: var(--accent); }
.player-clock.low { color: var(--red); animation: flash 1s infinite; }

@keyframes flash { 0%,100% { opacity:1 } 50% { opacity:0.5 } }

.captured-pieces {
  display: flex; flex-wrap: wrap; gap: 2px;
  font-size: 18px;
  flex: 1;
}

.board-wrapper {
  position: relative;
  user-select: none;
}

.board-coords-file {
  display: flex; padding: 0 24px; margin-top: 4px;
}
.board-coords-rank {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column;
  height: 100%;
}

.coord-label {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-muted); font-weight: 500;
}

.coords-file { display: flex; padding: 0 24px; }
.coord-file { flex: 1; text-align: center; }
.coords-rank { display: flex; flex-direction: column; width: 20px; }
.coord-rank { flex: 1; display: flex; align-items: center; justify-content: center; }

#chess-board {
  width: min(480px, calc(100vw - 200px));
  height: min(480px, calc(100vw - 200px));
  display: grid; grid-template-columns: repeat(8, 1fr);
  border: 3px solid var(--accent-dark);
  border-radius: 4px;
  box-shadow: var(--shadow), 0 0 40px rgba(0,0,0,0.5);
  overflow: hidden;
  grid-template-rows: repeat(8, 1fr);
}

.square {
  display: flex; align-items: center; justify-content: center;
  position: relative; cursor: pointer;
  transition: background-color 0.1s;
}

.square.light { background: var(--board-light); }
.square.dark { background: var(--board-dark); }

.square.selected { background: var(--board-highlight) !important; }
.square.legal-move::after {
  content: '';
  position: absolute;
  width: 30%; height: 30%;
  border-radius: 50%;
  background: var(--board-legal);
}
.square.legal-capture::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 0;
  border: 4px solid var(--board-legal);
  pointer-events: none;
}
.square.last-move { background: var(--board-move) !important; }
.square.in-check { background: var(--board-check) !important; }

.piece {
  width: 88%; height: 88%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0; /* use SVG/image */
  position: relative; z-index: 1;
  transition: transform 0.1s;
  cursor: grab;
}

.piece:active { cursor: grabbing; transform: scale(1.15); }

.piece img {
  width: 100%; height: 100%;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

/* Piece dragging */
.piece-dragging {
  position: fixed; pointer-events: none; z-index: 9999;
  transform: translate(-50%, -50%) scale(1.2);
}

/* ── GAME PANEL ──────────────────────────────────────────────── */
.game-panel {
  flex: 1;
  display: flex; flex-direction: column; gap: 12px;
  min-width: 200px; max-width: 260px;
}

.moves-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex: 1;
  overflow-y: auto; max-height: 320px;
}

.moves-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-mono); font-size: 13px;
}

.moves-table td { padding: 5px 10px; }
.moves-table td:first-child { color: var(--text-muted); width: 30px; }
.move-cell { cursor: pointer; border-radius: 4px; }
.move-cell:hover { background: var(--bg-hover); color: var(--accent); }
.move-cell.current { background: var(--accent); color: #000; }

.game-controls {
  display: flex; flex-direction: column; gap: 8px;
}

.game-actions {
  display: flex; gap: 8px; justify-content: center;
}

.eval-bar-container {
  width: 12px; align-self: stretch;
  background: var(--bg-card);
  border-radius: 4px; overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}

.eval-bar-fill {
  width: 100%;
  background: var(--text-primary);
  transition: height 0.5s ease;
  position: absolute; bottom: 0;
}

/* ── ANALYSIS PAGE ───────────────────────────────────────────── */
#page-analysis {
  padding: 16px;
  max-width: 1100px; margin: 0 auto;
}

.analysis-layout {
  display: flex; gap: 20px;
  margin-top: 16px; align-items: flex-start;
}

.engine-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  flex: 1;
}

.engine-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; margin-bottom: 12px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}

.engine-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
}
.engine-dot.ready { background: var(--green); box-shadow: 0 0 6px var(--green); }
.engine-dot.thinking { background: var(--accent); animation: pulse 0.8s infinite; }

.eval-score {
  font-family: var(--font-mono); font-size: 28px; font-weight: 500;
  text-align: center; margin-bottom: 12px;
  color: var(--accent);
}

.eval-score.negative { color: var(--text-secondary); }

.depth-line {
  font-size: 11px; color: var(--text-muted); text-align: center; margin-bottom: 12px;
}

.pv-line {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text-secondary); line-height: 1.8;
  background: var(--bg-secondary); border-radius: 6px;
  padding: 8px 10px; word-break: break-all;
}

.best-move {
  margin-top: 12px;
  font-size: 13px;
}

.best-move span {
  font-family: var(--font-mono); font-weight: 600;
  color: var(--accent); font-size: 16px;
}

/* ── EDITOR PAGE ─────────────────────────────────────────────── */
#page-editor {
  padding: 16px;
  max-width: 1100px; margin: 0 auto;
}

.editor-layout {
  display: flex; gap: 20px; margin-top: 16px;
  align-items: flex-start;
}

.piece-palette {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 160px;
}

.palette-section { margin-bottom: 16px; }
.palette-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 8px;
}

.palette-pieces {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}

.palette-piece {
  aspect-ratio: 1;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s;
}

.palette-piece:hover { border-color: var(--accent); background: var(--bg-hover); }
.palette-piece.selected { border-color: var(--accent); background: var(--accent-glow); }
.palette-piece img { width: 80%; height: 80%; }

.eraser-btn {
  width: 100%; padding: 8px;
  background: var(--bg-secondary); border: 2px solid var(--border);
  border-radius: 6px; color: var(--text-secondary);
  cursor: pointer; font-size: 13px; font-weight: 600;
  transition: all 0.2s; margin-top: 6px;
}
.eraser-btn:hover { border-color: var(--red); color: var(--red); }
.eraser-btn.selected { border-color: var(--red); color: var(--red); background: rgba(224,85,85,0.1); }

.editor-options {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}

/* ── MODALS ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px; max-width: 440px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 24px; margin-bottom: 24px; color: var(--text-primary);
}

.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; color: var(--text-muted);
  font-size: 20px; cursor: pointer; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: all 0.2s;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── FORMS ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
}

.form-input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary);
  font-family: var(--font-body); font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
}

.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-muted); }

.form-error {
  color: var(--red); font-size: 12px; margin-top: 6px;
}

.form-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 24px;
}

/* ── USER PANEL ──────────────────────────────────────────────── */
.user-menu {
  position: relative;
}

.user-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px;
  cursor: pointer; color: var(--text-primary); transition: all 0.2s;
}
.user-btn:hover { border-color: var(--border-light); }

.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px;
  min-width: 180px; z-index: 100;
  box-shadow: var(--shadow);
  display: none;
}
.user-dropdown.open { display: block; }

.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 6px;
  cursor: pointer; font-size: 14px; color: var(--text-secondary);
  transition: all 0.15s; text-decoration: none;
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-item.danger:hover { color: var(--red); }

/* ── SETTINGS PAGE ───────────────────────────────────────────── */
#page-settings, #page-privacy, #page-terms, #page-about {
  padding: 40px 24px;
  max-width: 800px; margin: 0 auto;
}

.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px; margin-bottom: 20px;
}

.settings-title {
  font-family: var(--font-display);
  font-size: 20px; margin-bottom: 20px;
  color: var(--text-primary);
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}

.settings-row {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }

.settings-label { flex: 1; }
.settings-label-name { font-weight: 600; font-size: 14px; }
.settings-label-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* Toggle switch */
.toggle {
  position: relative; width: 44px; height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 12px; transition: all 0.3s; cursor: pointer;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-muted);
  left: 2px; top: 2px; transition: all 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--accent-glow); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); background: var(--accent); }

/* Color picker rows */
.color-options { display: flex; gap: 8px; }
.color-option {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: all 0.2s;
}
.color-option.selected { border-color: var(--accent); transform: scale(1.15); }

/* ── TOAST ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9000; display: flex; flex-direction: column; gap: 8px;
}

.toast {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 18px;
  font-size: 14px; color: var(--text-primary);
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  display: flex; align-items: center; gap: 10px;
  min-width: 260px;
}

.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
.toast.info { border-color: var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── SEARCH ──────────────────────────────────────────────────── */
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); z-index: 200;
  box-shadow: var(--shadow);
  max-height: 300px; overflow-y: auto;
}

.search-result-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer; transition: background 0.15s;
}
.search-result-item:hover { background: var(--bg-hover); }

.result-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #000;
}

.result-name { font-weight: 600; font-size: 14px; }
.result-rating { font-size: 12px; color: var(--text-secondary); }
.result-online { color: var(--green); font-size: 11px; }

/* ── LEGAL PAGES ─────────────────────────────────────────────── */
.legal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px;
  line-height: 1.8;
}

.legal-content h1 {
  font-family: var(--font-display); font-size: 32px;
  color: var(--accent); margin-bottom: 8px;
}

.legal-content .last-updated {
  color: var(--text-muted); font-size: 13px; margin-bottom: 32px;
}

.legal-content h2 {
  font-size: 18px; font-weight: 700; margin: 28px 0 12px;
  color: var(--text-primary);
}

.legal-content p { color: var(--text-secondary); margin-bottom: 12px; }
.legal-content ul { padding-left: 20px; color: var(--text-secondary); }
.legal-content li { margin-bottom: 6px; }

/* ── PROMO DIALOG ─────────────────────────────────────────────── */
.promo-modal { text-align: center; }
.promo-icon { font-size: 48px; margin-bottom: 12px; }
.promo-pieces {
  display: flex; justify-content: center; gap: 12px; margin-top: 20px;
}
.promo-piece-btn {
  width: 60px; height: 60px; border-radius: 8px;
  border: 2px solid var(--border); background: var(--bg-secondary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.promo-piece-btn:hover { border-color: var(--accent); background: var(--accent-glow); }
.promo-piece-btn img { width: 80%; }

/* ── CHAT ─────────────────────────────────────────────────────── */
.game-chat-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column; height: 180px;
}

.chat-messages {
  flex: 1; overflow-y: auto; padding: 10px;
  font-size: 13px;
}

.chat-msg { margin-bottom: 6px; }
.chat-msg-name { font-weight: 700; color: var(--accent); }
.chat-msg-text { color: var(--text-secondary); }

.chat-input-row {
  display: flex; gap: 6px; padding: 8px;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 10px;
  color: var(--text-primary); font-size: 13px; outline: none;
}
.chat-input:focus { border-color: var(--accent); }

/* ── PAGE HEADER ──────────────────────────────────────────────── */
.page-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 28px; color: var(--text-primary);
  display: flex; align-items: center; gap: 12px;
}

.page-header p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* ── RESPONSIVE ───────────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════
   МОБИЛЬНАЯ АДАПТАЦИЯ
   ══════════════════════════════════════════════════════════════ */

/* ── Бургер-кнопка (скрыта на десктопе) ──────────────────── */
.burger-btn {
  display: none;
  flex-direction: column; justify-content: center; gap: 5px;
  width: 36px; height: 36px;
  background: none; border: none; cursor: pointer; padding: 4px;
  border-radius: 8px; transition: background 0.2s;
}
.burger-btn:hover { background: var(--bg-hover); }
.burger-btn span {
  display: block; width: 22px; height: 2px;
  background: var(--text-primary); border-radius: 2px;
  transition: all 0.25s;
}
.burger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger-btn.open span:nth-child(2) { opacity: 0; }
.burger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Мобильное меню ──────────────────────────────────────── */
.mobile-nav {
  display: none;
  position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0;
  background: rgba(14,15,19,0.98);
  backdrop-filter: blur(20px);
  z-index: 999;
  flex-direction: column;
  padding: 24px 20px;
  overflow-y: auto;
  transform: translateY(-10px);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.mobile-nav.open {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}
.mobile-nav-item {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 12px;
  border-radius: 10px;
  font-size: 18px; font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s;
  border-bottom: 1px solid var(--border);
}
.mobile-nav-item:last-child { border-bottom: none; }
.mobile-nav-item:hover, .mobile-nav-item.active {
  background: var(--bg-hover);
  color: var(--accent);
}
.mobile-nav-icon { font-size: 22px; width: 28px; text-align: center; }
.mobile-nav-divider { height: 1px; background: var(--border); margin: 8px 0; }
.mobile-nav-user {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 12px; margin-bottom: 8px;
}
.mobile-nav-footer {
  margin-top: auto; padding-top: 16px;
  display: flex; flex-direction: column; gap: 8px;
}

/* ── Планшет (768px–1024px) ──────────────────────────────── */
@media (max-width: 1024px) {
  .online-badge { display: none; }
}

/* ── Мобильный (≤768px) ──────────────────────────────────── */
@media (max-width: 768px) {

  /* Header */
  #header { padding: 0 16px; gap: 10px; }
  .logo-icon { font-size: 22px; }
  .logo { font-size: 19px; }
  .nav-links { display: none; }
  .burger-btn { display: flex; }
  .online-badge { display: none; }
  .header-right { gap: 6px; }

  /* Скрываем рейтинг-пилюлю в шапке на маленьких экранах */
  .header-right .rating-pill { display: none; }
  .user-btn { padding: 4px 8px; gap: 6px; }

  /* Hero */
  .hero { flex-direction: column; padding: 32px 16px 24px; gap: 24px; text-align: center; }
  .hero-visual { max-width: 260px; margin: 0 auto; }
  .hero h1 { font-size: 28px !important; }
  .hero-subtitle { font-size: 14px !important; }
  .hero-buttons { justify-content: center; flex-wrap: wrap; }

  /* Доска */
  #chess-board {
    width: min(90vw, 420px) !important;
    height: min(90vw, 420px) !important;
  }
  .player-info {
    min-width: unset;
    width: min(90vw, 420px);
    flex-wrap: wrap;
  }
  .player-clock { font-size: 20px !important; }
  .board-wrapper { width: min(90vw, 420px); }

  /* Игра */
  .game-layout { flex-direction: column; align-items: center; gap: 12px; }
  .board-area { width: 100%; display: flex; flex-direction: column; align-items: center; }
  .game-panel {
    max-width: 100%;
    width: min(90vw, 420px);
    order: 2;
  }

  /* Список ходов — компактнее */
  .moves-list { max-height: 120px; }
  .moves-table td { font-size: 12px; padding: 2px 4px; }

  /* Кнопки под доской */
  .game-actions { flex-wrap: wrap; gap: 6px; }
  .game-actions .btn { font-size: 12px; padding: 6px 10px; }

  /* Лобби */
  .lobby-layout { grid-template-columns: 1fr; gap: 16px; }
  .lobby-panel { padding: 16px; }
  .tc-options { gap: 6px; }
  .tc-btn { padding: 6px 12px; font-size: 13px; }

  /* Анализ / Редактор */
  .analysis-layout, .editor-layout { flex-direction: column; align-items: center; }
  .analysis-panel, .editor-panel { width: 100%; max-width: 100%; }
  #analysis-board-container, #editor-board-container {
    width: min(90vw, 420px);
    height: min(90vw, 420px);
  }

  /* Модалки */
  .modal { margin: 16px; max-width: calc(100vw - 32px) !important; width: 100% !important; }
  .modal h2 { font-size: 18px; }

  /* Страницы */
  .settings-section { padding: 16px; }
  .settings-section .settings-row { flex-direction: column; gap: 8px; }
  .page-header h1 { font-size: 22px; }

  /* Общее */
  .section-title { font-size: 20px !important; }
  [style*="padding:40px"] { padding: 20px 16px !important; }
  [style*="padding: 40px"] { padding: 20px 16px !important; }

  /* Чат */
  #global-chat-messages { height: 220px; }

  /* Таблица лидеров */
  .leaderboard-row { padding: 8px 10px; gap: 8px; }

  /* Профиль */
  .profile-grid { grid-template-columns: 1fr !important; }

  /* Кнопки — минимум 44px для тача */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
}

/* ── Совсем маленький (≤380px) ───────────────────────────── */
@media (max-width: 380px) {
  .logo span:last-child { display: none; } /* скрываем текст, оставляем иконку */
  #chess-board {
    width: calc(100vw - 16px) !important;
    height: calc(100vw - 16px) !important;
  }
  .board-wrapper { width: calc(100vw - 16px); }
  .player-info { width: calc(100vw - 16px); }
}

/* ── MISC ─────────────────────────────────────────────────────── */
.divider {
  height: 1px; background: var(--border); margin: 16px 0;
}

.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 700;
  background: var(--bg-secondary); color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-gold { background: rgba(201,168,76,0.15); color: var(--accent); }
.badge-green { background: rgba(76,175,114,0.15); color: var(--green); }

.rating-pill {
  font-family: var(--font-mono); font-size: 13px;
  background: var(--bg-secondary); color: var(--text-secondary);
  padding: 2px 8px; border-radius: 4px;
}

.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

select.form-input option { background: var(--bg-card); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.fw-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
.text-center { text-align: center; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }