:root {
  --red:#E63946; --red-d:#c92f3b; --black:#1D1D1F; --cream:#FFF4EC; --grey:#6B6B70;
  --line:#EADFD6; --card:#fff; --green:#2A9D5C; --gold:#E9A23B;
  --radius:16px; --shadow:0 8px 30px rgba(230,57,70,.10);
  --lv-facile:#2A9D5C; --lv-moyen:#2F7FD1; --lv-difficile:#E9A23B; --lv-insane:#7B2CBF;
}
* { box-sizing:border-box; margin:0; padding:0; }
html { -webkit-text-size-adjust:100%; }
body { font-family:'Poppins',system-ui,sans-serif; background:var(--cream); color:var(--black);
       min-height:100vh; padding-bottom:calc(76px + env(safe-area-inset-bottom)); }
a { color:inherit; }
button { font-family:inherit; }
[hidden] { display:none !important; }

/* En-tête */
.top { display:flex; align-items:center; gap:12px; padding:12px 16px; max-width:640px; margin:0 auto; }
.brand img { height:40px; width:auto; display:block; }
.lang { margin-left:auto; display:flex; gap:2px; }
.lang button { background:none; border:none; font:600 13px 'Poppins',sans-serif; color:var(--grey);
               cursor:pointer; padding:6px 8px; border-radius:8px; }
