:root {
  /* Little Coders Club — palette "espace geek", adoucie pour rester accueillante */
  --bg: #11142b;
  --bg-panel: #181d38;
  --bg-panel-2: #1e2444;
  --ink-deep: #0c0f22;
  --violet: #7c5cff;
  --mint: #4ce0b3;
  --sun: #ffb84c;
  --pink: #ff6ec7;
  --text: #f3f2ff;
  --text-soft: #c7cdf0;
  --text-mute: #8890b8;
  --line: #2d335a;
  --radius: 20px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Fredoka", "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse 60% 40% at 15% 0%, rgba(255,110,199,.14) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 85% 10%, rgba(76,224,179,.12) 0%, transparent 60%),
    radial-gradient(ellipse at 50% -10%, #232a52 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  position: relative;
}

h1 { font-family: "Space Grotesk", sans-serif; font-weight: 700; color: var(--text); }

/* --- floating pixel background (injected by byte.js, styled here) --- */
.lcc-field { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.lcc-pixel { position: absolute; border-radius: 50%; opacity: .55; animation: lcc-drift linear infinite alternate; }
.lcc-blob {
  position: absolute; border-radius: 50%; filter: blur(50px); opacity: .35;
  animation: lcc-blob-float ease-in-out infinite alternate;
}
@keyframes lcc-blob-float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(24px, -18px) scale(1.08); }
}
@keyframes lcc-drift { 0% { transform: translateY(0) rotate(0deg); } 100% { transform: translateY(-36px) rotate(90deg); } }
@keyframes lcc-twinkle { 0%, 100% { opacity: .2; } 50% { opacity: .8; } }

.topbar {
  position: relative; z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--ink-deep);
  border-bottom: 1px solid var(--line);
}

.logo {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo::before {
  content: "🧩";
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--violet), var(--mint));
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  box-shadow: 0 0 18px rgba(124,92,255,.45);
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.theme-badge {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--ink-deep);
  background: var(--sun);
  border-radius: 999px;
  padding: 5px 13px;
}

.logout-btn {
  background: transparent;
  border: 1px solid var(--violet);
  color: var(--text-soft);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.logout-btn:hover { background: var(--violet); color: white; }

.help-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-panel); border: 1px solid var(--line);
  color: var(--text-soft); font-size: .85rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s ease, transform .12s ease;
}
.help-btn:hover { border-color: var(--sun); transform: translateY(-1px); }

.screen { position: relative; z-index: 1; padding: 44px 24px; max-width: 1100px; margin: 0 auto; }

/* Garde-fou : quel que soit le display défini sur un écran (ex. .tutorial-screen
   utilise flex pour centrer son contenu), l'attribut [hidden] doit toujours gagner. */
.screen[hidden] { display: none !important; }

#theme-picker, #child-picker-screen, #language-screen { text-align: center; }

#theme-picker h1, #child-picker-screen h1, #language-screen h1 { font-size: 2rem; margin-bottom: 6px; }

.subtitle { color: var(--text-mute); margin-bottom: 32px; font-size: 1.02rem; }

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
}

.theme-card {
  background: var(--bg-panel);
  border: 2px solid var(--line);
  border-radius: 24px;
  padding: 26px 18px;
  cursor: pointer;
  text-align: center;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
  font-weight: 600;
  color: var(--text);
}

.theme-card:nth-child(5n+1) { border-color: rgba(76,224,179,.35); }
.theme-card:nth-child(5n+2) { border-color: rgba(124,92,255,.35); }
.theme-card:nth-child(5n+3) { border-color: rgba(255,110,199,.35); }
.theme-card:nth-child(5n+4) { border-color: rgba(255,184,76,.35); }
.theme-card:nth-child(5n+5) { border-color: rgba(76,224,179,.35); }

.theme-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: var(--mint);
  box-shadow: 0 16px 34px -10px rgba(76,224,179,.5);
}

.theme-card .emoji { font-size: 2.3rem; display: block; margin-bottom: 10px; filter: drop-shadow(0 0 10px rgba(124,92,255,.4)); }

.lang-grid { max-width: 620px; margin: 0 auto; }

#language-screen h1 { font-size: 1.35rem; max-width: 700px; margin: 0 auto 32px; color: var(--text); }

.section-label {
  font-family: "Space Grotesk", monospace;
  font-size: 0.75rem;
  color: var(--mint);
  letter-spacing: 0.06em;
  margin-right: 10px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 18px;
}

