/* MAUZTETRIS - feuille de style (thème sombre unique, identité MAUZ) */

/* Jetons de couleur */
:root {
  color-scheme: dark;
  --nuit: #070b07;
  --texte: #eafbea;
  --texte-doux: rgba(234, 251, 234, .6);
  --filet: rgba(234, 251, 234, .16);
  --mau: hsl(125 70% 70%);
  --z: hsl(45 88% 62%);
  --rose: #FF5C8A;
  --rouge: #FF3B30;
  --violet: #A238FF;
  --cyan: #3ECFDA;
  --spotify: #1ED760;
  --mauzitel-fond: #050912;
  --lueur-mau: hsl(125 70% 70% / .12);
  --police-titre: Anton, Impact, sans-serif;
  --police-texte: 'Space Grotesk', system-ui, sans-serif;
  --police-minitel: VT323, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

/* Page */
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, hsl(125 70% 70% / .06), transparent 70%),
    var(--nuit);
  color: var(--texte);
  font-family: var(--police-texte);
  font-size: 15px;
  line-height: 1.45;
  padding-block: 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  overflow-x: hidden;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--z);
  outline-offset: 3px;
}

/* Grille principale (desktop) */
.app {
  display: grid;
  grid-template-columns: 190px auto 270px;
  grid-template-rows: auto auto auto auto 1fr auto;
  grid-template-areas:
    "tete tete tete"
    "reserve plateau suivantes"
    "stats plateau mauzitel"
    "lettres plateau mauzitel"
    "aide plateau mauzitel"
    "pied pied pied";
  gap: 18px 22px;
  justify-content: center;
  min-height: calc(100svh - 32px);
}

.app > * {
  min-width: 0;
  align-self: start;
}

.tete { grid-area: tete; }
.reserve { grid-area: reserve; }
.stats { grid-area: stats; }
.lettres-bloc { grid-area: lettres; }
.plateau-cadre { grid-area: plateau; }
.suivantes { grid-area: suivantes; }
.mauzitel { grid-area: mauzitel; }
.touches { grid-area: touches; }
.aide { grid-area: aide; }
.pied { grid-area: pied; }

/* Panneaux sobres */
.panneau {
  min-width: 0;
}

.etiquette {
  margin: 0 0 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(234, 251, 234, .12);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--texte-doux);
}

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

.logo-bloc {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.logo {
  margin: 0;
  font-family: var(--police-titre);
  font-weight: 400;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  line-height: .9;
  text-transform: uppercase;
  white-space: nowrap;
}

.logo .mau {
  color: var(--mau);
}

.logo .z {
  display: inline-block;
  color: var(--z);
  transform: rotate(-3deg);
}

.logo .tetris {
  color: #fff;
  -webkit-text-stroke: 1.5px var(--rose);
}

.hashtag {
  margin: 0;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: .35em;
  text-transform: uppercase;
  color: var(--texte-doux);
}

#btn-pause {
  min-height: 44px;
  padding: .5em 1.2em;
  border: 1px solid var(--filet);
  border-radius: 999px;
  background: transparent;
  color: var(--texte);
  font: 500 14px var(--police-texte);
  cursor: pointer;
  touch-action: manipulation;
}

#btn-pause:hover {
  border-color: var(--mau);
}

/* Réserve et suivantes */
#reserve {
  display: block;
  width: 100%;
  height: 90px;
}

#suivantes {
  display: block;
  width: 100%;
  height: 180px;
}

/* Stats */
.stats-grille {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.score {
  margin: 0;
  font-family: var(--police-titre);
  font-size: 3rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--texte);
}

.stat {
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: var(--texte-doux);
}

.stat strong {
  color: var(--texte);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.sommet {
  margin-top: 12px;
}

.sommet-nom {
  margin: 0;
  font-weight: 500;
  font-size: 14px;
}

.sommet-alt {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--texte-doux);
  font-variant-numeric: tabular-nums;
}

.barre {
  height: 6px;
  border-radius: 999px;
  background: rgba(234, 251, 234, .12);
  overflow: hidden;
}

