/* Grillorama — page de jeu (grillorama.fr, ou en local). Valeurs de la charte : ../charte/tokens.css */

* { box-sizing: border-box; }
/* Pas d'agrandissement automatique du texte (iOS en paysage) : il ferait déborder les définitions des cases. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--gr-fond);
  color: var(--gr-texte);
  font: 400 16px/1.55 var(--gr-police-texte);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--gr-police-titre); line-height: 1.15; margin: 0; }
h1 { font-size: clamp(28px, 4.5vw, 40px); font-weight: 700; }
h2 { font-size: 26px; font-weight: 700; }
h3 { font-size: 20px; font-weight: 600; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 40px; }

/* Barre */
.barre { background: var(--gr-violet); color: var(--gr-ivoire); }
.barre .wrap { height: 56px; display: flex; align-items: center; }
.marque { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none;
  font: 600 22px var(--gr-police-titre); }

/* Boutons, pastilles, messages (composants de la charte) */
.btn {
  font: 600 16px var(--gr-police-titre); color: var(--gr-violet);
  padding: 10px 18px; border-radius: var(--gr-rayon-bouton);
  border: var(--gr-trait-fort) solid var(--gr-violet); background: var(--gr-ivoire);
  box-shadow: var(--gr-ombre); cursor: pointer; transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--gr-violet); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--gr-violet); }
.btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: var(--gr-ombre); }
.btn.primaire { background: var(--gr-orange); }
.btn.primaire:hover { background: var(--gr-orange-fonce); }
.btn.discret { border-color: transparent; box-shadow: none; background: transparent;
  text-decoration: underline; text-underline-offset: 4px; padding-left: 8px; padding-right: 8px; }
.btn.discret:active { transform: none; }

.pastilles { display: flex; gap: 8px; flex-wrap: wrap; }
.pastille { font-weight: 800; font-size: 13px; line-height: 1.3; padding: 4px 12px; border-radius: 999px;
  border: var(--gr-trait) solid var(--gr-violet); background: var(--gr-ivoire); white-space: nowrap; }
.pastille.lavande { background: var(--gr-lavande); }
.pastille.vert { background: var(--gr-vert); color: var(--gr-ivoire); border-color: var(--gr-vert); }
.pastille.orange { background: var(--gr-orange); }

.message { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--gr-rayon-carte);
  font-weight: 700; }
.message.reussite { background: var(--gr-vert); color: var(--gr-ivoire); }
.message.info { background: var(--gr-lavande); }

/* Écran liste */
.intro { color: var(--gr-texte-doux); font-size: 17px; margin: 8px 0 20px; }
.filtre {
  width: 100%; max-width: 360px; margin-bottom: 24px; padding: 10px 14px;
  font: 600 16px var(--gr-police-texte); color: var(--gr-texte);
  background: #fff; border: var(--gr-trait) solid var(--gr-violet); border-radius: var(--gr-rayon-bouton);
}
.filtre:focus { outline: 3px solid var(--gr-orange); outline-offset: 2px; }
.filtres { display: flex; flex-direction: column; gap: 10px; margin: -12px 0 24px; }
.filtre-groupe { display: flex; flex-wrap: wrap; gap: 8px; }
.choix {
  font: 700 14px/1.3 var(--gr-police-texte); color: var(--gr-texte); cursor: pointer;
  padding: 6px 14px; border-radius: 999px; border: var(--gr-trait) solid var(--gr-violet); background: var(--gr-ivoire);
}
.choix:hover { background: var(--gr-orange-clair); }
.choix.actif { background: var(--gr-violet); color: var(--gr-ivoire); }
.choix:focus-visible { outline: 3px solid var(--gr-orange); outline-offset: 2px; }
.cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.carte-grille {
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px 20px; background: #fff;
  border: var(--gr-trait) solid var(--gr-violet); border-radius: var(--gr-rayon-carte); box-shadow: var(--gr-ombre);
}
.carte-grille .date { font-size: 14px; color: var(--gr-texte-doux); margin-top: -6px; }
.lien-jeu {
  display: flex; flex-direction: column; gap: 6px; padding: 10px 12px;
  color: var(--gr-texte); text-decoration: none; background: var(--gr-ivoire);
  border: var(--gr-trait) solid var(--gr-violet); border-radius: var(--gr-rayon-bouton);
  transition: transform .08s, box-shadow .08s;
}
.lien-jeu:hover { background: var(--gr-orange-clair); transform: translateY(-1px); box-shadow: 0 3px 0 var(--gr-violet); }
.lien-jeu:focus-visible { outline: 3px solid var(--gr-orange); outline-offset: 2px; }
.lien-jeu .type-jeu { font: 600 17px var(--gr-police-titre); }
.lien-jeu .pastille { font-size: 12px; padding: 2px 10px; }
.vide { padding: 24px; border-radius: var(--gr-rayon-carte); background: var(--gr-lavande-clair); }
.vide code { font-size: 14px; }

