:root {
  --ciel: #e9f6ff;
  --encre: #1d2440;
  --doux: #5b6380;
  --rouge: #e8443a;
  --rouge-fonce: #c22f26;
  --jaune: #ffc93c;
  --vert: #3fae5a;
  --bleu: #2f6fe0;
  --carte: #ffffff;
  --ligne: #dfe6f3;
  --ombre: 0 10px 30px rgba(29, 36, 64, .14);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--encre);
  background: var(--ciel);
}
h1, h2, h3, .logo, .btn { font-family: "Fredoka", "Nunito", sans-serif; }

.ecran { display: none; min-height: 100vh; }
.ecran.actif { display: block; }
.cache { display: none !important; }

/* Boutons */
.btn {
  border: 0; cursor: pointer; border-radius: 14px;
  background: var(--rouge); color: #fff; font-weight: 600; font-size: 1rem;
  padding: .7rem 1.2rem; box-shadow: 0 4px 0 var(--rouge-fonce);
  transition: transform .08s ease, box-shadow .08s ease, opacity .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--rouge-fonce); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-grand { font-size: 1.15rem; padding: .9rem 1.6rem; width: 100%; }

/* Accueil */
#ecran-accueil.actif { display: flex; flex-direction: column; align-items: center; position: relative; padding: 24px 16px 0; }
#ecran-accueil .accueil-carte { margin: max(24px, calc(50vh - 330px)) 0 0; }
.accueil-fond {
  position: fixed; inset: 0; background-size: cover; background-position: center;
  filter: saturate(1.1);
}
.accueil-fond::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20, 24, 50, .15), rgba(20, 24, 50, .55)); }
.accueil-carte {
  position: relative; max-width: 520px; width: 100%; background: rgba(255, 255, 255, .95);
  border-radius: 24px; padding: 32px 28px; box-shadow: var(--ombre); text-align: center;
}
.sur-titre { margin: 0; text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; font-weight: 800; color: var(--rouge); }
.accueil-carte h1 { margin: .2rem 0 .6rem; font-size: clamp(2.8rem, 9vw, 4rem); line-height: 1; color: var(--encre); }
.accroche { margin: 0 0 1.2rem; font-size: 1.08rem; line-height: 1.55; color: var(--doux); }
.regles { text-align: left; margin: 0 0 1.4rem; padding-left: 1.2rem; line-height: 1.6; }
.regles li { margin-bottom: .35rem; }
.record { margin: 1rem 0 0; font-weight: 700; color: var(--doux); min-height: 1.2em; }

/* Barre d'état */
.barre {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px;
  background: var(--carte); padding: 12px 20px; box-shadow: 0 2px 10px rgba(29, 36, 64, .08);
  position: sticky; top: 0; z-index: 5;
}
.logo { font-size: 1.6rem; font-weight: 700; color: var(--rouge); margin-right: auto; }
.indic { display: flex; flex-direction: column; min-width: 92px; }
.indic span { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--doux); font-weight: 800; }
.indic strong { font-size: 1.12rem; }
.jauge { width: 130px; height: 12px; background: var(--ligne); border-radius: 99px; overflow: hidden; margin-top: 5px; }
.jauge i { display: block; height: 100%; width: 60%; background: var(--vert); border-radius: 99px; transition: width .5s ease, background .5s; }
.jauge.or i { background: var(--jaune); }
.flash-gain { animation: flashv .9s ease; }
.flash-perte { animation: flashr .9s ease; }
@keyframes flashv { 0% { color: var(--vert); transform: scale(1.15); } 100% { color: inherit; transform: none; } }
@keyframes flashr { 0% { color: var(--rouge); transform: scale(1.15); } 100% { color: inherit; transform: none; } }

