/* ── VARIABLES ────────────────────────────────────────────────────────────── */
:root {
  --bg-primary: #000000; --bg-secondary: #fff3; --bg-tertiary: #646464;
  --text-primary: #f5f4ee; --text-secondary: #a8a69a; --text-tertiary: #949494;
  --border-subtle: rgba(222,220,209,0.12); --border-mid: rgba(222,220,209,0.25); --border-strong: rgba(222,220,209,0.4);
  --radius-sm:6px; --radius-md:8px; --radius-lg:12px; --radius-full:9999px;
  --tag-anamnese-bg:rgba(37,62,95,0.7); --tag-anamnese-text:#80aadd;
  --tag-clinique-bg:rgba(27,70,20,0.7); --tag-clinique-text:#7ab948;
  --tag-paraclinique-bg:rgba(72,58,15,0.7); --tag-paraclinique-text:#d1a041;
  --tag-image-bg:rgba(55,45,90,0.7); --tag-image-text:#afa9ec;
  --green:#4a7a1a; --green-light:#c0dd97; --green-bg:rgba(27,70,20,0.4);
  --red:#a32d2d; --red-light:#f7c1c1; --red-bg:rgba(96,42,40,0.4);
  --neutral-bg: #5c461b;
  --neutral-light:#d1a041;
  --yellow: #ffd000;
  --sp-cardio-bg:rgba(37,62,95,0.7); --sp-cardio-text:#80aadd;
  --sp-urg-bg:rgba(55,45,90,0.7); --sp-urg-text:#afa9ec;
  --sp-pneumo-bg:rgba(27,70,20,0.7); --sp-pneumo-text:#7ab948;
  --sp-neuro-bg:rgba(72,58,15,0.7); --sp-neuro-text:#d1a041;
  --sp-med-bg:rgba(60,30,60,0.7); --sp-med-text:#d4a0d4;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-primary:#fff; --bg-secondary:#f5f4ed; --bg-tertiary:#eeede6;
    --text-primary:#14140f; --text-secondary:#3d3d3a; --text-tertiary:#73726c;
    --border-subtle:rgba(31,30,29,0.1); --border-mid:rgba(31,30,29,0.2); --border-strong:rgba(31,30,29,0.35);
    --tag-anamnese-bg:#d6e4f6; --tag-anamnese-text:#0c447c;
    --tag-clinique-bg:#d4edda; --tag-clinique-text:#085041;
    --tag-paraclinique-bg:#faeeda; --tag-paraclinique-text:#633806;
    --tag-image-bg:#eeedfe; --tag-image-text:#3c3489;
    --green:#3b6d11; --green-light:#639922; --green-bg:#eaf3de;
    --red:#791f1f; --red-light:#a32d2d; --red-bg:#fcebeb;
    --neutral-bg:#f5f4ed;
    --sp-cardio-bg:#d6e4f6; --sp-cardio-text:#0c447c;
    --sp-urg-bg:#eeedfe; --sp-urg-text:#3c3489;
    --sp-pneumo-bg:#d4edda; --sp-pneumo-text:#085041;
    --sp-neuro-bg:#faeeda; --sp-neuro-text:#633806;
    --sp-med-bg:#f5e6f5; --sp-med-text:#7a2a7a;
  }
}

/* ── RESET ────────────────────────────────────────────────────────────────── */
* { box-sizing:border-box; margin:0; padding:0; }
body { font-family:'Inter', system-ui, sans-serif; background:var(--bg-primary); color:var(--text-primary); min-height:100vh; }

/* ── HEADER ───────────────────────────────────────────────────────────────── */
.header { text-align:center; margin-bottom:32px; padding-bottom:1.5rem; border-bottom:0.5px solid var(--border-subtle); }
.header h1 { font-size:28px; font-weight:700; letter-spacing:0.08em; text-transform:uppercase; }
.header-sub { font-size:13px; color:var(--text-tertiary); margin-top:5px; }
.header-nav { margin-top:10px; display:flex; justify-content:center; gap:6px; }
.header-nav a { font-size:12px; color:var(--text-tertiary); text-decoration:none; border:0.5px solid var(--border-subtle); border-radius:var(--radius-full); padding:3px 10px; transition:all 0.1s; }
.header-nav a:hover { color:var(--text-secondary); border-color:var(--border-mid); }
.header-stats { display:flex; justify-content:center; gap:1.5rem; margin-top:1rem; }
.stat { text-align:center; }
.stat-value { font-size:18px; font-weight:600; }
.stat-label { font-size:11px; color:var(--text-tertiary); text-transform:uppercase; letter-spacing:0.05em; }

