/* ═══════════════════════════════════════════════
   GLOBAL RESET & TOKENS
════════════════════════════════════════════════ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg-base: #0f172a;
  --bg-surface: #1e293b;
  --bg-card: #1e293b;
  --accent: #8b5cf6;
  --accent-glow: rgba(139, 92, 246, 0.35);
  --text-primary: #f8fafc;
  --text-muted: #888899;
  --radius-card: 12px;
  --header-h: 50px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 6px 16px;
  text-decoration: none;
  backdrop-filter: blur(4px);
  cursor: pointer;
  font-weight: 900;
  font-size: 16px;
  color: #fff;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: background 0.2s;
  border: none;
  /* For button elements */
}

.brand-logo:hover {
  background: rgba(255, 255, 255, 0.15);
}

.brand-logo span {
  color: #8b5cf6;
}

.container {
  width: 100%;
  padding: 0 20px;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-weight: 800;
  letter-spacing: -0.02em;
}

img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  display: none !important;
}

.view-transition {
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══════════════════════════════════════════════
   LOADER STYLES
════════════════════════════════════════════════ */
.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(124, 92, 252, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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


/* ═══════════════════════════════════════════════
   CLEAN GAME GRID (Yandex Style)
════════════════════════════════════════════════ */
.main-catalog-grid,
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 15px;
  padding: 20px;
  width: 100%;
  box-sizing: border-box;
  align-items: start;
}



/* My Games Section */
.my-games-section {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0 auto 20px auto;
  padding: 0 20px;
  box-sizing: border-box;
}

.my-games-label {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #1e293b;
  color: #94a3b8;
  /* Softer text color */
  padding: 8px 10px;
  border-radius: 12px;
  flex-shrink: 0;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.my-games-label:hover {
  background: #2dd4bf;
  /* Or your brand color */
  color: #111118;
}

.my-games-text {
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
  text-align: left;
  letter-spacing: 0.5px;
}

.my-games-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  /* Firefox */
  padding: 4px 0;
  /* Space for hover shadow */
}

.my-games-list::-webkit-scrollbar {
  display: none;
}

/* Safari/Chrome */

.my-game-item {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  /* Smooth iOS-like squares */
  flex-shrink: 0;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  background: #111118;
}

.my-game-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.5);
}

.my-game-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.game-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  transition: transform 0.2s;
  min-width: 0;
  width: 100%;
  cursor: pointer;
  background: transparent;
}

.game-card:hover {
  transform: translateY(-4px);
}

.game-card:active {
  transform: scale(0.96);
}

.card-image-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1;
  /* Mobile: square icon */
  border-radius: 12px;
  overflow: hidden;
  background: #1e293b;
  position: relative;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .card-image-wrapper {
    aspect-ratio: 16 / 9;
    /* Desktop: wide cover */
  }
}

/* Badges System */
.game-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: #ffffff;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.5px;
}

.badge-top {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.badge-hot {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
}

.badge-new {
  background: linear-gradient(135deg, #10b981, #059669);
}

.card-image-wrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-title {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
  text-align: left;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.2;
  padding: 0 2px;
}

/* Cross-promo shared */
.cross-promo {
  padding: 20px 0 28px;
  background: var(--bg-base);
}

.cross-promo-title {
  margin: 0 0 4px;
  padding: 0 14px;
  font-size: 16px;
  font-weight: 700;
}

/* Shared button */
.btn-icon {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background 0.15s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
}


/* ═══════════════════════════════════════════════
   VIEW 1: CATALOG
════════════════════════════════════════════════ */
#view-catalog {
  min-height: 100dvh;
  padding-bottom: 24px;
}

.app-header {
  background: transparent;
  border-bottom: none;
}

.app-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 0;
  /* Horizontal padding comes from .container */
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header-icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #cbd5e1;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  backdrop-filter: blur(4px);
}

.header-icon-btn:hover {
  color: #8b5cf6;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  letter-spacing: -0.3px;
}

.logo-icon {
  font-size: 22px;
  line-height: 1;
}

.logo-text strong {
  color: var(--accent);
}


/* VIEW 2: DETAILS */
#view-details {
  min-height: 100dvh;
  overflow-y: auto;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  /* Group elements to the left */
  gap: 12px;
  /* Fixed space between burger and logo */
  padding: 15px 20px;
  box-sizing: border-box;
}

.details-top-nav {
  padding: 10px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  background: transparent;
  width: 100%;
}

.details-game-info-bar {
  padding: 10px 20px 20px 20px;
  width: 100%;
  box-sizing: border-box;
}

.details-title-group {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  margin: 0 15px;
  min-width: 0;
}

.details-main-title {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  margin: 0;
  line-height: 1.2;
}

.details-sub-text {
  font-size: 13px;
  color: #94a3b8;
  margin-top: 4px;
}

.details-game-icon {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  .details-game-icon {
    width: 80px;
    height: 80px;
  }

  .details-main-title {
    font-size: 24px;
  }
}

/* 2. Hero Cover */
.details-hero {
  width: 100%;
  margin: 0 0 15px 0;
  border-radius: 0;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-card);
  cursor: pointer;
}

/* 3. Play Button Wrapper */
.details-play-wrapper {
  margin-bottom: 20px;
  padding: 0 20px;
  box-sizing: border-box;
}

