/* === Сброс и базовые стили === */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #1a1a2e;
  color: #eee;
  overflow: hidden;

  /* Flexbox-центрирование */
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ================================================================
   СТАРТОВЫЙ ЭКРАН
   ================================================================ */
#start-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 30px;
  max-width: 480px;
  width: 100%;
}

.game-title {
  font-size: 52px;
  font-weight: 900;
  color: #f0c000;
  text-shadow: 3px 3px 0 #c0392b, 6px 6px 0 rgba(0,0,0,0.3);
  letter-spacing: 6px;
  text-align: center;
  user-select: none;
}

/* Поле ввода имени */
.name-input-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.name-input-group label {
  font-size: 18px;
  color: #ccc;
  font-weight: 600;
}

.name-input-group input {
  width: 260px;
  padding: 10px 16px;
  font-size: 20px;
  text-align: center;
  border: 2px solid #555;
  border-radius: 8px;
  background: #0a0a14;
  color: #f0c000;
  outline: none;
  transition: border-color 0.2s;
}

.name-input-group input:focus {
  border-color: #f0c000;
}

/* ================================================================ */
/* Таблица лидерборда */
#leaderboard {
  width: 100%;
  max-width: 360px;
  margin-top: 4px;
}

#leaderboard h2 {
  text-align: center;
  font-size: 20px;
  color: #aaa;
  margin-bottom: 8px;
}

#leaderboard-scroll {
  max-height: 220px;
  overflow-y: auto;
  border: 2px solid #444;
  border-radius: 8px;
  background: #0a0a14;
  scrollbar-width: thin;
  scrollbar-color: #555 #0a0a14;
}

#leaderboard-scroll::-webkit-scrollbar {
  width: 8px;
}
#leaderboard-scroll::-webkit-scrollbar-track {
  background: #0a0a14;
}
#leaderboard-scroll::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 4px;
}

#leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

#leaderboard-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

#leaderboard-table th {
  background: #16213e;
  color: #f0c000;
  padding: 8px 4px;
  border-bottom: 2px solid #444;
  font-weight: 700;
}

#leaderboard-table th:nth-child(1) { width: 15%; }
#leaderboard-table th:nth-child(2) { width: 55%; }
#leaderboard-table th:nth-child(3) { width: 30%; }

#leaderboard-table td {
  padding: 6px 4px;
  text-align: center;
  border-bottom: 1px solid #222;
  color: #ddd;
}

#leaderboard-table tbody tr:nth-child(1) td { color: #FFD700; font-weight: 700; }
#leaderboard-table tbody tr:nth-child(2) td { color: #C0C0C0; font-weight: 700; }
#leaderboard-table tbody tr:nth-child(3) td { color: #CD7F32; font-weight: 700; }

.leaderboard-empty {
  text-align: center;
  color: #666;
  padding: 20px;
  font-style: italic;
}

/* ================================================================ */
/* Болшие кнопки (старт, настройки, назад) */
.big-btn {
  font-size: 24px;
  font-weight: 700;
  padding: 14px 40px;
  border: 2px solid #f0c000;
  border-radius: 12px;
  background: #16213e;
  color: #f0c000;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s, transform 0.1s;
  min-width: 240px;
  text-align: center;
}

.big-btn:hover {
  background: #1a4a80;
}

.big-btn:active {
  transform: scale(0.95);
}

.big-btn.secondary {
  border-color: #555;
  color: #aaa;
  background: #0f0f23;
}

.big-btn.secondary:hover {
  background: #1a1a3a;
  color: #ddd;
}

/* ================================================================ */
/* СТРАНИЦА НАСТРОЕК */
#settings-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
  padding: 30px;
}

.settings-placeholder {
  font-size: 18px;
  color: #777;
  font-style: italic;
}

/* ================================================================ */
/* ИГРОВОЙ ЭКРАН */
/* ================================================================ */
#game-screen {
  position: relative;
}

/* === Игровой контейнер === */
#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* === Счёт === */
#score {
  font-size: 24px;
  font-weight: bold;
  color: #f0c000;
  background: #16213e;
  padding: 8px 24px;
  border: 2px solid #555;
  border-radius: 8px;
  text-align: center;
  min-width: 160px;
}

/* === Игровое поле (стакан) === */
#game-board {
  border: 2px solid #555;
  background: #0a0a14;
  display: block;
}

/* === Кнопки управления (для мобильных) === */
#controls {
  display: flex;
  gap: 16px;
}

.ctrl-btn {
  /* Размер: крупный, удобный для палцев */
  width: 70px;
  height: 70px;
  border: 2px solid #555;
  border-radius: 12px;
  background: #16213e;
  color: #eee;
  font-size: 28px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  /* Центрируем символ стрелки */
  display: flex;
  justify-content: center;
  align-items: center;
  /* Плавный отклик */
  transition: background 0.1s, transform 0.1s;
  /* Отклучаем стандартный tap-подсвет на мобильных */
  -webkit-tap-highlight-color: transparent;
}

.ctrl-btn:active {
  background: #0f3460;
  transform: scale(0.93);
}

/* === Эран прогирыша (модалное окно) === */
#game-over-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.game-over-box {
  background: #16213e;
  border: 3px solid #e74c3c;
  border-radius: 16px;
  padding: 40px 50px;
  text-align: center;
  color: #eee;
  box-shadow: 0 0 40px rgba(231, 76, 60, 0.4);
}

.game-over-box h1 {
  font-size: 42px;
  color: #e74c3c;
  margin-bottom: 16px;
}

#final-score {
  font-size: 24px;
  color: #f0c000;
  margin-bottom: 24px;
}

#btn-restart {
  font-size: 20px;
  padding: 12px 36px;
  border: 2px solid #555;
  border-radius: 10px;
  background: #0f3460;
  color: #eee;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
}

#btn-restart:hover {
  background: #1a4a80;
}

#btn-restart:active {
  transform: scale(0.95);
}

/* Контейнер для кнопок в окне проигрыша */
.game-over-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

#btn-go-start {
  font-size: 20px;
  padding: 12px 36px;
  border: 2px solid #555;
  border-radius: 10px;
  background: #0f3460;
  color: #eee;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
}

#btn-go-start:hover {
  background: #1a4a80;
}

#btn-go-start:active {
  transform: scale(0.95);
}

/* ================================================================ */
/* ЭКРАН ПАУЗЫ */
#pause-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.pause-box {
  background: #16213e;
  border: 3px solid #f0c000;
  border-radius: 16px;
  padding: 40px 50px;
  text-align: center;
  color: #eee;
  box-shadow: 0 0 40px rgba(240, 192, 0, 0.3);
}

.pause-box h1 {
  font-size: 42px;
  color: #f0c000;
  margin-bottom: 24px;
}

#btn-go-start-from-pause {
  font-size: 20px;
  padding: 12px 36px;
  border: 2px solid #555;
  border-radius: 10px;
  background: #0f3460;
  color: #eee;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
}

#btn-go-start-from-pause:hover {
  background: #1a4a80;
}

#btn-go-start-from-pause:active {
  transform: scale(0.95);
}

#btn-resume-from-pause {
  font-size: 20px;
  padding: 12px 36px;
  border: 2px solid #555;
  border-radius: 10px;
  background: #0f3460;
  color: #eee;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
}

#btn-resume-from-pause:hover {
  background: #1a4a80;
}

#btn-resume-from-pause:active {
  transform: scale(0.95);
}