/* ── FOOTER ───────────────────────────────────────────────────────────────── */
.footer { text-align:center; margin-top:2.5rem; padding-top:1.25rem; border-top:0.5px solid var(--border-subtle); }
.footer p { font-size:12px; color:var(--text-tertiary); line-height:1.6; }
.footer a { color:var(--text-tertiary); text-decoration:none; }
.footer a:hover { color:var(--text-secondary); }

/* ── TRIES ────────────────────────────────────────────────────────────────── */
.tries { display:flex; gap:8px; justify-content:center; margin-bottom:32px; }
.try-dot { width:30px; height:30px; border-radius:50%; border:0.5px solid var(--border-mid); background:var(--bg-secondary); display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:600; color:var(--text-tertiary); transition:all 0.15s; }
.try-dot.used { background:var(--red-bg); border-color:var(--red); color:var(--red-light); }
.try-dot.current { border-color:var(--border-strong); background:var(--bg-tertiary); color:var(--text-primary); }
.try-dot.correct { background:var(--green-bg); border-color:var(--green); color:var(--green-light); }

/* ── INDICES ──────────────────────────────────────────────────────────────── */
.indices { display:flex; flex-direction:column; gap:15px; margin-bottom:1rem; }
.indice-card { background:var(--bg-secondary); border:0px solid var(--border-subtle); border-radius:var(--radius-lg); padding:0.9rem 1.1rem; animation:fadeSlide 0.2s ease; }
@keyframes fadeSlide { from{opacity:0;transform: perspective(400px) rotateX(90deg);} to{opacity:1;transform: perspective(400px) rotateX(0deg);} }
.indice-header { display:flex; align-items:center; gap:8px; margin-bottom:7px; }
.indice-tag { font-size:10px; font-weight:600; padding:2px 8px; border-radius:var(--radius-full); text-transform:uppercase; letter-spacing:0.04em; }
.tag-anamnese { background:var(--tag-anamnese-bg); color:var(--tag-anamnese-text); }
.tag-clinique { background:var(--tag-clinique-bg); color:var(--tag-clinique-text); }
.tag-paraclinique { background:var(--tag-paraclinique-bg); color:var(--tag-paraclinique-text); }
.tag-image { background:var(--tag-image-bg); color:var(--tag-image-text); }
.indice-num { font-size:11px; color:var(--text-tertiary); }
.indice-text { font-size: 1.1rem; line-height: 1.65; font-weight: 600; }
.indice-locked-card { background:var(--bg-secondary); border:2px dashed var(--border-subtle); border-radius:var(--radius-lg); padding:0.7rem 1.1rem; display:flex; align-items:center; gap:8px; opacity:0.6; }
.indice-locked-text { font-size:13px; color:var(--text-tertiary); }
.lock-icon { width:12px; height:12px; opacity:0.3; flex-shrink:0; }

/* ── IMAGES + LIGHTBOX ────────────────────────────────────────────────────── */
.indice-image { width:100%; border-radius:var(--radius-md); margin-top:10px; background:var(--bg-tertiary); height:180px; display:flex; align-items:center; justify-content:center; border:0.5px solid var(--border-subtle); overflow:hidden; cursor:zoom-in; position:relative; }
.indice-image img { max-width:100%; max-height:100%; object-fit:contain; transition:transform 0.15s; }
.indice-image:hover img { transform:scale(1.03); }
.indice-image-placeholder { font-size:12px; color:var(--text-tertiary); }
.indice-image-hint { position:absolute; bottom:6px; right:8px; font-size:10px; color:var(--text-tertiary); opacity:0.7; pointer-events:none; }

