/* Polices embarquées : le jeu fonctionne même sans Internet */
@font-face { font-family: 'Righteous'; src: url('/fonts/righteous.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'VT323'; src: url('/fonts/vt323.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'DM Sans'; src: url('/fonts/dmsans.woff2') format('woff2'); font-weight: 100 1000; font-display: swap; }

:root {
  --bg: #1c1630;
  --bg2: #241d3b;
  --panel: #2c2447;
  --panel2: #352c54;
  --ink: #f4ead5;
  --muted: #b3a8cb;
  --dim: #7d7298;
  --line: rgba(244, 234, 213, .12);
  --coral: #e0876a;
  --mustard: #d9ad4f;
  --teal: #5fae9f;
  --lilac: #a597cf;
  --rose: #c9809a;
  --sky: #7499c9;
  --paper: #f4ead5;
  --paper-ink: #2a2140;
  --gold: #e3b54f;
  --silver: #c4c7d4;
  --bronze: #c98a5c;
  --good: #5fae9f;
  --bad: #d9705a;
  --radius: 18px;
  --title: 'Righteous', 'Trebuchet MS', system-ui, sans-serif;
  --mono: 'VT323', ui-monospace, monospace;
  --body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
img { display: block; }

/* ── décor rétro : soleil couchant discret + grille en perspective + trames ── */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background: radial-gradient(120% 70% at 50% 108%, #3b2a52 0%, transparent 60%), linear-gradient(180deg, #1a1430 0%, #1f1834 60%, #261c3c 100%); }
.backdrop::before { /* grille */
  content: ''; position: absolute; left: -50%; right: -50%; bottom: -10%; height: 46%;
  background-image: linear-gradient(rgba(224, 135, 106, .22) 1px, transparent 1px), linear-gradient(90deg, rgba(224, 135, 106, .22) 1px, transparent 1px);
  background-size: 48px 48px; transform: perspective(320px) rotateX(62deg); transform-origin: bottom;
  mask-image: linear-gradient(to top, #000 0%, transparent 85%); -webkit-mask-image: linear-gradient(to top, #000 0%, transparent 85%);
  opacity: .55; }
.backdrop::after { /* lignes de balayage */
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.09) 0 1px, transparent 1px 3px); opacity: .5; }

/* ── typographie ── */
.logo { font-family: var(--title); letter-spacing: .02em; line-height: .95; margin: 0; text-align: center;
  color: var(--ink); text-shadow: 3px 3px 0 var(--coral), 6px 6px 0 rgba(0,0,0,.25); }
.logo small { display: block; font-size: .36em; letter-spacing: .32em; margin-top: .65em; color: var(--mustard); text-shadow: none; text-transform: uppercase; }
.eyebrow { font-family: var(--mono); font-size: 20px; letter-spacing: .12em; text-transform: uppercase; color: var(--mustard); }
h2, h3 { font-family: var(--title); font-weight: 400; margin: 0; letter-spacing: .02em; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* ── soleil rayé ── */
.sun { width: 150px; height: 75px; margin: 0 auto; border-radius: 150px 150px 0 0; position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--mustard) 0%, var(--coral) 65%, var(--rose) 100%); opacity: .9; }
.sun::after { content: ''; position: absolute; inset: 0;
  background: linear-gradient(transparent 0 46%, var(--bg) 46% 52%, transparent 52% 64%, var(--bg) 64% 72%, transparent 72% 82%, var(--bg) 82% 92%, transparent 92%); }

/* ── boutons & champs ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; padding: 15px 22px; border-radius: 14px;
  background: var(--coral); color: #2a1a1a; font-family: var(--title); font-size: 19px; letter-spacing: .03em;
  box-shadow: 0 4px 0 #9c5743; transition: transform .08s, box-shadow .08s, opacity .2s; width: 100%; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #9c5743; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.alt { background: var(--panel2); color: var(--ink); box-shadow: 0 4px 0 #1a1429; }
.btn.teal { background: var(--teal); color: #10261f; box-shadow: 0 4px 0 #3c7469; }
.btn.small { width: auto; padding: 9px 14px; font-size: 15px; border-radius: 10px; }
.input { width: 100%; padding: 15px 16px; border-radius: 14px; border: 2px solid var(--line); background: rgba(0,0,0,.25);
  color: var(--ink); font: 500 18px var(--body); outline: none; }
.input:focus { border-color: var(--mustard); }
.error { color: #f0a08a; min-height: 1.4em; font-size: 15px; text-align: center; }

/* ── mise en page appli mobile ── */
.app { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.screen { flex: 1; padding: 18px 18px 8px; }
.hidden { display: none !important; }

/* ── inscription ── */
.join { display: flex; flex-direction: column; gap: 18px; padding-top: 28px; }
.join .logo { font-size: 46px; }
.selfie { width: 168px; height: 168px; border-radius: 50%; margin: 6px auto 0; position: relative; display: grid; place-items: center;
  background: var(--panel); border: 3px dashed rgba(217, 173, 79, .55); overflow: hidden; }
.selfie img { width: 100%; height: 100%; object-fit: cover; }
.selfie .ph { text-align: center; color: var(--muted); font-size: 14px; padding: 10px; }
.selfie .ph svg { width: 44px; height: 44px; color: var(--mustard); margin: 0 auto 6px; display: block; }
.selfie.done { border: 3px solid var(--mustard); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.rules { background: rgba(0,0,0,.2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; font-size: 14.5px; color: var(--muted); }
.rules b { color: var(--ink); font-weight: 600; }

/* ── barre du joueur ── */
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 18px 4px; }
.topbar .me-ph { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; border: 2px solid var(--mustard); }
.topbar .who { flex: 1; min-width: 0; }
.topbar .who b { font-family: var(--title); font-weight: 400; font-size: 19px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who span { font-size: 13px; color: var(--muted); }
.scorebox { text-align: right; font-family: var(--mono); line-height: .9; }
.scorebox .n { font-size: 40px; color: var(--mustard); }
.scorebox .l { font-size: 15px; color: var(--muted); letter-spacing: .1em; }

.progress { height: 6px; border-radius: 6px; background: rgba(255,255,255,.08); overflow: hidden; margin: 10px 18px 0; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--coral), var(--mustard)); border-radius: 6px; transition: width .4s; }

.cats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 14px 18px 4px; }
.cat-chip { text-align: center; font-size: 10.5px; color: var(--muted); }
.cat-chip svg { width: 22px; height: 22px; display: block; margin: 0 auto 3px; }
.dots { display: flex; justify-content: center; gap: 3px; margin-top: 3px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.14); }
.dots i.ok { background: var(--good); }
.dots i.ko { background: var(--bad); }

