:root {
  --rouge: #ff4d5e; --orange: #ff9f1c; --jaune: #ffd23f; --vert: #3ddc84;
  --bleu: #3a86ff; --violet: #9b5de5; --rose: #ff70a6; --blanc: #fffcf2;
  --encre: #222;
  --police: 'Trebuchet MS', 'Arial Rounded MT Bold', sans-serif;
  --contour: -2px -2px 0 var(--encre), 2px -2px 0 var(--encre), -2px 2px 0 var(--encre), 2px 2px 0 var(--encre), 0 4px 0 var(--encre);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #cdeeff; }
body { font-family: var(--police); font-weight: 900; color: #fff; user-select: none; }
#scene, #scene canvas { position: fixed; inset: 0; display: block; }
.hidden { display: none !important; }

/* ── Écrans ─────────────────────────────── */
#ui { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; z-index: 10; padding: 16px; }
.ecran {
  pointer-events: auto; text-align: center; max-width: 94vw; max-height: 94vh; overflow-y: auto;
  min-width: min(440px, 92vw); padding: 30px 38px; border-radius: 32px;
  background: linear-gradient(160deg, rgba(58, 134, 255, 0.92), rgba(155, 93, 229, 0.92));
  border: 5px solid var(--blanc); box-shadow: 0 12px 0 rgba(0, 0, 0, 0.18), 0 24px 50px rgba(0, 0, 0, 0.3);
  animation: entree 0.35s cubic-bezier(.3, 1.6, .5, 1);
}
@keyframes entree { from { opacity: 0; transform: scale(0.85); } }
.titre { font-size: clamp(42px, 8vw, 72px); letter-spacing: 2px; margin-bottom: 6px; line-height: 1.1; }
.titre span { display: inline-block; text-shadow: var(--contour); animation: vague 1.8s ease-in-out infinite; }
@keyframes vague { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(3deg); } }
h2 { font-size: 38px; margin-bottom: 10px; text-shadow: var(--contour); }
.sous { margin-bottom: 18px; font-size: 17px; line-height: 1.5; text-shadow: 0 2px 0 rgba(0,0,0,0.35); font-weight: 700; }
.colonne { display: flex; flex-direction: column; gap: 14px; align-items: center; margin-top: 10px; }
.ligne { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
button {
  font-family: var(--police); font-weight: 900; font-size: 21px; color: #fff; cursor: pointer;
  min-width: 260px; min-height: 70px; padding: 10px 26px; border-radius: 24px;
  border: 4px solid var(--blanc); text-shadow: 0 2px 0 rgba(0,0,0,0.35);
  background: linear-gradient(180deg, #5aa0ff, var(--bleu));
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25), 0 10px 18px rgba(0, 0, 0, 0.2);
  transition: transform 0.12s cubic-bezier(.3, 1.8, .5, 1), filter 0.12s;
}
button:hover { transform: translateY(-4px) scale(1.04); filter: brightness(1.1); }
button:active { transform: translateY(2px) scale(0.98); }
button.principal { background: linear-gradient(180deg, #ff7f8c, var(--rouge)); }
button.vert { background: linear-gradient(180deg, #6ff0a8, var(--vert)); }
button.orange { background: linear-gradient(180deg, #ffbd5c, var(--orange)); }
button.violet { background: linear-gradient(180deg, #b98bf0, var(--violet)); }
button.petit { min-width: 0; min-height: 0; padding: 8px 16px; font-size: 16px; border-radius: 16px; border-width: 3px; }
button.actif { background: linear-gradient(180deg, #ffe27a, var(--jaune)); color: var(--encre); text-shadow: none; }
button:disabled { filter: grayscale(0.8) brightness(0.8); cursor: not-allowed; transform: none; }
.aide { font-size: 14px; margin-top: 20px; line-height: 1.7; font-weight: 700; }
kbd { background: var(--blanc); color: var(--encre); border-radius: 8px; padding: 1px 8px; font-family: inherit; }
.erreur { background: var(--rouge); border-radius: 14px; padding: 8px 14px; margin-bottom: 12px; }

/* ── Niveaux et garage ─────────────────── */
.cartes { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.carte {
  width: 170px; padding: 14px 10px; border-radius: 22px; border: 4px solid var(--blanc); cursor: pointer;
  background: rgba(255, 255, 255, 0.18); box-shadow: 0 6px 0 rgba(0,0,0,0.2); transition: transform 0.12s;
}
.carte:hover { transform: translateY(-4px) scale(1.04); }
.carte.verrou { opacity: 0.45; cursor: not-allowed; transform: none; }
.carte.choisi { background: var(--jaune); color: var(--encre); }
.carte .ico { font-size: 44px; }
.carte .nom { font-size: 18px; margin: 4px 0; }
.carte .info { font-size: 13px; font-weight: 700; }

/* ── Configuration ─────────────────────── */
.reglages { display: grid; grid-template-columns: auto 1fr; gap: 12px 18px; align-items: center; text-align: left; margin: 10px 0; }
input[type=range] { width: 220px; accent-color: var(--jaune); }
input[type=text], select {
  font-family: var(--police); font-weight: 900; font-size: 20px; padding: 10px 16px; border-radius: 18px;
  border: 4px solid var(--blanc); background: rgba(255,255,255,0.95); color: var(--encre); width: 260px; text-align: center;
}
select { width: auto; }
.touche { min-width: 120px; }
.touche.attente { background: linear-gradient(180deg, #ffe27a, var(--jaune)); color: var(--encre); }

/* ── Tableaux ──────────────────────────── */
table { border-collapse: collapse; margin: 12px auto; min-width: min(440px, 86vw); font-weight: 700; }
th, td { padding: 8px 14px; border-bottom: 2px solid rgba(255,255,255,0.3); }
th { font-size: 13px; text-transform: uppercase; opacity: 0.85; }
tr.moi td { color: var(--jaune); font-weight: 900; }
.gros { font-size: 48px; color: var(--jaune); margin: 6px 0; text-shadow: var(--contour); }
.stats { display: flex; gap: 26px; justify-content: center; margin: 14px 0; font-weight: 700; }
.stats b { display: block; font-size: 26px; font-weight: 900; text-shadow: 0 2px 0 rgba(0,0,0,0.35); }
.code { font-size: 46px; letter-spacing: 8px; color: var(--jaune); text-shadow: var(--contour); }

/* ── HUD ───────────────────────────────── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; text-shadow: var(--contour); }
.hud-bloc { position: absolute; }
.hud-hg { top: 14px; left: 18px; }
.hud-hd { top: 14px; right: 18px; text-align: right; }
.hud-bg { bottom: 14px; left: 18px; }
.hud-bd { position: absolute; bottom: 14px; right: 18px; display: flex; gap: 10px; text-shadow: none; }
.hud-label { font-size: 15px; text-transform: uppercase; letter-spacing: 1px; }
.hud-val { font-size: 40px; }
.hud-pos { font-size: 64px; color: var(--jaune); line-height: 1; }
.vitesse { font-size: 52px; line-height: 1; }
.vitesse small { font-size: 18px; }
#h-standings { margin-top: 8px; font-size: 16px; }
.ligne-pilote { display: flex; align-items: center; gap: 6px; line-height: 1.5; }
.ligne-pilote.moi { color: var(--jaune); }
.ligne-pilote .rang { width: 18px; }
.ligne-pilote .pastille { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--encre); box-shadow: none; }
.ligne-pilote .ecart { margin-left: 4px; font-size: 14px; }
.bonus {
  min-width: 74px; text-align: center; border-radius: 20px; padding: 8px 10px; color: var(--encre);
  background: rgba(255, 252, 242, 0.75); border: 4px solid var(--blanc); font-size: 14px;
}
.bonus.arme { min-width: 130px; }
.bonus .ico { font-size: 28px; }
.bonus.on { background: var(--jaune); transform: scale(1.06); }
#hud-msg { position: absolute; top: 32%; width: 100%; text-align: center; font-size: 84px; color: var(--jaune); }
#hud-boss { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); width: 340px; text-align: center; }
.barre { height: 18px; background: rgba(255,255,255,0.5); border: 3px solid var(--encre); border-radius: 10px; overflow: hidden; margin-top: 4px; }
.barre div { height: 100%; background: linear-gradient(90deg, var(--rouge), var(--orange)); transition: width 0.3s; }
#minicarte { position: absolute; bottom: 92px; left: 14px; border-radius: 24px; background: rgba(34, 34, 34, 0.25); }

/* ── Balade libre ──────────────────────── */
.hud-libre { position: fixed; inset: 0; pointer-events: none; z-index: 5; text-shadow: var(--contour); }
.hud-libre #f-map { position: absolute; bottom: 92px; left: 14px; border-radius: 24px; border: 4px solid var(--blanc); }
.aide-touches { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); font-size: 16px; white-space: nowrap; }
.aide-touches kbd { text-shadow: none; margin-left: 8px; }
.hud-message { position: absolute; top: 30%; width: 100%; text-align: center; font-size: 54px; color: var(--jaune); padding: 0 16px; }
.barre.attaque div { background: linear-gradient(90deg, #9b5de5, #3a86ff); }
.barre.attaque div.alerte { background: linear-gradient(90deg, #ff4d5e, #ffd23f); animation: clignote 0.35s infinite alternate; }
@keyframes clignote { from { opacity: 1; } to { opacity: 0.45; } }

/* ── Rétroviseur ───────────────────────── */
#retro { position: fixed; z-index: 6; pointer-events: none; border: 5px solid var(--blanc); border-radius: 18px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.25); }
#retro span { position: absolute; bottom: -24px; left: 50%; transform: translateX(-50%); font-size: 13px; text-shadow: var(--contour); white-space: nowrap; }

/* ── Comète, trophées, boutique ───────── */
.comete, .toast { position: fixed; z-index: 30; display: flex; gap: 10px; align-items: center; pointer-events: none;
  background: linear-gradient(160deg, rgba(155, 93, 229, 0.95), rgba(58, 134, 255, 0.95)); border: 4px solid var(--blanc);
  border-radius: 22px; padding: 10px 16px; max-width: min(460px, 90vw); font-size: 17px; text-shadow: 0 2px 0 rgba(0,0,0,0.35);
  box-shadow: 0 6px 0 rgba(0,0,0,0.2); animation: entree 0.35s cubic-bezier(.3, 1.6, .5, 1); }
.comete { left: 16px; bottom: 330px; }
.toast { top: 16px; left: 50%; transform: translateX(-50%); background: linear-gradient(160deg, #ffbd5c, #ff70a6); }
.comete .ico, .toast .ico { font-size: 38px; }
.pastille-couleur { width: 46px; height: 46px; border-radius: 50%; padding: 0; }
.pastille-couleur.actif { outline: 4px solid var(--jaune); }

/* ── Menu sur deux colonnes, barre de défilement discrète ── */
.menu-grille { display: grid; grid-template-columns: repeat(2, minmax(200px, 260px)); gap: 12px; justify-content: center; margin-top: 8px; }
.menu-grille button { min-width: 0; min-height: 60px; font-size: 19px; }
.menu-grille button.large { grid-column: 1 / -1; min-height: 72px; font-size: 26px; }
.ecran { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.7) transparent; }
.ecran::-webkit-scrollbar { width: 8px; }
.ecran::-webkit-scrollbar-track { background: transparent; margin: 24px 0; }
.ecran::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.7); border-radius: 8px; }
@media (max-height: 820px) {
  .ecran { padding: 20px 28px; }
  .titre { font-size: clamp(36px, 6vw, 56px); }
  .sous { margin-bottom: 10px; font-size: 15px; }
  button { min-height: 54px; font-size: 18px; }
  .menu-grille button { min-height: 52px; }
  .menu-grille button.large { min-height: 62px; }
  .aide { margin-top: 10px; }
}
@media (max-width: 560px) { .menu-grille { grid-template-columns: 1fr; } }

/* ── Discussion ────────────────────────── */
.chat { position: fixed; right: 16px; bottom: 16px; width: min(340px, 44vw); z-index: 20; pointer-events: auto;
  background: rgba(34, 24, 70, 0.82); border: 4px solid var(--blanc); border-radius: 22px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.chat-titre { font-size: 15px; } .chat-titre small { font-weight: 700; opacity: 0.8; }
.chat-log { max-height: 34vh; overflow-y: auto; font-size: 15px; font-weight: 700; line-height: 1.45; scrollbar-width: thin; }
.chat-log b { color: var(--jaune); }
.chat-log .comete-msg b { color: #ff9ae6; }
.chat-rapide { display: flex; flex-wrap: wrap; gap: 4px; }
.chat-rapide button { min-width: 0; min-height: 0; padding: 4px 8px; font-size: 18px; border-width: 2px; border-radius: 12px; }
.chat-saisie { display: flex; gap: 6px; }
.chat-saisie input { width: 100%; font-size: 15px; padding: 8px 10px; border-radius: 14px; border-width: 3px; text-align: left; }
.chat-saisie button { min-width: 0; min-height: 0; padding: 8px 12px; font-size: 14px; }
.chat.compact { background: none; border: none; pointer-events: none; left: 16px; right: auto; bottom: 330px; width: min(380px, 60vw); text-shadow: var(--contour); }
.chat.compact .chat-titre, .chat.compact .chat-rapide, .chat.compact .chat-saisie { display: none; }
.chat-menu { position: fixed; right: 16px; top: 140px; z-index: 25; background: rgba(34, 24, 70, 0.9); border: 4px solid var(--blanc);
  border-radius: 22px; padding: 12px 16px; font-size: 17px; line-height: 1.7; }
.chat-menu kbd { margin-right: 6px; }
.carte.petite { width: 150px; padding: 10px 8px; }
.carte.petite .ico { font-size: 34px; }
.carte.petite .nom { font-size: 15px; }

/* ── Commandes tactiles ────────────────── */
.tactile { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
.tactile button { pointer-events: auto; touch-action: none; min-width: 0; min-height: 0; width: 88px; height: 88px; padding: 0;
  border-radius: 50%; font-size: 34px; background: rgba(255, 255, 255, 0.28); border: 4px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 0 rgba(0,0,0,0.2); -webkit-user-select: none; user-select: none; }
.tactile button.appui { background: rgba(255, 210, 63, 0.75); transform: scale(0.94); }
.tactile .t-gros { width: 110px; height: 110px; font-size: 44px; }
.tactile .t-petit { width: 60px; height: 60px; font-size: 26px; }
.t-gauche { position: absolute; left: 18px; bottom: 26px; display: flex; gap: 16px; }
.t-droite { position: absolute; right: 18px; bottom: 26px; display: flex; gap: 14px; align-items: flex-end; }
.t-haut { position: absolute; right: 18px; top: 150px; display: flex; flex-direction: column; gap: 12px; }
.t-engins { position: absolute; left: 50%; transform: translateX(-50%); bottom: 26px; display: none; gap: 8px; }
.tactile.balade .t-engins { display: flex; }
.tactile.balade [data-tap="fire"] { display: none; }
.chat-menu .choix { cursor: pointer; padding: 2px 6px; border-radius: 10px; }
.chat-menu .choix:active { background: rgba(255, 210, 63, 0.4); }
@media (pointer: coarse) {
  .hud-bg, .hud-bd { bottom: 140px; }
  #minicarte, .hud-libre #f-map { bottom: 210px; width: 150px; height: 150px; }
  .aide-touches { display: none; }
}

/* ── Téléphones : pas de zoom, champs assez grands ── */
html, body { touch-action: manipulation; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
#scene canvas, .tactile, #hud, .hud-libre { touch-action: none; }
input[type=text], select, .chat-saisie input { font-size: 16px; }
.pin-points { display: flex; gap: 14px; justify-content: center; margin: 8px 0 14px; }
.pin-point { width: 22px; height: 22px; border-radius: 50%; border: 4px solid var(--blanc); }
.pin-point.plein { background: var(--jaune); }
.pin-pave { display: grid; grid-template-columns: repeat(3, 84px); gap: 10px; justify-content: center; }
.pin-pave .pin-touche { min-width: 0; min-height: 0; width: 84px; height: 70px; font-size: 30px; border-radius: 20px; padding: 0; }

/* ── Petits écrans (téléphone en paysage) : tout tient sans défilement vertical ── */
@media (max-height: 520px) {
  #ui { padding: 6px; }
  .ecran { padding: 10px 18px; border-width: 3px; border-radius: 22px; max-height: 98vh; min-width: 0; }
  .titre { font-size: 30px; margin-bottom: 2px; }
  h2 { font-size: 24px; margin-bottom: 4px; }
  .sous { font-size: 13px; margin-bottom: 6px; line-height: 1.35; }
  .aide { display: none; }
  button { min-height: 40px; font-size: 15px; padding: 6px 14px; border-width: 3px; border-radius: 16px; min-width: 150px; }
  button.petit { padding: 5px 10px; font-size: 13px; }
  .ligne { margin-top: 8px; gap: 8px; }
  .menu-grille { grid-template-columns: repeat(3, minmax(130px, 200px)); gap: 7px; }
  .menu-grille button { min-height: 40px; font-size: 14px; }
  .menu-grille button.large { min-height: 44px; font-size: 18px; }
  /* Listes de cartes : défilement horizontal au doigt */
  .cartes { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding: 4px 2px 8px; margin: 4px 0;
    scroll-snap-type: x mandatory; scrollbar-width: none; }
  .cartes::-webkit-scrollbar { display: none; }
  .carte, .carte.petite { flex: 0 0 auto; width: 128px; padding: 8px 6px; border-width: 3px; border-radius: 16px; scroll-snap-align: start; }
  .carte .ico, .carte.petite .ico { font-size: 26px; }
  .carte .nom, .carte.petite .nom { font-size: 13px; }
  .carte .info { font-size: 11px; }
  table { margin: 4px auto; font-size: 13px; }
  th, td { padding: 3px 8px; }
  .gros { font-size: 30px; margin: 2px 0; }
  .stats { margin: 6px 0; gap: 16px; }
  .stats b { font-size: 18px; }
  .code { font-size: 30px; }
  .reglages { gap: 6px 12px; font-size: 13px; }
  .pin-points { margin: 4px 0 8px; }
  .pin-pave { grid-template-columns: repeat(6, 56px); gap: 6px; }
  .pin-pave .pin-touche { width: 56px; height: 44px; font-size: 22px; border-radius: 14px; }
  .chat { width: min(300px, 40vw); padding: 6px; }
  .chat-log { max-height: 26vh; font-size: 13px; }
  .hud-pos { font-size: 40px; } .vitesse { font-size: 34px; } .hud-val { font-size: 28px; }
  #h-standings { font-size: 13px; }
}
.cartes.trophees .carte { width: 150px; padding: 8px 6px; }
.cartes.trophees .ico { font-size: 30px; }
.cartes.trophees .nom { font-size: 14px; }
@media (max-height: 520px) {
  .reglages { grid-template-columns: auto 1fr auto 1fr; }
  .reglages input[type=range] { width: 110px; }
  .reglages .touche { min-width: 70px; }
  .ecran h2 + .sous { margin-bottom: 4px; }
  .ecran kbd { padding: 0 5px; }
}
#comete-muette { position: fixed; left: 16px; bottom: 300px; z-index: 6; font-size: 14px; pointer-events: none; text-shadow: var(--contour); opacity: 0.85; }
.cartes.trophees { gap: 10px; }
.cartes.trophees .carte { width: 140px; padding: 6px; }
.cartes.trophees .ico { font-size: 26px; }
.cartes.trophees .info { font-size: 12px; }

/* ── Téléphone en jeu : interface minimale, on voit la piste ── */
@media (pointer: coarse) and (max-height: 560px) {
  .tactile button { width: 58px; height: 58px; font-size: 24px; border-width: 3px; background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.55); box-shadow: none; }
  .tactile .t-gros { width: 70px; height: 70px; font-size: 30px; }
  .tactile .t-petit { width: 42px; height: 42px; font-size: 18px; }
  .t-gauche { left: 10px; bottom: 10px; gap: 10px; }
  .t-droite { right: 10px; bottom: 10px; gap: 10px; }
  .t-haut { right: 10px; top: 72px; gap: 8px; flex-direction: row; }
  .t-engins { bottom: 10px; gap: 5px; }
  /* HUD de course */
  .hud-hg { top: 6px; left: 10px; } .hud-hd { top: 6px; right: 10px; }
  #h-phase, #h-standings, .hud-bg, #b-boost, #b-shield, #h-firekey { display: none; }
  .hud-pos { font-size: 30px; } .hud-label { font-size: 11px; } .hud-val { font-size: 20px; }
  .hud-bd { bottom: 12px; left: 50%; right: auto; transform: translateX(-50%); }
  .bonus.arme { min-width: 0; padding: 3px 8px; border-width: 2px; font-size: 11px; border-radius: 12px; }
  .bonus .ico { font-size: 18px; }
  #minicarte { bottom: auto; top: 6px; left: auto; right: 90px; width: 92px; height: 92px; border-radius: 14px; }
  #hud-msg { font-size: 38px; top: 26%; }
  #hud-boss { width: 190px; top: 4px; } .barre { height: 10px; }
  /* Balade */
  .hud-libre .hud-bg, .aide-touches, #f-world { display: none; }
  .hud-libre #f-map { bottom: auto; top: 6px; left: auto; right: 90px; width: 92px; height: 92px; border-width: 2px; }
  .hud-message { font-size: 26px; top: 22%; }
  /* Comète, discussion, notifications : petits et en haut */
  .comete { left: 50%; transform: translateX(-50%); bottom: auto; top: 6px; font-size: 12px; padding: 5px 10px; max-width: 46vw; border-width: 2px; }
  .comete .ico, .toast .ico { font-size: 20px; }
  .toast { font-size: 12px; padding: 5px 10px; border-width: 2px; top: 54px; }
  .chat.compact { bottom: auto; top: 110px; width: 40vw; font-size: 12px; }
  .chat-menu { top: 60px; font-size: 13px; line-height: 1.5; padding: 8px 10px; }
  #comete-muette { display: none; }
}

/* ── Mini-jeux ─────────────────────────── */
.question { font-size: 26px; margin: 10px auto 14px; max-width: 640px; line-height: 1.35; text-shadow: 0 2px 0 rgba(0,0,0,0.35); }
.reponses { display: grid; grid-template-columns: repeat(2, minmax(160px, 300px)); gap: 10px; justify-content: center; }
.reponses.n2 { grid-template-columns: repeat(2, minmax(140px, 220px)); }
.reponses button { min-width: 0; min-height: 58px; font-size: 19px; }
.reponses button kbd { font-size: 13px; margin-right: 4px; }
.reponses button.bonne { background: linear-gradient(180deg, #6ff0a8, var(--vert)); }
.reponses button.fausse { background: linear-gradient(180deg, #ff7f8c, var(--rouge)); }
.reponses button.terne { opacity: 0.5; }
.explication { margin-top: 12px; background: rgba(255,255,255,0.15); border-radius: 14px; padding: 8px 12px; }
.piste-calcul { margin: 8px auto; max-width: 560px; display: flex; flex-direction: column; gap: 6px; }
.couloir { position: relative; height: 42px; background: rgba(34,34,34,0.35); border-radius: 21px; border: 3px solid var(--blanc); }
.couloir .voiture { position: absolute; top: 2px; font-size: 28px; transition: left 0.3s; transform: scaleX(-1); }
.couloir .arrivee { position: absolute; right: 6px; top: 4px; font-size: 26px; }
.memory { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 116px)); gap: 8px; justify-content: center; margin: 8px 0; }
.carte-mem { min-width: 0; min-height: 70px; padding: 4px; font-size: 17px; background: linear-gradient(180deg, #b98bf0, var(--violet)); }
.carte-mem.visible { background: var(--blanc); color: var(--encre); text-shadow: none; }
.carte-mem.trouvee { background: linear-gradient(180deg, #6ff0a8, var(--vert)); color: #fff; }
.phrase { min-height: 54px; margin: 8px auto; padding: 8px; border-radius: 16px; background: rgba(255,255,255,0.15); max-width: 640px; }
.mot { margin: 3px; }
.grille-classes button { min-width: 80px; }

/* ── Carte du monde ────────────────────── */
.hud-globe { position: fixed; inset: 0; pointer-events: none; z-index: 8; text-shadow: var(--contour); }
.hud-globe .globe-titre { position: absolute; top: 14px; left: 18px; font-size: 22px; }
.hud-globe .globe-menu { position: absolute; top: 12px; right: 16px; pointer-events: auto; }
.hud-globe .globe-aide { position: absolute; bottom: 22px; width: 100%; text-align: center; font-size: 17px; }
.hud-globe .globe-pays { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; gap: 14px; align-items: center;
  font-size: 26px; pointer-events: auto; background: rgba(34,24,70,0.7); border: 4px solid var(--blanc); border-radius: 24px; padding: 8px 10px 8px 18px; }
.hud-globe .globe-pays button { min-width: 0; }
@media (max-height: 520px) {
  .question { font-size: 18px; margin: 4px auto 8px; }
  .reponses button { min-height: 40px; font-size: 15px; }
  .memory { grid-template-columns: repeat(6, minmax(0, 92px)); gap: 5px; }
  .carte-mem { min-height: 54px; font-size: 13px; }
  .couloir { height: 32px; } .couloir .voiture, .couloir .arrivee { font-size: 20px; }
  .hud-globe .globe-titre { font-size: 15px; top: 8px; }
  .hud-globe .globe-pays { font-size: 17px; bottom: 90px; padding: 4px 6px 4px 12px; }
  .hud-globe .globe-aide { bottom: 96px; font-size: 13px; }
}

/* Quand un écran (quiz, fiche…) est ouvert, Comète se range en haut à gauche, petite et derrière l'écran */
body.ecran-ouvert .comete { left: 8px; top: 8px; bottom: auto; transform: none; z-index: 9; max-width: min(260px, 28vw);
  font-size: 12px; padding: 5px 9px; border-width: 2px; opacity: 0.92; }
body.ecran-ouvert .comete .ico { font-size: 20px; }
@media (max-width: 900px) { body.ecran-ouvert .comete { display: none; } }

/* ── Sous-carte d'un pays : 5 lieux reliés par un chemin ── */
.drapeau { vertical-align: middle; border-radius: 3px; box-shadow: 0 0 0 2px rgba(255,255,255,0.8); }
.sous-carte { position: relative; width: min(620px, 86vw); height: min(330px, 46vh); margin: 8px auto;
  border: 4px solid var(--blanc); border-radius: 26px; overflow: hidden;
  background: radial-gradient(ellipse 62% 70% at 50% 52%, #9be08a 0 55%, #d8e8a0 62%, #f3e4a8 66%, #4fb3e8 70%, #2f8fd1 100%); }
.sous-carte svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sous-carte polyline { fill: none; stroke: #fff; stroke-width: 0.9; stroke-dasharray: 2 1.6; opacity: 0.9; vector-effect: non-scaling-stroke; stroke-width: 4px; }
.lieu { position: absolute; transform: translate(-50%, -50%); min-width: 0; padding: 4px 8px 3px; border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; line-height: 1.05; font-size: 13px; background: linear-gradient(180deg, #b98bf0, var(--violet)); }
.lieu .lieu-ico { font-size: 26px; }
.lieu .lieu-etat { position: absolute; top: -10px; right: -10px; font-size: 18px; }
.lieu .lieu-nom { white-space: nowrap; }
.lieu.gagne { background: linear-gradient(180deg, #ffe27a, #f5a524); }
.lieu.course { background: linear-gradient(180deg, #6ff0a8, var(--vert)); }
.lieu.decouvrir { animation: clignote 0.8s ease-in-out infinite alternate; background: linear-gradient(180deg, #ffbd5c, #ff70a6); }
.lieu.verrou { filter: grayscale(0.85); opacity: 0.75; }
.faits { display: flex; flex-direction: column; gap: 8px; max-width: 620px; margin: 8px auto; text-align: left; }
.fait { background: rgba(255,255,255,0.14); border-radius: 14px; padding: 8px 12px; font-size: 17px; line-height: 1.35; }
.fait button { min-width: 0; padding: 2px 8px; margin-right: 6px; }
/* Carnet de suivi */
.semaine { display: flex; gap: 8px; align-items: flex-end; justify-content: center; height: 150px; margin: 10px auto; }
.jour { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; width: 54px; font-size: 12px; }
.barre-jour { width: 28px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, #ffd23f, #ff9f1c); }
.matieres { display: grid; gap: 6px; max-width: 520px; margin: 8px auto; }
.matiere { display: grid; grid-template-columns: 150px 1fr 90px; gap: 8px; align-items: center; font-size: 15px; text-align: left; }
.jauge { height: 12px; border-radius: 6px; background: rgba(255,255,255,0.2); overflow: hidden; }
.jauge div { height: 100%; background: linear-gradient(90deg, #6ff0a8, var(--vert)); }
@media (max-width: 900px), (max-height: 520px) {
  .sous-carte { height: 52vh; border-width: 3px; }
  .lieu { font-size: 10px; padding: 2px 5px; } .lieu .lieu-ico { font-size: 18px; } .lieu .lieu-etat { font-size: 13px; top: -7px; right: -7px; }
  .fait { font-size: 13px; padding: 5px 8px; }
  .semaine { height: 100px; } .matiere { grid-template-columns: 110px 1fr 70px; font-size: 12px; }
}

/* Boutons de la carte : en haut à droite, sous le titre sur téléphone */
.hud-globe .globe-boutons { position: absolute; top: 10px; right: 14px; display: flex; gap: 8px; pointer-events: auto; }
.hud-globe .globe-boutons button { min-width: 0; padding: 8px 14px; font-size: 16px; }
.hud-globe .globe-mission { position: absolute; top: 56px; left: 18px; font-size: 16px; background: rgba(34,24,70,0.75); border-radius: 12px; padding: 4px 10px; }
@media (max-width: 900px), (max-height: 520px) {
  .hud-globe .globe-boutons { top: 34px; left: 8px; right: auto; gap: 5px; }
  .hud-globe .globe-boutons button { padding: 4px 8px; font-size: 12px; border-width: 2px; }
  .hud-globe .globe-mission { top: 70px; font-size: 12px; }
}
/* Minuteur des quiz et du mémory */
.chrono { height: 12px; width: min(520px, 80vw); margin: 6px auto 10px; border-radius: 6px; background: rgba(255,255,255,0.2); overflow: hidden; }
.chrono div { height: 100%; width: 100%; background: linear-gradient(90deg, #6ff0a8, #ffd23f); transition: width 0.1s linear; }
.chrono div.urgent { background: linear-gradient(90deg, #ff5d5d, #ff9f1c); }
/* Correction de la dictée */
.dictee-correction { line-height: 1.7; }
.mot-ok { color: #8dffb8; }
.mot-faux { color: #ffb0b0; text-decoration: underline wavy #ff5d5d; }
.mot-faux s { opacity: 0.7; }

/* ── Garage ── */
.cartes.garage .carte { min-width: 0; }
.carte.a-vendre { filter: saturate(0.6); border-style: dashed; }
.jauge-mini { display: flex; align-items: center; gap: 4px; font-size: 11px; margin: 1px 0; }
.jauge-mini > div { flex: 1; height: 7px; border-radius: 4px; background: rgba(255,255,255,0.25); overflow: hidden; }
.jauge-mini > div > div { height: 100%; background: linear-gradient(90deg, #6ff0a8, #ffd23f); }
.ameliorations { display: grid; gap: 10px; max-width: 560px; margin: 10px auto; }
.amelioration { display: grid; grid-template-columns: 170px 1fr 150px; align-items: center; gap: 10px; font-size: 18px; text-align: left; }
.amelioration button { min-width: 0; }
.crans { display: flex; gap: 5px; }
.cran { width: 22px; height: 16px; border-radius: 5px; background: rgba(255,255,255,0.22); border: 2px solid rgba(255,255,255,0.6); }
.cran.plein { background: linear-gradient(180deg, #ffd23f, #ff9f1c); }
@media (max-width: 900px), (max-height: 520px) { .amelioration { grid-template-columns: 120px 1fr 110px; font-size: 13px; } .cran { width: 14px; height: 11px; } }

/* ── Amis et notifications ── */
#notifs { position: fixed; top: 12px; right: 12px; z-index: 40; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, 90vw); }
.notif { background: linear-gradient(160deg, rgba(61, 220, 132, 0.96), rgba(58, 134, 255, 0.96)); border: 3px solid var(--blanc); border-radius: 18px;
  padding: 8px 12px; font-size: 15px; text-shadow: 0 2px 0 rgba(0,0,0,0.3); box-shadow: 0 6px 0 rgba(0,0,0,0.2); animation: entree 0.35s cubic-bezier(.3, 1.6, .5, 1); }
.notif-boutons { display: flex; gap: 6px; margin-top: 6px; }
.notif-boutons button { min-width: 0; }
.amis { display: flex; flex-direction: column; gap: 6px; max-width: 560px; margin: 8px auto; }
.ami { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: rgba(255,255,255,0.12); border-radius: 14px; padding: 6px 10px; text-align: left; }
.ami.en-ligne { background: rgba(61, 220, 132, 0.25); }
.ami button { min-width: 0; }

/* ── Zéphyr le magicien (bas à droite) ── */
.magicien { position: fixed; right: 14px; bottom: 14px; z-index: 35; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.magicien > * { pointer-events: auto; }
.magicien-bouton { width: 66px; height: 66px; min-width: 0; padding: 0; border-radius: 50%; font-size: 38px;
  background: radial-gradient(circle at 35% 30%, #c9a6ff, #6a3fd1); box-shadow: 0 0 18px rgba(201, 166, 255, 0.8), 0 5px 0 rgba(0,0,0,0.25);
  animation: flotte 2.6s ease-in-out infinite; }
@keyframes flotte { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-6px) rotate(4deg); } }
.magicien-bulle { width: min(380px, 88vw); max-height: min(460px, 70vh); display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(170deg, rgba(74, 40, 150, 0.97), rgba(34, 24, 70, 0.97)); border: 4px solid var(--blanc); border-radius: 22px; padding: 10px 12px;
  box-shadow: 0 8px 0 rgba(0,0,0,0.25); animation: entree 0.3s cubic-bezier(.3, 1.6, .5, 1); }
.magicien-tete { display: flex; justify-content: space-between; align-items: center; }
.magicien-tete button { min-width: 0; padding: 2px 9px; }
.magicien-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; font-size: 15px; line-height: 1.35; min-height: 80px; scrollbar-width: thin; }
.dit-mage { align-self: flex-start; background: rgba(201, 166, 255, 0.25); border-radius: 14px 14px 14px 4px; padding: 6px 10px; max-width: 92%; }
.dit-moi { align-self: flex-end; background: rgba(61, 220, 132, 0.35); border-radius: 14px 14px 4px 14px; padding: 6px 10px; max-width: 85%; }
.magicien-idees { display: flex; flex-wrap: wrap; gap: 4px; }
.magicien-idees button { min-width: 0; font-size: 11px; padding: 3px 7px; }
.magicien-form { display: flex; gap: 6px; }
.magicien-form input { flex: 1; min-width: 0; font-size: 15px; }
.magicien-form button { min-width: 0; }
.magicien.ouvert .magicien-idees { display: flex; }
@media (max-width: 900px), (max-height: 520px) {
  .magicien-bouton { width: 48px; height: 48px; font-size: 27px; }
  .magicien-bulle { max-height: 62vh; font-size: 13px; }
  .magicien-log { font-size: 13px; }
}

/* ── Carte « Tour du monde » en tête du menu ── */
.carte-monde { display: flex; gap: 14px; align-items: center; max-width: 560px; margin: 6px auto 8px; padding: 12px 16px; text-align: left;
  border: 4px solid var(--blanc); border-radius: 24px; background: linear-gradient(135deg, #2f8fd1 0%, #3ddc84 100%); box-shadow: 0 6px 0 rgba(0,0,0,0.2); }
.cm-globe { font-size: 64px; line-height: 1; animation: tourne-globe 6s ease-in-out infinite; }
@keyframes tourne-globe { 50% { transform: rotate(-12deg) scale(1.06); } }
.cm-infos { flex: 1; min-width: 0; }
.cm-titre { font-size: 26px; line-height: 1.1; }
.cm-stats { font-size: 14px; margin: 3px 0 6px; }
.cm-barre { height: 10px; border-radius: 6px; background: rgba(0,0,0,0.25); overflow: hidden; margin-bottom: 8px; }
.cm-barre div { height: 100%; background: linear-gradient(90deg, #ffd23f, #ff9f1c); }
.cm-boutons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cm-boutons button { min-width: 0; }
.cm-boutons .principal { font-size: 18px; padding: 8px 16px; }
.cm-jour { max-width: 560px; margin: 0 auto 8px; padding: 7px 12px; border-radius: 16px; font-size: 15px; cursor: pointer;
  background: linear-gradient(90deg, #ff9f1c, #ff70a6); border: 3px solid var(--blanc); animation: clignote 1.1s ease-in-out infinite alternate; }
.cm-jour.fait { animation: none; background: rgba(255,255,255,0.18); font-size: 13px; }
.gain { display: inline-block; margin: 6px auto; padding: 6px 14px; border-radius: 14px; background: linear-gradient(90deg, #ffd23f, #ff9f1c); color: #3a2400; text-shadow: none; }

/* ── Passeport ── */
.onglets-pays { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin: 4px 0 8px; }
.onglet-pays { position: relative; min-width: 0; padding: 4px 6px; border-radius: 10px; background: rgba(255,255,255,0.15); }
.onglet-pays.actif { background: var(--jaune); }
.onglet-pays.ferme { filter: grayscale(0.9); opacity: 0.6; }
.onglet-pays i { position: absolute; top: -8px; right: -6px; font-style: normal; font-size: 12px; }
.passeport-page { position: relative; max-width: 640px; margin: 0 auto; padding: 14px 18px; border-radius: 18px; text-align: left; color: #3b2a12; text-shadow: none;
  background: linear-gradient(180deg, #fff6dc, #f3e2b4); border: 4px solid #8a5a3a; box-shadow: inset 0 0 30px rgba(138, 90, 58, 0.25); max-height: 52vh; overflow-y: auto; scrollbar-width: thin; }
.pp-tete { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.pp-nom { font-size: 26px; line-height: 1; }
.pp-info { font-size: 13px; font-weight: 700; }
.tampon { margin-left: auto; transform: rotate(-14deg); border: 4px double #c0392b; color: #c0392b; border-radius: 12px; padding: 4px 10px; font-size: 20px; text-align: center; line-height: 1.1; }
.pp-lieux { display: grid; gap: 8px; }
.page-lieu { background: rgba(255,255,255,0.6); border-radius: 12px; padding: 6px 10px; }
.page-lieu.inconnu { opacity: 0.55; }
.page-lieu ul { margin: 4px 0 0 18px; font-size: 13px; font-weight: 600; line-height: 1.35; }
.pl-tete { font-size: 16px; }

/* ── Conseil de Zéphyr ── */
.magicien-conseil { max-width: min(300px, 70vw); min-width: 0; padding: 8px 12px; font-size: 14px; text-align: left; line-height: 1.3; border-radius: 16px 16px 4px 16px;
  background: linear-gradient(160deg, #c9a6ff, #8a5cf0); border: 3px solid var(--blanc); animation: entree 0.35s cubic-bezier(.3, 1.6, .5, 1); }
@media (max-width: 900px), (max-height: 520px) {
  .carte-monde { padding: 6px 10px; gap: 8px; margin: 2px auto 4px; } .cm-globe { font-size: 38px; } .cm-titre { font-size: 18px; }
  .cm-stats { font-size: 11px; } .cm-boutons .principal { font-size: 14px; padding: 5px 10px; } .cm-jour { font-size: 12px; padding: 4px 8px; margin-bottom: 4px; }
  .passeport-page { max-height: 48vh; padding: 8px 10px; } .pp-nom { font-size: 20px; }
}
/* Menu compact : le Tour du monde en grand, le reste en 3 colonnes */
.carte-monde ~ .menu-grille { grid-template-columns: repeat(3, minmax(150px, 190px)); gap: 8px; }
.carte-monde ~ .menu-grille button { min-height: 46px; font-size: 16px; padding: 6px 10px; }
.carte-monde { max-width: 590px; }
.cm-boutons button.petit { padding: 6px 10px; font-size: 14px; }
@media (max-width: 620px) { .carte-monde ~ .menu-grille { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px), (max-height: 520px) { .carte-monde ~ .menu-grille button { min-height: 36px; font-size: 13px; } }
/* Correctifs de la carte du menu : boutons sur une ligne, quiz du jour lisible */
.cm-boutons { flex-wrap: nowrap; }
.cm-boutons .principal { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-boutons button.petit { flex: none; white-space: nowrap; }
.cm-jour { animation: pulse-jour 1.6s ease-in-out infinite; }
@keyframes pulse-jour { 50% { transform: scale(1.025); box-shadow: 0 0 16px rgba(255, 159, 28, 0.8); } }
.carte-monde ~ .menu-grille button:last-child:nth-child(3n+1) { grid-column: 1 / -1; }
@media (max-width: 620px) { .cm-boutons { flex-wrap: wrap; } .carte-monde ~ .menu-grille button:last-child:nth-child(3n+1) { grid-column: auto; } }
.lieu.decouvrir { animation: pulse-lieu 1.2s ease-in-out infinite; }
@keyframes pulse-lieu { 50% { transform: translate(-50%, -50%) scale(1.1); box-shadow: 0 0 18px rgba(255, 210, 63, 0.9); } }
.lieu { width: max-content; } /* sinon, près du bord droit, l'étiquette est rétrécie puis déborde */
/* Messages rapides (plus de texte libre entre joueurs) */
.chat-rapide { display: flex; flex-wrap: wrap; gap: 4px; max-height: 150px; overflow-y: auto; scrollbar-width: thin; }
.chat-rapide button { min-width: 0; min-height: 0; padding: 4px 8px; font-size: 12px; }
