/* Ciboulot, prototype : une bibliothèque de jeux du jour.
   Fond neutre, une couleur par jeu (jaune, bleu, rouge), Bricolage Grotesque partout. */

:root {
  --fond: #F2F2EF;
  --surface: #FFFFFF;
  --encre: #16171B;
  --encre-2: #4A4E5A;
  --discret: #6B6F7B;
  --bord: #D9DAD4;
  --bord-fort: #16171B;
  --jaune: #FFC83D;
  --jaune-texte: #1B1A17;
  --bleu: #2455E6;
  --bleu-texte: #FFFFFF;
  --rouge: #D9372E;
  --rouge-texte: #FFFFFF;
  --vert: #1E8A55;
  --alerte: #C0392B;
  --accent: #16171B;
  --accent-texte: #FFFFFF;
  --ombre: 0 1px 0 rgba(22, 23, 27, .06), 0 6px 18px rgba(22, 23, 27, .08);
  --rayon: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #111214;
    --surface: #1B1D21;
    --encre: #EDEEF0;
    --encre-2: #C3C7CF;
    --discret: #9AA0AB;
    --bord: #2C2F35;
    --bord-fort: #EDEEF0;
    --jaune: #FFCF55;
    --jaune-texte: #1B1A17;
    --bleu: #5B83FF;
    --bleu-texte: #0E1220;
    --rouge: #F0605A;
    --rouge-texte: #1A0B0A;
    --vert: #4CC08A;
    --alerte: #FF8A7E;
    --accent: #EDEEF0;
    --accent-texte: #111214;
    --ombre: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --fond: #111214;
  --surface: #1B1D21;
  --encre: #EDEEF0;
  --encre-2: #C3C7CF;
  --discret: #9AA0AB;
  --bord: #2C2F35;
  --bord-fort: #EDEEF0;
  --jaune: #FFCF55;
  --jaune-texte: #1B1A17;
  --bleu: #5B83FF;
  --bleu-texte: #0E1220;
  --rouge: #F0605A;
  --rouge-texte: #1A0B0A;
  --vert: #4CC08A;
  --alerte: #FF8A7E;
  --accent: #EDEEF0;
  --accent-texte: #111214;
  --ombre: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* chaque jeu apporte sa couleur */
[data-jeu="le-plus-long"] { --accent: var(--jaune); --accent-texte: var(--jaune-texte); }
[data-jeu="le-compte"] { --accent: var(--bleu); --accent-texte: var(--bleu-texte); }
[data-jeu="la-commune"] { --accent: var(--rouge); --accent-texte: var(--rouge-texte); }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font-family: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--bleu); outline-offset: 2px; border-radius: 6px; }

.app {
  max-width: 760px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 0 48px;
}

/* ------------------------------------------------------------ en-tête */

