/* ==========================================================================
   Du premier salaire au premier placement — Le Jeu
   Feuille de style unique (mobile-first, thème sombre « néon » de la couverture)
   Sommaire : 1 Variables · 2 Base · 3 Boutons · 4 Menu · 5 Jeu (HUD, cartes)
              6 Questions · 7 Niveaux spéciaux · 8 Résultats · 9 Fenêtres · 10 Accessibilité
   ========================================================================== */

/* 1. Variables ------------------------------------------------------------ */
:root {
  --bg: #080c24;
  --bg2: #0f1640;
  --card: #141c4a;
  --card2: #1b2560;
  --line: #2b3680;
  --ink: #f2f6ff;
  --sub: #a9b6e8;
  --cyan: #4ee3ff;
  --pink: #ff6fb0;
  --orange: #ff9a5a;
  --gold: #ffd166;
  --ok: #34d399;
  --bad: #fb7185;
  --meh: #fbbf24;
  --grad: linear-gradient(135deg, #ff9a5a, #ff6fb0);
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 500px at 85% -10%, rgba(255, 111, 176, 0.18), transparent 60%),
    radial-gradient(800px 500px at -10% 10%, rgba(78, 227, 255, 0.14), transparent 60%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.2; }
img { max-width: 100%; height: auto; }
a { color: var(--cyan); }
button { font: inherit; color: inherit; cursor: pointer; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

#app {
  width: 100%;
  max-width: 520px;
  padding: calc(14px + var(--safe-t)) 16px calc(24px + var(--safe-b));
}

.screen { display: none; flex-direction: column; gap: 18px; min-height: calc(100dvh - 40px); }
.screen.active { display: flex; }
[hidden] { display: none !important; }

.section-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--sub); margin-bottom: 10px; }
.kicker { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--cyan); }

