/* À la carte ! — Commit & Conquer, licence GPL-3.0-or-later.
   Polices Baloo 2 et Nunito : SIL Open Font License 1.1 (voir fonts/OFL-*.txt). */
@font-face { font-family: "Baloo 2"; src: url("../fonts/Baloo2.ttf") format("truetype"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("../fonts/Nunito.ttf") format("truetype"); font-weight: 200 1000; font-display: swap; }

:root {
  --bleu-fonce: #0B3D91;
  --bleu-vif: #1E90FF;
  --vert: #34C759;
  --orange: #FF9800;
  --creme: #FFF3D6;
  --texte: #0B2A63;
  --blanc: #fff;
  --rouge: #D9402B;
  --ombre: 0 3px 0 rgba(11, 61, 145, .25);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--texte);
  background: var(--creme);
  -webkit-text-size-adjust: 100%;
}
h1, .mode-titre, .bouton, .grandes-etoiles { font-family: "Baloo 2", "Nunito", sans-serif; }
#app { max-width: 560px; margin: 0 auto; min-height: 100%; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
.ecran { display: none; }
.ecran.actif { display: block; }

/* Accueil */
.logo { display: block; width: min(80%, 360px); height: auto; margin: 24px auto 0; }
.slogan { text-align: center; font-weight: 700; font-size: 1.1rem; margin: 8px 0 24px; color: var(--bleu-fonce); }
.modes { display: grid; gap: 12px; }
.mode {
  font-family: inherit; border: 0; border-radius: 18px; padding: 16px 20px; text-align: left; cursor: pointer;
  color: var(--blanc); box-shadow: var(--ombre); min-height: 76px;
  display: flex; flex-direction: column; justify-content: center;
}
.mode:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.mode:disabled { opacity: .55; cursor: default; }
.mode-titre { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.mode-sous { font-size: .95rem; font-weight: 700; opacity: .95; }
.mode-drapeaux { background: var(--bleu-vif); }
.mode-pays { background: var(--bleu-fonce); }
.mode-villes { background: #B35F00; } /* orange de la charte, assombri pour le contraste du texte blanc */
.pied { text-align: center; font-size: .85rem; margin-top: 28px; }
.pied a { color: var(--bleu-fonce); }

/* Barre */
.barre { display: flex; align-items: center; gap: 10px; padding: 14px 0 6px; }
.barre h1 { flex: 1; margin: 0; font-size: 1.5rem; color: var(--bleu-fonce); }
.retour {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--bleu-vif); color: #fff;
  font-size: 1.4rem; font-weight: 800; cursor: pointer;
}
.compteur { font-weight: 800; color: var(--bleu-fonce); }
.aide { margin: 4px 0 16px; }

/* Niveaux */
.niveaux { display: grid; gap: 12px; }
.niveau {
  border: 0; border-radius: 18px; padding: 14px 18px; background: var(--blanc); color: var(--texte);
  box-shadow: var(--ombre); text-align: left; cursor: pointer; display: flex; align-items: center; gap: 12px;
  font: inherit; min-height: 72px;
}
.niveau:disabled { opacity: .5; cursor: default; }
.niveau b { font-family: "Baloo 2", sans-serif; font-size: 1.3rem; display: block; line-height: 1.1; }
.niveau small { display: block; font-weight: 600; }
.niveau .corps { flex: 1; }
.etoiles { font-size: 1.4rem; letter-spacing: 2px; white-space: nowrap; color: var(--orange); }
.etoiles .vide { color: #c9c0a8; }

/* Partie */
.progression { height: 10px; background: #e6dcc0; border-radius: 5px; overflow: hidden; }
#jeu-barre { height: 100%; width: 0; background: var(--vert); transition: width .3s; }
.consigne { font-weight: 800; margin: 14px 0 8px; font-size: 1.05rem; }
.refs, .essais, #suggestions, .sugg { list-style: none; margin: 0; padding: 0; }
.refs { display: grid; gap: 8px; }
.ref {
  background: var(--bleu-fonce); color: #fff; border-radius: 14px; padding: 10px 16px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}
.ref .nom { font-family: "Baloo 2", sans-serif; font-size: 1.15rem; font-weight: 600; }
.ref .dist { font-weight: 800; font-size: 1.15rem; white-space: nowrap; }
.saisie { position: relative; margin-top: 16px; }
#champ, #drap-champ, #cache-champ {
  width: 100%; font: inherit; font-size: 1.1rem; font-weight: 700; padding: 14px 16px;
  border: 3px solid var(--bleu-vif); border-radius: 14px; background: #fff; color: var(--texte);
}
#champ:focus, #drap-champ:focus, #cache-champ:focus { outline: 3px solid var(--orange); outline-offset: 1px; }
#suggestions, .sugg {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5; background: #fff;
  border-radius: 14px; box-shadow: 0 6px 18px rgba(11, 61, 145, .3); overflow: hidden;
}
#suggestions li, .sugg li { padding: 12px 16px; cursor: pointer; font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
#suggestions li small, .sugg li small { font-weight: 600; opacity: .75; }
#suggestions li.actif, #suggestions li:hover, .sugg li.actif, .sugg li:hover { background: var(--bleu-vif); color: #fff; }
.message { min-height: 1.4em; margin: 8px 2px; font-weight: 700; color: var(--rouge); }
.essais { display: grid; gap: 8px; }
.essai {
  background: #fff; border-left: 8px solid var(--orange); border-radius: 12px; padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px; box-shadow: var(--ombre);
}
.essai.gagne { border-left-color: var(--vert); background: #E4F8E9; }
.essai .nom { font-weight: 800; }
.essai small { display: block; font-weight: 600; opacity: .75; }
.essai .dist { font-weight: 800; white-space: nowrap; }
.fleche { display: inline-block; font-size: 1.4rem; width: 1.6em; text-align: center; font-weight: 800; color: var(--bleu-vif); }
.lien { display: block; margin: 20px auto 0; background: none; border: 0; color: var(--bleu-fonce); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 12px; }

/* Fin */
.grandes-etoiles { text-align: center; font-size: 3.4rem; color: var(--orange); margin: 24px 0 8px; letter-spacing: 6px; }
.grandes-etoiles .vide { color: #c9c0a8; }
.fin-texte { text-align: center; font-size: 1.15rem; font-weight: 700; }
.actions { display: grid; gap: 10px; margin-top: 20px; }
.bouton {
  border: 0; border-radius: 16px; padding: 14px; font-size: 1.3rem; font-weight: 700; cursor: pointer;
  background: var(--bleu-vif); color: #fff; box-shadow: var(--ombre);
}
.bouton.secondaire { background: #fff; color: var(--bleu-fonce); }
button:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Drapeaux */
#drap-barre { height: 100%; width: 0; background: var(--vert); transition: width .3s; }
.drap-zone { margin: 8px 0 14px; display: flex; justify-content: center; }
#drap-img { width: min(100%, 320px); height: auto; aspect-ratio: 4 / 3; border-radius: 10px; box-shadow: var(--ombre); background: #fff; border: 3px solid #fff; }
.prop { width: min(100%, 320px); height: 120px; display: flex; gap: 4px; border-radius: 10px; overflow: hidden; border: 3px solid #fff; box-shadow: var(--ombre); background: #fff; }
.prop span { display: block; height: 100%; }
.choix { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choix button {
  font: inherit; font-weight: 800; font-size: 1.05rem; border: 3px solid var(--bleu-vif); background: #fff; color: var(--texte);
  border-radius: 14px; padding: 14px 8px; min-height: 64px; cursor: pointer; box-shadow: var(--ombre);
}
.choix button:disabled { cursor: default; }
.choix button.bon { background: var(--vert); border-color: #1d8f3d; color: #06260f; }
.choix button.faux { background: #FFE0DA; border-color: var(--rouge); text-decoration: line-through; }
.choix button.bon::after { content: " ✓"; }
#drap-retour { color: var(--texte); }
#drap-retour.mauvais { color: var(--rouge); }
#drap-suite { width: 100%; margin-top: 8px; }
[hidden] { display: none !important; }

/* Pays : silhouette */
.forme { width: min(100%, 320px); aspect-ratio: 1; background: #fff; border-radius: 10px; border: 3px solid #fff; box-shadow: var(--ombre); display: flex; overflow: hidden; }
.forme svg { width: 100%; height: 100%; transition: transform .6s ease; }
.forme svg path { fill: var(--bleu-fonce); stroke: var(--bleu-fonce); stroke-width: 1; stroke-linejoin: round; }
.forme.revele svg path { fill: var(--vert); stroke: #1d8f3d; }

/* Les bonnes couleurs, Recolorier */
.mode-couleurs { background: linear-gradient(120deg, #0B3D91, #1E70D8); }
.mode-recolorier { background: linear-gradient(120deg, #B35F00, #0B3D91); }
.barre-prog { height: 100%; width: 0; background: var(--vert); transition: width .3s; }
.grille-drapeaux { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.grille-drapeaux button { border: 4px solid #fff; border-radius: 12px; padding: 0; background: #fff; cursor: pointer; box-shadow: var(--ombre); position: relative; overflow: hidden; }
.grille-drapeaux button:disabled { cursor: default; }
.grille-drapeaux img { display: block; width: 100%; height: auto; max-width: 100%; aspect-ratio: 4 / 3; }
.grille-drapeaux button.bon { border-color: var(--vert); }
.grille-drapeaux button.bon::after { content: "✓"; position: absolute; top: 4px; right: 6px; background: var(--vert); color: #06260f; border-radius: 50%; width: 30px; height: 30px; display: grid; place-items: center; font-weight: 800; }
.grille-drapeaux button.faux { border-color: var(--rouge); opacity: .7; }
.aide-rec { margin: 4px 0 8px; font-weight: 700; }
.pastilles { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.pastille { width: 56px; height: 56px; border-radius: 50%; border: 4px solid #fff; box-shadow: var(--ombre), 0 0 0 2px var(--bleu-fonce); cursor: pointer; padding: 0; position: relative; }
.pastille.choisie { box-shadow: 0 0 0 4px var(--orange); transform: scale(1.1); }
.pastille.ok::after, .pastille.ko::after { position: absolute; right: -6px; top: -6px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .9rem; color: #fff; }
.pastille.ok::after { content: "✓"; background: #1d8f3d; }
.pastille.ko::after { content: "✗"; background: var(--rouge); }
.palette { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.palette button { border: 3px solid #fff; border-radius: 12px; min-height: 52px; cursor: pointer; font: inherit; font-weight: 800; font-size: .8rem; box-shadow: var(--ombre); padding: 4px; }
.palette button:disabled { opacity: .45; cursor: default; }
#rec-valider, #rec-suite, #cou-suite { width: 100%; margin-top: 10px; }

/* Capitales, carte de fin */
.mode-capitales { background: linear-gradient(120deg, #B35F00, #0B3D91 120%); }
.carte-fin { margin: 14px 0 4px; }
.carte-zone { border-radius: 14px; overflow: hidden; border: 3px solid #fff; box-shadow: var(--ombre); background: #BFE0F7; }
.carte-svg { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; }
.legende { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; }
.legende li { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.legende i { width: 14px; height: 14px; border-radius: 50%; flex: none; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--bleu-fonce); }
.legende span { flex: 1; }