/* Écran de jeu */
.jeu { display: grid; grid-template-columns: max-content minmax(260px, 340px); gap: 28px;
  justify-content: center; align-items: start; }
.plateau { position: relative; }
.panneau { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }
.retour { color: var(--gr-texte-doux); font-weight: 700; font-size: 15px; text-decoration: none; }
.retour:hover { color: var(--gr-texte); text-decoration: underline; text-underline-offset: 3px; }
.surtitre { font-weight: 800; font-size: 13px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--gr-texte-doux); margin-bottom: 2px; }

.compteurs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compteur { background: #fff; border: var(--gr-trait) solid var(--gr-violet); border-radius: var(--gr-rayon-carte);
  padding: 10px 14px; display: flex; flex-direction: column; }
.compteur .libelle { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: var(--gr-texte-doux); }
.compteur .valeur { font: 700 30px/1.2 var(--gr-police-grille); font-variant-numeric: tabular-nums; }
.compteur.fini { background: var(--gr-vert); border-color: var(--gr-vert); color: var(--gr-ivoire); }
.compteur.fini .libelle { color: var(--gr-ivoire); }

.definition { background: var(--gr-lavande); border-radius: var(--gr-rayon-carte); padding: 14px 18px; min-height: 104px; }
.definition-sens { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-height: 20px; }
.definition-sens .pastille { font-size: 11px; padding: 1px 8px; text-transform: none; letter-spacing: 0; }
.definition-texte { font: 600 21px/1.3 var(--gr-police-titre); margin-top: 6px; }

