/* Code de la Route — Sherine — style iPhone */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0d0d11;
  --card: #17181f;
  --card2: #21222c;
  --txt: #f5f3ee;
  --muted: #9c9caa;
  --accent: #c9a15e;
  --accent-dark: #a97f3c;
  --accent-soft: rgba(201, 161, 94, 0.14);
  --ok: #3ddc85;
  --ko: #ff6161;
  --gold: #ffd166;
  --radius: 18px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

.screen {
  display: none;
  min-height: 100dvh;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.active { display: flex; }

/* ============ ACCUEIL ============ */
#screen-home {
  justify-content: center; align-items: center; text-align: center;
  background:
    linear-gradient(180deg, rgba(13,13,17,.82) 0%, rgba(13,13,17,.9) 55%, #0d0d11 100%),
    url("img/fond_galerie.jpg") center / cover no-repeat;
}
.home-content { padding: 32px 24px; max-width: 440px; width: 100%; }
.home-badge {
  display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent);
  border: 1px solid rgba(201,161,94,.4); border-radius: 100px;
  background: rgba(13,13,17,.45);
  padding: 6px 14px; margin-bottom: 18px;
}
h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; }
.home-sub { color: var(--muted); margin: 8px 0 26px; font-size: 17px; }
.home-stats { display: flex; gap: 12px; justify-content: center; margin-bottom: 26px; }
.stat {
  background: var(--card); border-radius: var(--radius);
  padding: 14px 18px; flex: 1; display: flex; flex-direction: column; gap: 2px;
}
.stat-num { font-size: 24px; font-weight: 800; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--muted); }

