:root {
  --encre: #22305a;
  --carte: rgba(255, 255, 255, 0.95);
  --vert: #2fbf71;
  --bleu: #3b82f6;
  --orange: #ff9f1c;
  --rouge: #ef6a6a;
  --gris: #8d99ae;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd3ff; font-family: "Trebuchet MS", "Avenir Next", system-ui, sans-serif; color: var(--encre); touch-action: manipulation; user-select: none; }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
.ecran { position: absolute; inset: 0; display: flex; flex-direction: column; pointer-events: none; }
.ecran > *, .ecran button { pointer-events: auto; }
.cache { display: none !important; }

button { font: inherit; color: #fff; border: 0; cursor: pointer; min-height: 64px; min-width: 64px; padding: 10px 22px; border-radius: 18px; background: var(--bleu); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.22); font-weight: 800; font-size: clamp(1.1rem, 3.4vw, 1.6rem); transition: transform 0.08s; }
button:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.22); }
button:focus-visible { outline: 4px solid #ffd43b; outline-offset: 2px; }
button.vert { background: var(--vert); }
button.bleu { background: var(--bleu); }
button.gris { background: var(--gris); }
button.gros { min-height: 76px; padding: 12px 34px; font-size: clamp(1.4rem, 4.4vw, 2.1rem); }
button.rond { padding: 0; width: 64px; height: 64px; font-size: 1.7rem; border-radius: 20px; background: var(--orange); }
button[disabled], button.retire { opacity: 0.35; box-shadow: none; pointer-events: none; }

/* Titre */
#ecran-titre { align-items: center; justify-content: center; background: linear-gradient(180deg, rgba(91, 188, 255, 0.35), rgba(255, 255, 255, 0)); background-size: cover; background-position: center; }
#ecran-titre.avec-image { pointer-events: auto; }
.titre-boite { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 22px 28px; text-align: center; border-radius: 28px; background: rgba(255, 255, 255, 0.82); max-width: 92vw; }
.titre-boite img { width: min(34vw, 190px); height: auto; }
h1 { margin: 0; font-size: clamp(2rem, 8vw, 4rem); line-height: 1.05; color: #d6336c; text-shadow: 0 3px 0 #fff; }
.sous-titre { margin: 0; font-size: clamp(1.1rem, 3.5vw, 1.6rem); font-weight: 700; }

/* Ville */
.bandeau { align-self: center; margin: 18px 12px 0; padding: 10px 26px; border-radius: 20px; background: var(--carte); font-size: clamp(1.3rem, 4.4vw, 2.2rem); pointer-events: none; text-align: center; }
.ville-boutons { margin-top: auto; padding: 0 12px 18px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ville-boutons button { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 92px; padding: 10px 6px; font-size: clamp(1rem, 3vw, 1.5rem); }
.ville-boutons .icone { font-size: 2.1rem; line-height: 1; height: 2.4rem; display: flex; align-items: center; }
.ville-boutons .icone img { height: 2.4rem; width: auto; }
.ville-boutons .petites-etoiles { font-size: 0.85rem; letter-spacing: 1px; }
@media (max-width: 560px) { .ville-boutons { grid-template-columns: repeat(2, 1fr); } }

/* Panneaux */
#ecran-paliers, #ecran-fin { align-items: center; justify-content: center; }
.panneau { background: var(--carte); border-radius: 28px; padding: 22px 24px; display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 94vw; box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12); }
.panneau h2 { margin: 0; font-size: clamp(1.6rem, 5.4vw, 2.6rem); text-align: center; }
.paliers { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.paliers button { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 130px; min-height: 110px; }
.paliers .etoiles { font-size: 1.5rem; letter-spacing: 2px; }
.paliers button.verrou { background: var(--gris); opacity: 0.75; }
.message { margin: 0; min-height: 1.4em; font-weight: 700; font-size: 1.15rem; text-align: center; }
.etoiles-fin { margin: 0; font-size: clamp(2.6rem, 11vw, 5rem); letter-spacing: 6px; }
.boutons-fin { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

/* Partie */
#ecran-partie { justify-content: space-between; }
.haut { display: flex; flex-direction: column; gap: 8px; padding: 10px 10px 0; }
.barre { display: flex; align-items: center; gap: 10px; }
.loupes { flex: 1; display: flex; gap: 6px; justify-content: center; font-size: clamp(1.4rem, 5vw, 2rem); background: var(--carte); border-radius: 20px; padding: 6px 10px; min-height: 64px; align-items: center; }
.loupes span { opacity: 0.3; transition: transform 0.2s; }
.loupes span.courante { opacity: 1; transform: scale(1.25); }
.loupes span.faite { opacity: 1; filter: hue-rotate(250deg) saturate(2); }
.carte { background: var(--carte); border-radius: 24px; padding: 12px 14px 16px; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12); }
.consigne { margin: 0 0 10px; font-weight: 800; font-size: clamp(1.05rem, 3.6vw, 1.5rem); text-align: center; color: #3b4a8f; }
.phrase { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.mot { display: inline-flex; align-items: center; justify-content: center; min-height: 64px; min-width: 48px; padding: 4px 12px; border-radius: 16px; background: #eef3ff; color: var(--encre); font-weight: 800; font-size: clamp(1.3rem, 5.2vw, 2.4rem); border: 3px solid transparent; box-shadow: none; }
button.mot { background: #eef3ff; color: var(--encre); box-shadow: 0 4px 0 #c5d1f5; font-weight: 800; padding: 4px 12px; }
.mot.ponct { background: transparent; min-width: 22px; padding: 4px 2px; }
.mot.groupe { border-bottom: 7px solid var(--orange); background: #fff2d9; }
.mot.trou { min-width: 110px; border: 4px dashed #3b82f6; background: #fff; }
.mot.vide { min-width: 52px; border: 4px dashed #3b82f6; background: #fff; }
.mot.cible { border-color: var(--orange); background: #fff2d9; animation: pulse 0.9s ease-in-out infinite; }
.mot.repere { background: #e5dbff; border-color: #7b3fe4; }
.mot.change { background: #d3f9d8; border-color: var(--vert); color: #1b7a43; animation: pop 0.45s ease-out; }
.mot.faux { animation: secoue 0.4s; background: #ffe3e3; }
@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes pop { 0% { transform: scale(0.7); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes secoue { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.bas { display: flex; flex-direction: column; gap: 10px; padding: 0 10px 14px; }
.choix { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.choix button { min-height: 76px; min-width: 130px; font-size: clamp(1.4rem, 5vw, 2.2rem); }
.choix button small { display: block; font-size: 0.5em; font-weight: 700; opacity: 0.9; }
.choix button:nth-child(3n+1) { background: var(--bleu); }
.choix button:nth-child(3n+2) { background: #e64980; }
.choix button:nth-child(3n) { background: #7b3fe4; }
.frise { display: flex; align-items: stretch; justify-content: center; gap: 10px; position: relative; padding-top: 8px; }
.frise::before { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 8px; margin-top: -4px; background: #fff; border-radius: 4px; opacity: 0.8; }
.frise button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; max-width: 200px; min-height: 96px; }
.frise button .ico { font-size: 2rem; line-height: 1; }
.frise button.passe { background: #5c6bc0; }
.frise button.present { background: var(--orange); }
.frise button.futur { background: var(--vert); }
.bulle { display: flex; align-items: center; gap: 12px; background: #fffbe0; border: 4px solid #ffd43b; border-radius: 22px; padding: 10px 16px; animation: pop 0.35s ease-out; pointer-events: auto; }
.bulle img { height: 72px; width: auto; }
#bulle-emoji { font-size: 2.6rem; }
.bulle p { margin: 0; font-weight: 800; font-size: clamp(1.1rem, 3.8vw, 1.7rem); }

#debug { position: fixed; left: 6px; bottom: 6px; margin: 0; padding: 6px; font: 11px system-ui; background: rgba(255, 255, 255, 0.85); max-width: 50vw; pointer-events: none; }
#debug:not(.cache) { display: block; }

@media (orientation: portrait) {
  .ville-boutons button { min-height: 100px; }
}
@media (max-height: 520px) {
  .carte { padding: 6px 10px 8px; }
  .mot { min-height: 64px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
