/* MapAdri – © 2026 Pierre DULOY – https://github.com/pierre3119/mapadri
   Habillage. Tout est gros, rond et coloré : c'est fait pour des doigts de 4 ans. */

@font-face {
  font-family: 'Fredoka';
  src: url('../fonts/fredoka.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #1d2760;
  --soft: #6c79ad;
  --paper: #ffffff;
  --shadow: 0 6px 0 rgba(13, 20, 66, .28), 0 12px 26px rgba(4, 8, 36, .35);
  --fab: clamp(52px, 7.5vmin, 68px);
  --gap: clamp(8px, 1.6vmin, 16px);
  --flag-h: clamp(42px, 8.25vmin, 72px);
  --lift: 0px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: 'Fredoka', 'Baloo 2', 'Nunito', 'Comic Sans MS', 'Trebuchet MS', system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(ellipse at 50% 45%, #2a3d9c 0%, #172266 42%, #0a0e30 100%);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

img { -webkit-user-drag: none; }

/* ------------------------------------------------------------------ globe */

#globe {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  outline: none;
}
#globe.pointing { cursor: pointer; }
#globe.grabbing { cursor: grabbing; }

#pins {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}
.pin { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform; }
.pin i {
  position: absolute;
  left: -2px;
  bottom: 0;
  width: 4px;
  height: 42px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(10, 20, 60, .3);
  transform-origin: 50% 100%;
  animation: pin-in .5s cubic-bezier(.2, 1.6, .4, 1) both;
}
.pin img {
  position: absolute;
  left: 2px;
  bottom: 18px;
  height: 24px;
  max-width: 46px;
  object-fit: contain;
  object-position: left bottom;
  border-radius: 2px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .55));
  transform-origin: 0 100%;
  animation: pin-in .5s .15s cubic-bezier(.2, 1.6, .4, 1) both;
}

/* la capitale du pays choisi : une étoile et son nom, posés sur le globe */
#capital {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 3;
  width: 0;
  height: 0;
  display: none;
  pointer-events: none;
  will-change: transform;
}
#capital svg {
  position: absolute;
  left: -15px;
  top: -15px;
  width: 30px;
  height: 30px;
  fill: #ff3b3b;
  stroke: #fff;
  stroke-width: 2.2;
  stroke-linejoin: round;
  paint-order: stroke fill;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .6));
  animation: cap-star .8s ease-in-out infinite alternate;
}
#capital span {
  position: absolute;
  left: 19px;
  top: 0;
  transform: translateY(-50%);
  padding: .12em .6em;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 3px 10px rgba(4, 8, 36, .45);
  font-weight: 600;
  font-size: clamp(15px, 2.5vmin, 22px);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ le petit bonhomme */

#buddy {
  --bs: 100px;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 4;
  width: 0;
  height: 0;
  pointer-events: none;
  will-change: transform;
}
#buddy.front { z-index: 31; }
body[data-screen="loading"] #buddy { display: none; }
#buddy .b-jump { position: absolute; left: 0; top: 0; width: 0; height: 0; }
#buddy svg {
  position: absolute;
  left: calc(var(--bs) * -.283);
  bottom: calc(var(--bs) * -.0189);
  width: calc(var(--bs) * .566);
  height: var(--bs);
  overflow: visible;
  filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, .9)) drop-shadow(0 3px 4px rgba(4, 8, 36, .5));
}
#buddy .b-skin { fill: none; stroke: var(--skin, #f6cba8); stroke-width: 9; stroke-linecap: round; }
#buddy .b-leg .b-skin { stroke-width: 10; }
#buddy .b-sleeve { fill: none; stroke: #ff7a3d; stroke-width: 12.5; stroke-linecap: round; }
#buddy .b-hand { fill: var(--skin, #f6cba8); }
#buddy .b-neck { fill: var(--skin-dark, #d4af90); }
#buddy .b-shoe { fill: #ffd23f; stroke: #c98a00; stroke-width: 1.5; }
#buddy .b-shorts { fill: #2b4aa0; }
#buddy .b-shirt { fill: #ff7a3d; }
#buddy .b-star { fill: #ffe45c; }
#buddy .b-tear { fill: #6fd0ff; stroke: #fff; stroke-width: 1.2; opacity: 0; }
#buddy.sad .b-tear { animation: b-tear 1.15s .3s ease-in infinite; }
#buddy .b-lean, #buddy .b-head, #buddy .b-arm, #buddy .b-leg { transition: transform .35s; }

/* il court */
#buddy.run .b-lean { animation: b-bob .3s ease-in-out infinite alternate; }
#buddy.run .b-leg.b-l, #buddy.run .b-arm.b-r { animation: b-swing-a .3s ease-in-out infinite alternate; }
#buddy.run .b-leg.b-r, #buddy.run .b-arm.b-l { animation: b-swing-b .3s ease-in-out infinite alternate; }
#buddy .b-jump.hop { animation: b-hop .55s; }