.lightbox { position:fixed; inset:0; background:rgba(0,0,0,0.92); z-index:1000; display:none; align-items:center; justify-content:center; padding:1rem; }
.lightbox.open { display:flex; }
.lightbox img { max-width:100%; max-height:90vh; object-fit:contain; border-radius:var(--radius-md); }
.lightbox-close { position:fixed; top:16px; right:20px; background:none; border:none; color:#fff; font-size:28px; cursor:pointer; line-height:1; opacity:0.7; z-index:1001; }
.lightbox-close:hover { opacity:1; }

/* ── CONSTANTES ───────────────────────────────────────────────────────────── */
.constantes-zone { margin-bottom:1.25rem; }
.btn-constantes { width:100%; display:flex; align-items:center; justify-content:space-between; padding:10px 14px; background:var(--green-bg); border:2px solid var(--green); border-radius:var(--radius-md); font-size:13px; color:var(--green-light); cursor:pointer; font-family:inherit; transition:all 0.15s; }
.btn-constantes:not([disabled]):hover { filter:brightness(1.1); }
.btn-constantes[disabled] { opacity:0.4; cursor:not-allowed; background:var(--bg-secondary); border-color:var(--border-subtle); color:var(--text-tertiary); }
.btn-constantes-left { display:flex; align-items:center; gap:8px; }
.constantes-chevron { font-size:10px; transition:transform 0.2s; display:inline-block; }
.constantes-chevron.open { transform:rotate(180deg); }
.constantes-panel { background:var(--bg-secondary); border:0.5px solid var(--border-subtle); border-top:none; border-radius:0 0 var(--radius-md) var(--radius-md); overflow:hidden; display:none; }
.constantes-panel.open { display:block; }
.constantes-table { width:100%; border-collapse:collapse; }
.constantes-table tr { border-bottom:0.5px solid var(--border-subtle); }
.constantes-table tr:last-child { border-bottom:none; }
.constantes-table td { padding:8px 14px; font-size:13px; }
.constantes-table td:first-child { color:var(--text-secondary); width:45%; }
.constantes-table td:last-child { color:var(--text-primary); font-weight:500; }

/* ── INPUT / AUTOCOMPLETE ─────────────────────────────────────────────────── */
.input-zone { position:relative; background:var(--bg-secondary); border:2px solid var(--border-mid); border-radius:var(--radius-lg); padding:0.9rem; }
.input-row { display:flex; gap:8px; }
.diag-input { flex:1; font-size:14px; padding:0 12px; height:38px; border-radius:var(--radius-md); border:2px solid var(--border-mid); background:var(--bg-primary); color:var(--text-primary); outline:none; font-family:inherit; }
.diag-input::placeholder { color:var(--text-tertiary); }
.diag-input:focus { border-color:var(--border-strong); }
.btn-valider { height:38px; padding:0 16px; font-size:13px; font-weight:600; border-radius:var(--radius-md); border:2px solid var(--border-strong); background:var(--text-primary); color:var(--bg-primary); cursor:pointer; white-space:nowrap; font-family:inherit; transition:opacity 0.1s; }
.btn-valider:hover { opacity:0.85; }
.btn-valider:disabled { opacity:0.3; cursor:not-allowed; }
.btn-passer { height:38px; padding:0 12px; font-size:13px; border-radius:var(--radius-md); border:2px solid var(--border-subtle); background:transparent; color:var(--text-secondary); cursor:pointer; font-family:inherit; }
.btn-passer:hover { background:var(--bg-tertiary); }
.dropdown { position:absolute; top:calc(0.9rem + 38px + 8px); left:0.9rem; right:0.9rem; background:var(--bg-primary); border:2px solid var(--border-mid); border-radius:var(--radius-md); z-index:10; overflow:hidden; }
.dropdown-item { padding:9px 12px; font-size:14px; color:var(--text-primary); cursor:pointer; }
.dropdown-item:hover { background:var(--bg-secondary); }
.feedback { margin-top:8px; padding:8px 12px; border-radius:var(--radius-md); font-size:13px; line-height:1.5; }
.feedback.wrong { background:var(--red-bg); color:var(--red-light); border:2px solid var(--red); }
.feedback.correct { background:var(--green-bg); color:var(--green-light); border:2px solid var(--green); }
.feedback.reveal { background:var(--neutral-bg); color:var(--text-secondary); border:2px solid var(--border-subtle); }

/* ── RÉSULTAT ─────────────────────────────────────────────────────────────── */
.result-banner { text-align:center; padding:1.75rem; background:var(--bg-secondary); border-radius:var(--radius-lg); border:2px solid var(--border-subtle); margin-top:1rem; }
.result-banner h2 { font-size:20px; font-weight:700; margin-bottom:6px; }
.result-banner p { font-size:13px; color:var(--text-secondary); margin-bottom:14px; line-height:1.6; }
.result-emoji { font-size:18px; letter-spacing:3px; margin-bottom:14px; }
.countdown-block { margin:14px 0; }
.countdown-label { font-size:11px; color:var(--text-tertiary); text-transform:uppercase; letter-spacing:0.06em; margin-bottom:4px; }
.countdown-time { font-size:24px; font-weight:700; letter-spacing:0.06em; font-variant-numeric:tabular-nums; }
.result-actions { display:flex; gap:8px; justify-content:center; flex-wrap:wrap; margin-top:14px; }
.btn-partager { font-size:13px; font-weight:500; padding:8px 18px; border-radius:var(--radius-md); border:2px solid var(--border-mid); background:var(--bg-primary); color:var(--text-primary); cursor:pointer; font-family:inherit; }
.btn-partager:hover { background:var(--bg-tertiary); }
.btn-archives-link { font-size:13px; padding:8px 18px; border-radius:var(--radius-md); border:2px solid var(--border-subtle); background:transparent; color:var(--text-secondary); cursor:pointer; font-family:inherit; text-decoration:none; display:inline-flex; align-items:center; }
.btn-archives-link:hover { background:var(--bg-tertiary); }
.share-confirm { font-size:12px; color:var(--text-tertiary); margin-top:8px; }
.deja-joue { text-align:center; padding:2rem 1.5rem; background:var(--bg-secondary); border-radius:var(--radius-lg); border:2px solid var(--border-subtle); }
.deja-joue h2 { font-size:20px; font-weight:700; margin-bottom:8px; }
.deja-joue p { font-size:13px; color:var(--text-secondary); line-height:1.6; margin-bottom:6px; }

/* ── TAGS SPÉCIALITÉS ─────────────────────────────────────────────────────── */
.sp-cardiologie, .sp-cardio { background:var(--sp-cardio-bg); color:var(--sp-cardio-text); }
.sp-urgences, .sp-urg { background:var(--sp-urg-bg); color:var(--sp-urg-text); }
.sp-pneumologie, .sp-pneumo { background:var(--sp-pneumo-bg); color:var(--sp-pneumo-text); }
.sp-neurologie, .sp-neuro { background:var(--sp-neuro-bg); color:var(--sp-neuro-text); }
.sp-medecine-interne, .sp-med { background:var(--sp-med-bg); color:var(--sp-med-text); }

/* ── ARCHIVES — GRILLE ────────────────────────────────────────────────────── */
.archive-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.archive-card { background:var(--bg-secondary); border:2px solid var(--border-subtle); border-radius:var(--radius-lg); padding:0.85rem 1rem; cursor:pointer; transition:border-color 0.1s; display:flex; flex-direction:column; gap:6px; }
.archive-card:hover { border-color:var(--border-mid); }
.archive-card-top { display:flex; align-items:center; justify-content:space-between; }
.archive-date { font-size:11px; color:var(--text-tertiary); }
.archive-specialite { font-size:9px; font-weight:600; padding:2px 7px; border-radius:var(--radius-full); text-transform:uppercase; letter-spacing:0.04em; }
.archive-diagnostic { font-size:13px; font-weight:600; color:var(--text-primary); line-height:1.3; }
.archive-diff { display:flex; gap:3px; }
.diff-dot { width:5px; height:5px; border-radius:50%; background:var(--border-mid); }
.diff-dot.on { background:var(--text-secondary); }
.archive-empty { text-align:center; padding:3rem 1rem; color:var(--text-tertiary); font-size:14px; grid-column:1/-1; }

/* ── MODALE ───────────────────────────────────────────────────────────────── */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.6); display:none; align-items:flex-start; justify-content:center; z-index:100; padding:1rem; overflow-y:auto; }
.modal-overlay.open { display:flex; }
.modal { background:var(--bg-primary); border:2px solid var(--border-mid); border-radius:var(--radius-lg); width:100%; max-width:600px; margin:auto; padding:1.5rem; }
.modal-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:1.25rem; }
.modal-title { font-size:16px; font-weight:600; }
.modal-close { background:none; border:none; cursor:pointer; font-size:20px; color:var(--text-tertiary); padding:0 4px; line-height:1; }
.modal-close:hover { color:var(--text-primary); }
.modal-meta { font-size:12px; color:var(--text-tertiary); margin-bottom:1rem; }
