/* --- DEFINICIÓN DE TEMAS Y VARIABLES --- */
:root {
  --font-family: "Poppins", sans-serif;
  --navbar-height: 70px;
  --radius: 12px;
  --Color-Cards: #ffffff;
}
html.theme-library {
  --color-background: #1f1a14;
  --color-surface: #342a21;
  --color-primary: #d4af37;
  --color-primary-rgb: 212, 175, 55;
  --color-secondary: #8a0303;
  --color-text-primary: #e8e0d4;
  --color-text-secondary: #a39b90;
  --color-border: #4a3f35;
  --color-shadow: rgba(212, 175, 55, 0.1);
  --color-free: #386641;
}
html.theme-sorcerer {
  --color-background: #1a1423;
  --color-surface: #282136;
  --color-primary: #00f5d4;
  --color-primary-rgb: 0, 245, 212;
  --color-secondary: #c74da2;
  --color-text-primary: #e4e6eb;
  --color-text-secondary: #a0a3b8;
  --color-border: #3f3851;
  --color-shadow: rgba(0, 245, 212, 0.15);
  --color-free: #52b788;
}
html.theme-noir {
  --color-background: #0f1014;
  --color-surface: #1c1e28;
  --color-primary: #00aaff;
  --color-primary-rgb: 0, 170, 255;
  --color-secondary: #aa00ff;
  --color-text-primary: #daddf0;
  --color-text-secondary: #818398;
  --color-border: #3f3f4a;
  --color-shadow: rgba(0, 170, 255, 0.15);
  --color-free: #00ff41;
}

/* --- ESTILOS GLOBALES --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scroll-behavior: smooth;
}
body {
  font-family: var(--font-family);
  background-color: var(--color-background);
  color: var(--color-text-primary);
  line-height: 1.7;
  transition: background-color 0.3s ease, color 0.3s ease;
  padding-top: var(--navbar-height);
}
.container {
  width: 90%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 0;
}
h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  color: var(--color-primary);
  border-bottom: 1px solid var(--color-primary);
  padding-bottom: 0.5rem;
}
h3 {
  color: var(--color-primary);
  margin-bottom: 1rem;
}

/* --- COMPONENTES --- */

/* Barra de Navegación */
.top-navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--navbar-height);
  background: rgba(from var(--color-surface) r g b / 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
  z-index: 1000;
}
.navbar-content {
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
}
.navbar-brand {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-text-primary);
  text-decoration: none;
}
.navbar-brand:hover {
  color: var(--color-primary);
}
.nav-links {
  display: flex;
  gap: 2rem;
  align-items: center;
}
.nav-links a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.3s;
}
.nav-links a:hover {
  color: var(--color-primary);
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 2rem;
}
.theme-btn {
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}
.theme-btn:hover {
  color: var(--color-primary);
  transform: scale(1.1);
}
.hamburger-btn {
  display: none; /* Oculto en escritorio */
  background: transparent;
  border: none;
  color: var(--color-text-primary);
  font-size: 2rem;
  cursor: pointer;
  z-index: 1010;
}

/* Cabecera Principal */
.main-header {
  padding: 6rem 0;
  text-align: center;
  position: relative;
  background-image: url(../img/FondoMesa.jpg);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}
.main-header::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(18, 18, 18, 0.7);
}
.header-content {
  position: relative;
  z-index: 2;
}
.logo-header {
  font-size: 4rem;
  text-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}
.subtitle {
  font-size: 1.1rem;
  color: var(--color-text-secondary);
  margin-top: 0.5rem;
}
.content-section {
  margin-bottom: 2rem;
}

/* Controles de Filtro */
.controls-container {
  padding: 1.5rem;
  margin-bottom: 2rem;
  background: var(--color-surface);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.main-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
  width: 100%;
}
.catalog-search {
  flex-grow: 1;
  min-width: 250px;
}
.catalog-search input {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 1rem;
  transition: all 0.3s;
}
.catalog-search input:focus {
  outline: 0;
  border-color: var(--color-primary);
  box-shadow: 0 0 10px var(--color-shadow);
}
.advanced-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  width: 100%;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.filter-group label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}
.filter-group select {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  padding: 0.75rem;
  border-radius: var(--radius);
  font-size: 1rem;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23b3b3b3%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.6-3.6%205.4-7.9%205.4-12.9%200-5-1.8-9.2-5.4-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7em top 50%;
  background-size: 0.65em auto;
}
.filter-group select option {
  background: var(--color-background);
  color: var(--color-text-primary);
}
.filter-group select:focus {
  outline: 0;
  border-color: var(--color-primary);
}

/* Tarjetas (Juegos y Noticias) */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
}
.card {
  background-color: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-10px);
  box-shadow: 0 10px 30px var(--color-shadow);
}
.card a {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}
.card__image {
  width: 100%;
  height: 200px; /* Aumentado ligeramente para dar más espacio */
  object-fit: contain; /* MODIFICADO: Muestra la imagen completa */
  background-color: var(
    --Color-Cards
  ); /* MODIFICADO: Rellena el espacio sobrante */
  display: block;
}
.card__body {
  padding: 1.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}