@media (max-width: 800px) {
  .workspace-grid { grid-template-columns: 1fr; }
}

.editor-panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.preview-panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.panel-header {
  font-family: "Space Grotesk", monospace;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pink);
  margin: 14px 0 6px;
}

.panel-header:first-child { margin-top: 0; color: var(--mint); }

textarea {
  width: 100%;
  height: 108px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--ink-deep);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  resize: vertical;
}

textarea:focus { outline: none; border-color: var(--mint); box-shadow: 0 0 0 3px rgba(76,224,179,.15); }

.run-btn {
  margin-top: 16px;
  width: 100%;
  background: linear-gradient(135deg, var(--mint), var(--sun));
  color: var(--ink-deep);
  border: none;
  padding: 14px;
  border-radius: 999px;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.02rem;
  cursor: pointer;
  box-shadow: 0 12px 28px -10px rgba(76,224,179,.5);
  transition: transform .15s ease;
}

.run-btn:hover { transform: translateY(-2px); }
.run-btn:active { transform: translateY(0) scale(.98); }

#preview-frame {
  width: 100%;
  height: 320px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  display: block;
}

.live-indicator {
  font-family: "Space Grotesk", monospace;
  font-size: 0.7rem;
  color: var(--mint);
}

.made-this-btn {
  margin-top: 14px;
  width: 100%;
  background: linear-gradient(135deg, var(--sun), var(--pink));
  color: var(--ink-deep);
  border: none;
  padding: 14px;
  border-radius: 999px;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 12px 28px -10px rgba(255,184,76,.55);
  animation: lcc-pop 0.4s ease both;
  transition: transform .15s ease;
}

.made-this-btn:hover { transform: translateY(-2px); }
.made-this-btn:active { transform: translateY(0) scale(.98); }

@keyframes lcc-pop {
  0% { transform: scale(0.85); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes lcc-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.tutor-panel {
  margin-top: 22px;
  background: var(--ink-deep);
  border: 1px solid var(--violet);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: 0 0 30px -14px rgba(124,92,255,.5);
}

.tutor-header {
  font-family: "Space Grotesk", monospace;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--violet);
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.tutor-response {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg-panel);
  border-left: 3px solid var(--mint);
  border-radius: 0 10px 10px 0;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.tutor-response::before { content: "> "; color: var(--mint); font-weight: 700; }

.tutor-response::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 15px;
  background: var(--mint);
  margin-left: 4px;
  vertical-align: -2px;
  animation: lcc-blink 1s step-end infinite;
}

.quick-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.quick-question-chip {
  background: var(--bg-panel);
  border: 1px solid var(--violet);
  color: var(--text-soft);
  padding: 7px 13px;
  border-radius: 999px;
  font-family: "Space Grotesk", monospace;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.quick-question-chip:hover { background: var(--violet); color: white; }

.tutor-controls input {
  flex: 1;
  min-width: 200px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.85rem;
  background: var(--bg-panel);
  color: var(--text);
  margin-bottom: 10px;
  width: 100%;
}

.tutor-controls input:focus { outline: none; border-color: var(--mint); }

.hint-levels { display: flex; gap: 8px; flex-wrap: wrap; }

.hint-btn {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, color .15s ease;
}
.hint-btn:hover { transform: translateY(-2px); }

.hint-btn:nth-of-type(1) { background: var(--mint); color: var(--ink-deep); border: none; }
.hint-btn:nth-of-type(2) { background: var(--bg-panel); color: var(--violet); border: 1px solid var(--violet); }
.hint-btn:nth-of-type(2):hover { background: var(--violet); color: white; }
.hint-btn:nth-of-type(3) { background: var(--bg-panel); color: var(--sun); border: 1px solid var(--sun); }
.hint-btn:nth-of-type(3):hover { background: var(--sun); color: var(--ink-deep); }

.auth-card {
  max-width: 380px;
  margin: 0 auto;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px;
  text-align: left;
}

.auth-card h1 { font-size: 1.5rem; }

.auth-card input {
  width: 100%;
  padding: 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--ink-deep);
  color: var(--text);
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.auth-card input:focus { outline: none; border-color: var(--mint); }

.auth-buttons { display: flex; gap: 10px; }

.secondary-btn {
  flex: 1;
  background: transparent;
  border: 1px solid var(--violet);
  color: var(--violet);
  padding: 12px;
  border-radius: 999px;
  font-weight: 600;
  font-family: "Space Grotesk", sans-serif;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.secondary-btn:hover { background: var(--violet); color: white; }

.auth-buttons .run-btn { flex: 1; margin-top: 0; }

.auth-error {
  color: var(--pink);
  font-size: 0.85rem;
  margin-top: 10px;
  font-weight: 600;
}

.add-child-card { margin-top: 24px; }

.challenge-banner {
  background: var(--bg-panel);
  border: 1px solid var(--sun);
  border-radius: 12px;
  padding: 13px 18px;
  margin-bottom: 16px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--sun);
}

/* --- Byte, la mascotte robot du tuteur IA --- */
.byte-wrap {
  position: fixed; right: 22px; bottom: 22px; z-index: 6;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}

.byte-bubble {
  background: var(--bg-panel-2);
  border: 1px solid var(--line);
  border-radius: 14px 14px 4px 14px;
  padding: 12px 16px;
  max-width: 230px;
  font-family: "Fredoka", sans-serif;
  font-size: .85rem;
  color: var(--text);
  box-shadow: 0 10px 26px rgba(0,0,0,.4);
  opacity: 0; transform: translateY(6px) scale(.96);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
}
.byte-bubble.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.byte-bubble b { color: var(--mint); }

.byte-row { display: flex; align-items: center; gap: 8px; }

.byte-mute-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg-panel); border: 1px solid var(--line);
  color: var(--text-soft); font-size: .85rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s ease, transform .12s ease;
}
.byte-mute-btn:hover { border-color: var(--mint); transform: translateY(-1px); }
.byte-mute-btn.muted { color: var(--text-mute); }

