:root {
  --bg: #0b1020;
  --bg2: #111833;
  --card: rgba(255, 255, 255, 0.06);
  --card-b: rgba(255, 255, 255, 0.12);
  --txt: #e8ecf8;
  --muted: #9aa5c4;
  --acc: #7c5cff;
  --acc2: #22d3ee;
  --ok: #22c55e;
  --bad: #ef4444;
  --r: 18px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--txt);
  background: radial-gradient(1200px 600px at 10% -10%, #2a1b6b 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 10%, #0e4a5c 0%, transparent 55%), var(--bg);
  min-height: 100vh;
}
a { color: var(--acc2); }
h1 { font-size: clamp(28px, 5vw, 52px); line-height: 1.05; margin: 0 0 12px; letter-spacing: -0.02em; }
h2 { margin: 28px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.lead { font-size: 18px; color: var(--muted); max-width: 760px; line-height: 1.55; }
.big-ico { font-size: 48px; margin-bottom: 8px; }

/* ---------- barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px 20px; background: rgba(11, 16, 32, 0.75); backdrop-filter: blur(12px); border-bottom: 1px solid var(--card-b);
}
.brand { font-weight: 800; font-size: 20px; color: var(--txt); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 14px; height: 14px; border-radius: 50%; background: conic-gradient(#ef4444, #eab308, #22c55e, #3b82f6, #a855f7, #ef4444); animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 10px; font-weight: 500; }
.nav a.active, .nav a:hover { color: var(--txt); background: var(--card); }
.nav a { display: inline-flex; align-items: center; gap: 6px; }
.nav a i { font-style: normal; font-size: 15px; }
.model-select { display: none; font: inherit; font-size: 14px; font-weight: 600; color: var(--txt); background: var(--card);
  border: 1px solid var(--card-b); border-radius: 10px; padding: 7px 10px; }
.model-select option { background: var(--bg2); }
.tools { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--card-b); border-radius: 12px; padding: 3px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 7px 11px; border-radius: 9px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.seg button.on { background: linear-gradient(135deg, var(--acc), #5b8cff); color: white; }
.seg button:disabled { opacity: .45; cursor: not-allowed; }

main { max-width: 1240px; margin: 0 auto; padding: 28px 20px 60px; }
.view { display: none; animation: fade .35s ease; }
.view.on { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

/* ---------- accueil ---------- */
.hero { padding: 30px 0 10px; }
.hero-emojis { display: flex; gap: 10px; font-size: 34px; margin-bottom: 14px; }
.hero-emojis span { animation: bob 2.4s ease-in-out infinite; display: inline-block; }
.hero-emojis span:nth-child(2) { animation-delay: .2s } .hero-emojis span:nth-child(3) { animation-delay: .4s }
.hero-emojis span:nth-child(4) { animation-delay: .6s } .hero-emojis span:nth-child(5) { animation-delay: .8s }
.hero-emojis span:nth-child(6) { animation-delay: 1s } .hero-emojis span:nth-child(7) { animation-delay: 1.2s }
.hero-emojis.big { font-size: 44px; justify-content: center; margin: 24px 0; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 26px 0; }
.card { display: block; padding: 22px; border-radius: var(--r); background: var(--card); border: 1px solid var(--card-b); color: var(--txt); text-decoration: none; transition: transform .2s, border-color .2s; }
.card:hover { transform: translateY(-4px); border-color: rgba(124, 92, 255, .6); }
.card.accent { background: linear-gradient(135deg, rgba(124, 92, 255, .25), rgba(34, 211, 238, .12)); }
.card h3 { margin: 8px 0 6px; }
.card p { color: var(--muted); margin: 0; line-height: 1.5; }
.card-ico { font-size: 30px; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; }
.stats div { flex: 1; min-width: 160px; padding: 16px; border-radius: var(--r); background: var(--card); border: 1px solid var(--card-b); }
.stats b { display: block; font-size: 30px; }
.stats span { color: var(--muted); font-size: 14px; }
.privacy-note { color: var(--muted); margin-top: 18px; }

/* ---------- scène vidéo / photo ---------- */
.live-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; }
@media (max-width: 900px) { .live-grid { grid-template-columns: 1fr; } }
.stage { position: relative; border-radius: var(--r); overflow: hidden; background: #050814; border: 1px solid var(--card-b); aspect-ratio: 16/9; }
.stage canvas { width: 100%; height: 100%; display: block; object-fit: contain; }
.photo-stage { aspect-ratio: auto; align-self: start; }
.photo-stage canvas { height: auto; }
.stage-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 20px; color: var(--muted); }
.stage-bar { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.pill { font-size: 13px; color: var(--muted); background: var(--card); border: 1px solid var(--card-b); padding: 6px 10px; border-radius: 999px; }
.panel { padding: 18px; border-radius: var(--r); background: var(--card); border: 1px solid var(--card-b); align-self: start; }
.panel h3 { margin: 0 0 4px; }
.warn { color: #fbbf24; }

/* ---------- barres de probabilité ---------- */
.bars { margin: 12px 0; }
.bars h4 { margin: 10px 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; }
.bar { display: grid; grid-template-columns: 26px 92px 1fr 44px; align-items: center; gap: 6px; margin: 5px 0; font-size: 13px; }
.bar .track { height: 10px; background: rgba(255, 255, 255, .07); border-radius: 99px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 99px; width: 0; transition: width .35s ease; }
.bar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.bar.top { font-weight: 700; }
.bar.top .v { color: var(--txt); }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0 4px; }
.chip { border: 1px solid var(--card-b); border-left: 4px solid var(--c); border-radius: 10px; padding: 6px 8px; font-size: 13px; display: flex; flex-direction: column; gap: 1px; }
.chip small { color: var(--muted); }
.chip span { color: var(--muted); }
.verdict { font-size: 26px; font-weight: 800; display: flex; align-items: center; gap: 10px; margin: 8px 0 2px; }

/* ---------- boutons ---------- */
.btn { text-decoration: none; display: inline-block; font: inherit; font-weight: 600; font-size: 14px; border-radius: 12px; padding: 10px 16px; border: 1px solid var(--card-b); background: var(--card); color: var(--txt); cursor: pointer; transition: transform .1s, background .2s; }
.btn:hover { background: rgba(255, 255, 255, .12); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--acc), #5b8cff); border: 0; color: white; }
.btn.ghost { background: transparent; }
.btn.xl { font-size: 18px; padding: 14px 28px; }
.row { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.row.center { justify-content: center; }
.row.end { justify-content: flex-end; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
input:not([type]), input[type=text] { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--card-b); background: rgba(0, 0, 0, .25); color: var(--txt); width: 100%; }
.link { color: var(--acc2); cursor: pointer; text-decoration: underline; }

/* ---------- photo ---------- */
.drop { border: 2px dashed var(--card-b); border-radius: var(--r); padding: 40px; text-align: center; color: var(--muted); transition: border-color .2s, background .2s; }
.drop.compact { padding: 14px; display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }
.drop.compact .big-ico { display: none; }
.drop.compact p { margin: 0; }
.drop.over { border-color: var(--acc); background: rgba(124, 92, 255, .08); }
.photo-res { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; margin-top: 18px; }
@media (max-width: 900px) { .photo-res { grid-template-columns: 1fr; } }
.faces { display: flex; flex-direction: column; gap: 12px; }
.face-card { padding: 14px; border-radius: var(--r); background: var(--card); border: 1px solid var(--card-b); }
.face-card .head { display: flex; gap: 12px; align-items: center; }
.face-card img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; }

/* ---------- retour utilisateur ---------- */
.fb { margin-top: 10px; font-size: 14px; }
.fb .opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.fb .opts button { padding: 6px 9px; font-size: 13px; }

/* ---------- défi ---------- */
.ch-intro { text-align: center; padding: 30px 0; }
.ch-intro .lead { margin: 0 auto; }
.ch-run { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; }
@media (max-width: 900px) {
  .ch-run { grid-template-columns: 1fr; }
  .ch-side { order: -1; padding: 10px 12px; gap: 6px; }
  .ch-target { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; text-align: left; }
  .ch-target .ring { grid-column: 1; grid-row: 1 / 4; width: 84px; height: 84px; margin: 0; }
  .ch-target .ring-in { width: 70px; height: 70px; font-size: 38px; }
  .ch-target > span, .ch-target h2, .ch-target p { grid-column: 2; margin: 0; }
  .ch-target h2 { font-size: 20px; }
  .ch-target p { font-size: 13px; line-height: 1.35; }
  #chSkip { padding: 7px; }
  #chStage canvas { max-height: 50vh; }
}
.ch-side { padding: 20px; border-radius: var(--r); background: var(--card); border: 1px solid var(--card-b); text-align: center; display: flex; flex-direction: column; gap: 12px; }
.ch-step { display: flex; justify-content: center; gap: 6px; }
.ch-step i { width: 26px; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .12); }
.ch-step i.done { background: var(--ok); } .ch-step i.miss { background: var(--bad); } .ch-step i.cur { background: var(--acc); }
.ring { --p: 0; --c: var(--acc); width: 170px; height: 170px; margin: 10px auto; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), rgba(255, 255, 255, .08) 0); transition: --p .2s; }
.ring-in { width: 140px; height: 140px; border-radius: 50%; background: var(--bg2); display: grid; place-items: center; font-size: 70px; }
.ch-target h2 { margin: 4px 0; font-size: 30px; }
.timer { height: 6px; background: rgba(255, 255, 255, .08); border-radius: 99px; overflow: hidden; }
.timer div { height: 100%; background: linear-gradient(90deg, var(--acc2), var(--acc)); width: 100%; }
.flash { position: absolute; inset: 0; background: white; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .5s ease; }
@keyframes flash { 0% { opacity: .8 } 100% { opacity: 0 } }
.ch-end { text-align: center; }
.score { font-size: 22px; } .score b { font-size: 48px; color: var(--acc2); }
.recap { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 18px 0; text-align: left; }
.rc { border-radius: 14px; overflow: hidden; background: var(--card); border: 1px solid var(--card-b); }
.rc img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.rc .meta { padding: 8px 10px; font-size: 13px; }
.rc .meta b { display: block; font-size: 15px; margin-bottom: 4px; }
.rc .m { display: flex; justify-content: space-between; }
.ok { color: var(--ok); } .ko { color: var(--bad); }
.burst { position: fixed; pointer-events: none; font-size: 34px; animation: burst 1.1s ease-out forwards; z-index: 50; }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) scale(.4); opacity: 0; } }

