:root {
  --bg: #ffffff;
  --card: #ffffff;
  --accent: #2563eb;
  --muted: #6b7280;
  --text: #0f1724;
  --green: rgba(34, 197, 94, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none; /* 🚫 отключаем "прыжки" при свайпе */
}

.warning {
  max-width: 900px;
  margin: 40px auto;
  padding: 18px;
  border-radius: 10px;
  background: #fff3cd;
  border: 1px solid #ffeeba;
  color: #856404;
  font-size: 14px;
}

.container {
  max-width: 1100px;
  margin: 28px auto;
  padding: 18px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.logo {
  font-weight: 700;
  font-size: 20px;
  color: var(--accent);
}

.tagline {
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  max-width: 600px;
}

.right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.label-inline {
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.16);
}

.btn-primary:hover {
  background: #1e4fd8;
}

.btn-secondary {
  background: transparent;
  border: 1px solid rgba(15, 23, 36, 0.1);
  color: var(--text);
}

.btn-secondary:hover {
  background: rgba(15, 23, 36, 0.04);
}

.main {
  display: grid;
  grid-template-columns: 520px 1fr;
  gap: 20px;
  align-items: flex-start;
}

.board-card {
  background: var(--card);
  padding: 16px;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(16, 24, 40, 0.05);
  min-height: 540px; /* 📌 фикс, чтобы панель не прыгала */
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.board {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;  /* ✅ всегда квадрат */
  margin: 0 auto;
  touch-action: none; /* 🚫 запрет скролла страницы при таскании фигур */
}

.players {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
}

.player {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.player .name {
  font-weight: 700;
}

.player .role {
  font-size: 13px;
  color: var(--muted);
}

.side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  background: var(--card);
  padding: 14px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.05);
}

.panel h3 {
  margin: 0 0 8px 0;
  font-size: 15px;
}

.moves {
  font-family: monospace;
  font-size: 14px;
  line-height: 1.6;
  max-height: 220px;
  overflow: auto;
  color: var(--text);
}

.status {
  font-size: 14px;
  color: var(--muted);
}

.log {
  font-family: monospace;
  font-size: 13px;
  color: var(--muted);
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
}

.footer {
  margin-top: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 10px;
}

.square-highlight {
  box-shadow: inset 0 0 0 6px var(--green);
  transition: box-shadow 0.25s ease;
}

.piece-land {
  animation: land 0.12s ease;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.slider {
  position: relative;
  width: 40px;
  height: 22px;
  background: #d1d5db; /* серый */
  border-radius: 22px;
  transition: 0.3s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

.switch-label {
  font-size: 14px;
  color: var(--muted);
}

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

/* 📱 Мобильная адаптация */
@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
  }
  .board-card {
    min-height: auto;
  }
  .board {
    max-width: 100%;
  }
  .side {
    flex-direction: column;
  }
}

@media (max-width: 600px) {
  .top {
    flex-direction: column;
    align-items: flex-start;
  }
  .logo {
    font-size: 18px;
  }
  .tagline {
    font-size: 12px;
  }
  .btn {
    flex: 1;
    text-align: center;
  }
  .right {
    width: 100%;
    justify-content: stretch;
  }
}