.byte {
  width: 60px; height: 60px; cursor: pointer;
  animation: lcc-float 3.2s ease-in-out infinite;
}
@keyframes lcc-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

.byte-body {
  position: relative; width: 100%; height: 100%;
  background: linear-gradient(160deg, var(--bg-panel), var(--bg-panel-2));
  border: 2px solid var(--violet);
  border-radius: 28px;
  box-shadow: 0 0 22px rgba(124,92,255,.45), inset 0 0 14px rgba(124,92,255,.12);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.byte-body.byte-speaking {
  border-color: var(--mint);
  box-shadow: 0 0 30px rgba(76,224,179,.65), inset 0 0 16px rgba(76,224,179,.18);
}
.byte-antenna {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  width: 2px; height: 11px; background: var(--line);
}
.byte-antenna::after {
  content: ''; position: absolute; top: -5px; left: 50%; transform: translateX(-50%);
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--sun); box-shadow: 0 0 9px var(--sun);
  animation: lcc-twinkle 1.6s ease-in-out infinite;
}
.byte-eyes { position: absolute; top: 22px; left: 0; right: 0; display: flex; justify-content: center; gap: 11px; }
.byte-eye {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--mint); box-shadow: 0 0 7px var(--mint);
  animation: lcc-blink-eye 4.5s infinite;
}
@keyframes lcc-blink-eye { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.byte-mouth {
  position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%);
  width: 18px; height: 9px;
  border: 3px solid transparent;
  border-bottom-color: var(--sun);
  border-radius: 0 0 50% 50%;
  background: transparent;
  opacity: .9;
  transition: height .1s ease, width .1s ease;
}
.byte-body.byte-speaking .byte-mouth {
  border-bottom-color: var(--mint);
  animation: lcc-talk .32s ease-in-out infinite alternate;
}
@keyframes lcc-talk {
  0% { height: 6px; width: 18px; }
  100% { height: 11px; width: 13px; }
}

/* joues roses — pour un visage attachant plutôt qu'un robot froid */
.byte-body::before, .byte-body::after {
  content: "";
  position: absolute; top: 30px;
  width: 8px; height: 5px; border-radius: 50%;
  background: var(--pink); opacity: .55;
  filter: blur(1px);
}
.byte-body::before { left: 8px; }
.byte-body::after { right: 8px; }

/* RTL support: keep code editors and preview always LTR regardless of UI language */
[dir="rtl"] #html-editor,
[dir="rtl"] #css-editor,
[dir="rtl"] #preview-frame,
[dir="rtl"] .tutor-response {
  direction: ltr;
  text-align: left;
}

[dir="rtl"] .auth-card { text-align: right; }
[dir="rtl"] .byte-wrap { right: auto; left: 22px; align-items: flex-start; }
[dir="rtl"] .byte-bubble { border-radius: 14px 14px 14px 4px; }

/* ==========================================================
   Écran tutoriel — "Comment ça marche ?"
   ========================================================== */

