/* ==========================================================================
   Polices (hébergées sur le serveur)
   ========================================================================== */
@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/fredoka-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/fredoka-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ==========================================================================
   Variables
   ========================================================================== */
:root {
  --ink: #2b2a4c;
  --ink-soft: #5f5d86;
  --paper: #ffffff;
  --violet: #7c4dff;
  --violet-dark: #5a32d6;
  --pink: #ff6fa5;
  --pink-dark: #d94a85;
  --sun: #ffd23f;
  --sun-dark: #e0a800;
  --mint: #2fcf8c;
  --mint-dark: #1ba56d;
  --sky: #3fa7ff;
  --sky-dark: #1f7fd6;
  --coral: #ff5d73;
  --coral-dark: #d63a50;
  --line: #e4e0f5;
  --radius: 24px;
  --shadow: 0 6px 0 rgba(43, 42, 76, 0.08), 0 14px 30px rgba(43, 42, 76, 0.1);
  --font-kid: "Fredoka", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --font-admin: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-kid);
  font-size: 18px;
  line-height: 1.4;
  background: #eef2fb;
  min-height: 100vh;
  min-height: 100dvh;
}
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 4px solid #ffb300; outline-offset: 3px; border-radius: 12px; }
.center { text-align: center; }
.big { font-size: 1.15em; }
.small { font-size: 0.85em; color: var(--ink-soft); }
h1, h2, h3 { line-height: 1.15; margin-top: 0; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }
hr { border: 0; border-top: 2px dashed var(--line); margin: 20px 0; }

/* ==========================================================================
   Thèmes : connexion / enfant / parents
   ========================================================================== */
body.theme-child,
body.theme-login {
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.9) 0 60px, transparent 61px),
    radial-gradient(circle at 18% 9%, rgba(255, 255, 255, 0.9) 0 44px, transparent 45px),
    radial-gradient(circle at 86% 16%, rgba(255, 255, 255, 0.85) 0 52px, transparent 53px),
    radial-gradient(circle at 92% 17%, rgba(255, 255, 255, 0.85) 0 36px, transparent 37px),
    linear-gradient(180deg, #8fd3ff 0%, #c9ecff 38%, #fff4d6 100%);
  background-attachment: fixed;
}
body.theme-admin {
  font-family: var(--font-admin);
  font-size: 16px;
  background: #eef2fb;
}

/* ==========================================================================
   En-tête
   ========================================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  max-width: 1000px;
  margin: 0 auto;
}
.brand h1 { margin: 0; font-size: clamp(1.3rem, 5vw, 1.9rem); }
.brand p { margin: 2px 0 0; color: var(--ink-soft); font-size: 0.95rem; }
.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.balance-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  font-size: 1.25rem;
  box-shadow: 0 4px 0 rgba(43, 42, 76, 0.1);
}
.balance-pill .label { font-size: 0.8rem; font-weight: 500; color: var(--ink-soft); }
.icon-btn {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--paper);
  font-size: 1.4rem;
  box-shadow: 0 4px 0 rgba(43, 42, 76, 0.1);
}
.who { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--ink-soft); }
.theme-child .admin-only { display: none !important; }
.theme-admin .child-only { display: none !important; }
.theme-admin .topbar { background: linear-gradient(135deg, #10264b, #214d89); max-width: none; color: #fff; }
.theme-admin .brand p, .theme-admin .who { color: rgba(255, 255, 255, 0.85); }
.theme-admin .brand, .theme-admin .top-right { max-width: 1000px; }

/* ==========================================================================
   Navigation
   ========================================================================== */
#navigation button {
  border: 0;
  background: none;
  color: inherit;
}
#navigation .ico { display: block; font-size: 1.7rem; line-height: 1; }

/* Enfant : grande barre en bas */
.theme-child #navigation {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  box-shadow: 0 -8px 24px rgba(43, 42, 76, 0.12);
}
.theme-child #navigation button {
  flex: 1 1 0;
  max-width: 110px;
  min-height: 64px;
  padding: 6px 4px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.theme-child #navigation button.active {
  background: linear-gradient(180deg, #efe8ff, #e0d4ff);
  color: var(--violet-dark);
}
.theme-child #navigation .nav-account { display: none; }

