:root {
  --pink: #ff8fc8;
  --pink-dark: #e46aa9;
  --pink-soft: #ffe0f1;
  --lilac: #b18cf0;
  --lilac-dark: #8f68d6;
  --lilac-soft: #f1e7ff;
  --sky: #8ccfff;
  --sky-soft: #e2f4ff;
  --mint: #7fdcb6;
  --mint-dark: #46b88b;
  --gold: #ffd35c;
  --ink: #4a3a6b;
  --ink-soft: #7a6a99;
  --white: #fff;
  --shadow: 0 10px 24px rgba(74, 58, 107, .16);
  --font: 'Fredoka', 'Baloo 2', 'Nunito', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(165deg, #ffe4f4 0%, #f1e7ff 45%, #e2f4ff 100%);
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
button { font-family: inherit; color: inherit; }
svg { display: block; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.screen {
  flex: 1; position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow: hidden;
}

/* ---------- Décor ---------- */
.cloud {
  position: absolute; background: #fff; border-radius: 999px; opacity: .85;
  filter: drop-shadow(0 6px 10px rgba(143, 104, 214, .12));
  animation: drift 40s linear infinite;
}
.cloud::before, .cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 55%; height: 140%; left: 12%; top: -60%; }
.cloud::after { width: 40%; height: 110%; right: 14%; top: -40%; }
@keyframes drift { from { transform: translateX(-12vw); } to { transform: translateX(112vw); } }

/* ---------- Boutons ---------- */
.btn {
  border: none; border-radius: 999px; cursor: pointer;
  padding: 18px 40px; font-size: clamp(24px, 4vw, 40px); font-weight: 700;
  color: #fff; background: var(--pink);
  box-shadow: 0 8px 0 var(--pink-dark), var(--shadow);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--pink-dark), var(--shadow); }
.btn.lilac { background: var(--lilac); box-shadow: 0 8px 0 var(--lilac-dark), var(--shadow); }
.btn.small { padding: 10px 22px; font-size: 20px; box-shadow: 0 5px 0 var(--pink-dark); }
.btn.small.lilac { box-shadow: 0 5px 0 var(--lilac-dark); }
.btn.ghost { background: #fff; color: var(--ink); box-shadow: 0 5px 0 #d9cdee; }

.icon-btn {
  width: 64px; height: 64px; border-radius: 50%; border: none; cursor: pointer;
  background: #fff; box-shadow: 0 5px 0 #d9cdee, var(--shadow);
  display: grid; place-items: center; padding: 0; flex: none;
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #d9cdee; }
.icon-btn svg { width: 60%; height: 60%; }

/* ---------- Accueil ---------- */
.home-title { font-size: clamp(30px, 5.5vw, 60px); font-weight: 700; margin: 0; text-align: center;
  color: var(--lilac-dark); text-shadow: 0 4px 0 #fff; z-index: 1; }
.home-mascot { width: min(46vh, 52vw); z-index: 1; animation: float 3.2s ease-in-out infinite; cursor: pointer; }
.home-play {
  width: clamp(120px, 20vmin, 180px); height: clamp(120px, 20vmin, 180px); border-radius: 50%;
  border: none; cursor: pointer; z-index: 1;
  background: radial-gradient(circle at 35% 30%, #ffb3dc, var(--pink) 60%);
  box-shadow: 0 10px 0 var(--pink-dark), var(--shadow);
  display: grid; place-items: center; animation: pulse 2s ease-in-out infinite;
}
.home-play:active { transform: translateY(8px); box-shadow: 0 2px 0 var(--pink-dark); }
.home-play svg { width: 48%; height: 48%; margin-left: 8%; }
/* Paillette dort (minuteur du jour atteint) */
.screen.night { background: linear-gradient(170deg, #3b3478 0%, #6a5bb0 60%, #9b86d6 100%); }
.screen.night .home-title { color: #fff; text-shadow: 0 4px 0 rgba(0, 0, 0, .15); }
.screen.night .cloud { opacity: .25; }
.screen.night .island { opacity: .75; }
.home-play.sleep { background: radial-gradient(circle at 35% 30%, #8f7fd8, #4d4296 70%); box-shadow: 0 10px 0 #2f2868, var(--shadow); animation: none; }
.home-play.sleep svg { margin-left: 0; width: 56%; height: 56%; }
.zzz text { animation: zzz 2.4s ease-in-out infinite; }
.zzz text:nth-child(2) { animation-delay: .4s; } .zzz text:nth-child(3) { animation-delay: .8s; }
@keyframes zzz { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
.home-row { display: flex; align-items: center; gap: 28px; z-index: 1; margin-top: 8px; }
.corner { position: absolute; z-index: 5; }
.corner.tl { top: max(14px, env(safe-area-inset-top)); left: 14px; }
.corner.tr { top: max(14px, env(safe-area-inset-top)); right: 14px; }
.parent-gate { position: relative; width: 52px; height: 52px; opacity: .55; }
.parent-gate .ring { position: absolute; inset: -6px; pointer-events: none; }
.parent-gate .ring circle { transition: stroke-dashoffset linear; }

.map { display: flex; gap: clamp(6px, 1.4vw, 16px); align-items: center; z-index: 1; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.island {
  width: clamp(38px, 6vmin, 56px); height: clamp(38px, 6vmin, 56px); border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: clamp(16px, 2.6vmin, 24px);
  background: #fff; color: #cbbde3; border: 4px dashed #d9cdee;
}
.island.done { background: var(--mint); color: #fff; border: 4px solid var(--mint-dark); }
.island.current { background: var(--gold); color: var(--ink); border: 4px solid #f0b400; transform: scale(1.25); animation: pulse 1.6s ease-in-out infinite; }

/* ---------- Séance ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 14px 0;
}
.dots { display: flex; gap: 10px; }
.dot { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid #d9cdee; }
.dot.on { background: var(--gold); border-color: #f0b400; }
.dot.now { background: var(--pink-soft); border-color: var(--pink); animation: pulse 1.4s infinite; }

.prompt { display: flex; align-items: center; gap: 12px; max-width: 92vw; z-index: 2; margin-top: 64px; }
.prompt .mini-mascot { width: clamp(80px, 13vmin, 130px); flex: none; }
.bubble {
  background: #fff; border-radius: 26px; padding: 14px 22px; box-shadow: var(--shadow);
  font-size: clamp(20px, 3.2vmin, 30px); font-weight: 600; position: relative; min-height: 1.2em;
}
.bubble::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  border: 12px solid transparent; border-right-color: #fff; border-left: 0;
}
.stage-area { flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; position: relative; }

/* Choix (bulles) */
.choices { display: flex; flex-wrap: wrap; gap: clamp(16px, 3vw, 40px); justify-content: center; align-items: center; max-width: 96vw; }
.choice {
  border: 6px solid var(--lilac); background: #fff; cursor: pointer;
  width: clamp(110px, 19vmin, 190px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; padding: 10%;
  font-size: clamp(60px, 11vmin, 120px); font-weight: 700; line-height: 1; color: var(--ink);
  box-shadow: 0 8px 0 #d9cdee, var(--shadow);
  animation: appear .45s cubic-bezier(.3, 1.6, .6, 1) backwards;
}
.choice { position: relative; }
.choice > svg { position: absolute; inset: 9%; width: 82%; height: 82%; }
.choice.card { border-radius: 30px; aspect-ratio: auto; width: auto; min-width: 200px; padding: 18px 28px; font-size: clamp(36px, 6.5vmin, 64px); letter-spacing: .06em; }
.choice.plain { border-color: transparent; background: transparent; box-shadow: none; }
.choice:active { transform: scale(.94); }
.choice.wrong { animation: wiggle .5s; border-color: #ffb0b0; }
.choice.dim { opacity: .3; pointer-events: none; filter: grayscale(.6); }
.choice.right { animation: win .7s cubic-bezier(.3, 1.6, .6, 1); border-color: var(--mint-dark); background: #e7fbf2; }
.choice.hint { animation: glow 1.1s ease-in-out infinite; border-color: var(--gold); }

/* Logique : comparer des groupes */
.choice.group { border-radius: 30px; width: clamp(200px, 36vw, 360px); max-height: 46vh; padding: 5%; }
.choice.group.g3 { width: clamp(150px, 27vw, 270px); }
.choice.group .grp { position: absolute; inset: 7%; display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 4%; }
.choice.group .grp i { width: calc((100% - 4% * (var(--cols) - 1)) / var(--cols) - 1px); aspect-ratio: 1; display: block; }
.choice.group .grp svg { width: 100%; height: 100%; display: block; }
/* Logique : suites */
.suite-row { display: flex; flex-wrap: nowrap; gap: clamp(6px, 1.2vw, 14px); align-items: center; justify-content: center; max-width: 96vw; }
.suite-tile { position: relative; width: clamp(48px, 9vw, 104px); height: clamp(48px, 9vw, 104px); flex: none; border-radius: 18px; background: #fff; box-shadow: var(--shadow); display: grid; place-items: center; line-height: 1; animation: appear .4s cubic-bezier(.3, 1.6, .6, 1) backwards; }
.suite-tile svg { position: absolute; inset: 10%; width: 80%; height: 80%; display: block; }
.suite-tile.ask { border: 4px dashed var(--lilac); background: var(--lilac-soft); font-size: clamp(28px, 5vw, 56px); font-weight: 700; color: var(--lilac-dark); }
.suite-tile.ask.filled { border-style: solid; border-color: var(--mint-dark); background: #e7fbf2; animation: win .7s cubic-bezier(.3, 1.6, .6, 1); }

/* Memory */
.memo-grid { display: grid; gap: var(--gap, 16px); justify-content: center; --cw: 150px; }
.memo-card { width: var(--cw); aspect-ratio: .82; padding: 0; border: none; background: none; cursor: pointer; perspective: 900px; animation: appear .4s cubic-bezier(.3, 1.6, .6, 1) backwards; -webkit-tap-highlight-color: transparent; }
.memo-card.bump { animation: bump .5s; }
.memo-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.3, 1.3, .6, 1); }
.memo-card.up .memo-inner { transform: rotateY(180deg); }
.memo-face { position: absolute; inset: 0; border-radius: 18px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; place-items: center; box-shadow: 0 6px 0 #d9cdee, var(--shadow); }
.memo-back { background: linear-gradient(135deg, var(--lilac), var(--pink)); border: 5px solid #fff; }
.memo-back svg { width: 46%; height: auto; }
.memo-front { background: #fff; border: 5px solid var(--lilac-soft); transform: rotateY(180deg); padding: 12%; overflow: hidden; }
.memo-front > svg { width: 100%; height: 100%; display: block; }
.memo-card.found .memo-front { border-color: var(--mint-dark); background: #e7fbf2; }
.memo-card.hint .memo-back { animation: glow 1.1s ease-in-out infinite; }
.memo-glyph { font-size: calc(var(--cw) * .56); font-weight: 700; line-height: 1; color: var(--ink); }
.memo-qty { width: 100%; height: 100%; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 4%; }
.memo-qty i { width: calc((100% - 4% * (var(--cols) - 1)) / var(--cols) - 1px); aspect-ratio: 1; display: block; }
.memo-qty svg { width: 100%; height: 100%; display: block; }

/* Comptage */
.count-field { display: flex; flex-wrap: wrap; gap: clamp(14px, 3vw, 34px); justify-content: center; align-items: center; max-width: 90vw; }
.count-item { width: clamp(90px, 15vmin, 150px); aspect-ratio: 1; position: relative; cursor: pointer; animation: appear .45s cubic-bezier(.3, 1.6, .6, 1) backwards; }
.count-item.counted { animation: bump .45s; }
.count-item.counted::after {
  content: attr(data-n); position: absolute; right: -6px; top: -8px; width: 44%; aspect-ratio: 1;
  border-radius: 50%; background: var(--pink); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: clamp(20px, 3.6vmin, 34px); box-shadow: 0 3px 0 var(--pink-dark);
}

/* Prénom à remettre dans l'ordre */
.slots { display: flex; gap: clamp(6px, 1.2vw, 14px); flex-wrap: nowrap; }
.slot {
  width: clamp(54px, 9.5vmin, 96px); aspect-ratio: .82; border-radius: 18px; border: 4px dashed #cbbde3;
  display: grid; place-items: center; font-size: clamp(38px, 7vmin, 72px); font-weight: 700; color: #e3d9f3; background: rgba(255, 255, 255, .6);
}
.slot.filled { border: 4px solid var(--mint-dark); background: #fff; color: var(--ink); animation: bump .4s; }
.slot.next { border-color: var(--pink); }
.tiles { display: flex; gap: clamp(10px, 2vw, 22px); flex-wrap: wrap; justify-content: center; max-width: 94vw; }
.tile {
  width: clamp(70px, 12vmin, 116px); aspect-ratio: 1; border-radius: 24px; border: none; cursor: pointer;
  font-size: clamp(44px, 8vmin, 80px); font-weight: 700; color: #fff; background: var(--lilac);
  box-shadow: 0 7px 0 var(--lilac-dark); animation: appear .45s cubic-bezier(.3, 1.6, .6, 1) backwards;
}
.tile.used { visibility: hidden; }
.tile.wrong { animation: wiggle .5s; }
.tile.hint { animation: glow 1.1s infinite; }

/* Tracé au doigt */
.trace-box { display: flex; justify-content: center; align-items: center; }
.trace-box svg { height: min(58vh, 66vw); width: auto; max-width: 92vw; touch-action: none; overflow: visible; }
.trace-box .track { fill: none; stroke: #fff; stroke-width: 30; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 4px 0 #e3d9f3); }
.trace-box .guide { fill: none; stroke: #d2c2f0; stroke-width: 3.4; stroke-linecap: round; stroke-dasharray: 0 8; }
.trace-box .guide.current { stroke: #b18cf0; }
.trace-box .ink { fill: none; stroke-width: 20; stroke-linecap: round; stroke-linejoin: round; }
.trace-box .head polygon { fill: #ffd35c; stroke: #f0a800; stroke-width: 2; stroke-linejoin: round; }
.trace-box .head .halo { fill: rgba(255, 211, 92, .4); animation: halo 1.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.trace-box .arrow path { fill: none; stroke: #ff8fc8; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; }
.trace-box .arrow { transition: opacity .3s; }
.trace-box.done .head, .trace-box.done .arrow, .trace-box.done .guide { display: none; }
.trace-box.done svg { animation: win .7s cubic-bezier(.3, 1.6, .6, 1); }
@keyframes halo { 0%, 100% { transform: scale(1); opacity: .9 } 50% { transform: scale(1.7); opacity: .25 } }

/* Relier chiffre et quantité */
.match-board {
  position: relative; width: min(94vw, 980px); height: min(62vh, 580px);
  display: grid; grid-template-columns: minmax(90px, .7fr) 1.6fr; column-gap: clamp(56px, 15vw, 220px);
}
.match-col { display: flex; flex-direction: column; justify-content: center; gap: clamp(10px, 2vh, 20px); min-height: 0; }
.match-card {
  position: relative; flex: 1 1 0; min-height: 0; max-height: 170px;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 5px solid var(--lilac); border-radius: 26px; cursor: pointer; touch-action: none;
  box-shadow: 0 7px 0 #d9cdee, var(--shadow); transition: transform .12s, border-color .12s;
  animation: appear .45s cubic-bezier(.3, 1.6, .6, 1) backwards;
}
.match-digit { font-size: clamp(48px, 9vmin, 100px); font-weight: 700; line-height: 1; }
.match-group { padding: 8px 14px; }
.match-digit::after, .match-group::before {
  content: ''; position: absolute; top: 50%; width: 20px; height: 20px; margin-top: -10px;
  border-radius: 50%; background: var(--ink); border: 4px solid #fff;
}
.match-digit::after { right: -14px; }
.match-group::before { left: -14px; }
.match-items {
  display: grid; grid-template-columns: repeat(var(--cols), auto); grid-template-rows: repeat(var(--rows), 1fr);
  gap: 4px; justify-content: center; align-content: center; width: 100%; height: 100%; pointer-events: none;
}
.match-items svg { height: 100%; width: auto; aspect-ratio: 1; max-height: 78px; }
.match-items svg.flash { animation: bump .45s; }
.match-card.selected { border-color: var(--pink); transform: scale(1.05); }
.match-card.done { border-color: var(--mint-dark); background: #e7fbf2; cursor: default; }
.match-card.wrong { animation: wiggle .5s; }
.match-card.hint { animation: glow 1.1s ease-in-out infinite; border-color: var(--gold); }
.match-lines { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.match-lines svg { position: absolute; inset: 0; overflow: visible; }
.match-lines line { stroke-width: 9; stroke-linecap: round; }
.match-lines .temp { stroke: var(--pink); stroke-dasharray: 2 14; visibility: hidden; }

/* Bulles */
.bubbles-field { position: absolute; inset: 0; overflow: hidden; }
.soap {
  position: absolute; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  font-weight: 700; color: var(--ink); border: none; padding: 0;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .95) 0 12%, rgba(255, 255, 255, .35) 30%, rgba(177, 140, 240, .28) 70%, rgba(255, 143, 200, .45) 100%);
  box-shadow: inset 0 0 18px rgba(255, 255, 255, .8), 0 6px 14px rgba(143, 104, 214, .18);
}
.soap.popped { animation: popout .35s forwards; pointer-events: none; }

/* Récompense */
.reward-sticker { width: min(44vmin, 360px); animation: sticker 1s cubic-bezier(.3, 1.6, .6, 1) both; filter: drop-shadow(0 12px 18px rgba(74, 58, 107, .25)); }
.reward-title { font-size: clamp(32px, 6vmin, 60px); font-weight: 700; color: var(--pink-dark); margin: 10px 0; text-align: center; }

/* Confettis */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 14px; height: 18px; border-radius: 4px; animation: fall linear forwards; }

/* Mascotte */
.mascot-happy { animation: hop .7s cubic-bezier(.3, 1.6, .6, 1); }
.mascot-sad { animation: tilt .8s ease-in-out; }

/* Repeat */
.repeat-btn { width: 56px; height: 56px; }

/* ---------- Animations ---------- */
@keyframes float { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-14px) } }
@keyframes pulse { 0%, 100% { transform: scale(1) } 50% { transform: scale(1.06) } }
@keyframes appear { from { transform: scale(0); opacity: 0 } to { transform: scale(1); opacity: 1 } }
@keyframes wiggle { 0%, 100% { transform: translateX(0) } 20% { transform: translateX(-14px) rotate(-6deg) } 40% { transform: translateX(12px) rotate(5deg) } 60% { transform: translateX(-8px) } 80% { transform: translateX(5px) } }
@keyframes win { 0% { transform: scale(1) } 40% { transform: scale(1.25) rotate(-4deg) } 70% { transform: scale(.95) } 100% { transform: scale(1.08) } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 211, 92, .9), 0 8px 0 #d9cdee } 50% { box-shadow: 0 0 0 22px rgba(255, 211, 92, 0), 0 8px 0 #d9cdee; transform: scale(1.08) } }
@keyframes bump { 0% { transform: scale(1) } 40% { transform: scale(1.22) } 100% { transform: scale(1) } }
@keyframes hop { 0%, 100% { transform: translateY(0) } 40% { transform: translateY(-26px) rotate(-6deg) } }
@keyframes tilt { 0%, 100% { transform: rotate(0) } 30% { transform: rotate(-8deg) } 60% { transform: rotate(5deg) } }
@keyframes popout { to { transform: scale(1.6); opacity: 0 } }
@keyframes sticker { 0% { transform: scale(0) rotate(-200deg) } 100% { transform: scale(1) rotate(0) } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg) } }

/* ---------- Espace parent ---------- */
.parent { justify-content: flex-start; overflow-y: auto; background: #faf7ff; align-items: stretch; padding-top: max(20px, env(safe-area-inset-top)); }
.parent-inner { width: min(880px, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: 18px; padding-bottom: 40px; }
.parent h1 { margin: 0; font-size: 30px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel { background: #fff; border-radius: 20px; padding: 18px 20px; box-shadow: 0 4px 14px rgba(74, 58, 107, .08); }
.panel h2 { margin: 0 0 12px; font-size: 22px; }
.panel p { margin: 6px 0; color: var(--ink-soft); font-size: 17px; }
.stage-pick { display: flex; flex-wrap: wrap; gap: 10px; }
.stage-pick button { min-width: 54px; height: 54px; border-radius: 14px; border: 3px solid #e3d9f3; background: #fff; font-size: 20px; font-weight: 700; cursor: pointer; }
.stage-pick button.on { background: var(--gold); border-color: #f0b400; }
.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 10px; }
.skill { border-radius: 14px; padding: 8px; text-align: center; background: #f6f2fd; font-size: 15px; }
.skill b { display: block; font-size: 26px; }
.bar { height: 8px; border-radius: 4px; background: #e8e0f5; margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--mint-dark); }
.field { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid #f0eaf9; font-size: 18px; flex-wrap: wrap; }
.field:last-child { border-bottom: none; }
.field select, .field input[type=text] { font: inherit; font-size: 18px; padding: 8px 12px; border-radius: 12px; border: 2px solid #e3d9f3; background: #fff; color: var(--ink); max-width: 100%; }
.seg { display: inline-flex; border-radius: 12px; overflow: hidden; border: 2px solid #e3d9f3; }
.seg button { border: none; background: #fff; padding: 8px 14px; font-size: 17px; cursor: pointer; }
.seg button.on { background: var(--lilac); color: #fff; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 15px; color: var(--ink-soft); }
/* Temps d'écran : la semaine en barres */
.week-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; height: 150px; margin: 6px 0 4px; }
.wb { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.wb small { font-size: 13px; color: var(--ink-soft); min-height: 1.2em; white-space: nowrap; }
.wb-track { position: relative; flex: 1; width: 70%; max-width: 46px; background: #f3eefb; border-radius: 10px; }
.wb-track i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--lilac); border-radius: 10px; }
.wb.today .wb-track i { background: var(--pink); }
.wb-track b { position: absolute; left: -5px; right: -5px; border-top: 2px dashed #e5484d; }
.wb span { font-size: 14px; color: var(--ink-soft); }
.panel p.note { font-size: 15px; }
/* Voix de la famille */
.fam-warn { background: #fff4d6; border-radius: 12px; padding: 8px 12px; }
.fam-status:empty { display: none; }
.fam-status { background: #ffe6e6; border-radius: 12px; padding: 8px 12px; color: #a23b3b !important; }
.fam-status.ok { background: #e3f7ee; color: #23795a !important; }
.fam-cat { border-top: 1px solid #f0eaf9; padding: 12px 0 4px; }
/* Sauvegarde */
.backup-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; align-items: center; }
.backup-part + .backup-part { border-top: 2px solid #f0eaf9; margin-top: 18px; padding-top: 14px; }
.panel p.cloud-status { border-radius: 12px; padding: 8px 12px; background: #f6f2fd; }
.panel p.cloud-status.ok { background: #e3f7ee; color: #23795a; }
.panel p.cloud-status.warn { background: #fff4d6; color: #8a6100; }
.panel p.cloud-status.off { background: #f1f1f1; }
.cloud-code-box { margin: 12px 0; padding: 12px 14px; border-radius: 16px; border: 2px solid #e3d9f3; }
.cloud-code-box.todo { background: #fff4d6; border-color: #f0c64a; }
.cloud-code-box > span { font-size: 15px; color: var(--ink-soft); }
.cloud-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: clamp(22px, 4vw, 32px); font-weight: 700; letter-spacing: .08em; margin: 4px 0; user-select: all; }
.cloud-recover { margin-top: 8px; padding: 6px 12px 10px; border-radius: 16px; background: #faf7ff; }
.cloud-recover input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 18px; letter-spacing: .06em; padding: 8px 12px; border-radius: 12px; border: 2px solid #e3d9f3; width: 15em; max-width: 100%; text-transform: uppercase; }
.cloud-versions { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.cloud-version { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 10px; border-radius: 12px; background: #fff; font-size: 17px; }
.link-btn { border: none; background: none; padding: 6px 0; color: var(--ink-soft); text-decoration: underline; font: inherit; font-size: 15px; cursor: pointer; }
.backup-actions .btn[disabled] { opacity: .6; }
.backup-nag, .parent-notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-radius: 16px; padding: 12px 16px; font-size: 18px; }
.backup-nag { background: #fff4d6; }
.parent-notice { background: #e3f7ee; color: #23795a; font-weight: 600; }
.fam-head { font-size: 19px; }
.fam-head small { color: var(--ink-soft); font-size: 16px; }
.panel p.fam-ideas { font-size: 15px; margin: 4px 0 10px; }
.fam-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fam-clips { display: flex; flex-wrap: wrap; gap: 8px; }
.fam-clip { display: flex; align-items: center; gap: 6px; background: var(--lilac-soft); border-radius: 14px; padding: 4px 6px 4px 4px; }
.fam-clip small { color: var(--ink-soft); font-size: 14px; }
.fam-play { border: none; border-radius: 10px; background: var(--lilac); color: #fff; font: inherit; font-size: 17px; font-weight: 600; padding: 8px 12px; cursor: pointer; }
.fam-del { border: none; background: transparent; color: var(--ink-soft); font-size: 18px; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; }
.fam-del:active { background: #fff; }
.fam-rec-wrap { display: flex; flex-direction: column; align-items: stretch; gap: 6px; min-width: 210px; }
.fam-rec[disabled] { opacity: .45; box-shadow: none; }
.fam-rec.on { background: #e5484d; box-shadow: 0 5px 0 #b3262b; }
.fam-meter { height: 6px; border-radius: 3px; background: #f0eaf9; overflow: hidden; visibility: hidden; }
.fam-rec.on + .fam-meter { visibility: visible; }
.fam-meter i { display: block; height: 100%; width: 0; background: var(--mint-dark); transition: width .08s linear; }

/* ---------- Album ---------- */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(90px, 14vmin, 140px), 1fr)); gap: 16px; width: min(1000px, 94vw); margin-top: 80px; overflow-y: auto; padding: 10px; }
.album-slot { aspect-ratio: 1; border-radius: 24px; background: rgba(255, 255, 255, .7); border: 4px dashed #e3d9f3; display: grid; place-items: center; padding: 10%; }
.album-slot.has { background: #fff; border: 4px solid #fff; box-shadow: var(--shadow); }
.album-slot .shadow-shape { opacity: .12; filter: grayscale(1); }

/* ---------- Décore le monde de Paillette ---------- */
.corner.bl { bottom: max(14px, env(safe-area-inset-bottom)); left: 14px; }
.decor-go { width: 76px; height: 76px; color: #e46aa9; animation: pulse 2s ease-in-out infinite; }
.screen.decor { justify-content: flex-start; padding-top: 92px; gap: 12px; }
.decor .topbar { align-items: center; }
.decor-bgs { display: flex; gap: clamp(6px, 1.4vw, 14px); }
.decor-bg {
  width: clamp(64px, 11vmin, 104px); aspect-ratio: 16 / 10; padding: 0; border-radius: 14px; overflow: hidden;
  border: 4px solid #fff; background: #fff; box-shadow: 0 4px 0 #d9cdee, var(--shadow); cursor: pointer; position: relative;
}
.decor-bg svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.decor-bg.on { border-color: var(--pink); transform: scale(1.1); }
.decor-scene {
  position: relative; flex: none; aspect-ratio: 16 / 10;
  width: min(96vw, calc((100dvh - 236px) * 1.6)); border-radius: 28px; overflow: hidden;
  border: 6px solid #fff; box-shadow: var(--shadow); touch-action: none; background: #e8f7ff;
}
.decor-scene .scene-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.decor-mascot { position: absolute; left: 33%; bottom: 4%; width: 34%; cursor: pointer; filter: drop-shadow(0 8px 10px rgba(74, 58, 107, .18)); }
.decor-item { position: absolute; aspect-ratio: 1; touch-action: none; cursor: grab; filter: drop-shadow(0 4px 5px rgba(74, 58, 107, .22)); }
.decor-item.new { animation: appear .25s ease-out; }
.decor-item svg, .decor-src svg, .decor-ghost svg { width: 100%; height: 100%; }
.decor-ghost { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; filter: drop-shadow(0 10px 12px rgba(74, 58, 107, .3)); }
.decor-tray {
  display: flex; gap: 12px; overflow-x: auto; flex: none; align-items: center;
  width: min(96vw, 1100px); min-height: 104px; padding: 10px 14px; border-radius: 24px; background: rgba(255, 255, 255, .75);
}
.decor-src { flex: none; width: 82px; height: 82px; position: relative; background: #fff; border-radius: 20px; padding: 7px; box-shadow: 0 4px 0 #d9cdee; touch-action: pan-x; cursor: grab; }
.decor-src b { position: absolute; top: -8px; right: -8px; background: var(--pink); color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 17px; }
.decor-empty { margin: auto; font-size: clamp(18px, 2.8vmin, 24px); font-weight: 600; color: var(--ink-soft); text-align: center; }

/* ---------- Coloriage au doigt ---------- */
.screen.coloring { justify-content: flex-start; padding-top: 92px; gap: 12px; }
.color-pages {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 26vmin, 230px), 1fr)); gap: 18px;
  width: min(1000px, 94vw); overflow-y: auto; padding: 10px; align-content: start;
}
.color-thumb {
  background: #fff; border: none; border-radius: 24px; box-shadow: 0 6px 0 #d9cdee, var(--shadow); cursor: pointer;
  padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: clamp(17px, 2.4vmin, 22px); font-weight: 600;
}
.color-thumb:active { transform: translateY(4px); box-shadow: 0 2px 0 #d9cdee; }
.color-thumb svg { width: 100%; height: clamp(96px, 17vmin, 160px); }
.color-thumb.magic { background: linear-gradient(160deg, #fff, #fff4fb); border: 3px solid var(--pink-soft); }
.color-board { position: relative; flex: 1; min-height: 0; width: min(96vw, 1100px); background: #fff; border-radius: 28px; box-shadow: var(--shadow); touch-action: none; }
.color-board > svg { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); }
.color-board svg * { pointer-events: none; } /* reflets, ficelles… laissent passer le doigt */
.color-board .zone { cursor: pointer; transition: fill .25s; pointer-events: visiblePainted; }
.magic-n { font-family: var(--font); font-size: 15px; font-weight: 700; fill: #4a3a6b; text-anchor: middle; pointer-events: none; }
.magic-legend { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; flex: none; }
.magic-legend button {
  display: flex; align-items: center; gap: 8px; border: none; cursor: pointer; background: #fff; border-radius: 999px;
  padding: 6px 16px 6px 8px; font-size: clamp(18px, 2.8vmin, 26px); font-weight: 700; box-shadow: 0 4px 0 #d9cdee;
}
.magic-legend button.bump { animation: bump .5s; }
.magic-legend i { width: 32px; height: 32px; border-radius: 50%; display: inline-block; border: 3px solid #fff; box-shadow: 0 0 0 2px #d9cdee; }
.color-palette { display: flex; gap: clamp(8px, 1.6vw, 16px); flex-wrap: wrap; justify-content: center; flex: none; padding-bottom: 4px; }
.color-dot {
  width: clamp(50px, 8vmin, 72px); height: clamp(50px, 8vmin, 72px); border-radius: 50%; padding: 0; cursor: pointer;
  border: 5px solid #fff; box-shadow: 0 4px 0 #d9cdee, var(--shadow); transition: transform .12s;
}
.color-dot.on { transform: scale(1.2); border-color: var(--ink); }
.color-dot.eraser { background: #fff; display: grid; place-items: center; }
.color-dot.eraser svg { width: 70%; height: 70%; }

/* ---------- Imagier « J comme… » et jeu des sons ---------- */
.corner.br { bottom: max(14px, env(safe-area-inset-bottom)); right: 14px; }
.word-label { font-weight: 700; letter-spacing: .04em; color: var(--ink); }
.word-label b { color: var(--pink-dark); font-weight: 700; }
.screen.imagier { justify-content: flex-start; padding-top: 92px; gap: 14px; }
.imagier-letters { display: flex; gap: clamp(6px, 1.2vw, 12px); flex-wrap: wrap; justify-content: center; flex: none; }
.imagier-tab {
  width: clamp(48px, 7.5vmin, 64px); height: clamp(48px, 7.5vmin, 64px); border-radius: 50%; border: 4px solid #e3d9f3; cursor: pointer;
  background: #fff; color: #b9a9d6; font-size: clamp(22px, 3.6vmin, 32px); font-weight: 700; box-shadow: 0 4px 0 #d9cdee; padding: 0;
}
.imagier-tab.known { color: var(--ink); border-color: var(--lilac); }
.imagier-tab.on { background: var(--gold); border-color: #f0b400; color: var(--ink); transform: scale(1.15); }
.imagier-page { flex: 1; min-height: 0; width: min(96vw, 1150px); display: flex; align-items: center; gap: clamp(14px, 3vw, 36px); }
.imagier-big {
  flex: none; width: clamp(130px, 26vmin, 240px); aspect-ratio: 1; border-radius: 36px; border: none; cursor: pointer; padding: 0;
  background: radial-gradient(circle at 35% 30%, #ffb3dc, var(--pink) 65%); color: #fff;
  font-size: clamp(90px, 19vmin, 180px); font-weight: 700; line-height: 1; box-shadow: 0 8px 0 var(--pink-dark), var(--shadow);
}
.imagier-big.bump, .imagier-card.bump { animation: bump .5s; }
.imagier-grid { flex: 1; display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(10px, 2vw, 20px); max-height: 100%; }
.imagier-card {
  background: #fff; border: none; border-radius: 26px; box-shadow: 0 6px 0 #d9cdee, var(--shadow); cursor: pointer;
  padding: 10px 10px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: clamp(18px, 3vmin, 28px);
}
.imagier-card svg { width: clamp(70px, 20vmin, 170px); height: clamp(70px, 20vmin, 170px); }
.imagier-card.me { background: linear-gradient(160deg, #fff, #ffe9f5); }
.sound-letter {
  width: clamp(90px, 15vmin, 130px); aspect-ratio: 1; border-radius: 28px; display: grid; place-items: center;
  background: var(--pink); color: #fff; font-size: clamp(64px, 11vmin, 96px); font-weight: 700; line-height: 1;
  box-shadow: 0 6px 0 var(--pink-dark), var(--shadow); animation: appear .3s ease-out;
}
.choice.word-card .word-label { position: absolute; left: 0; right: 0; bottom: -1.5em; font-size: clamp(20px, 3.2vmin, 30px); text-align: center; }
.choice.word-card { border-radius: 32px; width: clamp(140px, 24vmin, 230px); margin-bottom: 1.6em; }

/* ---------- Puzzles de Paillette ---------- */
.puz { position: relative; flex: 1; align-self: stretch; min-height: 0; touch-action: none; }
.puz-board { position: absolute; transition: left .4s ease, top .4s ease; border-radius: 18px; background: #fff; box-shadow: var(--shadow); outline: 6px solid #fff; }
.puz-ghost { position: absolute; inset: 0; border-radius: 18px; overflow: hidden; filter: grayscale(.3); }
.puz-ghost svg, .puz-img svg { width: 100%; height: 100%; }
.puz-slot { position: absolute; border: 2px dashed #cbbde3; }
.puz-slot.hint { border: 4px solid var(--gold); background: rgba(255, 211, 92, .25); animation: pulse 1s ease-in-out infinite; }
.puz-piece {
  position: absolute; overflow: hidden; touch-action: none; cursor: grab; border-radius: 10px; background: #fff;
  box-shadow: 0 6px 14px rgba(74, 58, 107, .25), 0 0 0 3px #fff; transition: left .3s ease, top .3s ease, border-radius .3s;
}
.puz-piece.dragging { transition: none; z-index: 10; cursor: grabbing; box-shadow: 0 14px 26px rgba(74, 58, 107, .35), 0 0 0 3px #fff; transform: scale(1.04); }
.puz-piece.placed { z-index: 1; cursor: default; border-radius: 0; box-shadow: none; }
.puz-piece.bump { animation: bump .45s; }
.puz-img { position: absolute; }
.puz.done .puz-slot { opacity: 0; transition: opacity .4s; }
.puz-board.bump { animation: bump .6s; }

/* ---------- Grand / petit, sur / sous ---------- */
.choice.size-card { border-radius: 30px; width: clamp(170px, 30vmin, 280px); padding: 0; }
.choice.size-card .sz { position: absolute; left: 8%; right: 8%; bottom: 7%; height: 86%; display: flex; align-items: flex-end; justify-content: center; }
.choice.size-card .sz svg { width: calc(100% * var(--s)); height: calc(100% * var(--s)); }
.choice.pos-card { border-radius: 30px; width: clamp(200px, 36vmin, 340px); aspect-ratio: 6 / 5; padding: 0; }
.choice.pos-card > svg { inset: 6%; width: 88%; height: 88%; }

/* ---------- Familles : « Qui joue ? », bienvenue, lien personnel ---------- */
.who-switch { z-index: 2; display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; padding: 6px 14px 6px 8px; border: none; border-radius: 999px;
  background: rgba(255, 255, 255, .8); box-shadow: 0 3px 0 #d9cdee; font-size: 17px; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.who-switch:active { transform: translateY(3px); box-shadow: none; }
.who-switch-heads { display: inline-flex; }
.who-switch-heads svg { width: 34px; height: 34px; border-radius: 50%; background: #fff; }
.screen.night .who-switch { background: rgba(255, 255, 255, .25); color: #fff; box-shadow: none; }

.players .home-title { margin-bottom: clamp(18px, 4vh, 40px); z-index: 1; }
.player-cards { display: flex; flex-wrap: wrap; gap: clamp(16px, 4vw, 48px); justify-content: center; z-index: 1; padding: 0 16px; }
.player-card { border: none; background: #fff; border-radius: 32px; padding: 18px 18px 14px; width: clamp(170px, 30vw, 280px); cursor: pointer;
  box-shadow: 0 8px 0 #d9cdee, var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 8px; animation: player-in .5s ease-out both; }
.player-card:nth-child(2) { animation-delay: .08s; }
.player-card:nth-child(3) { animation-delay: .16s; }
.player-card.bump { animation: bump .5s; }
@keyframes player-in { from { transform: scale(.6); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.player-card:active { transform: translateY(6px); box-shadow: 0 2px 0 #d9cdee, var(--shadow); }
.player-head svg { width: 100%; height: auto; display: block; }
.player-head { width: 82%; aspect-ratio: 1; border-radius: 50%; background: var(--lilac-soft); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.player-name { font-size: clamp(26px, 4.4vw, 44px); font-weight: 700; }

.welcome-hero { display: flex; justify-content: center; gap: 18px; margin-top: 6px; }
.welcome-hero svg { width: 92px; height: 92px; border-radius: 50%; background: #fff; box-shadow: 0 4px 14px rgba(74, 58, 107, .1); }
.welcome h1 { justify-content: center; text-align: center; }
.kids-form { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.kid-row { border: 2px solid #f0eaf9; border-radius: 16px; padding: 4px 14px 8px; }
.kid-row h3 { margin: 8px 0 0; font-size: 18px; }
.pal-pick { display: flex; gap: 10px; flex-wrap: wrap; }
.pal-choice { border: 3px solid #e3d9f3; background: #fff; border-radius: 16px; padding: 6px 10px; width: 150px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pal-choice svg { width: 100%; height: 86px; }
.pal-choice span { font-size: 14px; font-weight: 600; text-align: center; line-height: 1.15; }
.pal-choice.on { border-color: var(--lilac); background: var(--lilac-soft); }
.cloud-link { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: clamp(14px, 2.4vw, 19px); font-weight: 700; margin: 4px 0 8px; word-break: break-all; user-select: all; -webkit-user-select: all; }

.kid-tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.kid-tabs button { display: inline-flex; align-items: center; gap: 8px; border: 3px solid #e3d9f3; background: #fff; border-radius: 999px; padding: 4px 16px 4px 4px; font-size: 19px; font-weight: 600; cursor: pointer; }
.kid-tabs button.on { border-color: var(--lilac); background: var(--lilac-soft); }
.kid-tab-head svg { width: 38px; height: 38px; border-radius: 50%; background: #fff; display: block; }
.kid-add { margin-top: 8px; padding: 4px 14px 12px; border-radius: 16px; background: #faf7ff; }
