/* =========================================================================
   defi.css — le défi du jour.
   Volontairement sobre : la page a un seul travail, mettre le décor sous
   les yeux du visiteur. Tout ce qui distrait de l'image lui nuit.
   ========================================================================= */

.defi-page { max-width: 1040px; margin: 0 auto; padding: 18px 16px 56px; }

.defi-head { text-align: center; margin-bottom: 14px; }
.defi-head h1 { font-size: clamp(24px, 4.2vw, 38px); margin: 0 0 6px; }
.defi-sous { margin: 0; color: var(--muted, #6b6880); font-weight: 700; display: flex;
  gap: 10px; justify-content: center; flex-wrap: wrap; align-items: center; }
.defi-date { background: rgba(124, 92, 255, 0.12); color: #5b3fd6; padding: 3px 10px; border-radius: 999px; }

.defi-barre { display: flex; gap: 10px; justify-content: center; margin: 0 0 10px; flex-wrap: wrap; }
.defi-pill { background: #fff; border: 2px solid rgba(20, 16, 40, 0.08); border-radius: 999px;
  padding: 7px 14px; font-weight: 800; box-shadow: 0 2px 0 rgba(20, 16, 40, 0.06); }

/* Le décor : plein cadre, ratio préservé, curseur en viseur. */
.defi-zone { position: relative; border-radius: 18px; overflow: hidden;
  border: 3px solid rgba(20, 16, 40, 0.10); box-shadow: 0 10px 30px rgba(20, 16, 40, 0.16);
  background: #20242c; aspect-ratio: 3 / 2; }
.defi-zone canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }
.defi-zone.fini canvas { cursor: default; }
/* Tant que l'image n'est pas là, on ne montre pas un canvas vide qui donne
   l'impression d'une page cassée. */
.defi-zone:not(.pret)::after { content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, #262b35 30%, #333949 50%, #262b35 70%);
  background-size: 220% 100%; animation: defiCharge 1.2s linear infinite; }
@keyframes defiCharge { from { background-position: 140% 0; } to { background-position: -40% 0; } }

.defi-res { text-align: center; font-weight: 800; min-height: 26px; margin: 12px 0 4px; font-size: 17px; }
.defi-res.ok { color: #1a9c6e; }
.defi-res.ko { color: #c8446a; }

.defi-fin { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
/* `display:flex` l'emporte sur l'attribut hidden : sans cette ligne, les
   boutons de fin s'affichent avant même qu'on ait cliqué. */
.defi-fin[hidden], .defi-vide[hidden], #defiJeu[hidden] { display: none; }

.defi-vide { text-align: center; padding: 40px 16px; }
.defi-vide p { font-weight: 700; margin-bottom: 16px; }

.defi-quoi { margin-top: 46px; text-align: center; background: #fff; border-radius: 20px;
  padding: 26px 22px; border: 2px solid rgba(20, 16, 40, 0.07); }
.defi-quoi h2 { margin: 0 0 10px; font-size: clamp(19px, 3vw, 25px); }
.defi-quoi p { margin: 0 auto 16px; max-width: 620px; line-height: 1.6; }

@media (max-width: 640px) {
  .defi-page { padding: 12px 10px 40px; }
  .defi-zone { border-width: 2px; border-radius: 14px; }
  .defi-fin .candy { width: 100%; }
}