/* ── cartes face cachée ── */
.hand-title { display: flex; align-items: baseline; justify-content: space-between; padding: 16px 18px 10px; }
.hand-title h2 { font-size: 22px; }
.hand { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 0 18px; perspective: 1000px; }
.card { aspect-ratio: 3 / 4; border-radius: var(--radius); position: relative; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.3,.7,.3,1);
  animation: deal .45s both; }
.card.flipping { transform: rotateY(90deg) scale(1.04); }
.card-back { position: absolute; inset: 0; border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding-bottom: 18px;
  background: var(--c); color: #231b33; box-shadow: 0 8px 0 rgba(0,0,0,.25), inset 0 0 0 3px rgba(255,255,255,.18); }
.card-back::before { content: ''; position: absolute; inset: 9px; border: 2px solid rgba(35, 27, 51, .35); border-radius: 12px; }
.card-back::after { content: ''; position: absolute; left: 9px; right: 9px; top: 34%; height: 17%;
  background: linear-gradient(rgba(35,27,51,.16) 0 18%, transparent 18% 40%, rgba(35,27,51,.16) 40% 58%, transparent 58% 80%, rgba(35,27,51,.16) 80%); }
.card-back .ico { width: 64px; height: 64px; border-radius: 50%; background: rgba(244, 234, 213, .88); display: grid; place-items: center; position: relative; z-index: 1; }
.card-back .ico svg { width: 36px; height: 36px; color: #2a2140; }
.card-back .lbl { font-family: var(--title); font-size: 21px; letter-spacing: .04em; position: relative; z-index: 1; }
.card-back .stamp { position: absolute; top: 16px; left: 0; right: 0; text-align: center; font-family: var(--mono); font-size: 16px; letter-spacing: .2em; opacity: .7; }
.card-back .tap { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; opacity: .65; z-index: 1; }
@keyframes deal { from { opacity: 0; transform: translateY(20px) rotate(-3deg); } }

/* ── carte question (recto) ── */
.overlay { position: fixed; inset: 0; z-index: 30; background: rgba(15, 11, 26, .78); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center; padding: 18px 14px; overflow-y: auto; }
.qcard { width: 100%; max-width: 480px; background: var(--paper); color: var(--paper-ink); border-radius: 22px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.5); animation: flipin .45s cubic-bezier(.3,.7,.3,1) both; margin: auto 0; }
@keyframes flipin { from { transform: perspective(900px) rotateY(-90deg) scale(.9); opacity: .4; } }
.qcard .band { background: var(--c); padding: 12px 18px; display: flex; align-items: center; gap: 10px; color: #231b33; }
.qcard .band svg { width: 24px; height: 24px; }
.qcard .band b { font-family: var(--title); font-weight: 400; font-size: 18px; flex: 1; letter-spacing: .03em; }
.qcard .band .num { font-family: var(--mono); font-size: 20px; }
.qcard .body { padding: 20px 18px 18px; }
.qcard .question { font-family: var(--title); font-size: 23px; line-height: 1.22; margin: 0 0 18px; color: var(--paper-ink); }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice { display: flex; align-items: center; gap: 12px; text-align: left; padding: 13px 14px; border-radius: 14px; background: #fff8e8;
  border: 2px solid #e2d5b8; color: var(--paper-ink); font-weight: 500; font-size: 16.5px; transition: background .2s, border-color .2s, transform .1s; }
.choice:active { transform: scale(.98); }
.choice .k { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: #2a2140; color: var(--paper); font-family: var(--mono); font-size: 22px; }
.choice.good { background: #d6efe7; border-color: var(--good); }
.choice.good .k { background: var(--good); }
.choice.bad { background: #f8dcd3; border-color: var(--bad); }
.choice.bad .k { background: var(--bad); }
.choice.fade { opacity: .5; }
.choices.locked .choice { pointer-events: none; }
.verdict { margin: 18px 0 0; padding: 12px 14px; border-radius: 14px; font-family: var(--title); font-size: 21px; display: flex; align-items: center; gap: 10px; animation: pop .35s both; }
.verdict.good { background: var(--good); color: #0f2620; }
.verdict.bad { background: var(--bad); color: #2b0f08; }
.verdict small { font-family: var(--body); font-size: 14px; font-weight: 500; opacity: .85; display: block; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.anecdote { margin-top: 12px; padding: 13px 14px; border-radius: 14px; background: #efe2c4; font-size: 15px; line-height: 1.5; animation: pop .35s .1s both; }
.anecdote .eyebrow { color: #9a6a2a; font-size: 17px; display: block; margin-bottom: 2px; }
.qcard .actions { margin-top: 16px; }

/* ── fin de partie individuelle ── */
.center-box { text-align: center; padding: 26px 20px; background: rgba(0,0,0,.2); border: 1px solid var(--line); border-radius: 22px; margin: 18px; }
.center-box .big { font-family: var(--mono); font-size: 86px; line-height: .9; color: var(--mustard); }
.center-box h2 { font-size: 26px; margin: 8px 0 6px; }

/* ── barre d'onglets ── */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: rgba(22, 17, 38, .92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.tabs button { flex: 1; max-width: 240px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border-radius: 12px;
  font-family: var(--title); font-size: 17px; color: var(--muted); letter-spacing: .03em; position: relative; }
.tabs button svg { width: 22px; height: 22px; }
.tabs button.on { background: var(--panel2); color: var(--ink); }
.tabs .live { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 0 rgba(224,135,106,.6); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(224,135,106,0); } 100% { box-shadow: 0 0 0 0 rgba(224,135,106,0); } }

/* ── podium ── */
.podium-wrap { padding: 8px 12px 0; }
.podium-head { text-align: center; margin: 10px 0 6px; }
.podium-head h2 { font-size: 28px; }
.podium { display: grid; grid-template-columns: 1fr 1.12fr 1fr; align-items: end; gap: 8px; margin-top: 34px; min-height: 260px; }
.step { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.step .name { font-family: var(--title); font-size: 15px; margin: 8px 0 2px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
.step .pts { font-family: var(--mono); font-size: 22px; color: var(--muted); line-height: 1; margin-bottom: 8px; }
.step .fl { font-size: 11px; font-weight: 700; color: var(--mustard); margin: -4px 0 8px; white-space: nowrap; }
.step .block { width: 100%; border-radius: 12px 12px 0 0; display: grid; place-items: start center; padding-top: 8px; font-family: var(--title); font-size: 34px; color: rgba(35,27,51,.75);
  box-shadow: inset 0 3px 0 rgba(255,255,255,.25); }
.step.r1 .block { height: 120px; background: linear-gradient(180deg, var(--gold), #b98c34); }
.step.r2 .block { height: 88px; background: linear-gradient(180deg, var(--silver), #9497a6); }
.step.r3 .block { height: 64px; background: linear-gradient(180deg, var(--bronze), #96603c); }
.step.empty .avatar { opacity: .25; }

.avatar { position: relative; width: var(--s, 72px); height: var(--s, 72px); flex: none; }
.avatar img.ph { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 3px solid var(--ring, var(--line)); background: var(--panel); }
.avatar .crown { position: absolute; width: 62%; left: 50%; top: -36%; transform: translateX(-50%) rotate(-10deg); filter: drop-shadow(0 3px 0 rgba(0,0,0,.35)); }
.avatar .crown svg { width: 100%; height: auto; display: block; }
.step.r1 .avatar { --s: 92px; --ring: var(--gold); }
.step.r2 .avatar { --s: 74px; --ring: var(--silver); }
.step.r3 .avatar { --s: 68px; --ring: var(--bronze); }
.step.r1 .avatar .crown { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateX(-50%) rotate(-6deg) translateY(-3px); } }

.board { margin: 0 6px; background: rgba(0,0,0,.22); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.board .r { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.board .r:first-child { border-top: 0; }
.board .r.me { background: rgba(217, 173, 79, .12); }
.board .rk { width: 34px; font-family: var(--mono); font-size: 28px; color: var(--muted); text-align: center; line-height: 1; }
.board .avatar { --s: 42px; }
.board .avatar .crown { width: 70%; top: -42%; }
.board .nm { flex: 1; min-width: 0; }
.board .nm b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board .bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,.08); margin-top: 5px; overflow: hidden; }
.board .bar i { display: block; height: 100%; background: var(--teal); }
.board .pt { font-family: var(--mono); font-size: 30px; color: var(--mustard); line-height: 1; text-align: right; min-width: 40px; }
.board .pt small { display: block; font-size: 14px; color: var(--dim); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; vertical-align: 2px; margin-left: 4px; }
.tag.tie { background: rgba(224,135,106,.2); color: var(--coral); }
.tag.flash { background: rgba(217,173,79,.2); color: var(--mustard); }
.tag.done { background: rgba(95,174,159,.18); color: var(--teal); }
.empty-msg { text-align: center; color: var(--muted); padding: 30px 10px; }

/* ── départage / questions flash ── */
.flash-banner { margin: 14px 18px 0; padding: 12px 14px; border-radius: 16px; display: flex; align-items: center; gap: 12px;
  background: repeating-linear-gradient(-45deg, rgba(217,173,79,.16) 0 12px, rgba(217,173,79,.06) 12px 24px); border: 2px solid rgba(217,173,79,.55); }
.flash-banner svg { width: 30px; height: 30px; color: var(--mustard); flex: none; }
.flash-banner b { font-family: var(--title); font-weight: 400; font-size: 18px; color: var(--mustard); display: block; letter-spacing: .03em; }
.flash-banner span { font-size: 14px; color: var(--muted); }
.flash-intro { text-align: center; padding: 26px 22px; margin: 18px; border-radius: 24px; border: 2px solid rgba(217,173,79,.6);
  background: radial-gradient(120% 90% at 50% 0%, rgba(217,173,79,.18), transparent 70%), rgba(0,0,0,.2); }
.flash-intro .bolt { width: 74px; height: 74px; margin: 0 auto; color: var(--mustard); animation: zap 1.6s ease-in-out infinite; }
@keyframes zap { 50% { transform: scale(1.08) rotate(-4deg); } }
.flash-intro h2 { font-size: 34px; color: var(--mustard); margin: 8px 0 4px; letter-spacing: .05em; }
.flash-intro .facts { display: flex; justify-content: center; gap: 10px; margin: 18px 0 22px; }
.flash-intro .facts div { background: rgba(0,0,0,.25); border-radius: 14px; padding: 10px 12px; min-width: 88px; }
.flash-intro .facts b { display: block; font-family: var(--mono); font-size: 38px; line-height: .9; color: var(--ink); }
.flash-intro .facts span { font-size: 12.5px; color: var(--muted); }
.timer { display: flex; align-items: center; gap: 14px; padding: 12px 18px; background: #2a2140; color: var(--paper); }
.timer .clock { font-family: var(--mono); font-size: 56px; line-height: .8; width: 64px; text-align: center; color: var(--mustard); }
.timer .clock.urgent { color: var(--coral); animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .45; } }
.timer .meta { flex: 1; }
.timer .meta b { font-family: var(--title); font-weight: 400; font-size: 17px; letter-spacing: .06em; display: flex; align-items: center; gap: 6px; color: var(--mustard); }
.timer .meta b svg { width: 18px; height: 18px; }
.timer .track { height: 8px; border-radius: 8px; background: rgba(255,255,255,.12); overflow: hidden; margin-top: 7px; }
.timer .track i { display: block; height: 100%; background: var(--mustard); border-radius: 8px; }
.timer .track i.urgent { background: var(--coral); }

/* ── confettis discrets ── */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 8px; height: 14px; opacity: .85; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 50; background: var(--panel2); color: var(--ink); padding: 10px 16px; border-radius: 12px; font-size: 15px; box-shadow: 0 8px 30px rgba(0,0,0,.4); animation: pop .25s both; }
