/* Secret Santa : pensé d'abord pour le téléphone (pouce, encoche, clavier). */
:root {
  --nuit: #0f1b33;
  --nuit-2: #18294a;
  --creme: #fff8ec;
  --creme-2: #f3e8d4;
  --encre: #2a1d14;
  --encre-douce: #6b5a4c;
  --rouge: #d6293f;
  --rouge-fonce: #a51c30;
  --vert: #1f7a4d;
  --vert-clair: #2fa56a;
  --or: #ffd166;
  --bleu-glace: #cfe6ff;
  --ombre: 0 6px 20px rgba(0, 0, 0, .25);
  --rayon: 22px;
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
  --onglets: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  font-family: 'Fredoka', system-ui, -apple-system, sans-serif;
  font-size: 17px; line-height: 1.4;
  color: var(--creme);
  background: radial-gradient(120% 70% at 50% 0%, #22406f 0%, var(--nuit) 60%) fixed, var(--nuit);
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
/* 16 px au moins : en dessous, iOS zoome dans le champ. */
input, textarea, select { font-size: 17px; }

#app {
  position: relative; z-index: 1;
  max-width: 560px; margin: 0 auto;
  padding: calc(var(--haut) + 16px) 16px calc(var(--onglets) + var(--bas) + 24px);
}
body.sans-onglets #app { padding-bottom: calc(var(--bas) + 24px); }
.chargement { font-size: 64px; text-align: center; margin-top: 30vh; animation: sautille 1s infinite; }

/* ---------- Neige ---------- */
#neige { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.flocon { position: absolute; top: -10px; color: #fff; opacity: .8; animation: tombe linear infinite; }
@keyframes tombe { to { transform: translate3d(var(--derive, 20px), 105vh, 0); } }
@media (prefers-reduced-motion: reduce) { #neige { display: none; } }

/* ---------- Titres ---------- */
.titre { font-family: 'Mountains of Christmas', 'Fredoka', cursive; font-size: 40px; line-height: 1.05; margin: 4px 0 2px; text-align: center; color: var(--or); text-shadow: 0 2px 0 rgba(0,0,0,.3); }
.sous-titre { text-align: center; color: var(--bleu-glace); margin: 0 0 18px; }
h2 { font-size: 21px; margin: 0 0 10px; }
h3 { font-size: 18px; margin: 16px 0 8px; }

/* ---------- Cartes ---------- */
.carte { background: var(--creme); color: var(--encre); border-radius: var(--rayon); padding: 18px; margin: 0 0 14px; box-shadow: var(--ombre); }
.carte.verre { background: rgba(255,255,255,.08); color: var(--creme); box-shadow: none; border: 1px solid rgba(255,255,255,.12); }
.carte.rouge { background: linear-gradient(160deg, #e8435a, var(--rouge-fonce)); color: #fff; }
.carte.vert { background: linear-gradient(160deg, var(--vert-clair), var(--vert)); color: #fff; }
.petit { font-size: 14px; color: var(--encre-douce); }
.verre .petit, .rouge .petit, .vert .petit { color: rgba(255,255,255,.75); }
.centre { text-align: center; }
.ligne { display: flex; gap: 10px; align-items: center; }
.ligne > .etire { flex: 1; min-width: 0; }

/* ---------- Boutons : au moins 48 px, faits pour le pouce ---------- */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; padding: 12px 18px; border: 0; border-radius: 16px; background: var(--rouge); color: #fff; font-weight: 600; font-size: 18px; cursor: pointer; box-shadow: 0 4px 0 var(--rouge-fonce); transition: transform .08s; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--rouge-fonce); }
.btn.vert { background: var(--vert-clair); box-shadow: 0 4px 0 var(--vert); }
.btn.or { background: var(--or); color: var(--encre); box-shadow: 0 4px 0 #c99a2e; }
.btn.discret { background: rgba(0,0,0,.06); color: inherit; box-shadow: none; font-weight: 500; }
.verre .btn.discret, body > #app > .btn.discret { background: rgba(255,255,255,.1); }
.btn.petit-btn { min-height: 44px; font-size: 16px; width: auto; padding: 8px 14px; }
.btn:disabled { opacity: .5; }
.btns { display: grid; gap: 10px; }
.btns.deux { grid-template-columns: 1fr 1fr; }

/* ---------- Champs ---------- */
label.champ { display: block; margin: 0 0 12px; font-weight: 500; }
label.champ span { display: block; font-size: 15px; margin-bottom: 4px; color: var(--encre-douce); }
.champ input, .champ textarea, .champ select, input.champ-libre {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 14px;
  border: 2px solid var(--creme-2); background: #fff; color: var(--encre); outline: none;
}
.champ input:focus, .champ textarea:focus, input.champ-libre:focus { border-color: var(--rouge); }
textarea { resize: none; }

/* ---------- Avatars ---------- */
.avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 26px; background: var(--creme-2); }
.avatar.grand { width: 96px; height: 96px; font-size: 60px; margin: 0 auto; }
.verre .avatar { background: rgba(255,255,255,.15); }
.grille-avatars { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.choix-perso { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 16px; border: 2px solid transparent; background: rgba(0,0,0,.05); cursor: pointer; font-size: 15px; text-align: center; word-break: break-word; }
.choix-perso.choisi { border-color: var(--rouge); background: #ffe3e7; }
.grille-emojis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.grille-emojis button { min-height: 52px; font-size: 30px; border-radius: 14px; border: 2px solid transparent; background: rgba(0,0,0,.05); }
.grille-emojis button.choisi { border-color: var(--rouge); background: #ffe3e7; }

/* ---------- Barre d'onglets en bas (zone du pouce) ---------- */
#onglets {
  position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center;
  padding: 6px 6px calc(6px + var(--bas));
  background: rgba(12, 22, 42, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255,255,255,.08);
}
#onglets button {
  position: relative; flex: 1; max-width: 112px; min-height: 52px; border: 0; background: none; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 12px; font-weight: 500; color: rgba(255,255,255,.6); touch-action: manipulation;
}
#onglets button .ic { font-size: 24px; line-height: 1; transition: transform .15s; }
#onglets button.actif { color: #fff; background: rgba(255,255,255,.09); }
#onglets button.actif .ic { transform: scale(1.15); }
.pastille { position: absolute; top: 4px; right: calc(50% - 22px); min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--rouge); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }

/* ---------- Toast ---------- */
#toast { position: fixed; z-index: 30; left: 50%; bottom: calc(var(--onglets) + var(--bas) + 14px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .25s; background: var(--creme); color: var(--encre); padding: 12px 18px; border-radius: 30px; box-shadow: var(--ombre); font-weight: 500; max-width: calc(100vw - 32px); text-align: center; }
#toast.visible { opacity: 1; transform: translate(-50%, 0); }
#toast.erreur { background: var(--rouge); color: #fff; }

/* ---------- Le cadeau à déballer ---------- */
.scene-cadeau { display: grid; place-items: center; padding: 24px 0 8px; user-select: none; -webkit-user-select: none; }
.cadeau { position: relative; width: 210px; height: 200px; cursor: pointer; touch-action: manipulation; }
.cadeau .boite { position: absolute; bottom: 0; left: 15px; width: 180px; height: 130px; border-radius: 14px; background: linear-gradient(160deg, #e8435a, var(--rouge-fonce)); box-shadow: var(--ombre); }
.cadeau .boite::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 30px; transform: translateX(-50%); background: var(--or); }
.cadeau .couvercle { position: absolute; top: 34px; left: 0; width: 210px; height: 50px; border-radius: 12px; background: linear-gradient(160deg, #f25b70, #c2253b); box-shadow: 0 4px 10px rgba(0,0,0,.25); transition: transform .6s cubic-bezier(.3,1.6,.5,1), opacity .6s; z-index: 2; }
.cadeau .couvercle::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 30px; transform: translateX(-50%); background: var(--or); }
.cadeau .noeud { position: absolute; top: -34px; left: 50%; transform: translateX(-50%); font-size: 56px; line-height: 1; }
.cadeau.secoue-1 { animation: secoue .4s; }
.cadeau.secoue-2 { animation: secoue .4s 2; }
.cadeau.ouvert .couvercle { transform: translate(60px, -160px) rotate(35deg); opacity: 0; }
@keyframes secoue { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-8deg) scale(1.04); } 75% { transform: rotate(8deg) scale(1.04); } }
@keyframes sautille { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.indice-tap { margin-top: 18px; color: var(--bleu-glace); animation: sautille 1.6s infinite; }
.nom-cible { font-family: 'Mountains of Christmas', cursive; font-size: 48px; line-height: 1.05; color: var(--or); text-align: center; margin: 8px 0; animation: apparait .7s cubic-bezier(.3,1.6,.5,1); }
@keyframes apparait { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Confettis ---------- */
.confetti { position: fixed; z-index: 40; top: -12px; width: 10px; height: 14px; border-radius: 2px; pointer-events: none; animation: confetti 2.6s ease-in forwards; }
@keyframes confetti { to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--rot)); } }

/* ---------- Bandeau « tu offres à » ---------- */
.bandeau-cible { display: flex; align-items: center; gap: 12px; }
.bandeau-cible .nom { font-size: 26px; font-weight: 700; line-height: 1.1; }

/* ---------- Compte à rebours ---------- */
.rebours { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.rebours div { background: rgba(255,255,255,.1); border-radius: 14px; padding: 8px 0; }
.rebours b { display: block; font-size: 26px; line-height: 1.1; }
.rebours small { font-size: 12px; opacity: .75; }

/* ---------- Cases à cocher géantes ---------- */
.coche { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: rgba(0,0,0,.05); margin-bottom: 8px; cursor: pointer; min-height: 56px; }
.coche .case { width: 30px; height: 30px; flex: none; border-radius: 9px; border: 3px solid var(--vert-clair); display: grid; place-items: center; font-size: 18px; color: #fff; transition: .15s; }
.coche.faite .case { background: var(--vert-clair); }
.coche.faite { background: #e1f5ea; }

/* ---------- Listes ---------- */
.souhait { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px dashed var(--creme-2); }
.souhait:last-child { border-bottom: 0; }
.fiche-ligne { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--creme-2); }
.fiche-ligne:last-child { border-bottom: 0; }
.fiche-ligne span:first-child { color: var(--encre-douce); }
.fiche-ligne span:last-child { text-align: right; font-weight: 500; }
.ligne-souhait { display: flex; gap: 8px; margin-bottom: 8px; }
.ligne-souhait input { flex: 1; }
.btn-rond { width: 48px; height: 48px; flex: none; border-radius: 50%; border: 0; background: rgba(0,0,0,.07); font-size: 20px; }

/* ---------- Messages ---------- */
.segments { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 16px; background: rgba(255,255,255,.08); margin-bottom: 12px; }
.segments button { position: relative; min-height: 46px; border: 0; border-radius: 12px; background: none; font-weight: 500; font-size: 15px; color: rgba(255,255,255,.7); }
.segments button.actif { background: var(--creme); color: var(--encre); }
.segments .pastille { top: -6px; right: 6px; }
.fil { display: flex; flex-direction: column; gap: 8px; padding: 6px 0 12px; }
.bulle { max-width: 82%; padding: 10px 14px; border-radius: 20px; white-space: pre-wrap; word-break: break-word; animation: apparait .3s; }
.bulle.moi { align-self: flex-end; background: var(--rouge); color: #fff; border-bottom-right-radius: 6px; }
.bulle.autre { align-self: flex-start; background: var(--creme); color: var(--encre); border-bottom-left-radius: 6px; }
.bulle small { display: block; font-size: 11px; opacity: .65; margin-top: 2px; }
.fil-vide { text-align: center; color: var(--bleu-glace); padding: 28px 10px; }
.puces { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; scroll-snap-type: x proximity; }
.puces::-webkit-scrollbar { display: none; }
.puces button { flex: none; min-height: 40px; padding: 6px 14px; border-radius: 20px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #fff; font-size: 15px; scroll-snap-align: start; }
.saisie { position: sticky; bottom: calc(var(--onglets) + var(--bas) + 8px); display: flex; gap: 8px; align-items: flex-end; padding: 8px; border-radius: 26px; background: rgba(12,22,42,.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.12); z-index: 5; }
.saisie textarea { flex: 1; min-height: 44px; max-height: 140px; padding: 10px 14px; border-radius: 20px; border: 0; background: #fff; color: var(--encre); outline: none; }
.saisie button { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: var(--rouge); color: #fff; font-size: 20px; }

/* ---------- Astuces : cartes qu'on fait défiler du pouce ---------- */
.carrousel { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px 14px; padding: 4px 16px 10px; scrollbar-width: none; }
.carrousel::-webkit-scrollbar { display: none; }
.carrousel .carte { flex: 0 0 82%; scroll-snap-align: center; margin: 0; min-height: 170px; display: flex; flex-direction: column; }
.carrousel .carte .gros-emoji { font-size: 40px; }
.categories { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
.categories::-webkit-scrollbar { display: none; }
.categories button { flex: none; min-height: 40px; padding: 6px 14px; border-radius: 20px; border: 0; background: rgba(255,255,255,.1); color: #fff; font-size: 15px; }
.categories button.actif { background: var(--or); color: var(--encre); font-weight: 600; }
.idee-tiree { font-size: 22px; font-weight: 600; text-align: center; padding: 14px 4px; min-height: 92px; display: grid; place-items: center; }
.idee-tiree.tourne { animation: tourne .4s; }
@keyframes tourne { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }

/* ---------- Groupe ---------- */
.progression { height: 14px; border-radius: 7px; background: rgba(255,255,255,.15); overflow: hidden; margin: 6px 0; }
.progression div { height: 100%; background: linear-gradient(90deg, var(--vert-clair), var(--or)); border-radius: 7px; transition: width .6s; }
.rangee-avatars { display: flex; flex-wrap: wrap; gap: 6px; }
.rangee-avatars .avatar { width: 38px; height: 38px; font-size: 22px; position: relative; }
.rangee-avatars .avatar.fait::after { content: '✓'; position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%; background: var(--vert-clair); color: #fff; font-size: 11px; display: grid; place-items: center; font-weight: 700; }
.mot-mur { padding: 12px 14px; border-radius: 16px; background: rgba(255,255,255,.08); margin-bottom: 8px; }
.mot-mur .qui { font-size: 13px; color: var(--bleu-glace); margin-bottom: 2px; }
.chaine-item { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px dashed var(--creme-2); opacity: 0; animation: apparait .5s forwards; }
.chaine-item .fleche { font-size: 20px; }
.chaine-item .nom-court { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Organisateur ---------- */
.perso-orga { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--creme-2); }
.perso-orga:last-child { border-bottom: 0; }
.perso-orga .nom { font-weight: 600; }
.etats { display: flex; gap: 4px; font-size: 15px; letter-spacing: 1px; }
.etats .non { opacity: .2; filter: grayscale(1); }
.puce-ex { display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-radius: 20px; background: var(--creme-2); margin: 0 6px 6px 0; }
.puce-ex button { width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(0,0,0,.08); }
.suspense { font-size: 80px; text-align: center; animation: secoue .3s infinite; }

/* ---------- Fenêtre du bas (feuille) ---------- */
.voile { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; animation: fondu .2s; }
@keyframes fondu { from { opacity: 0; } }
.feuille { width: 100%; max-width: 560px; margin: 0 auto; max-height: 88dvh; overflow-y: auto; background: var(--creme); color: var(--encre); border-radius: 26px 26px 0 0; padding: 10px 18px calc(18px + var(--bas)); animation: monte .25s cubic-bezier(.2,.9,.3,1); overscroll-behavior: contain; }
.feuille .poignee { width: 44px; height: 5px; border-radius: 3px; background: rgba(0,0,0,.18); margin: 0 auto 12px; }
@keyframes monte { from { transform: translateY(100%); } }

.cache { display: none !important; }

/* ---------- La roue des thèmes ---------- */
.roue-zone { position: relative; width: min(78vw, 320px, 44dvh); aspect-ratio: 1; margin: 18px auto 10px; }
.roue { position: absolute; inset: 0; border-radius: 50%; border: 8px solid var(--or); box-shadow: 0 0 0 4px var(--rouge-fonce), var(--ombre); overflow: hidden; transition: transform 5s cubic-bezier(.12,.8,.18,1); }
.roue .part { position: absolute; left: 50%; top: 0; height: 50%; width: 0; transform-origin: bottom center; display: flex; justify-content: center; }
.roue .part span { display: block; margin-top: 10px; font-size: 26px; line-height: 1; transform: translateX(0); }
.roue-moyeu { position: absolute; left: 50%; top: 50%; width: 22%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: var(--creme); display: grid; place-items: center; font-size: 30px; box-shadow: 0 2px 8px rgba(0,0,0,.35); border: 4px solid var(--or); cursor: pointer; z-index: 2; }
.roue-fleche { position: absolute; left: 50%; top: -14px; transform: translateX(-50%); width: 0; height: 0; border-left: 16px solid transparent; border-right: 16px solid transparent; border-top: 30px solid #fff; filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); z-index: 3; }
.theme-badge { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 20px; background: var(--or); color: var(--encre); font-weight: 600; font-size: 18px; }
.ligne-theme { display: flex; gap: 8px; margin-bottom: 8px; }
.ligne-theme input { flex: 1; }

/* ---------- Code secret : points et pavé à gros chiffres ---------- */
.points-code { display: flex; justify-content: center; gap: 18px; margin: 8px 0 6px; }
.points-code span { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--creme); transition: .12s; }
.points-code span.plein { background: var(--or); border-color: var(--or); transform: scale(1.1); }
.points-code.faux { animation: secoue .35s 2; }
.pave { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 320px; margin: 0 auto; }
.pave button { aspect-ratio: 1.35; border: 0; border-radius: 22px; background: rgba(255,255,255,.12); color: #fff; font-size: 30px; font-weight: 600; touch-action: manipulation; }
.pave button:active { background: rgba(255,255,255,.3); transform: scale(.96); }
.pave [data-retour], .pave [data-effacer] { background: none; font-size: 26px; }

/* ---------- Le chapeau ---------- */
.scene-chapeau { position: relative; height: 290px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; user-select: none; -webkit-user-select: none; }
.chapeau { font-size: 150px; line-height: 1; cursor: pointer; touch-action: manipulation; position: relative; z-index: 2; filter: drop-shadow(0 8px 12px rgba(0,0,0,.4)); }
.chapeau.agite { animation: secoue .25s infinite; }
.papier { position: absolute; bottom: 70px; z-index: 1; display: flex; align-items: center; gap: 10px; padding: 12px 22px 12px 12px; border-radius: 16px; background: var(--creme); color: var(--encre); font-size: 24px; font-weight: 700; box-shadow: var(--ombre); opacity: 0; transform: translateY(40px) scale(.6); transition: transform .5s cubic-bezier(.3,1.6,.5,1), opacity .3s; white-space: nowrap; }
.papier.sort { opacity: 1; transform: translateY(-110px) rotate(-3deg); }
.papier.gagne { transform: translateY(-120px) scale(1.25); background: var(--or); }