.play-btn {
  width: 100%;
  margin: 0;
  padding: 15px;
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  color: white;
  border-radius: 8px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.5px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-btn .play-icon {
  font-size: 20px;
  margin-right: 8px;
}

.play-btn:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

.play-btn:active {
  transform: scale(0.97);
}

/* 4. Hot Games (Cross-promo) */
.details-hot-games {
  padding: 0 20px;
  margin: 0 0 20px 0;
  width: 100%;
  box-sizing: border-box;
}

.details-hot-games h3 {
  color: #fff;
  font-size: 18px;
  margin: 0 0 12px 0;
}

.details-hot-games .games-grid {
  padding: 0;
  margin: 0;
  width: 100%;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 480px) {
  .details-hot-games .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

/* 5. Metadata: Title, Rating, Tags */
.details-metadata .container,
.details-text .container {
  display: flex;
  flex-direction: column;
}

.details-metadata {
  padding: 0 20px 20px 20px;
  box-sizing: border-box;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.details-title {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}

.details-rating {
  font-size: 14px;
  color: #fbbf24;
  font-weight: 600;
  margin-bottom: 15px;
}

.details-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-link {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  text-transform: capitalize;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.tag-link:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--accent);
  color: #fff;
}

.details-text {
  padding: 20px;
  box-sizing: border-box;
  color: #ddd;
  line-height: 1.6;
  font-size: 14px;
}

.details-section {
  margin-bottom: 20px;
}

.details-section h3 {
  color: #fff;
  font-size: 16px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.details-section p {
  margin: 0;
}

/* 7. Trailer */
.video-custom-poster {
  position: relative;
  cursor: pointer;
  border-radius: 0;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #111;
}

.video-custom-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.play-overlay::after {
  content: '';
  border-style: solid;
  border-width: 12px 0 12px 20px;
  border-color: transparent transparent transparent #fff;
  margin-left: 6px;
}

.video-custom-poster:hover .play-overlay {
  background: rgba(255, 0, 0, 0.9);
}

.video-custom-poster video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  outline: none;
}

/* 8. Screenshots strip */
.details-screenshots {
  display: flex;
  gap: 12px;
  padding: 0 0 30px 0;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.details-screenshots::-webkit-scrollbar {
  display: none;
}

.details-screenshots img {
  height: 180px;
  width: auto;
  border-radius: 16px;
  scroll-snap-align: start;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  background: var(--bg-card);
}


/* ═══════════════════════════════════════════════
   VIEW 3: PLAYER
════════════════════════════════════════════════ */
#view-player {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 9999;
  background: #000;
  display: flex;
  flex-direction: column;
}

/* Splash / Pre-roll overlay */
.player-splash {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #0f172a;
  background-size: cover;
  background-position: center;
  z-index: 20000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  cursor: pointer;
}

.player-splash::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: -1;
}

.splash-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 20px;
  z-index: 20002;
  box-sizing: border-box;
  display: flex;
  justify-content: flex-start;
}

.splash-back-btn {
  background: rgba(0, 0, 0, 0.5);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 8px 16px 8px 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s;
  position: relative;
  z-index: 20005;
}

.splash-back-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.splash-scroll-container {
  width: 100%;
  max-width: 800px;
  margin: auto;
  padding: 80px 20px 40px 20px;
  z-index: 20001;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
}

.splash-game-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
  width: 100%;
  min-width: 0;
}

.splash-game-info img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.splash-game-info h2 {
  color: white;
  font-size: 22px;
  font-weight: 800;
  margin: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.splash-cover-container {
  width: 100%;
  max-width: 600px;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  background: #1e293b;
}

.splash-cover-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#btn-start-iframe {
  width: 100%;
  max-width: 400px;
  margin-bottom: 24px;
  padding: 18px;
  font-size: 20px;
}

.splash-description {
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  max-width: 600px;
}

.floating-back-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  height: 32px;
  padding: 0 12px 0 12px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  z-index: 10001;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: all 0.2s;
  text-decoration: none;
}

#floating-back-btn.brand-logo {
  position: absolute;
  top: 6px;
  left: 10px;
  z-index: 10001;
  margin: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.floating-back-btn:hover,
#floating-back-btn.brand-logo:hover {
  background: #8b5cf6;
  border-color: #8b5cf6;
  transform: translateY(-1px);
}

#player-container {
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

#player-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 15px;
}

/* ═══════════════════════════════════════════════
   DESKTOP (WIDE SCREEN) REFINEMENTS
════════════════════════════════════════════════ */
@media (min-width: 768px) {

  /* 1. Details Layout Alignment */
  .details-top-nav .container,
  .details-game-info-bar .container,
  .details-content-container {
    max-width: 1200px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    width: 100% !important;
    padding: 0 20px !important;
    box-sizing: border-box !important;
  }

  /* 2. Hero & Button Refinements */
  .details-hero {
    max-height: 500px;
    border-radius: 20px;
    margin-top: 20px;
  }

  #btn-play-now {
    max-width: 400px;
    margin: 0 auto 30px auto;
    display: flex;
  }

  /* 3. Hot Games Grid Override */
  .details-hot-games .games-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  /* 4. Text Columns (Premium Look) */
  .details-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    width: 100%;
  }

  /* 5. Screenshots & Video */
  .details-screenshots img,
  .video-custom-poster {
    height: 240px;
  }
}

/* ═══════════════════════════════════════════════
   SIDEBAR (CATEGORIES MENU)
════════════════════════════════════════════════ */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 30000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100dvh;
  background: #0f172a;
  z-index: 30001;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.5);
}

.sidebar.active {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-title {
  font-size: 18px;
  font-weight: 800;
  color: #f8fafc;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
  scrollbar-width: none;
  /* Firefox */
}

.sidebar-content::-webkit-scrollbar {
  display: none;
}

/* Chrome/Safari */

.category-list {
  display: flex;
  flex-direction: column;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: #cbd5e1;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.category-item span {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.category-item:hover {
  background: #1e293b;
  color: #8b5cf6;
}