:root {
  color-scheme: light;
  --ink: #2a2118;
  --paper: #f6efe2;
  --card: #fffdf8;
  --moss: #174833;
  --honey: #f6c445;
  --sky: #9fd4f5;
  --line: #2a2118;
  --muted: #6d5c49;
  --good: #e5f6ee;
  --warm: #fff4e8;
  --calm: #f3eeff;
  --shadow: 4px 4px 0 var(--line);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 8% 0%, #ffe7a8 0 14rem, transparent 14.2rem),
    radial-gradient(circle at 100% 8%, #c7ebff 0 12rem, transparent 12.2rem),
    radial-gradient(#e4d3b4 1.1px, transparent 1.2px);
  background-size: auto, auto, 22px 22px;
  font-family: Nunito, "Segoe UI", sans-serif;
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.45;
}

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

h1, h2, h3, .brand span, .age-btn strong {
  font-family: Fraunces, Georgia, "Palatino Linotype", serif;
  font-weight: 560;
  line-height: 1.15;
  margin: 0;
}

h1 { font-size: clamp(2rem, 4.5vw, 3.3rem); }

h2 { font-size: clamp(1.45rem, 2.5vw, 2rem); }

p { margin: 0; }

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 5;
  background: white;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 10px;
}

.skip:focus { top: 12px; }

.boot {
  max-width: 40rem;
  margin: 3rem auto;
  padding: 0 1rem;
}

.page { min-height: 100vh; }

.top {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 4;
  padding: calc(12px + env(safe-area-inset-top)) 16px 0;
  background: var(--ink);
  color: #fff8ee;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.age-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0 0 12px;
}

.age-tab {
  border: 2px solid #fff8ee;
  border-radius: 999px;
  background: transparent;
  color: #fff8ee;
  padding: 8px 4px;
  font-weight: 800;
  font-size: 0.92rem;
  white-space: nowrap;
  text-align: center;
}

.age-tab[aria-selected="true"] {
  background: var(--honey);
  color: var(--ink);
  border-color: var(--honey);
}

.brand, .icon-btn, .age-chip, .star-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand, .icon-btn, .age-chip {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 4px;
}

.brand span { font-size: 1.35rem; }

.fox { width: 42px; height: 42px; display: block; }

.fox-lg { width: 108px; height: 108px; display: block; }

.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.icon-btn, .age-chip {
  border: 2px solid #fff8ee;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 800;
  font-size: 0.95rem;
}

.star-pill {
  background: var(--honey);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 800;
}

#contenu {
  width: min(1040px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 56px;
}

#contenu:focus { outline: none; }

.narrow { width: min(740px, 100%); margin: 0 auto; }

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}

.kicker {
  font-weight: 800;
  font-size: 0.98rem;
  color: #8a4b12;
  margin-bottom: 6px;
}

.lead { margin-top: 10px; font-size: 1.2rem; max-width: 38rem; }

.hello { margin-top: 12px; font-weight: 800; }

.ages {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 8px 0 22px;
}

.age-btn, .answer, .theme-card, .puzzle-row, .tile, .slot, .primary, .secondary, .daily button {
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--card);
}

.age-btn {
  text-align: left;
  padding: 18px 18px 16px;
  min-height: 112px;
}

.age-btn strong { display: block; font-size: 1.7rem; margin-bottom: 6px; }

.age-a, .level-1 { background: var(--honey); }

.age-b, .level-2 { background: var(--sky); }

