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

:root {
  --bw-bg-base: #140B06;
  --bw-accent-1: #FF5E00;
  --bw-accent-2: #FFC53D;
  --bw-text-main: #FFF8EF;
  --bw-text-muted: rgba(255, 236, 210, 0.66);

  --bw-glass-bg: rgba(255, 150, 60, 0.04);
  --bw-glass-border: rgba(255, 197, 61, 0.16);
  --bw-glass-highlight: rgba(255, 94, 0, 0.16);

  --bw-shadow-soft: 0 10px 34px 0 rgba(20, 6, 0, 0.5);
  --bw-shadow-neon: 0 0 28px rgba(255, 165, 0, 0.38);

  --bw-radius-xl: 36px;
  --bw-radius-lg: 28px;
  --bw-radius-md: 18px;
  --bw-radius-sm: 10px;

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

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bw-bg-base);
  color: var(--bw-text-main);
  line-height: 1.55;
  overflow-x: hidden;
  background-image:
          radial-gradient(circle at 18% 60%, rgba(255, 94, 0, 0.18), transparent 26%),
          radial-gradient(circle at 82% 30%, rgba(255, 197, 61, 0.12), transparent 26%),
          radial-gradient(circle at 55% 100%, rgba(255, 94, 0, 0.08), transparent 34%);
  background-attachment: fixed;
}

/* Glassmorphism Core */
.bw-glass {
  background: var(--bw-glass-bg);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  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: 800; letter-spacing: -0.01em; }
h1, h2, h3, .bw-brand { font-family: 'Playfair Display', serif; }
.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;
}

.bw-main {
  width: 100%;
  min-width: 0; /* Предотвращает переполнение сетки */
}

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

.form-block{
  width: 100%; max-width: 480px; padding: 48px;
}

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

/* 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);
  white-space: nowrap;
}
.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;
  font-family: inherit;
}
.bw-btn--primary {
  background: linear-gradient(135deg, var(--bw-accent-1), var(--bw-accent-2));
  color: #180d03;
  box-shadow: 0 6px 18px rgba(255, 120, 0, 0.4);
}
.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.25);
  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-2);
  box-shadow: 0 0 0 4px rgba(255, 197, 61, 0.14);
}
.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;
}

/* ==========================================================================
   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;
}

/* 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 {
  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;
}

.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.3);
}

.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);
}

.tile .fresh {
  position: absolute;
  top: 12px;
  right: 12px;
  background: linear-gradient(135deg, var(--bw-accent-1), var(--bw-accent-2));
  color: #1d0f02;
  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;
}

.tile .go {
  position: absolute;
  inset: 0;
  background: rgba(20, 11, 6, 0.62);
  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, 197, 61, 0.12);
  border: 1px solid rgba(255, 197, 61, 0.5);
  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.25);
}

.tile:hover .go span {
  transform: translateY(0);
  background: rgba(255, 140, 30, 0.22);
  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: #0c0602;
  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: #160b04;
  border-bottom: 1px solid var(--bw-glass-border);
}
.playfield-bar .title { font-weight: 600; font-size: 15px; }
.playfield-bar button {
  background: var(--bw-glass-bg);
  border: 1px solid var(--bw-glass-border);
  color: var(--bw-text-main);
  border-radius: 9px;
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.playfield-bar button:hover { border-color: rgba(255, 197, 61, 0.45); }
.playfield iframe { flex: 1; width: 100%; border: 0; }

/* ==========================================================================
   RESPONSIVE ADAPTATIONS (Сайдбар, Планашеты, Мобильные до 320px)
   ========================================================================== */

/* Tablet & Mobile Layout Override */
@media (max-width: 1024px) {
  .bw-layout {
    grid-template-columns: 1fr;
    padding: 20px;
    gap: 24px;
  }

  .bw-sidebar {
    position: static;
    height: auto;
    padding: 24px;
    margin-bottom: 0;
  }

  .bw-brand {
    margin-bottom: 24px;
  }

  .bw-auth-container {
    display: flex;
    flex-direction: column-reverse;
    padding: 24px;
    gap: 24px;
  }

  .form-block{
    max-width: 100%;
  }

  .bw-auth-hero {
    padding: 32px;
  }

  /* Перекрытие инлайновых стилей главной секции */
  .bw-hero {
    max-width: 100% !important;
    padding: 40px !important;
  }
}

/* Mobile Screens (<= 768px) */
@media (max-width: 768px) {
  .bw-layout {
    padding: 16px;
  }

  .bw-hero {
    padding: 28px 20px !important;
    margin-bottom: 28px !important;
  }

  .bw-hero h1 {
    font-size: 36px !important;
  }

  /* Горизонтальный скролл навигации по категориям */
  .bw-row {
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
    padding-bottom: 8px;
    margin-block: 16px;
    -webkit-overflow-scrolling: touch;
  }

  .bw-row .bw-nav-item {
    flex-shrink: 0;
    padding: 10px 16px;
    font-size: 14px;
  }

  .shelf-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .shelf-head h2 {
    font-size: 20px;
  }

  .shelf {
    margin-bottom: 32px;
  }

  .tile {
    flex: 0 0 160px; /* Уменьшенная ширина карточки для мобильных */
  }

  .tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
  }

  .tile .name {
    font-size: 14px;
  }

  .bw-auth-container {
    padding: 16px;
  }

  .bw-auth-hero {
    padding: 24px 16px;
  }

  .bw-auth-hero h1 {
    font-size: 32px !important;
  }

  #bw-auth-controller {
    padding: 24px !important;
  }
}

/* Small Mobile Screens (320px - 480px) */
@media (max-width: 480px) {
  .bw-layout {
    padding: 12px;
    gap: 16px;
  }

  .bw-sidebar {
    padding: 16px;
    border-radius: var(--bw-radius-md);
  }

  .bw-brand {
    font-size: 22px;
    margin-bottom: 16px;
  }

  .bw-brand svg {
    width: 30px;
    height: 30px;
  }

  .bw-nav {
    gap: 6px;
  }

  .bw-nav-item {
    padding: 10px 14px;
    font-size: 14px;
  }

  .bw-hero {
    padding: 20px 14px !important;
    border-radius: var(--bw-radius-md);
  }

  .bw-hero h1 {
    font-size: 28px !important;
    margin-bottom: 16px !important;
  }

  .bw-hero p {
    font-size: 14px !important;
    margin-bottom: 24px !important;
  }

  .tile {
    flex: 0 0 140px; /* Подходит для экранов 320px без обрезки */
  }

  .tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
  }

  .tile .art {
    margin-bottom: 8px;
  }

  .tile .fresh {
    top: 8px;
    right: 8px;
    font-size: 9px;
    padding: 3px 6px;
  }

  .tile .go span {
    padding: 8px 16px;
    font-size: 12px;
  }

  .shelf-track {
    gap: 12px;
  }

  .bw-btn {
    padding: 12px 20px;
    font-size: 14px;
    width: 100%; /* Полноширинные кнопки для удобного тапа */
  }

  .bw-auth-container {
    padding: 8px;
  }

  #bw-auth-controller {
    padding: 16px !important;
  }

  .bw-input {
    padding: 12px;
    font-size: 14px;
  }

  .playfield-bar {
    padding: 8px 12px;
  }

  .playfield-bar .title {
    font-size: 13px;
  }

  .playfield-bar button {
    padding: 6px 12px;
    font-size: 12px;
  }
}