:root {
  --card-bg: rgba(255, 255, 255, 0.88);
  --accent: #2563eb;
  --header-h: 60px;
  --footer-h: 46px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: url('img/bg-1.png') no-repeat center center fixed;
  background-size: cover;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #fff;
  /* place pour header sticky et footer sticky (le perso flotte dans
     la gouttière droite en desktop, donc pas besoin d'espace en bas) */
  padding-top: var(--header-h);
  padding-bottom: calc(var(--footer-h) + 1.5em);
}

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

/* ---------- En-tête sticky : logo à gauche, recherche à droite ---------- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 1 auto;
}
.brand img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: contain;
  flex: 0 0 auto;
}
/* conteneur texte (nom + sous-titre) : pile verticale centrée dans le
   header. min-width:0 permet l'ellipsis du nom au lieu de le faire
   déborder sous le champ de recherche. */
.brand > span {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  overflow: hidden;
}
.brand .brand-name {
  display: block;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand .brand-sub {
  display: block;
  font-size: 0.7rem;
  line-height: 1.2;
  opacity: 0.7;
  white-space: nowrap;
}

#search {
  width: 100%;
  max-width: 320px;
  min-width: 0;
  flex: 1 1 140px;
  padding: 0.55em 1em;
  border: none;
  border-radius: 999px;
  font-size: 0.95em;
  outline: none;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

/* ---------- Recherche : aucun résultat ---------- */
.no-result {
  text-align: center;
  font-style: italic;
  display: none;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  padding: 2em;
}

/* ---------- Retour au catalogue (pages de catégorie) ---------- */
.back-link {
  max-width: 1100px;
  margin: 0.8em auto 0;
  padding: 0 1em;
}
.back-link a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.92em;
  padding: 0.45em 1em;
  border-radius: 999px;
  background: rgba(11, 18, 32, 0.55);
  transition: background 0.2s;
}
.back-link a:hover { background: rgba(11, 18, 32, 0.75); }

/* ---------- Menu des catégories (page d'accueil) ---------- */
.category-menu {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.6em 1em 2em;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}
.category-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  background: rgba(11, 18, 32, 0.55);
  border-radius: 16px;
  padding: 1.8em 1.2em;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.category-tile:hover {
  background: rgba(11, 18, 32, 0.78);
  transform: translateY(-4px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
}
.category-tile .cat-icon { font-size: 2.4rem; line-height: 1; }
.category-tile .cat-label { font-size: 1.2rem; font-weight: 800; }
.category-tile .cat-sub { font-size: 0.82em; opacity: 0.7; }

.intro-lead {
  max-width: 1100px;
  margin: 0.6em auto 0;
  padding: 0 1em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}
.intro-lead h1 { font-size: 1.5em; margin: 0.2em 0 0.15em; }
.intro-lead p { margin: 0; opacity: 0.85; font-size: 0.95em; }

/* ---------- Catégories collapsables ---------- */
.catalog { max-width: 1100px; margin: 0 auto; padding-top: 0.8em; }

.category {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.4em 1em 0.6em;
}

.category-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: rgba(11, 18, 32, 0.55);
  border: none;
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0.6em 0.9em;
  border-radius: 10px;
  margin-top: 0.6em;
  transition: background 0.2s;
}
.category-head:hover { background: rgba(11, 18, 32, 0.75); }

.category-head .chevron {
  transition: transform 0.25s ease;
  font-size: 0.9em;
  flex: 0 0 auto;
}
.category.collapsed .category-head .chevron { transform: rotate(-90deg); }

.category-head .cat-title {
  font-size: 1.15em;
  font-weight: 700;
  flex: 1 1 auto;
}
.category-head .cat-count {
  font-size: 0.8em;
  opacity: 0.7;
  flex: 0 0 auto;
}

.category-body {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}
/* une fois l'animation d'ouverture terminée, on laisse déborder
   les tooltips (sinon ils sont coupés sur la 1re/dernière rangée) */
.category-body.is-open {
  overflow: visible;
}
.category.collapsed .category-body {
  max-height: 0 !important;
  opacity: 0;
  overflow: hidden;
}

