/* Jeu « Stand de tir des maths » – 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; }
#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 à gauche (pour ne pas masquer la Corse) */
#jeu .zoom { position: absolute; left: 10px; bottom: 10px; display: flex; flex-direction: column; 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; }
}

/* ---------- Grandes villes : fond de carte, points, noms, choix du niveau ---------- */
#jeu .fond {
  fill: #eef1e6;
  stroke: #b7c4c9;
  stroke-width: .6px;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  pointer-events: none;
}
#jeu .ville {
  fill: #e4572e;
  stroke: #fff;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill .15s;
}
@media (hover: hover) { #jeu:not(.verrou) .ville:hover { fill: #ffb703; } }
#jeu.verrou .ville { cursor: default; }
#jeu .ville.bon { fill: #3fb77a; }
#jeu .ville.faux { fill: #a52e22; }
#jeu .etiq {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 700;
  fill: #14303f;
  stroke: #fff;
  paint-order: stroke;
  stroke-linejoin: round;
  dominant-baseline: central;
  pointer-events: none;
}
#jeu .etiq.bon { fill: #1c8a52; }
#jeu .etiq.faux { fill: #a52e22; }

#jeu #fin .intro { margin: 8px 0 16px; opacity: .85; color: inherit; }
#jeu #fin .niveaux { display: flex; flex-direction: column; gap: 10px; }
#jeu #fin .btn-niveau {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left;
  border: 2px solid rgba(242, 182, 50, .5); border-radius: 10px;
  background: rgba(255, 255, 255, .06); color: #fff;
  font: inherit;
  padding: 12px 16px;
  margin: 0;
  cursor: pointer;
}
#jeu #fin .btn-niveau:hover { background: rgba(242, 182, 50, .15); border-color: #f2b632; }
#jeu #fin .btn-niveau:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
#jeu #fin .nv-titre { font-size: 17px; font-weight: 700; color: #f2b632; }
#jeu #fin .nv-sous { font-size: 13px; opacity: .8; }

/* ---------- Stand de tir : décor, cibles, balles, viseur ---------- */
#jeu:focus { outline: none; }
#jeu .titre { text-align: center; }
#jeu #zone-carte {
  container-type: size;
  overflow: hidden;
  touch-action: none;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .035) 0 22px, transparent 22px 44px),
    linear-gradient(180deg, #0f2a4a 0%, #1f4d7a 55%, #2e6a94 100%);
}
#jeu #zone-carte.vise { cursor: none; }

/* Auvent rayé, guirlande d'ampoules et comptoir en bois */
#jeu .auvent {
  position: absolute; left: 0; right: 0; top: 0; height: 13%; z-index: 1;
  background: repeating-linear-gradient(90deg, #d8402f 0 56px, #fbf0d9 56px 112px);
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 28px) no-repeat,
                radial-gradient(circle at 50% 0, #000 27px, transparent 28.5px) bottom / 56px 28px repeat-x;
  mask: linear-gradient(#000 0 0) top / 100% calc(100% - 28px) no-repeat,
        radial-gradient(circle at 50% 0, #000 27px, transparent 28.5px) bottom / 56px 28px repeat-x;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .35));
  pointer-events: none;
}
#jeu .guirlande {
  position: absolute; left: 0; right: 0; top: calc(13% + 2px); height: 18px; z-index: 1;
  background: radial-gradient(circle at 50% 50%, #fff3b8 0 3px, rgba(255, 205, 90, .55) 4px, rgba(255, 205, 90, 0) 9px) 0 0 / 56px 18px repeat-x;
  animation: cd-ampoules 1.4s steps(1, end) infinite;
  pointer-events: none;
}
#jeu .guirlande.b { background-position: 28px 0; animation-delay: -.7s; }
@keyframes cd-ampoules { 0% { opacity: 1; } 50% { opacity: .3; } }
#jeu .comptoir {
  position: absolute; left: 0; right: 0; bottom: 0; height: 14%; z-index: 1;
  background:
    repeating-linear-gradient(90deg, transparent 0 118px, rgba(0, 0, 0, .2) 118px 120px),
    linear-gradient(180deg, #c58a4a 0 6px, #8a5a2b 6px, #6d4220 100%);
  box-shadow: 0 -6px 10px rgba(0, 0, 0, .35);
  pointer-events: none;
}
#jeu .munitions {
  position: absolute; left: 50%; top: 52%;
  transform: translate(-50%, -50%);
  display: flex; align-items: flex-end; gap: 9px;
}
#jeu .balle {
  position: relative; display: block;
  width: 11px; height: 28px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(90deg, #fff3b0, #f2b632 45%, #b27a10);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .55);
  transition: transform .2s, opacity .2s;
}
#jeu .balle::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 32%;
  background: linear-gradient(90deg, #e0a45c, #a8672a);
  border-radius: 0 0 2px 2px;
}
#jeu .balle.tiree { opacity: .2; transform: translateY(6px); }
#jeu .balle.recharge { animation: cd-recharge .35s ease-out backwards; animation-delay: calc(var(--k) * 70ms); }
@keyframes cd-recharge { from { transform: translateY(-46px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Les trois rangées : ballons en haut, canards sur l'eau, cibles rondes sur l'étagère */
#jeu #scene, #jeu .eau, #jeu .etagere { --t: min(19cqh, 22cqw); }
#jeu #scene { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
#jeu .eau {
  position: absolute; left: 0; right: 0; z-index: 4; pointer-events: none;
  top: calc(51.5% + var(--t) * .27); height: calc(var(--t) * .26);
  background: linear-gradient(180deg, rgba(150, 215, 245, .92), rgba(33, 118, 176, .96));
  border-top: 2px solid rgba(255, 255, 255, .6);
  box-shadow: inset 0 6px 8px rgba(255, 255, 255, .15);
}
#jeu .etagere {
  position: absolute; left: 0; right: 0; z-index: 4; pointer-events: none;
  top: calc(74.5% + var(--t) * .44); height: calc(var(--t) * .16);
  background: linear-gradient(180deg, #b5803f, #7a4b22);
  border-top: 2px solid #d9a766;
  box-shadow: 0 4px 6px rgba(0, 0, 0, .4);
}
#jeu .but {
  position: absolute; left: 0;
  top: calc(var(--y) * 1% - var(--t) / 2);
  width: var(--t); height: var(--t);
  pointer-events: none;
  will-change: transform;
}
#jeu .but-in { width: 100%; height: 100%; transform-origin: 50% 100%; }
#jeu .but-svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .35)); }

/* Cible touchée : le ballon éclate, le canard et la cible ronde basculent */
#jeu .but.touche .but-in { animation: cd-bascule .45s ease-in forwards; }
@keyframes cd-bascule {
  0% { transform: perspective(500px) rotateX(0); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: perspective(500px) rotateX(-92deg); opacity: 0; }
}
#jeu .but.eclate .but-in { animation: cd-eclate .26s ease-out forwards; transform-origin: 50% 45%; }
@keyframes cd-eclate {
  0% { transform: scale(1); opacity: 1; }
  40% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(1.7); opacity: 0; }
}
#jeu .but.retire .but-in { animation: cd-retire .4s ease-in forwards; }
@keyframes cd-retire {
  from { transform: perspective(500px) rotateX(0); opacity: 1; }
  to { transform: perspective(500px) translateY(25%) rotateX(-70deg); opacity: 0; }
}
#jeu .but.bon .but-svg { filter: drop-shadow(0 0 10px #3fb77a) drop-shadow(0 0 4px #3fb77a); }
#jeu .but.bon::after {
  content: ""; position: absolute; inset: -6%;
  border: 4px solid #3fb77a; border-radius: 50%;
  animation: cd-repere .7s ease-in-out infinite alternate;
}
#jeu .but.faux .but-svg { filter: drop-shadow(0 0 10px #e2604f) saturate(1.4); }
#jeu .but.faux .but-in { animation: cd-secoue-but .4s; }
@keyframes cd-secoue-but { 20%, 60% { transform: rotate(-9deg); } 40%, 80% { transform: rotate(9deg); } }

