:root {
  --bg: #0a0a0b;
  --tile-bg: #141415;
  --border: #262626;
  --fg: #f5f5f7;
  --fg-muted: #8e8e93;
  --fg-faint: #444;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(24px, 4.5vw, 64px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.serif { font-family: 'Crimson Pro', Georgia, serif; }

a { color: inherit; text-decoration: none; }

:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }

svg.icon {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- shell ---------- */

.app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, #1a1a1c 0%, #0a0a0b 100%);
  user-select: none;
}

.bg-layer { position: absolute; inset: 0; z-index: 0; overflow: hidden; }

.bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  /* blur fuerte + escala: el arte aporta color, no detalle */
  transform: scale(1.25);
  filter: blur(64px) saturate(1.35);
  opacity: 0;
  transition: opacity 900ms var(--ease);
}

.bg.is-visible { opacity: 0.45; }

/* dos halos que respiran: dan movimiento al fondo sin depender de la nitidez de la imagen */
.glow {
  position: absolute;
  width: 65vmax;
  height: 65vmax;
  border-radius: 50%;
  filter: blur(70px);
  mix-blend-mode: screen;
  will-change: transform;
}

.glow--a {
  top: -28vmax;
  left: -14vmax;
  background: radial-gradient(circle, rgba(96, 132, 255, 0.42), rgba(96, 132, 255, 0) 62%);
  animation: drift-a 38s var(--ease) infinite alternate;
}

.glow--b {
  bottom: -32vmax;
  right: -18vmax;
  background: radial-gradient(circle, rgba(226, 104, 168, 0.32), rgba(226, 104, 168, 0) 62%);
  animation: drift-b 52s var(--ease) infinite alternate;
}

@keyframes drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(14vmax, 8vmax, 0) scale(1.18); }
}

@keyframes drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.1); }
  to   { transform: translate3d(-12vmax, -9vmax, 0) scale(0.92); }
}

.bg-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(10, 10, 11, 0.2) 0%, rgba(10, 10, 11, 0.8) 55%, var(--bg) 100%);
}

/* cierra los bordes para que los halos no queden cortados contra el marco */
.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 45%, rgba(10, 10, 11, 0) 35%, rgba(10, 10, 11, 0.75) 100%);
}

/* ---------- barra de estado ---------- */

.topbar {
  position: relative;
  z-index: 50;
  flex: 0 0 auto;
  height: 96px;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.topbar-left { display: flex; align-items: center; gap: 40px; }

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark { width: 20px; height: 20px; background: #fff; }

.brand-name {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4em;
}

.topnav { display: flex; gap: 32px; }

.topnav a {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--fg-muted);
  transition: color 250ms var(--ease);
}

.topnav a:hover, .topnav a.is-active { color: #fff; }
.topnav a.is-active { font-weight: 700; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
}

.status-item { display: flex; align-items: center; gap: 8px; }
.status-item .icon { font-size: 14px; }
.status-divider { width: 1px; height: 24px; background: var(--border); }
.user { color: #fff; gap: 12px; }

.avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1) center/cover no-repeat;
  font-size: 12px;
}

.avatar.has-photo .icon { display: none; }

/* ---------- zona interactiva ---------- */

main {
  position: relative;
  z-index: 10;
  flex: 1 1 auto;
  min-height: 0;
  /* sin esto el contenido del estante estira el flex item y nada llega a desbordar */
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0;
}

.detail { margin: 0 var(--gutter) 40px; }

.detail h1 {
  margin: 0 0 8px;
  font-family: 'Crimson Pro', Georgia, serif;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(38px, 5.2vw, 60px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.meta {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4em;
  color: var(--fg-muted);
}

.meta .sep {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--fg-faint);
  flex: 0 0 auto;
}

/* ---------- tiles ---------- */

.tiles-wrap { position: relative; min-width: 0; }

.tiles {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  /* el padding deja aire para que la tile agrandada no se corte contra los bordes */
  padding: 32px var(--gutter);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.tiles::-webkit-scrollbar { display: none; }

/* zonas de borde para desplazar el estante con el mouse */
.edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: clamp(48px, 6vw, 88px);
  padding: 0;
  border: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity 300ms var(--ease);
}

/* apagada = no molesta a las tiles que tiene debajo */
.edge:not(.is-available) { pointer-events: none; }

.edge--left {
  left: 0;
  background: linear-gradient(to right, var(--bg) 10%, rgba(10, 10, 11, 0) 100%);
}

.edge--right {
  right: 0;
  background: linear-gradient(to left, var(--bg) 10%, rgba(10, 10, 11, 0) 100%);
}

.edge.is-available { opacity: 0.85; }
.edge.is-available:hover, .edge.is-available:focus-visible { opacity: 1; }

/* flechita dentro de la zona */
.edge::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-top: 1px solid rgba(255, 255, 255, 0.55);
  border-right: 1px solid rgba(255, 255, 255, 0.55);
  transition: border-color 250ms var(--ease);
}

.edge--left::after { transform: rotate(-135deg); }
.edge--right::after { transform: rotate(45deg); }
.edge:hover::after { border-color: #fff; }

.tile {
  position: relative;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--tile-bg) center/cover no-repeat;
  cursor: pointer;
  overflow: hidden;
  scroll-snap-align: start;
  transition: transform 500ms var(--ease), opacity 500ms var(--ease), filter 500ms var(--ease);
}

/* tile en reposo: cuadrada, gris, apagada */
.tile--game {
  width: 176px;
  aspect-ratio: 1;
  filter: grayscale(1);
  opacity: 0.6;
}

.tile--game:hover { transform: scale(1.05); opacity: 1; filter: grayscale(0); }

/* tile seleccionada: apaisada, a color, con marco blanco */
.tile--active {
  width: min(420px, 46vw);
  aspect-ratio: 16 / 9;
  filter: grayscale(0.5);
  opacity: 1;
  border: none;
  outline: 3px solid #fff;
  outline-offset: 4px;
  transform: scale(1.02);
  z-index: 20;
}

.tile--active:hover { filter: grayscale(0); }

.tile--active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
}

