/* Menu « Mes Jeux » — sombre moderne, cartes en verre dépoli, rayons horizontaux façon store. */
:root {
  --bg: #1a1a2e;
  --bg-deep: #12122a;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-strong: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.11);
  --text: #eeedf8;
  --muted: #a3a2c3;
  --faint: #6f6e92;
  --accent: #8b7bff;
  --ok: #3ddc97;
  --warn: #ffb347;
  --gold: #ffd166;
  --radius: 14px;
  --gutter: 16px;
  --card-w: clamp(138px, 39vw, 184px);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; }
html { background: var(--bg); }
body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation; /* menu défilant : pan autorisé, pas de zoom double-tap */
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 0% -8%, rgba(139, 123, 255, 0.28), transparent 62%),
    radial-gradient(700px 460px at 105% 6%, rgba(255, 107, 129, 0.16), transparent 60%),
    radial-gradient(800px 600px at 50% 110%, rgba(61, 220, 151, 0.10), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: calc(env(safe-area-inset-top, 44px) + 8px);
  padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 8px);
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}

/* ——— En-tête ——— */
.brand { display: flex; align-items: center; gap: 10px; padding-top: 6px; }
.brand-text { flex: 1; min-width: 0; }
h1 {
  width: fit-content;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.5px;
  line-height: 1.1;
  background: linear-gradient(90deg, #ffd166, #ff8a5b 30%, #ff5d8f 55%, #a78bfa 80%, #5cc8ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-sub { font-size: 13px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.icon-btn:active { transform: scale(0.94); }
@media (hover: hover) { .icon-btn:hover { background: var(--glass-strong); color: var(--text); } }
.net-pill {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  color: #1a1a2e;
  background: var(--warn);
}

.update-banner {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 14px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(139, 123, 255, 0.24), rgba(92, 200, 255, 0.16));
  border: 1px solid rgba(139, 123, 255, 0.45);
  font-size: 14px;
  font-weight: 600;
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.update-banner span { flex: 1; }
.update-banner button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.search {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  padding: 0 6px 0 14px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: var(--muted);
  transition: border-color 0.2s, background 0.2s;
}
.search:focus-within { border-color: rgba(139, 123, 255, 0.7); background: var(--glass-strong); }
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* ≥ 16 px : pas de zoom auto sur iOS */
  -webkit-user-select: text;
  user-select: text;
  -webkit-appearance: none;
  appearance: none;
}
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 12px calc(-1 * var(--gutter)) 0;
  padding: 2px var(--gutter) 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  --c: var(--accent);
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }
.chip[aria-pressed='true'] {
  color: #fff;
  border-color: color-mix(in srgb, var(--c) 70%, transparent);
  background: color-mix(in srgb, var(--c) 26%, transparent);
}

/* ——— Rayons ——— */
#view { flex: 1; }
.shelf { margin-top: 26px; animation: fade 0.35s ease both; }
.shelf-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.shelf-head h2 { font-size: 19px; font-weight: 800; letter-spacing: -0.2px; display: flex; align-items: center; gap: 9px; }
.shelf-head h2::before {
  content: '';
  width: 4px;
  height: 18px;
  border-radius: 4px;
  background: var(--c, var(--accent));
  box-shadow: 0 0 12px var(--c, var(--accent));
}
.shelf-count { color: var(--faint); font-size: 13px; font-weight: 600; }
.shelf-more {
  margin-left: auto;
  min-height: 44px;
  padding: 0 4px 0 12px;
  border: 0;
  background: transparent;
  color: var(--c, var(--accent));
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--card-w);
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 var(--gutter);
  margin: 0 calc(-1 * var(--gutter));
  padding: 4px var(--gutter) 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.row::-webkit-scrollbar { display: none; }
.row .card { scroll-snap-align: start; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px 12px;
  margin-top: 6px;
}
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); } }

.results-head { display: flex; align-items: center; gap: 10px; margin-top: 22px; min-height: 44px; }
.results-head h2 { font-size: 19px; font-weight: 800; }
.results-head .shelf-count { margin-right: auto; }
.empty {
  margin-top: 40px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}
