:root { --top: 0px; --bottom: 0px; --bleu: #1e6bff; --jaune: #ffd93d; --rose: #ff5d73; --vert: #3ecf6e; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; height: 100dvh; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif; color: #12306b;
  background: linear-gradient(180deg, #0b1d5c 0%, #2a4bd6 45%, #6fc3ff 100%);
  user-select: none; -webkit-user-select: none;
}
#stage { position: fixed; left: 0; right: 0; top: var(--top); bottom: var(--bottom); }
#gl { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

button.gros {
  min-width: 64px; min-height: 64px; padding: 8px 16px; font: inherit; font-size: 28px; line-height: 1;
  border: 0; border-radius: 20px; background: #fff; color: #12306b; cursor: pointer;
  box-shadow: 0 5px 0 rgba(10, 30, 100, .35); transition: transform .12s;
}
button.gros:active { transform: translateY(3px) scale(.96); box-shadow: 0 2px 0 rgba(10, 30, 100, .35); }
button.gros:disabled { opacity: .45; cursor: default; }
button.enorme { font-size: 34px; min-height: 84px; padding: 12px 36px; background: var(--jaune); }

#hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 10; display: flex; gap: 10px; align-items: center;
  padding: 10px 92px 10px 10px; flex-wrap: wrap;
}
#hud[hidden] { display: none; }
#bandeau {
  flex: 1 1 220px; min-height: 64px; display: flex; flex-direction: column; justify-content: center;
  background: #fff; border-radius: 22px; padding: 8px 18px; box-shadow: 0 5px 0 rgba(10, 30, 100, .35);
}
#mission-texte { font-size: clamp(20px, 3.4vw, 32px); font-weight: 700; }
#indice { font-size: clamp(16px, 2.4vw, 22px); color: #d6336c; min-height: 0; }
#indice:empty { display: none; }
#etoiles { background: var(--jaune); border-radius: 20px; padding: 0 16px; font-size: 28px; min-height: 64px; display: flex; align-items: center; gap: 6px; box-shadow: 0 5px 0 rgba(10, 30, 100, .35); }
#btn-voix.off { opacity: .45; }
#zoom { position: fixed; right: 10px; top: 50%; transform: translateY(-50%); z-index: 12; display: flex; flex-direction: column; gap: 12px; }
body.mode-accueil #zoom { display: none; }
#zoom button { width: 64px; height: 64px; padding: 0; font-size: 30px; }
#btn-album { position: fixed; top: 10px; right: 10px; z-index: 40; background: var(--rose); color: #fff; }
#btn-album.pulse { animation: boing .7s; }

#flags {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; gap: 14px; justify-content: center;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); flex-wrap: nowrap;
}
#flags[hidden] { display: none; }
#flags button { padding: 8px; min-width: 96px; flex: 0 1 200px; }
#flags canvas { width: 100%; height: auto; display: block; border-radius: 8px; aspect-ratio: 3 / 2; }
#flags button.bon { background: var(--vert); animation: boing .6s; }
#flags button.essaie { animation: tremble .4s; }
#flags button.indice { outline: 6px solid var(--jaune); animation: boing .8s infinite; }

.ecran {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 29, 92, .55); padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); overflow: auto; max-height: 100dvh; -webkit-overflow-scrolling: touch;
}
.ecran[hidden] { display: none; }
.carte {
  background: #fff; border-radius: 32px; padding: 22px 26px; max-width: 560px; width: 100%; text-align: center;
  display: flex; flex-direction: column; gap: 16px; align-items: center; box-shadow: 0 10px 0 rgba(10, 30, 100, .3);
  max-height: 100%; overflow: auto;
}
.carte.large { max-width: 860px; }
#accueil .carte { background: transparent; box-shadow: none; }
#titre-img { max-width: min(560px, 90vw); width: 100%; border-radius: 28px; box-shadow: 0 8px 0 rgba(10, 30, 100, .3); }
h1 { margin: 0; font-size: clamp(44px, 9vw, 84px); line-height: 1; color: #fff; text-shadow: 0 5px 0 #1e3fae; }
h2 { margin: 0; font-size: 36px; }
#fin-texte { margin: 0; font-size: 26px; }
#fin-etoiles { font-size: 44px; }
#paliers { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
#paliers button { font-size: 30px; padding: 6px 14px; min-width: 88px; }
#paliers small { display: block; font-size: 15px; margin-top: 4px; }

#album-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; width: 100%; }
.vignette {
  border-radius: 18px; background: #eef4ff; padding: 8px; min-height: 104px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; font-size: 14px; border: 3px solid #cfe0ff;
}
.vignette .ico { font-size: 40px; line-height: 1.1; height: 52px; display: flex; align-items: center; }
.vignette img, .vignette canvas { max-height: 52px; max-width: 80px; border-radius: 6px; }
.vignette.vide { background: #dfe3ee; color: #8b93a7; border-style: dashed; }
.vignette.plein { border-color: var(--jaune); background: #fffbe6; }

#pop { position: fixed; left: 50%; top: 42%; z-index: 35; font-size: 72px; pointer-events: none; transform: translate(-50%, -50%); }
#pop .p { display: inline-block; animation: pop 1.3s ease-out forwards; }

@keyframes boing { 0% { transform: scale(1, 1); } 25% { transform: scale(1.2, .85); } 50% { transform: scale(.9, 1.15); } 75% { transform: scale(1.06, .96); } 100% { transform: scale(1, 1); } }
@keyframes tremble { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes pop { 0% { transform: scale(0, 0); opacity: 0; } 25% { transform: scale(1.4, .8); opacity: 1; } 45% { transform: scale(.9, 1.2); } 60% { transform: scale(1, 1); } 100% { transform: translateY(-80px) scale(1, 1); opacity: 0; } }

@media (max-width: 640px) {
  button.gros { font-size: 24px; }
  #hud { padding-right: 84px; gap: 8px; }
  #flags { gap: 8px; }
}

@media (max-width: 480px) {
  button.gros { min-height: 52px; min-width: 52px; }
  .carte { padding: 14px; gap: 10px; border-radius: 24px; }
  #paliers button { min-width: 56px; font-size: 24px; }
  #bandeau { padding: 6px 12px; min-height: 52px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .carte { padding: 8px 16px; gap: 6px; border-radius: 20px; }
  #accueil .carte { flex-direction: row; flex-wrap: wrap; justify-content: center; max-width: 760px; }
  #titre-img { max-width: 30vw; max-height: 34dvh; width: auto; border-radius: 16px; }
  h1 { font-size: clamp(28px, 11dvh, 44px); }
  h2 { font-size: 24px; }
  button.gros { min-height: 48px; min-width: 48px; font-size: 22px; padding: 4px 12px; }
  button.enorme { min-height: 56px; font-size: 26px; padding: 6px 24px; }
  #paliers { gap: 8px; flex-basis: 100%; }
  #paliers button { min-width: 64px; font-size: 22px; padding: 4px 10px; }
  #paliers small { font-size: 12px; margin-top: 0; }
  #fin-etoiles { font-size: 30px; }
  #fin-texte { font-size: 18px; }
  #hud { padding-top: 6px; padding-bottom: 6px; }
  #bandeau { min-height: 48px; padding: 4px 14px; }
  #etoiles { min-height: 48px; font-size: 22px; }
  #zoom button { width: 48px; height: 48px; }
  #zoom { gap: 8px; }
  #flags { padding-top: 6px; }
  #flags button { min-width: 72px; flex-basis: 110px; padding: 4px; }
}