/* 3. Boutons ----------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px;
  border: 0; border-radius: 999px;
  background: var(--grad); color: #14102e;
  font-weight: 800; font-size: 0.98rem; text-align: center; text-decoration: none;
  box-shadow: 0 6px 22px rgba(255, 111, 176, 0.28);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.btn-big { width: 100%; min-height: 56px; font-size: 1.15rem; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
}

/* 4. Menu --------------------------------------------------------------------- */
.hero { position: relative; border-radius: 22px; overflow: hidden; border: 1px solid var(--line); }
.hero-bg {
  position: absolute; inset: -20px;
  background: url("../assets/img/cover-jeu-320.webp") center 30% / cover;
  filter: blur(18px) saturate(1.2) brightness(0.45);
}
.hero-inner { position: relative; display: flex; align-items: center; gap: 16px; padding: 16px; }
.hero-cover { flex: 0 0 auto; width: 112px; height: auto; border-radius: 10px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.12); transform: rotate(-3deg); }
.hero-text { display: grid; gap: 6px; min-width: 0; }
.hero h1 { font-size: 1.35rem; font-weight: 900; letter-spacing: -0.01em; }
.hero h1 span { color: var(--cyan); display: block; }
.tagline { font-size: 0.92rem; color: #d7e2ff; }
.tagline strong { color: var(--orange); }

.stats-card {
  display: flex; justify-content: space-around; gap: 8px;
  padding: 14px 8px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card);
}
.stat-item { text-align: center; }
.stat-label { display: block; font-size: 0.7rem; color: var(--sub); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-val { font-size: 1.15rem; font-weight: 800; color: var(--ok); }

.levels-grid { display: grid; gap: 8px; }
.level-btn {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px;
  width: 100%; min-height: 62px; padding: 8px 14px 8px 10px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  text-align: left; transition: transform 0.12s ease, border-color 0.12s ease;
}
.level-btn:active { transform: scale(0.985); background: var(--card2); }
.level-btn .lvl-ico {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--card2); font-size: 1.4rem;
}
.level-btn .lvl-num { display: block; font-size: 0.72rem; font-weight: 700; color: var(--cyan); }
.level-btn .lvl-title { display: block; font-size: 0.98rem; font-weight: 700; }
.level-btn .lvl-stars { font-size: 0.95rem; letter-spacing: 2px; color: var(--gold); white-space: nowrap; }
.level-btn .lvl-stars .off { color: #3a4690; }
.level-btn.done { border-color: rgba(52, 211, 153, 0.55); }
.level-btn.next { border-color: var(--orange); box-shadow: 0 0 0 2px rgba(255, 154, 90, 0.25); }

.badges-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.badge-item {
  display: grid; gap: 2px; justify-items: center;
  padding: 10px 4px; border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  text-align: center;
}
.badge-item.unlocked { border-color: var(--ok); background: rgba(52, 211, 153, 0.12); }
.badge-item.locked { opacity: 0.5; filter: grayscale(1); }
.badge-icon { font-size: 1.6rem; line-height: 1.2; }
.badge-name { font-size: 0.64rem; font-weight: 700; line-height: 1.2; }

.book-card { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); display: grid; gap: 12px; }
.book-card p { font-size: 0.92rem; color: #d7e2ff; }
.book-card .section-title { margin: 0; color: var(--orange); }
.book-actions { display: grid; gap: 8px; }
.teaser-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.teaser-strip button { flex: 0 0 auto; width: 168px; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; scroll-snap-align: start; }
.teaser-strip img { display: block; width: 100%; height: auto; }

.install-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: var(--radius); font-size: 0.88rem; color: #d7e2ff; }
.foot { margin-top: auto; display: grid; gap: 8px; font-size: 0.75rem; color: var(--sub); text-align: center; }
.foot a { display: inline-block; padding: 8px 4px; }

/* 5. Jeu : HUD et cartes ----------------------------------------------------------------- */
.game-hud {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(6px + var(--safe-t)) 0 10px; margin-top: calc(-6px - var(--safe-t));
  background: linear-gradient(var(--bg) 80%, transparent);
}
.hud-item { font-size: 0.92rem; font-weight: 700; white-space: nowrap; }
.hud-level { color: var(--cyan); }
#score { margin-left: auto; color: var(--ok); }
#lives { letter-spacing: 1px; }

.game-area { display: grid; gap: 14px; align-content: start; padding-bottom: 12px; }
.card {
  display: grid; gap: 12px; padding: 18px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  animation: pop 0.25s ease-out;
}
.card h2 { font-size: 1.3rem; font-weight: 800; }
.card .lead { font-size: 1rem; color: #e3ebff; }
.card .small { font-size: 0.85rem; color: var(--sub); }
.centered { text-align: center; justify-items: center; }
.emoji-xl { font-size: 2.6rem; line-height: 1; }

.fiche {
  position: relative; display: block; width: 100%; padding: 0;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff;
}
.fiche img { display: block; width: 100%; height: auto; }
.fiche .fiche-hint {
  position: absolute; right: 8px; bottom: 8px; padding: 5px 10px;
  border-radius: 999px; background: rgba(8, 12, 36, 0.88); color: #fff; font-size: 0.74rem; font-weight: 700;
}
.rules { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.rules li { padding: 4px 10px; border-radius: 999px; background: var(--card2); font-size: 0.78rem; color: #d7e2ff; }

.progress { display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; color: var(--sub); }
.progress-bar { flex: 1; height: 6px; margin-left: 12px; border: 0; border-radius: 99px; background: var(--card2); overflow: hidden; -webkit-appearance: none; appearance: none; }
.progress-bar::-webkit-progress-bar { background: var(--card2); border-radius: 99px; }
.progress-bar::-webkit-progress-value { background: var(--grad); border-radius: 99px; transition: width 0.3s ease; }
.progress-bar::-moz-progress-bar { background: var(--grad); border-radius: 99px; }
.noscript { padding: 24px; font-family: sans-serif; }

/* 6. Questions à choix ----------------------------------------------------------------------- */
.choices { display: grid; gap: 10px; }
.choice {
  display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 10px;
  width: 100%; min-height: 54px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--card2);
  text-align: left; font-size: 0.96rem; font-weight: 600;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.choice:active:not(:disabled) { transform: scale(0.985); border-color: var(--cyan); }
.choice .mark { font-size: 1.2rem; text-align: center; }
.choice:disabled { cursor: default; opacity: 0.75; }
.choice.is-correct { opacity: 1; border-color: var(--ok); background: rgba(52, 211, 153, 0.16); }
.choice.is-wrong { opacity: 1; border-color: var(--bad); background: rgba(251, 113, 133, 0.16); }
.choice.is-meh { opacity: 1; border-color: var(--meh); background: rgba(251, 191, 36, 0.14); }
.choices.row { grid-template-columns: 1fr 1fr; }
.choices.row .choice { grid-template-columns: 1fr; justify-items: center; text-align: center; font-size: 1.05rem; font-weight: 800; }

.info-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; border-radius: 12px; overflow: hidden; }
.info-table th, .info-table td { padding: 9px 12px; text-align: left; background: var(--card2); border-bottom: 1px solid var(--line); }
.info-table td { text-align: right; font-weight: 800; white-space: nowrap; }
.info-table tr:last-child th, .info-table tr:last-child td { border-bottom: 0; }

.feedback { display: grid; gap: 10px; padding: 14px 16px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--bg2); animation: pop 0.2s ease-out; }
.feedback.ok { border-color: var(--ok); }
.feedback.bad { border-color: var(--bad); }
.feedback.meh { border-color: var(--meh); }
.feedback h3 { font-size: 1.05rem; font-weight: 800; }
.feedback.ok h3 { color: var(--ok); }
.feedback.bad h3 { color: var(--bad); }
.feedback.meh h3 { color: var(--meh); }
.feedback p { font-size: 0.93rem; color: #e3ebff; }
.feedback .pts { font-weight: 800; color: var(--gold); }

/* 7. Niveaux spéciaux ---------------------------------------------------------------------- */
/* Niveau 1 : swipe */
.swipe-zone { display: grid; gap: 14px; }
.swipe-card {
  display: grid; gap: 6px; justify-items: center; padding: 30px 18px 22px;
  border: 1.5px solid var(--cyan); border-radius: 22px; background: var(--card);
  text-align: center; touch-action: pan-y; user-select: none; -webkit-user-select: none;
  will-change: transform; cursor: grab;
  box-shadow: 0 10px 30px rgba(78, 227, 255, 0.12);
}
.swipe-card .card-category { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--cyan); }
.swipe-card h2 { font-size: 1.4rem; }
.swipe-card .price { font-size: 2rem; font-weight: 900; color: var(--gold); }
.swipe-card .swipe-hint { margin-top: 8px; font-size: 0.8rem; color: var(--sub); }
.swipe-card.stamp-block { border-color: var(--bad); }
.swipe-card.stamp-buy { border-color: var(--ok); }
.swipe-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Niveau 3 : tri 50/30/20 */
.budget-bar { display: flex; height: 44px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.budget-bar > div { display: grid; place-items: center; padding: 0 2px; overflow: hidden; white-space: nowrap; font-size: 0.7rem; font-weight: 800; color: #0b1030; transition: filter 0.3s ease; }
.budget-bar .b50 { flex: 50; background: #34d3b5; }
.budget-bar .b30 { flex: 30; background: var(--gold); }
.budget-bar .b20 { flex: 20; background: var(--orange); }
.sort-item { display: grid; gap: 4px; justify-items: center; padding: 18px; border: 1.5px dashed var(--cyan); border-radius: 16px; background: var(--card2); text-align: center; }
.sort-item .emoji-xl { font-size: 2.2rem; }
.sort-item strong { font-size: 1.2rem; }
.sort-btns { display: grid; gap: 8px; }
.sort-btns .choice { grid-template-columns: 58px 1fr; }
.sort-btns .choice .pct { font-weight: 900; font-size: 1.1rem; color: var(--cyan); }

/* Niveau 7 : audit d'abonnements */
.sub-list { display: grid; gap: 8px; }
.sub-row {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px;
  width: 100%; min-height: 64px; padding: 8px 12px;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--card2); text-align: left;
}
.sub-row .ico { font-size: 1.5rem; text-align: center; }
.sub-row .nm { display: block; font-weight: 700; font-size: 0.95rem; }
.sub-row .hint { display: block; font-size: 0.78rem; color: var(--sub); }
.sub-row .price { font-weight: 800; font-size: 0.9rem; white-space: nowrap; text-align: right; }
.sub-row .act { display: block; margin-top: 2px; font-size: 0.7rem; font-weight: 800; color: var(--sub); text-transform: uppercase; }
.sub-row[aria-pressed="true"] { border-color: var(--bad); background: rgba(251, 113, 133, 0.14); }
.sub-row[aria-pressed="true"] .nm { text-decoration: line-through; text-decoration-thickness: 2px; }
.sub-row[aria-pressed="true"] .act { color: var(--bad); }
.sub-row.is-right { border-color: var(--ok); }
.sub-row.is-wrong { border-color: var(--bad); }
.sub-total { display: flex; justify-content: space-between; font-size: 0.9rem; color: #d7e2ff; }
.sub-total strong { color: var(--gold); }

/* 8. Résultats ------------------------------------------------------------------------------------- */
.stars { font-size: 2.4rem; letter-spacing: 6px; color: var(--gold); text-shadow: 0 0 18px rgba(255, 209, 102, 0.5); }
.stars .off { color: #3a4690; text-shadow: none; }
.big-score { font-size: 1.7rem; font-weight: 900; color: var(--ok); }
.record { font-size: 0.82rem; font-weight: 800; color: var(--gold); }
.takeaway { display: grid; gap: 6px; padding: 12px 14px; border-left: 4px solid var(--orange); border-radius: 8px; background: var(--bg2); text-align: left; width: 100%; }
.takeaway strong { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--orange); }
.takeaway p { font-size: 0.93rem; color: #e3ebff; }
.unlocked-badge { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 1.5px solid var(--ok); border-radius: 14px; background: rgba(52, 211, 153, 0.12); text-align: left; animation: pop 0.4s ease-out; }
.unlocked-badge .badge-icon { font-size: 2rem; }
.unlocked-badge small { display: block; color: var(--sub); }
.actions { display: grid; gap: 10px; width: 100%; }
.book-cta { display: grid; gap: 10px; width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg2); text-align: left; }
.book-cta p { font-size: 0.88rem; color: #d7e2ff; }
.book-cta strong { color: var(--orange); }

/* 9. Fenêtres (zoom du schéma, confirmation, message) -------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 18px;
  background: rgba(4, 6, 20, 0.82);
}
.dialog { width: min(100%, 420px); display: grid; gap: 14px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); animation: pop 0.2s ease-out; }
.dialog h2 { font-size: 1.15rem; }
.dialog p { font-size: 0.93rem; color: #d7e2ff; }
.dialog .actions { grid-template-columns: 1fr 1fr; }
.zoom { position: fixed; inset: 0; z-index: 110; display: grid; grid-template-rows: auto 1fr; background: rgba(4, 6, 20, 0.95); padding-top: var(--safe-t); }
.zoom-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; font-size: 0.8rem; color: var(--sub); }
.zoom-scroll { overflow: auto; padding: 0 12px calc(16px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.zoom-scroll img { display: block; width: max(100%, 860px); height: auto; border-radius: 10px; background: #fff; }
.toast {
  position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); z-index: 120;
  max-width: min(92vw, 440px); padding: 12px 18px; transform: translateX(-50%);
  border: 1px solid var(--line); border-radius: 14px; background: var(--card2);
  font-size: 0.9rem; font-weight: 600; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: pop 0.2s ease-out;
}

@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
.shake { animation: shake 0.3s ease-in-out; }

/* 10. Accessibilité ------------------------------------------------------------------------------------------ */
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
h2[tabindex="-1"]:focus { outline: none; }

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

@media (min-width: 560px) {
  #app { padding-top: 28px; }
  .hero-cover { width: 132px; }
  .hero h1 { font-size: 1.6rem; }
  .book-actions { grid-template-columns: 1fr 1fr; }
}
.install-box.attire { border: 1px solid var(--orange); box-shadow: 0 0 0 3px rgba(255, 154, 90, 0.25); }