#progression {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--mau), var(--z));
  transition: width .4s ease;
}

.prochain {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--texte-doux);
}

/* Lettres MAUZ */
.lettres {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.lettre {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(234, 251, 234, .25);
  border-radius: 6px;
  background: #0b120c;
  font-family: var(--police-titre);
  font-size: 1.6rem;
  color: rgba(234, 251, 234, .25);
}

.lettre.on {
  border-style: solid;
  border-color: transparent;
  background: var(--mau);
  color: var(--nuit);
  animation: pop-lettre .4s ease-out;
}

.lettre.on[data-l="Z"] {
  background: var(--z);
}

.lettres.complet .lettre {
  animation: brille 1s ease-in-out infinite alternate;
}

.aide-lettres {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--texte-doux);
}

/* Plateau */
.plateau-cadre {
  position: relative;
  align-self: start;
  height: min(calc(100svh - 150px), 740px);
  min-height: 440px;
  aspect-ratio: 1 / 2;
  border: 2px solid var(--filet);
  border-radius: 6px;
  overflow: hidden;
  background: #050a06;
  box-shadow: 0 0 40px var(--lueur-mau);
}

#plateau {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Pops (annonces de score animées) */
.pops {
  position: absolute;
  top: 18%;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.pop {
  font-family: var(--police-titre);
  text-transform: uppercase;
  font-size: clamp(16px, 2.6vw, 22px);
  color: #fff;
  text-shadow: 0 2px 0 var(--mauzitel-fond), 0 0 12px rgba(0, 0, 0, .8);
  animation: monter 1.4s ease-out forwards;
}

.pop--combo {
  color: var(--rose);
}

.pop--mauz {
  color: var(--z);
  font-size: clamp(26px, 4vw, 34px);
}

.pop--mauztris {
  color: var(--mau);
  font-size: clamp(30px, 5vw, 40px);
}

.pop--carte {
  padding: .35em .7em;
  border: 1px solid rgba(62, 207, 218, .4);
  border-radius: 6px;
  background: rgba(5, 9, 18, .9);
  font-family: var(--police-texte);
  font-weight: 700;
  font-size: 14px;
  text-transform: none;
  text-shadow: none;
  color: var(--cyan);
}

.pop--niveau {
  padding: .2em .6em;
  border-radius: 4px;
  background: rgba(7, 11, 7, .85);
  font-size: 15px;
  color: var(--z);
}

/* Superpositions (accueil, pause, fin) */
.ecran {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  overflow: auto;
  padding: 16px;
  background: rgba(7, 11, 7, .85);
}

.ecran > section {
  margin: auto;
  width: min(100%, 320px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.accroche {
  margin: 0;
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--texte-doux);
}

.ecran-titre {
  margin: 0;
  font-family: var(--police-titre);
  font-weight: 400;
  font-size: clamp(2.4rem, 9vw, 3.4rem);
  line-height: .95;
  text-transform: uppercase;
}

.ecran-titre .mau {
  color: var(--mau);
}

.ecran-titre .z {
  color: var(--z);
}

.regles {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  text-align: left;
  font-size: 14px;
}

.regles li::before {
  content: "▸ ";
  color: var(--z);
}

.meilleur-accueil,
.copie-statut {
  margin: 0;
  font-size: 14px;
}

.meilleur-accueil {
  color: var(--texte-doux);
}

.fin-etiquette {
  margin: 0;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--texte-doux);
}

.fin-score {
  margin: 0;
  font-family: var(--police-titre);
  font-size: clamp(3rem, 14vw, 4.5rem);
  line-height: 1;
  color: var(--z);
  font-variant-numeric: tabular-nums;
}

.copie-statut {
  min-height: 1.4em;
  color: var(--mau);
}

.lien-decouvrir {
  font-size: 14px;
  color: var(--mau);
}

/* Boutons */
.bouton-principal,
.bouton-secondaire {
  min-height: 48px;
  padding: .75em 2em;
  border-radius: 999px;
  font-family: var(--police-titre);
  font-size: 1.2rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}

.bouton-principal {
  border: 0;
  background: var(--mau);
  color: var(--nuit);
}

.bouton-principal:hover {
  filter: brightness(1.08);
}

.bouton-secondaire {
  border: 2px solid var(--texte-doux);
  background: transparent;
  color: var(--texte);
}

.bouton-secondaire:hover {
  border-color: var(--texte);
}

/* Suivantes */
.suivantes {
  display: flex;
  flex-direction: column;
}

/* Mauzitel (panneau rétro, police VT323) */
.mauzitel {
  position: relative;
  align-self: start;
  overflow: hidden;
  padding: 14px;
  border: 2px solid rgba(62, 207, 218, .4);
  background: var(--mauzitel-fond);
  color: var(--texte);
  font-family: var(--police-minitel);
  font-size: 20px;
  line-height: 1.15;
}

/* Scanlines discrètes */
.mauzitel::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .035) 0 1px, transparent 1px 3px);
  pointer-events: none;
}

