*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #07080f;
  --surface: #0d1117;
  --card: #111827;
  --card-hover: #1a2235;
  --border: #1f2d44;
  --border-bright: #2d4060;
  --text: #e8f0ff;
  --text-dim: #7b8fb5;
  --text-muted: #4a5a7a;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 25px 50px rgba(0,0,0,.6);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 15% 10%, rgba(59,130,246,.07) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 85% 90%, rgba(139,92,246,.07) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#app { position: relative; z-index: 1; min-height: 100vh; }

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
}

/* ─── UTILITIES ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .75rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .9rem 1.8rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all .2s ease;
  text-decoration: none;
}

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

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  box-shadow: 0 8px 20px rgba(99,102,241,.35);
}
.btn-primary:hover { box-shadow: 0 12px 28px rgba(99,102,241,.5); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { border-color: var(--border-bright); color: var(--text); }

.btn-sm { padding: .6rem 1.2rem; font-size: .9rem; }

/* ─── HOME ──────────────────────────────────────────────── */
.home-screen {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}

.home-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100vh;
}

.home-mascot-col {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.home-mascot {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 0 60px rgba(59,130,246,.15));
  animation: float 5s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.home-content-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 2.5rem 3rem 2rem;
}

.home-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: rgba(99,102,241,.15);
  color: #818cf8;
  border: 1px solid rgba(99,102,241,.3);
  padding: .35rem .9rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  width: fit-content;
}

.home-title {
  font-size: clamp(2.8rem, 5vw, 4.5rem);
  font-weight: 900;
  background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 50%, #f472b6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: left;
  line-height: 1.1;
  margin-bottom: .8rem;
}

.home-sub {
  color: var(--text-dim);
  text-align: left;
  font-size: 1rem;
  max-width: 480px;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.home-section-title {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  width: 100%;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  width: 100%;
  max-width: 820px;
  margin-bottom: 1.5rem;
}

.level-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  cursor: pointer;
  transition: all .25s ease;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.level-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--level-color);
  opacity: 0;
  transition: opacity .25s;
}

.level-card:hover {
  transform: translateY(-6px);
  border-color: var(--level-color);
  box-shadow: 0 20px 40px rgba(0,0,0,.5), 0 0 0 1px var(--level-color), 0 0 40px var(--level-glow);
}

.level-card:hover::before { opacity: .05; }

.level-card .card-content { position: relative; z-index: 1; }
.level-icon { font-size: 2.5rem; margin-bottom: .8rem; }
.level-name {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: .4rem;
  color: var(--level-color);
}
.level-desc { font-size: .88rem; color: var(--text-dim); line-height: 1.5; }

.home-actions {
  display: flex;
  gap: 1rem;
  margin-top: .5rem;
}

/* ─── CATEGORIES ────────────────────────────────────────── */
.cats-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1.5rem 3rem;
  min-height: 100vh;
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 860px;
  margin-bottom: 2.5rem;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  padding: .5rem 1rem;
  cursor: pointer;
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 600;
  transition: all .2s;
}
.back-btn:hover { border-color: var(--border-bright); color: var(--text); }

.screen-title { font-size: 1.6rem; font-weight: 800; }
.screen-title span { color: var(--text-dim); font-weight: 500; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  width: 100%;
  max-width: 860px;
}

.cat-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  transition: all .25s ease;
  position: relative;
  overflow: hidden;
}

.cat-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--cat-color);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s ease;
}

.cat-card:hover {
  transform: translateY(-5px);
  border-color: var(--cat-color);
  box-shadow: 0 16px 32px rgba(0,0,0,.5), 0 0 30px var(--cat-glow);
}

.cat-card:hover::after { transform: scaleX(1); }

.cat-icon { font-size: 2.2rem; margin-bottom: .75rem; display: block; }
.cat-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--cat-color);
  margin-bottom: .3rem;
}
.cat-desc { font-size: .82rem; color: var(--text-dim); line-height: 1.45; }
.cat-count {
  margin-top: .75rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.cat-card.mix-card {
  --cat-color: #a78bfa;
  --cat-glow: rgba(167,139,250,.15);
  border-style: dashed;
  border-color: #2d3a55;
}

/* ─── QUIZ ──────────────────────────────────────────────── */
.quiz-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1.25rem 3rem;
  min-height: 100vh;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

.quiz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.quiz-badges { display: flex; gap: .5rem; flex-wrap: wrap; }

.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: color-mix(in srgb, var(--c) 15%, transparent);
  color: var(--c);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  padding: .3rem .75rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
}

