/* Сброс и базовые настройки для мобильных устройств */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100dvh; /* Динамическая высота viewport для мобильных (учитывает адресную строку) */
  width: 100vw;
  overflow: hidden; /* Запрет прокрутки */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #1a1a2e;
  color: #e0e0e0;
  user-select: none; /* Запрет выделения текста при быстрых нажатиях */
}

/* Управление экранами (скрываем неактивные) */
.screen {
  display: none;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  padding: 2vmin;
}

.screen.active {
  display: flex;
}

/* Заголовки */
h1, h2 {
  text-align: center;
  color: #4ecca3;
  margin-bottom: 2vmin;
  font-size: 5vmin;
}

/* Кнопки и интерактивные элементы */
button, .btn {
  background-color: #16213e;
  color: #4ecca3;
  border: 2px solid #4ecca3;
  border-radius: 2vmin;
  padding: 2vmin;
  font-size: 4.5vmin;
  font-weight: bold;
  cursor: pointer;
  touch-action: manipulation; /* Улучшает отклик на тач-устройствах */
  transition: background 0.1s;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:active, .btn:active {
  background-color: #4ecca3;
  color: #1a1a2e;
}

/* Экран входа и меню */
.auth-container, .menu-container {
  display: flex;
  flex-direction: column;
  gap: 2vmin;
  flex: 1;
  justify-content: center;
  align-items: center;
}

.auth-container button, .menu-container button {
  width: 80vw;
  max-width: 300px;
}

/* Статус поиска */
.status-text {
  text-align: center;
  font-size: 4vmin;
  margin: 4vmin 0;
  color: #a0a0a0;
}

/* Игровой экран */
.game-screen {
  justify-content: space-between;
}

.progress-container {
  display: flex;
  justify-content: space-between;
  font-size: 3.5vmin;
  padding: 1vmin 0;
  color: #a0a0a0;
}

.progress-bar {
  width: 100%;
  height: 2vmin;
  background: #0f3460;
  border-radius: 1vmin;
  margin-top: 1vmin;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #4ecca3;
  width: 0%; /* Будет меняться через JS */
  transition: width 0.3s ease;
}

/* Блок с вопросом */
.question-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2vmin;
}

.question-text {
  font-size: 12vmin;
  font-weight: bold;
  color: #fff;
}

.answer-display {
  font-size: 10vmin;
  min-height: 12vmin;
  min-width: 40vmin;
  border-bottom: 1vmin solid #4ecca3;
  text-align: center;
  color: #4ecca3;
}

/* Клавиатура */
.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 1.5vmin;
  width: 100%;
  max-height: 55dvh; /* Ограничение высоты, чтобы всё влезало */
  padding-bottom: 2vmin;
}

.keypad button {
  width: 100%;
  height: 100%;
  font-size: 7vmin;
  border-radius: 2vmin;
  background-color: #0f3460;
  color: #fff;
  border: none;
}

.keypad button:active {
  background-color: #1a1a2e;
}

.keypad .btn-action {
  background-color: #e94560;
  color: white;
}

.keypad .btn-ok {
  background-color: #4ecca3;
  color: #1a1a2e;
}

/* Экран результатов */
.result-screen {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 4vmin;
}

.result-text {
  font-size: 6vmin;
  color: #4ecca3;
}