:root {
  --primary: #2ECC71;
  --primary-dark: #27AE60;
  --text: #333;
  --text-light: #666;
  --bg: #f4f4f4;
  --card-bg: #fff;
  --border: #e0e0e0;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
  --radius-sm: 20px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --transition: all 0.3s ease;
  --red: #ff4757;
  --yellow: #ffc107;
  --animation-duration: 0.2s;
}

.genres-popup {
    position: fixed;
    top: calc(100% - 80%); /* Начинается снизу */
    left: 0;
    width: 100vw;
    height: 80%; /* Занимает 80% экрана */
    z-index: 1000;
    overflow-y: auto;
    display: none;
    padding: 20px;
    border-radius: 35px 35px 0 0;
    box-sizing: border-box;
    animation-duration: 0.4s;
    animation-fill-mode: both;
    background: rgba(0, 0, 0, 0.2) !important; /* Фон для контента */
    backdrop-filter: blur(20px);
}

/*.genre-arrow {position: fixed; 
  bottom: 10px; 
  left: 50%;
  transform: translateX(-50%) rotate(270deg); 
  width: 24px;
  height: auto;
  background: transparent;
  backdrop-filter: blur(10px);
  border-radius: 50px;
  z-index: 1100;
  opacity: 1;
  pointer-events: none; 
  transition: opacity 0.3s ease;
}
*/

/* Анимация появления (снизу вверх) */
@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Анимация скрытия (вниз) */
@keyframes slideDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

.slide-up {
    animation-name: slideUp;
}

.slide-down {
    animation-name: slideDown;
}

.genre-fade-overlay {
  position: fixed;
  left: 0;
  bottom: 0px;
  width: 100%;
  height: 60px;
  pointer-events: none;
  z-index: 1000;
  background: linear-gradient(to top, #000, transparent);
}


#selected-genre-container {
    display: none;
    align-items: center;
    background-color: rgba(52, 219, 149, 0.1);
    border-radius: 20px;
    padding: 5px 15px;
    margin: 0 10px;
    animation: fadeIn 0.3s ease;
}

.selected-genre-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-genre-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-genre-btn:hover {
    background-color: rgba(52, 152, 219, 0.2);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Анимация для chevron */
.chevrons {
    transition: transform 0.3s ease;
}

*, #pagination-loader .load-circle {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
}

#pagination-loader, #loading-indicator {
  display: none;
  margin: 20px auto;
  text-align: center;
}

#pagination-loader .load-circle, .load-circle {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(73, 181, 63, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

html {
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

body {
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-y: overlay;
}

::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#categories {
    position: relative;
    margin: 0 30px; /* Отступы для стрелок */
}

.scroll-btn {
    position: absolute;
    top: 43%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    color: var(--primary);
    background: transparent;
    font-size: 20px;
    font-style: bold;
    border: none;
    border-radius: 50%;
    box-shadow: var(--shadow);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: var(--transition);
}

.chevrons{
    display: none;
    filter: invert(1);
}

.left-scroll-btn {
    left: -15px;
}

.right-scroll-btn {
    right: -15px;
}

/* Скрываем стрелки, если прокрутка невозможна */
#categories.scroll-start .left-scroll-btn,
#categories.scroll-end .right-scroll-btn {
    display: none;
}

.header {
  display: flex;
  justify-content: space-between;
  padding: 15px 25px;
  background: transparent !important;
  backdrop-filter: blur(15px);
  flex-direction: column;
  border-radius: var(--radius-lg);
  margin: 10px 25px;
  position: sticky;
  top: 10px;
  transition: margin 0.3s ease;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-content, .search-container {
  display: flex;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  white-space: nowrap;
  filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.08));
}

.search-icon {
  width: 30px;
  height: auto;
  margin-top: 5px;
  filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.08));
}

.message {
  text-align: center;
  padding: 20px;
  color: var(--text-light);
  grid-column: 1 / -1;
}

#search {
  display: flex;
  gap: 10px;
  padding: 0 25px;
  margin-bottom: 20px;
}

#search-input {
  flex-grow: 1;
  padding: 5px 15px;
  border: 1px solid var(--border);
  border-radius: 30px;
  font-size: 1rem;
  outline: none;
  width: 100px;
  background-color: rgba(255, 255, 255, 0.1);
}

#search-button {
  background: transparent;
  color: var(--primary);
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background-color: #dfe6e9;
  cursor: pointer;
}

#main-content {
  display: flex;
  flex-direction: column;
  padding: 0 25px;
}

#categories-list {
  list-style: none;
  display: flex;
  overflow-x: auto;
  gap: 10px;
  justify-content: center;
  padding: 5px 25px 15px 25px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: relative;
    scroll-behavior: smooth;
    mask-image: linear-gradient(
        to right, 
        transparent 0%, 
        black 30px, 
        black calc(100% - 30px), 
        transparent 100%
    );
}
#categories-list::-webkit-scrollbar {
  display: none;
}