.level-badge {
  padding: .3rem .75rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
}
.level-badge.debutant { background: rgba(34,197,94,.15); color: #22c55e; }
.level-badge.intermediaire { background: rgba(245,158,11,.15); color: #f59e0b; }
.level-badge.expert { background: rgba(239,68,68,.15); color: #ef4444; }

.quiz-stats {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .9rem;
  font-weight: 700;
}
.score-stat { color: #fbbf24; }
.streak-stat { color: #f97316; }

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  margin-bottom: .5rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--progress-color, #3b82f6);
  transition: width .4s cubic-bezier(.34,1.56,.64,1);
}

.progress-label {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 600;
  width: 100%;
  text-align: right;
  margin-bottom: 2rem;
}

.question-card {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  margin-bottom: 1.5rem;
}

.question-num {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

.question-text {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 600;
  line-height: 1.55;
  color: var(--text);
}

.answers {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  width: 100%;
  margin-bottom: 1.25rem;
}

.answer-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1rem 1.25rem;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  color: var(--text);
  text-align: left;
  transition: all .18s ease;
  position: relative;
  overflow: hidden;
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--progress-color, #3b82f6);
  background: var(--card-hover);
  transform: translateX(4px);
}

.answer-btn:disabled { cursor: default; }

.answer-btn.correct {
  border-color: #22c55e;
  background: rgba(34,197,94,.12);
  animation: correctPulse .4s ease;
}

.answer-btn.wrong {
  border-color: #ef4444;
  background: rgba(239,68,68,.12);
  animation: shake .4s ease;
}

.answer-btn.dimmed {
  opacity: .35;
}

@keyframes correctPulse {
  0% { transform: scale(1); }
  30% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.answer-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--border);
  font-size: .8rem;
  font-weight: 800;
  flex-shrink: 0;
  transition: background .18s;
}

.answer-btn.correct .answer-letter { background: #22c55e; color: #fff; }
.answer-btn.wrong .answer-letter { background: #ef4444; color: #fff; }

.answer-text {
  font-size: .95rem;
  font-weight: 500;
  line-height: 1.4;
}

.explanation {
  width: 100%;
  border-radius: var(--radius-sm);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  animation: slideUp .3s ease;
  line-height: 1.6;
  font-size: .92rem;
}

.explanation.correct {
  background: rgba(34,197,94,.08);
  border: 1px solid rgba(34,197,94,.3);
}

.explanation.wrong {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.3);
}

.exp-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  margin-bottom: .5rem;
  font-size: .9rem;
}

.explanation.correct .exp-header { color: #4ade80; }
.explanation.wrong .exp-header { color: #f87171; }

.exp-body { color: var(--text-dim); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.btn-next {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s ease;
  box-shadow: 0 8px 20px rgba(99,102,241,.3);
}
.btn-next:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(99,102,241,.45); }

/* ─── RESULTS ───────────────────────────────────────────── */
.results-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1.5rem;
  min-height: 100vh;
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}

.result-mascot {
  width: 140px;
  height: 210px;
  object-fit: cover;
  object-position: center top;
  border-radius: 999px;
  border: 3px solid var(--border-bright);
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  margin-bottom: 1rem;
  animation: bounce .6s ease;
}

.result-trophy { font-size: 4rem; margin-bottom: .5rem; }

@keyframes bounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  30% { transform: translateY(-20px) rotate(-5deg); }
  60% { transform: translateY(-10px) rotate(5deg); }
}

.result-rating {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: .5rem;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-score {
  font-size: clamp(4rem, 12vw, 7rem);
  font-weight: 900;
  line-height: 1;
  margin-bottom: .25rem;
}

.result-total { font-size: 1.1rem; color: var(--text-dim); margin-bottom: .5rem; }

.result-meta {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.result-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem 1.5rem;
}
.result-stat-val { font-size: 1.6rem; font-weight: 900; }
.result-stat-label { font-size: .75rem; color: var(--text-muted); font-weight: 600; margin-top: .15rem; }

.result-answers {
  width: 100%;
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  text-align: left;
}

.result-answer-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  font-size: .85rem;
}

.result-answer-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: .05rem; }
.result-answer-q { font-weight: 600; margin-bottom: .2rem; color: var(--text); }
.result-answer-info { color: var(--text-dim); font-size: .8rem; }

.result-actions {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  width: 100%;
  max-width: 400px;
  margin-top: 1rem;
}

/* ─── STATS ─────────────────────────────────────────────── */
.stats-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1.5rem 3rem;
  min-height: 100vh;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  width: 100%;
  max-width: 860px;
}

.stats-cat-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.stats-cat-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1rem;
}

