@font-face { font-family: 'Fredoka'; src: url('/fonts/fredoka-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('/fonts/fredoka-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('/fonts/fredoka-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bleu: #1d4e9e;
  --bleu-fonce: #133a7a;
  --bleu-clair: #e6eefb;
  --jaune: #ffc83d;
  --jaune-clair: #fff3cf;
  --corail: #ff6b57;
  --corail-clair: #ffe4df;
  --vert: #17a079;
  --vert-clair: #dcf5ec;
  --violet: #7b5cd6;
  --creme: #fff8ec;
  --encre: #1d2440;
  --doux: #5a6280;
  --bord: #d9e2f3;
  --rayon: 18px;
  --ombre: 0 2px 0 rgba(29, 78, 158, 0.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--creme); color: var(--encre); }
body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, .titre { font-family: 'Fredoka', system-ui, sans-serif; line-height: 1.2; }
h1 { font-size: 26px; margin: 0 0 8px; }
h2 { font-size: 21px; margin: 0 0 10px; color: var(--bleu); }
h3 { font-size: 17px; margin: 0 0 6px; }
p { margin: 0 0 10px; }
a { color: var(--bleu); }
img, video { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.chargement { padding: 60px 20px; text-align: center; font-family: 'Fredoka'; font-size: 20px; color: var(--bleu); }

/* ─── en-tête façon azulejo */
.entete {
  position: sticky; top: 0; z-index: 20;
  background-color: var(--bleu);
  background-image:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.16) 0 6px, transparent 7px),
    radial-gradient(circle at 0 0, rgba(255,255,255,0.10) 0 10px, transparent 11px),
    radial-gradient(circle at 100% 100%, rgba(255,255,255,0.10) 0 10px, transparent 11px),
    radial-gradient(circle at 100% 0, rgba(255,255,255,0.10) 0 10px, transparent 11px),
    radial-gradient(circle at 0 100%, rgba(255,255,255,0.10) 0 10px, transparent 11px);
  background-size: 32px 32px;
  color: #fff; padding: 10px 14px calc(10px); padding-top: calc(10px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 10px;
}
.logo { width: 40px; height: 40px; flex: none; }
.entete .nom-app { font-family: 'Fredoka'; font-weight: 700; font-size: 19px; flex: 1; letter-spacing: 0.2px; }
.entete .nom-app small { display: block; font-weight: 400; font-size: 12px; opacity: 0.85; }
.puce-agent { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.16); border: 0; color: #fff; border-radius: 999px; padding: 4px 10px 4px 4px; font-weight: 600; font-size: 14px; }
.puce-agent .av { width: 30px; height: 30px; }

/* ─── contenu */
main { max-width: 560px; margin: 0 auto; padding: 14px 14px 110px; }
.carte { background: #fff; border-radius: var(--rayon); padding: 16px; margin: 0 0 14px; box-shadow: var(--ombre); border: 1.5px solid var(--bord); }
.carte.jaune { background: var(--jaune-clair); border-color: #f3dc94; }
.carte.bleue { background: var(--bleu-clair); border-color: #c5d5f1; }
.carte.verte { background: var(--vert-clair); border-color: #b4e6d4; }
.carte.corail { background: var(--corail-clair); border-color: #ffc6bc; }
.petit { font-size: 14px; color: var(--doux); }
.rang { display: flex; gap: 10px; align-items: center; }
.rang.espace { justify-content: space-between; }
.pile > * + * { margin-top: 10px; }
.etiquette { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--bleu-clair); color: var(--bleu); text-transform: uppercase; letter-spacing: 0.4px; }
.etiquette.ensemble { background: var(--jaune-clair); color: #8a5a00; }
.etiquette.distance { background: #ece6ff; color: var(--violet); }
.etiquette.ok { background: var(--vert-clair); color: #0d6e52; }
.etiquette.attente { background: var(--corail-clair); color: #b33a29; }

/* ─── boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 700; font-family: 'Fredoka'; font-size: 17px; background: var(--bleu); color: #fff; cursor: pointer; box-shadow: 0 3px 0 var(--bleu-fonce); text-decoration: none; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--bleu-fonce); }
.btn.large { width: 100%; }
.btn.jaune { background: var(--jaune); color: var(--encre); box-shadow: 0 3px 0 #d9a21a; }
.btn.corail { background: var(--corail); box-shadow: 0 3px 0 #d64c3a; }
.btn.vert { background: var(--vert); box-shadow: 0 3px 0 #0f7a5c; }
.btn.blanc { background: #fff; color: var(--bleu); box-shadow: 0 0 0 2px var(--bleu) inset, 0 3px 0 var(--bleu-fonce); }
.btn.petit { padding: 8px 12px; font-size: 15px; border-radius: 11px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.groupe-btn { display: flex; gap: 10px; flex-wrap: wrap; }
.groupe-btn .btn { flex: 1; }

/* ─── champs */
.champ { display: block; margin: 0 0 12px; }
.champ span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.champ input, .champ textarea, .champ select { width: 100%; border: 2px solid var(--bord); border-radius: 12px; padding: 11px 12px; background: #fff; }
.champ input:focus, .champ textarea:focus { outline: none; border-color: var(--bleu); }
.code-input { font-size: 30px; letter-spacing: 14px; text-align: center; font-weight: 700; font-family: 'Fredoka'; }

/* ─── avatars */
.av { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--jaune); color: var(--encre); display: inline-flex; align-items: center; justify-content: center; font-family: 'Fredoka'; font-weight: 700; flex: none; overflow: hidden; }
.av.grand { width: 88px; height: 88px; font-size: 34px; }
.av img { width: 100%; height: 100%; object-fit: cover; }

/* ─── navigation du bas */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1.5px solid var(--bord); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
.nav-in { display: flex; max-width: 560px; width: 100%; }
.nav button { flex: 1; border: 0; background: none; padding: 8px 2px 10px; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 12px; font-weight: 600; color: var(--doux); position: relative; }
.nav button .ico { font-size: 23px; line-height: 1.1; filter: grayscale(0.4); }
.nav button.actif { color: var(--bleu); }
.nav button.actif .ico { filter: none; transform: scale(1.12); }
.nav .pastille { position: absolute; top: 4px; right: calc(50% - 22px); background: var(--corail); color: #fff; border-radius: 999px; font-size: 11px; min-width: 18px; height: 18px; padding: 0 5px; display: flex; align-items: center; justify-content: center; }

/* ─── Gardien */
.gardien { display: flex; gap: 14px; align-items: flex-start; }
.gardien .portrait { width: 74px; height: 74px; border-radius: 20px; flex: none; background: var(--bleu); overflow: hidden; border: 3px solid var(--jaune); }
.gardien .portrait img, .gardien .portrait video { width: 100%; height: 100%; object-fit: cover; }
.briefing { white-space: pre-line; }
.media-gardien { border-radius: 14px; overflow: hidden; margin: 10px 0; background: #000; }

/* ─── coffre */
.coffre { display: flex; gap: 12px; justify-content: center; margin: 26px 0 4px; flex-wrap: wrap; }
.cadenas { background: var(--bleu); border-radius: 16px; padding: 18px 8px 8px; position: relative; display: flex; gap: 5px; }
.cadenas::before { content: ''; position: absolute; top: -16px; left: 50%; transform: translateX(-50%); width: 34px; height: 30px; border: 6px solid var(--bleu); border-bottom: 0; border-radius: 20px 20px 0 0; }
.cadenas.ouvert::before { transform: translateX(-30%) translateY(-6px) rotate(-12deg); border-color: var(--vert); }
.cadenas.ouvert { background: var(--vert); }
.chiffre { width: 30px; height: 42px; border-radius: 10px; background: #fff; display: flex; align-items: center; justify-content: center; font-family: 'Fredoka'; font-weight: 700; font-size: 26px; color: var(--bleu); }
.chiffre.vide { background: rgba(255,255,255,0.25); color: rgba(255,255,255,0.8); font-size: 20px; }
.mots { display: flex; flex-wrap: wrap; gap: 8px; }
.mot { background: var(--vert-clair); color: #0d6e52; border-radius: 12px; padding: 6px 10px; font-weight: 600; }
.mot small { font-weight: 400; color: var(--doux); }

/* ─── missions */
.mission { display: flex; gap: 12px; align-items: center; background: #fff; border: 1.5px solid var(--bord); border-radius: 16px; padding: 12px; margin-bottom: 10px; width: 100%; text-align: left; cursor: pointer; box-shadow: var(--ombre); }
.mission .pico { width: 46px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 24px; flex: none; background: var(--bleu-clair); }
.mission.finale .pico { background: var(--jaune); }
.mission.faite { background: #f6fcf9; border-color: #b4e6d4; }
.mission.faite .pico { background: var(--vert-clair); }
.mission .txt { flex: 1; min-width: 0; }
.mission .txt b { font-family: 'Fredoka'; font-size: 17px; display: block; }
.mission .etat { font-size: 22px; }
.consigne { white-space: pre-line; font-size: 17px; }
.bonus { background: var(--jaune-clair); border-radius: 12px; padding: 8px 12px; font-size: 15px; margin-top: 10px; }
.indice { background: #f2ecff; border-radius: 12px; padding: 8px 12px; margin-top: 8px; color: #4b3497; }
.secret { background: var(--encre); color: #fff; border-radius: 16px; padding: 16px; font-size: 18px; font-family: 'Fredoka'; margin-top: 10px; }
.secret + .secret { margin-top: 8px; }
.tableau { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; font-size: 14px; margin-top: 10px; }
.tableau div { background: var(--bleu-clair); border-radius: 8px; padding: 4px 2px; text-align: center; }
.tableau b { color: var(--bleu); }
.tableau.morse { grid-template-columns: repeat(4, 1fr); }
.choix-vote { display: grid; gap: 8px; margin-top: 10px; }
.choix-vote button { border: 2px solid var(--bord); background: #fff; border-radius: 14px; padding: 12px; text-align: left; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.choix-vote button.choisi { border-color: var(--bleu); background: var(--bleu-clair); }
.barre { height: 10px; border-radius: 999px; background: var(--bleu-clair); overflow: hidden; margin-top: 4px; }
.barre i { display: block; height: 100%; background: var(--bleu); }
.qui-fait { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.qui-fait .av { width: 32px; height: 32px; font-size: 14px; opacity: 0.35; }
.qui-fait .av.ok { opacity: 1; outline: 3px solid var(--vert); outline-offset: 1px; }

/* ─── mur */
.post { background: #fff; border: 1.5px solid var(--bord); border-radius: var(--rayon); margin-bottom: 14px; overflow: hidden; box-shadow: var(--ombre); }
.post .haut { display: flex; gap: 10px; align-items: center; padding: 12px 12px 8px; }
.post .haut .qui { flex: 1; min-width: 0; }
.post .haut .qui b { display: block; }
.post .tag { margin: 0 12px 8px; display: inline-block; background: var(--jaune-clair); color: #8a5a00; border-radius: 10px; padding: 3px 9px; font-size: 13px; font-weight: 700; }
.post .corps { padding: 0 12px 10px; white-space: pre-line; }
.post .media img, .post .media video { width: 100%; max-height: 520px; object-fit: contain; background: #10152a; }
.post .bas { display: flex; align-items: center; gap: 6px; padding: 8px 10px 10px; flex-wrap: wrap; }
.react { border: 1.5px solid var(--bord); background: #fff; border-radius: 999px; padding: 4px 9px; font-size: 15px; }
.react.moi { border-color: var(--bleu); background: var(--bleu-clair); }
.post .valider { margin-left: auto; }
.composer textarea { width: 100%; border: 2px solid var(--bord); border-radius: 14px; padding: 10px 12px; min-height: 52px; resize: vertical; }

/* ─── agents */
.grille-agents { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fiche { background: #fff; border-radius: var(--rayon); border: 1.5px solid var(--bord); padding: 14px 10px; text-align: center; box-shadow: var(--ombre); position: relative; }
.fiche .av { margin: 0 auto 8px; }
.fiche .nc { font-family: 'Fredoka'; font-weight: 700; color: var(--bleu); font-size: 17px; }
.fiche .pts { position: absolute; top: 8px; right: 8px; background: var(--jaune); border-radius: 999px; font-size: 12px; font-weight: 700; padding: 2px 8px; }
.fiche.moi { border-color: var(--bleu); border-width: 2.5px; }

/* ─── modale */
#modal { position: fixed; inset: 0; z-index: 50; background: rgba(15, 22, 48, 0.55); display: flex; align-items: flex-end; justify-content: center; }
.feuille { background: var(--creme); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 24px 24px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); animation: monte .2s ease-out; }
@keyframes monte { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.feuille .fermer { float: right; border: 0; background: #fff; border-radius: 50%; width: 38px; height: 38px; font-size: 20px; box-shadow: var(--ombre); }

#toast { pointer-events: none; position: fixed; left: 50%; top: calc(72px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 60; background: var(--encre); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; max-width: 90vw; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
#toast.bien { background: var(--vert); }
#toast.mal { background: var(--corail); }

/* ─── enregistreur vidéo */
.camera { position: relative; border-radius: 16px; overflow: hidden; background: #10152a; aspect-ratio: 3 / 4; }
.camera video { width: 100%; height: 100%; object-fit: cover; }
.camera .chrono { position: absolute; top: 10px; left: 10px; background: var(--corail); color: #fff; font-weight: 700; border-radius: 999px; padding: 4px 12px; font-family: 'Fredoka'; }
.progression { height: 12px; border-radius: 999px; background: var(--bleu-clair); overflow: hidden; }
.progression i { display: block; height: 100%; width: 0; background: var(--vert); transition: width .2s; }

/* ─── clignotement morse */
.flash { position: fixed; inset: 0; z-index: 70; background: #0b1020; display: flex; align-items: center; justify-content: center; color: #fff; font-family: 'Fredoka'; font-size: 22px; }
.flash.on { background: var(--jaune); }

/* ─── accueil sans lien */
.accueil { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 480px; margin: 0 auto; text-align: center; }
.accueil .logo { width: 110px; height: 110px; margin: 0 auto 14px; }
.qr { background: #fff; border-radius: 14px; padding: 10px; display: inline-block; }
.qr svg, .qr img { width: 180px; height: 180px; }
.lien-agent { word-break: break-all; font-size: 13px; color: var(--doux); }
.sep { height: 1px; background: var(--bord); margin: 14px 0; }
.compte { font-family: 'Fredoka'; font-size: 22px; color: var(--bleu); font-weight: 700; }

.champ-nom { min-width: 0; }
.fete { text-align: center; }
.fete .gros { font-size: 64px; line-height: 1; margin: 6px 0; }
.fete .chiffre-geant { width: 84px; height: 108px; margin: 12px auto; border-radius: 18px; background: var(--bleu); color: #fff; font-family: 'Fredoka'; font-weight: 700; font-size: 64px; display: flex; align-items: center; justify-content: center; box-shadow: 0 5px 0 var(--bleu-fonce); }
