@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bw-bg-base: #0B0B12;
  --bw-accent-1: #6C5CE7;
  --bw-accent-2: #00CEC9;
  --bw-text-main: #FFFFFF;
  --bw-text-muted: rgba(255, 255, 255, 0.6);

  --bw-glass-bg: rgba(255, 255, 255, 0.03);
  --bw-glass-border: rgba(255, 255, 255, 0.08);
  --bw-glass-highlight: rgba(255, 255, 255, 0.12);

  --bw-shadow-soft: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  --bw-shadow-neon: 0 0 24px rgba(108, 92, 231, 0.4);

  --bw-radius-xl: 32px;
  --bw-radius-lg: 24px;
  --bw-radius-md: 16px;
  --bw-radius-sm: 8px;

  --bw-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bw-bg-base);
  color: var(--bw-text-main);
  line-height: 1.5;
  overflow-x: hidden;
  background-image:
          radial-gradient(circle at 15% 50%, rgba(108, 92, 231, 0.15), transparent 25%),
          radial-gradient(circle at 85% 30%, rgba(0, 206, 201, 0.15), transparent 25%);
  background-attachment: fixed;
}

/* Glassmorphism Core */
.bw-glass {
  background: var(--bw-glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--bw-glass-border);
  border-radius: var(--bw-radius-lg);
  box-shadow: var(--bw-shadow-soft);
}

/* Typography */
h1, h2, h3 { font-weight: 700; letter-spacing: -0.02em; }
.bw-gradient-text {
  background: linear-gradient(135deg, var(--bw-accent-2), var(--bw-accent-1));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Layout Grid */
.bw-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  gap: 32px;
  padding: 32px;
}

/* Sidebar */
.bw-sidebar {
  position: sticky;
  top: 32px;
  height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  padding: 32px 24px;
}

/* Branding */
.bw-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-size: 24px;
  font-weight: 800;
  color: var(--bw-text-main);
  margin-bottom: 48px;
}
.bw-brand svg { width: 36px; height: 36px; }

/* Navigation */
.bw-nav { display: flex; flex-direction: column; gap: 12px; }
.bw-nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  color: var(--bw-text-muted);
  text-decoration: none;
  border-radius: var(--bw-radius-md);
  font-weight: 500;
  transition: all 0.3s var(--bw-ease);
}
.bw-nav-item:hover, .bw-nav-item.is-active {
  background: var(--bw-glass-highlight);
  color: var(--bw-text-main);
  transform: translateX(8px);
}

/* Buttons */
.bw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 28px;
  border-radius: var(--bw-radius-sm);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.3s var(--bw-ease);
  text-decoration: none;
}
.bw-btn--primary {
  background: linear-gradient(135deg, var(--bw-accent-1), var(--bw-accent-2));
  color: #fff;
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}
.bw-btn--primary:hover {
  box-shadow: var(--bw-shadow-neon);
  transform: translateY(-2px);
}
.bw-btn--glass {
  background: var(--bw-glass-bg);
  border: 1px solid var(--bw-glass-border);
  color: var(--bw-text-main);
}
.bw-btn--glass:hover {
  background: var(--bw-glass-highlight);
  border-color: var(--bw-accent-2);
}