.stats-cat-icon { font-size: 1.4rem; }

.stats-levels {
  display: flex;
  flex-direction: column;
}

.stats-level-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .7rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.stats-level-row:last-child { border-bottom: none; }

.stats-level-name { font-weight: 600; color: var(--text-dim); }
.stats-best {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-weight: 800;
}

.stats-score-bar {
  flex: 1;
  margin: 0 1rem;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.stats-score-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  transition: width .6s ease;
}

.stats-empty {
  padding: .7rem 1.25rem;
  font-size: .82rem;
  color: var(--text-muted);
}

/* ─── RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 860px) {
  .home-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .home-mascot-col {
    position: relative;
    display: flex;
    justify-content: center;
    padding: 1.5rem 1.5rem 0;
  }
  .home-mascot {
    width: 220px;
    height: auto;
  }
  .home-content-col {
    padding: 2rem 1.25rem 3rem;
    align-items: center;
    text-align: center;
  }
  .home-title { text-align: center; }
  .home-sub { text-align: center; }
  .home-section-title { text-align: center; }
  .home-badge { align-self: center; }
}

@media (max-width: 600px) {
  .quiz-screen { padding: 1rem 1rem 2.5rem; }
  .question-card { padding: 1.5rem 1.25rem; }
  .level-grid { grid-template-columns: 1fr; }
  .cat-grid { grid-template-columns: 1fr 1fr; }
  .result-meta { gap: .75rem; }
}

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

/* ─── TECH TERMS ────────────────────────────────────────── */
.tech-term {
  color: #7dd3fc;
  border-bottom: 1.5px dashed #3b82f6;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  border-radius: 2px;
}

.tech-term:hover,
.tech-term:focus {
  color: #bae6fd;
  border-bottom-color: #7dd3fc;
  outline: none;
  background: rgba(59,130,246,.08);
}

.tech-term-demo {
  color: #7dd3fc;
  border-bottom: 1.5px dashed #3b82f6;
  font-style: italic;
}

.exp-hint {
  margin-top: .75rem;
  font-size: .78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ─── MODAL ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 1.5rem;
  animation: fadeIn .2s ease;
}

.modal-card {
  background: #131c2e;
  border: 1.5px solid #2d4060;
  border-radius: 20px;
  padding: 2rem 2rem 1.75rem;
  max-width: 440px;
  width: 100%;
  position: relative;
  animation: modalIn .25s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 30px 70px rgba(0,0,0,.7), 0 0 0 1px rgba(59,130,246,.1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.92) translateY(12px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--border);
  border: none;
  color: var(--text-dim);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--border-bright); color: var(--text); }

.modal-cat {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: rgba(59,130,246,.12);
  color: #60a5fa;
  border: 1px solid rgba(59,130,246,.25);
  padding: .25rem .7rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: .9rem;
}

.modal-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: .75rem;
  line-height: 1.2;
  padding-right: 2rem;
}

.modal-body {
  color: var(--text-dim);
  font-size: .93rem;
  line-height: 1.7;
}

.modal-body code {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .1rem .4rem;
  font-size: .85em;
  font-family: 'Fira Code', 'Consolas', 'Courier New', monospace;
  color: #93c5fd;
}

.modal-body b { color: var(--text); font-weight: 700; }
.modal-body i { color: #c4b5fd; font-style: italic; }

/* ─── TRANSITIONS ───────────────────────────────────────── */
.fade-in {
  animation: fadeIn .3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── SCROLLBAR ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
