/* DILEM : style Pop (autocollants, bords épais, ombres dures, cartes inclinées).
   Toutes les couleurs et tailles importantes sont dans le bloc :root juste en dessous :
   change-les ici pour changer l'allure de tout le site. */

:root {
  --bg: #3B2BEE;          /* fond indigo */
  --surface: #2B1FC4;     /* indigo plus foncé : boutons discrets, fond des stats */
  --ink: #FFFFFF;         /* texte sur fond indigo */
  --muted: #D3CDFF;       /* texte secondaire */
  --line: #111111;        /* contours et ombres */
  --empty: rgba(255, 255, 255, .28);
  --a: #FFD43B;           /* carte A : jaune */
  --a-ink: #111111;
  --a-fill: rgba(17, 17, 17, .14);
  --b: #FF5CA8;           /* carte B : rose */
  --b-ink: #111111;
  --b-fill: rgba(17, 17, 17, .14);
  --puck: #FFFFFF;
  --puck-ink: #111111;
  --flame: #FFD43B;
  --paper: #FFFFFF;       /* fiches blanches (connexion) */
  --paper-ink: #111111;
  --danger: #FF3B5C;

  --display: 'Bricolage Grotesque', 'Arial Black', system-ui, sans-serif;
  --body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --track: -.03em;

  --r: 20px;
  --bw: 3px;              /* épaisseur des contours */
  --pbw: 2.5px;
  --gap: 14px;            /* écart entre les deux cartes */
  --tilt: 2.5deg;         /* inclinaison des cartes */
  --shadow: 5px 5px 0 #111111;
  --pshadow: 3px 3px 0 #111111;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: 15px; line-height: 1.4;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--flame); outline-offset: 3px; }

.app { width: 100%; max-width: 480px; margin-inline: auto; min-height: 100%; display: flex; flex-direction: column; gap: 14px; }

/* ---------- En-tête ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand {
  display: flex; align-items: center; gap: 8px; margin: 0;
  font-family: var(--display); font-weight: 800; font-size: 1.75rem; letter-spacing: -.03em; text-transform: uppercase; line-height: 1;
}
.brand svg { width: 44px; height: 44px; flex: none; overflow: visible; }
.top-actions { display: flex; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 13px; cursor: pointer;
  background: var(--surface); border: var(--pbw) solid var(--line); border-radius: 999px;
  font-weight: 700; font-size: .9rem; font-variant-numeric: tabular-nums;
}
.pill svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.streak { cursor: default; color: var(--muted); }
.streak.lit { color: var(--ink); }
.streak.lit svg { fill: var(--flame); stroke: var(--flame); }

/* ---------- Chargement ---------- */
.loading { display: grid; place-items: center; flex: 1; min-height: 50vh; color: var(--muted); font-weight: 700; }

/* ---------- Connexion ---------- */
.auth { display: grid; gap: 18px; }
.hero { display: grid; gap: 8px; text-align: center; padding-top: 6px; }
.hero h2 { margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(2rem, 9vw, 2.8rem); line-height: 1; letter-spacing: -.04em; text-wrap: balance; }
.hero p { margin: 0; color: var(--muted); text-wrap: balance; }
.sheet-paper, .paper {
  background: var(--paper); color: var(--paper-ink); border: var(--bw) solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
}
.paper { padding: 18px; display: grid; gap: 14px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; border: var(--pbw) solid var(--line); border-radius: 999px; overflow: hidden; }
.tabs button { border: 0; background: transparent; padding: 9px 8px; font-weight: 700; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--line); color: #FFFFFF; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; font-size: .85rem; }
.field input[type="text"], .field input[type="password"] {
  width: 100%; padding: 12px 14px; font-size: 1rem; background: #FFFFFF; color: #111111;
  border: var(--pbw) solid var(--line); border-radius: 12px;
}
.field small { color: #4A4670; }
.check { display: flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: #3B2BEE; }
.btn {
  cursor: pointer; padding: 13px 22px; font-weight: 800; font-size: 1rem; text-align: center;
  background: var(--a); color: #111111; border: var(--pbw) solid var(--line); border-radius: 999px; box-shadow: var(--pshadow);
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.alt { background: var(--puck); }
.btn.danger { background: var(--danger); color: #111111; }
.btn.wide { width: 100%; }
.error { margin: 0; padding: 10px 12px; font-weight: 700; font-size: .9rem; color: #111111; background: #FFD6DF; border: var(--pbw) solid var(--line); border-radius: 12px; }
.fine { margin: 0; color: var(--muted); font-size: .8rem; text-align: center; text-wrap: balance; }
.fine a { color: inherit; }

/* ---------- Défi du jour ---------- */
.goal { display: grid; gap: 8px; }
.goal-label { font-size: .8rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.segs { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.segs i { height: 8px; border-radius: 999px; background: var(--empty); transition: background .25s; }
.segs i.on { background: var(--flame); }
.cat { margin: 0; font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); text-align: center; min-height: 1.2em; }

/* ---------- Les deux cartes ---------- */
.game { display: flex; flex-direction: column; gap: 14px; }
.arena {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap);
  height: clamp(380px, 56vh, 600px); height: clamp(380px, 56dvh, 600px);
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.side {
  position: relative; overflow: hidden; min-width: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 38px 10px 84px;
  border: var(--bw) solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  transition: transform .2s, opacity .2s, rotate .2s;
}
.side.a { background: var(--a); color: var(--a-ink); rotate: calc(var(--tilt) * -1); }
.side.b { background: var(--b); color: var(--b-ink); rotate: var(--tilt); }
.arena[data-lean="A"] .side.a, .arena[data-lean="B"] .side.b { rotate: 0deg; transform: scale(1.025); }
.arena[data-lean="A"] .side.b, .arena[data-lean="B"] .side.a { opacity: .55; transform: scale(.97); }
.fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; transition: height .8s cubic-bezier(.2, .8, .2, 1); }
.a .fill { background: var(--a-fill); }
.b .fill { background: var(--b-fill); }
.opt {
  position: relative; z-index: 1; width: 94%; margin-inline: auto; text-align: center;
  font-family: var(--display); font-weight: 800; font-size: 2rem; line-height: .95; letter-spacing: -.045em;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, .55);
  overflow-wrap: normal; hyphens: manual; text-wrap: balance;
}
.res {
  position: relative; z-index: 1; font-family: var(--display); font-weight: 800; font-size: 1.7rem; text-transform: uppercase;
  font-variant-numeric: tabular-nums; opacity: 0; transform: translateY(8px); transition: opacity .35s .15s, transform .35s .15s;
}
.arena.result .res { opacity: 1; transform: none; }
.tag {
  position: absolute; z-index: 1; top: 12px; left: 50%; translate: -50% 0; opacity: 0; white-space: nowrap;
  font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; background: #111111; color: #FFFFFF;
}
.side.picked .tag { opacity: 1; }
.arena.result .side:not(.picked) { opacity: .78; }
.arena.enter .side { animation: enter .28s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Jeton VS */
.puck {
  position: absolute; left: 50%; top: 85%; width: 66px; height: 66px; margin: -33px 0 0 -33px; z-index: 3; pointer-events: none;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--puck); color: var(--puck-ink); border: var(--pbw) solid var(--line); box-shadow: var(--pshadow);
  font-family: var(--display); font-weight: 800; font-size: 1.3rem; letter-spacing: -.03em;
  translate: var(--dx, 0px) 0; transition: translate .25s ease, opacity .2s, scale .2s;
}
.puck.drag { transition: none; scale: 1.08; }
.puck.nudge { animation: nudge 2.6s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-12px); } 60% { transform: translateX(12px); } }
.arena.result .puck, .arena.pending .puck { opacity: 0; scale: .6; }

.status { margin: 0; min-height: 2.8em; text-align: center; font-weight: 700; text-wrap: balance; }
.status.hint { color: var(--muted); font-weight: 500; font-size: .88rem; }

/* ---------- Fin des duels ---------- */
.done { display: grid; gap: 14px; justify-items: center; padding: 26px 20px; text-align: center; }
.done h2 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 1.6rem; text-transform: uppercase; letter-spacing: -.03em; line-height: 1.05; text-wrap: balance; }
.done p { margin: 0; color: #4A4670; text-wrap: balance; }

/* ---------- Notification ---------- */
.toast {
  position: fixed; z-index: 30; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 12px); translate: -50% 0;
  width: min(92vw, 420px); padding: 12px 16px; text-align: center; pointer-events: none;
  background: #FFFFFF; color: #111111; border: var(--pbw) solid var(--line); border-radius: 14px; box-shadow: var(--pshadow);
  opacity: 0; transform: translateY(-14px); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: none; }
.toast b { display: block; font-family: var(--display); font-size: 1.05rem; letter-spacing: -.02em; text-transform: uppercase; }
.toast span { font-size: .85rem; }

/* ---------- Profil ---------- */
.sheet { position: fixed; z-index: 20; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; }
.sheet-in {
  width: 100%; max-width: 480px; max-height: 90%; overflow-y: auto; background: var(--bg); color: var(--ink);
  border: var(--bw) solid var(--line); border-bottom: 0; border-radius: var(--r) var(--r) 0 0; display: grid; gap: 16px;
  padding: 20px max(16px, env(safe-area-inset-left, 0px)) calc(20px + env(safe-area-inset-bottom, 0px));
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h2 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 1.5rem; text-transform: uppercase; letter-spacing: -.03em; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { padding: 12px 14px; background: var(--surface); border: var(--pbw) solid var(--line); border-radius: 14px; }
.stat b { display: block; font-family: var(--display); font-size: 1.8rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--muted); }
.sheet h3 { margin: 0; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.badges { display: grid; gap: 10px; }
.bd { display: grid; grid-template-columns: 46px 1fr; gap: 12px; align-items: center; padding: 10px 12px; background: var(--surface); border: var(--pbw) solid var(--line); border-radius: 14px; }
.bd.locked { opacity: .5; }
.bd-g { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: var(--flame); color: #111111; border: var(--pbw) solid var(--line); }
.bd.locked .bd-g { background: var(--empty); color: var(--muted); }
.bd-g svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.bd b { display: block; }
.bd span { font-size: .82rem; color: var(--muted); }
.sheet-actions { display: grid; gap: 10px; }
.confirm-box { display: grid; gap: 10px; padding: 14px; background: var(--paper); color: var(--paper-ink); border: var(--bw) solid var(--line); border-radius: 14px; }
.confirm-box p { margin: 0; font-weight: 700; }
.confirm-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (max-width: 380px) {
  .brand { font-size: 1.5rem; }
  .brand svg { width: 38px; height: 38px; }
  .pill { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
#sheetTitle, #fsTitle { text-transform: none; }

/* =====================================================================
   V1.5 : avatars, amis, compatibilité, devine, défis
   ===================================================================== */
.avatar {
  --s: 44px; display: inline-block; flex: none; width: var(--s); height: var(--s); overflow: hidden;
  border: var(--pbw) solid var(--line); border-radius: 30%; background: #FFFFFF; box-shadow: 2px 2px 0 #111111; vertical-align: middle;
}
.avatar svg { display: block; width: 100%; height: 100%; }
.avatar.sm  { --s: 34px; box-shadow: none; }
.avatar.md  { --s: 46px; }
.avatar.xl  { --s: 92px; border-width: var(--bw); box-shadow: var(--pshadow); }
.avatar.xxl { --s: 150px; border-width: var(--bw); box-shadow: var(--shadow); }
.avatar-btn { padding: 0; background: none; border: 0; cursor: pointer; line-height: 0; border-radius: 30%; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); border: 2px solid var(--line); margin-left: -3px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
a.btn { display: block; text-decoration: none; }
.btn.wa { background: #25D366; }
.btn:disabled { opacity: .5; }

.invite {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--paper-ink);
  background: var(--a); border: var(--bw) solid var(--line); border-radius: var(--r); box-shadow: var(--pshadow);
}
.invite p { margin: 0; font-weight: 800; text-wrap: balance; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }

/* Listes d'amis */
.list { display: grid; gap: 10px; }
.frow {
  display: grid; grid-template-columns: 24px auto 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; text-align: left; cursor: pointer;
  background: var(--surface); color: var(--ink); border: var(--pbw) solid var(--line); border-radius: 14px;
}
.frow.static { grid-template-columns: auto 1fr auto; cursor: default; }
.frow:active:not(.static) { transform: translate(1px, 1px); }
.rank { font-family: var(--display); font-weight: 800; color: var(--muted); text-align: center; }
.fmain { display: grid; min-width: 0; }
.fmain b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmain small { color: var(--muted); font-size: .78rem; }
.fright { display: flex; align-items: center; gap: 8px; }
.pct { font-family: var(--display); font-weight: 800; font-size: 1.35rem; font-variant-numeric: tabular-nums; color: var(--flame); }
.duo { display: inline-flex; align-items: center; gap: 2px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.duo svg, .flame-i svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.duo.lit { color: var(--flame); }
.duo.lit svg, .duo-box.lit .flame-i svg { fill: var(--flame); stroke: var(--flame); }
.mini {
  cursor: pointer; padding: 6px 11px; font-weight: 800; font-size: .82rem; color: #111111; background: #FFFFFF;
  border: var(--pbw) solid var(--line); border-radius: 999px;
}
.mini.ok { background: var(--a); }
.addf { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.addf input {
  min-width: 0; padding: 11px 14px; font-size: 1rem; background: #FFFFFF; color: #111111;
  border: var(--pbw) solid var(--line); border-radius: 999px;
}
.addf .btn { padding: 11px 18px; }
.ready { display: grid; gap: 10px; padding: 12px; background: var(--paper); color: var(--paper-ink); border: var(--bw) solid var(--line); border-radius: 14px; }
.ready p { margin: 0; }

/* Fiche d'un duo (ami ou défi) */
.body { display: grid; gap: 14px; }
.duo-hero { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.duo-mid { display: grid; text-align: center; justify-items: center; }
.duo-mid b { font-family: var(--display); font-weight: 800; font-size: 2.6rem; line-height: 1; letter-spacing: -.03em; color: var(--flame); text-shadow: 3px 3px 0 #111111; font-variant-numeric: tabular-nums; }
.duo-mid span { font-weight: 800; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; text-wrap: balance; }
.duo-box b { display: flex; align-items: center; gap: 4px; }
.duo-box .flame-i { color: var(--muted); display: inline-flex; }
.duo-box.lit .flame-i { color: var(--flame); }
.insights { padding: 12px 14px; background: var(--surface); border: var(--pbw) solid var(--line); border-radius: 14px; }
.insights p { margin: 4px 0; font-size: .9rem; }
.dls { display: grid; gap: 8px; }
.dl { padding: 10px 12px; background: var(--surface); border: var(--pbw) solid var(--line); border-radius: 12px; }
.dl-q { font-weight: 800; }
.dl-q i { color: var(--muted); font-weight: 500; }
.dl-a { font-size: .85rem; color: var(--muted); }
.dl-a b { color: var(--ink); }

/* Devine */
.guess-q { margin: 0; text-align: center; font-family: var(--display); font-weight: 800; font-size: 1.4rem; text-wrap: balance; }
.guess-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gbtn {
  min-height: 130px; padding: 12px 8px; cursor: pointer; font-family: var(--display); font-weight: 800; font-size: 1.5rem; line-height: 1; letter-spacing: -.04em; overflow-wrap: anywhere;
  color: #111111; border: var(--bw) solid var(--line); border-radius: var(--r); box-shadow: var(--pshadow);
}
.gbtn.a { background: var(--a); rotate: -2deg; }
.gbtn.b { background: var(--b); rotate: 2deg; }
.gbtn.right { outline: 4px solid #2EE6A6; outline-offset: 2px; }
.gbtn.wrong { opacity: .45; }
.guess-res { margin: 0; min-height: 1.4em; text-align: center; font-weight: 800; text-wrap: balance; }
.guess-res.ok { color: #7DF9C0; }
.guess-res.ko { color: #FFB3C7; }

/* Avatar */
.av-preview { display: grid; place-items: center; }
.avrows { display: grid; gap: 8px; }
.avrow { display: grid; grid-template-columns: 1fr auto 56px auto; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border: var(--pbw) solid var(--line); border-radius: 12px; }
.avrow span { font-weight: 700; }
.avrow b { text-align: center; font-variant-numeric: tabular-nums; }
.avrow .mini { width: 38px; height: 34px; padding: 0; font-size: 1rem; }

@media (max-width: 380px) {
  .duo-mid b { font-size: 2.1rem; }
  .avatar.xl { --s: 74px; }
}

/* En-tête compact sur téléphone : logo + série + Amis + avatar doivent tenir sur une ligne */
@media (max-width: 430px) {
  .top { gap: 8px; }
  .top-actions { gap: 6px; align-items: center; }
  .brand { font-size: 1.5rem; gap: 6px; }
  .brand svg { width: 36px; height: 36px; }
  .pill { height: 36px; padding: 0 10px; gap: 5px; font-size: .85rem; }
  #openProfile .avatar { --s: 40px; }
}
@media (max-width: 350px) {
  .brand { font-size: 1.3rem; }
  .brand svg { width: 30px; height: 30px; }
  #openFriends span { display: none; }
  #openProfile .avatar { --s: 36px; }
}