.entete {
  padding-block: 18px 16px;
  margin-inline: -16px;
  padding-inline: 16px;
  margin-bottom: 20px;
}
.app[data-jeu] .entete {
  background: var(--accent);
  color: var(--accent-texte);
  border-radius: 0 0 var(--rayon) var(--rayon);
}
.entete-haut { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.marque {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1;
}
.marque i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.marque i:nth-child(1) { background: var(--jaune); }
.marque i:nth-child(2) { background: var(--bleu); }
.marque i:nth-child(3) { background: var(--rouge); }
.marque .points-marque { display: inline-flex; gap: 4px; }
.retour {
  font-weight: 700; text-decoration: none; font-size: 16px;
  padding: 8px 0; min-height: 44px; display: inline-flex; align-items: center;
}
.retour:hover { text-decoration: underline; }
.numero { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; opacity: .8; }
.date { margin: 6px 0 0; font-size: 15px; font-weight: 500; opacity: .85; }

/* ------------------------------------------------------------ accueil */

.titre-programme { font-size: 30px; line-height: 1.1; letter-spacing: -.02em; margin: 6px 0 16px; font-weight: 800; }
.programme { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }

.carte-jeu {
  position: relative; display: grid; grid-template-rows: auto 1fr auto; gap: 6px;
  min-height: 172px; padding: 18px 18px 16px; border-radius: var(--rayon);
  background: var(--accent); color: var(--accent-texte); text-decoration: none;
  box-shadow: var(--ombre); overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
}
.carte-jeu:active { transform: scale(.985); }
.carte-visuel { display: flex; align-items: center; gap: 6px; min-height: 52px; }
.carte-textes { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.carte-nom { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.carte-resume { display: block; font-size: 15.5px; line-height: 1.35; opacity: .92; max-width: 30ch; }
.carte-bas { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.carte-statut {
  font-size: 14px; font-weight: 700; padding: 6px 12px; border-radius: 999px;
  background: var(--accent-texte); color: var(--accent);
}
.carte-statut.fait { background: transparent; color: var(--accent-texte); box-shadow: inset 0 0 0 2px currentColor; }
.carte-jouer { font-weight: 700; font-size: 15px; }

/* petites couvertures, faites avec les pièces de chaque jeu */
.visuel-lettres i {
  width: 34px; height: 38px; display: grid; place-items: center; font-style: normal;
  background: #FFFFFF; color: #16171B; border: 2px solid #16171B; border-radius: 7px;
  font-weight: 800; font-size: 20px; box-shadow: 0 2px 0 #16171B;
}
.visuel-lettres i:nth-child(2) { transform: translateY(-4px) rotate(-4deg); }
.visuel-lettres i:nth-child(3) { transform: rotate(3deg); }
.visuel-lettres i:nth-child(4) { transform: translateY(-3px) rotate(-2deg); }
.visuel-plaques i, .visuel-plaques b {
  height: 38px; min-width: 38px; padding: 0 8px; display: grid; place-items: center; font-style: normal;
  border-radius: 8px; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums;
}
.visuel-plaques i { background: rgba(255, 255, 255, .95); color: #16171B; }
.visuel-plaques i.op { background: transparent; color: inherit; min-width: 0; padding: 0 2px; font-size: 22px; }
.visuel-plaques b { background: transparent; color: inherit; box-shadow: inset 0 0 0 2px currentColor; }
.visuel-boussole { display: flex; align-items: center; gap: 10px; }
.visuel-boussole .rond {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .95); color: #16171B;
}
.visuel-boussole svg { width: 26px; height: 26px; transform: rotate(38deg); fill: currentColor; }
.visuel-boussole span { font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }

.journee, .serie {
  margin-top: 22px; padding: 18px; border-radius: var(--rayon);
  background: var(--surface); box-shadow: var(--ombre);
}
.journee h2 { margin: 0 0 8px; font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.journee-lignes { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 4px; font-variant-numeric: tabular-nums; }
.serie { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; font-weight: 500; color: var(--encre-2); }
.serie .points { display: inline-flex; gap: 6px; }
.serie .points i { width: 18px; height: 18px; border-radius: 5px; background: var(--bord); display: inline-block; }
.serie .points i.on:nth-child(3n + 1) { background: var(--jaune); }
.serie .points i.on:nth-child(3n + 2) { background: var(--bleu); }
.serie .points i.on:nth-child(3n) { background: var(--rouge); }

.pied { margin-top: 32px; font-size: 14px; color: var(--discret); display: grid; gap: 4px; }
.pied p { margin: 0; }
.credits { font-size: 12.5px; margin-top: 8px !important; }

/* ------------------------------------------------------------ commun aux jeux */

.zone-jeu { display: flex; flex-direction: column; gap: 14px; }
.zone-jeu > * { flex-shrink: 0; }
.titre-jeu { font-size: 28px; line-height: 1.1; letter-spacing: -.02em; margin: 0; font-weight: 800; }
.barre-jeu { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chrono {
  font-weight: 800; font-size: 24px; font-variant-numeric: tabular-nums;
  padding: 4px 12px; border-radius: 10px; background: var(--surface); box-shadow: var(--ombre);
  min-width: 78px; text-align: center;
}
.chrono.urgent { color: var(--alerte); }
.regles { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; color: var(--encre-2); }
.consigne { margin: 0; color: var(--encre-2); }

.bouton, .bouton-2 {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 12px; font-weight: 700; font-size: 16px;
  text-decoration: none; border: 0; transition: transform .08s ease;
}
.bouton { background: var(--accent); color: var(--accent-texte); box-shadow: 0 3px 0 rgba(0, 0, 0, .25); }
.bouton:active, .bouton-2:active { transform: translateY(2px); }
.bouton-2 { background: var(--surface); color: var(--encre); box-shadow: inset 0 0 0 2px var(--bord-fort); }
.bouton:disabled, .bouton-2:disabled, .operateur:disabled { opacity: .45; cursor: default; transform: none; }
.lien-fin, .lien-retour {
  align-self: center; background: none; border: 0; padding: 10px; min-height: 44px;
  color: var(--encre-2); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .bouton { flex: 1 1 auto; }
.actions-fin { display: flex; flex-direction: column; gap: 10px; }
.message { margin: 0; min-height: 1.5em; font-weight: 600; color: var(--encre-2); }
.erreur { margin: 0; padding: 14px 16px; border-radius: 12px; background: var(--surface); color: var(--alerte); font-weight: 600; }
.chargement { margin: 0; color: var(--discret); }
.discret { color: var(--discret); font-weight: 400; }
.visuellement-cache {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.bilan { padding: 22px 18px; border-radius: var(--rayon); background: var(--accent); color: var(--accent-texte); }
.bilan-chiffre { margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.bilan-detail { margin: 8px 0 0; font-size: 16.5px; }
.solution { padding: 18px; border-radius: var(--rayon); background: var(--surface); box-shadow: var(--ombre); }
.solution h2 { margin: 0 0 8px; font-size: 18px; font-weight: 800; }
.solution p { margin: 0 0 6px; }

/* ------------------------------------------------------------ tuiles */

.tuile {
  display: grid; place-items: center; aspect-ratio: 1 / 1.08; min-width: 0;
  background: var(--surface); color: var(--encre);
  border: 2px solid var(--bord-fort); border-radius: 9px; box-shadow: 0 3px 0 var(--bord-fort);
  font-weight: 800; font-size: clamp(20px, 6vw, 28px); line-height: 1; padding: 0;
  transition: transform .08s ease, opacity .12s ease;
}
.tuile:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--bord-fort); }
.tuile.utilisee { opacity: .25; box-shadow: none; transform: translateY(3px); }

/* Le plus long */
.tirage { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; }
.compo {
  display: flex; flex-wrap: wrap; gap: 6px; min-height: 64px; align-items: center;
  padding: 10px; border-radius: 12px; background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--bord);
}
.compo-vide { color: var(--discret); font-size: 15.5px; padding-left: 4px; }
.tuile-mot { width: 44px; background: var(--accent); color: var(--accent-texte); font-size: 22px; }
.trouves { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.trouves li {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px;
  border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--bord); font-weight: 600;
}
.trouves li.record { box-shadow: inset 0 0 0 2px var(--encre); }
.trouves .longueur {
  min-width: 26px; height: 26px; display: grid; place-items: center; border-radius: 999px;
  background: var(--accent); color: var(--accent-texte); font-size: 13px; font-weight: 800;
}

/* Le compte */
.cible {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-radius: var(--rayon); background: var(--accent); color: var(--accent-texte);
}
.cible-etiquette { font-weight: 700; font-size: 15px; text-transform: uppercase; letter-spacing: .08em; }
.cible-nombre { font-size: 56px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.plaques { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.plaque { aspect-ratio: auto; min-height: 60px; font-size: clamp(22px, 6.5vw, 30px); font-variant-numeric: tabular-nums; }
.plaque.calculee { border-style: dashed; }
.plaque.choisie { background: var(--accent); color: var(--accent-texte); }
.operateurs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.operateur {
  min-height: 52px; border-radius: 12px; border: 0; font-size: 28px; font-weight: 800; line-height: 1;
  background: var(--surface); color: var(--encre); box-shadow: inset 0 0 0 2px var(--bord-fort);
}
.operateur.choisie { background: var(--accent); color: var(--accent-texte); box-shadow: none; }
.etapes { margin: 0; padding-left: 1.4em; display: grid; gap: 2px; font-weight: 600; font-variant-numeric: tabular-nums; }
.etapes:empty { display: none; }
.plus-pres { margin: 0; color: var(--encre-2); font-weight: 600; min-height: 1.5em; }

/* La commune */
.indices { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.indices li {
  display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface); box-shadow: var(--ombre); font-weight: 600;
}
.indices li b { font-weight: 800; }
.indices li.cache { box-shadow: inset 0 0 0 1.5px var(--bord); background: transparent; color: var(--discret); font-weight: 500; }
.formulaire { display: flex; gap: 10px; align-items: flex-start; }
.champ-conteneur { position: relative; flex: 1 1 auto; min-width: 0; }
.champ {
  width: 100%; min-height: 50px; padding: 0 14px; border-radius: 12px; font-size: 17px;
  background: var(--surface); border: 2px solid var(--bord-fort); outline: none;
}
.champ:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.suggestions {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 5;
  list-style: none; margin: 0; padding: 6px; border-radius: 12px;
  background: var(--surface); box-shadow: var(--ombre), inset 0 0 0 1.5px var(--bord);
}
.suggestions:empty { display: none; }
.suggestions li { padding: 10px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.suggestions li.active, .suggestions li:hover { background: var(--accent); color: var(--accent-texte); }
.suggestions li.active .discret, .suggestions li:hover .discret { color: inherit; opacity: .8; }
.reste { margin: 0; font-weight: 700; color: var(--encre-2); }
.essais { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.essai {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 12px 14px; border-radius: 12px; background: var(--surface); box-shadow: var(--ombre);
}
.essai.trouve { background: var(--vert); color: #FFFFFF; }
.essai-nom { font-weight: 700; overflow-wrap: anywhere; }
.essai-info { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-variant-numeric: tabular-nums; }
.essai-direction { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-texte); }
.fleche { width: 20px; height: 20px; fill: currentColor; }
.essai-proximite { width: 54px; height: 8px; border-radius: 99px; background: var(--bord); overflow: hidden; display: inline-block; }
.essai-proximite i { display: block; height: 100%; background: var(--encre); border-radius: 99px; }
.essai-pop { grid-column: 1 / -1; font-size: 14.5px; color: var(--discret); font-weight: 500; }

/* ------------------------------------------------------------ animations */

.tampon { animation: tampon .18s ease-out; }
@keyframes tampon {
  0% { transform: scale(1.16); }
  60% { transform: scale(.95); }
  100% { transform: scale(1); }
}
.secoue { animation: secoue .32s ease-in-out; }
@keyframes secoue {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  .tampon, .secoue { animation: none; }
  .carte-jeu, .tuile, .bouton, .bouton-2 { transition: none; }
}

/* ------------------------------------------------------------ écrans larges (en fin de feuille) */

@media (hover: hover) {
  .carte-jeu:hover { transform: translateY(-3px); box-shadow: var(--ombre), 0 14px 30px rgba(22, 23, 27, .12); }
}

@media (min-width: 720px) {
  .app { padding-inline: 24px; }
  .entete { margin-inline: -24px; padding-inline: 24px; }
  .programme { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .carte-jeu { min-height: 250px; }
  .zone-jeu { max-width: 560px; margin: 0 auto; }
  .actions-fin { flex-direction: row; flex-wrap: wrap; align-items: center; }
}

@media (max-width: 380px) {
  .tirage { gap: 4px; }
  .tuile { border-radius: 7px; }
  .cible-nombre { font-size: 46px; }
}