.age-c { background: #d4c6f5; }

.age-d, .level-3 { background: #f6a08a; }

.levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 8px 0 22px;
}

.level-title { margin-bottom: 8px; }

.home-levels .age-btn {
  min-height: 0;
  padding: 14px 14px 12px;
}

.home-levels .age-btn strong { font-size: 1.35rem; }

.age-btn[aria-current="true"] { outline: 4px solid var(--moss); outline-offset: 2px; }

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.steps span {
  display: block;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.4rem;
}

.daily {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 22px 0;
  padding: 18px;
  background: #fff7d6;
  border: 3px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.daily h2 { margin: 2px 0 6px; }

.daily button, .primary, .secondary {
  padding: 12px 18px;
  font-weight: 800;
  min-height: 52px;
}

.primary { background: var(--moss); color: white; }

.secondary { background: var(--honey); }

.themes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.theme-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  padding: 16px;
  min-height: 180px;
}

.blob {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  border: 3px solid var(--line);
  font-size: 2rem;
  margin-bottom: 6px;
}

.teinte-miel .blob { background: var(--honey); }
.teinte-ciel .blob { background: var(--sky); }
.teinte-coquelicot .blob { background: #f6a08a; }
.teinte-lilas .blob { background: #d4c6f5; }
.teinte-mousse .blob { background: #a9d8c3; }
.teinte-charade .blob { background: #f6c445; }
.teinte-rebus .blob { background: #f6a08a; }
.teinte-enigme .blob { background: #d4c6f5; }

.t-nom { font-family: Fraunces, Georgia, serif; font-size: 1.45rem; }

.t-pitch, .t-meta, .parents p, .hint, .detail { color: var(--muted); }

.bar {
  display: block;
  width: 100%;
  height: 12px;
  margin-top: 8px;
  background: #efe2cc;
  border: 2px solid var(--line);
  border-radius: 99px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  width: calc(var(--p) * 100%);
  background: var(--moss);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.text-btn {
  border: 0;
  box-shadow: none;
  background: transparent;
  color: var(--moss);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 6px 0;
}

.liste {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.puzzle-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 14px 16px;
  min-height: 64px;
}

.mini-stars { letter-spacing: 2px; color: #8a5a00; font-size: 1.15rem; }

.tag {
  background: var(--calm);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.9rem;
}

.fox-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.bubble {
  flex: 1;
  background: white;
  border: 3px solid var(--line);
  border-radius: 22px 22px 22px 6px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.bubble p { font-size: 1.28rem; }

.meta { margin-bottom: 8px; }

.tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.tools .secondary, .tools .ghost {
  min-height: 48px;
}

.ghost {
  background: white;
  border: 3px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 10px 14px;
  font-weight: 800;
}

.scene {
  text-align: center;
  font-size: 2rem;
  margin: 6px 0 16px;
  letter-spacing: 0.03em;
}

.scene.eq {
  font-weight: 800;
  font-size: 2.2rem;
  letter-spacing: 0.08em;
}

.pile {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 280px;
  margin: 8px auto 16px;
  font-size: 2rem;
}

.charade {
  display: grid;
  gap: 8px;
  margin: 8px 0 16px;
}

.charade p {
  margin: 0;
  background: white;
  border: 3px solid var(--line);
  border-radius: 16px;
  padding: 10px 14px;
}

.rebus {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 8px 0 16px;
  font-size: 2rem;
  font-weight: 800;
}

.rebus span {
  background: white;
  border: 3px solid var(--line);
  border-radius: 16px;
  min-width: 64px;
  min-height: 64px;
  display: grid;
  place-items: center;
  padding: 8px 12px;
}

.rebus .plus {
  background: transparent;
  border: 0;
  min-width: 0;
  min-height: 0;
  padding: 0;
}

.seq {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 16px;
}

.seq span {
  min-width: 52px;
  min-height: 56px;
  padding: 6px;
  display: grid;
  place-items: center;
  background: white;
  border: 3px solid var(--line);
  border-radius: 16px;
  font-weight: 800;
  font-size: 1.35rem;
}

.seq .mystery { background: var(--honey); }

.choix { display: grid; gap: 12px; }

.choix.visuel { grid-template-columns: 1fr 1fr; }

.answer.compact { font-size: 1.8rem; }

.answer {
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  font-weight: 800;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.choix.visuel .answer {
  min-height: 108px;
  flex-direction: column;
}

.big-emoji { font-size: 2.5rem; line-height: 1; }

.answer.is-good, .slots.is-good .slot { background: var(--good); }

.answer.is-bad, .slots.is-bad .slot { background: #fde8e4; }

.slots, .bank {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 14px;
}

.slot, .tile {
  min-width: 56px;
  min-height: 58px;
  padding: 8px;
  font-weight: 800;
  font-size: 1.35rem;
  background: white;
}

.slot.empty {
  background: transparent;
  color: transparent;
}

.play-actions, .fin-actions, .badge-row, .confirm {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: white;
}

.feedback:focus { outline: 3px solid #3d8fd1; outline-offset: 3px; }

.feedback.ok { background: var(--good); }

.feedback.no { background: var(--warm); }

.feedback.reveal { background: var(--calm); }

.feedback p + p { margin-top: 6px; }

.got { font-size: 1.4rem; letter-spacing: 2px; color: #8a5a00; }

.hint {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: #e7f6ea;
  border-radius: 12px;
}

.hint:focus { outline: 3px solid #3d8fd1; }

.play { position: relative; }

.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -12px;
  left: calc(var(--i) * 6.25%);
  width: 10px;
  height: 14px;
  border-radius: 2px;
  animation: fall 900ms ease-in forwards;
  animation-delay: calc(var(--i) * 18ms);
}

.confetti i:nth-child(3n) { background: var(--honey); }
.confetti i:nth-child(3n + 1) { background: #e15a3a; }
.confetti i:nth-child(3n + 2) { background: #3d8fd1; }

.score {
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(2.4rem, 6vw, 4rem);
  margin: 8px 0;
}

.score span { display: block; font-family: Nunito, sans-serif; font-size: 1.1rem; font-weight: 800; }

.certificate {
  text-align: center;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 28px;
  box-shadow: inset 0 0 0 10px var(--honey), var(--shadow);
  padding: 42px 18px 28px;
}

.certificate .fox-lg { margin: 0 auto 8px; }

.badge-row { justify-content: center; margin-top: 16px; }

.badge-btn[aria-pressed="true"] { background: var(--honey); }

.level-head { margin: 22px 0 8px; font-size: 1.35rem; }

.parents {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 3px dashed #d9c7a8;
}

.parents h2 { font-size: 1.35rem; margin-bottom: 8px; }

.parents p + p { margin-top: 8px; }

.confirm p { margin-bottom: 8px; }

button:focus-visible, .skip:focus {
  outline: 3px solid #3d8fd1;
  outline-offset: 3px;
}

@media (hover: hover) {
  .age-btn:hover, .answer:hover, .theme-card:hover, .puzzle-row:hover,
  .tile:hover, .primary:hover, .secondary:hover, .daily button:hover, .ghost:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--line);
  }
}

.age-btn:active, .answer:active, .theme-card:active, .primary:active, .secondary:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--line);
}

button:disabled { cursor: default; transform: none; }

.answer:disabled:not(.is-good):not(.is-bad), .tile:disabled, .slot:disabled {
  opacity: 0.72;
}

@media (max-width: 700px) {
  .hero, .ages, .steps, .daily, .levels { grid-template-columns: 1fr; }
  .home-levels { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .home-levels .age-btn { padding: 10px 8px; }
  .home-levels .age-btn strong { font-size: 1rem; margin-bottom: 4px; }
  .home-levels .age-btn span { font-size: 0.82rem; }
  .hero { display: grid; }
  .hero-fox { order: -1; }
  .daily { flex-direction: column; align-items: flex-start; }
  .steps { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  .choix.visuel { grid-template-columns: 1fr; }
}

@keyframes fall {
  to { transform: translateY(340px) rotate(160deg); opacity: 0.2; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  body { background: white; }
  .top, .parents, .no-print, .badge-row { display: none !important; }
  .certificate { box-shadow: none; }
}