.series-select { margin-bottom: 20px; }
.series-label { font-size: 14px; color: rgba(255,255,255,0.7); margin-bottom: 10px; text-align: left; }
.series-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.series-btn {
  padding: 12px 4px;
  border-radius: 12px;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.75);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.series-btn.active {
  background: var(--accent, #3b82f6);
  border-color: var(--accent, #3b82f6);
  color: #fff;
}
.home-options { margin-bottom: 24px; display: flex; flex-direction: column; gap: 10px; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-radius: 14px; padding: 14px 16px;
  font-size: 15px; cursor: pointer;
}
.toggle-row input { display: none; }
.toggle {
  width: 48px; height: 28px; border-radius: 100px; background: #2a3554;
  position: relative; transition: background .25s; flex-shrink: 0; margin-left: 12px;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .25s;
}
.toggle-row input:checked + .toggle { background: var(--ok); }
.toggle-row input:checked + .toggle::after { transform: translateX(20px); }

.btn-primary, .btn-secondary, .btn-validate {
  width: 100%; border: none; border-radius: 16px; font-size: 17px; font-weight: 700;
  padding: 17px; cursor: pointer; transition: transform .1s, opacity .2s;
  font-family: inherit;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #0d0d11; margin-bottom: 12px;
}
.btn-secondary {
  background: var(--card2); color: var(--txt); margin-bottom: 12px;
  border: 1px solid rgba(255,255,255,0.08);
}
.btn-primary:active, .btn-secondary:active, .btn-validate:active { transform: scale(.97); }
.home-note { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* ============ QUIZ ============ */
.quiz-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; font-size: 14px; font-weight: 600; color: var(--muted);
}
#q-counter { flex-shrink: 0; }
#timer-wrap {
  flex: 1; height: 6px; background: #232e4e; border-radius: 100px; overflow: hidden;
}
#timer-bar {
  height: 100%; width: 100%; background: var(--accent); border-radius: 100px;
  transition: width 1s linear, background .3s;
}
#timer-bar.warn { background: var(--ko); }
.q-theme-badge {
  font-size: 11px; background: var(--card2); border-radius: 100px;
  padding: 4px 10px; color: var(--accent); flex-shrink: 0;
}
.btn-back {
  background: none; border: none; color: var(--accent);
  font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-quit {
  background: var(--card2); border: 1px solid rgba(255,255,255,0.1);
  color: var(--muted); border-radius: 100px;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
  padding: 6px 12px; flex-shrink: 0;
}
.btn-quit:active { transform: scale(.95); }
.corr-quit { margin-bottom: 14px; }

.quiz-body { flex: 1; padding: 0 18px 18px; overflow-y: auto; }
.q-image-wrap {
  background: #fff; border-radius: var(--radius); overflow: hidden;
  display: flex; justify-content: center; align-items: center;
  height: 220px; margin-bottom: 16px;
}
.q-image-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; }
.q-text { font-size: 18px; font-weight: 700; line-height: 1.4; margin-bottom: 4px; }
.q-hint { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

.q-choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 2px solid transparent; border-radius: 14px;
  padding: 14px 16px; font-size: 15.5px; line-height: 1.35; cursor: pointer;
  transition: border .15s, background .15s; text-align: left; width: 100%;
  color: var(--txt); font-family: inherit;
}
.choice .letter {
  width: 30px; height: 30px; border-radius: 50%; background: var(--card2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; flex-shrink: 0; color: var(--accent);
}
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice.selected .letter { background: var(--accent); color: #0d0d11; }

.quiz-footer { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); }
.btn-validate { background: var(--accent); color: #fff; }
.btn-validate:disabled { opacity: .35; }

/* ============ CORRECTION ============ */
.correction-body { padding: 22px 18px calc(24px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; width: 100%; }
.corr-verdict {
  font-size: 22px; font-weight: 800; text-align: center; margin-bottom: 16px;
  padding: 14px; border-radius: var(--radius);
}
.corr-verdict.ok { background: rgba(46,204,113,.12); color: var(--ok); }
.corr-verdict.ko { background: rgba(255,92,92,.12); color: var(--ko); }
.corr-image-wrap {
  background: #fff; border-radius: var(--radius); height: 160px;
  display: flex; justify-content: center; align-items: center; margin-bottom: 14px; overflow: hidden;
}
.corr-image-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; }
.corr-answer { font-size: 15px; font-weight: 700; margin-bottom: 14px; color: var(--ok); line-height: 1.4; }
.corr-card {
  background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.corr-card h3 { font-size: 14px; margin-bottom: 8px; color: var(--accent); }
.corr-card.astuce h3 { color: var(--gold); }
.corr-card p { font-size: 14.5px; line-height: 1.55; color: #cdd6ea; }
.corr-card.astuce { border: 1px solid rgba(255,209,102,.25); }

/* ============ RÉSULTAT ============ */
#screen-result { justify-content: center; }
.result-body { padding: 32px 24px; text-align: center; max-width: 440px; margin: 0 auto; width: 100%; }
.result-emoji { font-size: 64px; margin-bottom: 10px; }
#result-title { font-size: 26px; font-weight: 800; margin-bottom: 14px; }
.result-score { font-size: 54px; font-weight: 900; letter-spacing: -0.03em; margin-bottom: 8px; }
.result-score.ok { color: var(--ok); }
.result-score.ko { color: var(--ko); }
.result-msg { color: var(--muted); font-size: 15.5px; line-height: 1.55; margin-bottom: 22px; }
.result-themes {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; text-align: left;
}
.theme-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border-radius: 12px; padding: 12px 16px; font-size: 14px;
}
.theme-row .score { font-weight: 800; }
.theme-row .score.good { color: var(--ok); }
.theme-row .score.bad { color: var(--ko); }

/* ============ REVUE ERREURS ============ */
.review-list { padding: 0 18px calc(24px + env(safe-area-inset-bottom)); }
.review-item {
  background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.review-item img {
  max-height: 110px; max-width: 100%; background: #fff; border-radius: 10px;
  padding: 6px; margin-bottom: 10px;
}
.review-item .rq { font-weight: 700; font-size: 15px; margin-bottom: 8px; }
.review-item .ra { font-size: 13.5px; line-height: 1.5; margin-bottom: 4px; }
.review-item .ra.bad { color: var(--ko); }
.review-item .ra.good { color: var(--ok); }
.review-item .rexp { font-size: 13px; color: var(--muted); line-height: 1.5; margin-top: 8px; }

@media (min-width: 600px) {
  .quiz-body, .quiz-footer, .quiz-header { max-width: 560px; margin: 0 auto; width: 100%; }
  .q-image-wrap { height: 280px; }
}
