/* Jeu « Départements de France » – styles
   (tous les sélecteurs sont limités à #jeu pour ne pas gêner le reste de la page) */

/* ---------- Conteneur : 800x600 sur ordinateur ---------- */
#jeu {
  container-type: size;
  position: relative;
  width: 800px;
  height: 600px;
  aspect-ratio: 4 / 3;   /* utilisé seulement si la hauteur n'est pas imposée par la page */
  max-width: 100%;
  background: #cfe0e6;
  border-radius: 10px;
  overflow: hidden;
  color: #14303f;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Tablette / mobile : le jeu occupe l'écran disponible */
@media (pointer: coarse), (max-width: 820px) {
  #jeu {
    width: 100%;
    height: min(100dvh, 170vw);
    max-width: none;
    border-radius: 0;
  }
}
@media (max-width: 820px) {
  #jeu { aspect-ratio: 3 / 4; }
}

/* Plein écran (API native) */
#jeu:fullscreen { width: 100vw; height: 100vh; max-width: none; border-radius: 0; }
#jeu:-webkit-full-screen { width: 100vw; height: 100vh; max-width: none; border-radius: 0; }
/* Plein écran de secours (iPhone, navigateurs sans API) */
#jeu.pseudo-plein {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  margin: 0;
  border-radius: 0;
  z-index: 99999;
}

#jeu #cadre { display: flex; width: 100%; height: 100%; }

/* ---------- Panneau de gauche ---------- */
#jeu #panneau {
  flex: 0 0 250px;
  box-sizing: border-box;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: #14303f;
  color: #f3f6f4;
  overflow: auto;
}
#jeu .titre { font-size: 19px; font-weight: 600; line-height: 1.2; opacity: .92; }

#jeu .question {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 92px;
  padding: 8px;
  box-sizing: border-box;
  text-align: center;
  background: rgba(255, 255, 255, .06);
  border-radius: 10px;
}
#jeu .consigne { display: block; font-size: 14px; opacity: .85; margin-bottom: 2px; }
#jeu .cible {
  display: block;
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-style: italic;
  font-size: clamp(24px, 6cqh, 34px);
  line-height: 1.1;
  color: #fff;
  overflow-wrap: anywhere;
}

#jeu .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#jeu .stat {
  position: relative;
  display: flex; flex-direction: column;
  background: rgba(255, 255, 255, .08);
  border-radius: 10px;
  padding: 6px 10px;
}
#jeu .stat.score { grid-column: 1 / -1; }
#jeu .lib { font-size: 12px; opacity: .65; }
#jeu .val {
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 26px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  transform-origin: left center;
}
#jeu .stat.score .val { font-size: 38px; color: #f2b632; }
#jeu .stat.score .val small { font-size: 15px; color: #f3f6f4; opacity: .6; }
#jeu .val.pop { animation: cd-pop .45s ease-out; }
#jeu .val.chaude { color: #ff9a3c; }
#jeu .stat.secoue { animation: cd-secoue .4s; }
#jeu .flottant {
  position: absolute; right: 12px; top: 8px;
  color: #7fe0ac; font-weight: 700; font-size: 20px;
  pointer-events: none;
  animation: cd-monte 1s ease-out forwards;
}
@keyframes cd-pop { 30% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes cd-monte { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-26px); } }
@keyframes cd-secoue { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* Jauge : les points en jeu diminuent avec le temps */
#jeu .jauge { display: flex; flex-direction: column; gap: 4px; }
#jeu .jauge-txt { display: flex; justify-content: space-between; align-items: baseline; }
#jeu .jauge-txt .pts {
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
#jeu .jauge-fond { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .15); overflow: hidden; }
#jeu .jauge-barre { height: 100%; width: 100%; border-radius: 4px; background: hsl(120, 70%, 50%); }

#jeu .progression { display: flex; flex-direction: column; gap: 6px; }
#jeu .progression .lib { opacity: .75; }
#jeu .pastilles { display: flex; gap: 5px; flex-wrap: wrap; }
#jeu .pastilles span {
  width: 15px; height: 15px; border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  box-sizing: border-box;
  transition: background .2s;
}
#jeu .pastilles span.cur { outline: 2px solid #f2b632; outline-offset: 1px; }
#jeu .pastilles span.ok { background: #3fb77a; }
#jeu .pastilles span.ko { background: #e2604f; }

#jeu .retour { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
#jeu .verdict { font-size: 15px; font-weight: 600; line-height: 1.3; min-height: 2.6em; }
#jeu .verdict.ok { color: #7fe0ac; }
#jeu .verdict.ko { color: #ffb0a6; }
#jeu .fiche {
  background: rgba(255, 255, 255, .08);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}
#jeu .fiche.neuf { animation: cd-apparait .35s ease-out; }
@keyframes cd-apparait { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#jeu .fiche b {
  display: block;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 17px; font-weight: 400; font-style: italic;
}
#jeu .fiche b small { font-size: 12px; font-style: normal; opacity: .6; }
#jeu .fiche .court { display: none; }
#jeu .fiche dl { margin: 6px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; }
#jeu .fiche dt { opacity: .6; }
#jeu .fiche dd { margin: 0; }
#jeu .fiche.vide {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, .25);
  opacity: .75;
}
#jeu .record { margin-top: auto; font-size: 12px; opacity: .7; }

