:root {
  --violet: #6c3cf0; --violet-fonce: #4b22c4; --violet-clair: #efe9ff;
  --vert: #22c55e; --vert-fonce: #15803d; --vert-clair: #dcfce7;
  --orange: #ff8a00; --orange-clair: #fff1dc;
  --rouge: #ef4444; --rouge-clair: #fee2e2;
  --jaune: #ffc83d; --bleu: #0ea5e9; --rose: #ec4899;
  --fond: #f6f3ff; --carte: #ffffff; --texte: #1f1640; --doux: #6b6390; --bord: #e4ddff;
  --rayon: 18px; --ombre: 0 4px 0 rgba(76, 34, 196, .12), 0 10px 24px rgba(76, 34, 196, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--fond); color: var(--texte); font-size: 16px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.2; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: .3rem 0 .8rem; }
.chargement { padding: 4rem 1rem; text-align: center; color: var(--doux); }
.cache { display: none !important; }
.doux { color: var(--doux); }
.petit { font-size: .88rem; }
.centre { text-align: center; }

/* ---------- Boutons et champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 0; border-radius: 14px; padding: .7rem 1.1rem; font-weight: 800; cursor: pointer;
  background: var(--violet); color: #fff; box-shadow: 0 4px 0 var(--violet-fonce);
  transition: transform .08s, box-shadow .08s, filter .15s; min-height: 44px;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--violet-fonce); }
.btn:disabled { background: #cfc8e8; box-shadow: 0 4px 0 #b4abd6; cursor: not-allowed; transform: none; filter: none; }
.btn.vert { background: var(--vert); box-shadow: 0 4px 0 var(--vert-fonce); }
.btn.rouge { background: var(--rouge); box-shadow: 0 4px 0 #b91c1c; }
.btn.orange { background: var(--orange); box-shadow: 0 4px 0 #c2410c; }
.btn.clair { background: #fff; color: var(--violet); box-shadow: 0 4px 0 var(--bord); border: 2px solid var(--bord); }
.btn.petit { padding: .4rem .75rem; min-height: 36px; font-size: .9rem; border-radius: 11px; }
.btn.large { width: 100%; }
label { display: block; font-weight: 700; margin: .6rem 0 .25rem; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: .7rem .85rem; border: 2px solid var(--bord); border-radius: 12px; background: var(--carte); min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 4px var(--violet-clair); }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.case { display: flex; align-items: center; gap: .5rem; font-weight: 700; margin: .7rem 0; }
.case input { width: 22px; height: 22px; accent-color: var(--violet); }
.ligne-form { display: grid; gap: .6rem; grid-template-columns: 1fr; align-items: end; }
@media (min-width: 720px) { .ligne-form { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }
.ligne-form label { margin-top: 0; }

/* ---------- Cartes ---------- */
.carte { background: var(--carte); border-radius: var(--rayon); padding: 1.1rem; box-shadow: var(--ombre); margin-bottom: 1rem; border: 2px solid #fff; }
.grille { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.pastille { display: inline-flex; align-items: center; gap: .25rem; padding: .15rem .6rem; border-radius: 999px; font-weight: 800; font-size: .85rem; white-space: nowrap; }
.pastille.attente { background: var(--orange-clair); color: #b45309; }
.pastille.valide { background: var(--vert-clair); color: var(--vert-fonce); }
.pastille.refuse { background: var(--rouge-clair); color: #b91c1c; }
.pastille.points { background: var(--violet-clair); color: var(--violet); }
.pastille.zero { background: #eee; color: #666; }
.vide { text-align: center; padding: 2rem 1rem; color: var(--doux); }
.vide .gros { font-size: 2.6rem; display: block; margin-bottom: .4rem; }

/* ---------- Connexion ---------- */
.ecran-connexion { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.2rem;
  background: radial-gradient(circle at 20% 10%, #ffd7f0 0, transparent 40%), radial-gradient(circle at 90% 80%, #c9f7ff 0, transparent 40%), var(--fond); }
.boite-connexion { width: 100%; max-width: 420px; }
.logo { text-align: center; margin-bottom: 1rem; }
.logo .etoile { font-size: 3.4rem; display: inline-block; animation: flotte 3s ease-in-out infinite; }
.logo h1 { font-size: 1.6rem; color: var(--violet); }
.onglets { display: flex; background: var(--violet-clair); border-radius: 14px; padding: 4px; margin-bottom: 1rem; }
.onglets button { flex: 1; border: 0; background: transparent; padding: .6rem; border-radius: 11px; font-weight: 800; cursor: pointer; color: var(--doux); min-height: 44px; }
.onglets button.actif { background: #fff; color: var(--violet); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.code-input { letter-spacing: .6em; text-align: center; font-size: 1.5rem; font-weight: 800; }

/* ---------- Barre du haut ---------- */
.entete { position: sticky; top: 0; z-index: 20; background: var(--violet); color: #fff; padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top));
  display: flex; align-items: center; gap: .6rem; box-shadow: 0 4px 0 var(--violet-fonce); }
.entete .titre { font-weight: 900; font-size: 1.05rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compteur { display: inline-flex; align-items: center; gap: .3rem; background: rgba(255,255,255,.18); padding: .3rem .7rem; border-radius: 999px; font-weight: 900; }
.btn-sortie { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 10px; padding: .45rem .7rem; font-weight: 800; cursor: pointer; min-height: 38px; }
.contenu { max-width: 980px; margin: 0 auto; padding: 1rem; padding-bottom: 6.5rem; }

/* ---------- Navigation ---------- */
.nav-bas { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--carte); display: flex; justify-content: space-around;
  border-top: 2px solid var(--bord); padding: .3rem .2rem; padding-bottom: max(.3rem, env(safe-area-inset-bottom)); }
.nav-bas button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .35rem .1rem;
  font-size: .72rem; font-weight: 800; color: var(--doux); cursor: pointer; border-radius: 12px; min-height: 52px; position: relative; }
.nav-bas button .ico { font-size: 1.45rem; line-height: 1; transition: transform .2s; }
.nav-bas button.actif { color: var(--violet); background: var(--violet-clair); }
.nav-bas button.actif .ico { transform: scale(1.15); }
.badge { position: absolute; top: 2px; right: calc(50% - 22px); background: var(--rouge); color: #fff; font-size: .7rem; border-radius: 999px; padding: 0 .4rem; min-width: 18px; }
@media (min-width: 900px) {
  .avec-cote .nav-bas { top: 64px; bottom: 0; right: auto; width: 210px; flex-direction: column; justify-content: flex-start; border-top: 0; border-right: 2px solid var(--bord); padding: 1rem .6rem; gap: .3rem; }
  .avec-cote .nav-bas button { flex: 0; flex-direction: row; justify-content: flex-start; gap: .6rem; font-size: .95rem; padding: .6rem .8rem; min-height: 44px; }
  .avec-cote .nav-bas .badge { position: static; margin-left: auto; }
  .avec-cote .contenu { margin-left: 210px; max-width: 1100px; padding: 1.4rem 2rem 2rem; }
}

/* ---------- Accueil élève ---------- */
.heros { background: linear-gradient(135deg, var(--violet) 0%, #9a5cff 55%, var(--rose) 120%); color: #fff; border-radius: 24px; padding: 1.4rem; text-align: center;
  position: relative; overflow: hidden; box-shadow: 0 6px 0 var(--violet-fonce); margin-bottom: 1rem; }
.heros .bonjour { font-weight: 800; opacity: .95; }
.heros .total { font-size: 3.4rem; font-weight: 900; line-height: 1.1; margin: .3rem 0; text-shadow: 0 3px 0 rgba(0,0,0,.15); }
.heros .total small { font-size: 1.1rem; font-weight: 800; opacity: .9; }
.heros .reserve { font-size: .9rem; opacity: .9; }
.flamme-boite { display: flex; align-items: center; gap: .9rem; }
.flamme { font-size: 2.6rem; display: inline-block; transform-origin: 50% 90%; }
.flamme.allumee { animation: flamme 1.4s ease-in-out infinite; }
.flamme.eteinte { filter: grayscale(1); opacity: .45; }
.serie-nb { font-size: 1.8rem; font-weight: 900; color: var(--orange); line-height: 1; }
.mini-serie { display: flex; gap: 4px; margin-top: .4rem; flex-wrap: wrap; }
.mini-serie span { width: 18px; height: 18px; border-radius: 6px; background: #eee; }
.mini-serie span.ok { background: var(--orange); }
.mini-serie span.non { background: var(--rouge-clair); border: 2px solid var(--rouge); }

/* Barre de progression */
.barre { height: 22px; background: var(--violet-clair); border-radius: 999px; overflow: hidden; position: relative; border: 2px solid var(--bord); }
.barre > div { height: 100%; background: linear-gradient(90deg, var(--vert), #4ade80); border-radius: 999px; transition: width 1s cubic-bezier(.2,.9,.3,1.2); width: 0; position: relative; }
.barre > div::after { content: ""; position: absolute; inset: 3px 8px auto 8px; height: 5px; border-radius: 9px; background: rgba(255,255,255,.45); }
.barre-texte { display: flex; justify-content: space-between; font-weight: 800; font-size: .9rem; margin-top: .3rem; }

/* Devoirs */
.devoir { display: flex; align-items: center; gap: .8rem; }
.devoir .note { width: 64px; height: 64px; flex: 0 0 64px; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 900; font-size: 1.3rem; background: var(--violet-clair); color: var(--violet); }
.devoir .note small { font-size: .7rem; font-weight: 800; }
.devoir .note.nr { background: var(--rouge-clair); color: var(--rouge); font-size: .8rem; text-align: center; }
.devoir .info { flex: 1; min-width: 0; }
.devoir .info b { display: block; }
.devoir .gain { font-weight: 900; font-size: 1.15rem; color: var(--vert-fonce); text-align: right; }
.devoir .gain.zero { color: #999; }
.bonus-tag { display: inline-block; background: var(--jaune); color: #6b4500; font-weight: 900; font-size: .75rem; border-radius: 8px; padding: 0 .35rem; margin-left: .3rem; }

/* Boutique */
.article { display: flex; flex-direction: column; text-align: center; transition: transform .15s; }
.article:hover { transform: translateY(-3px); }
.article .ico { font-size: 2.8rem; margin: .2rem 0 .4rem; }
.article h3 { margin-bottom: .2rem; }
.article .desc { color: var(--doux); font-size: .92rem; flex: 1; }
.article .prix { font-size: 1.3rem; font-weight: 900; color: var(--violet); margin: .4rem 0; }
.article .stock { font-size: .82rem; color: var(--doux); margin-bottom: .5rem; }
.article.inactif { opacity: .55; }
.manque { font-size: .85rem; color: var(--orange); font-weight: 800; margin-top: .4rem; }

/* Graphique */
.graph { width: 100%; height: auto; display: block; }
.graph .axe { stroke: var(--bord); stroke-width: 1; }
.graph .grille-l { stroke: #eee; stroke-dasharray: 4 4; }
.graph .courbe { fill: none; stroke: var(--violet); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.graph .aire { fill: url(#degrade); opacity: .35; }
.graph .point { fill: #fff; stroke: var(--violet); stroke-width: 3; }
.graph .point.nr { stroke: var(--rouge); fill: var(--rouge-clair); }
.graph .barre-pts { fill: var(--jaune); }
.graph text { font-size: 11px; fill: var(--doux); font-family: inherit; }
.graph .val { font-weight: 800; fill: var(--texte); }
.legende { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; font-weight: 700; color: var(--doux); }
.legende i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 4px; }
.legende .l-note { background: var(--violet); }
.legende .l-pts { background: var(--jaune); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: var(--carte); border-radius: 16px; padding: .8rem; text-align: center; box-shadow: var(--ombre); }
.stat b { display: block; font-size: 1.6rem; font-weight: 900; color: var(--violet); }
.stat span { font-size: .85rem; color: var(--doux); font-weight: 700; }

/* Listes et tableaux */
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; align-items: center; gap: .6rem; padding: .7rem 0; border-bottom: 2px solid var(--violet-clair); flex-wrap: wrap; }
.liste li:last-child { border-bottom: 0; }
.liste .grow { flex: 1; min-width: 140px; }
.montant { font-weight: 900; white-space: nowrap; }
.montant.plus { color: var(--vert-fonce); }
.montant.moins { color: var(--rouge); }
.montant.nul { color: var(--doux); }
.tableau-boite { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .5rem; text-align: left; border-bottom: 2px solid var(--violet-clair); vertical-align: middle; }
th { font-size: .85rem; color: var(--doux); text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; }
.actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.saisie { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.saisie select { width: auto; min-width: 120px; }
.saisie input { width: 90px; }
.barre-outils { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.barre-outils select { width: auto; min-width: 160px; }
.barre-outils .grow { flex: 1; }

/* Fenêtre */
.voile { position: fixed; inset: 0; background: rgba(31, 22, 64, .55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 0; animation: apparait .15s; }
.fenetre { background: var(--carte); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 24px 24px 0 0; padding: 1.3rem; animation: monte .25s cubic-bezier(.2,.9,.3,1.1); }
@media (min-width: 600px) { .voile { align-items: center; padding: 1rem; } .fenetre { border-radius: 24px; } }
.fenetre .boutons { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.2rem; flex-wrap: wrap; }
.code-affiche { font-size: 2.6rem; font-weight: 900; letter-spacing: .3em; text-align: center; background: var(--violet-clair); color: var(--violet); border-radius: 16px; padding: .6rem; margin: .6rem 0; }
.alerte { background: var(--orange-clair); border-left: 5px solid var(--orange); padding: .7rem .9rem; border-radius: 10px; font-weight: 700; margin: .6rem 0; }
.alerte.info { background: var(--violet-clair); border-color: var(--violet); }

/* Messages */
#toasts { position: fixed; top: 74px; left: 50%; transform: translateX(-50%); z-index: 100000; display: flex; flex-direction: column; gap: .5rem; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--texte); color: #fff; padding: .8rem 1rem; border-radius: 14px; font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: toast .3s cubic-bezier(.2,.9,.3,1.3); }
.toast.erreur { background: var(--rouge); }
.toast.succes { background: var(--vert-fonce); }

/* Animations de gain */
.bulle-gain { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 100001; pointer-events: none; font-size: 3rem; font-weight: 900; color: var(--vert);
  text-shadow: 0 4px 0 #fff, 0 6px 16px rgba(0,0,0,.2); animation: gain 1.8s ease-out forwards; }
.etincelle { position: fixed; z-index: 100001; pointer-events: none; font-size: 1.6rem; animation: etincelle 1.2s ease-out forwards; }
.saute { animation: saute .5s; }

@keyframes flotte { 50% { transform: translateY(-6px) rotate(6deg); } }
@keyframes flamme { 0%, 100% { transform: scale(1) rotate(-3deg); } 50% { transform: scale(1.12) rotate(3deg); } }
@keyframes apparait { from { opacity: 0; } }
@keyframes monte { from { transform: translateY(40px); opacity: 0; } }
@keyframes toast { from { transform: translateY(-20px) scale(.9); opacity: 0; } }
@keyframes gain { 0% { transform: translate(-50%, -20%) scale(.4); opacity: 0; } 20% { transform: translate(-50%, -50%) scale(1.25); opacity: 1; } 70% { opacity: 1; } 100% { transform: translate(-50%, -160%) scale(1); opacity: 0; } }
@keyframes etincelle { 0% { transform: translate(0, 0) scale(.3); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(200deg); opacity: 0; } }
@keyframes saute { 30% { transform: scale(1.18); } 60% { transform: scale(.95); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Impression : seulement la fenêtre ouverte (exemple : les codes des élèves) */
@media print {
  body > *:not(.voile) { display: none !important; }
  .voile { position: static; background: none; display: block; }
  .fenetre { max-height: none; box-shadow: none; border: 0; }
  .fenetre .boutons { display: none; }
}

/* ======================= Thèmes de couleur ======================= */
body.theme-ocean { --violet: #0077b6; --violet-fonce: #024f80; --violet-clair: #e0f4ff; --fond: #f0f9ff; --bord: #cde9fb; --rose: #00b4d8; }
body.theme-foret { --violet: #2d9d4f; --violet-fonce: #1b6e35; --violet-clair: #e3f7e8; --fond: #f2fbf3; --bord: #cdeed6; --rose: #a3d977; }
body.theme-coucher { --violet: #f0663c; --violet-fonce: #b9431c; --violet-clair: #ffe8dc; --fond: #fff6f0; --bord: #ffd9c4; --rose: #f9a03f; }
body.theme-bonbon { --violet: #e64ba0; --violet-fonce: #b8327c; --violet-clair: #ffe3f2; --fond: #fff4fa; --bord: #fbd0e7; --rose: #8b5cf6; }
body.theme-nuit { --violet: #8b6cff; --violet-fonce: #5b3fd6; --violet-clair: #2d2452; --fond: #141029; --carte: #211a3d; --texte: #f1ecff; --doux: #b3a8d9; --bord: #3a2f66; }
body.theme-nuit .carte { border-color: var(--carte); }
body.theme-nuit .btn.clair { background: var(--carte); }
.apercu-theme { display: inline-block; width: 22px; height: 22px; border-radius: 50%; vertical-align: middle; margin-right: .4rem; border: 2px solid #fff; box-shadow: 0 0 0 2px var(--bord); }
.apercu-theme.violet { background: #6c3cf0; } .apercu-theme.ocean { background: #0077b6; } .apercu-theme.foret { background: #2d9d4f; }
.apercu-theme.coucher { background: #f0663c; } .apercu-theme.bonbon { background: #e64ba0; } .apercu-theme.nuit { background: #141029; }

/* ======================= Divers ======================= */
.avatar { font-size: 2.6rem; line-height: 1; }
.avatar.petit { font-size: 1.4rem; }
.choix-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .6rem; }
.choix { border: 3px solid var(--bord); background: var(--carte); border-radius: 16px; padding: .6rem .3rem; text-align: center; cursor: pointer; font-weight: 800; font-size: .8rem; min-height: 44px; }
.choix .gros { font-size: 2.2rem; display: block; }
.choix.actif { border-color: var(--violet); background: var(--violet-clair); }
.choix:disabled { opacity: .4; cursor: not-allowed; }
.onglets-cat { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .4rem; margin-bottom: .8rem; }
.onglets-cat button { flex: 0 0 auto; border: 2px solid var(--bord); background: var(--carte); border-radius: 999px; padding: .45rem .9rem; font-weight: 800; cursor: pointer; color: var(--doux); min-height: 40px; }
.onglets-cat button.actif { background: var(--violet); border-color: var(--violet); color: #fff; }
.temps-barre { display: flex; align-items: center; gap: .6rem; }
.temps-barre .barre { flex: 1; }
.barre.orange > div { background: linear-gradient(90deg, var(--orange), #ffb347); }
.barre.rouge > div { background: linear-gradient(90deg, var(--rouge), #f87171); }
.mini-cal { display: flex; gap: 4px; flex-wrap: wrap; margin-top: .4rem; }
.mini-cal span { width: 26px; height: 26px; border-radius: 8px; background: #eee; font-size: .65rem; font-weight: 800; display: flex; align-items: center; justify-content: center; color: #777; }
.mini-cal span.ok { background: var(--orange); color: #fff; }
.mini-cal span.we { background: transparent; border: 2px dashed #ddd; }
.mini-cal span.bouclier { background: var(--bleu); color: #fff; }
.a-faire { border-left: 6px solid var(--orange); }
.a-faire.fini { border-left-color: var(--vert); }
.a-faire.retard { border-left-color: var(--rouge); }
.code-famille { font-size: 1.6rem; font-weight: 900; letter-spacing: .25em; color: var(--violet); }
.lien { background: none; border: 0; color: var(--violet); font-weight: 800; cursor: pointer; text-decoration: underline; padding: .3rem 0; }
.inventaire-ligne { display: flex; flex-wrap: wrap; gap: .5rem; }
.inventaire-ligne .pastille { font-size: .95rem; padding: .35rem .7rem; }
.texte-legal { font-size: .92rem; }
.texte-legal h3 { margin-top: 1rem; }
.verrou { text-align: center; padding: 2rem 1rem; }
.verrou .gros { font-size: 3.5rem; display: block; }

/* ======================= Écran de jeu ======================= */
.ecran-jeu { position: fixed; inset: 0; z-index: 40; background: var(--fond); overflow: auto; display: flex; flex-direction: column; }
.ecran-jeu .entete { position: sticky; }
.zone-jeu { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 1rem; gap: .8rem; max-width: 760px; width: 100%; margin: 0 auto; }
.statut-jeu { font-weight: 900; font-size: 1.15rem; text-align: center; min-height: 1.6em; }
.scores { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
.scores .score { background: var(--carte); border-radius: 14px; padding: .4rem .9rem; font-weight: 800; box-shadow: var(--ombre); border: 3px solid transparent; }
.scores .score.tour { border-color: var(--violet); }
.avantages { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; }
.avantages .btn { font-size: .85rem; }
.options-jeu { width: 100%; max-width: 460px; }
.pause-jeu { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 45; background: var(--texte); color: #fff; padding: .5rem 1rem; border-radius: 999px; font-weight: 800; }

.morpion { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(86vw, 330px); }
.morpion button, .alignement button { aspect-ratio: 1; border: 0; border-radius: 16px; background: var(--carte); box-shadow: var(--ombre); font-size: 3rem; font-weight: 900; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.morpion button.gagne, .alignement button.gagne, .p4 .trou.gagne { background: var(--jaune); }
.morpion button.indice, .alignement button.indice, .p4 .col.indice { outline: 4px dashed var(--orange); outline-offset: -4px; }
.c-x { color: var(--violet); } .c-o { color: var(--orange); }
.p4 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; background: var(--violet); padding: 8px; border-radius: 18px; width: min(94vw, 460px); box-shadow: 0 6px 0 var(--violet-fonce); }
.p4 .col { display: flex; flex-direction: column; gap: 6px; cursor: pointer; border-radius: 10px; padding: 2px; border: 0; background: transparent; }
.p4 .col:hover { background: rgba(255,255,255,.15); }
.p4 .trou { aspect-ratio: 1; border-radius: 50%; background: var(--fond); }
.p4 .trou.j0 { background: radial-gradient(circle at 35% 35%, #ff7a7a, var(--rouge)); animation: tombe .3s ease-in; }
.p4 .trou.j1 { background: radial-gradient(circle at 35% 35%, #ffe17a, #f5b400); animation: tombe .3s ease-in; }
@keyframes tombe { from { transform: translateY(-120px); } }
.pfc { display: flex; gap: .8rem; flex-wrap: wrap; justify-content: center; }
.pfc button { font-size: 3rem; width: 96px; height: 96px; border-radius: 24px; border: 0; background: var(--carte); box-shadow: var(--ombre); cursor: pointer; }
.pfc button.indice { outline: 4px dashed var(--orange); }
.duel { display: flex; gap: 1.5rem; align-items: center; justify-content: center; font-size: 3.4rem; min-height: 80px; }
.duel .vs { font-size: 1.2rem; font-weight: 900; color: var(--doux); }
.memoire { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: min(92vw, 400px); }
.memoire button { aspect-ratio: 3/4; border: 0; border-radius: 14px; font-size: 2.2rem; cursor: pointer; background: linear-gradient(135deg, var(--violet), var(--rose)); color: transparent; box-shadow: var(--ombre); transition: transform .25s; }
.memoire button.visible { background: var(--carte); color: inherit; transform: rotateY(180deg) scaleX(-1); }
.memoire button.trouve { background: var(--vert-clair); color: inherit; opacity: .75; }
.memoire button.indice { outline: 4px dashed var(--orange); }
.course { width: 100%; display: flex; flex-direction: column; gap: .6rem; }
.piste { background: var(--carte); border-radius: 16px; padding: .6rem .8rem; box-shadow: var(--ombre); }
.piste .route { height: 18px; background: repeating-linear-gradient(90deg, #ddd 0 12px, #eee 12px 24px); border-radius: 9px; position: relative; margin: .4rem 0; }
.piste .voiture { position: absolute; top: -10px; font-size: 1.6rem; transition: left .6s; transform: translateX(-50%); }
.piste .arrivee { position: absolute; right: -4px; top: -10px; font-size: 1.4rem; }
.main { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; }
.carte-course { width: 86px; min-height: 112px; border-radius: 12px; border: 3px solid var(--bord); background: var(--carte); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; padding: .3rem; font-weight: 800; font-size: .78rem; text-align: center; }
.carte-course .ico { font-size: 1.8rem; }
.carte-course.distance { border-color: var(--vert); }
.carte-course.obstacle { border-color: var(--rouge); }
.carte-course.reparation { border-color: var(--bleu); }
.carte-course.bonus { border-color: var(--jaune); background: #fff8dc; color: #333; }
.carte-course.choisie { transform: translateY(-8px); box-shadow: 0 8px 18px rgba(0,0,0,.2); }
.carte-course.indice { outline: 4px dashed var(--orange); }
.carte-course.cachee { background: linear-gradient(135deg, var(--violet), var(--rose)); color: transparent; }

/* ======================= Créateur de jeux ======================= */
.chrono { font-variant-numeric: tabular-nums; font-weight: 900; font-size: 1.1rem; background: rgba(255,255,255,.2); padding: .3rem .7rem; border-radius: 999px; }
.chrono.pause { background: var(--orange); }
.chrono.fini { background: var(--rouge); }
.editeur fieldset { border: 2px solid var(--bord); border-radius: 14px; padding: .4rem .9rem .9rem; margin: 0 0 1rem; }
.editeur legend { font-weight: 900; padding: 0 .4rem; }
.editeur[data-verrou] input, .editeur[data-verrou] select, .editeur[data-verrou] textarea, .editeur[data-verrou] .pixels { pointer-events: none; opacity: .6; }
.ligne-edit { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; padding: .5rem 0; border-bottom: 2px dashed var(--violet-clair); }
.ligne-edit input[type=text] { flex: 1; min-width: 120px; }
.ligne-edit input[type=number] { width: 80px; }
.ligne-edit select { width: auto; }
.btn-image { min-width: 48px; min-height: 44px; border-radius: 12px; border: 2px solid var(--bord); background: var(--carte); font-size: 1.5rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 2px; }
.img-dessin { display: inline-block; vertical-align: middle; image-rendering: pixelated; }
.palette { display: flex; flex-wrap: wrap; gap: 4px; margin: .5rem 0; }
.palette button { width: 30px; height: 30px; border-radius: 8px; border: 3px solid #fff; box-shadow: 0 0 0 1px #ccc; cursor: pointer; }
.palette button.actif { box-shadow: 0 0 0 3px var(--texte); }
.pixels { display: grid; grid-template-columns: repeat(12, 1fr); width: min(84vw, 300px); border: 2px solid var(--bord); touch-action: none; user-select: none; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 20px 20px; }
.pixels span { aspect-ratio: 1; }
.emojis { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; max-height: 220px; overflow: auto; }
.emojis button { font-size: 1.6rem; border: 0; background: var(--violet-clair); border-radius: 10px; cursor: pointer; min-height: 44px; }
.plateau { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; width: min(94vw, 520px); }
.plateau .case { aspect-ratio: 1; border-radius: 10px; background: var(--carte); box-shadow: var(--ombre); position: relative; display: flex; align-items: center; justify-content: center; font-size: .65rem; font-weight: 800; color: var(--doux); overflow: hidden; }
.plateau .case .num { position: absolute; top: 2px; left: 4px; }
.plateau .case .spe { font-size: 1.2rem; }
.plateau .case .pions { position: absolute; bottom: 1px; right: 2px; font-size: .95rem; display: flex; }
.de { font-size: 2.6rem; display: inline-flex; width: 70px; height: 70px; border-radius: 16px; background: var(--carte); box-shadow: var(--ombre); align-items: center; justify-content: center; font-weight: 900; }
.de.roule { animation: roule .5s; }
@keyframes roule { 50% { transform: rotate(180deg) scale(.8); } }
.laby { display: grid; gap: 0; border: 3px solid var(--texte); width: min(92vw, 440px); background: var(--carte); touch-action: none; }
.laby span { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: clamp(.7rem, 3.4vw, 1.4rem); cursor: pointer; }
.laby span.mur { background: var(--texte); }
.fleches { display: grid; grid-template-columns: repeat(3, 60px); gap: 6px; justify-content: center; }
.fleches button { height: 56px; font-size: 1.5rem; }
.quiz-rep { display: grid; gap: .6rem; width: 100%; max-width: 460px; }
.quiz-rep .btn { justify-content: flex-start; text-align: left; }
.quiz-rep .btn.bonne { background: var(--vert); box-shadow: 0 4px 0 var(--vert-fonce); }
.quiz-rep .btn.fausse { background: var(--rouge); box-shadow: 0 4px 0 #b91c1c; }
.carte-perso { width: 120px; height: 160px; border-radius: 16px; border: 4px solid var(--bord); background: var(--carte); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; font-weight: 900; box-shadow: var(--ombre); }
.carte-perso .val { font-size: 1.6rem; }
.carte-perso .ico { font-size: 2.6rem; }