/* ---------- Sous-drawers (à l'intérieur d'un drawer) ---------- */
.subcategory {
  margin: 0.5em 0 0.2em;
}
.subcategory-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: rgba(11, 18, 32, 0.32);
  border: none;
  border-left: 3px solid rgba(148, 163, 184, 0.55);
  color: #e5e7eb;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0.42em 0.8em;
  border-radius: 8px;
  transition: background 0.2s;
}
.subcategory-head:hover { background: rgba(11, 18, 32, 0.55); }
.subcategory-head .chevron {
  transition: transform 0.25s ease;
  font-size: 0.8em;
  flex: 0 0 auto;
}
.subcategory.collapsed .subcategory-head .chevron { transform: rotate(-90deg); }
.subcategory-head .cat-title {
  font-size: 0.98em;
  font-weight: 600;
  flex: 1 1 auto;
}
.subcategory-head .cat-count {
  font-size: 0.72em;
  opacity: 0.65;
  flex: 0 0 auto;
}
.subcategory-body {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}
.subcategory-body.is-open { overflow: visible; }
.subcategory.collapsed .subcategory-body {
  max-height: 0 !important;
  opacity: 0;
  overflow: hidden;
}
/* grille un peu plus resserrée dans les sous-drawers */
.subcategory-body .grid { padding: 8px 2px 4px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
  padding: 12px 2px 4px;
}

/* ---------- Tuile de jeu ---------- */
.game {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 8px 6px 10px;
  color: #222;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.game:hover,
.game.tooltip-active {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  z-index: 25;
}
.game .thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  background: #eee;
}
.game .name {
  margin-top: 6px;
  font-size: 0.72em;
  line-height: 1.2;
  text-align: center;
  font-weight: 600;
  max-width: 90px;
}
.game .year { font-size: 0.62em; opacity: 0.6; }

/* Encadré spécial pour une app vedette (ex. suite Go) */
.game.featured {
  background: linear-gradient(160deg, #fef3c7, #fce7f3 55%, #ede9fe);
  border: 2px solid #f59e0b;
  box-shadow: 0 3px 14px rgba(245, 158, 11, 0.4);
  padding-top: 20px;
}
.game.featured:hover,
.game.featured.tooltip-active {
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.55);
}
.game.featured .name { color: #1e1b4b; }
.game.featured .year { color: #4c1d95; opacity: 0.75; }
.featured-badge {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #f59e0b, #ec4899);
  color: #fff;
  font-size: 0.58em;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Tooltip global, détaché des tuiles pour éviter que :hover fuie
   vers le drawer ou les fiches voisines. */
.game-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  width: min(200px, calc(100vw - 16px));
  max-height: calc(100vh - 24px);
  overflow: visible;
  background: rgba(20, 20, 20, 0.96);
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.72em;
  line-height: 1.3;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(var(--tip-left, -9999px), var(--tip-top, -9999px), 0);
  transition: opacity 0.15s, visibility 0s linear 0.15s;
  z-index: 80;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}
.game-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
.game-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: var(--arrow-x, 50%);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(20, 20, 20, 0.96);
}
.game-tooltip::before {
  content: "";
  position: absolute;
  left: var(--bridge-left, 50%);
  top: 100%;
  width: var(--bridge-w, 0px);
  height: var(--bridge-h, 0px);
  pointer-events: auto;
}
.game-tooltip[data-side="bottom"]::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: rgba(20, 20, 20, 0.96);
}
.game-tooltip[data-side="bottom"]::before {
  top: auto;
  bottom: 100%;
}

