/* Jeu du serpent : styles propres à l'outil. Couleurs tirées des variables du site (thèmes clair et sombre). */
.o-serpent { min-width: 0; }
.o-serpent [hidden] { display: none !important; }

/* Couleurs lues par le script pour dessiner le plateau */
.o-serpent-couleurs { display: none; }
.o-serpent-c-plateau { color: var(--surface); }
.o-serpent-c-damier { color: color-mix(in srgb, var(--texte) 4%, var(--surface)); }
.o-serpent-c-obstacle { color: color-mix(in srgb, var(--texte) 52%, var(--surface)); }
.o-serpent-c-corps { color: color-mix(in srgb, var(--ok-texte) 78%, var(--marque)); }
.o-serpent-c-ecaille { color: color-mix(in srgb, var(--ok-texte) 55%, var(--surface)); }
.o-serpent-c-ecaille2 { color: color-mix(in srgb, var(--ok-texte) 70%, var(--surface)); }
.o-serpent-c-tete { color: var(--ok-texte); }
.o-serpent-c-oeil { color: #fff; }
.o-serpent-c-pupille { color: #141a2a; }

.o-serpent .o-serpent-reglages { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); max-width: 640px; margin: 0 auto; border-top: 0; padding-top: 0; }
.o-serpent-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; margin: 10px 0 4px; }
.o-serpent-options label.case { display: flex; align-items: center; gap: 8px; font-size: .95rem; color: var(--texte); }
.o-serpent-options input { width: 20px; height: 20px; flex: none; accent-color: var(--marque); }
.o-serpent select:disabled { opacity: .5; }

.o-serpent-barre { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 18px; margin: 12px 0; }
.o-serpent-barre p { display: flex; flex-direction: column; align-items: center; margin: 0; color: var(--texte-2); font-size: .8rem; line-height: 1.2; }
.o-serpent-barre strong { color: var(--texte); font: 700 1.3rem/1.1 var(--mono); font-variant-numeric: tabular-nums; }
.atelier .o-serpent-barre .btn { min-height: 42px; }

.o-serpent-cadre { position: relative; width: 100%; max-width: 520px; margin: 0 auto; padding: 8px; border-radius: var(--rayon); background: var(--surface-2); border: 1px solid var(--bord); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.o-serpent-plateau { display: block; width: 100%; aspect-ratio: 1; border-radius: var(--rayon-petit); outline: none; }
.o-serpent-plateau:focus-visible { box-shadow: 0 0 0 3px var(--marque); }
.o-serpent-voile {
  position: absolute; inset: 8px; display: grid; place-items: center; padding: 12px; border-radius: var(--rayon-petit);
  background: color-mix(in srgb, var(--surface) 30%, transparent);
}
.o-serpent-carte {
  display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 100%; padding: 16px 20px; text-align: center; color: var(--texte);
  border: 1px solid var(--bord); border-radius: var(--rayon); background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--texte) 14%, transparent);
}
.o-serpent-voile p { margin: 0; max-width: 34ch; line-height: 1.45; }
.o-serpent-voile .o-serpent-voile-titre { font-size: 1.35rem; font-weight: 800; }
.atelier .o-serpent-voile .btn { min-height: 46px; min-width: 140px; font-weight: 700; }
.o-serpent.fini .o-serpent-cadre { border-color: var(--erreur-texte); }
.o-serpent.gagne .o-serpent-cadre { border-color: var(--ok-texte); box-shadow: 0 0 0 2px var(--ok-texte); }

/* Croix directionnelle */
.o-serpent-croix { display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); grid-template-areas: ". h ." "g . d" ". b ."; gap: 4px; justify-content: center; margin: 12px auto 0; }
.atelier .o-serpent-croix .btn { display: grid; place-items: center; width: 52px; height: 52px; min-height: 0; padding: 0; border-radius: 14px; touch-action: manipulation; }
.o-serpent-croix svg { width: 24px; height: 24px; }
.o-serpent-croix .o-serpent-haut { grid-area: h; }
.o-serpent-croix .o-serpent-gauche { grid-area: g; }
.o-serpent-croix .o-serpent-droite { grid-area: d; }
.o-serpent-croix .o-serpent-bas { grid-area: b; }
@media (hover: hover) and (pointer: fine) {
  .o-serpent-croix { grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(3, 40px); }
  .atelier .o-serpent-croix .btn { width: 40px; height: 40px; border-radius: 10px; }
  .o-serpent-croix svg { width: 18px; height: 18px; }
}

.o-serpent-message { display: block; min-height: 1.5em; margin-top: 10px; text-align: center; font-size: .98rem; line-height: 1.45; color: var(--texte); }
.o-serpent.fini .o-serpent-message:not(:empty) { padding: 8px 10px; border-radius: var(--rayon-petit); background: var(--erreur-fond); color: var(--erreur-texte); font-weight: 600; }
.o-serpent.gagne .o-serpent-message:not(:empty) { background: var(--ok-fond); color: var(--ok-texte); }
.o-serpent .o-serpent-aide { margin: 14px 0 0; color: var(--texte-2); font-size: .92rem; line-height: 1.5; text-align: center; }
.atelier .o-serpent-aide .btn { margin-left: 6px; padding: 4px 12px; font-size: .9rem; }
.o-serpent .btn:focus-visible, .o-serpent select:focus-visible, .o-serpent input:focus-visible { outline: 3px solid var(--marque); outline-offset: 2px; }
.o-serpent .btn:disabled { opacity: .45; cursor: default; }

@media (max-width: 560px) {
  .o-serpent-cadre { padding: 4px; }
  .o-serpent-voile { inset: 4px; padding: 8px; }
  .o-serpent-carte { padding: 12px 14px; gap: 8px; }
  .o-serpent .o-serpent-reglages { grid-template-columns: 1fr 1fr; }
  .o-serpent .o-serpent-reglages label:last-child { grid-column: 1 / -1; }
  .o-serpent-barre { gap: 8px 12px; }
}
