/* =============================================
   Pixjaro! — Estilos Portal
   Tema: colorido infantil
   ============================================= */

/* --- Reset y base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-primary: #FF6B6B;
  --color-secondary: #4ECDC4;
  --color-accent: #FFE66D;
  --color-purple: #A06CD5;
  --color-orange: #FF8A5C;
  --color-blue: #6BCBFF;
  --color-green: #51CF66;
  --color-pink: #F06595;
  --color-bg: #FFF5F5;
  --color-bg-card: #FFFFFF;
  --color-text: #2D3436;
  --color-text-light: #636E72;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 15px rgba(0,0,0,0.1);
  --shadow-hover: 0 8px 25px rgba(0,0,0,0.15);
  --max-width: 1200px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Header (estilo plataformas) --- */
.header {
  background: linear-gradient(180deg, #6BCBFF 0%, #48A9E6 40%, #FF8A5C 80%, #FF6B6B 100%);
  color: white;
  padding: 2.5rem 1rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  min-height: 200px;
}

/* Nubes decorativas */
.header::before {
  content: '☁️☁️☁️';
  position: absolute;
  top: 10px;
  left: -10px;
  right: -10px;
  font-size: 2.5rem;
  letter-spacing: 2rem;
  opacity: 0.3;
  animation: floatClouds 8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes floatClouds {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(20px); }
}

/* Ola de tierra/cesped al final */
.header::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: -10%;
  right: -10%;
  height: 40px;
  background: #51CF66;
  border-radius: 50% 50% 0 0;
  z-index: 2;
}

/* Bloques de plataforma decorativos */
.header-decoration {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  height: 28px;
  z-index: 1;
  pointer-events: none;
  display: flex;
  justify-content: space-around;
  padding: 0 5%;
}

.header-decoration span {
  display: inline-block;
  width: 32px;
  height: 28px;
  background: #A06CD5;
  border-radius: 4px 4px 0 0;
  box-shadow: 0 4px 0 #7B52AB, 0 0 0 2px #333;
  opacity: 0.7;
}

.header-decoration span:nth-child(2) { background: #FFE66D; box-shadow: 0 4px 0 #D4B84A, 0 0 0 2px #333; }
.header-decoration span:nth-child(4) { background: #F06595; box-shadow: 0 4px 0 #C44A74, 0 0 0 2px #333; }

/* Personaje pixel-art con CSS */
.header-character {
  position: absolute;
  bottom: 40px;
  left: 20%;
  width: 28px;
  height: 40px;
  background: #FFE66D;
  border-radius: 8px 8px 4px 4px;
  z-index: 3;
  animation: bounce 1.2s ease-in-out infinite;
  pointer-events: none;
}

.header-character::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 2px;
  width: 22px;
  height: 14px;
  background: #FFE66D;
  border-radius: 10px 10px 0 0;
}

.header-character::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 5px;
  height: 5px;
  background: #2D3436;
  border-radius: 50%;
  box-shadow: 10px 0 0 #2D3436;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.header-content {
  position: relative;
  z-index: 4;
}

.header-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -1px;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.15);
}

.header-subtitle {
  font-size: 1.1rem;
  opacity: 0.95;
  margin-top: 0.25rem;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

/* --- Instalación proactiva PWA (banner) --- */
.install-prompt {
  background: linear-gradient(135deg, var(--color-primary), var(--color-orange));
  color: white;
  padding: 0;
  overflow: hidden;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { max-height: 0; opacity: 0; }
  to   { max-height: 100px; opacity: 1; }
}

.install-prompt-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.install-prompt-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.install-prompt-text {
  flex: 1;
  min-width: 0;
}

.install-prompt-text strong {
  display: block;
  font-size: 0.95rem;
}

.install-prompt-text span {
  display: block;
  font-size: 0.8rem;
  opacity: 0.9;
  margin-top: 0.1rem;
}

.install-prompt-btn {
  flex-shrink: 0;
  padding: 0.5rem 1.2rem;
  border: 2px solid white;
  border-radius: 50px;
  background: rgba(255,255,255,0.25);
  color: white;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.install-prompt-btn:hover {
  background: rgba(255,255,255,0.4);
  transform: scale(1.05);
}

.install-prompt-btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

.install-prompt-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.15);
  color: white;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.install-prompt-close:hover {
  background: rgba(0,0,0,0.3);
}

/* --- Main --- */
.main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem;
  width: 100%;
}