/* ---------- Carte ---------- */
#jeu #zone-carte { flex: 1; position: relative; min-width: 0; min-height: 0; }
#jeu #zone-carte.tremble { animation: cd-tremble .45s; }
@keyframes cd-tremble { 15%, 55% { transform: translateX(-9px); } 35%, 75% { transform: translateX(9px); } }
#jeu #carte {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  touch-action: none;
  cursor: grab;
}
#jeu #carte:active { cursor: grabbing; }
#jeu .dep {
  fill: #eef1e6;
  stroke: #6d8590;
  stroke-width: .8px;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  cursor: pointer;
  transition: fill .15s;
}
@media (hover: hover) { #jeu:not(.verrou) .dep:hover { fill: #f6d98a; } }
#jeu.verrou .dep { cursor: default; }
/* Pays voisins (non jouables) et micro-États (points cliquables) */
#jeu .ctx {
  fill: #dfe5dc;
  stroke: #a5b3ba;
  stroke-width: .6px;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  pointer-events: none;
}
#jeu .dep.micro { fill: #f2c94c; stroke: #14303f; stroke-width: 1px; vector-effect: non-scaling-stroke; }
@media (hover: hover) { #jeu:not(.verrou) .dep.micro:hover { fill: #ffe68a; } }
#jeu .dep.bon { fill: #3fb77a; animation: cd-flashbon .6s ease-out; }
#jeu .dep.faux { fill: #e2604f; animation: cd-flashfaux .6s ease-out; }
@keyframes cd-flashbon { from { fill: #fff; } to { fill: #3fb77a; } }
@keyframes cd-flashfaux { 0% { fill: #fff; } 50% { fill: #a52e22; } 100% { fill: #e2604f; } }
#jeu .repere {
  fill: none;
  stroke: #1c8a52;
  stroke-width: 3px;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  animation: cd-repere .7s ease-in-out infinite alternate;
}
@keyframes cd-repere { from { opacity: .25; } to { opacity: 1; } }
#jeu .onde {
  fill: none;
  stroke: #3fb77a;
  stroke-width: 4px;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
  animation: cd-onde .8s ease-out forwards;
}
@keyframes cd-onde { from { transform: scale(.3); opacity: 1; } to { transform: scale(4); opacity: 0; } }

#jeu #flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
#jeu #flash.flash-ok { box-shadow: inset 0 0 90px 10px rgba(63, 183, 122, .75); animation: cd-flash .7s ease-out; }
#jeu #flash.flash-ko { box-shadow: inset 0 0 90px 10px rgba(226, 96, 79, .85); animation: cd-flash .7s ease-out; }
@keyframes cd-flash { from { opacity: 1; } to { opacity: 0; } }

#jeu #effets { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 12; }

@media (prefers-reduced-motion: reduce) {
  #jeu #zone-carte.tremble, #jeu .val.pop, #jeu .stat.secoue, #jeu .dep.bon, #jeu .dep.faux,
  #jeu .repere, #jeu .onde, #jeu #flash.flash-ok, #jeu #flash.flash-ko, #jeu .flottant,
  #jeu .fiche.neuf { animation: none; }
}

/* ---------- Boutons ---------- */
/* Zoom en bas à droite, boutons côte à côte */
#jeu .zoom { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: row; gap: 6px; }
#jeu .zoom button, #jeu .bi {
  width: 40px; height: 40px;
  border: 0; border-radius: 8px;
  background: rgba(20, 48, 63, .88);
  color: #fff;
  font-size: 22px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  margin: 0;
}
#jeu .zoom button:focus-visible, #jeu .bi:focus-visible { outline: 3px solid #f2b632; outline-offset: 2px; }
#jeu .bi { position: absolute; top: 10px; z-index: 5; }
#jeu #plein { right: 10px; }
#jeu #son { right: 58px; }
#jeu .bi svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#jeu #plein .reduire, #jeu #son .off { display: none; }
#jeu.plein #plein .agrandir { display: none; }
#jeu.plein #plein .reduire { display: block; }
#jeu.muet #son .on { display: none; }
#jeu.muet #son .off { display: block; }

#jeu #chargement {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 20px;
  font-size: 16px;
}

/* ---------- Écran de fin ---------- */
#jeu #fin {
  display: none;
  position: absolute; inset: 0; z-index: 10;
  background: rgba(10, 26, 36, .96);
  color: #f3f6f4;
  overflow: auto;
  padding: 20px 16px;
  box-sizing: border-box;
}
#jeu #fin.visible { display: flex; }
#jeu #fin .boite { margin: auto; text-align: center; max-width: 540px; width: 100%; }
#jeu #fin h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; opacity: .8; color: inherit; }
#jeu #fin .gros {
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: clamp(48px, 16cqmin, 84px);
  color: #f2b632;
  line-height: 1;
}
#jeu #fin .gros small { font-size: .4em; opacity: .7; }
#jeu #fin p { color: inherit; }
#jeu #fin .temps { margin: 8px 0 2px; font-size: 16px; }
#jeu #fin .record-fin { margin: 0 0 4px; font-size: 14px; opacity: .8; }
#jeu #fin .record-fin.nouveau { color: #f2b632; opacity: 1; font-weight: 700; }
#jeu #fin .mot { margin: 0 0 14px; opacity: .85; }
#jeu #fin ul {
  list-style: none; margin: 0 0 16px; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px;
  text-align: left; font-size: 14px;
}
#jeu #fin li { margin: 0; padding: 0; }
#jeu #fin li.ok::before { content: "✔ "; color: #3fb77a; }
#jeu #fin li.ko::before { content: "✘ "; color: #e2604f; }
#jeu #fin li small { opacity: .65; }
#jeu #fin .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#jeu #fin .btn {
  border: 2px solid #f2b632; border-radius: 8px;
  background: #f2b632; color: #14303f;
  font: inherit; font-size: 16px; font-weight: 700;
  padding: 10px 22px;
  margin: 0;
  cursor: pointer;
}
#jeu #fin .btn.sec { background: transparent; color: #f2b632; }
#jeu #fin .btn:focus-visible, #jeu #fin .rs:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
#jeu #fin .partage { display: none; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
#jeu #fin .partage.visible { display: flex; }
#jeu #fin .rs {
  border: 0; border-radius: 999px;
  background: rgba(255, 255, 255, .14); color: #fff;
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 16px;
  margin: 0;
  text-decoration: none;
  cursor: pointer;
}
#jeu #fin .rs:hover { background: rgba(255, 255, 255, .26); }

