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

:root {
  --bg:        #0d1b2a;
  --surface:   #112233;
  --surface2:  #1a3040;
  --sea:       #1e4d6b;
  --land:      #2d5a27;
  --land-h:    #3d7a35;
  --gold:      #f5c842;
  --gold-h:    #ffd966;
  --red:       #e05252;
  --green:     #4caf50;
  --text:      #e8f0fe;
  --muted:     #7a9ab0;
  --r:         .85rem;
  --h-header:  50px;
}

html,body{height:100%;overflow:hidden;background:var(--bg);color:var(--text);
  font-family:'Segoe UI',system-ui,sans-serif;-webkit-tap-highlight-color:transparent;
  overscroll-behavior:none}

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

/* ── App shell ──────────────────────────────────────────── */
.app-shell{
  height:100dvh;
  display:grid;
  grid-template-rows:var(--h-header) 1fr;
  padding-top:env(safe-area-inset-top);
  padding-bottom:env(safe-area-inset-bottom);
}

/* ── Header ─────────────────────────────────────────────── */
.app-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:0 1rem;
  background:var(--surface);
  border-bottom:2px solid var(--sea);
}
.nav-back{color:var(--gold);text-decoration:none;font-size:.8rem;font-weight:700}
.header-center{font-size:1rem;font-weight:900;letter-spacing:.5px}
.score-chip{
  background:var(--gold);color:#0d1b2a;
  border-radius:2rem;padding:.2rem .7rem;
  font-size:.82rem;font-weight:900;
}

/* ── Main ───────────────────────────────────────────────── */
.app-main{overflow:hidden;position:relative}

/* ── Screens ────────────────────────────────────────────── */
.screen{
  position:absolute;inset:0;
  display:flex;flex-direction:column;
  overflow-y:auto;overflow-x:hidden;
  padding:.75rem;
  gap:.7rem;
  -webkit-overflow-scrolling:touch;
}

/* ══════════════════════════════════════════════════════
   ÉCRAN ACCUEIL
══════════════════════════════════════════════════════ */
.home-hero{
  background:var(--surface);
  border:1px solid var(--sea);
  border-radius:var(--r);
  padding:1.5rem 1rem;
  text-align:center;
  display:flex;flex-direction:column;align-items:center;gap:.6rem;
}
.hero-emoji{font-size:3rem;animation:float 3s ease-in-out infinite}
@keyframes float{0%,100%{transform:translateY(0)}50%{transform:translateY(-8px)}}
.hero-title{font-size:1.8rem;font-weight:900;color:var(--gold)}
.hero-sub{color:var(--muted);font-size:.88rem;line-height:1.6}
.hero-hint{
  display:inline-block;background:var(--surface2);
  border-radius:2rem;padding:.2rem .75rem;
  font-size:.75rem;color:var(--gold-h);margin-top:.3rem;
}

/* Grille des modes */
.mode-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:.55rem;
}

.mode-card{
  background:var(--surface);
  border:1px solid var(--sea);
  border-radius:var(--r);
  padding:.85rem .7rem;
  cursor:pointer;
  display:flex;flex-direction:column;align-items:center;gap:.3rem;
  text-align:center;
  transition:border-color .2s,background .2s,transform .1s;
  color:var(--text);
  touch-action:manipulation;
}
.mode-card:active{transform:scale(.96);background:var(--surface2)}
.mode-card:hover{border-color:var(--gold);background:var(--surface2)}

.mode-icon{font-size:1.6rem}
.mode-label{font-size:.82rem;font-weight:800;color:var(--gold-h)}
.mode-desc{font-size:.7rem;color:var(--muted);line-height:1.4}

/* Stats bas accueil */
.home-stats{display:flex;gap:.55rem}
.stat-box{
  flex:1;background:var(--surface);border:1px solid var(--sea);
  border-radius:var(--r);padding:.5rem .75rem;
  font-size:.78rem;color:var(--muted);text-align:center;
}

/* ══════════════════════════════════════════════════════
   ÉCRAN QUIZ
══════════════════════════════════════════════════════ */
.quiz-shell{
  display:flex;flex-direction:column;gap:.6rem;
  height:100%;min-height:0;overflow:hidden;
}

.quiz-top{display:flex;flex-direction:column;gap:.5rem;flex-shrink:0}

.quiz-meta{display:flex;justify-content:space-between;align-items:center}
.quiz-mode-label{
  font-size:.72rem;font-weight:700;
  background:var(--sea);border-radius:2rem;padding:.2rem .65rem;
  color:var(--gold-h);
}
.quiz-counter{font-size:.75rem;color:var(--muted)}