/* il a gagné : il saute en agitant les bras et les jambes */
#buddy.cheer .b-jump { animation: b-jump .56s infinite; }
#buddy.cheer .b-arm.b-l { animation: b-wave-l .19s ease-in-out infinite alternate; }
#buddy.cheer .b-arm.b-r { animation: b-wave-r .19s ease-in-out infinite alternate; }
#buddy.cheer .b-leg.b-l { animation: b-jack-l .28s ease-in-out infinite alternate; }
#buddy.cheer .b-leg.b-r { animation: b-jack-r .28s ease-in-out infinite alternate; }
#buddy.cheer .b-head { animation: b-nod .28s ease-in-out infinite alternate; }

/* il s'est trompé : il se penche, la tête basse */
#buddy.sad .b-lean { transform: rotate(13deg); animation: b-sway 1.4s .35s ease-in-out infinite alternate; }
#buddy.sad .b-head { transform: rotate(18deg) translateY(2px); }
#buddy.sad .b-arm.b-l { transform: rotate(-9deg); }
#buddy.sad .b-arm.b-r { transform: rotate(-17deg); }
#buddy.sad.mirror svg { transform: scaleX(-1); }

/* en voyage : il salue quand il est arrivé, il court ou prend l'avion pour repartir */
#buddy .b-plane {
  display: none;
  position: absolute;
  left: calc(var(--bs) * -.33);
  top: calc(var(--bs) * -.4);
  font-size: calc(var(--bs) * .66);
  line-height: 1;
  filter: drop-shadow(0 3px 4px rgba(4, 8, 36, .5));
}
#buddy.wave .b-lean { animation: b-idle 1.1s ease-in-out infinite alternate; }
#buddy.wave .b-arm.b-r { animation: b-hello .3s ease-in-out infinite alternate; }
#buddy.fly .b-plane { display: block; }
#buddy.fly .b-jump { animation: b-float .7s ease-in-out infinite alternate; }
#buddy.fly .b-arm.b-l { transform: rotate(138deg); }
#buddy.fly .b-arm.b-r { transform: rotate(-138deg); }
#buddy.fly .b-leg.b-l { transform: rotate(48deg); }
#buddy.fly .b-leg.b-r { transform: rotate(-48deg); }

/* ------------------------------------------------------------------ boutons ronds */

.fab {
  width: var(--fab);
  height: var(--fab);
  flex: none;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: calc(var(--fab) * .48);
  line-height: 1;
  transition: transform .12s, box-shadow .12s;
}
.fab.small { --fab: clamp(42px, 6vmin, 52px); }
.fab:active, .big:active {
  animation: none;
  transform: translateY(4px) scale(.95);
  box-shadow: 0 2px 0 rgba(13, 20, 66, .28), 0 4px 10px rgba(4, 8, 36, .3);
}

.pill {
  height: var(--fab);
  padding: 0 calc(var(--fab) * .34);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: .25em;
  font-size: calc(var(--fab) * .44);
  font-weight: 600;
  white-space: nowrap;
}
.pill.bump { animation: bump .6s cubic-bezier(.2, 1.8, .4, 1); }

#btn-home { position: fixed; z-index: 10; left: var(--gap); top: var(--gap); }
#top-right {
  position: fixed;
  z-index: 10;
  right: var(--gap);
  top: var(--gap);
  display: flex;
  align-items: center;
  gap: var(--gap);
}
#zoom {
  position: fixed;
  z-index: 10;
  left: var(--gap);
  bottom: calc(var(--gap) + var(--lift));
  display: none;
  flex-direction: column;
  gap: var(--gap);
  transition: bottom .3s;
}
#btn-hint {
  position: fixed;
  z-index: 10;
  right: var(--gap);
  bottom: var(--gap);
  display: none;
  background: #ffe45c;
  animation: wiggle 3.4s ease-in-out infinite;
}

/* la vue satellite : le bouton existe dans tous les modes et reste allumé quand elle est active */
#btn-style.on, #trip-pause.on {
  background: #ffe45c;
  box-shadow: 0 0 0 4px rgba(255, 228, 92, .5), var(--shadow);
}

body[data-screen="loading"] #btn-home,
body[data-screen="loading"] #top-right,
body[data-screen="home"] #btn-home { display: none; }
body[data-screen="explore"] #zoom,
body[data-screen="game"] #zoom,
body[data-screen="trip"] #zoom { display: flex; }
body[data-screen="game"] #btn-hint { display: grid; }

/* ------------------------------------------------------------------ accueil, niveaux */