/* ---------- Format portrait (téléphone, tablette verticale) ---------- */
@container (max-aspect-ratio: 1/1) {
  #jeu #cadre { flex-direction: column; }
  #jeu #panneau {
    flex: 0 0 auto;
    padding: 10px 108px 10px 12px;
    gap: 8px;
    overflow: visible;
  }
  #jeu .titre, #jeu .record, #jeu .fiche dl, #jeu .fiche.vide { display: none; }
  #jeu .question { display: block; min-height: 0; padding: 4px 0; background: none; }
  #jeu .consigne { display: inline; margin: 0 8px 0 0; font-size: 13px; }
  #jeu .cible { display: inline; font-size: clamp(22px, 7cqw, 32px); }
  #jeu .stats { grid-template-columns: repeat(3, auto); justify-content: start; gap: 6px; }
  #jeu .stat { padding: 4px 10px; }
  #jeu .stat.score { grid-column: auto; }
  #jeu .val, #jeu .stat.score .val { font-size: 20px; }
  #jeu .stat.score .val small { display: none; }
  #jeu .lib { font-size: 11px; }
  #jeu .jauge { flex-direction: row; align-items: center; gap: 8px; }
  #jeu .jauge-txt { flex: 0 0 auto; gap: 8px; }
  #jeu .jauge-fond { flex: 1; }
  #jeu .progression { flex-direction: row; align-items: center; gap: 10px; }
  #jeu .retour { flex: none; gap: 4px; }
  #jeu .verdict { min-height: 1.3em; font-size: 13px; }
  #jeu .fiche { padding: 5px 10px; font-size: 12px; }
  #jeu .fiche b { font-size: 15px; }
  #jeu .fiche .court { display: block; opacity: .8; }
  #jeu #fin ul { grid-template-columns: 1fr; }
}

/* Petite hauteur en paysage (téléphone couché) */
@container (max-height: 420px) and (min-aspect-ratio: 1/1) {
  #jeu #panneau { flex-basis: 220px; padding: 8px 10px; gap: 6px; }
  #jeu .titre, #jeu .record, #jeu .fiche dl, #jeu .fiche.vide { display: none; }
  #jeu .question { min-height: 0; padding: 4px; }
  #jeu .cible { font-size: 22px; }
  #jeu .stat { padding: 4px 8px; }
  #jeu .val { font-size: 18px; }
  #jeu .stat.score .val { font-size: 26px; }
  #jeu .stat.score .val small { display: none; }
  #jeu .verdict { font-size: 12px; min-height: 2.6em; }
  #jeu .fiche { padding: 5px 8px; font-size: 11px; }
  #jeu .fiche b { font-size: 14px; }
  #jeu .fiche .court { display: block; opacity: .8; }
}

/* ---------- Intégration dans Quizenligne ---------- */

#jeu {
    width: 100%;
    height: 100%;
    max-width: 800px;
    margin: 0 auto;
    border-radius: 0;
}

/* Le conteneur de Quizenligne gère les dimensions */
@media (pointer: coarse), (max-width: 820px) {
    #jeu {
        width: 100%;
        height: 100%;
        max-width: 800px;
        max-height: none;
        border-radius: 0;
    }
}