.game-tooltip .links {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.game-tooltip .links a {
  color: #7bb6ff;
  font-weight: 600;
  pointer-events: auto;
  text-decoration: underline;
}

/* ---------- Perso : en bas à droite (desktop) ----------
   Centré horizontalement dans la gouttière droite, entre le bord
   droit des accordéons (max 1100px) et le bord droit de la page. */
.character {
  position: fixed;
  bottom: var(--footer-h);
  /* centre de la gouttière droite : moitié de l'espace restant à droite */
  right: calc(max(0px, (100vw - 1100px) / 2) / 2);
  transform: translateX(50%);
  width: 200px;
  cursor: pointer;
  z-index: 20;
  filter: drop-shadow(0 0 12px rgba(0, 0, 0, 0.5));
}

/* ---------- Flèche flottante « Retour en haut » (toutes les pages) ---------- */
.back-to-top {
  position: fixed;
  left: 18px;
  bottom: calc(var(--footer-h) + 18px);
  z-index: 45;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: rgba(11, 18, 32, 0.82);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s, background 0.2s, visibility 0s linear 0.2s;
}
.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.2s, transform 0.2s, background 0.2s;
}
.back-to-top:hover { background: rgba(37, 99, 235, 0.92); }

/* ---------- Footer sticky ---------- */
.site-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  padding: 0 1.2rem;
  background: #0b1220;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.3);
  font-size: 0.74rem;
  color: rgba(199, 214, 230, 0.75);
}
.footer-copy { white-space: nowrap; }
.footer-legal { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.footer-legal a { color: rgba(199, 214, 230, 0.75); transition: color 0.15s; }
.footer-legal a:hover { color: #7aa7ff; }
.footer-btc { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.footer-btc code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.01em;
  color: rgba(199, 214, 230, 0.85);
}
.footer-btc-icon { font-size: 0.85rem; line-height: 1; }

/* ---------- Modales (popup overlay) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 12, 22, 0.6);
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }

.modal {
  position: relative;
  width: min(680px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  background: #ffffff;
  color: #172033;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  padding: 28px 32px 32px;
  line-height: 1.6;
  animation: modalIn 0.18s ease;
}
@keyframes modalIn {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal h2 { font-size: 1.45rem; margin: 0 0 4px; }
.modal h3 { font-size: 1.02rem; margin: 20px 0 6px; }
.modal p, .modal li { color: #334155; font-size: 0.92rem; }
.modal ul { margin: 8px 0; padding-left: 22px; }
.modal a { color: var(--accent); }
.modal .legal-meta { color: #607086; font-size: 0.85rem; margin-bottom: 16px; }
.modal .legal-callout {
  margin: 16px 0;
  padding: 12px 14px;
  border-left: 4px solid #ca8a04;
  border-radius: 8px;
  background: #fffbeb;
  font-weight: 600;
  font-size: 0.9rem;
}

.modal-about { width: min(960px, 100%); }
.about-lead { margin-top: 16px; }
.about-lead p { margin: 0 0 0.8em; }
.about-timeline {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}
.about-event {
  display: grid;
  grid-template-columns: minmax(180px, 34%) 1fr;
  gap: 16px;
  align-items: start;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
}
.about-event img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 8px;
  background: #e2e8f0;
}
.about-event time {
  display: inline-block;
  margin-bottom: 4px;
  color: #2563eb;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.about-event h3 { margin: 0 0 6px; }
.about-event p { margin: 0.45em 0 0; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: #eef2f7;
  color: #334155;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}
.modal-close:hover { background: #dde4ec; }

/* Tant qu'il n'y a pas de vraie gouttière à droite (≤ 1100px),
   le perso passe dans le flux, SOUS les accordéons. */
@media (max-width: 1100px) {
  .character {
    position: static;
    display: block;
    width: 180px;
    margin: 1.5em auto calc(var(--footer-h) + 1em);
    right: auto;
    bottom: auto;
    transform: none;
  }
  body { padding-bottom: var(--footer-h); }
}

@media (max-width: 600px) {
  .character { width: 150px; }
  .brand .brand-sub { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  /* la marque garde la priorité : le nom ne doit pas passer sous le champ */
  .app-header { gap: 8px; padding: 0 12px; }
  .brand { flex: 1 1 auto; }
  .brand img { width: 32px; height: 32px; }
  .brand .brand-name { font-size: 0.98rem; }
  #search { flex: 0 1 150px; max-width: 150px; min-width: 90px; }
  .modal { padding: 22px 18px 26px; }
  .about-event { grid-template-columns: 1fr; }
  .back-to-top { left: 12px; width: 42px; height: 42px; font-size: 1.15rem; }
}
