/* === Базовые стили === */
html {
  height: -webkit-fill-available;
}

body {
  margin: 0;
  padding: 0;
  background: #121417;
  font-family: 'Inter', 'Open Sans', sans-serif;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  box-sizing: border-box;
  overflow-x: hidden;

  /* безопасный отступ сверху */
  padding-top: env(safe-area-inset-top, 8px);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Контейнер */
.wrap {
  margin-top: 12px;
  width: 100%;
  max-width: 680px;
  padding: 0 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Верхний блок */
.hero {
  margin-top: 0;
  padding-top: 10px;
  padding-bottom: 6px;
  width: 100%;
  max-width: 680px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #b8b8b8;
  font-weight: 600;
  z-index: 5;
  background: transparent;
  box-sizing: border-box;
}

/* Карточка */
.card {
  background: #1e1f23;
  border-radius: 16px;
  padding: 28px 32px;
  width: 100%;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
}

/* Заголовки и текст */
h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 10px;
  color: #fff;
}

.sub {
  color: #bbb;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 20px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #ccc;
}

/* Поля и кнопки */
textarea {
  width: 100%;
  height: 70px;
  background: #0e0f10;
  border: 1px solid #333;
  border-radius: 10px;
  color: #fff;
  padding: 10px;
  font-family: monospace;
  resize: none;
  margin-bottom: 16px;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

button.btn {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  padding: 10px 16px;
  transition: background 0.25s, transform 0.2s;
}

.btn-blue {
  background: #297eff;
  color: #fff;
}

.btn-blue:hover {
  background: #5093ff;
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent;
  border: 1px solid #444;
  color: #ccc;
}

.btn-ghost:hover {
  background: #2a2b2f;
}

.btn-green {
  background: #2eb872;
  color: #fff;
}

.btn-green:hover {
  background: #37d186;
}

/* Поле результата */
.out {
  display: flex;
  gap: 8px;
  align-items: center;
}

.out input {
  flex: 1;
  background: #0e0f10;
  border: 1px solid #333;
  border-radius: 8px;
  color: #fff;
  padding: 8px 10px;
}

.note {
  margin-top: 10px;
  font-size: 13px;
}

.note.ok { color: #38d878; }
.note.err { color: #f66; }

/* Нижний блок с играми */
.games {
  margin-top: 50px;
  text-align: center;
  width: 100%;
}

.games h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #ccc;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.games-grid {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 25px;
  flex-wrap: wrap;
}

.game {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: #ddd;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.game img {
  width: 78px;
  height: 78px;
  border-radius: 22px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
  margin-bottom: 8px;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.game:hover img {
  transform: scale(1.08);
  box-shadow: 0 0 20px rgba(0,255,128,0.35);
}

/* Мобильная адаптация */
@media (max-width: 768px) {
  .wrap {
    padding: 20px 14px 0;
    width: 100%;
  }

  .card {
    padding: 20px 18px;
    border-radius: 12px;
  }

  textarea {
    height: 90px;
    font-size: 14px;
  }

  .row {
    flex-direction: column;
    gap: 8px;
  }

  button.btn {
    width: 100%;
    font-size: 15px;
  }

  .games {
    margin-top: 40px;
    padding: 0 10px 30px;
  }

  .games-grid {
    gap: 18px;
  }

  .game img {
    width: 70px;
    height: 70px;
  }

  .hero {
    flex-direction: column;
    gap: 6px;
  }
}

/* Safari с вырезом (точечная поддержка) */
@supports(padding: max(0px)) {
  body {
    padding-top: max(env(safe-area-inset-top), 8px);
  }
}

/* Фикс горизонтального скролла и поведения при первой загрузке */
html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

* {
  box-sizing: border-box;
}

textarea, input, button {
  max-width: 100%;
}

@supports (-webkit-touch-callout: none) {
  html {
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden !important;
  }
}

.btn-green {
  background: #2eb872;
  color: #fff;
  text-align: center;
  display: inline-block;
  width: 100%;
  padding: 12px 0;
  border-radius: 10px;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  transition: background 0.3s ease, transform 0.2s ease;
}

.btn-green:hover {
  background: #37d186;
  transform: translateY(-2px);
}