.mauzitel > * {
  position: relative;
  z-index: 0;
}

.mauzitel p {
  margin: 0 0 8px;
  font-size: 20px;
}

.mauzitel-tete {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(62, 207, 218, .4);
}

.mauzitel h2 {
  margin: 0;
  font-family: var(--police-minitel);
  font-weight: 400;
  font-size: 40px;
  line-height: 1;
  letter-spacing: .04em;
  color: var(--z);
}

.mauzitel .sous-titre {
  margin: 0;
  font-size: 20px;
  color: var(--cyan);
}

.mauzitel-une-label {
  margin: 0 0 4px;
  font-size: 18px;
  text-transform: uppercase;
  color: var(--texte-doux);
}

/* Carte du Mauzitel (lien injecté par mauzitel.js) */
.mauzitel a.carte {
  display: block;
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid var(--cyan);
  color: inherit;
  text-decoration: none;
  transition: border-color .2s ease;
}

.mauzitel a.carte:hover,
.mauzitel a.carte:focus-visible {
  border-color: var(--z);
}

.mauzitel a.carte .rub {
  display: inline-block;
  padding: 0 6px;
  border-radius: 2px;
  background: var(--c, var(--cyan));
  color: var(--nuit);
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.mauzitel a.carte .titre {
  display: block;
  margin: 6px 0 2px;
  font-family: var(--police-minitel);
  font-weight: 400;
  font-size: 22px;
  color: var(--z);
}

.mauzitel a.carte .texte {
  display: block;
  font-size: 18px;
  color: var(--texte);
}

.mauzitel a.carte .url {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  color: var(--cyan);
  overflow-wrap: anywhere;
}

.mauzitel ul {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.mauzitel li {
  padding: 3px 0;
  font-size: 18px;
}

.mauzitel li a {
  color: var(--cyan);
  text-decoration: underline;
}

.mauzitel li small {
  display: block;
  font-size: 16px;
  color: var(--texte-doux);
}

.mauzitel li.vide {
  color: var(--texte-doux);
}

/* Flash lors d'une nouvelle carte */
#mauzitel.flash {
  animation: clignote-z 1.2s ease-in-out;
}

/* Manette tactile : masquée sur grand écran */
.touches {
  display: none;
}

/* Aide */
.aide {
  font-size: 13px;
  color: var(--texte-doux);
}

.aide-tactile {
  display: none;
  margin: 0;
}

.raccourcis,
.bareme {
  margin: 0;
  padding: 0;
  list-style: none;
}

.raccourcis {
  display: grid;
  gap: 4px;
}

.bareme-bloc {
  margin-top: 12px;
}

.bareme {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
}

.bareme strong,
.raccourcis kbd {
  color: var(--texte);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

kbd {
  padding: 0 .35em;
  border: 1px solid rgba(234, 251, 234, .2);
  border-radius: 4px;
  background: rgba(234, 251, 234, .08);
  font-family: var(--police-texte);
  font-size: 12px;
}

/* Pied de page */
.pied {
  padding-top: 14px;
  border-top: 1px solid rgba(234, 251, 234, .1);
  text-align: center;
}

.pied-titre {
  margin: 0 0 10px;
  font-family: var(--police-titre);
  font-weight: 400;
  font-size: 14px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--texte-doux);
}

.pilules {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.pilule {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: .45rem .85rem;
  border: 1px solid var(--filet);
  border-radius: .9rem;
  background: rgba(7, 14, 8, .55);
  color: var(--texte);
  font-size: 14px;
  text-decoration: none;
  transition: border-color .2s ease;
}

.pilule .point {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--teinte);
}

.pilule:hover,
.pilule:focus-visible {
  border-color: var(--teinte);
}

.mention {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--texte-doux);
}

