:root {
  --bg: #fff8e1;
  --ink: #2b2b3a;
  --muted: #6b6b80;
  --card: #ffffff;
  --accent: #ff7a00;
  --accent-ink: #ffffff;
  --blue: #3b82f6;
  --line: #e9dfc0;
  --radius: 22px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Comic Sans MS", "Chalkboard SE", "Comic Neue", "Trebuchet MS", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.35;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 4px solid var(--blue); outline-offset: 2px; }

.screen { max-width: 1100px; margin: 0 auto; padding: 16px; }
.center { text-align: center; }
.title { font-size: clamp(1.8rem, 5vw, 2.8rem); margin: .4em 0 .2em; text-align: center; }
.lead { font-size: 1.3rem; color: var(--muted); margin: 0 0 1em; }

/* Barre du haut */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.chip {
  background: var(--card); border: 3px solid var(--line); border-radius: 999px;
  padding: 8px 18px; font-weight: 700;
}
.chip small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.chip:hover { border-color: var(--accent); }
.stars { font-weight: 700; font-size: 1.2rem; }

/* Profils */
.profiles { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; margin-bottom: 28px; }
.profile-card { position: relative; }
.profile {
  background: var(--card); border: 4px solid var(--line); border-radius: var(--radius);
  width: 170px; padding: 16px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform .15s, border-color .15s;
}
.profile:hover { transform: translateY(-4px) rotate(-1deg); border-color: var(--accent); }
.avatar { font-size: 3.6rem; line-height: 1.1; }
.pname { font-weight: 700; font-size: 1.25rem; }
.pstars { color: var(--muted); }
.tiny {
  position: absolute; top: 6px; right: 6px; border: 0; background: transparent;
  font-size: 1rem; opacity: .45; padding: 6px; border-radius: 50%;
}
.tiny:hover { opacity: 1; background: #fee2e2; }

.newprofile {
  background: var(--card); border: 4px dashed var(--line); border-radius: var(--radius);
  max-width: 460px; margin: 0 auto; padding: 18px 20px 22px;
}
.newprofile h2 { margin: 0 0 10px; font-size: 1.2rem; }
.newprofile input {
  width: 100%; padding: 12px 16px; border: 3px solid var(--line); border-radius: 14px; background: #fffdf5;
}
.avatars { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0; }
.avatar-pick {
  font-size: 2rem; width: 58px; height: 58px; border-radius: 16px; background: #fffdf5;
  border: 3px solid var(--line);
}
.avatar-pick.on { border-color: var(--accent); background: #fff0dc; transform: scale(1.08); }

/* Boutons */
.btn {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 16px;
  padding: 12px 22px; font-weight: 700; font-size: 1.1rem; box-shadow: 0 4px 0 #c25d00;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #c25d00; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.ghost { background: var(--card); color: var(--ink); border: 3px solid var(--line); box-shadow: none; }
.btn.big { font-size: 1.3rem; padding: 14px 28px; }
.btn.done { background: #2f9e44; box-shadow: 0 4px 0 #1f6f2f; width: 100%; margin-top: 12px; }
[hidden] { display: none !important; }

/* Accueil */
.tabs { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 12px 0 20px; }
.tab {
  background: var(--card); border: 3px solid var(--line); border-radius: 999px; padding: 10px 22px; font-weight: 700;
}
.tab.on { background: var(--blue); border-color: var(--blue); color: #fff; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px; }
.card {
  position: relative; background: var(--card); border: 4px solid var(--line); border-radius: var(--radius);
  padding: 12px 10px 14px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-4px) rotate(1deg); border-color: var(--accent); }
.card small { color: var(--muted); }
.thumb { width: 100%; aspect-ratio: 1; display: block; }
.thumb svg { width: 100%; height: 100%; }
.badge { position: absolute; top: 8px; right: 10px; font-size: 1.6rem; }

/* Galerie */
.gallery { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.work {
  position: relative; margin: 0; background: var(--card); border: 4px solid var(--line);
  border-radius: var(--radius); padding: 10px; text-align: center;
}
.work img { width: 100%; aspect-ratio: 1; border-radius: 12px; display: block; background: #fff; }
.work figcaption { display: flex; flex-direction: column; margin-top: 6px; }
.work figcaption small { color: var(--muted); }
.work .tiny { background: rgba(255, 255, 255, .85); }

/* Leçon */
.ltitle { margin: 0; font-size: clamp(1.4rem, 4vw, 2rem); }
.dots { display: flex; gap: 6px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.dots i.ok { background: #40c057; }
.dots i.now { background: var(--accent); transform: scale(1.3); }

.panels { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 860px) { .panels { grid-template-columns: 1fr 1fr; } }
.panel { background: var(--card); border: 4px solid var(--line); border-radius: var(--radius); padding: 14px; }
.steplabel { font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; font-size: .95rem; }
.svgbox { width: 100%; max-width: 440px; margin: 6px auto; aspect-ratio: 1; background: #fffdf5; border-radius: 16px; }
.svgbox svg { width: 100%; height: 100%; display: block; }
.instruction { font-size: 1.25rem; font-weight: 700; margin: 8px 0 12px; min-height: 3.2em; }
.nav { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.nav .btn { flex: 1 1 140px; }

/* Les traits du modèle */
svg .past { stroke: #343a40; stroke-width: 4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
svg .cur { stroke: #e8590c; stroke-width: 5.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
svg .cur > * { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.4s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { svg .cur > * { animation: none; stroke-dasharray: none; } }

/* Zone de dessin */
.tools { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 10px; }
.colors, .sizes, .actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); }
.swatch.on { box-shadow: 0 0 0 4px var(--ink); transform: scale(1.1); }
.size, .tool {
  width: 42px; height: 42px; border-radius: 12px; border: 3px solid var(--line); background: #fffdf5;
  display: grid; place-items: center; padding: 0; font-size: 1.2rem;
}
.size i { display: block; background: var(--ink); border-radius: 50%; }
.size.on, .tool.on { border-color: var(--accent); background: #fff0dc; }
#canvas {
  width: 100%; aspect-ratio: 1; display: block; background: #fff; border-radius: 16px;
  border: 3px solid var(--line); touch-action: none; cursor: crosshair;
}

/* Félicitations */
.overlay {
  position: fixed; inset: 0; background: rgba(30, 30, 50, .55); display: grid; place-items: center; padding: 16px; z-index: 10;
}
.modal { background: #fff; border-radius: 28px; padding: 26px; max-width: 440px; width: 100%; text-align: center; animation: pop .3s ease-out; }
.modal h2 { font-size: 2rem; margin: 4px 0; }
.party { font-size: 3rem; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