/* --- Filtros --- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  justify-content: center;
}

.filter-btn {
  padding: 0.5rem 1.2rem;
  border: 2px solid transparent;
  border-radius: 50px;
  background: white;
  color: var(--color-text-light);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}

.filter-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.filter-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* --- Ads: espacio reservado, no flotante --- */
.ad-band {
  display: none;
  margin: 0 0 1.5rem;
}

.ad-slot {
  width: 100%;
  min-height: 96px;
  border: 2px dashed rgba(45,52,54,0.16);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.ad-label {
  position: absolute;
  top: 0.35rem;
  left: 0.55rem;
  font-size: 0.65rem;
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ad-placeholder {
  color: var(--color-text-light);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem;
}

.ad-slot[data-ad-state="disabled"] {
  display: none;
}

.ad-slot[data-ad-state="production-pending"] {
  background: #fff;
}

/* --- Grid de juegos --- */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

/* --- Tarjeta de juego --- */
.game-card {
  background: var(--color-bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: all 0.3s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
}

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

.game-card-banner {
  height: 8px;
  flex-shrink: 0;
}

.game-card-body {
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.game-card-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--color-bg);
}

.game-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.game-card-info {
  flex: 1;
  min-width: 0;
}

.game-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text);
}

.game-card-description {
  font-size: 0.85rem;
  color: var(--color-text-light);
  line-height: 1.4;
  margin-top: 0.25rem;
}

.game-card-instructions {
  margin-top: 0.45rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  background: #F7FBFA;
  color: var(--color-text);
  font-size: 0.8rem;
  line-height: 1.35;
}

.game-card-instructions span {
  display: block;
  margin-bottom: 0.12rem;
  color: var(--color-text-light);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

/* --- Tags / badges --- */
.game-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.tag-estado {
  background: var(--color-accent);
  color: #856404;
}

.tag-estado.jugable {
  background: var(--color-green);
  color: #fff;
}

.tag-estado.completo {
  background: var(--color-blue);
  color: #fff;
}

.tag-categoria {
  background: #E8F8F5;
  color: #0E6251;
}

.tag-offline {
  background: #E8F8F5;
  color: #0E6251;
}

.tag-offline.no {
  background: #FDF2E9;
  color: #7B7B7B;
}

/* --- Acciones en tarjeta --- */
.game-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-play {
  flex: 1;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--color-secondary);
  color: white;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  text-align: center;
}

.btn-play:hover {
  filter: brightness(1.1);
  transform: scale(1.02);
}

.btn-install-game {
  padding: 0.6rem 0.8rem;
  border: 2px solid var(--color-secondary);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-install-game:hover {
  background: var(--color-secondary);
  color: white;
}

/* --- Status bar --- */
.status-bar {
  margin-top: 2rem;
  padding: 0.75rem 1rem;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-text-light);
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #CCC;
  flex-shrink: 0;
}

.status-indicator.online {
  background: var(--color-green);
  box-shadow: 0 0 6px rgba(81,207,102,0.5);
}

.status-indicator.offline {
  background: var(--color-orange);
}

.status-indicator.error {
  background: var(--color-primary);
}

/* --- Footer --- */
.footer {
  background: var(--color-text);
  color: white;
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.9rem;
  opacity: 0.85;
}

.footer-legal {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  opacity: 0.7;
}

.footer-link {
  color: var(--color-blue);
  text-decoration: none;
  transition: opacity 0.2s;
}

.footer-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .header-title {
    font-size: 1.8rem;
  }

  .games-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    gap: 0.35rem;
  }

  .filter-btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.9rem;
  }

  .game-card-body {
    padding: 0.75rem 1rem 1rem;
  }
}

/* --- Estados de carga/error --- */
.games-grid.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  color: var(--color-text-light);
  font-size: 1.1rem;
}

.games-grid.error {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  color: var(--color-primary);
  font-size: 1.1rem;
}