/* Annonces pour lecteurs d'écran uniquement */
.lecteur {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Responsive : mobile */
@media (max-width: 900px) {
  .app {
    grid-template-columns: auto 72px;
    grid-template-rows: auto;
    grid-template-areas:
      "tete tete"
      "stats stats"
      "lettres lettres"
      "plateau reserve"
      "plateau suivantes"
      "touches touches"
      "mauzitel mauzitel"
      "aide aide"
      "pied pied";
    gap: 10px;
    justify-content: center;
  }

  .plateau-cadre {
    height: min(56svh, calc((100vw - 120px) * 2));
    min-height: 0;
  }

  #reserve {
    height: 60px;
  }

  #suivantes {
    height: 180px;
  }

  .stats-grille {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 14px;
  }

  .score {
    font-size: 2.2rem;
  }

  .stat {
    justify-content: flex-start;
  }

  .sommet {
    width: 100%;
    margin-top: 6px;
  }

  .lettres {
    gap: 6px;
  }

  .lettre {
    font-size: 1.2rem;
    aspect-ratio: auto;
    height: 40px;
  }

  .aide-lettres,
  .aide-clavier {
    display: none;
  }

  .aide-tactile {
    display: block;
  }

  .aide-tactile {
    font-size: 13px;
  }

  .touches {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .touches button {
    min-height: 48px;
    border: 1px solid rgba(234, 251, 234, .2);
    border-radius: 12px;
    background: rgba(234, 251, 234, .07);
    color: var(--texte);
    font-family: var(--police-texte);
    font-size: 18px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
  }

  .touches button:active {
    background: rgba(234, 251, 234, .18);
  }

  .touches [data-action="lacher"] {
    grid-column: span 2;
  }

  .mauzitel {
    font-size: 18px;
  }
}

/* Mouvements réduits : fondu simple à la place des animations */
@media (prefers-reduced-motion: reduce) {
  .lettre.on,
  .lettres.complet .lettre,
  #mauzitel.flash,
  #progression,
  .mauzitel a.carte,
  .pilule {
    animation: none;
    transition: none;
  }

  .pop {
    animation: fondu 1.4s ease-out forwards;
  }
}

/* Animations */
@keyframes monter {
  0% {
    opacity: 0;
    transform: translateY(0) scale(.9);
  }
  15% {
    opacity: 1;
    transform: translateY(-8px) scale(1.05);
  }
  75% {
    opacity: 1;
    transform: translateY(-22px);
  }
  100% {
    opacity: 0;
    transform: translateY(-30px);
  }
}

@keyframes fondu {
  0% {
    opacity: 0;
  }
  20%,
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes pop-lettre {
  0% {
    transform: scale(.6);
  }
  60% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes brille {
  from {
    filter: brightness(1);
    box-shadow: 0 0 0 transparent;
  }
  to {
    filter: brightness(1.6);
    box-shadow: 0 0 14px var(--mau);
  }
}

@keyframes clignote-z {
  0%,
  100% {
    border-color: var(--cyan);
    box-shadow: none;
  }
  25%,
  75% {
    border-color: var(--z);
    box-shadow: 0 0 18px hsl(45 88% 62% / .5);
  }
}

/* Responsive : grand écran, réglages de la grille desktop */
@media (min-width: 901px) {
  .app {
    grid-template-columns: 190px auto 270px;
  }
}