/* Disposition */
.jeu { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr); gap: 20px; padding: 20px; max-width: 1400px; margin: 0 auto; }
.parc { background: linear-gradient(180deg, #bfe6ff 0%, #e9f6ff 45%); border-radius: 22px; padding: 10px; box-shadow: var(--ombre); }
#plan { width: 100%; height: auto; display: block; }
.aide-plan { margin: 4px 0 6px; text-align: center; color: var(--doux); font-size: .88rem; }
.panneau { display: flex; flex-direction: column; gap: 16px; }
.bloc { background: var(--carte); border-radius: 22px; padding: 22px; box-shadow: var(--ombre); }

/* Plan du parc */
.tuile { cursor: pointer; }
.tuile .sol { fill: #6cc35a; stroke: #4fa443; stroke-width: 2; transition: fill .2s; }
.tuile:hover .sol { fill: #7fd36c; }
.tuile.choisie .sol { fill: #ffe27a; stroke: #e7b923; }
.tuile .vide { fill: none; stroke: rgba(255, 255, 255, .55); stroke-width: 2; stroke-dasharray: 6 6; }
.tuile image { pointer-events: none; }
.tuile.neuve image { animation: pose .6s cubic-bezier(.2, 1.4, .4, 1); transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes pose { 0% { transform: translateY(-40px) scale(.6); opacity: 0; } 100% { transform: none; opacity: 1; } }
.niveau { font: 700 15px "Fredoka", sans-serif; fill: #fff; paint-order: stroke; stroke: rgba(0, 0, 0, .45); stroke-width: 3px; }
.allee { fill: #e6d3a3; stroke: #d2bb83; stroke-width: 2; }

/* Question */
.question-tete { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.etiquette { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; padding: .3rem .65rem; border-radius: 99px; background: #e8efff; color: var(--bleu); }
.etiquette.gestion { background: #fff1d6; color: #b7791f; }
.gain { font-weight: 800; color: var(--vert); }
.chrono { height: 8px; background: var(--ligne); border-radius: 99px; overflow: hidden; margin-bottom: 14px; }
.chrono i { display: block; height: 100%; width: 100%; background: var(--bleu); border-radius: 99px; }
#q-texte { font-size: 1.3rem; line-height: 1.35; margin: 0 0 16px; }
.choix { display: grid; gap: 10px; }
.choix button {
  text-align: left; border: 2px solid var(--ligne); background: #fff; border-radius: 14px;
  padding: .8rem 1rem; font: 600 1rem "Nunito", sans-serif; color: var(--encre); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.choix button:hover:not(:disabled) { border-color: var(--bleu); background: #f3f7ff; }
.choix button.bonne { border-color: var(--vert); background: #e7f7ea; }
.choix button.mauvaise { border-color: var(--rouge); background: #fdeceb; }
.choix button:disabled { cursor: default; }

/* Résultat */
.verdict { font: 700 1.35rem "Fredoka", sans-serif; margin-bottom: 6px; }
.verdict.ok { color: var(--vert); }
.verdict.ko { color: var(--rouge); }
.explication { margin: 0 0 16px; color: var(--doux); line-height: 1.55; }
.bloc h3 { margin: 4px 0 10px; font-size: 1.1rem; }
.boutique { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.article {
  border: 2px solid var(--ligne); border-radius: 16px; padding: 8px 10px 10px; text-align: center;
  background: #fff; cursor: pointer; transition: border-color .15s, transform .15s;
  font: inherit; color: inherit;
}
.article:hover:not(:disabled) { border-color: var(--rouge); transform: translateY(-2px); }
.article:disabled { opacity: .45; cursor: not-allowed; }
.article img { width: 90px; height: 90px; object-fit: contain; display: block; margin: 0 auto 4px; }
.article b { display: block; font-size: .95rem; }
.article .prix { display: block; color: var(--rouge); font-weight: 800; }
.article .rap { display: block; font-size: .8rem; color: var(--doux); }
.amelioration { border: 2px dashed var(--jaune); border-radius: 16px; padding: 12px; margin-bottom: 14px; background: #fffaf0; }
.amelioration p { margin: 0 0 8px; }
.amelioration .btn { background: var(--vert); box-shadow: 0 4px 0 #2d8a44; }

/* Modale */
.modale { position: fixed; inset: 0; background: rgba(20, 24, 50, .55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modale-carte { background: #fff; border-radius: 24px; padding: 28px; width: 100%; max-width: 440px; box-shadow: var(--ombre); }
.modale-carte h2 { margin: 0 0 12px; font-size: 1.6rem; }
.ligne-bilan { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--ligne); }
.ligne-bilan.total { font-weight: 800; font-size: 1.1rem; border-bottom: 0; }
.plus { color: var(--vert); }
.moins { color: var(--rouge); }
.modale-carte p { line-height: 1.55; color: var(--doux); }
.modale-carte .btn { margin-top: 16px; }

@media (max-width: 900px) {
  .jeu { grid-template-columns: 1fr; padding: 12px; }
  /* Sur mobile, la question passe avant le plan : c'est elle qu'on lit en premier. */
  .panneau { order: -1; }
  .barre { padding: 10px 14px; gap: 8px 14px; }
  .logo { width: 100%; font-size: 1.3rem; }
  .indic { min-width: 0; }
  .jauge { width: 90px; }
}

/* Situations */
.jour { font-weight: 800; color: var(--doux); font-size: .85rem; }
#sit-titre { font-size: 1.35rem; line-height: 1.3; margin: 4px 0 8px; }
.texte { margin: 0 0 16px; line-height: 1.6; color: #3a4260; }
.choix button { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.choix button em { font-style: normal; font-weight: 800; white-space: nowrap; font-size: .92rem; }
.cat-personnel { background: #eaf3ff; color: #2f6fe0; }
.cat-foule { background: #fff1d6; color: #b7791f; }
.cat-badbuzz { background: #fdeceb; color: #c22f26; }
.cat-communication { background: #f1e9ff; color: #7a3fd1; }
.cat-scurit { background: #ffe9e0; color: #c4501b; }
.cat-opportunit { background: #e7f7ea; color: #2d8a44; }
.resultat { font-size: 1.08rem; color: var(--encre); font-weight: 600; }
.effets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.puce { padding: .3rem .65rem; border-radius: 99px; background: #eef1f8; font-weight: 800; font-size: .88rem; }
.puce.plus { background: #e7f7ea; color: #2d8a44; }
.puce.moins { background: #fdeceb; color: #c22f26; }
.bilan { background: #f6f8fc; border-radius: 14px; padding: 6px 14px; margin-bottom: 16px; }
.alerte { margin: 8px 0 4px; color: var(--rouge); font-weight: 700; font-size: .92rem; }

/* Boutique en deux familles */
.boutique .famille { grid-column: 1 / -1; margin: 6px 0 0; font-size: .9rem; color: var(--doux); }
.boutique .famille b { color: var(--encre); font-family: "Fredoka", sans-serif; font-size: 1rem; }
.article .entretien { display: block; font-size: .74rem; color: #8a91a8; margin-top: 2px; }
.article.possede { opacity: .6; border-style: dashed; }
.article.possede .prix { color: var(--vert); }
.ligne-bilan small { color: var(--doux); font-weight: 600; }
.usure { margin: 8px 0 4px; font-size: .85rem; color: var(--doux); }

/* Conseils de Léa */
.conseil { display: flex; flex-direction: column; gap: 4px; background: #fff7e0; border-left: 4px solid var(--jaune); border-radius: 12px; padding: 10px 14px; margin: 0 0 16px; line-height: 1.5; }
.conseil b { font-family: "Fredoka", sans-serif; font-size: .9rem; color: #b7791f; }
.conseil span { color: var(--encre); font-size: .95rem; }
.choix button:disabled { opacity: .5; }
.insuffisant { display: block; font-size: .78rem; color: var(--rouge); font-weight: 700; margin-top: 2px; }

/* Pied de l'accueil et page de mentions */
.pied { margin: 1rem 0 0; font-size: .82rem; }
.pied a, .legal a { color: var(--doux); }
body.page-texte { background: var(--ciel); }
.legal { max-width: 720px; margin: 0 auto; padding: 32px 20px 60px; line-height: 1.65; }
.legal h1 { font-size: 2rem; margin: 0 0 1rem; }
.legal h2 { font-size: 1.15rem; margin: 1.6rem 0 .4rem; }
.legal p { margin: 0 0 .8rem; color: #3a4260; }

/* Présentation sous l'écran d'accueil (texte de référencement) */
.defiler { position: relative; margin: 18px 0 32px; color: #fff; font-weight: 800; text-decoration: none; text-shadow: 0 1px 6px rgba(0, 0, 0, .55); }
.presentation { position: relative; width: calc(100% + 32px); margin: 0 -16px; background: #fff; padding: 48px 20px 56px; }
.presentation > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.presentation h2 { font-size: clamp(1.6rem, 4vw, 2.1rem); line-height: 1.2; margin-top: 0; margin-bottom: 1rem; }
.presentation h3 { font-size: 1.25rem; margin-top: 1.8rem; margin-bottom: .5rem; color: var(--rouge); }
.presentation p { line-height: 1.7; color: #3a4260; font-size: 1.05rem; }
.presentation .rejouer { display: block; max-width: 420px; margin-top: 2rem; }
.pied-page { position: relative; width: calc(100% + 32px); margin: 0 -16px; padding: 18px 20px 26px; background: #fff; border-top: 1px solid var(--ligne); text-align: center; font-size: .88rem; }
.pied-page a { color: var(--doux); }
/* Fiche de l'élément choisi, sous le plan du parc */
.parc .amelioration { margin: 6px 12px 10px; background: #fff; box-shadow: 0 4px 14px rgba(29, 36, 64, .1); }
/* Sur grand écran, le plan reste visible pendant qu'on fait défiler la colonne de droite. */
@media (min-width: 901px) {
  .parc { position: sticky; top: 84px; align-self: start; }
  /* Plan et fiche doivent tenir ensemble dans la fenêtre, même sur un portable peu haut. */
  #plan { max-height: calc(100vh - 290px); margin: 0 auto; }
}

/* Formulaire de contact */
.formulaire { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin: 1.4rem 0 1.2rem; }
.formulaire label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.formulaire .large { grid-column: 1 / -1; }
.formulaire input, .formulaire select, .formulaire textarea {
  font: 400 1rem "Nunito", sans-serif; color: var(--encre); padding: .7rem .8rem;
  border: 2px solid var(--ligne); border-radius: 12px; background: #fff;
}
.formulaire input:focus, .formulaire select:focus, .formulaire textarea:focus { outline: none; border-color: var(--bleu); }
.formulaire .hp { display: none; }
.formulaire .btn { justify-self: start; width: auto; }
.resultat-envoi { margin: 0; font-weight: 700; min-height: 1.4em; }
.resultat-envoi.ok { color: var(--vert); }
.resultat-envoi.err { color: var(--rouge); }
.legal .petit { font-size: .88rem; color: var(--doux); }
@media (max-width: 640px) { .formulaire { grid-template-columns: 1fr; } .formulaire .btn { width: 100%; } }

/* ===== Écrans du jeu : menu, vues et Léa (03/10/2026) ===== */
.onglets { display: flex; gap: 8px; max-width: 1400px; margin: 14px auto 0; padding: 0 20px; }
.onglets button {
  position: relative; display: flex; align-items: center; gap: 8px; border: 2px solid var(--ligne); background: #fff;
  border-radius: 99px; padding: .55rem 1.1rem; font: 700 1rem "Fredoka", sans-serif; color: var(--doux); cursor: pointer;
}
.onglets button.actif { background: var(--encre); border-color: var(--encre); color: #fff; }
.onglets .ico { font-size: 1.15rem; line-height: 1; }
.pastille { position: absolute; top: 4px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--rouge); border: 2px solid #fff; }

.vue { display: none; }
.vue.actif { display: block; }
.vue > * + * { margin-top: 16px; }

/* Léa */
.lea { display: flex; align-items: flex-start; gap: 12px; }
.lea > img { flex: 0 0 auto; width: 88px; height: 88px; border-radius: 50%; object-fit: cover; object-position: 50% 8%; background: #fff7e0; border: 3px solid #fff; box-shadow: var(--ombre); }
.lea-petite > img { width: 64px; height: 64px; }
.bulle { position: relative; flex: 1; min-width: 0; background: #fff; border-radius: 20px; padding: 16px 18px; box-shadow: var(--ombre); }
.bulle::before { content: ""; position: absolute; left: -9px; top: 26px; border: 10px solid transparent; border-left: 0; border-right-color: #fff; }
.bulle #sit-titre { margin-top: 2px; }
.question-lea { margin: 4px 0 0; font: 600 1.05rem "Fredoka", sans-serif; color: var(--rouge); }
.accueil-lea { background: #fff7e0; border-radius: 12px; padding: 8px 12px; margin: 4px 0 10px; font-size: .92rem; line-height: 1.5; }
.texte-lea { margin: 0; line-height: 1.55; }
.actions-lea { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.actions-lea:empty { display: none; }
.btn-lea { border: 2px solid var(--encre); background: #fff; color: var(--encre); border-radius: 99px; padding: .4rem .9rem; font: 700 .9rem "Nunito", sans-serif; cursor: pointer; }
.btn-lea:hover { background: var(--encre); color: #fff; }
#sit-choix { margin-top: 14px; }
#bloc-resultat > * + * { margin-top: 16px; }

/* Grand écran : le parc reste visible à droite, sans onglet dédié. */
@media (min-width: 901px) {
  .jeu { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
  #vue-situation, #vue-construire { grid-column: 1; grid-row: 1; }
  #vue-parc { display: block; grid-column: 2; grid-row: 1; position: sticky; top: 84px; align-self: start; }
  .onglet-parc, .lea-parc { display: none !important; }
  #plan { max-height: calc(100vh - 290px); margin: 0 auto; }
}

/* Téléphone : menu fixe en bas, un écran à la fois. */
@media (max-width: 900px) {
  .onglets {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; margin: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: #fff; box-shadow: 0 -4px 16px rgba(29, 36, 64, .12); gap: 4px;
  }
  .onglets button { flex: 1; flex-direction: column; gap: 2px; border: 0; border-radius: 14px; padding: .45rem .2rem; font-size: .82rem; }
  .onglets .ico { font-size: 1.35rem; }
  .jeu { padding-bottom: 96px; }
  .lea > img { width: 64px; height: 64px; }
  .lea-petite > img { width: 52px; height: 52px; }
  .bulle { padding: 14px 15px; }
  .barre { gap: 4px 12px; }
  .barre .indic span { font-size: .62rem; }
  .barre .indic strong { font-size: 1rem; }
  .barre .jauge { width: 72px; height: 9px; }
}

/* ===== Placement, passage, propreté et animation du parc ===== */
.placement { display: flex; align-items: center; gap: 12px; justify-content: space-between; background: var(--encre); color: #fff; border-radius: 14px; padding: 10px 14px; margin: 6px 10px 0; }
.placement p { margin: 0; font-weight: 700; line-height: 1.4; }
.placement .btn-lea { background: #fff; flex: 0 0 auto; }
#plan.en-placement .tuile.cible .sol { fill: #9be08a; stroke: #3fae5a; stroke-width: 3; animation: clignote 1.2s ease-in-out infinite; }
#plan.en-placement .tuile.occupee { opacity: .55; cursor: not-allowed; }
.tuile.jonchee .sol { fill: #a8b45a; stroke: #8a9440; }
.tuile.jonchee .vide { stroke: rgba(120, 90, 40, .45); }
#plan.en-placement .tuile.jonchee { cursor: not-allowed; }
#plan.en-placement .tuile.jonchee .sol { fill: #c9a86a; stroke: #a5803f; }
@keyframes clignote { 50% { fill: #c9f2bd; } }
.passage { font: 700 18px "Fredoka", sans-serif; text-anchor: middle; paint-order: stroke; stroke: #fff; stroke-width: 4px; pointer-events: none; }
.passage.p125, .passage.p1 { fill: #1f8a3a; }
.passage.p075 { fill: #b7791f; }
.passage.p05 { fill: #c22f26; }
.actions-fiche { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-second { background: #fff; color: var(--encre); box-shadow: 0 4px 0 var(--ligne); border: 2px solid var(--ligne); }
.amelioration .btn-second { background: #fff; box-shadow: 0 4px 0 var(--ligne); }
.panneau-panne { fill: #ffc93c; stroke: #c4501b; stroke-width: 2.5; stroke-linejoin: round; }
.panneau-panne-txt { font: 800 18px "Fredoka", sans-serif; text-anchor: middle; fill: #7a2a10; }
.dechets, .poubelle { pointer-events: none; }
.foule { pointer-events: none; }
.visiteur { animation: marche 2.4s ease-in-out infinite; }
@keyframes marche { 50% { transform: translate(5px, -2px); } }
@media (prefers-reduced-motion: reduce) { .visiteur, #plan.en-placement .tuile.cible .sol { animation: none; } }
