
:root{
  --terra:#C77660; --terra-d:#A85E4A; --jaune:#FCD415; --creme:#F7F0EA; --noir:#1D1D1B;
  --rouge:#DE1729; --sauge:#5F9595; --peche:#E5AB85; --grege:#C9BEB7;
  --bg:#FFFFFF; --surface:#F7F0EA; --surface2:#EFE4DA; --text:#1D1D1B; --muted:#6B625C;
  --on-terra:#FFFFFF; --line:#E6D9CE; --ok-bg:#E3EFEF; --ko-bg:#FBE3E4;
  color-scheme:light;
  box-sizing:border-box;
  padding-top:env(safe-area-inset-top,0px);
  padding-bottom:env(safe-area-inset-bottom,0px);
}
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --bg:#1D1D1B; --surface:#2A2622; --surface2:#352F2A; --text:#F7F0EA; --muted:#B8ACA3;
    --line:#40382F; --ok-bg:#20393A; --ko-bg:#45201F; --terra:#D58671; color-scheme:dark;
  }
}
:root[data-theme="dark"]{
  --bg:#1D1D1B; --surface:#2A2622; --surface2:#352F2A; --text:#F7F0EA; --muted:#B8ACA3;
  --line:#40382F; --ok-bg:#20393A; --ko-bg:#45201F; --terra:#D58671; color-scheme:dark;
}
*,*::before,*::after{box-sizing:border-box}
html{height:100%;scroll-padding-top:env(safe-area-inset-top,0px)}
body{margin:0;min-height:100%;background:var(--bg);color:var(--text);
  font-family:"Poppins",system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;font-size:16px;line-height:1.45;
  -webkit-tap-highlight-color:transparent}
body::after{content:"";position:fixed;left:0;right:0;bottom:0;height:calc(6px + env(safe-area-inset-bottom,0px));background:var(--jaune);z-index:5}
.app{max-width:520px;margin:0 auto;padding:16px 18px 40px;min-height:100vh}
button{font:inherit;color:inherit;cursor:pointer;border:0;background:none}
button:focus-visible,input:focus-visible{outline:3px solid var(--jaune);outline-offset:2px}
img{max-width:100%;display:block}
h1,h2,h3{margin:0;line-height:1.15}

