/* ===== Le mot du jour ===== */
:root {
  --bien: #3b5bdb;
  --bien-ink: #ffffff;
  --mal: #b0ad85;
  --mal-ink: #0f1752;
  --absent: #383e66;
  --absent-ink: rgba(255, 255, 255, 0.82);
  --touche: rgba(255, 255, 255, 0.16);
  /* La case s'adapte à la largeur ET à la hauteur de l'écran, pour que le clavier reste visible. */
  --case: max(34px, min(60px, calc((100vw - 56px) / 5), calc((100vh - 500px) / 6)));
}

@supports (height: 100dvh) {
  :root {
    --case: max(34px, min(60px, calc((100vw - 56px) / 5), calc((100dvh - 500px) / 6)));
  }
}

.mot {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 4px 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* En-tête */
.mot-tete {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mot-titre {
  text-align: center;
}

.mot-titre h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.mot-titre p {
  margin: 2px 0 0;
  color: var(--ne-chamois);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.icone {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--panel-line);
  background: var(--panel);
  color: var(--on-bg);
  font-size: 1.1rem;
  font-weight: 900;
}

.icone svg {
  width: 20px;
  height: 20px;
}

/* Indice flouté */
.indice {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  user-select: none;
  -webkit-user-select: none;
}

.indice-emoji {
  flex: none;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 2.1rem;
  line-height: 1;
  filter: blur(var(--flou-emoji, 0px));
  transition: filter 0.9s ease;
}

.indice-corps {
  min-width: 0;
}

.indice-titre {
  margin: 0 0 3px;
  color: var(--ne-chamois);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.indice-titre span {
  color: var(--on-bg-muted);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
}

.indice-texte {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  filter: blur(var(--flou, 0px));
  transition: filter 0.9s ease;
}

/* Grille */
.grille {
  display: grid;
  grid-template-rows: repeat(6, var(--case));
  gap: 6px;
}

.rangee {
  display: grid;
  grid-template-columns: repeat(5, var(--case));
  gap: 6px;
}

.case {
  display: grid;
  place-items: center;
  width: var(--case);
  height: var(--case);
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  font-size: calc(var(--case) * 0.52);
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.case.pleine {
  border-color: rgba(255, 255, 255, 0.62);
  animation: pop 0.12s ease-out;
}

.case.bien,
.case.mal,
.case.absent {
  border-color: transparent;
}

.case.bien {
  background: var(--bien);
  color: var(--bien-ink);
}

.case.mal {
  background: var(--mal);
  color: var(--mal-ink);
}

.case.absent {
  background: var(--absent);
  color: var(--absent-ink);
}

.case.tourne {
  animation: tourne 0.5s ease-in-out;
}

.case.saute {
  animation: saute 0.6s ease-out both;
  animation-delay: calc(var(--i) * 90ms);
}

.rangee.secoue {
  animation: secoue 0.45s ease;
}

@keyframes pop {
  from {
    scale: 0.88;
  }
  to {
    scale: 1;
  }
}

@keyframes tourne {
  0% {
    transform: rotateX(0);
  }
  50% {
    transform: rotateX(90deg);
  }
  100% {
    transform: rotateX(0);
  }
}

@keyframes saute {
  0%,
  100% {
    translate: 0 0;
  }
  35% {
    translate: 0 -34%;
  }
  60% {
    translate: 0 6%;
  }
}

@keyframes secoue {
  0%,
  100% {
    translate: 0 0;
  }
  20%,
  60% {
    translate: -7px 0;
  }
  40%,
  80% {
    translate: 7px 0;
  }
}

/* Clavier AZERTY */
.clavier {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 4px;
  user-select: none;
  -webkit-user-select: none;
}

.clavier-ligne {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.touche {
  flex: 1 1 0;
  min-width: 0;
  max-width: 44px;
  height: 52px;
  border: 0;
  border-radius: 8px;
  background: var(--touche);
  color: var(--on-bg);
  font-size: 1rem;
  font-weight: 800;
  touch-action: manipulation;
  transition: background 0.3s ease, transform 0.08s ease;
}

.touche:active {
  transform: scale(0.94);
}

.touche--large {
  flex-grow: 1.6;
  max-width: 72px;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.touche--large svg {
  width: 22px;
  height: 22px;
}

.touche.bien {
  background: var(--bien);
  color: var(--bien-ink);
}

.touche.mal {
  background: var(--mal);
  color: var(--mal-ink);
}

.touche.absent {
  background: var(--absent);
  color: rgba(255, 255, 255, 0.5);
}

/* Fenêtres */
.voile {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5, 8, 32, 0.72);
  backdrop-filter: blur(4px);
  overflow-y: auto;
  animation: apparait 0.25s ease;
}

.fiche {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: 24px 20px 20px;
  border-radius: 22px;
  background: #151c5f;
  border: 1px solid var(--panel-line);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
  animation: monte 0.35s ease;
}

.fiche h2 {
  margin: 0 0 12px;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.2;
}

.fiche h3 {
  margin: 18px 0 8px;
  color: var(--ne-chamois);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fiche p {
  margin: 0 0 10px;
  font-size: 0.92rem;
  line-height: 1.5;
}

.fiche-sur {
  color: var(--ne-chamois);
  font-size: 0.75rem !important;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fermer {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--on-bg);
  font-size: 1.4rem;
  line-height: 1;
}

.btn-large {
  width: 100%;
  margin-top: 8px;
}

@keyframes apparait {
  from {
    opacity: 0;
  }
}

@keyframes monte {
  from {
    translate: 0 24px;
    opacity: 0;
  }
}

/* Règles */
.exemple {
  display: flex;
  gap: 5px;
  margin: 4px 0 12px;
  --case: 42px;
}

.legende {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
  line-height: 1.45;
}

.legende li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.pastille {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 5px;
}

.pastille.bien {
  background: var(--bien);
}

.pastille.mal {
  background: var(--mal);
}

.pastille.absent {
  background: var(--absent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

/* Fin de partie */
.fin-mot {
  display: flex;
  gap: 5px;
  margin: 2px 0 14px;
  --case: 46px;
}

.fin-mot .case {
  width: auto;
  min-width: var(--case);
  padding: 0 4px;
}

.fin-explication {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  border-left: 4px solid var(--ne-chamois);
}

.fin-explication p {
  margin-bottom: 6px;
}

.fin-explication a {
  color: var(--ne-chamois-light);
  font-size: 0.85rem;
  font-weight: 800;
}

.fin-grille {
  margin: 0 0 12px;
  font-family: inherit;
  font-size: 1.15rem;
  line-height: 1.25;
  letter-spacing: 2px;
}

.fin-bas {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--panel-line);
  text-align: center;
}

.fin-bas p {
  margin: 0;
}

.prochain strong {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  color: var(--ne-chamois);
}

.fin-autres {
  color: var(--on-bg-muted);
  font-size: 0.85rem !important;
}

.fin-autres a {
  color: var(--on-bg);
  font-weight: 800;
}

/* Statistiques */
.chiffres {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
}

.chiffres b {
  display: block;
  font-size: 1.7rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.chiffres span {
  display: block;
  color: var(--on-bg-muted);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.25;
}

.repartition {
  display: grid;
  gap: 5px;
}

.barre {
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 800;
}

.barre i {
  display: block;
  min-width: 26px;
  width: var(--p);
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--absent);
  font-style: normal;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.barre.aujourdhui i {
  background: var(--bien);
}