/* Parents : onglets en haut */
.theme-admin #navigation {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 10px;
  background: #dce6f5;
}
.theme-admin #navigation button {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 12px;
  background: #10264b;
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
}
.theme-admin #navigation .ico { display: inline; font-size: 1.1rem; }
.theme-admin #navigation button.active,
.theme-admin #navigation button:hover { background: #386bb0; }

/* ==========================================================================
   Contenu
   ========================================================================== */
main { max-width: 1000px; margin: 0 auto; padding: 8px 16px 32px; }
main.narrow { max-width: 460px; }
.theme-child main { padding-bottom: 130px; }

.panel {
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.theme-admin .panel { border-radius: 16px; box-shadow: 0 4px 16px #10264b14; }
.theme-admin h2, .theme-admin h3 { color: #10264b; }

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 10px 22px;
  margin: 4px;
  border: 0;
  border-radius: 20px;
  background: var(--violet);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  box-shadow: 0 5px 0 var(--violet-dark);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--violet-dark); }
.btn.secondary { background: #ece8fb; color: var(--violet-dark); box-shadow: 0 5px 0 #cfc7f0; }
.btn.green { background: var(--mint); box-shadow: 0 5px 0 var(--mint-dark); }
.btn.red { background: var(--coral); box-shadow: 0 5px 0 var(--coral-dark); }
.btn.gold { background: var(--sun); color: var(--ink); box-shadow: 0 5px 0 var(--sun-dark); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; filter: grayscale(0.2); }
.btn.small { min-height: 44px; padding: 6px 14px; font-size: 0.9rem; }
.theme-admin .btn { min-height: 44px; border-radius: 12px; font-size: 0.95rem; box-shadow: 0 3px 0 var(--violet-dark); }
.theme-admin .btn.secondary { box-shadow: 0 3px 0 #cfc7f0; }
.theme-admin .btn.green { box-shadow: 0 3px 0 var(--mint-dark); }
.theme-admin .btn.red { box-shadow: 0 3px 0 var(--coral-dark); }
.theme-admin .topbar .btn.secondary { background: rgba(255, 255, 255, 0.18); color: #fff; box-shadow: none; }

/* Formulaires */
input, select, textarea {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  margin: 6px 0 14px;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #fff;
  font-size: 1rem;
}
input:focus, select:focus { border-color: var(--violet); outline: none; box-shadow: 0 0 0 4px rgba(124, 77, 255, 0.2); }
label { display: block; font-weight: 600; margin-top: 8px; }
.inline-check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 400; }
.inline-check input { width: 24px; height: 24px; min-height: 0; margin: 0; }
.theme-admin input, .theme-admin select { min-height: 44px; border-width: 1px; border-color: #bdcbe0; border-radius: 9px; }

.notice { padding: 12px 16px; border-radius: 16px; background: #e8f0ff; margin: 10px 0; }
.notice.success { background: #d9f7e8; }
.notice.error { background: #ffe3e3; }

.badge { display: inline-block; font-size: 0.75rem; padding: 2px 10px; border-radius: 10px; background: #e2eaf7; color: #193b70; margin-left: 6px; font-weight: 600; }
.badge.off { background: #ffe0e0; color: #a52e3b; }

/* Listes et cartes */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.card {
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  text-align: center;
}
.card .emoji { font-size: 3rem; line-height: 1; margin-bottom: 8px; }
.card h3 { margin-bottom: 6px; }
.task {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 20px;
  padding: 14px 16px;
  margin: 10px 0;
}
.theme-admin .task { border-width: 1px; border-radius: 12px; background: #f7f9fe; }
.task-main { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 220px; }
.task-emoji { font-size: 2.2rem; flex: none; }
.task-title { font-weight: 600; font-size: 1.1rem; }
.stars { color: #b07a00; font-weight: 700; white-space: nowrap; }
.task-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Grandes tuiles de choix */
.category-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(98px, 1fr)); gap: 12px; }
.tile-grid .category-button { min-height: 110px; padding: 10px 6px; font-size: 1rem; }
.category-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 120px;
  padding: 14px;
  border: 0;
  border-radius: 24px;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  background: var(--violet);
  box-shadow: 0 7px 0 var(--violet-dark);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.category-button:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--violet-dark); }
/* L'icône est posée sur une pastille blanche : elle reste lisible quelle que soit la couleur de la tuile */
.category-button span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 -4px 0 rgba(43, 42, 76, 0.08);
  font-size: 2.2rem;
  line-height: 1;
}
.category-button.tone-sun { background: #ffb938; box-shadow: 0 7px 0 #d98e00; color: var(--ink); }
.category-button.tone-pink { background: var(--pink); box-shadow: 0 7px 0 var(--pink-dark); }
.category-button.tone-mint { background: var(--mint); box-shadow: 0 7px 0 var(--mint-dark); }
.category-button.tone-sky { background: var(--sky); box-shadow: 0 7px 0 var(--sky-dark); }
.category-button.tone-coral { background: var(--coral); box-shadow: 0 7px 0 var(--coral-dark); }

/* ==========================================================================
   Accueil : compagnon
   ========================================================================== */
.hero {
  position: relative;
  text-align: center;
  padding: 18px 16px 22px;
  margin-bottom: 18px;
  border-radius: 32px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.9));
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -40px;
  height: 120px;
  /* sol neutre (lavande) : il ne se confond avec aucune couleur de compagnon */
  background: radial-gradient(ellipse at center, #ece8fb 0%, #d9d2f4 60%, transparent 62%);
  z-index: 0;
}
.hero > * { position: relative; z-index: 1; }
.bubble {
  position: relative;
  display: inline-block;
  max-width: 92%;
  padding: 12px 18px;
  margin-bottom: 14px;
  border-radius: 22px;
  background: #fff;
  border: 3px solid var(--line);
  font-weight: 600;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -14px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-right: 3px solid var(--line);
  border-bottom: 3px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}
.companion-btn {
  display: block;
  width: min(300px, 70vw);
  margin: 6px auto 0;
  padding: 0;
  border: 0;
  background: none;
}
.companion-btn svg, .companion-art svg { display: block; width: 100%; height: auto; overflow: visible; }
.hearts { position: absolute; left: 0; right: 0; top: 30%; height: 0; pointer-events: none; z-index: 3; }
.heart { position: absolute; font-size: 1.8rem; animation: heart-up 1.4s ease-out forwards; }
.nameplate {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
  padding: 6px 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 0 rgba(43, 42, 76, 0.1);
  font-weight: 700;
}
.nameplate .lvl { background: var(--sun); color: var(--ink); border-radius: 999px; padding: 2px 12px; }
.nameplate .stage { color: var(--ink-soft); font-weight: 500; font-size: 0.9rem; }
.xp { max-width: 420px; margin: 14px auto 0; }
.xp-bar { height: 26px; border-radius: 999px; background: #e9e4fb; overflow: hidden; box-shadow: inset 0 3px 0 rgba(43, 42, 76, 0.08); }
.xp-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--mint), #7ae582); transition: width 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.xp-text { margin-top: 6px; font-weight: 600; color: var(--ink-soft); font-size: 0.95rem; }

/* Compagnon : couleurs et pièces du dessin */
.sp-bulbizarre { --c: #79d2b8; --c2: #c4f0e3; --cd: #3da58c; }
.sp-bulbizarre.f1 { --c: #6ec9b2; --cd: #35957f; }
.sp-bulbizarre.f2 { --c: #63c0a8; --cd: #2e8a74; }
.sp-salameche { --c: #ff9d4d; --c2: #ffe6a8; --cd: #e0721f; }
.sp-salameche.f1 { --c: #ee5f46; --c2: #ffe0a0; --cd: #c53b2a; }
.sp-salameche.f2 { --c: #ff8b3a; --c2: #ffe3a0; --cd: #d8661a; }
.sp-carapuce { --c: #6ec6f5; --c2: #fff0b8; --cd: #3b8fd0; }
.sp-carapuce.f1 { --c: #5db3ec; --cd: #2f7fc0; }
.sp-carapuce.f2 { --c: #4c9fe0; --cd: #2a70b0; }
.pet-body { fill: var(--c); }
.pet-belly { fill: var(--c2); }
.pet-shade { fill: var(--cd); }
.pet-gold { fill: #ffd23f; stroke: #e0a800; stroke-width: 3; stroke-linejoin: round; }
.pet-cape { fill: #ff5d73; }
.pet-white { fill: #fff; }
.pet-ink { fill: #2b2a4c; }
.pet-line { fill: none; stroke: #2b2a4c; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.pet-cheek { fill: #ff8fa8; opacity: 0.7; }
.pet-mouth { fill: #7a2d3f; }
.pet-tongue { fill: #ff8fa8; }
.pet-crack { fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.pet-shadow { fill: rgba(43, 42, 76, 0.14); }
.p-green { fill: #59c76b; }
.p-green-d { fill: #2f9a47; }
.p-line-g { fill: none; stroke: #2a8a41; stroke-width: 4; stroke-linecap: round; }
.p-pink { fill: #ff7aa8; }
.p-pink-d { fill: #e0527f; }
.p-cream { fill: #fff0c2; }
.p-red { fill: #e8404f; }
.p-iris-b { fill: #2a5fa8; }
.p-brown { fill: #c78a45; }
.p-brown-d { fill: #8a5a24; }
.p-line-b { fill: none; stroke: #cfa55c; stroke-width: 3; stroke-linecap: round; }
.p-white { fill: #fff; stroke: #cfe6f7; stroke-width: 3; }
.p-white-l { fill: none; stroke: #bcd9f2; stroke-width: 4; stroke-linecap: round; }
.p-white-r { fill: none; stroke: #fff6dc; stroke-width: 8; }
.p-gray { fill: #9aa7b5; }
.p-gray-d { fill: #6b7785; }
.p-horn { fill: #f4e6c8; stroke: #d9c7a0; stroke-width: 2; stroke-linejoin: round; }
.p-claw { fill: #fff7e0; }
.p-wing-o { fill: #ff8b3a; stroke: #d8661a; stroke-width: 3; stroke-linejoin: round; }
.p-wing-i { fill: #4cc2c0; }
.p-flame-o { fill: #ff6a2b; }
.p-flame-m { fill: #ffb52e; }
.p-flame-i { fill: #fff1a0; }
.flame { transform-box: fill-box; transform-origin: 50% 100%; animation: flame 0.9s ease-in-out infinite; }
@keyframes flame { 0%, 100% { transform: scale(1, 1) skewX(0deg); } 50% { transform: scale(1.1, 0.92) skewX(4deg); } }

/* Choix du starter */
.modal.wide { width: min(560px, 100%); }
.starter-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 14px; }
.starter-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 10px;
  border: 4px solid var(--line);
  border-radius: 22px;
  background: #fff;
  font-size: 0.95rem;
}
.starter-card .companion-art { width: 100%; }
.starter-card small { color: var(--ink-soft); }
.starter-card[aria-pressed="true"] { border-color: var(--violet); background: #f4efff; transform: translateY(-3px); box-shadow: 0 6px 0 rgba(124, 77, 255, 0.25); }
.starters { display: flex; justify-content: center; gap: 2px; margin-bottom: 8px; }
.starters .starter { width: 33%; max-width: 130px; }
.starters .starter svg { display: block; width: 100%; height: auto; overflow: visible; }
.pet-zzz { font-family: var(--font-kid); font-weight: 700; font-size: 26px; fill: #5f5d86; animation: zzz 2.4s ease-in-out infinite; }
.pet-twinkle { fill: #fff3a3; transform-box: fill-box; transform-origin: center; animation: twinkle 1.6s ease-in-out infinite; }
.pet-twinkle.t2 { animation-delay: 0.5s; }
.pet-twinkle.t3 { animation-delay: 1s; }

.pet-wrap { transform-box: fill-box; transform-origin: 50% 90%; animation: bob 3s ease-in-out infinite; }
.mood-sleepy .pet-wrap { animation: breathe 4s ease-in-out infinite; }
.mood-hungry .pet-wrap { animation: droop 3.5s ease-in-out infinite; }
.pet-wrap.cheer { animation: cheer 0.9s ease-out; }
.pet-wrap.wobble { animation: wobble 2.4s ease-in-out infinite; }

@keyframes bob { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-8px) scale(1.02, 0.98); } }
@keyframes breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.03, 0.97); } }
@keyframes droop { 0%, 100% { transform: translateY(2px) scale(1, 0.97); } 50% { transform: translateY(4px) scale(1.01, 0.95); } }
@keyframes wobble { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes cheer { 0% { transform: translateY(0) scale(1); } 30% { transform: translateY(-26px) scale(1.06, 0.94) rotate(-4deg); } 55% { transform: translateY(0) scale(0.96, 1.04); } 75% { transform: translateY(-12px) rotate(4deg); } 100% { transform: translateY(0) scale(1); } }
@keyframes heart-up { 0% { opacity: 0; transform: translateY(0) scale(0.6); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-120px) scale(1.2); } }
@keyframes zzz { 0%, 100% { opacity: 0.2; transform: translateY(6px); } 50% { opacity: 1; transform: translateY(-6px); } }
@keyframes twinkle { 0%, 100% { opacity: 0.2; transform: scale(0.5); } 50% { opacity: 1; transform: scale(1.1); } }

/* ==========================================================================
   Fenêtres (adoption, niveau gagné) et notifications
   ========================================================================== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(43, 42, 76, 0.55);
  overflow-y: auto;
}
.modal {
  width: min(480px, 100%);
  padding: 26px 22px;
  border-radius: 32px;
  background: #fff;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.modal h2 { font-size: 1.9rem; }
.modal .companion-art { width: min(240px, 60vw); margin: 0 auto; }
.color-picker { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 16px; }
.color-dot {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 5px solid #fff;
  box-shadow: 0 0 0 3px var(--line);
}
.color-dot[aria-pressed="true"] { box-shadow: 0 0 0 5px var(--violet); transform: scale(1.1); }
.color-dot.c-violet { background: #a07bff; }
.color-dot.c-bleu { background: #5bb6ff; }
.color-dot.c-vert { background: #4fd69a; }
.color-dot.c-orange { background: #ffa24d; }
.color-dot.c-rose { background: #ff86b6; }
.color-dot.c-jaune { background: #ffd43f; }
.modal input { text-align: center; font-size: 1.3rem; font-weight: 600; }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.confetti { position: fixed; top: -20px; width: 12px; height: 18px; z-index: 60; pointer-events: none; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { to { transform: translateY(110vh) rotate(720deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  z-index: 70;
  max-width: min(92vw, 460px);
  padding: 14px 22px;
  border-radius: 20px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transform: translateX(-50%);
  animation: toast-in 0.3s ease-out;
}
.toast.error { background: var(--coral-dark); }
.theme-admin .toast { bottom: 24px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ==========================================================================
   Jeux
   ========================================================================== */
.subject-card { text-align: center; padding: 22px 14px; background: #fff; border: 3px solid var(--line); border-radius: 24px; }
.subject-card .emoji { font-size: 3.2rem; line-height: 1.1; }
.subject-card h3 { margin: 6px 0; }
.question-number { color: var(--ink-soft); font-weight: 600; }
.question-title { font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 700; margin: 18px 0; }
.answer-grid { display: grid; gap: 12px; max-width: 520px; margin: 18px auto; }
.answer-button {
  min-height: 64px;
  padding: 14px 18px;
  border: 3px solid var(--line);
  border-radius: 20px;
  background: #fff;
  font-weight: 700;
  font-size: 1.2rem;
  text-align: left;
  box-shadow: 0 5px 0 var(--line);
}
.answer-button:hover:not(:disabled) { border-color: var(--violet); background: #f4efff; }
.answer-button:disabled { cursor: default; }
.answer-button.correct { background: #d9f7e8; border-color: var(--mint-dark); box-shadow: 0 5px 0 var(--mint-dark); }
.answer-button.wrong { background: #ffe3e3; border-color: var(--coral-dark); box-shadow: 0 5px 0 var(--coral-dark); }
.score-circle {
  width: 160px;
  height: 160px;
  margin: 20px auto;
  border: 8px solid var(--sun);
  border-radius: 50%;
  background: #fff8dc;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.score-circle strong { font-size: 2.4rem; }
.score-circle span { font-size: 0.9rem; color: var(--ink-soft); }

footer { text-align: center; color: var(--ink-soft); padding: 14px; font-size: 0.8rem; }
.theme-child footer { display: none; }

/* ==========================================================================
   Petits écrans / accessibilité
   ========================================================================== */
@media (max-width: 520px) {
  body { font-size: 17px; }
  .panel { padding: 16px; }
  .theme-child #navigation button { font-size: 0.72rem; }
  .theme-admin #navigation button { flex: 1 1 40%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Images officielles des compagnons */
.pet-art { position: relative; width: 100%; isolation: isolate; }
.pet-art .pet-wrap { transform-box: border-box; transform-origin: 50% 95%; }
.pet-art img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 8px 5px rgba(43, 42, 76, 0.2));
  user-select: none;
  -webkit-user-drag: none;
}
.f0 .pet-art img { transform: scale(0.84); }
.f1 .pet-art img { transform: scale(0.93); }
.mood-sleepy .pet-art img { filter: saturate(0.65) brightness(0.92) drop-shadow(0 8px 5px rgba(43, 42, 76, 0.2)); }
.pet-badge { position: absolute; right: 4%; top: 2%; font-size: 2.2rem; animation: zzz 2.4s ease-in-out infinite; }

/* ==========================================================================
   Animations des compagnons (images officielles)
   ========================================================================== */
/* Respiration : l'image s'écrase légèrement puis s'étire, en gardant les pieds au sol */
@keyframes art-bob {
  0%, 100% { transform: translateY(0) scale(1.02, 0.97); }
  50% { transform: translateY(-9px) scale(0.985, 1.02); }
}
@keyframes sway { 0%, 100% { transform: rotate(-1.4deg); } 50% { transform: rotate(1.4deg); } }
@keyframes aura { 0%, 100% { opacity: 0.35; transform: translateX(-50%) scale(0.95); } 50% { opacity: 0.75; transform: translateX(-50%) scale(1.08); } }
@keyframes ground { 0%, 100% { transform: translateX(-50%) scale(1.05, 1); opacity: 0.9; } 50% { transform: translateX(-50%) scale(0.88, 0.9); opacity: 0.6; } }

.mood-happy .pet-art .pet-wrap,
.mood-neutral .pet-art .pet-wrap { animation: art-bob 3.2s ease-in-out infinite; }
.mood-sleepy .pet-art .pet-wrap { animation: breathe 4.5s ease-in-out infinite; }
.mood-hungry .pet-art .pet-wrap { animation: droop 3.5s ease-in-out infinite; }
.pet-art .pet-wrap.cheer { animation: cheer 0.9s ease-out; }
.mood-happy .pet-art, .mood-neutral .pet-art { transform-origin: 50% 92%; animation: sway 6s ease-in-out infinite; }

/* Ombre au sol qui suit les mouvements + halo de la couleur du type */
.pet-art::before, .pet-art::after { content: ""; position: absolute; left: 50%; pointer-events: none; }
.pet-art::after {
  bottom: 2%;
  width: 56%;
  height: 7%;
  border-radius: 50%;
  background: rgba(43, 42, 76, 0.2);
  transform: translateX(-50%);
  animation: ground 3.2s ease-in-out infinite;
}
.pet-art::before {
  bottom: 8%;
  width: 78%;
  height: 78%;
  border-radius: 50%;
  z-index: -1;
  transform: translateX(-50%);
  animation: aura 4s ease-in-out infinite;
}
.sp-bulbizarre .pet-art::before { background: radial-gradient(circle, rgba(120, 220, 140, 0.55), transparent 68%); }
.sp-salameche .pet-art::before { background: radial-gradient(circle, rgba(255, 170, 70, 0.6), transparent 68%); }
.sp-carapuce .pet-art::before { background: radial-gradient(circle, rgba(100, 190, 255, 0.6), transparent 68%); }
.mood-sleepy .pet-art::before, .mood-hungry .pet-art::before { animation: none; opacity: 0.25; }

/* Petits effets qui montent autour du compagnon (feuilles, flammes, bulles) */
.fx {
  position: absolute;
  bottom: 18%;
  z-index: 3;
  font-size: 1.5rem;
  pointer-events: none;
  animation: fx-up 2.8s ease-out forwards;
}
@keyframes fx-up {
  0% { opacity: 0; transform: translate(0, 0) scale(0.6) rotate(0deg); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx, 0), -150px) scale(1.15) rotate(30deg); }
}

/* Évolution : l'image clignote en blanc avant de se transformer */
@keyframes evolve-flash {
  0%, 100% { filter: brightness(1) saturate(1); transform: scale(1); }
  50% { filter: brightness(6) saturate(0); transform: scale(1.08); }
}
@keyframes evolve-ring { 0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0.9; } 100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; } }
.evolving { position: relative; }
.evolving .pet-art img { animation: evolve-flash 0.55s ease-in-out infinite; }
.evolving .pet-art .pet-wrap { animation: none; }
.evolving::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 90%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 8px solid #fff;
  box-shadow: 0 0 40px 10px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  animation: evolve-ring 0.9s ease-out infinite;
}