/* Accueil */
.home{display:flex;flex-direction:column;gap:22px;padding-top:8px}
.logo{width:96px;height:96px}
.home-top{display:flex;align-items:center;justify-content:space-between}
.icon-btn{width:44px;height:44px;border-radius:50%;background:var(--surface);display:grid;place-items:center}
.hero{position:relative;border-radius:22px;overflow:hidden;aspect-ratio:16/10;background:var(--surface)}
.hero img{width:100%;height:100%;object-fit:cover}
.hero .badge-q{position:absolute;left:14px;bottom:14px;background:var(--jaune);color:#1D1D1B;font-weight:700;font-size:14px;padding:6px 12px;border-radius:999px}
.title{font-size:34px;font-weight:800;letter-spacing:-.02em}
.sub{color:var(--muted);margin-top:6px}
.field label{display:block;font-weight:600;font-size:14px;margin-bottom:6px}
.field input{width:100%;font:inherit;font-size:17px;padding:14px 16px;border-radius:14px;border:2px solid var(--line);background:var(--bg);color:var(--text)}
.btn{display:flex;align-items:center;justify-content:center;gap:10px;width:100%;min-height:56px;border-radius:16px;font-weight:700;font-size:17px;padding:12px 18px;transition:transform .08s}
.btn:active{transform:scale(.98)}
.btn-main{background:var(--terra);color:#fff;box-shadow:0 4px 0 var(--terra-d)}
.btn-sec{background:var(--surface);color:var(--text);box-shadow:0 4px 0 var(--surface2)}
.btn-jaune{background:var(--jaune);color:#1D1D1B;box-shadow:0 4px 0 #D9B400}
.stack{display:flex;flex-direction:column;gap:14px}
.small{font-size:13px;color:var(--muted)}

/* Barre haute */
.topbar{display:flex;align-items:center;gap:12px;margin-bottom:18px}
.topbar h2{font-size:20px;font-weight:700;flex:1}
.pill{background:var(--surface);border-radius:999px;padding:6px 12px;font-weight:700;font-size:14px;white-space:nowrap}

/* Carte des niveaux */
.map{position:relative;display:flex;flex-direction:column;gap:18px;padding:8px 0 20px}
.map::before{content:"";position:absolute;left:50%;top:40px;bottom:60px;width:6px;margin-left:-3px;
  background:repeating-linear-gradient(var(--line) 0 14px,transparent 14px 24px);border-radius:3px}
.lvl{position:relative;display:flex;align-items:center;gap:14px;width:86%;text-align:left;border-radius:20px;padding:14px;background:var(--surface);box-shadow:0 4px 0 var(--surface2)}
.lvl:nth-child(odd){align-self:flex-start}
.lvl:nth-child(even){align-self:flex-end;flex-direction:row-reverse;text-align:right}
.lvl.locked{opacity:.55}
.lvl.locked .tile{filter:grayscale(1)}
/* Tuile = tranche de panneau */
.tile{flex:none;width:64px;height:64px;border-radius:14px;overflow:hidden;display:flex;flex-direction:column;box-shadow:inset 0 0 0 2px rgba(0,0,0,.06)}
.tile i{flex:1;display:block}
.tile b{position:absolute;width:64px;height:64px;display:grid;place-items:center;font-size:26px;font-weight:800;color:#fff;text-shadow:0 2px 0 rgba(0,0,0,.25)}
.lvl-info{flex:1;min-width:0}
.lvl-info h3{font-size:16px;font-weight:700}
.lvl-info p{margin:2px 0 0;font-size:13px;color:var(--muted)}
.stars{display:inline-flex;gap:2px;margin-top:4px}
.star{width:18px;height:18px}
.lock{font-size:13px;font-weight:600;color:var(--muted);margin-top:4px}

/* Jeu */
.hud{display:flex;align-items:center;gap:10px;margin-bottom:10px}
.lives{display:flex;gap:6px}
.life{width:22px;height:22px}
.life.lost{opacity:.18;filter:grayscale(1)}
.hud .spacer{flex:1}
.combo{background:var(--jaune);color:#1D1D1B;border-radius:999px;padding:4px 10px;font-weight:800;font-size:13px}
.progress{height:8px;background:var(--surface);border-radius:4px;overflow:hidden;margin-bottom:8px}
.progress span{display:block;height:100%;background:var(--terra);border-radius:4px;transition:width .3s}
.timer{height:6px;background:var(--surface);border-radius:3px;overflow:hidden;margin-bottom:16px}
.timer span{display:block;height:100%;background:var(--jaune);transform-origin:left}
.timer.hurry span{background:var(--rouge)}
.qcount{font-size:13px;font-weight:600;color:var(--muted);margin-bottom:6px}
.qimg{background:#fff;border-radius:18px;padding:10px;margin-bottom:14px;display:grid;place-items:center}
.qimg img{max-height:170px;object-fit:contain}
.prompt{font-size:21px;font-weight:700;letter-spacing:-.01em;margin-bottom:18px}
.answers{display:flex;flex-direction:column;gap:12px}
.ans{display:flex;align-items:center;gap:14px;width:100%;min-height:64px;text-align:left;padding:12px 16px;border-radius:16px;
  background:var(--bg);border:2px solid var(--line);box-shadow:0 4px 0 var(--line);font-weight:600;font-size:16px;transition:transform .08s,background .15s,border-color .15s}
.ans:active{transform:translateY(2px);box-shadow:0 2px 0 var(--line)}
.ans .k{flex:none;width:32px;height:32px;border-radius:50%;background:var(--terra);color:#fff;display:grid;place-items:center;font-weight:800;font-size:15px}
.ans.ok{background:var(--ok-bg);border-color:var(--sauge);box-shadow:0 4px 0 var(--sauge)}
.ans.ok .k{background:var(--sauge)}
.ans.ko{background:var(--ko-bg);border-color:var(--rouge);box-shadow:0 4px 0 var(--rouge);animation:shake .35s}
.ans.ko .k{background:var(--rouge)}
.ans.dim{opacity:.5}
.ans[disabled]{cursor:default}
@keyframes shake{0%,100%{transform:translateX(0)}25%{transform:translateX(-6px)}75%{transform:translateX(6px)}}
.feedback{margin-top:16px;border-radius:18px;padding:16px;background:var(--surface)}
.feedback h3{font-size:18px;font-weight:800;margin-bottom:4px}
.feedback.good h3{color:var(--sauge)}
.feedback.bad h3{color:var(--rouge)}
.feedback p{margin:0 0 14px;font-size:15px}
.gain{font-weight:800;color:var(--terra)}

/* Fin */
.end{text-align:center;padding-top:20px}
.end .big-stars{display:flex;justify-content:center;gap:10px;margin:18px 0}
.end .big-stars .star{width:58px;height:58px}
.end .score{font-size:48px;font-weight:800;color:var(--terra);letter-spacing:-.02em}
.end .stat{display:flex;justify-content:center;gap:10px;margin:14px 0 22px;flex-wrap:wrap}
.newbadge{display:flex;align-items:center;gap:12px;text-align:left;background:var(--surface);border-radius:16px;padding:12px 14px;margin-bottom:12px}

/* Profil */
.card{background:var(--surface);border-radius:18px;padding:16px;margin-bottom:14px}
.card h3{font-size:16px;font-weight:700;margin-bottom:10px}
.row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:6px 0;font-size:14px}
.bar{flex:1;height:8px;background:var(--surface2);border-radius:4px;overflow:hidden;max-width:140px}
.bar span{display:block;height:100%;background:var(--terra)}
.badges{display:grid;grid-template-columns:repeat(2,1fr);gap:10px}
.bdg{background:var(--bg);border-radius:14px;padding:12px;display:flex;gap:10px;align-items:center}
.bdg.off{opacity:.4;filter:grayscale(1)}
.bdg .ico{flex:none;width:40px;height:40px;border-radius:50%;background:var(--jaune);display:grid;place-items:center;font-size:20px}
.bdg b{display:block;font-size:13px;line-height:1.2}
.bdg small{font-size:11px;color:var(--muted);line-height:1.2;display:block}
.toggle{display:flex;background:var(--surface);border-radius:14px;padding:4px;gap:4px}
.toggle button{flex:1;min-height:44px;border-radius:10px;font-weight:600;font-size:15px}
.toggle button[aria-pressed="true"]{background:var(--terra);color:#fff}
#confetti{position:fixed;inset:0;pointer-events:none;z-index:20}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
/* v2 */
.nav3{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-bottom:6px}
.nav3 button{background:var(--surface);border-radius:14px;min-height:64px;padding:8px 4px;font-weight:600;font-size:13px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;box-shadow:0 3px 0 var(--surface2)}
.nav3 button span{font-size:20px}
.lvl.bonus{background:#1D1D1B;color:#F7F0EA;box-shadow:0 4px 0 #000}
.lvl.bonus .lvl-info p{color:#C9BEB7}
.tag{display:inline-block;background:var(--jaune);color:#1D1D1B;font-size:11px;font-weight:800;padding:2px 8px;border-radius:999px;margin-bottom:4px;letter-spacing:.02em}
.chips{display:flex;flex-wrap:wrap;gap:8px}
.chip{min-height:40px;padding:6px 14px;border-radius:999px;background:var(--surface);font-weight:600;font-size:14px;border:2px solid transparent}
.chip[aria-pressed="true"]{background:var(--terra);color:#fff}
.lb{display:flex;flex-direction:column;gap:8px}
.lbrow{display:flex;align-items:center;gap:12px;background:var(--surface);border-radius:14px;padding:10px 14px}
.lbrow.me{outline:3px solid var(--jaune)}
.rank{flex:none;width:32px;height:32px;border-radius:50%;display:grid;place-items:center;font-weight:800;font-size:14px;background:var(--bg)}
.rank.r1{background:#FCD415;color:#1D1D1B}.rank.r2{background:#C9BEB7;color:#1D1D1B}.rank.r3{background:#E5AB85;color:#1D1D1B}
.lbname{flex:1;min-width:0}
.lbname b{display:block;font-size:15px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.lbname small{font-size:12px;color:var(--muted)}
.lbpts{font-weight:800;color:var(--terra);white-space:nowrap}
.note{background:var(--surface);border-radius:14px;padding:12px 14px;font-size:14px;color:var(--muted)}
.fgrid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}
.fcard{background:var(--surface);border-radius:16px;padding:10px;text-align:left;display:flex;flex-direction:column;gap:8px;box-shadow:0 3px 0 var(--surface2)}
.fcard .fi{background:#fff;border-radius:10px;height:92px;display:grid;place-items:center;padding:6px}
.fcard .fi img{max-height:80px;object-fit:contain}
.fcard b{font-size:14px;line-height:1.2}
.fcard small{font-size:12px;color:var(--muted);line-height:1.2}
.sheet-bg{position:fixed;inset:0;background:rgba(29,29,27,.5);z-index:30;display:flex;align-items:flex-end;justify-content:center}
.sheet{background:var(--bg);width:100%;max-width:520px;max-height:88vh;overflow:auto;border-radius:22px 22px 0 0;padding:20px 18px calc(24px + env(safe-area-inset-bottom,0px));animation:up .2s ease-out}
@keyframes up{from{transform:translateY(40px);opacity:0}to{transform:none;opacity:1}}
.sheet h2{font-size:22px;font-weight:800;margin-bottom:4px}
.sheet .aspect{color:var(--terra);font-weight:600;font-size:14px;margin-bottom:12px}
.sheet h3{font-size:14px;font-weight:700;margin:14px 0 4px;color:var(--terra)}
.sheet p{margin:0;font-size:15px}
.sheet .cle{margin-top:14px;background:var(--jaune);color:#1D1D1B;border-radius:14px;padding:12px 14px;font-weight:600;font-size:15px}
.linkbtn{color:var(--terra);font-weight:700;font-size:14px;text-decoration:underline;text-underline-offset:3px;padding:6px 0;margin-bottom:10px}
.famrow{width:100%;text-align:left}
.cert{background:#F7F0EA;color:#1D1D1B;border-radius:22px;padding:28px 22px;text-align:center;border:3px solid #C77660;box-shadow:inset 0 0 0 8px #F7F0EA,inset 0 0 0 10px #FCD415;margin-bottom:16px}
.cert img{width:84px;height:84px;margin:0 auto 10px}
.cert .k{font-size:12px;font-weight:700;letter-spacing:.18em;text-transform:uppercase;color:#C77660}
.cert h2{font-size:26px;font-weight:800;margin:8px 0 14px;line-height:1.15}
.cert .who{font-size:30px;font-weight:800;color:#C77660;margin:6px 0 2px;word-break:break-word}
.cert p{margin:4px 0;font-size:14px;color:#5A524C}
.cert .cstars{display:flex;justify-content:center;gap:4px;margin:12px 0 6px}
.certcard{background:#1D1D1B;color:#F7F0EA}
.certcard .small{color:#C9BEB7}
.acct{background:var(--surface);border-radius:16px;padding:14px;display:flex;flex-direction:column;gap:6px}
.acct b{font-size:15px}
.acct-row{display:flex;gap:8px;margin-top:4px}
.acct-row input{flex:1;min-width:0;font:inherit;font-size:16px;padding:12px 14px;border-radius:12px;border:2px solid var(--line);background:var(--bg);color:var(--text)}
.acct-row .btn{width:auto;min-height:48px;padding:8px 16px;font-size:15px}

.req{display:inline-block;margin-left:6px;font-size:11px;font-weight:700;color:var(--terra);background:var(--surface);border-radius:999px;padding:1px 8px}
