/* =============================================================================
   Fun Academy — habillage "kids" (CP/CE1). Couleurs pilotées par le monde
   courant via les variables --accent/--accent-2 (voir applyTheme), donc un autre
   monde (Minecraft, Brawl Stars…) se re-skinne sans toucher au CSS.
   ============================================================================= */
:root {
  --accent: #16a34a; --accent-2: #0ea5e9;
  --ink: #0b1f1a; --muted: #6b7c86; --line: #e7eee9;
  --bg: #eaf6ef; --bg-glow: #c9f7d8; --bg-glow2: #cfecff;
  --hero-from: #15803d; --hero-to: #0ea5e9;
  --gold: #f9a826; --gold-2: #f6c945; --violet: #8b5cf6; --violet-2: #6366f1;
  --r: 22px; --r-lg: 30px; --pill: 999px;
  --teal: var(--accent); /* compat pages légales */
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-size: 17px;
  font-family: ui-rounded, "Baloo 2", "Nunito", "Quicksand", -apple-system, system-ui, "Segoe UI", sans-serif;
  background:
    radial-gradient(750px 480px at 88% -12%, var(--bg-glow) 0, transparent 60%),
    radial-gradient(680px 460px at 8% 8%, var(--bg-glow2) 0, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.container { max-width: 640px; margin: 0 auto; padding: 0 1rem 3rem; }
.center { justify-content: center; text-align: center; }

/* ---- Hero ---- */
.hero { color: #fff; padding: .9rem 1rem 1.6rem;
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  border-radius: 0 0 28px 28px; box-shadow: 0 12px 30px -16px rgba(2,40,20,.5); }
.nav { max-width: 640px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.brand { font-weight: 800; font-size: 1.3rem; letter-spacing: .2px; display: flex; align-items: center; gap: .45rem; }
.brand #brandEmoji { font-size: 1.5rem; filter: drop-shadow(0 2px 3px rgba(0,0,0,.25)); animation: bob 3s ease-in-out infinite; }

/* ---- Cartes & textes ---- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 1.3rem 1.3rem;
  margin-top: 1.1rem; box-shadow: 0 22px 44px -26px rgba(6,78,59,.4); }
.card.cta { text-align: center; margin-top: 1.6rem; }
h2 { margin: 0 0 .7rem; font-size: 1.45rem; font-weight: 800; }
h3 { font-size: 1.15rem; font-weight: 800; }
.muted { color: var(--muted); font-weight: 600; font-size: .9rem; }
.big-emoji { font-size: 4rem; line-height: 1; animation: pop .5s ease; }
label { display: block; margin: .8rem 0 .2rem; font-weight: 700; font-size: .95rem; }
input, select { width: 100%; margin-top: .25rem; padding: .85rem .9rem; border: 2px solid var(--line);
  border-radius: 14px; font: inherit; font-weight: 600; background: #fff; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
.row { display: flex; align-items: center; gap: .7rem; margin-top: 1.1rem; flex-wrap: wrap; }
.row.center { justify-content: center; }

/* ---- Boutons "candy" (relief, rebond au clic) ---- */
button { font: inherit; cursor: pointer; border: 0; }
.btn-primary, .btn-ghost {
  font-weight: 800; border-radius: 16px; padding: .8rem 1.3rem; transition: transform .08s, box-shadow .08s;
}
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 0 color-mix(in srgb, var(--accent) 70%, #000), 0 14px 24px -10px var(--accent); }
.btn-primary:active { transform: translateY(5px); box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 70%, #000); }
.btn-ghost { background: #fff; color: var(--ink); box-shadow: 0 5px 0 var(--line); border: 2px solid var(--line); }
.btn-ghost:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.btn-primary:disabled { opacity: .5; box-shadow: none; cursor: not-allowed; }
.btn-back { background: #fff; width: 2.8rem; height: 2.8rem; border-radius: 16px; font-size: 1.2rem; font-weight: 800;
  box-shadow: 0 4px 0 var(--line); transition: transform .08s; }
.btn-back:active { transform: translateY(3px); }
.pill { background: rgba(255,255,255,.22); padding: .25rem .7rem; border-radius: var(--pill); font-size: .8rem; font-weight: 700; }

.screen-head { display: flex; align-items: center; gap: .7rem; margin: 1.3rem 0 .3rem; }
.screen-head h2 { margin: 0; }

/* ---- Mascotte + bulle (accueil) ---- */
.greet { display: flex; align-items: center; gap: .9rem; margin: 1rem 0 .4rem; }
.greet .mascot { font-size: 3.4rem; line-height: 1; animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 6px 6px rgba(0,0,0,.15)); }
.greet .bubble { position: relative; background: #fff; border: 2px solid var(--line); border-radius: 18px;
  padding: .7rem 1rem; font-weight: 700; box-shadow: 0 10px 24px -16px rgba(0,0,0,.4); }
.greet .bubble::before { content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  border: 8px solid transparent; border-right-color: #fff; }

/* ---- Profils ---- */
.profile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-top: 1.1rem; }
.profile-tile { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: 1.4rem .7rem; background: #fff;
  border: 2px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 8px 0 var(--line), 0 22px 40px -26px rgba(6,78,59,.4);
  transition: transform .1s, box-shadow .1s; }
.profile-tile:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--line); }
.profile-tile.add { border-style: dashed; color: var(--muted); justify-content: center; box-shadow: 0 8px 0 var(--line); }
.pt-avatar { font-size: 3rem; filter: drop-shadow(0 4px 5px rgba(0,0,0,.12)); }
.pt-name { font-weight: 800; font-size: 1.15rem; }
.pt-meta { font-size: .8rem; color: var(--muted); font-weight: 600; }
.parent-line { text-align: center; margin-top: 1.6rem; font-size: .9rem; font-weight: 600; }
.parent-line a { color: var(--accent); }

.avatar-pick { display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; margin: .4rem 0; }
.ava { font-size: 1.7rem; padding: .45rem 0; border: 2px solid var(--line); border-radius: 14px; background: #fff; transition: transform .08s; }
.ava:active { transform: scale(.9); }
.ava.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, #fff); transform: scale(1.05); }

/* ---- Accueil : stats + grandes actions ---- */
.stat-row { display: flex; gap: .7rem; margin: 1rem 0 .2rem; }
.stat { flex: 1; background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: .8rem .4rem; text-align: center;
  box-shadow: 0 10px 22px -18px rgba(6,78,59,.5); }
.stat b { display: block; font-size: 1.2rem; font-weight: 800; }
.stat span { font-size: .72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }

.big-action { display: flex; flex-direction: column; align-items: center; gap: .15rem; width: 100%; border: 0;
  border-radius: var(--r-lg); padding: 1.15rem; font-size: 1.35rem; font-weight: 800; color: #fff; margin-top: 1rem;
  transition: transform .1s, box-shadow .1s; }
.big-action small { font-weight: 700; font-size: .8rem; opacity: .95; }
.big-action:active { transform: translateY(7px) !important; }
.act-play { font-size: 1.8rem; padding: 1.6rem 1rem; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 9px 0 color-mix(in srgb, var(--accent) 68%, #000), 0 22px 40px -14px var(--accent); }
.act-play:active { box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 68%, #000); }
.act-play .ico { animation: bob 1.6s ease-in-out infinite; display: inline-block; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.row2 .big-action { margin-top: 0; }
.act-chest { background: linear-gradient(135deg, var(--gold), var(--gold-2)); box-shadow: 0 8px 0 #c9831a, 0 20px 34px -16px var(--gold); }
.act-chest:active { box-shadow: 0 2px 0 #c9831a; }
.act-album { background: linear-gradient(135deg, var(--violet-2), var(--violet)); box-shadow: 0 8px 0 #4f46c4, 0 20px 34px -16px var(--violet); }
.act-album:active { box-shadow: 0 2px 0 #4f46c4; }
.big-action.dim { background: #d3dde2; color: #fff; box-shadow: 0 8px 0 #b9c5cc; }
.big-action.dim:active { box-shadow: 0 2px 0 #b9c5cc; }

/* ---- Jeu ---- */
.play-bar { position: relative; height: 16px; background: #fff; border: 2px solid var(--line); border-radius: var(--pill);
  margin: 1.3rem 0 .5rem; overflow: visible; }
.play-fill { height: 100%; border-radius: var(--pill); background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .35s cubic-bezier(.2,.8,.3,1.2); position: relative; }
.play-fill::after { content: "⚽"; position: absolute; right: -10px; top: 50%; transform: translateY(-52%); font-size: 1.3rem; }
.play-meta { display: flex; justify-content: space-between; font-size: .9rem; color: var(--muted); font-weight: 800; }
.q-card { background: #fff; border: 2px solid var(--line); border-radius: var(--r-lg); padding: 1.6rem 1.2rem; margin-top: .5rem;
  text-align: center; box-shadow: 0 26px 50px -28px rgba(6,78,59,.5); animation: pop .35s ease; }
.q-card.shake { animation: shake .4s; }
.q-prompt { font-size: 2.3rem; font-weight: 800; margin: .5rem 0 1.2rem; }
.count-grid { font-size: 2rem; line-height: 1.45; word-break: break-word; }
.word-blank { font-size: 2.6rem; font-weight: 800; letter-spacing: .12em; }
.word-blank .blank { color: var(--accent); }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; }
.choice { font-size: 1.7rem; font-weight: 800; padding: 1.1rem; border: 2px solid var(--line); border-radius: 18px; background: #fff;
  box-shadow: 0 6px 0 var(--line); transition: transform .08s, box-shadow .08s; }
.choice:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--line); }
.choice.good { border-color: #15a34a; background: #d8f9e3; box-shadow: 0 6px 0 #9fe2b8; color: #0a7d36; animation: pop .35s ease; }
.choice.bad { border-color: #ef4444; background: #fde2e2; box-shadow: 0 6px 0 #f3b4b4; color: #c81e1e; }
.feedback { text-align: center; min-height: 2.2rem; margin-top: 1.1rem; font-weight: 800; font-size: 1.2rem; }
.fb-ok { color: #15a34a; } .fb-no { color: #c81e1e; font-size: 1.05rem; }

/* ---- Résultat ---- */
.result .score { font-size: 1.7rem; font-weight: 800; margin: .2rem 0; }

/* ---- Coffre / révélation ---- */
.chest-reveal { --r: #94a3b8; --rg: #cbd5e1; }
.reveal-badge { display: inline-block; background: var(--r); color: #fff; font-weight: 800; padding: .3rem 1rem;
  border-radius: var(--pill); font-size: .9rem; box-shadow: 0 5px 0 color-mix(in srgb, var(--r) 70%, #000); }
.reveal-card { margin: 1.2rem auto; width: 200px; padding: 1.6rem 1rem; border-radius: var(--r-lg); border: 4px solid var(--r);
  background: radial-gradient(140px 140px at 50% 28%, var(--rg), #fff); box-shadow: 0 0 50px -4px var(--rg); animation: reveal .5s cubic-bezier(.2,.9,.3,1.4); }
.rc-emoji { font-size: 3.4rem; } .rc-name { font-weight: 800; font-size: 1.3rem; margin-top: .3rem; } .rc-group { color: var(--muted); font-size: .9rem; font-weight: 700; }

/* ---- Album ---- */
.album-group { margin: 1.5rem 0 .5rem; }
.album-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.album-card { --r: #94a3b8; --rg: #cbd5e1; position: relative; text-align: center; padding: 1rem .4rem; border-radius: 18px;
  border: 2.5px solid var(--r); background: linear-gradient(160deg, color-mix(in srgb, var(--rg) 50%, #fff), #fff);
  box-shadow: 0 8px 20px -14px var(--r); }
.album-card.owned { animation: pop .3s ease; }
.album-card.locked { border-color: #e2e8f0; background: #eef2f5; color: #aab6bf; box-shadow: none; }
.ac-emoji { font-size: 2.1rem; } .ac-name { font-weight: 800; font-size: .82rem; margin-top: .2rem; }
.ac-rar { font-size: .65rem; color: var(--muted); margin-top: .15rem; font-weight: 700; }
.album-card.locked .ac-rar { visibility: hidden; }
.ac-dup { position: absolute; top: .35rem; right: .45rem; background: var(--r); color: #fff; font-size: .72rem; font-weight: 800; padding: .08rem .45rem; border-radius: var(--pill); }
@media (min-width: 560px) { .album-grid { grid-template-columns: repeat(4, 1fr); } }

/* ---- Confettis (DOM, légers) ---- */
.confetti-piece { position: fixed; top: 0; left: 0; width: 11px; height: 11px; border-radius: 2px; pointer-events: none; z-index: 9999;
  animation: confetti 1s ease-out forwards; }

/* ---- Footer + pages légales ---- */
.footer { text-align: center; color: var(--muted); font-size: .9rem; padding: 1.6rem; font-weight: 600; }
.footer-links { display: block; margin-top: .4rem; }
.footer-links a { color: var(--accent); text-decoration: none; }
.legal { max-width: 760px; margin: 2rem auto; padding: 0 1.25rem 3rem; }
.legal a { color: var(--accent); }
.legal .back { display: inline-block; margin-bottom: 1rem; color: var(--accent); text-decoration: none; font-weight: 700; }

/* ---- Animations ---- */
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes pop { 0% { transform: scale(.7); opacity: 0; } 70% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }
@keyframes reveal { 0% { transform: scale(.4) rotate(-8deg); opacity: 0; } 60% { transform: scale(1.12) rotate(3deg); } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-9px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
@keyframes confetti { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ===================== v2 : menu, niveau, jeux, quêtes, trophées ============ */
.sec { margin: 1.4rem 0 .2rem; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* Carte "niveau de joueur" + barre d'XP */
.level-card { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-radius: var(--r);
  padding: .9rem 1.1rem; margin-top: 1rem; box-shadow: 0 16px 30px -18px var(--accent); }
.lc-top { display: flex; justify-content: space-between; font-weight: 800; font-size: 1.05rem; }
.lc-sub { font-size: .75rem; opacity: .92; margin-top: .35rem; font-weight: 700; }
.xp-bar { height: 12px; background: rgba(255,255,255,.3); border-radius: 999px; margin-top: .5rem; overflow: hidden; }
.xp-fill { height: 100%; background: #fff; border-radius: 999px; transition: width .5s; }

/* Grille de tuiles (matières / jeux / récompenses) */
.tile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin-top: .5rem; }
.tile { --c: var(--accent); position: relative; display: flex; flex-direction: column; align-items: center; gap: .35rem;
  padding: 1.1rem .4rem; background: #fff; border: 2px solid var(--line); border-radius: 20px;
  box-shadow: 0 6px 0 var(--line); transition: transform .09s, box-shadow .09s; }
.tile:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--line); }
.tile.locked { opacity: .55; }
.tile-ico { font-size: 2rem; filter: drop-shadow(0 3px 3px rgba(0,0,0,.12)); }
.tile-lbl { font-weight: 800; font-size: .85rem; text-align: center; color: var(--ink); }
.tile .badge { display: inline-block; min-width: 1.2rem; margin-left: .2rem; background: #ef4444; color: #fff;
  border-radius: 999px; font-size: .72rem; padding: 0 .35rem; }
.tile.subj .tile-lbl { color: var(--c); }
@media (max-width: 380px) { .tile-grid { grid-template-columns: repeat(2, 1fr); } }

.flame { color: #f97316; }
.story { background: #f6faf8; border-left: 4px solid var(--accent); border-radius: 0 12px 12px 0; padding: .8rem 1rem;
  text-align: left; font-weight: 600; font-size: 1.05rem; margin-bottom: .4rem; }

/* Toast (niveau / trophée) */
.toast { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 10000; background: #fff;
  border: 2px solid var(--line); border-radius: 18px; padding: .9rem 1.3rem; text-align: center; font-weight: 800;
  box-shadow: 0 24px 50px -20px rgba(0,0,0,.4); animation: pop .35s ease; }
.toast.out { animation: fadeup .5s forwards; }
.toast .t-big { font-size: 1.4rem; } .toast .t-ico { font-size: 2rem; }
@keyframes fadeup { to { opacity: 0; transform: translate(-50%, -20px); } }

/* Quêtes */
.quest-list { display: flex; flex-direction: column; gap: .7rem; margin-top: 1rem; }
.quest { display: flex; align-items: center; gap: .8rem; background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: .8rem; }
.quest.ready { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 25%, #fff); }
.quest.claimed { opacity: .6; }
.q-ico { font-size: 1.8rem; } .q-mid { flex: 1; } .q-lbl { font-weight: 800; font-size: .95rem; }
.q-bar { height: 9px; background: #eef2f5; border-radius: 999px; margin: .3rem 0; overflow: hidden; }
.q-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; }
.q-num { font-size: .75rem; color: var(--muted); font-weight: 700; }
.q-state { font-weight: 800; color: var(--muted); } .q-claim { padding: .5rem .8rem; }

/* Route des trophées */
.trophy-road { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin-top: 1rem; }
.trophy { text-align: center; padding: 1rem .4rem; border-radius: 18px; border: 2px solid var(--line); background: #fff; }
.trophy.on { border-color: var(--gold); background: linear-gradient(160deg, #fff7e6, #fff); box-shadow: 0 8px 20px -14px var(--gold); }
.trophy.off { opacity: .6; } .tr-ico { font-size: 2rem; display: block; } .tr-lbl { font-size: .78rem; font-weight: 800; margin-top: .25rem; display: block; }

/* Minijeux */
.game-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; color: var(--muted); margin: 1.2rem 0 .5rem; }
.goal-scene { font-size: 2.4rem; position: relative; margin-bottom: .4rem; }
.goal-scene .ball { transition: transform .5s; display: inline-block; } .goal-scene .ball.scored { transform: translateY(-14px) scale(1.2); }
.blitz-bar { height: 12px; background: #eef2f5; border-radius: 999px; overflow: hidden; margin: 1.1rem 0 .3rem; }
.blitz-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #f97316, #ef4444); transition: width .25s linear; }
.mem-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-top: .6rem; }
.mem-card { aspect-ratio: 1; font-size: 1.9rem; border: 2px solid var(--line); border-radius: 16px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: transparent;
  box-shadow: 0 5px 0 var(--line); transition: transform .1s; }
.mem-card.up { background: #fff; color: inherit; } .mem-card.done { background: #d8f9e3; border-color: #9fe2b8; box-shadow: none; }
.mem-card:active { transform: translateY(3px); }

.btn-ghost.danger { color: #c81e1e; border-color: #f3b4b4; box-shadow: 0 5px 0 #f3b4b4; }

/* ===================== Responsive ========================================== */
html { overflow-x: hidden; }
body { overflow-x: hidden; min-height: 100svh; }
/* encoches / safe-areas (iPhone, Android gestes) */
@supports (padding: max(0px)) {
  .hero { padding-top: max(.9rem, env(safe-area-inset-top)); padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
  .container { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); padding-bottom: max(3rem, env(safe-area-inset-bottom)); }
}
/* typographie fluide */
.brand { font-size: clamp(1.1rem, 4.6vw, 1.45rem); }
h2 { font-size: clamp(1.25rem, 5.2vw, 1.6rem); }
.q-prompt { font-size: clamp(1.55rem, 7vw, 2.4rem); }
.act-play { font-size: clamp(1.4rem, 6vw, 1.9rem); }
.choice { font-size: clamp(1.2rem, 5.2vw, 1.7rem); }
/* anti-débordement (mots longs, grands nombres) */
.q-prompt, .tile-lbl, .q-lbl, .pt-name, .rc-name { overflow-wrap: anywhere; }
/* tablette / desktop : on élargit la colonne et on aère les grilles */
@media (min-width: 700px) {
  .container, .nav { max-width: 760px; }
  .mem-grid { max-width: 560px; margin-inline: auto; }
}
@media (min-width: 960px) {
  .container, .nav { max-width: 880px; }
  .tile-grid { grid-template-columns: repeat(4, 1fr); }
  .choices { max-width: 680px; margin-inline: auto; }
}
/* paysage court (téléphone couché) : on compacte le vertical */
@media (max-height: 500px) and (orientation: landscape) {
  .hero { padding: .5rem 1rem .7rem; border-radius: 0 0 18px 18px; }
  .greet, .level-card, .big-action { margin-top: .6rem; }
  .q-card { padding: 1rem; } .q-prompt { margin: .3rem 0 .7rem; }
  .big-emoji { font-size: 2.6rem; }
}