.actionbar { position: sticky; bottom: 12px; z-index: 5; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap;
  margin: 18px auto 0; padding: 12px 16px; max-width: 640px; border-radius: 18px; border: 1px solid var(--card-b);
  background: rgba(17, 24, 51, .88); backdrop-filter: blur(12px); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
.actionbar > span { color: var(--muted); font-size: 14px; }

/* ---------- dialogues ---------- */
.dlg { max-width: 640px; width: calc(100% - 32px); border: 1px solid var(--card-b); border-radius: 22px; background: var(--bg2); color: var(--txt); padding: 24px; }
.dlg.narrow { max-width: 520px; }
.dlg::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px); }
.dlg h2 { margin-top: 0; }
.chk { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; cursor: pointer; line-height: 1.4; }
.chk input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--acc); }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 26px; letter-spacing: .08em; padding: 14px; border-radius: 14px; background: rgba(0, 0, 0, .3); margin: 14px 0; }
.explain-imgs { display: flex; gap: 10px; justify-content: center; }
.explain-imgs img { width: 46%; border-radius: 14px; }

/* ---------- aperçu caméra ---------- */
.cam-wrap { position: relative; border-radius: 16px; overflow: hidden; background: #000; }
.cam-wrap video { width: 100%; display: block; max-height: 60vh; object-fit: cover; }
.cam-wrap video.mirror { transform: scaleX(-1); }
.cam-count { position: absolute; inset: 0; display: grid; place-items: center; font-size: 96px; font-weight: 800; color: #fff;
  text-shadow: 0 4px 24px rgba(0, 0, 0, .6); animation: pop .9s ease; }
@keyframes pop { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- guide ---------- */
.tips { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 18px 0; }
.tip { padding: 12px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--card-b); font-size: 14px; line-height: 1.45; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.gcard { padding: 18px; border-radius: var(--r); background: var(--card); border: 1px solid var(--card-b); border-top: 4px solid var(--c); }
.gcard header { display: flex; align-items: center; gap: 12px; }
.gcard h3 { margin: 0; font-size: 22px; }
.gemo { font-size: 26px; }
.gcard header { gap: 16px; }
.gface { flex: 0 0 132px; height: 150px; border-radius: 16px; background: color-mix(in srgb, var(--c) 14%, transparent); display: grid; place-items: center; }
.gface svg { width: 118px; height: 138px; }
.gface .sk { fill: #f1c9a5; stroke: #8a5a3c; stroke-width: 1.5; }
.gface .hr { fill: #3b2a20; }
.gface .br { fill: none; stroke: #3b2a20; stroke-width: 4; stroke-linecap: round; }
.gface .ln { fill: none; stroke: #5b3b2a; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.gface .th { fill: none; stroke: #a0694a; stroke-width: 1.6; stroke-linecap: round; }
.gface .ew { fill: #fff; stroke: #5b3b2a; stroke-width: 1.8; }
.gface .ir { fill: #3b2a20; }
.gface .mo { fill: #7a2e2a; stroke: #5b3b2a; stroke-width: 1.8; stroke-linejoin: round; }
.gface .tw { fill: #fff; stroke: none; }
.gface .tw:not([d$="Z"]) { fill: none; stroke: #fff; stroke-width: 2; }
.gface .ck { fill: #f08f8f; opacity: .45; }
.gcard ul { padding-left: 18px; margin: 12px 0; line-height: 1.5; font-size: 14px; }
.gcard li { margin: 4px 0; }
.gtip { font-size: 14px; margin: 8px 0 4px; }
.gwarn { font-size: 13px; color: var(--muted); margin: 0; }

/* ---------- à propos ---------- */
.prose { max-width: 820px; line-height: 1.6; }
.results { border-collapse: collapse; width: 100%; }
.results th, .results td { padding: 10px; border-bottom: 1px solid var(--card-b); text-align: right; }
.results td:first-child, .results th:first-child { text-align: left; }
.results tr.hl td { font-weight: 700; color: var(--acc2); }
.withdraw { margin: 18px 0; padding: 18px; border-radius: var(--r); background: var(--card); border: 1px solid var(--card-b); }
.withdraw h3 { margin-top: 0; }
@media (max-width: 760px) {
  .topbar { position: static; padding: 10px 14px; gap: 8px; flex-wrap: nowrap; backdrop-filter: none; background: transparent; }
  .brand { font-size: 18px; }
  .tools { margin-left: auto; gap: 6px; flex-wrap: nowrap; }
  #modelSeg { display: none; }
  .model-select { display: block; max-width: 150px; }
  .seg.small button { padding: 6px 8px; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: rgba(11, 16, 32, .94); backdrop-filter: blur(14px);
    border-top: 1px solid var(--card-b); }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 11px; border-radius: 10px; text-align: center; }
  .nav a i { font-size: 22px; }
  .nav .nav-about { display: none; }
  main { padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); }
  .actionbar { bottom: calc(78px + env(safe-area-inset-bottom)); }
  h1 { font-size: 30px; }
  .lead { font-size: 16px; }
  .hero { padding: 8px 0 0; }
  .hero-emojis { font-size: 28px; gap: 6px; }
  .cards { margin: 18px 0; gap: 10px; }
  .card { padding: 16px; }
  .stage { aspect-ratio: auto !important; min-height: 0; }
  .stage canvas { height: auto; max-height: 56vh; margin: 0 auto; }
  .stage-empty { position: static; padding: 28px 16px; }
  .stage-bar { position: sticky; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 4; padding: 8px; margin-top: 8px;
    border-radius: 14px; background: rgba(17, 24, 51, .9); backdrop-filter: blur(10px); border: 1px solid var(--card-b); }
  .stage-bar .pill { flex-basis: 100%; text-align: center; }
  .stage-bar .spacer { display: none; }
  .stage-bar .btn { flex: 1; }
  .row2 { grid-template-columns: 1fr; }
  .dlg { padding: 18px; max-height: 92vh; overflow: auto; }
  .bar { grid-template-columns: 22px 78px 1fr 34px; }
  .chips { grid-template-columns: 1fr 1fr 1fr; font-size: 12px; }
  .drop { padding: 18px; }
  .drop.compact { padding: 10px; }
  .drag-txt { display: none; }
  .link.pick { display: inline-block; text-decoration: none; padding: 10px 16px; border-radius: 12px; background: linear-gradient(135deg, var(--acc), #5b8cff); color: #fff; font-weight: 600; }
  .link.pick::before { content: "📁 "; }
  .link.pick span { display: inline-block; }
  .link.pick span::first-letter { text-transform: uppercase; }
  .photo-stage { min-height: 0; }
  .stats div { min-width: 0; padding: 12px; }
  .stats b { font-size: 24px; }
  .recap { grid-template-columns: repeat(2, 1fr); }
  .tips { grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
  .tip { padding: 9px 10px; font-size: 12.5px; }
  .gcard { padding: 14px; }
}