/* Viseur, impacts, éclair du tir et texte qui s'envole */
#jeu .viseur {
  position: absolute; left: 0; top: 0; z-index: 10;
  width: 46px; height: 46px; margin: -23px 0 0 -23px;
  pointer-events: none; opacity: 0;
}
#jeu .viseur.actif { opacity: 1; }
#jeu .viseur-in { width: 100%; height: 100%; }
#jeu .viseur-in.recul { animation: cd-recul .22s ease-out; }
@keyframes cd-recul { 0% { transform: scale(1.5) rotate(-12deg); } 100% { transform: scale(1) rotate(0); } }
#jeu .viseur svg {
  display: block; width: 100%; height: 100%; overflow: visible;
  fill: none; stroke: #ff4d3d; stroke-width: 3; stroke-linecap: round;
  filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 1px #fff);
}
#jeu .viseur svg .pt { fill: #ff4d3d; stroke: none; }
#jeu .impacts { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
#jeu .impact {
  position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%;
  background: radial-gradient(circle, #0b0b0b 0 32%, #3a3a3a 33% 56%, rgba(255, 255, 255, .25) 57% 66%, transparent 67%);
  animation: cd-impact 2.6s ease-out forwards;
}
@keyframes cd-impact { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
#jeu .eclair {
  position: absolute; z-index: 9; width: 90px; height: 90px; margin: -45px 0 0 -45px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 247, 194, .95) 0, rgba(255, 200, 80, .5) 35%, transparent 65%);
  pointer-events: none;
  animation: cd-eclair .18s ease-out forwards;
}
@keyframes cd-eclair { from { opacity: 1; transform: scale(.4); } to { opacity: 0; transform: scale(1.2); } }
#jeu .gain {
  position: absolute; z-index: 9; transform: translate(-50%, -50%);
  font-size: 30px; font-weight: 800; white-space: nowrap;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .55), 0 0 6px rgba(0, 0, 0, .4);
  pointer-events: none;
  animation: cd-gain 1s ease-out forwards;
}
#jeu .gain.ok { color: #7fe0ac; }
#jeu .gain.ko { color: #ff8a7a; }
@keyframes cd-gain {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  20% { opacity: 1; transform: translate(-50%, -60%) scale(1.25); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}
#jeu #flash { z-index: 11; }

@media (prefers-reduced-motion: reduce) {
  #jeu .guirlande, #jeu .balle.recharge, #jeu .but.bon::after, #jeu .but.faux .but-in, #jeu .viseur-in.recul,
  #jeu .impact, #jeu .gain { animation: none; }
  #jeu .but.touche .but-in, #jeu .but.eclate .but-in, #jeu .but.retire .but-in { animation: none; opacity: 0; }
}

/* ---------- Panneau de gauche sans défilement ---------- */
#jeu .consigne:empty { display: none; }
@container (min-aspect-ratio: 1/1) {
  #jeu #panneau { overflow: hidden; }
  #jeu .retour { overflow: hidden; }
}
/* Si la hauteur disponible est inférieure à 600 px, on retire le rappel de la consigne pour que tout tienne */
@container (max-height: 599px) and (min-aspect-ratio: 1/1) {
  #jeu .fiche.vide { display: none; }
}

/* ---------- 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;
    }
}