.panel {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 12;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: clamp(10px, 3vh, 34px) 12px clamp(14px, 4vh, 44px);
  pointer-events: none;
}
.panel > * { pointer-events: auto; }
body[data-screen="home"] #home,
body[data-screen="levels"] #levels,
body[data-screen="conts"] #conts,
body[data-screen="win"] #win { display: flex; }

.title { text-align: center; pointer-events: none; }
.title h1 {
  margin: 0;
  font-size: clamp(54px, 13vmin, 128px);
  line-height: .95;
  font-weight: 700;
  letter-spacing: .02em;
}
.title h1 span {
  display: inline-block;
  -webkit-text-stroke: .08em #fff;
  paint-order: stroke fill;
  text-shadow: 0 .07em 0 rgba(6, 10, 44, .4);
  animation: bob 1.5s ease-in-out infinite alternate;
}
.title h1 span:nth-child(1) { color: #ff5d5d; }
.title h1 span:nth-child(2) { color: #ffa23a; animation-delay: -.25s; }
.title h1 span:nth-child(3) { color: #ffd93b; animation-delay: -.5s; }
.title h1 span:nth-child(4) { color: #5fd66b; animation-delay: -.75s; }
.title h1 span:nth-child(5) { color: #3ec5ff; animation-delay: -1s; }
.title h1 span:nth-child(6) { color: #8a97ff; animation-delay: -1.25s; }
.title h1 span:nth-child(7) { color: #e083ff; animation-delay: -1.5s; }
.title p, .title h2 {
  margin: .15em 0 0;
  color: #fff;
  font-weight: 600;
  font-size: clamp(17px, 3.6vmin, 34px);
  text-shadow: 0 2px 0 rgba(6, 10, 44, .6), 0 0 5px rgba(6, 10, 44, .9), 0 0 16px rgba(6, 10, 44, .9);
}
.title h2 { font-size: clamp(30px, 7.5vmin, 68px); font-weight: 700; }

.choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
  gap: clamp(12px, 3.2vmin, 36px);
}
.big {
  --s: clamp(104px, 27vmin, 210px);
  width: var(--s);
  height: var(--s);
  flex: none;
  padding: 0 4px;
  border-radius: 24%;
  color: #fff;
  font-weight: 600;
  font-size: calc(var(--s) * .15);
  line-height: 1.1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .22);
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .16), inset 0 4px 0 rgba(255, 255, 255, .35), var(--shadow);
  transition: transform .12s;
  animation: float 3s ease-in-out infinite;
}
.big:nth-child(2) { animation-delay: -1s; }
.big:nth-child(3) { animation-delay: -2s; }
.big:nth-child(4) { animation-delay: -.5s; }
.big:nth-child(5) { animation-delay: -1.5s; }
.big:nth-child(6) { animation-delay: -2.5s; }
.big .ico { font-size: calc(var(--s) * .44); line-height: 1.1; text-shadow: none; }
.big small { font-size: .58em; font-weight: 500; opacity: .92; }
.explore { background: linear-gradient(160deg, #58d6ff, #1b8fe8); }
.play { background: linear-gradient(160deg, #ffc247, #ff6f3c); }
.big.trip { background: linear-gradient(160deg, #b9a2ff, #6b4fe0); }
.big.all { background: linear-gradient(160deg, #ff9fd0, #e0368f); }
.l1 { background: linear-gradient(160deg, #a7ec6a, #37b24d); }
.l2 { background: linear-gradient(160deg, #ffc247, #ff7f2a); }
.l3 { background: linear-gradient(160deg, #ff8f8f, #e03163); }

/* beaucoup de choix (les continents) : boutons plus petits, sur une ou deux rangées */
.choices.many {
  --cs: clamp(86px, 18.5vmin, 150px);
  --cg: clamp(8px, 2vmin, 22px);
  gap: var(--cg);
}
.choices.many .big { --s: var(--cs); }
.choices.many .big .ico { font-size: calc(var(--s) * .36); }
.choices.many .big .txt { font-size: .88em; line-height: 1.02; }
.choices.many .big small { font-size: .7em; }
@media (max-aspect-ratio: 3/2) {
  .choices.many { max-width: calc(var(--cs) * 4 + var(--cg) * 3 + 4px); }
}

/* ------------------------------------------------------------------ exploration */

.bubble {
  position: fixed;
  z-index: 10;
  left: 0;
  right: 0;
  bottom: calc(var(--gap) * 2);
  width: -moz-fit-content;
  width: fit-content;
  margin: 0 auto;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  padding: .5em 1.1em;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: clamp(18px, 3.4vmin, 28px);
  white-space: nowrap;
  transition: opacity .3s, transform .3s;
}
body[data-screen="explore"] .bubble.show {
  opacity: 1;
  transform: none;
  animation: nudge 1.4s .4s ease-in-out infinite alternate;
}

#card {
  position: fixed;
  z-index: 14;
  right: var(--gap);
  top: calc(var(--fab) + var(--gap) * 2);
  width: min(350px, 42vw);
  max-height: calc(100% - var(--fab) - var(--gap) * 3);
  display: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 14px;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 14px 40px rgba(4, 8, 36, .5);
  font-size: clamp(15px, 2.1vmin, 18px);
  transform: translateX(calc(100% + 40px));
  visibility: hidden;
  transition: transform .38s cubic-bezier(.2, .9, .3, 1.15), visibility 0s .38s;
}
body[data-screen="explore"] #card { display: block; }
#card.open {
  transform: none;
  visibility: visible;
  transition: transform .38s cubic-bezier(.2, .9, .3, 1.15), visibility 0s;
}
#card-close, #card-speak {
  position: absolute;
  z-index: 1;
  top: 8px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(10, 20, 60, .3);
  color: var(--soft);
  font-weight: 700;
}
#card-close { right: 8px; }
#card-speak { left: 8px; }
.flagbox {
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: 20px;
  background: linear-gradient(160deg, #e9eeff, #d5e3ff);
}
#card-flag {
  display: block;
  max-width: 100%;
  height: clamp(70px, 14vh, 124px);
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(10, 20, 60, .35));
}
#card-name {
  margin: 8px 4px 7px;
  text-align: center;
  font-size: clamp(23px, 3.5vmin, 33px);
  line-height: 1.1;
  font-weight: 700;
  overflow-wrap: anywhere;
}
#card-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
#card-rows li {
  display: grid;
  grid-template-columns: 2.4em 1fr;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 15px;
  background: #f3f5ff;
}
#card-rows .ico { font-size: 1.6em; line-height: 1; text-align: center; }
#card-rows .lab {
  display: block;
  font-size: .7em;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--soft);
}
#card-rows .val { display: block; font-size: 1.12em; font-weight: 600; line-height: 1.15; overflow-wrap: anywhere; }
#card-rows .sub { display: block; font-size: .82em; color: var(--soft); }
/* le fait remarquable : « Le savais-tu ? » */
#card-rows li.fact { background: linear-gradient(160deg, #fff6c9, #ffe9a3); }
#card-rows li.fact .lab { color: #b06a00; }
#card-rows li.fact .val { font-size: 1em; font-weight: 500; line-height: 1.25; }

/* ------------------------------------------------------------------ voyage */

#trip {
  --ph: min(calc((min(400px, 42vw) - 24px) * .667), 36vh);
  position: fixed;
  z-index: 14;
  right: var(--gap);
  top: calc(var(--fab) + var(--gap) * 2);
  width: min(400px, 42vw);
  max-height: calc(100% - var(--fab) - var(--gap) * 3);
  display: none;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 12px;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 14px 40px rgba(4, 8, 36, .5);
  font-size: clamp(15px, 2.1vmin, 18px);
}
body[data-screen="trip"] #trip { display: grid; }
#trip .thead { display: flex; align-items: center; gap: 12px; min-width: 0; }
#trip-flag {
  flex: none;
  height: clamp(40px, 7.5vh, 62px);
  max-width: 34%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(10, 20, 60, .35));
}
#trip .tname { min-width: 0; }
#trip-step {
  display: block;
  font-size: .72em;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--soft);
}
#trip-name {
  margin: 0;
  font-size: clamp(22px, 3.4vmin, 32px);
  line-height: 1.05;
  font-weight: 700;
  overflow-wrap: anywhere;
}
#trip-photo {
  position: relative;
  height: var(--ph);
  overflow: hidden;
  border-radius: 20px;
  background: linear-gradient(160deg, #7fb6ff, #3f6fe0);
}
/* la même photo, floue, remplit le cadre derrière l'image entière */
#trip-bg {
  position: absolute;
  left: -8%;
  top: -8%;
  right: -8%;
  bottom: -8%;
  background: center / cover no-repeat;
  filter: blur(14px) brightness(.72);
}
#trip-photo img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity .7s;
}
#trip-photo img.on { opacity: 1; }
#trip-photo img.flag { padding: 9% 14%; filter: drop-shadow(0 3px 6px rgba(10, 20, 60, .4)); }
#trip.moving #trip-photo img { opacity: 0; transition: none; }
#trip-way {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 1.25em;
  text-shadow: 0 2px 0 rgba(6, 10, 44, .35);
}
#trip.moving #trip-way { display: flex; }
#trip-way span { font-size: 3em; line-height: 1.15; animation: way .9s ease-in-out infinite alternate; }
#trip-caption {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  padding: .22em .7em;
  border-radius: 12px;
  background: rgba(255, 255, 255, .93);
  font-weight: 600;
  font-size: .95em;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
#trip.moving #trip-caption { visibility: hidden; }
#trip-dots { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; }
#trip-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .5);
  box-shadow: 0 0 3px rgba(0, 0, 0, .6);
  transition: transform .2s, background .2s;
}
#trip-dots i.on { background: #fff; transform: scale(1.3); }
#trip-credit {
  display: block;
  min-height: 1.25em;
  margin: -5px 6px -2px;
  font-size: .6em;
  color: var(--soft);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#trip-fact {
  display: grid;
  grid-template-columns: 2.4em 1fr;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 15px;
  background: linear-gradient(160deg, #fff6c9, #ffe9a3);
  line-height: 1.25;
}
#trip-fact .ico { font-size: 1.6em; line-height: 1; text-align: center; }
#trip .tctrl { display: flex; align-items: center; justify-content: center; gap: var(--gap); padding: 2px 0 5px; }
#trip .tctrl .fab { background: #e9eeff; box-shadow: 0 4px 0 rgba(13, 20, 66, .22); }
#trip .tctrl #trip-pause.on { background: #ffe45c; }