.empty b { display: block; font-size: 40px; margin-bottom: 8px; }
.hint {
  margin-top: 26px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px dashed var(--glass-border);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ——— Cartes ——— */
.card {
  --c: var(--accent);
  position: relative;
  min-width: 0;
  animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 28ms);
}
.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  border-radius: 16px;
  outline-offset: 3px;
}
.thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 30% 10%, color-mix(in srgb, var(--c) 45%, transparent), transparent 70%),
    linear-gradient(160deg, #2a2950, #16162c);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35), 0 0 0 0 transparent;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s, border-color 0.25s;
}
.thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.thumb img.loaded { opacity: 1; }
.thumb .emoji {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 52px;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.4));
}
.thumb::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  background: linear-gradient(180deg, transparent, rgba(10, 10, 26, 0.72));
  pointer-events: none;
}
.card-link:active .thumb { transform: scale(0.97); }
@media (hover: hover) {
  .card-link:hover .thumb {
    transform: translateY(-4px);
    border-color: color-mix(in srgb, var(--c) 60%, transparent);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.45), 0 0 24px color-mix(in srgb, var(--c) 30%, transparent);
  }
}
.card-meta { display: flex; align-items: center; gap: 7px; margin-top: 9px; padding: 0 2px; }
.card-icon { flex: none; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 15px; overflow: hidden; }
.card-icon img { width: 100%; height: 100%; object-fit: cover; }
.card-name { font-size: 14.5px; font-weight: 750; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-desc {
  margin-top: 4px;
  padding: 0 2px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-cat { color: var(--c); font-weight: 700; }

.fav-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 2;
}
.fav-btn span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(14, 14, 32, 0.5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: transform 0.2s, color 0.2s, background 0.2s;
}
.fav-btn[aria-pressed='true'] span { color: var(--gold); background: rgba(40, 30, 6, 0.6); border-color: rgba(255, 209, 102, 0.5); }
.fav-btn.pop span { animation: pop 0.35s ease; }

.badge {
  position: absolute;
  z-index: 1;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 4px 8px;
  border-radius: 999px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.badge-beta { top: 9px; left: 9px; color: #e9d8ff; background: rgba(120, 60, 200, 0.62); border: 1px solid rgba(200, 160, 255, 0.5); }
.badge-off {
  left: 8px;
  bottom: 8px;
  color: #d7ffe9;
  background: rgba(14, 60, 40, 0.66);
  border: 1px solid rgba(61, 220, 151, 0.5);
}
.badge-dl { left: 8px; bottom: 8px; color: #fff; background: rgba(20, 20, 50, 0.7); border: 1px solid var(--glass-border); }
.badge-dl i {
  display: block;
  height: 3px;
  margin-top: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--ok) var(--p, 0%), rgba(255, 255, 255, 0.18) var(--p, 0%));
}

/* ——— Réglages ——— */
.settings { margin-top: 18px; animation: fade 0.3s ease both; }
.settings-head { display: flex; align-items: center; gap: 8px; }
.settings-head h2 { font-size: 22px; font-weight: 850; }
.back-btn {
  min-height: 44px;
  padding: 0 14px 0 10px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.panel {
  margin-top: 14px;
  padding: 16px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.panel h3 { font-size: 16px; font-weight: 800; margin-bottom: 6px; }
.panel p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.panel p + .btn, .panel .btn + p, .panel .progress + p { margin-top: 12px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 13px;
  border: 1px solid var(--glass-border);
  background: var(--glass-strong);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { border: 0; color: #fff; background: linear-gradient(135deg, #7b6cff, #4f8dff); box-shadow: 0 8px 22px rgba(91, 110, 255, 0.35); }
.btn.danger { color: #ffb3c0; border-color: rgba(255, 107, 129, 0.4); background: rgba(255, 107, 129, 0.1); }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 13px; }
.btn.block { width: 100%; }
.progress { margin-top: 14px; }
.progress-bar { height: 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 0; border-radius: 10px; background: linear-gradient(90deg, #3ddc97, #5cc8ff); transition: width 0.3s ease; }
.progress-label { margin-top: 8px; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; }
.storage-list { list-style: none; padding: 0; margin-top: 12px; }
.storage-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.storage-list li:first-child { border-top: 0; }
.storage-list .n { flex: 1; min-width: 0; font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.storage-list .s { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.stat { font-size: 26px; font-weight: 850; letter-spacing: -0.4px; }
.stat small { font-size: 14px; color: var(--muted); font-weight: 600; letter-spacing: 0; }

.app-version {
  margin-top: 36px;
  padding: 12px 0 4px;
  text-align: center;
  color: var(--faint);
  font-size: 12px;
  letter-spacing: 0.5px;
}

/* ——— Feuille (message hors ligne) ——— */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(6, 6, 18, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fade 0.2s ease both;
}
.sheet {
  width: 100%;
  max-width: 480px;
  margin: 0 12px;
  padding: 22px 20px calc(env(safe-area-inset-bottom, 20px) + 16px);
  border-radius: 22px 22px 0 0;
  background: #24244a;
  border: 1px solid var(--glass-border);
  border-bottom: 0;
  text-align: center;
  animation: slide 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.sheet-icon { font-size: 44px; }
.sheet h2 { margin-top: 8px; font-size: 20px; font-weight: 800; }
.sheet p { margin: 8px auto 18px; color: var(--muted); font-size: 15px; line-height: 1.5; max-width: 360px; }
.sheet .btn { width: 100%; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateY(100%); } to { transform: none; } }
@keyframes pop { 40% { transform: scale(1.3); } }

@media (min-width: 700px) {
  :root { --gutter: 28px; --card-w: 180px; }
  h1 { font-size: 38px; }
  .search { max-width: 720px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
