/* =====================================================================
   Base : remise à zéro, typographie, mise en page générale, en-tête, navigation.
   ===================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: calc(14px * var(--fs));
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
  min-height: 100vh;
}
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.015em; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.lg { width: 22px; height: 22px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- en-tête */
.app-header {
  position: sticky; top: 0; z-index: 40; height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 96%, transparent); /* sans flou d'arrière-plan : coûteux à chaque défilement */
  border-bottom: 1px solid var(--border);
}
.app-header .inner { max-width: 1360px; height: 100%; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 22px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 780; font-size: calc(18px * var(--fs)); letter-spacing: -0.03em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; }
.nav { display: flex; gap: 2px; height: 100%; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 7px; padding: 0 11px; height: 100%;
  color: var(--text-2); font-weight: 560; font-size: calc(13.5px * var(--fs)); white-space: nowrap;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); }
.nav a.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.nav-badge { min-width: 17px; height: 17px; padding: 0 5px; border-radius: 99px; background: var(--danger); color: #fff; font-size: calc(10.5px * var(--fs)); font-weight: 800; display: inline-grid; place-items: center; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-weight: 650; white-space: nowrap; color: var(--text);
}
.pill:hover { text-decoration: none; border-color: var(--border-strong); }
.pill .sub { color: var(--muted); font-weight: 550; font-size: calc(12px * var(--fs)); }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.coin { width: 20px; height: 20px; flex: none; }
.coin.sm { width: 15px; height: 15px; }
.coin.xs { width: 13px; height: 13px; display: inline-block; vertical-align: -2px; }
.dev-tag { font-size: calc(10px * var(--fs)); font-weight: 800; letter-spacing: .08em; color: #fff; background: var(--danger); padding: 3px 7px; border-radius: 6px; }

.banner { background: var(--danger-soft); color: var(--danger); border-bottom: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); font-size: calc(13px * var(--fs)); font-weight: 560; }
.banner .inner { max-width: 1360px; margin: 0 auto; padding: 8px 20px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner a { color: inherit; text-decoration: underline; }

/* ---------------------------------------------------------------- pages */
main.page { max-width: 1360px; margin: 0 auto; padding: 28px 20px 70px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: calc(28px * var(--fs)); font-weight: 780; letter-spacing: -0.03em; }
.page-head p { margin-top: 4px; color: var(--text-2); max-width: 720px; }
.stack { display: grid; gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cols-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.cols-main-side > * { min-width: 0; }
.split > *, .cols-main-side > * { min-width: 0; }
@media (max-width: 1100px) { .cols-main-side { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- navigation mobile */
.mobile-nav { display: none; }
@media (max-width: 960px) {
  .nav { display: none; }
  .app-header .inner { gap: 10px; padding: 0 14px; }
  .pill .sub { display: none; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--bg-elevated); border-top: 1px solid var(--border); height: 62px;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: calc(11px * var(--fs)); font-weight: 620; position: relative; }
  .mobile-nav a.active { color: var(--text); }
  .mobile-nav a:hover { text-decoration: none; }
  .mobile-nav .nav-badge { position: absolute; top: 6px; left: calc(50% + 6px); }
  main.page { padding-bottom: 100px; }
}
@media (max-width: 520px) {
  .brand span { display: none; }
  .page-head h1 { font-size: calc(24px * var(--fs)); }
}

/* réduction des animations (réglage du jeu ou du système) */
:root[data-animations="off"] *, :root[data-animations="off"] *::before, :root[data-animations="off"] *::after {
  animation-duration: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0s !important;
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------- mobile : barre du bas et menu « Plus » */
.more-sheet { display: none; }
@media (max-width: 960px) {
  .mobile-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted);
    font: inherit; font-size: calc(11px * var(--fs)); font-weight: 620; background: none; border: 0; position: relative; cursor: pointer; }
  .mobile-nav button[aria-expanded="true"] { color: var(--text); }
  .mobile-nav .nav-badge { position: absolute; top: 6px; left: calc(50% + 6px); }
  .more-sheet { display: block; position: fixed; inset: 0; z-index: 60; background: rgba(5, 8, 15, .5); animation: fade-in .15s ease; }
  .more-sheet.hidden { display: none; }
  .more-sheet .sheet { position: absolute; left: 10px; right: 10px; bottom: calc(68px + env(safe-area-inset-bottom)); background: var(--surface-solid, var(--surface));
    border: 1px solid var(--border-strong); border-radius: 18px; padding: 8px; display: grid; gap: 2px; box-shadow: var(--shadow-lg); }
  .more-sheet .sheet a, .more-sheet .sheet button { display: flex; width: 100%; border: 0; background: none; cursor: pointer; font: inherit; text-align: left; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 12px; color: var(--text); font-weight: 620; }
  .more-sheet .sheet button.hidden { display: none; }
  .more-sheet .sheet button { color: var(--accent); border-top: 1px solid var(--border); border-radius: 0 0 12px 12px; }
  .more-sheet .sheet a:hover, .more-sheet .sheet a.active, .more-sheet .sheet button:hover { background: var(--surface-3); text-decoration: none; }
  .more-sheet .sheet a .nav-badge { margin-left: auto; }
  .header-right .icon-btn { display: none; }
}

/* bouton de la série de connexion (en-tête) */
.streak-btn { cursor: pointer; font: inherit; color: #ff8a3d; }
.streak-btn svg { color: #ff8a3d; }
.streak-btn.ready { box-shadow: 0 0 0 1.5px #ff8a3d; animation: streak-pulse 1.8s ease-in-out infinite; }
@keyframes streak-pulse { 50% { box-shadow: 0 0 0 1.5px #ff8a3d, 0 0 16px rgba(255,138,61,.55); } }
:root[data-animations="off"] .streak-btn.ready { animation: none; }

/* en-tête compact sur les écrans moyens (8 onglets + compteurs) */
@media (max-width: 1560px) and (min-width: 961px) {
  .app-header .inner { gap: 14px; }
  .nav { gap: 0; }
  .nav a { gap: 5px; padding-left: 8px; padding-right: 8px; }
  .pill .sub { display: none; }
  .brand span { font-size: calc(17px * var(--fs)); }
}
@media (max-width: 1480px) and (min-width: 961px) {
  .brand span { display: none; } /* le logo reste : place pour le bouclier admin et les gros soldes */
}
@media (max-width: 1180px) and (min-width: 961px) {
  .nav a { padding-left: 6px; padding-right: 6px; font-size: calc(13px * var(--fs)); }
}

/* écrans étroits (avant la version mobile) : onglets réduits à leur icône, nom en info-bulle */
@media (max-width: 1100px) and (min-width: 961px) {
  .nav a .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav a { padding-left: 10px; padding-right: 10px; }
  .nav a > svg { width: 19px; height: 19px; }
}

/* Lien « Aller au contenu » : invisible jusqu'à ce qu'on y arrive au clavier */
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 2000; padding: 8px 14px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 650; text-decoration: none; }
.skip-link:focus { top: 10px; }
main.page:focus { outline: none; }

/* pastille « quelque chose à récupérer » sur un lien de navigation */
.nav a.has-dot, .mobile-nav a.has-dot { position: relative; }
.nav a.has-dot::before, .mobile-nav a.has-dot::before { content: ""; position: absolute; top: 8px; right: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 2px var(--bg-elevated); }

/* Erreur au démarrage (hors ligne, serveur injoignable) */
.boot-error { min-height: 100vh; display: grid; place-content: center; gap: 16px; text-align: center; padding: 24px; }
.boot-error p { max-width: 420px; color: var(--text-2); }
.install-help ol { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 8px; }