/* ------------------------------------------------------------------ jeu */

#target {
  position: fixed;
  z-index: 11;
  left: 0;
  right: 0;
  top: var(--gap);
  width: -moz-fit-content;
  width: fit-content;
  margin: 0 auto;
  display: none;
  align-items: center;
  gap: clamp(8px, 2vmin, 18px);
  max-width: calc(100% - (var(--fab) * 4.3 + var(--gap) * 4) * 2);
  padding: 10px 14px;
  border-radius: 26px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
body[data-screen="game"] #target { display: flex; }
body[data-screen="game"] #btn-full { display: none; }
#target.pop { animation: target-in .55s cubic-bezier(.2, 1.5, .4, 1); }
#target-flag {
  flex: none;
  height: clamp(58px, 13vh, 112px);
  max-width: 30vw;
  object-fit: contain;
  cursor: pointer;
  filter: drop-shadow(0 3px 6px rgba(10, 20, 60, .35));
}
#target .q { min-width: 0; font-size: clamp(16px, 3vmin, 26px); font-weight: 500; line-height: 1.1; }
#target .q span { display: block; }
#target .q b {
  display: block;
  font-size: clamp(20px, 4.2vmin, 38px);
  font-weight: 700;
  color: #f0561d;
}
#target-count { display: block; margin-top: .2em; font-size: .82em; font-weight: 600; color: #1f9d55; }
#target-count:empty { display: none; }
#target .fab { background: #e9eeff; box-shadow: none; }