.tile-start {
  position: absolute;
  z-index: 1;
  left: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: #fff;
}

.tile-start .play {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: #fff;
  color: #000;
}

.tile-start .play svg { width: 16px; height: 16px; fill: currentColor; }

/* placeholder cuando el juego no tiene imagen */
.tile-initials {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: 'Crimson Pro', Georgia, serif;
  font-style: italic;
  font-size: 28px;
  color: #3a3a3d;
}

/* tile final: todos los juegos */
.tile--all {
  width: 176px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  gap: 8px;
  color: var(--fg-faint);
  transition: color 250ms var(--ease);
}

.tile--all:hover { color: #fff; }
.tile--all svg { width: 30px; height: 30px; }

.tile--all span {
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

/* ---------- contexto inferior ---------- */

.bottombar {
  position: relative;
  z-index: 50;
  flex: 0 0 auto;
  height: 128px;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
}

.slots { display: flex; gap: 48px; }

.slot-label {
  margin: 0 0 4px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
}

.slot-value {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Crimson Pro', Georgia, serif;
  font-style: italic;
  font-size: 11px;
}

.slot-value .icon { font-size: 15px; }

/* ---------- pantallas chicas ---------- */

@media (max-width: 860px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; }

  /* la barra se apila: marca / secciones / estado */
  .topbar {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding-block: 18px 4px;
  }

  .topbar-left { flex-direction: column; align-items: flex-start; gap: 14px; }
  .topbar-right { justify-content: space-between; }
  .topnav { gap: 22px; }
  .status-divider { display: none; }

  /* en desktop el contenido se apoya contra el borde inferior; en celular arranca arriba */
  main { justify-content: flex-start; padding-top: 12px; }

  .detail { margin-bottom: 24px; }
  .detail h1 { font-size: clamp(40px, 11vw, 64px); }
  .meta { gap: 10px; font-size: 10px; letter-spacing: 0.25em; }

  .tiles { gap: 12px; padding-block: 4px 8px; }
  .tile--game, .tile--all { width: 148px; }
  .tile--active { width: min(80vw, 420px); }

  /* las zonas de borde dependen del hover: en touch no hacen nada */
  .edge { display: none; }

  .bottombar { height: auto; padding-block: 28px 36px; }
  .slots { flex-wrap: wrap; gap: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
