/* Petits Héros — styles. Pensé pour les doigts d'un enfant de 4 ans : grandes cibles, peu de texte. */
:root {
  --bg: #fef3c7;
  --ink: #1f2937;
  --card: #ffffff;
  --muted: #6b7280;
  --primary: #3b82f6;
  --good: #22c55e;
  --bad: #ef4444;
  --star: #facc15;
  --radius: 24px;
  --gap: clamp(10px, 2.5vw, 22px);
  --font: 'Nunito', 'Baloo 2', 'Comic Sans MS', 'Chalkboard SE', ui-rounded, system-ui, sans-serif;
  --emoji: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  background-attachment: fixed;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
  transition: background 0.4s;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.loading { margin: auto; font-size: 80px; animation: spin 1.2s linear infinite; }
.item-emoji { font-family: var(--emoji); line-height: 1; display: inline-block; }
.item-img { width: 1em; height: 1em; object-fit: contain; display: inline-block; vertical-align: middle; }
.silhouette { filter: brightness(0) opacity(0.85); transition: filter 0.5s; }
.silhouette.revealed { filter: none; }

/* ---------- Barre du haut ---------- */
.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--gap);
}
.hud-spacer { width: 56px; flex: none; }
.btn-round {
  width: 56px; height: 56px; flex: none;
  border-radius: 50%;
  background: #fff;
  font-size: 28px;
  display: grid; place-items: center;
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
  position: relative;
  font-family: var(--emoji);
}
.btn-round:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.15); }
.btn-lock { width: 44px; height: 44px; font-size: 20px; opacity: 0.75; }
.hold-ring { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); transform: rotate(-90deg); pointer-events: none; }
.hold-ring circle { fill: none; stroke: var(--primary); stroke-width: 3; stroke-dasharray: 101; stroke-dashoffset: 101; }
.holding .hold-ring circle { transition: stroke-dashoffset 1.5s linear; stroke-dashoffset: 0; }