#categories-list button {
  background: transparent;
  will-change: transform, box-shadow, border-color;
  border: 2px solid transparent; /* <- Фиксированная ширина границы */
  transition: 
    transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    box-shadow 0.3s ease,
    border-color 0.3s ease,
    background-color 0.3s ease !important;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

#games-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  padding: 20px 0;
}

/* Анимация при наведении */
.game-card:hover .game-info-overlay {
  bottom: 0;
}

.game-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
  position: relative;
  display: block;
  text-decoration: none;
  color: inherit;
  animation: fadeIn var(--animation-duration) ease forwards;
}
.game-card:hover {
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-radius 0.3s ease;
  border-radius: 7px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  outline: 2px solid #FFF;

}

.game-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  /*background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);*/
}

.game-info {
  display: none;
}

/* Стили для оверлея с названием и жанром */
.game-info-overlay {
  position: absolute;
  bottom: -100%;
  left: 0;
  right: 0;
  padding: 8px 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
  color: white;
  transition: all 0.3s ease;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.game-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  flex: 1;
  min-width: 0;
}

#genres-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* <-- выравнивание по левому краю */
    gap: 8px; /* расстояние между жанрами */
    padding: 10px;
}

.genre-item {
    display: block;
    width: 100%;
    max-width: 100%; /* по желанию — ограничение ширины */
    padding: 10px 14px;
    background-color: transparent;
    border: 3px solid #FFF;
    border-radius: 20px;
    font-weight: 500;
    color: #FFF;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.game-category {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  flex-shrink: 0;
}

.category-icon {
  display: inline-flex;
}

#category-icon-menu {
    filter: invert(1);
}

.category-name-title {
  display: none;
}

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

.favorite-btn:hover {
  background: rgba(0, 0, 0, 0.5);
  color: var(--red);
}
.favorite-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;  /* Оставляем кнопку flex для правильного выравнивания */
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  z-index: 2;
  opacity: 0; /* Скрываем кнопку с помощью opacity */
  transform: scale(0.8); /* Начальный масштаб кнопки */
  transition: opacity 0.3s ease, transform 0.3s ease; /* Плавная анимация изменения opacity и transform */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-size: 17px;
}

/* Показываем кнопку при наведении на карточку */
.game-card:hover .favorite-btn {
  opacity: 1; /* Делаем кнопку видимой */
  transform: scale(1); /* Восстанавливаем нормальный масштаб */
}

#loading-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
}

@media (min-width: 769px) {
  #main-content {
    flex-direction: row;
    align-items: flex-start;
    gap: 30px;
  }
  #categories h2 {
    display: none;
  }
  #games {
    flex: 1;
  }
}

@media (max-width: 1390px) {
  #games-list {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
  }
  #categories-list {
    justify-content: flex-start; /* Изменено с center на flex-start */
    padding-left: 25px; /* Добавляем небольшой отступ слева */
  }
  .category-name-title{
    display:none;
  }
  .game-card img {
    height: 100px;
  }
  .chevrons{
    display: flex;
  }
}

@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 15px;
    padding: 15px;
    margin: 10px 15px;
    background: white;
  }
  .search-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    z-index: 10;
    display: flex !important;
    background: transparent;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
  }
  .search-container.active {
    opacity: 1;
    width: 35%;
    margin-left: 20px;
    padding: 10 15;
  }
  .header-content {
    transition: all 0.3s ease;
  }
  /*#search-input { caret-color: transparent; Или любой другой цвет }*/
  .search-container.active ~ .header-content {
    opacity: 0.5;
    transform: scale(0.9);
  }
  
  #search-button {
    position: relative;
    z-index: 11;
  }
  .header-content {
    gap: 10px;
  }
  .logo {
    font-size: 1.5rem;
    order: 1; /* Перемещаем логотип в конец (крайний справа) */
    margin-left: auto;
  }
  #search {
    flex-direction: column;
    width: 100%;
  }
  #games-list {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
  }
  #search-input {
    min-width: 100%; /* Фиксируем ширину поля */
    transition: none !important; /* Отключаем внутренние анимации */
  }
  #games {
    transition: opacity 0.3s ease;
  }
  .game-card img {
    height: 90px;
  }
  .favorite-btn {
    background: rgba(0, 0, 0, 0.6);
    display: none;
  }
  .search-active #games {
    opacity: 0;
    pointer-events: none;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #e0e0e0;
    --text-light: #b0b0b0;
    --bg: #141414;
    --card-bg: #1e1e1e;
    --border: #333;
  }
  body {
    background-color: var(--bg);
  }
  .header {
    background: transparent !important;
    backdrop-filter: blur(15px);
  }
  .category-icon {
    display: inline-flex;
  }
  #category-icon-menu {
    filter: invert(0);
  }
  .chevrons{
    filter: invert(0);
  }
  #search-input {
    background-color: transparent;
    color: var(--text);
    width: 60px;
    border-color: rgba(0, 0, 0, 0.1);
  }
  #categories-list button {
    color: var(--text);
    font-size: 15px;
  }
  #categories-list button:hover {
    background: #3d3d3d;
  }
  .game-card {
    background: #1e1e1e;
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}