/* Pèlerin — une marche de nuit éclairée par une lampe : fond indigo, lumière dorée, texte biblique sur parchemin. */
:root {
  --bg: #0e1127; --bg2: #161a3a; --card: #1d2248; --card2: #262c5c; --line: #323a74;
  --ink: #f1f2ff; --muted: #a2a8d3; --gold: #ffc94d; --gold-deep: #e09a1f; --ember: #ff8f3f;
  --green: #4fd39a; --green-deep: #2f9e6e; --red: #ff6b6b; --red-deep: #c94848; --blue: #6aa8ff;
  --parch: #fbf3df; --parch-ink: #3a2d18; --parch-line: #e6d6ad;
  --accent: var(--gold);
  /* Couleurs de texte lisibles sur le fond (le doré, le vert et le rouge servent aussi de remplissage). */
  --gold-ink: var(--gold); --green-ink: var(--green); --red-ink: var(--red); --ink-soft: #dfe2ff;
  --page: #080a1a; --app-glow: #2a2f6a; --topbar-bg: #0e1127e6; --tabbar-bg: #0b0d20;
  --hair: #ffffff14; --hair-strong: #ffffff20; --track: #ffffff14; --soft: #ffffff0a; --shadow-deep: #12163a;
  --btn-off-bg: #343a6b; --btn-off-ink: #7b82b5; --btn-off-shadow: #262b55; --action-a: #2b3170;
  --node-bg: #2b3166; --node-ink: #7d84b8; --node-shadow: #1a1e45; --star-shadow: 0 1px 2px #000;
  --bubble-bg: #fff; --bubble-ink: #1b1b3a; --toast-bg: #fff; --toast-ink: #1b1b3a; --backdrop: #05061299;
  --feedback-ok: #143d2e; --feedback-ko: #47191d; --feedback-ink: #e9ecff; --opt-ok-ink: #c9ffe6; --opt-ko-ink: #ffd6d6;
  --hero-a: #fff3cf; --hero-b: var(--gold); --kicker-mix: 100%;
  color-scheme: dark;
  --ui: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --tab-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px);
}
/* Thème clair : le même chemin à l'aube — fond crème, encre indigo, la lampe garde son or. */
:root[data-theme="light"] {
  --bg: #f6f1e6; --bg2: #fffaf0; --card: #ffffff; --card2: #f3ecdc; --line: #e0d4b8;
  --ink: #23264a; --muted: #67688a; --ember: #d9620c; --blue: #2f6fd6;
  --gold-ink: #9a5b00; --green-ink: #1c7a4f; --red-ink: #c23a3a; --ink-soft: #44476b;
  --page: #e8e0cf; --app-glow: #ffe3a3; --topbar-bg: #f6f1e6e6; --tabbar-bg: #fffaf0;
  --hair: #23264a17; --hair-strong: #23264a24; --track: #23264a14; --soft: #23264a08; --shadow-deep: #ddd0b2;
  --btn-off-bg: #e7e0d0; --btn-off-ink: #a39c88; --btn-off-shadow: #d4cab3; --action-a: #fff1cf;
  --node-bg: #e9e1ce; --node-ink: #9b937d; --node-shadow: #d2c7aa; --star-shadow: 0 1px 1px #9a5b00;
  --bubble-bg: #23264a; --bubble-ink: #fff; --toast-bg: #23264a; --toast-ink: #fff; --backdrop: #23264a66;
  --feedback-ok: #dcf4e7; --feedback-ko: #fde2e0; --feedback-ink: #23264a; --opt-ok-ink: #0f5234; --opt-ko-ink: #7a1a1a;
  --hero-a: #f0a92a; --hero-b: #9a5b00; --kicker-mix: 55%;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--page); color: var(--ink); font-family: var(--ui); font-size: 16px; }
body { overscroll-behavior-y: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input { font: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

#app {
  position: relative; max-width: 520px; height: 100dvh; margin: 0 auto; background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
  background-image: radial-gradient(1200px 500px at 50% -10%, var(--app-glow) 0%, transparent 60%);
}
.screen { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px 16px calc(24px + var(--safe-b)); scroll-behavior: smooth; }
.screen::-webkit-scrollbar { width: 0; }

/* ───────── Barre du haut et onglets ───────── */
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--hair); background: var(--topbar-bg); backdrop-filter: blur(8px); z-index: 5; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; background: var(--card); font-weight: 800; font-size: 14px; border: 1px solid var(--hair); }
.pill.hot { color: var(--ember); } .pill.cold { color: var(--muted); filter: grayscale(.8); }
.pill.gold { color: var(--gold-ink); }
.goalbar { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.goalbar small { font-size: 11px; color: var(--muted); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 10px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--ember), var(--gold)); transition: width .6s cubic-bezier(.2, .9, .3, 1); min-width: 0; }
.bar.green > i { background: linear-gradient(90deg, var(--green-deep), var(--green)); }
.bar.thin { height: 6px; }