.tutorial-screen {
  position: relative;
  min-height: calc(100vh - 60px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  max-width: 560px;
  padding-top: 20px;
}

.tut-skip {
  position: absolute; top: 0; right: 24px;
  background: var(--bg-panel); border: 1px solid var(--line); cursor: pointer;
  color: var(--text-soft); font-family: "Space Grotesk", sans-serif;
  font-weight: 500; font-size: .82rem; padding: 8px 16px;
  border-radius: 999px;
  transition: border-color .15s ease, color .15s ease, transform .12s ease;
}
.tut-skip:hover { border-color: var(--sun); color: var(--text); transform: translateY(-1px); }
[dir="rtl"] .tut-skip { right: auto; left: 24px; }

.tut-dots { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 30px; }
.tut-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); transition: background .2s ease, box-shadow .2s ease, width .2s ease; }
.tut-dot.on { background: var(--violet); box-shadow: 0 0 10px var(--violet); width: 20px; border-radius: 4px; }

.tut-stage {
  width: 100%; max-width: 320px; height: 190px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 28px;
  overflow: hidden;
  position: relative;
}

.tut-title { font-size: 1.5rem; margin-bottom: 10px; }
.tut-text {
  color: var(--text-soft); font-size: 1rem; line-height: 1.55;
  min-height: 3.2em; max-width: 420px;
}

.tut-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 26px; width: 100%; max-width: 320px; }
.tut-nav .tut-prev { flex: 0 0 56px; padding: 12px; }
.tut-nav .tut-next { flex: 1; margin-top: 0; }

/* --- step 1: logo qui pulse --- */
.tut-logo-pulse {
  width: 84px; height: 84px; border-radius: 22px;
  background: linear-gradient(135deg, var(--violet), var(--mint));
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem;
  animation: tut-pulse 1.8s ease-in-out infinite;
}
@keyframes tut-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 26px rgba(124,92,255,.45); }
  50% { transform: scale(1.08); box-shadow: 0 0 42px rgba(76,224,179,.6); }
}

/* --- step 2: chips de thèmes --- */
.tut-chips { display: flex; gap: 10px; }
.tut-chip {
  width: 46px; height: 46px; border-radius: 14px;
  background: var(--bg-panel-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  animation: tut-chip-light 2.4s ease-in-out infinite;
}
.tut-chip:nth-child(1) { animation-delay: 0s; }
.tut-chip:nth-child(2) { animation-delay: .18s; }
.tut-chip:nth-child(3) { animation-delay: .36s; }
.tut-chip:nth-child(4) { animation-delay: .54s; }
.tut-chip:nth-child(5) { animation-delay: .72s; }
@keyframes tut-chip-light {
  0%, 70%, 100% { border-color: var(--line); box-shadow: none; transform: translateY(0); }
  20% { border-color: var(--mint); box-shadow: 0 0 16px rgba(76,224,179,.5); transform: translateY(-6px); }
}

/* --- step 3: ligne de code qui s'écrit --- */
.tut-code-box {
  width: 240px; padding: 16px 18px; border-radius: 12px;
  background: var(--ink-deep); border: 1px solid var(--line);
  text-align: left;
}
.tut-code-line {
  font-family: "JetBrains Mono", monospace; font-size: .95rem; color: var(--mint);
}
.tut-code-line::after {
  content: ""; display: inline-block; width: 7px; height: 1.1em; background: var(--mint);
  margin-left: 3px; vertical-align: -2px; animation: lcc-blink 1s step-end infinite;
}

/* --- step 4: bouton Run -> monde qui apparaît --- */
.tut-run-row { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.tut-run-fake {
  font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: .95rem;
  color: var(--ink-deep); background: linear-gradient(135deg, var(--mint), var(--sun));
  border-radius: 999px; padding: 11px 26px;
  animation: tut-run-pulse 2.2s ease-in-out infinite;
}
@keyframes tut-run-pulse {
  0%, 40%, 100% { transform: scale(1); box-shadow: 0 8px 20px -8px rgba(76,224,179,.4); }
  55% { transform: scale(.93); box-shadow: 0 4px 10px -6px rgba(76,224,179,.5); }
}
.tut-world-pop {
  font-size: 1.8rem; opacity: 0; transform: scale(.4);
  animation: tut-world-pop 2.2s ease-in-out infinite;
}
@keyframes tut-world-pop {
  0%, 55% { opacity: 0; transform: scale(.4); }
  70% { opacity: 1; transform: scale(1.15); }
  85%, 100% { opacity: 1; transform: scale(1); }
}

/* --- step 5: Byte qui aide --- */
.tut-byte-row { display: flex; align-items: center; gap: 16px; }
.tut-mini-byte {
  width: 58px; height: 58px; position: relative;
  animation: lcc-float 3.2s ease-in-out infinite;
}
.tut-bulb {
  font-size: 1.7rem;
  animation: tut-bulb-glow 1.8s ease-in-out infinite;
}
@keyframes tut-bulb-glow {
  0%, 100% { opacity: .5; transform: translateY(0) scale(1); filter: drop-shadow(0 0 0 transparent); }
  50% { opacity: 1; transform: translateY(-5px) scale(1.12); filter: drop-shadow(0 0 10px rgba(255,184,76,.7)); }
}

/* --- step 6: fusée qui décolle --- */
.tut-rocket {
  font-size: 3rem;
  animation: tut-launch 2.4s ease-in-out infinite;
}
@keyframes tut-launch {
  0% { transform: translateY(30px) rotate(0deg); opacity: .3; }
  55% { transform: translateY(-6px) rotate(-4deg); opacity: 1; }
  100% { transform: translateY(-60px) rotate(6deg); opacity: 0; }
}

/* ==========================================================
   Écran de choix de niveau — catégorisation par compétence
   ========================================================== */

.back-btn {
  position: absolute; top: 0; left: 0;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg-panel); border: 1px solid var(--line);
  color: var(--text-soft); font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s ease, transform .12s ease;
}
.back-btn:hover { border-color: var(--mint); transform: translateX(-2px); }
[dir="rtl"] .back-btn { left: auto; right: 0; transform: scaleX(-1); }
[dir="rtl"] .back-btn:hover { transform: scaleX(-1) translateX(-2px); }

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}