#tray {
  position: fixed;
  z-index: 11;
  left: 0;
  right: 0;
  bottom: var(--gap);
  width: -moz-fit-content;
  width: fit-content;
  margin: 0 auto;
  display: none;
  gap: clamp(6px, 1.4vmin, 12px);
  padding: clamp(9px, 1.7vmin, 14px);
  max-width: calc(100% - (var(--fab) + var(--gap) * 2) * 2);
  overflow-x: auto;
  touch-action: pan-x;
  scrollbar-width: none;
  border: 2px solid rgba(255, 255, 255, .28);
  border-radius: 26px;
  background: rgba(255, 255, 255, .17);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
#tray::-webkit-scrollbar { display: none; }
body[data-screen="game"] #tray { display: flex; }
#tray button {
  position: relative;
  flex: none;
  width: calc(var(--flag-h) * 1.34);
  height: var(--flag-h);
  padding: 4px;
  border: 4px solid transparent;
  border-radius: 14px;
  background: #e3e9fb;
  box-shadow: 0 4px 0 rgba(13, 20, 66, .28);
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
#tray img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 0 1px rgba(10, 20, 60, .7));
}
#tray button.current {
  border-color: #ffcf33;
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 0 0 4px rgba(255, 207, 51, .4), 0 8px 14px rgba(4, 8, 36, .4);
}
#tray button.done::after {
  content: '✓';
  position: absolute;
  left: -4px;
  top: -4px;
  right: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(40, 190, 95, .84);
  color: #fff;
  font-size: calc(var(--flag-h) * .62);
  font-weight: 700;
}

#toast {
  position: fixed;
  z-index: 13;
  left: 0;
  right: 0;
  bottom: calc(var(--flag-h) + var(--gap) * 5 + 22px);
  width: -moz-fit-content;
  width: fit-content;
  margin: 0 auto;
  transform: translateY(24px) scale(.9);
  opacity: 0;
  pointer-events: none;
  display: none;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 24px);
  padding: 8px 18px 8px 10px;
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: clamp(17px, 3.4vmin, 28px);
  transition: opacity .22s, transform .22s;
}
body[data-screen="game"] #toast { display: flex; }
#toast.show { opacity: 1; transform: none; }
#toast img {
  flex: none;
  height: clamp(34px, 6vmin, 52px);
  max-width: 90px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(10, 20, 60, .35));
}