.card__title {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
  color: var(--color-text-primary);
  word-break: break-word;
}
.card__description {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  flex-grow: 1;
  word-break: break-word;
}
.game-card .card-image-container {
  position: relative;
}
.game-card__platform {
  position: absolute;
  top: 1rem;
  left: 1rem;
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
}
.game-card__price {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--color-primary);
  color: var(--color-background);
}
#no-results {
  text-align: center;
  padding: 3rem;
  background: var(--color-surface);
  border-radius: var(--radius);
  grid-column: 1 / -1;
}
.news-item .card__body {
  border-top: 3px solid var(--color-secondary);
}

/* Perfil de Juego */
.game-profile-header {
  height: 60vh;
  background-size: cover;
  background-position: center;
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 2rem;
  margin-top: calc(-1 * var(--navbar-height));
}
.game-profile-header::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    to top,
    var(--color-background) 15%,
    transparent 80%
  );
}
.game-title-overlay {
  position: relative;
  z-index: 2;
  color: #fff;
  font-size: 3.5rem;
  font-weight: 700;
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}
#game-profile-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-top: -5rem;
  position: relative;
  z-index: 3;
}
.profile-main-content,
.profile-sidebar {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.profile-section {
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius);
}
.profile-section h2 {
  font-size: 1.5rem;
  color: var(--color-primary);
}
.profile-video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}
.profile-video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}
.profile-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}
.gallery-image {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.3s;
}
.gallery-image:hover {
  transform: scale(1.05);
}
.profile-buy-button {
  display: block;
  width: 100%;
  padding: 1rem;
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: var(--color-background);
  background: var(--color-primary);
  border-radius: var(--radius);
  transition: all 0.3s;
}
.profile-buy-button:hover {
  filter: brightness(1.2);
  box-shadow: 0 0 15px var(--color-shadow);
}
.back-link-container {
  text-align: center;
  margin-top: 2rem;
}
.back-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}
.details-list {
  list-style: none;
  padding: 0;
}
.details-list li {
  display: flex;
  align-items: center;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
}
.details-list svg {
  width: 24px;
  height: 24px;
  margin-right: 10px;
  fill: var(--color-secondary);
}
.profile-main-content p {
  text-align: justify;
  hyphens: auto;
  word-break: break-word; /* AÑADIDO: Evita el desbordamiento de texto */
}
.ludoteca-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}
.ludoteca-actions button {
  flex-grow: 1;
  padding: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  border: 2px solid var(--color-border);
  background-color: var(--color-surface);
  color: var(--color-text-secondary);
  transition: all 0.2s ease-in-out;
}
.ludoteca-actions button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.ludoteca-actions button.active {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-background);
  font-weight: 700;
}
.gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  display: flex;
  z-index: 1050;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.gallery-modal.open {
  opacity: 1;
  visibility: visible;
}
.gallery-modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}
.gallery-modal-image {
  display: block;
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  margin: 0 auto;
}
.modal-navigation-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #fff;
  font-size: 3rem;
  cursor: pointer;
  padding: 1rem;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  z-index: 1060;
}
.modal-navigation-button:hover {
  opacity: 1;
}
.modal-prev {
  left: 1rem;
}
.modal-next {
  right: 1rem;
}
.modal-close-button {
  position: absolute;
  top: 1rem;
  right: 2rem;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 2.5rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  z-index: 1060;
}
.modal-close-button:hover {
  opacity: 1;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem;
  margin-top: 2rem;
  color: var(--color-text-secondary);
  border-top: 1px solid var(--color-border);
}

/* --- Media Queries (SECCIÓN CORREGIDA) --- */
@media (min-width: 992px) {
  #game-profile-container {
    grid-template-columns: 3fr 1fr;
  }
  .profile-sidebar {
    min-width: 300px;
  }
}
@media (max-width: 768px) {
  .navbar-content {
    flex-wrap: nowrap; /* Evita que los elementos de la navbar se desplacen hacia abajo */
  }
  .nav-links {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--navbar-height));
    background-color: var(--color-surface);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2.5rem;
    /* Oculto por defecto fuera de la pantalla */
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    /* Asegura que no haya un display: none; */
    display: flex;
  }
  .nav-links.active {
    transform: translateX(0); /* Mueve el menú a la vista */
  }
  .nav-links a {
    font-size: 1.8rem;
  }
  .hamburger-btn {
    display: block; /* Muestra el botón de hamburguesa en móviles */
  }

  /* Reducción de tamaño de títulos para móviles */
  .logo-header {
    font-size: 2.8rem;
  }
  .game-title-overlay {
    font-size: 2.5rem;
  }

  .main-controls,
  .advanced-filters {
    flex-direction: column;
  }
}