.tabbar { display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--tabbar-bg); border-top: 1px solid var(--hair); z-index: 5; }
.tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 800; color: var(--muted); }
.tab span { font-size: 23px; filter: grayscale(.9) opacity(.7); transition: transform .2s; }
.tab.on { color: var(--gold-ink); } .tab.on span { filter: none; transform: translateY(-2px) scale(1.12); }
.tab b.dot { position: absolute; top: 8px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

/* ───────── Boutons ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; padding: 12px 18px;
  border-radius: 16px; font-weight: 900; font-size: 16px; letter-spacing: .02em; text-transform: uppercase;
  background: var(--gold); color: #3a2600; box-shadow: 0 5px 0 var(--gold-deep); transition: transform .08s, box-shadow .08s, filter .2s; user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--gold-deep); }
.btn:disabled { background: var(--btn-off-bg); color: var(--btn-off-ink); box-shadow: 0 5px 0 var(--btn-off-shadow); cursor: default; }
.btn.green { background: var(--green); color: #05301f; box-shadow: 0 5px 0 var(--green-deep); }
.btn.green:active:not(:disabled) { box-shadow: 0 1px 0 var(--green-deep); }
.btn.red { background: var(--red); color: #3d0707; box-shadow: 0 5px 0 var(--red-deep); }
.btn.ghost { background: var(--card); color: var(--ink); box-shadow: 0 5px 0 var(--shadow-deep); border: 1px solid var(--line); }
.btn.ghost:active:not(:disabled) { box-shadow: 0 1px 0 var(--shadow-deep); }
.btn.small { width: auto; min-height: 38px; padding: 6px 14px; font-size: 13px; border-radius: 12px; box-shadow: 0 3px 0 var(--gold-deep); }
.btn.small.ghost { box-shadow: 0 3px 0 var(--shadow-deep); } .btn.small.green { box-shadow: 0 3px 0 var(--green-deep); }
.link { color: var(--blue); font-weight: 800; padding: 10px; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; color: var(--muted); }
.iconbtn.on { background: var(--card2); color: var(--gold-ink); }

/* ───────── Cartes génériques ───────── */
.card { background: var(--card); border: 1px solid var(--hair); border-radius: 18px; padding: 14px; }
.card + .card, .stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
.title { font-size: 20px; font-weight: 900; } .big { font-size: 28px; font-weight: 900; }
.h { font-size: 13px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 20px 4px 10px; }
.emoji { font-size: 30px; line-height: 1; } .emoji.xl { font-size: 64px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--track); font-size: 11px; font-weight: 800; color: var(--muted); }
.tag.gold { background: #ffc94d26; color: var(--gold-ink); } .tag.red { background: #ff6b6b26; color: var(--red-ink); } .tag.green { background: #4fd39a26; color: var(--green-ink); }
.action-card { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: linear-gradient(135deg, var(--action-a), var(--card)); border: 1px solid var(--hair-strong); border-radius: 18px; padding: 12px 14px; }
.action-card.glow { border-color: #ffc94d70; box-shadow: 0 0 0 1px #ffc94d30, 0 8px 24px -12px #ffc94d; animation: breathe 2.4s ease-in-out infinite; }

/* ───────── Authentification ───────── */
.auth { display: flex; flex-direction: column; justify-content: center; gap: 14px; min-height: 100%; padding: 8px 6px; }
.hero { text-align: center; padding: 18px 0 4px; }
.hero .lamp { font-size: 76px; filter: drop-shadow(0 0 28px #ffc94d); animation: float 3.2s ease-in-out infinite; }
.hero h1 { font-size: 42px; font-weight: 900; letter-spacing: -.02em; background: linear-gradient(180deg, var(--hero-a), var(--hero-b)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); font-weight: 700; margin-top: 4px; }
.field { display: block; }
.field span { display: block; font-size: 12px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 4px 6px; }
.input { width: 100%; height: 52px; padding: 0 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg2); color: var(--ink); font-weight: 700; outline: none; }
.input:focus { border-color: var(--gold); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { min-width: 48px; height: 48px; padding: 0 12px; border-radius: 14px; background: var(--bg2); border: 2px solid var(--line); font-size: 24px; font-weight: 800; display: grid; place-items: center; }
.choice.text { font-size: 14px; flex: 1; height: auto; padding: 10px 8px; line-height: 1.25; }
.choice.on { border-color: var(--gold); background: #ffc94d1f; }
.error { color: var(--red); font-weight: 800; text-align: center; min-height: 20px; font-size: 14px; }

/* ───────── Le Chemin ───────── */
.region-banner { border-radius: 22px; padding: 16px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 34%, var(--card)), var(--card) 70%); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.region-banner .kicker { font-size: 12px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: color-mix(in srgb, var(--accent) var(--kicker-mix), var(--ink)); }
.region-banner h2 { font-size: 26px; font-weight: 900; margin: 2px 0; }
.region-banner p { color: var(--ink-soft); font-size: 14px; opacity: .85; }
.booknav { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.booknav .btn.small { flex: 1; white-space: nowrap; }
.booknav .btn.small:nth-child(2) { flex: 4; }
.path { position: relative; margin: 18px auto 8px; width: 100%; }
.path svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.node { position: absolute; width: 68px; height: 68px; margin: -34px 0 0 -34px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 20px;
  background: var(--node-bg); color: var(--node-ink); box-shadow: 0 6px 0 var(--node-shadow); transition: transform .1s; }
.node:active { transform: translateY(3px); }
.node.done { background: radial-gradient(circle at 35% 30%, #fff0bd, var(--gold) 60%); color: #4a3200; box-shadow: 0 6px 0 var(--gold-deep), 0 0 26px -4px #ffc94daa; }
.node.current { background: radial-gradient(circle at 35% 30%, #ffffff, var(--accent) 70%); color: #1b1b3a; box-shadow: 0 6px 0 color-mix(in srgb, var(--accent) 60%, #000), 0 0 0 8px color-mix(in srgb, var(--accent) 25%, transparent); animation: pulse 1.8s ease-in-out infinite; }
.node.boss { border-radius: 22px; font-size: 30px; }
.node .stars { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 12px; letter-spacing: 1px; white-space: nowrap; color: var(--gold); text-shadow: var(--star-shadow); }
.node .stars i { font-style: normal; opacity: .25; }
.node .here { position: absolute; top: -40px; left: 50%; transform: translateX(-50%); background: var(--bubble-bg); color: var(--bubble-ink); border-radius: 12px; padding: 4px 10px; font-size: 12px; font-weight: 900; white-space: nowrap; animation: float 1.6s ease-in-out infinite; }
.node .here::after { content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-top-color: var(--bubble-bg); border-bottom: 0; }
.decor { position: absolute; font-size: 30px; opacity: .5; pointer-events: none; transform: translate(-50%, -50%); }
.fab { position: sticky; bottom: 0; padding-top: 10px; background: linear-gradient(180deg, transparent, var(--bg) 40%); z-index: 3; }
.worldlist .regionhead { display: flex; align-items: center; gap: 10px; margin: 18px 2px 8px; }
.worldlist .regionhead b { font-size: 16px; }
.bookrow { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 12px; border-radius: 14px; background: var(--card); margin-top: 6px; }
.bookrow.locked { opacity: .5; }
.bookrow.cur { outline: 2px solid var(--gold); }

/* ───────── Feuilles et fenêtres ───────── */
#overlay { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.backdrop { position: absolute; inset: 0; background: var(--backdrop); pointer-events: auto; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.backdrop.mid { align-items: center; padding: 20px; }
.sheet { width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto; background: var(--bg2); border-radius: 26px 26px 0 0; padding: 20px 18px calc(22px + var(--safe-b)); border-top: 1px solid var(--hair-strong); animation: rise .28s cubic-bezier(.2, .9, .3, 1.1); }
.modal { width: 100%; max-width: 400px; background: var(--bg2); border: 1px solid var(--hair-strong); border-radius: 26px; padding: 24px 20px 20px; text-align: center; animation: pop .32s cubic-bezier(.2, 1.3, .4, 1); }
.modal .emoji.xl { display: block; margin-bottom: 8px; animation: pop .5s .1s both cubic-bezier(.2, 1.6, .4, 1); }
.modal p { color: var(--muted); margin: 8px 0 18px; line-height: 1.45; }
#toasts { position: fixed; top: 14px; left: 0; right: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--toast-bg); color: var(--toast-ink); font-weight: 800; padding: 10px 16px; border-radius: 14px; box-shadow: 0 10px 30px #000a; animation: drop .3s cubic-bezier(.2, 1.3, .4, 1); max-width: 90vw; text-align: center; }
.toast.bad { background: var(--red); color: #fff; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }

/* ───────── Partie : lecture ───────── */
.flow { display: flex; flex-direction: column; height: 100%; }
.flowbar { display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px; }
.flowbar .bar { flex: 1; height: 14px; }
.combo { font-weight: 900; color: var(--ember); min-width: 44px; text-align: right; transition: transform .2s; }
.combo.bump { animation: pop .35s; }
.flowbody { flex: 1; overflow-y: auto; padding: 8px 16px 16px; display: flex; flex-direction: column; }
.flowbody::-webkit-scrollbar { width: 0; }
.flowfoot { padding: 12px 16px calc(16px + var(--safe-b)); }
.scenehead { text-align: center; color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; margin: 4px 0 12px; }
.verse { position: relative; background: var(--parch); color: var(--parch-ink); border-radius: 18px; padding: 16px 16px 16px 44px; font-family: var(--serif); font-size: 20px; line-height: 1.5; margin-bottom: 10px; box-shadow: 0 6px 0 #c9b98a, 0 14px 30px -18px #000; animation: versein .45s cubic-bezier(.2, .9, .3, 1.1) both; }
.verse .num { position: absolute; left: 12px; top: 18px; width: 24px; height: 24px; border-radius: 50%; background: #e9d9ae; color: #7a6230; font: 900 12px/24px var(--ui); text-align: center; }
.verse.past { opacity: .5; font-size: 16px; padding-top: 10px; padding-bottom: 10px; box-shadow: none; transform: scale(.98); transition: all .3s; }
.verse.past .num { top: 10px; }
.verse em { font-style: normal; font-weight: 700; color: #9a5a00; }
.verse.gold { background: linear-gradient(135deg, #fff6d2, #ffe08a); box-shadow: 0 6px 0 var(--gold-deep), 0 0 40px -6px var(--gold); }
.verse .goldtag { display: inline-block; margin-bottom: 6px; padding: 2px 10px; border-radius: 99px; background: #7a4b00; color: #ffe9a8; font: 900 11px var(--ui); letter-spacing: .08em; text-transform: uppercase; animation: pop .5s .2s both; }
.tap-hint { margin-top: auto; padding-top: 14px; text-align: center; color: var(--muted); font-size: 13px; font-weight: 800; animation: breatheo 1.6s ease-in-out infinite; }
.introcard { margin: auto 0; text-align: center; }
.introcard .emoji.xl { font-size: 84px; animation: float 3s ease-in-out infinite; display: inline-block; }
.introcard h2 { font-size: 34px; font-weight: 900; margin-top: 8px; }
.introcard .teaser { font-family: var(--serif); font-size: 18px; font-style: italic; color: var(--ink-soft); margin: 14px 10px; line-height: 1.45; }

/* ───────── Défis ───────── */
.q { animation: slidein .3s cubic-bezier(.2, .9, .3, 1) both; display: flex; flex-direction: column; flex: 1; }
.q h3 { font-size: 21px; font-weight: 900; margin: 6px 2px 14px; }
.q .ref { color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; margin: 0 2px; }
.scripture { background: var(--parch); color: var(--parch-ink); border-radius: 18px; padding: 16px; font-family: var(--serif); font-size: 19px; line-height: 1.6; box-shadow: 0 5px 0 #c9b98a; margin-bottom: 16px; }
.blank { display: inline-block; min-width: 76px; border-bottom: 3px solid #b99a55; text-align: center; font-weight: 700; color: transparent; margin: 0 2px; transition: all .2s; line-height: 1.2; }
.blank.next { border-color: #e09a1f; background: #ffe6a8; border-radius: 6px 6px 0 0; }
.blank.ok { color: #1c7a4f; border-color: #1c7a4f; } .blank.ko { color: #b53030; border-color: #b53030; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: auto; }
.opts.col { grid-template-columns: 1fr; }
.opt { min-height: 56px; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--shadow-deep); font-weight: 800; font-size: 17px; transition: transform .08s, background .2s; text-align: center; }
.opt.long { text-align: left; font-family: var(--serif); font-weight: 400; font-size: 16px; line-height: 1.4; }
.opt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--shadow-deep); }
.opt.sel { border-color: var(--blue); background: #6aa8ff22; }
.opt.ok { border-color: var(--green); background: #4fd39a2e; color: var(--opt-ok-ink); box-shadow: 0 4px 0 var(--green-deep); animation: pop .35s; }
.opt.ko { border-color: var(--red); background: #ff6b6b2e; color: var(--opt-ko-ink); box-shadow: 0 4px 0 var(--red-deep); animation: shake .35s; }
.opt:disabled { cursor: default; } .opt.dim { opacity: .45; }
.dropzone { min-height: 120px; background: var(--parch); border-radius: 18px; padding: 12px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; box-shadow: 0 5px 0 #c9b98a; margin-bottom: 16px; }
.dropzone:empty::before { content: "Touche les morceaux dans le bon ordre…"; color: #a08c5e; font-family: var(--serif); font-style: italic; padding: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: auto; padding-top: 8px; }
.chip { padding: 9px 13px; border-radius: 12px; background: var(--card2); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--shadow-deep); font-family: var(--serif); font-size: 17px; animation: pop .25s both; }
.dropzone .chip.still { animation: none; }
.dropzone .chip { background: #fff; color: var(--parch-ink); border-color: var(--parch-line); box-shadow: 0 3px 0 #d8c79a; }
.chip.used { visibility: hidden; }
.chip.ok { background: #d5f5e3 !important; border-color: #1c7a4f !important; color: #0f5234 !important; }
.chip.ko { background: #ffd9d9 !important; border-color: #b53030 !important; color: #7a1a1a !important; animation: shake .35s; }
.words { line-height: 2.25; }
.word { display: inline-block; padding: 1px 5px; margin: 0 1px; border-radius: 8px; border-bottom: 2px dashed #cdb97f; transition: background .15s; cursor: pointer; }
.word:active { background: #ffe6a8; }
.word.ok { background: #bfeed6; border-bottom-color: #1c7a4f; } .word.ko { background: #ffd0d0; border-bottom-color: #b53030; text-decoration: line-through; }
.word.miss { background: #ffd0d0; border-bottom-color: #b53030; }
.word.fix { background: #bfeed6; font-weight: 700; border-bottom-style: solid; border-bottom-color: #1c7a4f; }
.pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: stretch; }
.pair { padding: 10px 12px; border-radius: 14px; background: var(--parch); color: var(--parch-ink); font-family: var(--serif); font-size: 15px; line-height: 1.35; text-align: left; border: 3px solid transparent; box-shadow: 0 4px 0 #c9b98a; min-height: 84px; transition: transform .1s; }
.pair.sel { border-color: var(--blue); transform: scale(1.02); }
.pair.ok { background: #d5f5e3; border-color: #1c7a4f; box-shadow: none; opacity: .85; }
.pair.ko { animation: shake .35s; border-color: #b53030; }
.pair small { display: block; font: 900 11px var(--ui); color: #7a6230; margin-bottom: 3px; }
.typein { display: inline-block; width: 7.2ch; min-width: 60px; border: 0; border-bottom: 3px solid #b99a55; background: #fff8e3; font: 700 18px var(--serif); color: var(--parch-ink); text-align: center; border-radius: 6px 6px 0 0; padding: 2px 4px; outline: none; margin: 0 2px; }
.typein:focus { border-color: #e09a1f; background: #ffe6a8; }
.typein.ok { color: #1c7a4f; border-color: #1c7a4f; background: #d5f5e3; } .typein.ko { color: #b53030; border-color: #b53030; background: #ffd9d9; }
.typefix { font: 700 13px var(--ui); color: #1c7a4f; }

.feedback { border-radius: 22px 22px 0 0; padding: 16px 16px calc(16px + var(--safe-b)); animation: rise .25s cubic-bezier(.2, .9, .3, 1.1); }
.feedback.ok { background: var(--feedback-ok); } .feedback.ko { background: var(--feedback-ko); }
.feedback b { display: block; font-size: 20px; font-weight: 900; margin-bottom: 4px; }
.feedback.ok b { color: var(--green-ink); } .feedback.ko b { color: var(--red-ink); }
.feedback p { font-family: var(--serif); font-size: 15px; line-height: 1.45; color: var(--feedback-ink); margin-bottom: 12px; max-height: 22dvh; overflow-y: auto; }
.feedback p small { display: block; font: 900 11px var(--ui); letter-spacing: .08em; text-transform: uppercase; opacity: .7; margin-bottom: 2px; }
.timer { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; margin: 0 16px; }
.timer > i { display: block; height: 100%; background: var(--blue); border-radius: 99px; transform-origin: left; }
.timer.low > i { background: var(--red); }

/* ───────── Résultats ───────── */
.results { text-align: center; margin: auto 0; }
.bigstars { font-size: 60px; letter-spacing: 6px; margin: 6px 0 2px; }
.bigstars span { display: inline-block; opacity: .18; filter: grayscale(1); }
.bigstars span.on { opacity: 1; filter: none; animation: starpop .6s both cubic-bezier(.2, 1.7, .4, 1); }
.bigstars span.on:nth-child(2) { animation-delay: .25s; } .bigstars span.on:nth-child(3) { animation-delay: .5s; }
.xplines { text-align: left; margin: 14px 0; }
.xplines .row { justify-content: space-between; padding: 7px 4px; border-bottom: 1px dashed var(--hair-strong); font-weight: 700; animation: slidein .3s both; }
.xplines .row b { color: var(--gold-ink); } .xplines .row.neg b { color: var(--muted); }
.xptotal { font-size: 44px; font-weight: 900; color: var(--gold-ink); text-shadow: 0 0 30px #ffc94d80; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0; }
.badge { padding: 8px 12px; border-radius: 14px; background: var(--card2); font-weight: 800; font-size: 14px; animation: pop .4s both; }
.treasure-pick { text-align: left; width: 100%; background: var(--parch); color: var(--parch-ink); border-radius: 16px; padding: 12px 14px; font-family: var(--serif); font-size: 16px; line-height: 1.45; border: 3px solid transparent; box-shadow: 0 4px 0 #c9b98a; margin-top: 10px; }
.treasure-pick small { display: block; font: 900 11px var(--ui); letter-spacing: .06em; color: #7a6230; margin-bottom: 2px; }
.treasure-pick.on { border-color: var(--gold-deep); background: #fff1c4; }

/* ───────── Listes, classements ───────── */
.seg { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; }
.seg::-webkit-scrollbar { height: 0; }
.seg button { flex: none; padding: 9px 14px; border-radius: 99px; background: var(--card); font-weight: 800; font-size: 14px; color: var(--muted); border: 1px solid var(--hair); white-space: nowrap; }
.seg button.on { background: var(--gold); color: #3a2600; }
.lb { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 14px; margin-top: 6px; background: var(--card); }
.lb.me { background: #ffc94d1f; outline: 2px solid #ffc94d80; }
.lb .rk { width: 28px; text-align: center; font-weight: 900; color: var(--muted); }
.lb .av { width: 40px; height: 40px; border-radius: 50%; background: var(--card2); display: grid; place-items: center; font-size: 22px; flex: none; }
.lb .nm { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb .sc { font-weight: 900; color: var(--gold-ink); white-space: nowrap; }
.zone { text-align: center; font-size: 11px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; margin: 10px 0 2px; }
.zone.up { color: var(--green-ink); } .zone.down { color: var(--red-ink); }
.league-head { text-align: center; padding: 6px 0 10px; }
.league-head .emoji.xl { filter: drop-shadow(0 0 20px var(--accent)); }
.quest { display: flex; align-items: center; gap: 12px; }
.quest .grow b { display: block; font-size: 15px; margin-bottom: 6px; }
.ring { --p: 0; width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--gold) calc(var(--p) * 1%), var(--track) 0); position: relative; flex: none; }
.ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--card); }
.ring > * { position: relative; font-weight: 900; text-align: center; line-height: 1.1; }
.habit-card { margin-top: 12px; }
.habit-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 12px; }
.habit-day { min-width: 0; height: 58px; border-radius: 14px; background: var(--soft); border: 1px solid var(--hair); display: grid; place-items: center; align-content: center; gap: 3px; color: var(--muted); }
.habit-day small { font-weight: 900; text-transform: uppercase; }
.habit-day span { font-size: 19px; line-height: 1; }
.habit-day.on { background: #ffc94d1c; border-color: #ffc94d55; color: var(--gold-ink); }
.habit-day.today { outline: 2px solid var(--blue); outline-offset: 1px; }
.reminder-settings { margin-top: 8px; padding: 12px; border-radius: 14px; background: var(--soft); }
.reminder-settings p { margin-bottom: 10px; }
.reminder-time { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 800; margin-left: auto; }
.reminder-time .input { width: 116px; padding: 8px 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: var(--card); border-radius: 16px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 22px; font-weight: 900; } .stat small { color: var(--muted); font-weight: 700; font-size: 11px; }
.ach { background: var(--card); border-radius: 16px; padding: 10px 6px; text-align: center; font-size: 11px; font-weight: 800; line-height: 1.2; }
.ach span { display: block; font-size: 28px; margin-bottom: 4px; }
.ach.off { opacity: .35; filter: grayscale(1); }
.relics { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.relic { aspect-ratio: 1; border-radius: 12px; background: var(--card); display: grid; place-items: center; font-size: 22px; opacity: .25; filter: grayscale(1); }
.relic.on { opacity: 1; filter: none; background: #ffc94d26; box-shadow: inset 0 0 0 2px #ffc94d80; }
.trow { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; }
.trow .txt { font-family: var(--serif); font-size: 15px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pips { display: flex; gap: 3px; margin-top: 6px; }
.pips i { width: 16px; height: 6px; border-radius: 3px; background: var(--track); } .pips i.on { background: var(--gold); }
.avatar-lg { width: 84px; height: 84px; border-radius: 50%; background: var(--card2); display: grid; place-items: center; font-size: 46px; border: 3px solid var(--gold); flex: none; }
.codebox { font: 900 26px ui-monospace, Consolas, monospace; letter-spacing: .18em; color: var(--gold-ink); text-align: center; padding: 10px; background: var(--bg2); border-radius: 14px; border: 2px dashed var(--line); user-select: all; }
.loader { margin: 60px auto; width: 44px; height: 44px; border-radius: 50%; border: 5px solid var(--track); border-top-color: var(--gold); animation: spin .8s linear infinite; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; line-height: 1.5; }
.empty .emoji.xl { display: block; margin-bottom: 10px; opacity: .8; }

/* ───────── Animations ───────── */
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes drop { from { transform: translateY(-30px); opacity: 0; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.08); } }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes float { 50% { transform: translateY(-7px); } }
@keyframes pulse { 50% { box-shadow: 0 6px 0 color-mix(in srgb, var(--accent) 60%, #000), 0 0 0 14px color-mix(in srgb, var(--accent) 8%, transparent); } }
@keyframes breathe { 50% { transform: scale(1.012); } }
@keyframes breatheo { 50% { opacity: .45; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes versein { from { transform: translateY(24px) scale(.96); opacity: 0; } }
@keyframes slidein { from { transform: translateX(26px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media (min-width: 560px) { #app { border-left: 1px solid var(--hair); border-right: 1px solid var(--hair); } }

/* ───────── Pages légales (confidentialité, conditions, suppression de compte) ───────── */
body.legal-page { height: auto; min-height: 100%; background: var(--bg); overscroll-behavior-y: auto; }
.legal { max-width: 720px; margin: 0 auto; padding: 28px 16px 48px; line-height: 1.6; }
.legal h1 { font-size: 28px; margin: 6px 0 4px; color: var(--gold-ink); }
.legal h2 { font-size: 19px; margin: 28px 0 8px; }
.legal p, .legal ul { margin: 0 0 12px; color: var(--ink); }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 6px; }
.legal a { color: var(--blue); font-weight: 700; }
.legal .muted { color: var(--muted); }
.legal .todo { color: var(--ember); font-weight: 800; }
.legal nav { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); }
.legal form { display: grid; gap: 14px; margin-top: 18px; padding: 18px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); }
.legal .btn { width: 100%; }