/* Liste des mots (mots mêlés) */
.bloc-mots { background: var(--gr-lavande-clair); border-radius: var(--gr-rayon-carte); padding: 14px 16px; }
.bloc-mots-titre { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  display: flex; justify-content: space-between; margin-bottom: 10px; }
.liste-mots { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.liste-mots .mot {
  font: 700 14px/1.2 var(--gr-police-grille); letter-spacing: .04em; color: var(--gr-texte);
  padding: 5px 10px; border-radius: 999px; border: var(--gr-trait) solid var(--gr-violet);
  background: var(--gr-ivoire); cursor: pointer;
}
.liste-mots .mot:hover:not(:disabled) { background: var(--gr-orange-clair); }
.liste-mots .mot.cible { background: var(--gr-orange); }
.liste-mots .mot.trouve { background: var(--gr-vert); border-color: var(--gr-vert); color: var(--gr-ivoire);
  text-decoration: line-through; text-decoration-thickness: 2px; cursor: default; }
.liste-mots .mot.revele { background: var(--gr-lavande); border-style: dashed; cursor: default; }
.liste-mots .mot:disabled { opacity: 1; }

/* Mot mystère (mots fléchés) : une case par lettre, numérotée comme dans la grille */
.bloc-mystere { background: var(--gr-orange-clair); border-radius: var(--gr-rayon-carte); padding: 14px 16px; }
.bloc-mystere .pastille { font-size: 11px; padding: 1px 8px; text-transform: none; letter-spacing: 0; }
.mystere-cases { display: flex; flex-wrap: wrap; gap: 6px; }
.case-mystere {
  position: relative; width: 36px; height: 36px; padding: 0; cursor: pointer;
  font: 700 20px/1 var(--gr-police-grille); color: var(--gr-texte);
  background: var(--gr-ivoire); border: var(--gr-trait) solid var(--gr-violet); border-radius: 8px;
}
.case-mystere::before {
  content: attr(data-num); position: absolute; top: 1px; left: 3px;
  font: 800 10px/1 var(--gr-police-texte); color: var(--gr-orange-fonce);
}
.case-mystere:hover { background: var(--gr-lavande-clair); }
.case-mystere.sel { background: var(--gr-orange); }
.case-mystere.trouve { background: var(--gr-vert); border-color: var(--gr-vert); color: var(--gr-ivoire); }
.case-mystere.trouve::before { color: var(--gr-ivoire); }
.mystere-enigme { font: 600 18px/1.3 var(--gr-police-titre); margin-bottom: 10px; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.aide { font-size: 14px; color: var(--gr-texte-doux); margin: 0; }

/* Grille */
.grille {
  --c: 44px; --gap: 4px; --pad: 10px;
  display: grid; grid-template-columns: repeat(var(--cols), var(--c)); grid-auto-rows: var(--c);
  gap: var(--gap); padding: var(--pad); width: max-content;
  background: var(--gr-violet); border-radius: min(var(--gr-rayon-plaque), calc(var(--c) * .6));
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.case {
  position: relative; border-radius: calc(var(--c) * .18); background: var(--gr-ivoire);
  display: grid; place-items: center; overflow: hidden;
}
.case.lettre { cursor: pointer; font: 700 calc(var(--c) * .56)/1 var(--gr-police-grille); }
.case.lettre.actif { background: var(--gr-orange-clair); }
.case.lettre.sel { background: var(--gr-orange); }
.case.lettre.revele { color: var(--gr-violet-80); }
.case.lettre.revele::after {
  content: ""; position: absolute; top: calc(var(--c) * .08); right: calc(var(--c) * .08);
  width: calc(var(--c) * .13); height: calc(var(--c) * .13); border-radius: 50%; background: var(--gr-orange);
}
.case.lettre.sel.revele::after { background: var(--gr-violet); }
.case.lettre[data-num]::before {
  /* numéro d'une lettre du mot mystère (en haut à gauche ; le point des lettres révélées est à droite) */
  content: attr(data-num); position: absolute; top: calc(var(--c) * .05); left: calc(var(--c) * .08);
  font: 800 calc(var(--c) * .2)/1 var(--gr-police-texte); color: var(--gr-orange-fonce);
}
.case.lettre.sel[data-num]::before { color: var(--gr-violet); }
.case.lettre.trouve[data-num]::before { color: var(--gr-ivoire); }
.case.lettre.trouve { background: var(--gr-vert); color: var(--gr-ivoire); cursor: default; }
.case.lettre.trouve::after { display: none; }

.case.def { background: var(--gr-lavande); display: flex; flex-direction: column; place-items: stretch; }
.case.noire { background: var(--gr-violet-80); }
.def-txt {
  flex: 1 1 0; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: 1px 2px; text-align: center; cursor: pointer;
  font-weight: 800; line-height: 1.05; text-transform: uppercase; letter-spacing: .01em;
  overflow: hidden; overflow-wrap: normal; word-break: normal; hyphens: none;
}
.def-txt span { display: block; max-width: 100%; }
.def-txt.coupe { overflow-wrap: anywhere; }
/* « ~ » et non « + » : la flèche de la première définition est insérée entre les deux textes. */
.def-txt ~ .def-txt { border-top: max(1px, calc(var(--c) * .025)) solid var(--gr-violet); }
.def-txt.vers-droite { padding-right: calc(var(--c) * .16); }
.def-txt.vers-bas { padding-bottom: calc(var(--c) * .15); }
.def-txt.lie-theme {
  /* liseré des définitions liées au thème (pastille orange dans les SVG) */
  box-shadow: inset max(2px, calc(var(--c) * .05)) 0 0 var(--gr-orange);
  padding-left: calc(2px + max(2px, calc(var(--c) * .05)));
}
.def-txt.actif { background: var(--gr-orange-clair); }
.def-txt:hover { background: var(--gr-lavande-clair); }
.def-txt.actif:hover { background: var(--gr-orange-clair); }
.fleche {
  position: absolute; width: calc(var(--c) * .15); height: calc(var(--c) * .15); pointer-events: none;
  fill: none; stroke: var(--gr-violet); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

/* Grille de mots mêlés (SVG, unité = une case) */
.grille.meles { display: block; padding: 0; background: none; width: auto; touch-action: none; }
.grille.meles svg { display: block; height: auto; cursor: pointer; }
.mm-fond { fill: var(--gr-violet); }
.mm-tuile { fill: var(--gr-ivoire); }
.mm-gelule { stroke-width: .8; stroke-linecap: round; }
.mm-gelule.trouve { stroke: var(--gr-vert); }
.mm-gelule.revele { stroke: var(--gr-lavande); }
.mm-gelule.sel { stroke: var(--gr-orange); }
.mm-lettre { font: 700 .56px var(--gr-police-grille); fill: var(--gr-violet); text-anchor: middle;
  dominant-baseline: central; pointer-events: none; }
.mm-lettre.sur-vert { fill: var(--gr-ivoire); }

.voile {
  position: absolute; inset: 0; border-radius: var(--gr-rayon-plaque); background: var(--gr-lavande);
  border: var(--gr-trait-fort) solid var(--gr-violet);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.voile p { font: 700 32px var(--gr-police-titre); margin: 0; }

.saisie-cachee { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0;
  font-size: 16px; pointer-events: none; }

@media (max-width: 899px) {
  .jeu { grid-template-columns: 1fr; gap: 18px; }
  .plateau { justify-self: center; }
  .panneau { position: static; order: -1; gap: 12px; }
  .definition { min-height: 0; }
  /* Mots mêlés : la grille juste sous le chronomètre, la liste des mots et les boutons en dessous. */
  .jeu.meles .panneau { display: contents; }
  .jeu.meles .plateau { order: 1; }
  .jeu.meles .bloc-mots, .jeu.meles .actions, .jeu.meles .message, .jeu.meles .aide { order: 2; }
  .definition-texte { font-size: 18px; }
  .aide { display: none; }
}
@media (max-width: 480px) {
  .compteur .valeur { font-size: 24px; }
  .btn { font-size: 15px; padding: 8px 14px; }
}