/* ------------------------------------------------------------------ victoire */

#fx {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 30;
  display: none;
  pointer-events: none;
}

#bravo {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 32;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 4vh;
  pointer-events: none;
  text-align: center;
  background: radial-gradient(ellipse 62% 44% at 50% 48%, rgba(8, 12, 44, .6), rgba(8, 12, 44, 0) 72%);
}
#bravo.show { display: flex; }
#bravo.out { animation: fade-out .42s ease-in forwards; }
#bravo .line { font-weight: 700; line-height: 1.08; white-space: nowrap; }
#bravo .b1 { font-size: clamp(56px, 17vmin, 200px); }
#bravo .b2 { font-size: clamp(30px, 9.5vmin, 112px); }
#bravo span {
  display: inline-block;
  color: hsl(var(--h), 96%, 60%);
  -webkit-text-stroke: .09em #fff;
  paint-order: stroke fill;
  text-shadow: 0 .07em 0 rgba(10, 16, 60, .55);
  animation: letter-in .65s cubic-bezier(.2, 1.7, .4, 1) both, letter-dance .9s ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * 45ms), calc(650ms + var(--i) * 60ms);
}

#win {
  justify-content: center;
  pointer-events: auto;
  background: radial-gradient(ellipse at center, rgba(10, 14, 48, .3), rgba(10, 14, 48, .72));
}
.winbox { text-align: center; color: #fff; animation: box-in .6s cubic-bezier(.2, 1.5, .4, 1) both; }
.trophy {
  font-size: clamp(70px, 20vmin, 170px);
  line-height: 1.05;
  animation: trophy 1.1s ease-in-out infinite alternate;
}
.winbox h2 {
  margin: 0;
  font-size: clamp(32px, 8vmin, 76px);
  line-height: 1.1;
  color: #ffd93b;
  -webkit-text-stroke: .07em #fff;
  paint-order: stroke fill;
  text-shadow: 0 .07em 0 rgba(6, 10, 44, .45);
}
.winbox p {
  margin: .2em 0 0;
  font-size: clamp(18px, 4vmin, 34px);
  font-weight: 600;
  text-shadow: 0 2px 0 rgba(6, 10, 44, .5);
}
#win-stars { margin: .1em 0 .45em; font-size: clamp(26px, 6.5vmin, 60px); }
#win-stars span { display: inline-block; animation: star-in .5s cubic-bezier(.2, 1.8, .4, 1) both; }
#win .big { --s: clamp(96px, 22vmin, 170px); }

/* ------------------------------------------------------------------ réglages (pour les parents) */

#btn-settings {
  position: fixed;
  z-index: 10;
  left: var(--gap);
  top: var(--gap);
  display: none;
  opacity: .9;
}
body[data-screen="home"] #btn-settings { display: grid; }

#settings {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
  background: rgba(8, 12, 44, .68);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
