:root {
  --bg: #EEF1EF;
  --surface: #FFFFFF;
  --surface-2: #F5F7F6;
  --ink: #14262A;
  --muted: #5A6A6D;
  --line: #D5DCD9;
  --ember: #F08A24;
  --ember-hi: #FFD27A;
  --ember-deep: #C2410C;
  --ember-ink: #9A3412;
  --moss: #2D7A59;
  --rose: #B4365A;
  --focus: #1D6FB8;
  --shadow: 0 1px 2px rgba(20, 38, 42, .06), 0 8px 24px rgba(20, 38, 42, .06);
  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --body: "Instrument Sans", "Helvetica Neue", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1A1C; --surface: #152628; --surface-2: #1B2F32; --ink: #E7EEEC; --muted: #9BABAE;
    --line: #29403F; --ember-ink: #FDBA74; --moss: #5FBF92; --rose: #F07A9A; --focus: #7FB8F0;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1A1C; --surface: #152628; --surface-2: #1B2F32; --ink: #E7EEEC; --muted: #9BABAE;
  --line: #29403F; --ember-ink: #FDBA74; --moss: #5FBF92; --rose: #F07A9A; --focus: #7FB8F0;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
/* Écran de démarrage (#demarrage) : affiché par défaut dans index.html, jusqu'à ce que le chemin soit prêt. Fond crème, même en mode sombre. */
#demarrage { display: flex; position: fixed; inset: 0; z-index: 1; align-items: center; justify-content: center; flex-direction: column; gap: 18px; background: #FFF8EA; color: #16292B; font: 700 22px/1.2 system-ui, -apple-system, sans-serif; }
#demarrage:not(.active) { display: none; }
#demarrage .dem-flamme { width: 72px; height: 72px; border-radius: 50%; background: radial-gradient(circle at 50% 60%, #FFD27A, #F08A24 55%, #C2410C); animation: dem-souffle 1.6s ease-in-out infinite; }
#demarrage p { margin: 0; font-size: 15px; font-weight: 500; color: #5B6B6D; }
@keyframes dem-souffle { 50% { transform: scale(.9); opacity: .85; } }
@media (prefers-reduced-motion: reduce) { #demarrage .dem-flamme { animation: none; } }

body {
  background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 10px; }
.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { display: none; flex: 1; flex-direction: column; padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
.screen.active { display: flex; }
/* Pied de page vide : 1,5 × la hauteur du badge « Powered by Netlify » (environ 36 px), pour qu'il ne cache rien. */
.app::after { content: ""; display: block; flex: none; height: 54px; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 34px; line-height: 1.08; font-weight: 800; }
h2 { font-size: 22px; line-height: 1.2; font-weight: 700; }
h3 { font-size: 17px; line-height: 1.3; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.stack > * + * { margin-top: 12px; }
.spacer { flex: 1; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 22px;
  border-radius: 999px; border: 0; font-weight: 600; font-size: 17px; text-decoration: none;
}
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:active { transform: scale(.98); }
.btn-ember { background: var(--ember); color: #2A1405; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-text { background: none; border: 0; color: var(--muted); padding: 8px 4px; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* Champs */
.field { display: block; }
.field span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%; min-height: 52px; padding: 0 16px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--surface); font-size: 17px;
}
.field input:focus { outline: none; border-color: var(--focus); }

.card { background: var(--surface); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); }
.hint { font-size: 14px; color: var(--muted); }
.error { color: var(--rose); font-size: 15px; min-height: 22px; }

/* Braise (identité) */
.ember {
  border-radius: 50%;
  background: radial-gradient(circle at 50% 62%, var(--ember-hi) 0%, var(--ember) 46%, var(--ember-deep) 78%, rgba(194,65,12,0) 79%);
  box-shadow: 0 0 40px rgba(240,138,36,.35), 0 0 120px rgba(240,138,36,.18);
}

/* Connexion */
.login-hero { display: flex; flex-direction: column; align-items: flex-start; gap: 18px; margin: 28px 0 32px; }
.login-hero .ember { width: 64px; height: 64px; }
.login-hero h1 { font-size: 44px; }

/* Accueil */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.streak { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; background: var(--surface); padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow); }
.streak i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); display: inline-block; }
.streak.on i { background: radial-gradient(circle, var(--ember-hi), var(--ember) 60%, var(--ember-deep)); box-shadow: 0 0 10px var(--ember); }
.hello { margin: 26px 0 6px; }
.launch {
  margin: 22px 0 28px; display: flex; align-items: center; gap: 18px; width: 100%; padding: 20px; border: 0; border-radius: 24px;
  background: var(--ink); color: var(--bg); text-align: left;
}
.launch .ember { width: 58px; height: 58px; flex: none; animation: breathe 4s ease-in-out infinite; }
.launch strong { display: block; font-family: var(--display); font-size: 24px; font-weight: 800; line-height: 1.1; }
.launch span { font-size: 14px; opacity: .78; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 8px 0 12px; }
.mastery { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--surface); border-radius: 18px; padding: 14px; display: flex; gap: 12px; align-items: center; min-height: 76px; box-shadow: var(--shadow); }
.dot { width: 26px; height: 26px; border-radius: 50%; flex: none; border: 2px dashed var(--line); }
.dot.l1 { border: 0; background: radial-gradient(circle at 50% 60%, #F5D6B8, #E6B48A 70%); opacity: .7; }
.dot.l2 { border: 0; background: radial-gradient(circle at 50% 60%, #FFE2B0, #F3A65A 70%); }
.dot.l3 { border: 0; background: radial-gradient(circle at 50% 60%, var(--ember-hi), var(--ember) 60%, var(--ember-deep)); box-shadow: 0 0 10px rgba(240,138,36,.45); }
.dot.l4 { border: 0; background: radial-gradient(circle at 50% 60%, #FFF1C9, var(--ember-hi) 30%, var(--ember) 65%, var(--ember-deep)); box-shadow: 0 0 16px rgba(240,138,36,.8), 0 0 4px #fff inset; }
.tile b { display: block; font-size: 14px; line-height: 1.25; }
button.tile { border: 0; font: inherit; color: var(--ink); text-align: left; width: 100%; cursor: pointer; }
button.tile:active { transform: scale(.98); }
button.tile::after { content: "›"; margin-left: auto; font-size: 22px; color: var(--muted); }
.tile.locked { opacity: .55; }
.case.todo { background: var(--surface-2); box-shadow: none; border: 1.5px dashed var(--line); cursor: pointer; color: var(--muted); }
.case.todo .q { font-size: 13px; font-style: italic; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.case .lock { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1.5px dashed var(--line); font-weight: 800; color: var(--muted); }
.tile small { color: var(--muted); font-size: 13px; }
.legend { font-size: 13px; color: var(--muted); margin-top: 10px; }
.axes { display: grid; gap: 10px; }
.axis { display: grid; grid-template-columns: 92px 1fr 34px; gap: 10px; align-items: center; font-size: 14px; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--ember); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-top: 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.modes button { min-height: 40px; border: 0; border-radius: 999px; background: transparent; font: inherit; font-weight: 600; font-size: 15px; color: var(--muted); cursor: pointer; }
.modes button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.mode-hint { font-size: 13px; color: var(--muted); text-align: center; margin: 6px 0 0; }
.cases { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.case { position: relative; text-align: left; background: var(--surface); border: 0; border-radius: 18px; padding: 14px 12px 12px; box-shadow: var(--shadow); font: inherit; color: var(--ink); cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.case:active { transform: scale(.98); }
.case .who { position: relative; width: 52px; height: 52px; }
.case .who .avatar { width: 52px; height: 52px; font-size: 19px; }
.case .note { position: absolute; right: -8px; bottom: -4px; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 2px; white-space: nowrap; font-family: var(--display); font-weight: 800; font-size: 12px; border: 2px solid var(--surface); }
.note.n-rouge { background: #D33A3A; color: #fff; }
.note.n-orange { background: #F08A24; color: #2A1405; }
.note.n-vert-clair { background: #9ED9A6; color: #133A1C; }
.note.n-vert { background: #1E8E4E; color: #fff; }
.case b { font-size: 14px; line-height: 1.25; }
.case .t { font-size: 13px; color: var(--muted); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.case small { font-size: 12px; color: var(--muted); }
.case.joue { cursor: default; }
.case.joue:active { transform: none; }
.note .trophee { width: 11px; height: 11px; fill: currentColor; flex: none; }
.case .actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; margin-top: auto; padding-top: 2px; }
.case .actions button { border: 1.5px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 5px 11px; min-height: 30px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap; }
.case .actions button:active { transform: scale(.96); }
/* Obsidienne : verre volcanique violet presque noir, reflet qui balaie la surface */
.case .actions .hardcore { align-self: stretch; position: relative; isolation: isolate; overflow: hidden; padding: 5px 8px; font-weight: 700; border: 0; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.45);
  background: linear-gradient(135deg, #2a0f45 0%, #12051f 45%, #1d0a33 70%, #3b1466 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), inset 0 -2px 6px rgba(0,0,0,.6), 0 0 0 1px #4b1d80, 0 4px 14px rgba(59,20,102,.5); }
.case .actions .hardcore::before, .note.n-obsidienne::before { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit;
  background: linear-gradient(115deg, transparent 30%, rgba(214,180,255,.55) 48%, rgba(255,255,255,.85) 50%, rgba(214,180,255,.4) 53%, transparent 62%);
  transform: translateX(-120%); animation: obsidienne-reflet 3.2s cubic-bezier(.6,0,.2,1) infinite; }
.case .actions .hardcore svg { width: 13px; height: 13px; fill: #fff; flex: none; position: relative; z-index: 2; filter: drop-shadow(0 0 3px rgba(255,255,255,.55)); }
.case .actions .hardcore span { position: relative; z-index: 2; }
.note.n-obsidienne { color: #fff; overflow: hidden; background: linear-gradient(135deg, #3b1466 0%, #12051f 50%, #2a0f45 100%); }
.note.n-obsidienne { position: absolute; }
/* Trophée d'un cas réussi en Hardcore : chevauche l'avatar en haut à droite */
.case .badge-trophee { position: absolute; right: -10px; top: -8px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; z-index: 2;
  background: linear-gradient(135deg, #3b1466 0%, #12051f 55%, #2a0f45 100%); box-shadow: 0 0 0 2px var(--surface), 0 2px 6px rgba(18,5,31,.35); }
.case .badge-trophee svg { width: 18px; height: 18px; fill: #fff; }
@keyframes obsidienne-reflet { 0%, 55% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
@media (prefers-reduced-motion: reduce) { .case .actions .hardcore::before, .note.n-obsidienne::before { animation: none; } }
.brief-hardcore { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 4px 11px; border-radius: 999px; color: #fff; font-size: 13px; font-weight: 700; background: linear-gradient(135deg, #2a0f45 0%, #12051f 45%, #3b1466 100%); box-shadow: 0 0 0 1px #4b1d80; }
.brief-hardcore svg { width: 14px; height: 14px; fill: #fff; }
#brief-moment { white-space: pre-line; }
.score-pill { font-family: var(--display); font-weight: 700; }