/* Auth View (Split) */
.bw-auth-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  padding: 40px;
  gap: 40px;
}
.bw-auth-hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
}
.bw-auth-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Forms */
.bw-form-group { margin-bottom: 24px; }
.bw-label { display: block; font-size: 14px; margin-bottom: 8px; color: var(--bw-text-muted); }
.bw-input {
  width: 100%;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--bw-glass-border);
  color: #fff;
  padding: 16px;
  border-radius: var(--bw-radius-md);
  font-family: inherit;
  font-size: 16px;
  transition: all 0.3s var(--bw-ease);
}
.bw-input:focus {
  outline: none;
  border-color: var(--bw-accent-1);
  box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.1);
}
.bw-input.is-error { border-color: #ff4757; }
.bw-error-msg { color: #ff4757; font-size: 12px; margin-top: 6px; display: none; }

.bw-row {
  display: flex;
  flex-direction: row;
  padding: 0;
  margin-block: 20px;
  gap: 14px;
}

/* Responsive */
@media (max-width: 1024px) {
  .bw-layout { grid-template-columns: 1fr; padding: 16px; }
  .bw-sidebar { position: static; height: auto; padding: 24px; margin-bottom: 24px; }
  .bw-auth-container { grid-template-columns: 1fr; }
}

/* ==========================================================================
   GAME SHELVES & TRACKS
   ========================================================================== */

.shelf {
  margin-bottom: 48px;
  width: 100%;
}

.shelf-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 20px;
}

.shelf-head h2 {
  font-size: 24px;
  color: var(--bw-text-main);
  margin: 0;
}

.shelf-head .tally {
  font-size: 14px;
  color: var(--bw-text-muted);
  font-weight: 500;
}

/* Horizontal Scroll Track */
.shelf-track {
  display: flex !important;
  gap: 20px;
  width: 100%;
  max-width: 100%;
  overflow-x: scroll !important; /* Включает горизонтальный скролл */
  overflow-y: hidden;
  padding-bottom: 16px;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch; /* Плавный скролл на iOS */
}

/* Grid for "All Games" */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
}

/* ==========================================================================
   CUSTOM SCROLLBAR (Линия скролла)
   ========================================================================== */

.shelf-track::-webkit-scrollbar {
  height: 6px;
}

.shelf-track::-webkit-scrollbar-track {
  background: var(--bw-glass-bg);
  border-radius: 8px;
  border: 1px solid var(--bw-glass-border);
}

.shelf-track::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, var(--bw-accent-2), var(--bw-accent-1));
  border-radius: 8px;
}

.shelf-track::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(90deg, var(--bw-accent-1), var(--bw-accent-2));
}

/* ==========================================================================
   GAME TILES (Карточки игр из функции tile(g))
   ========================================================================== */

.tile {
  flex: 0 0 200px; /* Фиксированная ширина для горизонтального скролла */
  scroll-snap-align: start;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  transition: transform 0.3s var(--bw-ease);
  position: relative;
}

/* Для сетки (grid) сбрасываем фиксированную ширину */
.tile-grid .tile {
  flex: auto;
  width: 100%;
}

.tile:hover {
  transform: translateY(-8px);
}

.tile .art {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4; /* Пропорции обложки игры */
  border-radius: var(--bw-radius-md);
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--bw-glass-border);
  box-shadow: var(--bw-shadow-soft);
  background: rgba(0, 0, 0, 0.2);
}

.tile .art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--bw-ease);
}

.tile:hover .art img {
  transform: scale(1.08); /* Плавный зум при наведении */
}

/* Бейдж "New" */
.tile .fresh {
  position: absolute;
  top: 12px;
  right: 12px;
  background: linear-gradient(135deg, var(--bw-accent-1), var(--bw-accent-2));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--bw-radius-sm);
  z-index: 2;
  box-shadow: var(--bw-shadow-neon);
  letter-spacing: 1px;
}

/* Оверлей "Play free" */
.tile .go {
  position: absolute;
  inset: 0;
  background: rgba(11, 11, 18, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s var(--bw-ease);
  z-index: 3;
}

.tile:hover .go {
  opacity: 1;
}

.tile .go span {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 10px 24px;
  border-radius: 30px;
  font-weight: 600;
  font-size: 14px;
  transform: translateY(15px);
  transition: all 0.4s var(--bw-ease);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tile:hover .go span {
  transform: translateY(0);
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--bw-accent-2);
}

/* Текстовый блок под картинкой */
.tile .label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 4px;
}

.tile .name {
  color: var(--bw-text-main);
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile .kind {
  color: var(--bw-accent-2);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.playfield {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #05090b;
  display: none;
  flex-direction: column;
}
.playfield.on { display: flex; }
.playfield-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #0a120e;
  border-bottom: 1px solid var(--line);
}
.playfield-bar .title { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 15px; }
.playfield-bar button {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.playfield-bar button:hover { border-color: rgba(255, 255, 255, 0.25); }
.playfield iframe { flex: 1; width: 100%; border: 0; }
