:root {
  --bitume: #262C2F;
  --beton: #3A4247;
  --beton-clair: #4A5359;
  --craie: #F1F2EE;
  --gris-texte: #B9BFBF;
  --jaune: #F2C300;
  --jaune-fonce: #C99F00;
  --encre: #1A1D1F;
  --vert: #2E9E68;
  --ambre: #E08A1E;
  --rouge: #D9534A;
  --condense: 'Barlow Condensed', 'Roboto Condensed', 'Arial Narrow', sans-serif-condensed, sans-serif;
  --texte: 'Barlow', 'Segoe UI', Roboto, system-ui, sans-serif;
  --rayon: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bitume);
  color: var(--craie);
  font-family: var(--texte);
  font-size: clamp(17px, 1.6vw, 22px);
  line-height: 1.4;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.vue-borne { height: 100%; display: flex; flex-direction: column; position: relative; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible { outline: 4px solid var(--jaune); outline-offset: 3px; }

/* ---------- Bandeau ---------- */
.bandeau {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 18px clamp(16px, 3vw, 40px) 0;
  color: var(--gris-texte);
}
.lieu { font-weight: 500; }
.horloge { display: flex; align-items: baseline; gap: 16px; }
.horloge strong {
  font-family: var(--condense);
  font-weight: 600;
  font-size: clamp(34px, 4vw, 52px);
  color: var(--craie);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.hors-ligne {
  margin: 14px clamp(16px, 3vw, 40px) 0;
  padding: 12px 18px;
  border-radius: var(--rayon);
  background: var(--rouge);
  color: #fff;
  font-weight: 600;
}

main { flex: 1; display: flex; min-height: 0; }
.ecran { flex: 1; display: flex; padding: clamp(16px, 3vw, 40px); min-height: 0; }
[hidden] { display: none !important; }

h1 {
  font-family: var(--condense);
  font-weight: 600;
  margin: 0;
  line-height: 1.05;
}

/* ---------- Saisie ---------- */
.saisie { gap: clamp(24px, 4vw, 64px); align-items: center; }
.saisie-gauche { flex: 1; display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.saisie h1 { font-size: clamp(36px, 4.4vw, 60px); }
.aide { margin: 0; color: var(--gris-texte); max-width: 30em; }
.aide.erreur { color: var(--ambre); font-weight: 600; }

/* Langues : chaque nom est écrit dans sa propre langue */
.langues { display: flex; flex-wrap: wrap; gap: 8px; max-width: 34em; }
.langue {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  border: 2px solid var(--beton-clair);
  color: var(--craie);
  font-size: 17px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.langue[aria-pressed="true"] { background: var(--craie); color: var(--encre); border-color: var(--craie); font-weight: 600; }
.langue svg { width: 20px; height: 20px; }

.voile {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 26, 0.86);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 5;
}
.panneau-langues {
  background: var(--bitume);
  border: 2px solid var(--beton-clair);
  border-radius: 18px;
  padding: 28px;
  width: min(720px, 100%);
  display: flex;
  flex-direction: column;
  gap: 22px;
  align-items: center;
}
.panneau-langues h2 { font-family: var(--condense); font-weight: 600; font-size: 34px; margin: 0; }
.grille-langues { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; width: 100%; }
.grille-langues .langue { justify-content: center; min-height: 64px; font-size: 20px; border-radius: var(--rayon); }

.plaque {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 14px);
  padding: clamp(14px, 1.6vw, 22px) clamp(18px, 2vw, 30px);
  background: var(--jaune);
  color: var(--encre);
  border-radius: 10px;
  border: 5px solid var(--encre);
  box-shadow: 0 0 0 3px var(--jaune);
  font-family: var(--condense);
  font-weight: 700;
  line-height: 1;
}
.plaque-xvp { font-size: clamp(52px, 6.5vw, 96px); letter-spacing: 0.02em; margin-right: 0.12em; }
.chiffre {
  width: 0.78em;
  font-size: clamp(64px, 8vw, 120px);
  text-align: center;
  border-bottom: 6px solid rgba(26, 29, 31, 0.35);
  min-height: 1em;
  font-variant-numeric: tabular-nums;
}
.chiffre.rempli { border-bottom-color: transparent; }
.chiffre.curseur { border-bottom-color: var(--encre); animation: clignote 1.1s steps(2, start) infinite; }
@keyframes clignote { to { border-bottom-color: transparent; } }
.plaque.refus { animation: refus 0.4s ease; }
@keyframes refus { 20%, 60% { transform: translateX(-12px); } 40%, 80% { transform: translateX(12px); } }

.clavier {
  flex: 0 0 auto;
  width: min(46vw, 560px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(10px, 1.2vw, 16px);
}
.touche {
  aspect-ratio: 1.35;
  border-radius: var(--rayon);
  background: var(--beton);
  font-family: var(--condense);
  font-weight: 600;
  font-size: clamp(40px, 4.4vw, 64px);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.06s, background 0.06s;
}
.touche:active { transform: translateY(3px); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25); background: var(--beton-clair); }
.touche.secondaire { background: transparent; border: 2px solid var(--beton-clair); box-shadow: none; font-family: var(--texte); font-size: clamp(18px, 1.7vw, 24px); font-weight: 500; color: var(--gris-texte); }

/* ---------- Choix / doublon / succès / message ---------- */
.choix, .doublon, .succes, .message {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 22px;
}
.code-rappel { margin: 0; color: var(--gris-texte); font-size: 1.1em; }
.nom { font-size: clamp(56px, 8vw, 120px); font-weight: 700; letter-spacing: 0.01em; max-width: 14em; overflow-wrap: anywhere; }
.actions { display: flex; gap: clamp(16px, 2vw, 28px); flex-wrap: wrap; justify-content: center; margin-top: 18px; }

.bouton-sens {
  width: clamp(240px, 30vw, 380px);
  padding: 26px 20px 22px;
  border-radius: var(--rayon);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-family: var(--condense);
  font-weight: 700;
  font-size: clamp(40px, 4.6vw, 64px);
  line-height: 1;
  background: var(--beton);
  border: 3px solid var(--beton-clair);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.25);
}
.bouton-sens svg { width: 1.2em; height: 1.2em; }
.bouton-sens small { font-family: var(--texte); font-size: 18px; font-weight: 500; color: var(--gris-texte); }
.bouton-sens.suggere { background: var(--jaune); color: var(--encre); border-color: var(--jaune); }
.bouton-sens.suggere small { color: rgba(26, 29, 31, 0.75); }
.bouton-sens:active { transform: translateY(3px); }

.bouton {
  min-height: 84px;
  padding: 0 36px;
  border-radius: var(--rayon);
  font-weight: 600;
  font-size: clamp(20px, 2vw, 26px);
}
.bouton.principal { background: var(--jaune); color: var(--encre); }
.bouton.secondaire { border: 2px solid var(--beton-clair); color: var(--craie); }
.lien-retour { margin-top: 14px; padding: 18px 26px; color: var(--gris-texte); text-decoration: underline; text-underline-offset: 5px; }

.pictogramme { width: clamp(80px, 9vw, 120px); height: auto; }
.doublon .pictogramme { color: var(--ambre); }
.doublon h1, .message h1 { font-size: clamp(36px, 4.6vw, 64px); max-width: 18em; }
.sous-titre { margin: 0; color: var(--gris-texte); font-size: 1.15em; max-width: 34em; }

.succes .pictogramme { color: var(--vert); animation: apparait 0.35s ease-out; }
@keyframes apparait { from { transform: scale(0.6); opacity: 0; } }
.succes h1 { font-size: clamp(40px, 5vw, 72px); }
.heure-pointee {
  margin: -6px 0 0;
  font-family: var(--condense);
  font-weight: 700;
  font-size: clamp(80px, 11vw, 170px);
  line-height: 1;
  color: var(--vert);
  font-variant-numeric: tabular-nums;
}
.compte-a-rebours { width: min(560px, 80vw); height: 6px; border-radius: 3px; background: var(--beton); overflow: hidden; margin-top: 10px; }
.compte-a-rebours span { display: block; height: 100%; background: var(--gris-texte); width: 100%; transform-origin: left; }

/* ---------- Format portrait (tablette verticale, téléphone) ---------- */
@media (max-aspect-ratio: 1/1) {
  .saisie { flex-direction: column; justify-content: center; }
  .saisie-gauche { flex: 0 0 auto; align-items: center; text-align: center; }
  .plaque { align-self: center; }
  .langues { justify-content: center; }
  .clavier { width: min(92vw, 560px); }
}
@media (max-height: 620px) and (min-aspect-ratio: 1/1) {
  .touche { aspect-ratio: 1.8; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