.lang button.active { color:var(--black); background:#fff; }
.me { font-size:13px; font-weight:600; text-decoration:none; background:#fff; padding:6px 12px; border-radius:999px;
      max-width:130px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

main { max-width:640px; margin:0 auto; padding:8px 16px 24px; }
h1 { font-size:clamp(26px,6vw,36px); line-height:1.15; font-weight:700; }
h1 em { color:var(--red); font-style:italic; }
h2 { font-size:20px; font-weight:700; margin-bottom:10px; }
.sub { color:var(--grey); line-height:1.6; margin:8px 0 18px; }
.muted { color:var(--grey); font-size:14px; }
.center { text-align:center; }

/* Cartes et boutons */
.card { background:var(--card); border-radius:var(--radius); padding:18px; box-shadow:var(--shadow); margin-bottom:14px; }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; background:var(--red); color:#fff;
       border:none; border-radius:12px; padding:13px 20px; font:700 15px 'Poppins',sans-serif; cursor:pointer;
       text-decoration:none; transition:transform .12s, background .12s; }
.btn:hover { background:var(--red-d); }
.btn:active { transform:scale(.98); }
.btn.block { width:100%; }
.btn.ghost { background:#fff; color:var(--black); border:2px solid var(--line); }
.btn.ghost:hover { border-color:var(--black); }
.btn.dark { background:var(--black); }
.btn:disabled { opacity:.45; cursor:not-allowed; }
.row { display:flex; gap:10px; }
.row > * { min-width:0; }
input[type=email], input[type=text] { width:100%; border:2px solid var(--line); border-radius:12px; background:#fff;
       font:400 16px 'Poppins',sans-serif; padding:12px 14px; outline:none; }
input:focus { border-color:var(--black); }

/* Accueil */
.hero { text-align:center; padding:8px 0 18px; }
.daily { background:var(--black); color:#fff; border-radius:20px; padding:22px; margin-bottom:14px; position:relative; overflow:hidden; }
.daily h2 { color:#fff; font-size:22px; margin:6px 0 4px; }
.daily .muted { color:#c9c9cf; }
.daily .btn { margin-top:16px; }
.daily .kicker { font-size:12px; letter-spacing:.08em; text-transform:uppercase; color:var(--gold); font-weight:700; }
.daily::after { content:'?'; position:absolute; right:-6px; top:-34px; font:italic 700 160px 'Poppins'; color:rgba(255,255,255,.06); }
.levels { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:12px; }
.lv { border:none; border-radius:14px; padding:14px 12px; color:#fff; font:700 15px 'Poppins',sans-serif; cursor:pointer;
      text-align:left; position:relative; }
.lv small { display:block; font-weight:400; font-size:12px; opacity:.9; }
.lv.locked { opacity:.55; }
.lv.locked::after { content:'🔒'; position:absolute; right:10px; top:10px; font-size:14px; }
.lv-facile { background:var(--lv-facile); } .lv-moyen { background:var(--lv-moyen); }
.lv-difficile { background:var(--lv-difficile); } .lv-insane { background:var(--lv-insane); }
.chip { display:inline-block; font-size:12px; font-weight:700; color:#fff; padding:3px 10px; border-radius:999px; text-transform:uppercase; letter-spacing:.04em; }
.stats3 { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; text-align:center; }
.stats3 b { display:block; font-size:22px; }
.stats3 span { font-size:12px; color:var(--grey); }

/* Partie */
.gamehead { display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.gamehead .title { font-weight:700; }
.lives { margin-left:auto; display:flex; gap:3px; font-size:16px; }
.lives .lost { filter:grayscale(1); opacity:.3; }
.progress { display:flex; gap:4px; margin-bottom:14px; }
.progress i { flex:1; height:6px; border-radius:4px; background:var(--line); }
.progress i.on { background:var(--red); }
.clues { display:grid; gap:8px; margin-bottom:14px; }
.clue { background:#fff; border-radius:14px; padding:12px 14px; display:flex; gap:12px; align-items:center;
        box-shadow:0 2px 10px rgba(0,0,0,.04); animation:pop .35s ease; }
.clue .ic { font-size:20px; width:28px; text-align:center; flex:none; }
.clue .lb { font-size:12px; color:var(--grey); text-transform:uppercase; letter-spacing:.04em; }
.clue .vl { font-weight:700; font-size:16px; }
.clue.hiddenclue { background:transparent; border:2px dashed var(--line); box-shadow:none; color:var(--grey); animation:none; }
@keyframes pop { from { transform:translateY(6px); opacity:0; } to { transform:none; opacity:1; } }
.guessbox { position:sticky; bottom:calc(84px + env(safe-area-inset-bottom)); background:var(--cream); padding:8px 0; z-index:5; }
.ac { position:relative; }
.ac ul { list-style:none; position:absolute; left:0; right:0; bottom:100%; margin-bottom:6px; background:#fff; border-radius:12px;
         box-shadow:0 10px 30px rgba(0,0,0,.15); overflow:hidden; max-height:300px; overflow-y:auto; }
.ac li { padding:12px 14px; cursor:pointer; border-bottom:1px solid #f2ece6; }
.ac li:last-child { border-bottom:none; }
.ac li.sel, .ac li:hover { background:#FFE9E0; }
.wrong { display:flex; flex-wrap:wrap; gap:6px; margin:8px 0 0; }
.wrong span { background:#fde2e4; color:#a4161a; font-size:13px; padding:4px 10px; border-radius:999px; text-decoration:line-through; }
.actions { display:flex; gap:10px; margin-top:10px; }
.actions .btn { flex:1; }
.shake { animation:shake .35s; }
@keyframes shake { 25% { transform:translateX(-6px); } 75% { transform:translateX(6px); } }

/* Résultat */
.result { text-align:center; }
.result .photo { width:120px; height:120px; border-radius:50%; object-fit:cover; object-position:top; margin:4px auto 10px; display:block;
                 background:var(--line); border:4px solid #fff; box-shadow:var(--shadow); }
.result .big { font-size:30px; font-weight:700; }
.result .pts { font-size:42px; font-weight:700; color:var(--red); line-height:1; margin:12px 0 2px; }
.result .credit { font-size:11px; color:var(--grey); }
.emoji { font-size:22px; letter-spacing:2px; margin:10px 0; }

/* Classement */
.seg { display:flex; background:#fff; border-radius:12px; padding:4px; margin-bottom:14px; }
.seg button { flex:1; border:none; background:none; padding:9px; border-radius:9px; font:600 14px 'Poppins'; color:var(--grey); cursor:pointer; }
.seg button.active { background:var(--black); color:#fff; }
table.board { width:100%; border-collapse:collapse; }
.board td, .board th { padding:11px 8px; text-align:left; border-bottom:1px solid #f2ece6; font-size:15px; }
.board th { font-size:12px; color:var(--grey); text-transform:uppercase; font-weight:600; }
.board td:first-child { width:42px; font-weight:700; }
.board td:last-child, .board th:last-child { text-align:right; font-weight:700; }
.board tr.mine { background:#FFE9E0; }

/* Duels */
.code { font:700 34px 'Poppins'; letter-spacing:.18em; text-align:center; padding:10px; background:var(--cream); border-radius:12px; margin:10px 0; }
.rounds { display:grid; grid-template-columns:repeat(5,1fr); gap:8px; margin:12px 0; }
.round { border:2px solid var(--line); background:#fff; border-radius:12px; padding:10px 0; text-align:center; font-weight:700; cursor:pointer; }
.round.done { background:var(--black); color:#fff; border-color:var(--black); cursor:default; }
.round small { display:block; font-weight:400; font-size:11px; }
.versus { display:grid; grid-template-columns:1fr auto 1fr; align-items:center; text-align:center; gap:8px; }
.versus b { display:block; font-size:28px; }
.duelrow b:last-child { white-space:nowrap; }
.duelrow { display:flex; align-items:center; gap:10px; padding:10px 0; border-bottom:1px solid #f2ece6; text-decoration:none; }
.duelrow:last-child { border-bottom:none; }

/* Pub */
.ad-slot { min-height:100px; border:2px dashed var(--line); border-radius:12px; display:flex; align-items:center; justify-content:center;
           color:var(--grey); font-size:12px; margin:14px 0; }

/* Newsletter */
.newsletter { max-width:640px; margin:0 auto; padding:10px 16px 0; }
.newsletter > * { max-width:100%; }
.newsletter form { background:#fff; border-radius:var(--radius); padding:14px; }
.consent { display:flex; gap:10px; align-items:flex-start; font-size:12px; color:var(--grey); margin-top:10px; line-height:1.5; }
.consent input { margin-top:3px; accent-color:var(--red); }

/* Barre du bas */
.tabs { position:fixed; left:0; right:0; bottom:0; background:#fff; display:flex; justify-content:center; gap:clamp(0px,6vw,48px);
        border-top:1px solid var(--line); padding:6px 0 calc(6px + env(safe-area-inset-bottom)); z-index:10; }
.tabs a { text-decoration:none; display:flex; flex-direction:column; align-items:center; font-size:11px; color:var(--grey); padding:4px 10px; border-radius:10px; }
.tabs a span { font-size:20px; filter:grayscale(1); opacity:.6; }
.tabs a.active { color:var(--black); }
.tabs a.active span { filter:none; opacity:1; }
.foot { text-align:center; font-size:12px; color:var(--grey); padding:20px 16px 8px; max-width:640px; margin:0 auto; }
.foot a { color:var(--grey); }

.toast { position:fixed; left:50%; transform:translateX(-50%); bottom:calc(90px + env(safe-area-inset-bottom)); background:var(--black); color:#fff;
         padding:10px 16px; border-radius:12px; font-size:14px; z-index:50; max-width:90vw; text-align:center; }
.spinner { width:28px; height:28px; border:3px solid var(--line); border-top-color:var(--red); border-radius:50%; animation:spin .8s linear infinite; margin:40px auto; }
@keyframes spin { to { transform:rotate(360deg); } }
@media (max-width:380px) { .row { flex-direction:column; } }

/* ---- v2 : séries, chrono ---- */
:root { --lv-legende:#B5179E; }
.lv-legende { background:var(--lv-legende); }
.modes { display:grid; gap:12px; margin-bottom:14px; }
.mode { background:#fff; border-radius:18px; padding:16px; box-shadow:var(--shadow); display:flex; gap:14px; align-items:center; text-decoration:none; border:none; text-align:left; cursor:pointer; width:100%; font:inherit; color:inherit; }
.mode .ico { font-size:30px; width:52px; height:52px; border-radius:14px; display:flex; align-items:center; justify-content:center; flex:none; }
.mode h3 { font-size:17px; margin-bottom:2px; }
.mode p { font-size:13px; color:var(--grey); line-height:1.4; }
.mode .go { margin-left:auto; font-size:22px; color:var(--red); font-weight:700; }
.mode.series .ico { background:#FFE3E5; } .mode.chrono .ico { background:#E3F0FF; } .mode.duel .ico { background:#F0E7FF; }
.scorebar { display:flex; align-items:center; gap:10px; background:#fff; border-radius:14px; padding:10px 14px; margin-bottom:10px; box-shadow:0 2px 10px rgba(0,0,0,.04); }
.scorebar .sc { font-size:22px; font-weight:700; color:var(--red); }
.scorebar .sc small { font-size:12px; color:var(--grey); font-weight:600; margin-left:2px; }
.scorebar .right { margin-left:auto; display:flex; align-items:center; gap:10px; }
.hearts { font-size:18px; letter-spacing:2px; }
.timer { font:700 20px 'Poppins'; font-variant-numeric:tabular-nums; padding:4px 10px; border-radius:10px; background:var(--black); color:#fff; }
.timer.low { background:var(--red); animation:pulse 1s infinite; }
@keyframes pulse { 50% { opacity:.6; } }
.subhead { display:flex; align-items:center; gap:8px; margin:4px 0 10px; font-size:14px; color:var(--grey); }
.subhead b { color:var(--black); }
.cluegrid { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-bottom:8px; }
.cluegrid .clue { padding:10px 12px; gap:10px; }
.cluegrid .clue.wide { grid-column:1 / -1; }
.cluegrid .clue .vl { font-size:15px; line-height:1.3; }
.clue .ex { font-size:12px; color:var(--grey); font-weight:400; }
.feedback { border-radius:14px; padding:10px 12px; display:flex; gap:12px; align-items:center; margin-bottom:10px; animation:pop .3s ease; }
.feedback.ok { background:#E3F5EA; } .feedback.ko { background:#FDE2E4; }
.feedback img { width:44px; height:44px; border-radius:50%; object-fit:cover; object-position:top; background:#fff; flex:none; }
.feedback b { display:block; }
.feedback span { font-size:13px; color:var(--grey); }
.feedback .pts { margin-left:auto; font-weight:700; font-size:18px; color:var(--green); white-space:nowrap; }
.errs { font-size:13px; color:var(--grey); margin-top:6px; display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.errs .dots i { display:inline-block; width:8px; height:8px; border-radius:50%; background:var(--line); margin-right:3px; }
.errs .dots i.on { background:var(--red); }
.btn.small { padding:9px 12px; font-size:13px; }
.history { display:flex; flex-wrap:wrap; gap:4px; justify-content:center; font-size:20px; margin:10px 0; }

/* ---- v3 : barre du bas compacte, masquée en partie ---- */
.tabs { padding:3px 0 calc(3px + env(safe-area-inset-bottom)); transition:transform .25s ease; }
.tabs a { font-size:10px; padding:2px 10px; }
.tabs a span { font-size:18px; }
body { padding-bottom:calc(60px + env(safe-area-inset-bottom)); }
body.ingame { padding-bottom:env(safe-area-inset-bottom); }
body.ingame .tabs, body.tabs-hidden .tabs { transform:translateY(110%); }
body.ingame .foot, body.ingame .newsletter { display:none; }
body.ingame .guessbox { bottom:env(safe-area-inset-bottom); }
.guessbox { bottom:calc(60px + env(safe-area-inset-bottom)); }
.homebtn { font-size:13px; font-weight:600; text-decoration:none; color:var(--grey); padding:6px 4px; }

/* ---- Flash « Trouvé ! » (disparaît tout seul) ---- */
.flash { position:fixed; left:50%; top:14px; transform:translate(-50%,-20px); opacity:0; z-index:60; min-width:260px; max-width:92vw;
         box-shadow:0 10px 30px rgba(0,0,0,.18); transition:opacity .25s, transform .25s; pointer-events:none; margin:0; }
.flash.show { opacity:1; transform:translate(-50%,0); }

/* ---- Bouton thème ---- */
.themebtn { background:none; border:none; font-size:18px; cursor:pointer; padding:4px 6px; border-radius:8px; line-height:1; }

/* ---- Emplacements publicitaires sur grand écran ---- */
.rail { display:none; }
@media (min-width:1100px) {
  .rail { display:flex; position:fixed; top:90px; width:160px; height:600px; }
  .rail.left { left:calc(50% - 320px - 200px); } .rail.right { right:calc(50% - 320px - 200px); }
  .rail .ad-slot { width:100%; height:100%; margin:0; }
}

/* ---- Mode sombre ---- */
[data-theme="dark"] {
  --black:#F2F2F4; --cream:#121214; --grey:#A0A0A8; --line:#2E2E34; --card:#1E1E22;
  --shadow:0 8px 30px rgba(0,0,0,.35); color-scheme:dark;
}
[data-theme="dark"] body { background:var(--cream); color:var(--black); }
[data-theme="dark"] .card, [data-theme="dark"] .mode, [data-theme="dark"] .clue:not(.hiddenclue), [data-theme="dark"] .scorebar,
[data-theme="dark"] .tabs, [data-theme="dark"] .seg, [data-theme="dark"] .newsletter form, [data-theme="dark"] .ac ul,
[data-theme="dark"] .lang button.active, [data-theme="dark"] .me, [data-theme="dark"] .round, [data-theme="dark"] .btn.ghost,
[data-theme="dark"] input[type=email], [data-theme="dark"] input[type=text] { background:var(--card); color:var(--black); }
[data-theme="dark"] .tabs { border-top-color:var(--line); }
[data-theme="dark"] .daily { background:#000; border:1px solid var(--line); }
[data-theme="dark"] .seg button.active, [data-theme="dark"] .round.done, [data-theme="dark"] .btn.dark { background:#F2F2F4; color:#121214; }
[data-theme="dark"] .timer { background:#F2F2F4; color:#121214; }
[data-theme="dark"] .ac li { border-bottom-color:var(--line); }
[data-theme="dark"] .ac li.sel, [data-theme="dark"] .ac li:hover, [data-theme="dark"] .board tr.mine { background:#3A2326; }
[data-theme="dark"] .board td, [data-theme="dark"] .board th, [data-theme="dark"] .duelrow { border-bottom-color:var(--line); }
[data-theme="dark"] .feedback.ok { background:#163222; } [data-theme="dark"] .feedback.ko { background:#3A1E21; }
[data-theme="dark"] .wrong span { background:#3A1E21; color:#ff9aa2; }
[data-theme="dark"] .code { background:#121214; }
[data-theme="dark"] .brand img { filter:invert(1) hue-rotate(180deg); }
[data-theme="dark"] .mode.series .ico { background:#3A1E21; } [data-theme="dark"] .mode.chrono .ico { background:#16263A; } [data-theme="dark"] .mode.duel .ico { background:#2A1E3A; }
[data-theme="dark"] #loginMsg { background:#163222 !important; }

/* ---- Niveaux et badges ---- */
.lvl { display:flex; gap:14px; align-items:center; }
.lvl-ic { font-size:40px; width:64px; height:64px; display:flex; align-items:center; justify-content:center; background:var(--cream); border-radius:18px; flex:none; }
.bar { height:8px; background:var(--line); border-radius:6px; margin:8px 0 6px; overflow:hidden; }
.bar i { display:block; height:100%; background:linear-gradient(90deg,var(--red),var(--gold)); border-radius:6px; }
.badges { display:grid; grid-template-columns:repeat(auto-fill,minmax(98px,1fr)); gap:8px; }
.badge { text-align:center; padding:10px 6px; border-radius:14px; background:var(--cream); opacity:.45; filter:grayscale(1); }
.badge.on { opacity:1; filter:none; }
.badge span { font-size:26px; display:block; }
.badge b { display:block; font-size:12px; margin-top:4px; }
.badge small { display:block; font-size:10px; color:var(--grey); line-height:1.3; margin-top:2px; }
