:root {
  --bg: #131a2b;
  --bg-2: #1c2540;
  --ink: #eef1f8;
  --ink-soft: #9aa5c2;
  --line: rgba(238, 241, 248, 0.12);
  --sun: #ffc845;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 600px at 15% -10%, #26325a 0%, transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--sun); outline-offset: 3px; }

/* La page tient dans la fenêtre : en-tête, filtres, puis la liste (qui défile seulement s'il y a beaucoup de jeux). */
.wrap {
  max-width: 1100px; margin: 0 auto; height: 100vh; height: 100dvh;
  padding: clamp(18px, 6vh, 64px) 16px clamp(14px, 3vh, 32px);
  display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: clamp(10px, 2.2vh, 20px);
}
.head h1 { font-size: clamp(1.8rem, min(6vw, 7vh), 3.4rem); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 8px; line-height: 1.05; }
.head p { margin: 0; color: var(--ink-soft); font-size: 1.1rem; max-width: 46ch; line-height: 1.5; }

/* Filtres */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--bg-2);
  color: var(--ink-soft); padding: 7px 14px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { color: var(--ink); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .count { font-size: .75rem; padding: 1px 7px; border-radius: 999px; background: rgba(127, 127, 127, .22); }

/* Liste */
.list-wrap { min-height: 0; display: flex; }
.games {
  flex: 1; list-style: none; margin: 0; padding: 2px 2px 8px; min-height: 0; overflow: auto; overscroll-behavior: contain;
  display: grid; gap: 12px; align-content: start; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  scrollbar-width: thin;
}
/* Un fondu signale qu'il reste des jeux plus bas (ou plus haut). */
.games.more { -webkit-mask-image: linear-gradient(#000 calc(100% - 56px), transparent); mask-image: linear-gradient(#000 calc(100% - 56px), transparent); }
.games.more.scrolled { -webkit-mask-image: linear-gradient(transparent, #000 40px, #000 calc(100% - 56px), transparent); mask-image: linear-gradient(transparent, #000 40px, #000 calc(100% - 56px), transparent); }
.games:not(.more).scrolled { -webkit-mask-image: linear-gradient(transparent, #000 40px); mask-image: linear-gradient(transparent, #000 40px); }

.game {
  --accent: var(--sun);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 18px; min-height: 100%;
  background: var(--bg-2); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  color: inherit; text-decoration: none;
  transition: transform .15s ease, border-color .15s ease, background .15s;
  animation: rise .35s cubic-bezier(.2, 1.2, .4, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.game:hover, .game:focus-visible { transform: translateY(-2px); border-color: var(--accent); background: #212c4b; }
.game .icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.7rem;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}
.game .body { min-width: 0; display: grid; gap: 4px; }
.game h2 { margin: 0; font-size: 1.2rem; font-weight: 800; }
.game p {
  margin: 0; color: var(--ink-soft); line-height: 1.4; font-size: .92rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.meta span { white-space: nowrap; font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: rgba(238, 241, 248, .07); color: var(--ink-soft); }
.go { padding: 8px 14px; border-radius: 999px; font-weight: 700; background: var(--accent); color: #1a1400; white-space: nowrap; }
.empty { color: var(--ink-soft); }
.gamepad-nav :focus { outline: 3px solid var(--sun); outline-offset: 3px; }

/* Téléphone : liste d'une colonne, filtres sur une ligne qui défile horizontalement. */
@media (max-width: 600px) {
  .head p { font-size: .98rem; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .filters::-webkit-scrollbar { display: none; }
  .chip { flex: none; padding: 6px 12px; }
  .games { grid-template-columns: 1fr; gap: 10px; }
  .game { padding: 12px; gap: 12px; }
  .game .icon { width: 44px; height: 44px; font-size: 1.4rem; }
  .game h2 { font-size: 1.05rem; }
  .game p { -webkit-line-clamp: 1; font-size: .85rem; }
  .go { display: none; }
}
@media (max-height: 700px) {
  .head p { display: none; }
  .game p { -webkit-line-clamp: 1; }
}
/* Écrans bas (petit téléphone, téléphone à l'horizontale) : cartes réduites à l'essentiel. */
@media (max-height: 700px) and (max-width: 600px), (max-height: 520px) {
  .meta { display: none; }
  .games { gap: 8px; }
  .game { padding: 10px 12px; }
  .game .icon { width: 40px; height: 40px; font-size: 1.3rem; border-radius: 12px; }
}
@media (max-height: 520px) {
  .game p { display: none; }
  .go { padding: 6px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .game { transition: none; animation: none; }
}