.progress-bar{height:5px;background:var(--surface2);border-radius:2rem;overflow:hidden}
.progress-fill{
  height:100%;width:10%;
  background:linear-gradient(90deg,var(--gold),var(--green));
  border-radius:2rem;transition:width .4s ease;
}

.question-card{
  background:var(--surface);
  border:1px solid var(--sea);
  border-radius:var(--r);
  padding:1rem;
  text-align:center;
}
.question-text{font-size:clamp(1.5rem,7vw,2.2rem);font-weight:900;color:var(--gold);line-height:1.1}
.question-sub{font-size:.82rem;color:var(--muted);margin-top:.4rem}

/* Middle zone — scrollable if needed */
.quiz-middle{
  flex:1;min-height:0;
  overflow-y:auto;-webkit-overflow-scrolling:touch;
  display:flex;flex-direction:column;
}

.choice-btn{
  background:var(--surface);
  border:2px solid var(--sea);
  border-radius:var(--r);
  padding:.75rem .5rem;
  font-size:.85rem;font-weight:700;
  color:var(--text);
  cursor:pointer;
  text-align:center;
  transition:border-color .15s,background .15s,transform .1s;
  touch-action:manipulation;
  line-height:1.3;
}
.choice-btn:active{transform:scale(.95)}
.choice-btn:hover{border-color:var(--gold);background:var(--surface2)}
.choice-btn.correct{border-color:var(--green);background:#1a3a1a;color:#7ee87e}
.choice-btn.wrong  {border-color:var(--red);background:#3a1a1a;color:#f08080}
.choice-btn.reveal {border-color:var(--green);background:#1a3a1a;color:#7ee87e;opacity:.8}
.choice-btn:disabled{pointer-events:none;opacity:.6}

/* Mode region-deps : input libre */
.deps-input-wrap{
  display:flex;flex-direction:column;gap:.5rem;
  flex:1;
}
.deps-found{
  display:flex;flex-wrap:wrap;gap:.35rem;min-height:2.5rem;
  padding:.5rem;background:var(--surface);border:1px solid var(--sea);
  border-radius:var(--r);
}
.dep-tag{
  background:var(--sea);border-radius:2rem;padding:.2rem .65rem;
  font-size:.78rem;font-weight:700;color:var(--gold-h);
}
.dep-tag.missed{background:#3a2020;color:#f08080}
.deps-input{
  width:100%;padding:.65rem;
  background:var(--surface2);border:2px solid var(--sea);
  border-radius:var(--r);color:var(--text);font-size:1rem;
  outline:none;
}
.deps-input:focus{border-color:var(--gold)}
.deps-help{font-size:.72rem;color:var(--muted);text-align:center}

/* Feedback + curiosité */
.quiz-bottom{display:flex;flex-direction:column;gap:.5rem;flex-shrink:0}

.feedback-box{
  padding:.7rem 1rem;border-radius:var(--r);
  font-size:.9rem;font-weight:700;text-align:center;
}
.feedback-box.correct{background:#1a3a1a;border:1px solid var(--green);color:#7ee87e}
.feedback-box.wrong  {background:#3a1a1a;border:1px solid var(--red);color:#f08080}

.curiosite-box{
  background:var(--surface);border-left:3px solid var(--gold);
  border-radius:var(--r);padding:.6rem .85rem;
  font-size:.78rem;color:var(--muted);line-height:1.5;
}
.curiosite-box strong{color:var(--gold-h)}

.btn-next{
  padding:.7rem;font-size:.9rem;font-weight:800;
  background:linear-gradient(135deg,var(--gold),#e8a800);
  color:#0d1b2a;border:none;border-radius:var(--r);
  cursor:pointer;touch-action:manipulation;
  transition:transform .1s;
}
.btn-next:active{transform:scale(.97)}

.btn-quit{
  padding:.45rem;font-size:.75rem;
  background:transparent;color:var(--muted);
  border:1px solid #ffffff12;border-radius:var(--r);
  cursor:pointer;touch-action:manipulation;
}
.btn-quit:active{color:var(--red);border-color:var(--red)}

/* ══════════════════════════════════════════════════════
   ÉCRAN CARTE
══════════════════════════════════════════════════════ */
.map-shell{
  display:flex;flex-direction:column;gap:.5rem;
  height:100%;overflow-y:auto;
}

.map-instruction{
  font-size:.82rem;color:var(--muted);text-align:center;
  background:var(--surface);border-radius:var(--r);padding:.5rem .75rem;
  flex-shrink:0;
}

.map-target{
  text-align:center;font-size:clamp(1.2rem,6vw,1.8rem);
  font-weight:900;color:var(--gold);
  background:var(--surface);border-radius:var(--r);padding:.6rem;
  flex-shrink:0;
}

.map-container{
  flex:1;position:relative;overflow:hidden;
  background:var(--sea);border-radius:var(--r);
  border:1px solid var(--sea);
  min-height:260px;
}

#map-svg-wrap{
  width:100%;height:100%;
  display:flex;align-items:center;justify-content:center;
}

#map-svg-wrap svg{
  width:100%;height:100%;
}

/* Départements SVG (silhouettes « en masque », sans numéro) */
.dep-path{
  fill:var(--land);stroke:var(--bg);stroke-width:0.6;
  cursor:pointer;transition:fill .15s;
  stroke-linejoin:round;
}
.dep-path:hover,.dep-path.hovered{fill:var(--land-h)}
.dep-path.correct{fill:#2d7a2d;stroke:#4caf50;stroke-width:1.5}
.dep-path.wrong  {fill:#7a2d2d;stroke:#e05252;stroke-width:1.5}
.dep-path.target {fill:var(--gold);stroke:var(--gold-h);stroke-width:1.5}

/* Vignettes DROM dans l'encart outre-mer (vraies formes) */
.drom-bg{
  fill:rgba(255,255,255,0.03);stroke:rgba(255,255,255,0.08);stroke-width:0.5;
}
.drom-shape{
  fill:var(--land);stroke:var(--bg);stroke-width:0.5;
  transition:fill .15s;stroke-linejoin:round;
}
.drom-label{fill:var(--muted)}
.drom-cell{cursor:pointer}
.drom-cell:hover .drom-shape,.drom-cell.hovered .drom-shape{fill:var(--land-h)}
.drom-cell:hover .drom-bg,.drom-cell.hovered .drom-bg{stroke:var(--land-h)}
.drom-cell.correct .drom-shape{fill:#2d7a2d;stroke:#4caf50;stroke-width:1}
.drom-cell.correct .drom-bg{stroke:#4caf50}
.drom-cell.wrong .drom-shape  {fill:#7a2d2d;stroke:#e05252;stroke-width:1}
.drom-cell.wrong .drom-bg{stroke:#e05252}
.drom-cell.target .drom-shape {fill:var(--gold);stroke:var(--gold-h);stroke-width:1}
.drom-cell.target .drom-bg{stroke:var(--gold)}
.drom-cell.correct .drom-label,.drom-cell.wrong .drom-label,.drom-cell.target .drom-label{fill:#fff}

.dep-path.target {fill:#7a6010;stroke:var(--gold);stroke-width:2;animation:pulse-dep 1s ease-in-out infinite}
@keyframes pulse-dep{0%,100%{opacity:1}50%{opacity:.6}}

.map-feedback{
  text-align:center;font-size:.88rem;font-weight:700;
  min-height:1.5rem;flex-shrink:0;padding:.3rem;
}
.map-feedback.correct{color:var(--green)}
.map-feedback.wrong  {color:var(--red)}

/* ══════════════════════════════════════════════════════
   ÉCRAN RÉSULTATS
══════════════════════════════════════════════════════ */
.results-card{
  margin:auto;
  background:var(--surface);border:1px solid var(--sea);
  border-radius:var(--r);padding:2rem 1.5rem;
  display:flex;flex-direction:column;align-items:center;gap:1rem;
  text-align:center;max-width:380px;width:100%;
}
.results-emoji{font-size:3.5rem}
.results-title{font-size:1.5rem;font-weight:900;color:var(--gold)}
.results-score{font-size:2rem;font-weight:900}
.results-details{font-size:.85rem;color:var(--muted);line-height:1.7}
.results-btns{display:flex;gap:.75rem;flex-wrap:wrap;justify-content:center;width:100%}

.btn-primary{
  flex:1;padding:.75rem;font-size:.9rem;font-weight:800;
  background:linear-gradient(135deg,var(--gold),#e8a800);
  color:#0d1b2a;border:none;border-radius:var(--r);cursor:pointer;
  min-width:120px;touch-action:manipulation;
}
.btn-secondary{
  flex:1;padding:.75rem;font-size:.9rem;font-weight:700;
  background:var(--surface2);color:var(--text);
  border:1px solid var(--sea);border-radius:var(--r);cursor:pointer;
  min-width:120px;touch-action:manipulation;
}

/* ── Responsive paysage smartphone ─────────────────────── */
@media(orientation:landscape) and (max-height:500px){
  .mode-grid{grid-template-columns:repeat(3,1fr)}
  .choices{grid-template-columns:repeat(4,1fr)}
}