.stars-pill {
  display: flex; align-items: center; gap: 6px;
  background: #fff; border-radius: 999px;
  padding: 6px 16px 6px 10px;
  font-size: 26px; font-weight: 900;
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
}
.star-icon { font-family: var(--emoji); animation: pulse 2s ease-in-out infinite; }
.time-pill {
  flex: 1; min-width: 80px;
  display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 999px; padding: 8px 14px;
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
}
.time-icon { font-size: 24px; font-family: var(--emoji); }
.time-bar { flex: 1; height: 16px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.time-fill { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #22c55e, #84cc16); border-radius: 999px; transition: width 1s linear; }
.time-fill.low { background: linear-gradient(90deg, #f97316, #ef4444); animation: blink 1s ease-in-out infinite; }

/* ---------- Écrans ---------- */
.screen { flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--gap); }
.title {
  margin: 0; text-align: center;
  font-size: clamp(28px, 6vw, 48px); font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.home .title { color: var(--ink); text-shadow: 0 3px 0 rgba(255,255,255,.6); }
.wave { display: inline-block; animation: wave 2s ease-in-out infinite; transform-origin: 70% 70%; font-family: var(--emoji); }

.world-grid {
  width: 100%; max-width: 1100px;
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  flex: 1;
}
.world-card {
  position: relative; overflow: hidden;
  border-radius: 32px;
  min-height: clamp(130px, 21vh, 320px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: #fff;
  box-shadow: 0 8px 0 rgba(0,0,0,.2);
  transition: transform .15s;
}
.world-card:active { transform: translateY(6px) scale(.98); box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.world-pattern {
  position: absolute; inset: -10px; font-size: 42px; opacity: .14; line-height: 1.3;
  word-break: break-all; pointer-events: none; font-family: var(--emoji);
}
.world-hero { font-size: clamp(70px, 14vw, 130px); animation: bob 2.4s ease-in-out infinite; position: relative; }
.world-name { font-size: clamp(24px, 4.5vw, 38px); font-weight: 900; text-shadow: 0 3px 0 rgba(0,0,0,.3); position: relative; }

.treasure-btn {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #facc15, #f97316);
  color: #fff; font-weight: 900; font-size: clamp(22px, 4vw, 30px);
  padding: 14px 30px; border-radius: 999px;
  box-shadow: 0 6px 0 #c2410c;
}
.treasure-btn span:first-child { font-size: 40px; font-family: var(--emoji); animation: wiggle 2.5s ease-in-out infinite; }
.treasure-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #c2410c; }
.treasure-label { text-shadow: 0 2px 0 rgba(0,0,0,.2); }

/* ---------- Choix du jeu ---------- */
.world-title .item-emoji, .world-title .item-img { font-size: 1.1em; }
.game-grid {
  width: 100%; max-width: 900px; flex: 1;
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: minmax(110px, min(calc((100dvh - 210px) / 4), 220px));
  align-content: center;
}
@media (min-aspect-ratio: 1/1) {
  .game-grid { max-width: 1200px; grid-template-columns: repeat(4, 1fr); grid-auto-rows: minmax(120px, min(calc((100dvh - 200px) / 2), 280px)); }
}
.game-card {
  background: #fff;
  border-radius: 28px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 8px 0 rgba(0,0,0,.2);
  border: 6px solid var(--c1);
}
.game-card:active { transform: translateY(6px); box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.game-preview { font-size: clamp(40px, min(10vw, 9dvh), 90px); display: flex; align-items: center; justify-content: center; position: relative; }
.game-name { font-size: clamp(18px, 3.5vw, 28px); font-weight: 900; color: var(--c2); }
.game-tool { font-size: .5em; position: absolute; right: -0.4em; bottom: -0.1em; }
.mini-cards { display: flex; gap: 6px; }
.mini-cards > span {
  width: .9em; height: 1.15em; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--c1), var(--c2)); font-size: .7em; font-family: var(--emoji);
  box-shadow: 0 3px 0 rgba(0,0,0,.2);
}
.mini-cards > span:last-child { background: #f3f4f6; transform: rotate(8deg); }
.count-preview { font-weight: 900; color: var(--c1); font-size: .7em; letter-spacing: .05em; }

/* ---------- Résultat / overlay ---------- */
#overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, .55);
  display: grid; place-items: center; padding: 16px;
  animation: fade .25s;
}
#overlay[hidden] { display: none; }
.result-card {
  background: #fff; border-radius: 36px; padding: clamp(20px, 5vw, 40px);
  width: min(100%, 460px);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  box-shadow: 0 12px 0 rgba(0,0,0,.2);
  animation: pop .4s cubic-bezier(.2, 1.6, .4, 1);
}
.result-stars { display: flex; gap: 8px; font-size: clamp(56px, 14vw, 84px); font-family: var(--emoji); }
.rstar { filter: grayscale(1) opacity(.3); }
.rstar.on { filter: none; animation: starIn .6s cubic-bezier(.2, 1.8, .4, 1) both; }
.result-text { font-size: clamp(30px, 7vw, 44px); font-weight: 900; color: var(--primary); }
.result-actions { display: flex; gap: 20px; }
.btn-big {
  width: 96px; height: 96px; border-radius: 28px;
  font-size: 50px; font-family: var(--emoji);
  display: grid; place-items: center;
  background: #e0f2fe; box-shadow: 0 6px 0 rgba(0,0,0,.18);
}
.btn-big:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.btn-replay, .btn-yes, .btn-go { background: #dcfce7; }
.btn-home { background: #fef9c3; }
.btn-no { background: #fee2e2; }
.confirm-sticker { font-size: 110px; font-family: var(--emoji); animation: bob 2s ease-in-out infinite; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti span { position: absolute; top: -50px; font-family: var(--emoji); animation: fall linear forwards; }

/* ---------- Memory ---------- */
.game { justify-content: center; }
.memory-grid {
  --size: min(calc((100vw - 60px) / var(--cols)), calc((100dvh - 140px) / 3), 170px);
  display: grid; gap: 12px;
  grid-template-columns: repeat(var(--cols), var(--size));
}
.mcard { width: var(--size); height: var(--size); perspective: 800px; padding: 0; }
.mcard-inner { position: relative; display: block; width: 100%; height: 100%; transition: transform .45s; transform-style: preserve-3d; }
.mcard.flipped .mcard-inner { transform: rotateY(180deg); }
.mcard-face {
  position: absolute; inset: 0; border-radius: 20px;
  display: grid; place-items: center;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 5px 0 rgba(0,0,0,.2);
  font-size: calc(var(--size) * .55);
}
.mcard-back {
  color: #fff; font-size: calc(var(--size) * .4); border: 5px solid #fff;
  background-image: radial-gradient(rgba(255,255,255,.25) 2px, transparent 2px) !important;
  background-size: 14px 14px !important;
}
.mcard-back > * { opacity: .9; filter: drop-shadow(0 2px 0 rgba(0,0,0,.25)); }
.mcard-front { background: #fff; transform: rotateY(180deg); }
.mcard.matched .mcard-front { background: #dcfce7; box-shadow: 0 0 0 5px var(--good), 0 5px 0 rgba(0,0,0,.2); animation: tada .6s; }

/* ---------- Attrape ---------- */
.game-catch { align-items: stretch; }
.catch-area {
  position: relative; flex: 1; min-height: 60dvh;
  border-radius: 28px; overflow: hidden;
  box-shadow: inset 0 0 0 6px rgba(255,255,255,.4);
  touch-action: none;
}
.catch-deco { position: absolute; left: 0; right: 0; bottom: 0; font-size: clamp(40px, 10vw, 80px); opacity: .35; text-align: center; white-space: nowrap; overflow: hidden; pointer-events: none; font-family: var(--emoji); }
.catch-score { position: absolute; top: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; z-index: 2; }
.catch-score .dot { width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,.5); border: 2px solid #fff; }
.catch-score .dot.hit { background: var(--star); transform: scale(1.2); }
.catch-score .dot.miss { background: rgba(0,0,0,.25); }
.catch-start { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; }
.btn-go { width: 140px; height: 140px; font-size: 80px; border-radius: 50%; animation: pulse 1.4s ease-in-out infinite; }
.target {
  position: absolute; z-index: 1;
  width: clamp(90px, 18vw, 140px); height: clamp(90px, 18vw, 140px);
  margin: calc(clamp(90px, 18vw, 140px) / -2) 0 0 calc(clamp(90px, 18vw, 140px) / -2);
  font-size: clamp(60px, 12vw, 100px);
  display: grid; place-items: center;
  animation: appear .35s cubic-bezier(.2, 1.6, .4, 1), bob 1.2s ease-in-out .35s infinite;
}
.target.gone { animation: vanish .35s forwards; }
.target.caught { animation: caught .5s forwards; }
.catch-tool {
  position: absolute; z-index: 2; pointer-events: none;
  font-size: clamp(70px, 14vw, 120px);
  transform: translate(-50%, -50%);
  animation: toolIn .5s ease-out forwards;
}

/* ---------- Compte ---------- */
.count-wrap, .shadow-wrap { width: 100%; max-width: 900px; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: space-around; gap: var(--gap); }
.progress-dots { display: flex; gap: 10px; }
.progress-dots span { width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,.5); border: 3px solid #fff; }
.progress-dots .done { background: var(--star); }
.progress-dots .now { background: #fff; transform: scale(1.25); }
.count-items {
  background: rgba(255,255,255,.9); border-radius: 28px; padding: 18px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  max-width: 640px; min-height: 140px; align-items: center;
  box-shadow: 0 6px 0 rgba(0,0,0,.15);
}
.count-item { font-size: clamp(54px, 11vw, 84px); position: relative; animation: appear .4s both; }
.count-item.counted { animation: tada .5s; }
.count-item.counted::after {
  content: attr(data-n);
  position: absolute; top: -6px; right: -6px;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 20px; font-weight: 900;
  display: grid; place-items: center; font-family: var(--font);
}
.answers, .shadow-choices { display: flex; gap: var(--gap); flex-wrap: wrap; justify-content: center; }
.answer {
  width: clamp(96px, 24vw, 150px); aspect-ratio: 1;
  background: #fff; border-radius: 28px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  box-shadow: 0 6px 0 rgba(0,0,0,.2);
}
.answer .num { font-size: clamp(48px, 11vw, 76px); font-weight: 900; line-height: 1; color: var(--primary); }
.num-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; max-width: 80%; }
.num-dots i { width: 10px; height: 10px; border-radius: 50%; background: #f59e0b; }
.answer:active, .shadow-choice:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.right { background: #dcfce7 !important; box-shadow: 0 0 0 6px var(--good), 0 6px 0 rgba(0,0,0,.2) !important; animation: tada .6s; }
.wrong { animation: shake .45s; opacity: .45; }

/* ---------- Ombres ---------- */
.shadow-target {
  background: rgba(255,255,255,.92); border-radius: 50%;
  width: clamp(170px, 40vw, 280px); aspect-ratio: 1;
  display: grid; place-items: center;
  font-size: clamp(110px, 26vw, 190px);
  box-shadow: 0 8px 0 rgba(0,0,0,.15);
}
.shadow-choice {
  width: clamp(92px, 22vw, 150px); aspect-ratio: 1;
  background: #fff; border-radius: 28px;
  font-size: clamp(56px, 13vw, 96px);
  display: grid; place-items: center;
  box-shadow: 0 6px 0 rgba(0,0,0,.2);
}

/* ---------- Aperçus des nouveaux jeux ---------- */
.colors-preview { display: flex; gap: 6px; }
.colors-preview i { width: .45em; height: .45em; border-radius: 50%; background: var(--col); box-shadow: 0 3px 0 rgba(0,0,0,.2); }
.size-preview { display: flex; align-items: flex-end; gap: 4px; }
.size-preview .sm { font-size: .5em; }
.puzzle-preview, .coloring-preview { font-family: var(--emoji); }

/* ---------- Couleurs ---------- */
.colors-wrap, .size-wrap, .puzzle-wrap, .coloring-wrap { width: 100%; max-width: 900px; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: space-around; gap: var(--gap); }
.colors-ask, .size-label {
  width: 90px; height: 90px; border-radius: 50%; background: #fff; font-size: 46px; font-family: var(--emoji);
  display: grid; place-items: center; box-shadow: 0 6px 0 rgba(0,0,0,.18); animation: pulse 1.6s ease-in-out infinite;
}
.colors-choices { display: grid; grid-template-columns: repeat(2, auto); gap: var(--gap); }
@media (min-aspect-ratio: 1/1) { .colors-choices { grid-template-columns: repeat(4, auto); } }
.color-blob {
  width: clamp(110px, 30vw, 170px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 30% 28%, rgba(255,255,255,.7) 0 12%, transparent 13%), var(--col);
  border: 6px solid #fff; box-shadow: 0 7px 0 rgba(0,0,0,.2);
  display: grid; place-items: center;
}
.color-deco { font-size: clamp(36px, 9vw, 56px); opacity: .9; }
.color-blob.right { background: radial-gradient(circle at 30% 28%, rgba(255,255,255,.7) 0 12%, transparent 13%), var(--col) !important; }

/* ---------- Grand / Petit ---------- */
.size-choices { display: flex; align-items: flex-end; justify-content: center; gap: var(--gap); flex-wrap: nowrap; min-height: 45vh; }
.size-choice {
  background: rgba(255,255,255,.92); border-radius: 28px; box-shadow: 0 6px 0 rgba(0,0,0,.18);
  font-size: calc(min(26vw, 30vh, 190px) * var(--k));
  padding: 10px; display: grid; place-items: center;
}

/* ---------- Puzzle ---------- */
.puzzle-board { position: relative; background: rgba(255,255,255,.9); border-radius: 20px; box-shadow: 0 6px 0 rgba(0,0,0,.18); flex: none; }
.puzzle-ghost { position: absolute; inset: 0; display: grid; place-items: center; line-height: 1; opacity: .18; filter: grayscale(1); pointer-events: none; font-family: var(--emoji); }
.puzzle-slot { position: absolute; border: 3px dashed rgba(0,0,0,.18); box-sizing: border-box; }
.puzzle-board.done { animation: tada .7s; box-shadow: 0 0 0 6px var(--good), 0 6px 0 rgba(0,0,0,.18); }
.puzzle-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; min-height: 80px; }
.piece {
  position: relative; overflow: hidden; flex: none;
  background: #fff; border-radius: 10px; box-shadow: 0 4px 0 rgba(0,0,0,.2);
  touch-action: none; cursor: grab; transition: transform .25s;
}
.piece.dragging { transition: none; z-index: 20; cursor: grabbing; box-shadow: 0 12px 20px rgba(0,0,0,.3); }
.piece.placed { position: absolute; border-radius: 0; box-shadow: none; cursor: default; animation: pop .3s; }
.piece-img { position: absolute; display: grid; place-items: center; line-height: 1; pointer-events: none; font-family: var(--emoji); }

/* ---------- Coloriage ---------- */
.coloring-svg {
  width: min(100%, calc((100dvh - 230px) * 4 / 3)); height: auto;
  background: #fff; border-radius: 20px; box-shadow: 0 6px 0 rgba(0,0,0,.18);
}
.coloring-svg .zone { fill: #fff; stroke: #1f2937; stroke-width: 3; stroke-linejoin: round; cursor: pointer; transition: fill .15s; }
.coloring-svg .zone.filled { animation: fillPop .3s; transform-box: fill-box; transform-origin: center; }
.coloring-svg .line { fill: none; stroke: #1f2937; stroke-width: 3; stroke-linecap: round; pointer-events: none; }
.coloring-svg .dot { fill: #1f2937; pointer-events: none; }
.palette { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; max-width: 720px; }
.swatch {
  width: clamp(44px, 11vw, 60px); aspect-ratio: 1; border-radius: 50%;
  background: var(--col); border: 4px solid #fff; box-shadow: 0 4px 0 rgba(0,0,0,.2);
}
.swatch.active { transform: scale(1.22); box-shadow: 0 0 0 4px #1f2937, 0 4px 0 rgba(0,0,0,.2); }
.swatch-done { width: clamp(54px, 13vw, 70px); aspect-ratio: 1; border-radius: 50%; background: #dcfce7; font-size: 34px; font-family: var(--emoji); box-shadow: 0 4px 0 rgba(0,0,0,.2); animation: pulse 1.4s ease-in-out infinite; }
.swatch-done[hidden] { display: none; }
@keyframes fillPop { 50% { transform: scale(1.04); } }

/* ---------- Album ---------- */
.album-tabs { display: flex; gap: 14px; }
.album-tab {
  width: 76px; height: 76px; border-radius: 22px; font-size: 44px;
  background: rgba(255,255,255,.55); display: grid; place-items: center;
  box-shadow: 0 5px 0 rgba(0,0,0,.15);
}
.album-tab.active { background: #fff; transform: scale(1.12); }
.sticker-grid {
  width: 100%; max-width: 820px;
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(40%, 130px), 1fr));
}
.sticker {
  aspect-ratio: 1; border-radius: 26px;
  background: rgba(255,255,255,.55);
  border: 4px dashed rgba(255,255,255,.9);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.sticker-emoji { font-size: clamp(50px, 11vw, 72px); font-family: var(--emoji); }
.sticker .silhouette { filter: brightness(0) opacity(.25); }
.sticker-cost { font-weight: 900; font-size: 20px; background: #fff; border-radius: 999px; padding: 2px 10px; }
.sticker.owned { background: #fff; border: 4px solid #fff; box-shadow: 0 6px 0 rgba(0,0,0,.18); }
.sticker.owned .sticker-emoji { animation: bob 3s ease-in-out infinite; }
.sticker.can-buy { border-color: var(--star); animation: glow 1.4s ease-in-out infinite; }
.sub-title { color: #fff; margin: 8px 0 0; font-size: 30px; text-shadow: 0 3px 0 rgba(0,0,0,.25); }
.reward-list { width: 100%; max-width: 620px; display: flex; flex-direction: column; gap: 10px; }
.reward { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 22px; padding: 10px 16px; box-shadow: 0 5px 0 rgba(0,0,0,.15); }
.reward.ready { box-shadow: 0 0 0 4px var(--star), 0 5px 0 rgba(0,0,0,.15); }
.reward-emoji { font-size: 44px; font-family: var(--emoji); }
.reward-body { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.reward-label { font-weight: 800; font-size: 18px; }
.reward-bar { height: 14px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.reward-bar span { display: block; height: 100%; background: linear-gradient(90deg, #facc15, #f97316); border-radius: 999px; }
.reward-cost { font-weight: 900; white-space: nowrap; }

/* ---------- Fin du temps ---------- */
.locked { justify-content: center; background: linear-gradient(180deg, #312e81, #1e1b4b); margin: -12px; padding: 20px; border-radius: 0; position: relative; }
body:has(.locked) { background: #1e1b4b; }
.locked-emoji { font-size: clamp(100px, 25vw, 180px); font-family: var(--emoji); animation: bob 3s ease-in-out infinite; }
.locked-sub { color: #e0e7ff; font-size: 28px; font-weight: 800; margin: 0; }
.locked-parent { position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px; }

/* ---------- Espace parents ---------- */
body.parent-mode { background: #f1f5f9 !important; -webkit-user-select: text; user-select: text; }
.parent { width: 100%; max-width: 1200px; margin: 0 auto; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: #0f172a; }
.parent h1 { font-size: 26px; margin: 0; }
.parent h2 { font-size: 18px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pin-screen { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 6vh; }
.pin-dots { display: flex; gap: 14px; min-height: 22px; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #334155; }
.pin-dots span.on { background: #334155; }
.pin-error { color: var(--bad); min-height: 1.2em; margin: 0; font-weight: 600; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; }
.pin-pad button { height: 76px; border-radius: 18px; background: #fff; font-size: 28px; font-weight: 600; box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.pin-pad button:active { background: #e2e8f0; }
.pin-pad .pin-ok { background: var(--primary); color: #fff; }
.link-btn { color: var(--primary); font-weight: 600; padding: 10px; }
.parent-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.parent-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.alert { background: #fef3c7; border: 1px solid #f59e0b; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: start; }
.card { background: #fff; border-radius: 16px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.big-stat { font-size: 30px; font-weight: 800; }
.progress { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progress span { display: block; height: 100%; background: var(--primary); }
.status { font-weight: 700; }
.status-on { color: #15803d; }
.status-off { color: #b91c1c; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn { padding: 10px 14px; border-radius: 10px; background: #e2e8f0; font-weight: 600; font-size: 15px; font-family: inherit; }
.btn:hover:not(:disabled) { filter: brightness(.95); }
.btn:disabled { opacity: .45; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: #16a34a; color: #fff; }
.btn-warn { background: #f59e0b; color: #fff; }
.btn-ghost { background: transparent; border: 1px solid #cbd5e1; }
.btn-small { padding: 6px 10px; font-size: 13px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
.form input:not([type=checkbox]):not([type=range]) { padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 10px; font-size: 16px; font-family: inherit; }
.form input[type=range] { width: 100%; accent-color: var(--primary); }
.form fieldset { border: 1px solid #e2e8f0; border-radius: 12px; padding: 10px 12px; margin: 0; }
.form legend { font-weight: 600; font-size: 14px; padding: 0 4px; }
.form .row { flex-direction: row; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > label { flex: 1; }
.form label.check { flex-direction: row; align-items: center; gap: 6px; flex: none; }
.form .w-emoji { width: 64px; text-align: center; }
.form .w-num { width: 90px; }
.form.row input[name=label], .form.row input[name=newPin] { flex: 1; min-width: 160px; }
.reward-admin, .history { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.reward-admin li { display: flex; align-items: center; gap: 8px; }
.r-emoji { font-size: 24px; font-family: var(--emoji); }
.r-label { flex: 1; }
.r-cost { font-weight: 700; white-space: nowrap; }
.history { max-height: 280px; overflow: auto; }
.history li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; font-size: 14px; align-items: baseline; }
.plus { color: #15803d; font-weight: 700; }
.minus { color: #b91c1c; font-weight: 700; }
.chart { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding-top: 18px; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
.bar { width: 100%; max-width: 36px; background: var(--primary); border-radius: 6px 6px 0 0; min-height: 2px; }
.bar-val { font-size: 12px; color: var(--muted); }
.bar-lbl { font-size: 12px; text-transform: capitalize; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); padding: 12px 20px; border-radius: 12px; color: #fff; font-weight: 600; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.ok { background: #16a34a; }
.toast.err { background: #dc2626; }
.toast[hidden] { display: none; }

/* ---------- Niveaux ---------- */
.lvl { display: inline-flex; gap: 4px; }
.lvl i { width: 12px; height: 12px; border-radius: 50%; background: #e5e7eb; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); }
.lvl i.on { background: var(--c1, var(--star)); }
.lvl.big { gap: 8px; }
.lvl.big i { width: 22px; height: 22px; }
.lvl.big i.on { background: var(--star); }
.lvl.up i.new { animation: levelPop 1s .6s cubic-bezier(.2, 1.8, .4, 1) both; box-shadow: 0 0 0 4px #fde68a; }
.level-up {
  display: flex; align-items: center; gap: 10px;
  font-size: clamp(26px, 6vw, 36px); font-weight: 900; color: #fff;
  background: linear-gradient(135deg, #22c55e, #16a34a); padding: 8px 22px; border-radius: 999px;
  box-shadow: 0 5px 0 rgba(0,0,0,.18); font-family: var(--font), var(--emoji);
  animation: pop .5s .5s cubic-bezier(.2, 1.6, .4, 1) both, pulse 1.4s 1.2s ease-in-out 3;
}

/* Attrape : taille et déplacement selon le niveau */
.target { --ts: 1; scale: var(--ts); }
.target.moving.move-0 { animation: appear .35s cubic-bezier(.2, 1.6, .4, 1), drift0 2.4s ease-in-out .35s infinite alternate; }
.target.moving.move-1 { animation: appear .35s cubic-bezier(.2, 1.6, .4, 1), drift1 2.2s ease-in-out .35s infinite alternate; }
.target.moving.move-2 { animation: appear .35s cubic-bezier(.2, 1.6, .4, 1), drift2 2.6s ease-in-out .35s infinite alternate; }
.target.moving.move-3 { animation: appear .35s cubic-bezier(.2, 1.6, .4, 1), drift3 2s ease-in-out .35s infinite alternate; }
.target.moving.gone { animation: vanish .35s forwards; }
.target.moving.caught { animation: caught .5s forwards; }
@keyframes drift0 { to { transform: translate(12vw, -6vh); } }
@keyframes drift1 { to { transform: translate(-12vw, 6vh); } }
@keyframes drift2 { to { transform: translate(10vw, 8vh); } }
@keyframes drift3 { to { transform: translate(-10vw, -8vh); } }
@keyframes levelPop { from { transform: scale(0); } 60% { transform: scale(1.5); } }

/* Ombres : beaucoup de choix, ombre retournée */
.shadow-many .shadow-choice { width: clamp(84px, 26vw, 130px); font-size: clamp(50px, 15vw, 82px); }
.shadow-many .shadow-target { width: clamp(150px, 34vw, 240px); font-size: clamp(96px, 22vw, 160px); }
.shadow-flip .shadow-target .silhouette { display: inline-block; transform: scaleX(-1); }

/* Couleurs : 5 ou 6 pastilles */
.colors-n5 .colors-choices, .colors-n6 .colors-choices { grid-template-columns: repeat(3, auto); }
.colors-n5 .color-blob, .colors-n6 .color-blob { width: clamp(88px, 26vw, 150px); }

/* Grand / Petit : la taille s'adapte au nombre d'objets */
.size-choice { font-size: calc(min(calc(88vw / var(--n, 3) - 34px), 30vh, 190px) * var(--k)); }

.level-admin { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.level-admin li { display: flex; align-items: center; gap: 8px; }
.level-admin .l-name { flex: 1; font-weight: 600; }
.l-dots { display: inline-flex; gap: 3px; margin-right: 4px; }
.l-dots i { width: 10px; height: 10px; border-radius: 50%; background: #e5e7eb; }
.l-dots i.on { background: #f59e0b; }

/* ---------- Petits écrans ---------- */
@media (max-width: 480px) {
  .btn-round { width: 46px; height: 46px; font-size: 22px; }
  .btn-lock { width: 38px; height: 38px; font-size: 17px; }
  .hud-spacer { width: 0; }
  .hud { gap: 6px; }
  .stars-pill { font-size: 20px; padding: 4px 12px 4px 8px; }
  .time-pill { padding: 6px 10px; }
  .time-icon { font-size: 18px; }
  .game-grid { gap: 12px; }
  .game-card { border-width: 4px; }
  .btn-big { width: 80px; height: 80px; font-size: 42px; }
}
/* Paysage sur téléphone : moins de hauteur */
@media (max-height: 500px) and (orientation: landscape) {
  .world-card { min-height: 52vh; }
  .title { font-size: 26px; }
  .memory-grid { --size: min(calc((100vw - 60px) / 6), calc((100dvh - 110px) / 2), 140px); grid-template-columns: repeat(calc(var(--cols) * 1), var(--size)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Animations ---------- */
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(18deg); } 20%, 40% { transform: rotate(-10deg); } }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-12deg); } 90% { transform: rotate(12deg); } 95% { transform: rotate(-6deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: .55; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }
@keyframes starIn { from { transform: scale(0) rotate(-180deg); } }
@keyframes tada { 0% { transform: scale(1); } 30% { transform: scale(1.18) rotate(-4deg); } 60% { transform: scale(1.1) rotate(4deg); } 100% { transform: scale(1); } }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
@keyframes appear { from { transform: scale(0); opacity: 0; } }
@keyframes vanish { to { transform: scale(0) rotate(90deg); opacity: 0; } }
@keyframes caught { 40% { transform: scale(1.3); } 100% { transform: scale(0) translateY(-40px); opacity: 0; } }
@keyframes toolIn { from { transform: translate(-50%, 120%) scale(.3); opacity: .4; } 70% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; } to { transform: translate(-50%, -50%) scale(1); opacity: 0; } }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, .7); } 50% { box-shadow: 0 0 0 10px rgba(250, 204, 21, 0); } }