.level-card {
  position: relative;
  background: var(--bg-panel);
  border: 2px solid var(--line);
  border-radius: 22px;
  padding: 20px 16px 16px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.level-card:nth-child(5n+1) { border-color: rgba(76,224,179,.35); }
.level-card:nth-child(5n+2) { border-color: rgba(124,92,255,.35); }
.level-card:nth-child(5n+3) { border-color: rgba(255,110,199,.35); }
.level-card:nth-child(5n+4) { border-color: rgba(255,184,76,.35); }
.level-card:nth-child(5n+5) { border-color: rgba(76,224,179,.35); }

.level-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: var(--mint);
  box-shadow: 0 16px 34px -10px rgba(76,224,179,.5);
}

.level-card .level-num {
  position: absolute; top: 10px; right: 12px;
  font-family: "Space Grotesk", monospace;
  font-size: .7rem; font-weight: 700;
  color: var(--text-mute);
  background: var(--ink-deep);
  border-radius: 999px;
  padding: 3px 9px;
}
[dir="rtl"] .level-card .level-num { right: auto; left: 12px; }

.level-card .emoji { font-size: 2rem; margin-top: 4px; filter: drop-shadow(0 0 10px rgba(124,92,255,.35)); }
.level-card .level-name { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.level-card .level-skill { font-size: .8rem; color: var(--text-mute); min-height: 2.2em; }
.level-card .level-preview { font-size: 1rem; letter-spacing: 2px; margin-top: 4px; opacity: .8; }

.level-card-classics {
  background: linear-gradient(160deg, var(--bg-panel), var(--bg-panel-2));
  border-color: var(--sun) !important;
}

/* ==========================================================
   Panneau de mission par étapes (1, 2, 3...)
   ========================================================== */

.steps-panel {
  background: var(--bg-panel);
  border: 2px solid var(--mint);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.steps-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: .95rem;
  color: var(--mint);
  margin-bottom: 10px;
}

.steps-count {
  font-family: "Space Grotesk", monospace;
  font-size: .8rem;
  color: var(--text-mute);
  background: var(--ink-deep);
  border-radius: 999px;
  padding: 3px 12px;
}

.steps-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .92rem;
  color: var(--text-soft);
  transition: color .2s ease;
}

.step-item .step-num {
  flex: 0 0 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ink-deep);
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: .75rem;
  color: var(--text-mute);
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.step-item.done {
  color: var(--text);
}

.step-item.done .step-num {
  background: var(--mint);
  border-color: var(--mint);
  color: var(--ink-deep);
}

/* Name screen */
.name-emoji { font-size: 3.5rem; text-align: center; animation: lcc-float 3s ease-in-out infinite; }
@keyframes lcc-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
