/* ==== ОБЩИЙ ФОН И ВЕРСТКА ==== */

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px 0 24px;

  background:
    radial-gradient(circle at 20% 0%, #4fa53c 0%, #2c5e24 40%, #183615 80%),
    #183615;
  color: #fdf8e6;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 920px;
  padding: 0 12px;
}

h1 {
  margin: 0 0 6px;
  font-size: 24px;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

/* ==== ПАНЕЛИ ИГРОКОВ ==== */

.player-panel {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 20px;
  padding: 8px 20px 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 260px;
}

.player-panel .player-name {
  font-weight: 700;
  font-size: 15px;
}

.player-actions {
  display: flex;
  gap: 8px;
}

.player-panel.current-turn {
  background: rgba(40, 90, 32, 0.95);
  box-shadow:
    0 0 0 2px rgba(255,255,255,0.16),
    0 6px 18px rgba(0,0,0,0.8);
}

.player-panel.current-turn .player-name {
  color: #fffbe0;
}

/* ==== КНОПКИ ХОД / СТЕНА ==== */

.mode-btn {
  padding: 7px 20px;
  border-radius: 18px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: linear-gradient(#f4f4f4, #c8c8c8);
  color: #23313a;
  box-shadow:
    0 4px 0 rgba(0,0,0,0.35),
    0 7px 12px rgba(0,0,0,0.4);
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.12s ease;
}

.mode-btn:hover {
  filter: brightness(1.03);
}

.mode-btn:active {
  transform: translateY(1px);
  box-shadow:
    0 2px 0 rgba(0,0,0,0.4),
    0 4px 8px rgba(0,0,0,0.5);
}

.mode-btn.active {
  background: linear-gradient(#8be36b, #3aa332);
  color: #fff;
}

/* ==== ДЕРЕВЯННАЯ РАМКА ==== */

#board-wrapper {
  padding: 16px;
  background: linear-gradient(135deg, #b97537, #8a4a20);
  border-radius: 26px;
  box-shadow:
    0 10px 0 #5b2f12,
    0 18px 30px rgba(0,0,0,0.8);
  position: relative;
  width: min(92vw, 620px);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==== ЗЕЛЁНОЕ ПОЛЕ ==== */

#board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  gap: 4px;
  width: 100%;
  height: 100%;
  padding: 10px;
  border-radius: 20px;

  background: radial-gradient(circle at 30% 20%, #8fd870 0%, #4a9038 55%, #2f5c27 100%);
  box-shadow:
    inset 0 3px 6px rgba(255,255,255,0.12),
    inset 0 -4px 8px rgba(0,0,0,0.6);
  user-select: none;
}

/* ==== КЛЕТКИ ==== */

.cell {
  position: relative;
  background: #28561a;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.5);
  box-shadow:
    inset 0 2px 2px rgba(255,255,255,0.18),
    inset 0 -3px 4px rgba(0,0,0,0.7);
}

/* Верхняя линия финиша для Игрока 1 (синий) */
.cell.goal-p1 {
  background: #3e8fe5;
  border-color: #20518e;
}

/* Нижняя линия финиша для Игрока 2 (красный) */
.cell.goal-p2 {
  background: #e2554f;
  border-color: #7b2622;
}

/* ==== ФИШКИ ==== */

.cell.player1::after,
.cell.player2::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  box-shadow:
    0 4px 0 rgba(0,0,0,0.45),
    0 8px 12px rgba(0,0,0,0.6),
    inset 0 2px 3px rgba(255,255,255,0.4);
}

/* нижняя синяя фишка */
.cell.player1::after {
  background:
    radial-gradient(circle at 30% 20%, #7fd0ff 0%, #1a7ed6 45%, #08457d 100%);
}

/* верхняя красная фишка */
.cell.player2::after {
  background:
    radial-gradient(circle at 30% 20%, #ff8a7a 0%, #e53b32 45%, #8a1010 100%);
}

/* Клетки, куда можно походить в текущий ход */
.cell.move-available {
  box-shadow:
    0 0 0 2px rgba(255,255,255,0.5) inset,
    inset 0 -3px 4px rgba(0,0,0,0.7);
}

/* ==== СТЕНЫ ПОВЕРХ КЛЕТОК ==== */

.wall {
  position: absolute;
  background: #e5a24a;
  border-radius: 999px;
  box-shadow: 0 3px 0 rgba(116, 63, 19, 0.9);
  z-index: 5;
}

.wall-preview {
  background: #fff7c7;
  box-shadow: none;
}

/* ==== ОВЕРЛЕЙ КОНЦА ИГРЫ ==== */

#end-overlay.hidden {
  display: none;
}

#end-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay-content {
  background: rgba(15, 40, 18, 0.97);
  border-radius: 20px;
  padding: 22px 28px;
  text-align: center;
  box-shadow:
    0 6px 18px rgba(0,0,0,0.8),
    0 0 0 2px rgba(255,255,255,0.08);
  min-width: 260px;
}

.overlay-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.overlay-subtitle {
  font-size: 16px;
  margin-bottom: 16px;
}

.overlay-animation {
  font-size: 32px;
  margin-bottom: 16px;
  height: 40px;
}

.overlay-button {
  padding: 8px 18px;
  border-radius: 18px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  background: linear-gradient(#ffe070, #f0a731);
  color: #4b2500;
  box-shadow:
    0 4px 0 rgba(116, 63, 19, 0.9),
    0 7px 12px rgba(0,0,0,0.5);
}

.overlay-button:hover {
  filter: brightness(1.05);
}

.overlay-button:active {
  transform: translateY(1px);
  box-shadow:
    0 2px 0 rgba(116, 63, 19, 0.9),
    0 4px 8px rgba(0,0,0,0.6);
}

/* ==== СЧЁТ, СТАТУС, ПРАВИЛА ==== */

#score,
#total-games {
  font-size: 14px;
  text-align: center;
  opacity: 0.95;
}

#info {
  margin-top: 6px;
}

#reset-btn {
  padding: 8px 18px;
  border-radius: 18px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  background: linear-gradient(#ffe070, #f0a731);
  color: #4b2500;
  box-shadow:
    0 4px 0 rgba(116, 63, 19, 0.9),
    0 7px 12px rgba(0,0,0,0.5);
}

#reset-btn:hover {
  filter: brightness(1.05);
}

#reset-btn:active {
  transform: translateY(1px);
  box-shadow:
    0 2px 0 rgba(116, 63, 19, 0.9),
    0 4px 8px rgba(0,0,0,0.6);
}

#status {
  margin-top: 6px;
  font-size: 14px;
  min-height: 20px;
  text-align: center;
}

/* Правила игры */

#rules {
  margin-top: 8px;
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#rules > summary {
  cursor: pointer;
  list-style: none;
  background: rgba(0, 0, 0, 0.35);
  padding: 8px 14px;
  border-radius: 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#rules > summary::marker {
  display: none;
}

#rules[open] > summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

#rules > summary::after {
  content: "▼";
  font-size: 10px;
  opacity: 0.7;
  transform: translateY(1px);
}

#rules[open] > summary::after {
  content: "▲";
}

#controls {
  width: 100%;
  max-width: 700px;
  padding: 10px 14px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
}

/* ==== АДАПТИВ ДЛЯ ТЕЛЕФОНА ==== */

@media (max-width: 600px) {
  #board-wrapper {
    width: 92vw;
  }

  h1 {
    font-size: 20px;
  }

  .player-panel {
    min-width: 0;
    width: 90%;
  }
}