body.settings #settings { display: flex; }
#settings .sheet {
  position: relative;
  width: min(540px, 100%);
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 14px 16px 16px;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 14px 40px rgba(4, 8, 36, .5);
  font-size: clamp(15px, 2.2vmin, 18px);
}
#settings h2 { margin: 2px 52px 4px 4px; font-size: 1.55em; line-height: 1.15; }
#settings h2 small { margin-left: .3em; font-size: .5em; font-weight: 500; color: var(--soft); white-space: nowrap; }
#set-close {
  position: absolute;
  right: 10px;
  top: 10px;
  background: #e9eeff;
  box-shadow: none;
  color: var(--soft);
  font-weight: 700;
}
.set-block { margin-top: 10px; padding: 11px 14px 13px; border-radius: 20px; background: #f3f5ff; }
.set-block h3 { margin: 0 0 8px; font-size: 1.08em; }
.set-block p { margin: 6px 0; line-height: 1.3; }
.set-row { display: flex; align-items: center; gap: 14px; }
.headbox {
  flex: none;
  width: clamp(84px, 16vmin, 104px);
  height: clamp(84px, 16vmin, 104px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(160deg, #7fb6ff, #3f6fe0);
}
.headbox img { width: 74%; height: 80%; object-fit: contain; }
.set-actions { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.set-actions.row { flex-direction: row; flex-wrap: wrap; }
.set-actions.row .pillbtn { flex: 1 1 130px; }
.pillbtn {
  padding: .55em 1em;
  border-radius: 999px;
  background: linear-gradient(160deg, #58d6ff, #1b8fe8);
  box-shadow: 0 4px 0 rgba(13, 20, 66, .22);
  color: #fff;
  font-weight: 600;
  text-align: center;
  transition: transform .12s, box-shadow .12s;
}
.pillbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(13, 20, 66, .22); }
.pillbtn.ghost { background: #fff; box-shadow: inset 0 0 0 2px #c9d2f5; color: var(--ink); }
.pillbtn.ok { background: linear-gradient(160deg, #a7ec6a, #37b24d); }
.pillbtn.danger { background: linear-gradient(160deg, #ff8f8f, #e03163); }
.hint { font-size: .82em; color: var(--soft); }
#head-file { display: none; }
#head-edit { display: none; text-align: center; }
#settings.editing #head-edit { display: block; }
#settings.editing #head-view { display: none; }
/* pendant le cadrage, on ne montre que la photo : pas besoin de faire défiler */
#settings.editing .set-block ~ .set-block { display: none; }
#settings:not(.custom) #head-reset { display: none; }
#head-canvas {
  display: block;
  width: min(240px, 60vw, 40vh);
  height: auto;
  margin: 0 auto;
  border-radius: 18px;
  background: #26306e;
  touch-action: none;
  cursor: grab;
}
#settings.cutout #head-canvas { cursor: default; }
.zoomrow { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 8px 0; }
.zoomrow input { flex: 1; max-width: 260px; height: 34px; touch-action: none; accent-color: #1b8fe8; }
#settings.cutout .zoomrow { display: none; }
#reset-confirm { display: none; }
#settings.confirm #reset-confirm { display: block; }
#settings.confirm #reset-ask { display: none; }
.about a { color: #1b6fd8; font-weight: 600; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ chargement */

#loading {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  color: #fff;
  text-align: center;
  background: radial-gradient(ellipse at 50% 45%, #2a3d9c 0%, #172266 42%, #0a0e30 100%);
  transition: opacity .5s, visibility 0s .5s;
}
body:not([data-screen="loading"]) #loading { opacity: 0; visibility: hidden; pointer-events: none; }
#loading .spin { font-size: clamp(80px, 22vmin, 170px); line-height: 1.1; animation: spin 2.4s linear infinite; }
#loading p { margin: 0; max-width: 22em; font-size: clamp(20px, 4.5vmin, 36px); font-weight: 600; }
.bar { width: min(320px, 70vw); height: 16px; border-radius: 99px; overflow: hidden; background: rgba(255, 255, 255, .2); }
#bar { width: 0; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #ffd93b, #ff7f2a); transition: width .15s; }
#loading.error .spin { animation: none; }
#loading.error .bar { display: none; }

/* ------------------------------------------------------------------ petits écrans */

/* écran pas très large : les titres passent sous la rangée de boutons du haut */
@media (max-width: 1100px) {
  .panel { padding-top: calc(var(--fab) + var(--gap) * 2); }
}

@media (max-width: 900px) {
  #target {
    top: calc(var(--fab) + var(--gap) * 2);
    max-width: calc(100% - var(--gap) * 2);
  }
}

/* écran large mais très bas (téléphone couché) : le voyage ne garde que l'essentiel */
@media (max-height: 480px) and (min-aspect-ratio: 4/5) {
  #trip { gap: 6px; padding: 10px; }
  #trip-fact, #trip-credit { display: none; }
  #trip .tctrl { padding: 0 0 4px; }
}

/* écran bas : le cadrage de la photo se met sur deux colonnes, la photo à gauche */
@media (max-height: 620px) and (min-aspect-ratio: 4/5) {
  #settings.editing #head-edit {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 14px;
    align-items: center;
    text-align: left;
  }
  #head-canvas { grid-row: 1 / span 3; width: min(200px, 34vw, 52vh); margin: 0; }
  .zoomrow { justify-content: flex-start; }
}

@media (max-aspect-ratio: 4/5) {
  .panel { padding-top: calc(var(--fab) + var(--gap) * 2.5); }
  /* accueil : quatre boutons en carré */
  .choices.four { --hs: clamp(104px, 33vmin, 210px); max-width: calc(var(--hs) * 2 + 40px); }
  .choices.four .big { --s: var(--hs); }
  .choices.many { max-width: calc(var(--cs) * 3 + var(--cg) * 2 + 4px); }
  #trip {
    --ph: min(27vh, 62vw);
    left: var(--gap);
    right: var(--gap);
    top: auto;
    bottom: var(--gap);
    width: auto;
    max-height: 58%;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
  }
  #trip .thead { grid-column: 1; grid-row: 1; }
  #trip .tctrl { grid-column: 2; grid-row: 1; gap: 6px; padding: 0; }
  #trip .tctrl .fab { --fab: 44px; }
  #trip-photo, #trip-credit, #trip-fact { grid-column: 1 / -1; }
  #card {
    left: var(--gap);
    right: var(--gap);
    top: auto;
    bottom: var(--gap);
    width: auto;
    max-height: 50%;
    transform: translateY(calc(100% + 40px));
  }
  #card .head {
    display: grid;
    grid-template-columns: 38% 1fr;
    align-items: center;
    gap: 10px;
    padding-right: 112px;
  }
  #card-speak { left: auto; right: 62px; }
  .flagbox { padding: 8px; }
  #card-flag { height: clamp(56px, 10vh, 110px); }
  #card-name { margin: 0; text-align: left; }
  #card-rows { grid-template-columns: 1fr 1fr; margin-top: 8px; }
  #card-rows li.fact { grid-column: 1 / -1; }
  #tray { max-width: calc(100% - var(--gap) * 2); bottom: var(--gap); }
  #zoom, #btn-hint { bottom: calc(var(--flag-h) + var(--gap) * 5 + var(--lift)); }
  #toast { bottom: calc(var(--flag-h) + var(--gap) * 7 + var(--fab)); }
}

/* ------------------------------------------------------------------ animations */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bob { from { transform: translateY(.04em) rotate(-3deg); } to { transform: translateY(-.06em) rotate(3deg); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes nudge { from { transform: translateY(0); } to { transform: translateY(-8px); } }
@keyframes wiggle { 0%, 84%, 100% { transform: rotate(0); } 88% { transform: rotate(-14deg); } 92% { transform: rotate(12deg); } 96% { transform: rotate(-8deg); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.35) rotate(-6deg); } 100% { transform: scale(1); } }
@keyframes target-in { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes box-in { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pin-in { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes cap-star { from { transform: scale(.85) rotate(-8deg); } to { transform: scale(1.2) rotate(8deg); } }
@keyframes b-bob { from { transform: translateY(0) rotate(7deg); } to { transform: translateY(-4px) rotate(7deg); } }
@keyframes b-swing-a { from { transform: rotate(-38deg); } to { transform: rotate(38deg); } }
@keyframes b-swing-b { from { transform: rotate(38deg); } to { transform: rotate(-38deg); } }
@keyframes b-hop {
  0% { transform: translateY(0); animation-timing-function: ease-out; }
  50% { transform: translateY(calc(var(--bs) * -.42)); animation-timing-function: ease-in; }
  100% { transform: translateY(0); }
}
@keyframes b-jump {
  0% { transform: translateY(0); animation-timing-function: ease-out; }
  50% { transform: translateY(calc(var(--bs) * -.6)); animation-timing-function: ease-in; }
  100% { transform: translateY(0); }
}
@keyframes b-wave-l { from { transform: rotate(100deg); } to { transform: rotate(140deg); } }
@keyframes b-wave-r { from { transform: rotate(-100deg); } to { transform: rotate(-140deg); } }
@keyframes b-jack-l { from { transform: rotate(2deg); } to { transform: rotate(32deg); } }
@keyframes b-jack-r { from { transform: rotate(-2deg); } to { transform: rotate(-32deg); } }
@keyframes b-nod { from { transform: rotate(-7deg); } to { transform: rotate(7deg); } }
@keyframes b-sway { from { transform: rotate(13deg); } to { transform: rotate(16deg); } }
@keyframes b-idle { from { transform: rotate(-2.5deg); } to { transform: rotate(2.5deg); } }
@keyframes b-hello { from { transform: rotate(-122deg); } to { transform: rotate(-162deg); } }
@keyframes b-float {
  from { transform: translateY(calc(var(--bs) * -.1)) rotate(-4deg); }
  to { transform: translateY(calc(var(--bs) * -.2)) rotate(4deg); }
}
@keyframes way { from { transform: translate(-.25em, .12em) rotate(-6deg); } to { transform: translate(.25em, -.12em) rotate(6deg); } }
@keyframes b-tear {
  0% { opacity: 0; transform: translateY(0) scale(.5); }
  20% { opacity: 1; transform: translateY(2px) scale(1); }
  100% { opacity: 0; transform: translateY(24px) scale(1); }
}
@keyframes letter-in { from { transform: translateY(.9em) scale(0) rotate(-30deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes letter-dance { from { transform: translateY(.03em) rotate(-4deg); } to { transform: translateY(-.13em) rotate(4deg); } }
@keyframes fade-out { to { opacity: 0; transform: scale(1.25); } }
@keyframes trophy { from { transform: rotate(-8deg) scale(1); } to { transform: rotate(8deg) scale(1.08); } }
@keyframes star-in { from { transform: scale(0) rotate(-120deg); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .big, .title h1 span, #btn-hint, .trophy, .bubble.show, #capital svg, #trip-way span { animation: none !important; }
}
