/* ── Arrows : Puzzle Escape ──────────────────────────────────────
   Esthétique minimaliste façon "calm puzzle game" : crème, brun,
   accents corail. Tout est optimisé tactile (boutons ≥ 44px, pas de
   hover requis, pas de double-tap zoom).
*/

:root {
  /* Coche SVG partagée (mask-image), remplace les anciennes coches en
     `content:` texte ; la couleur vient du `background-color` de l'élément. */
  --icon-check-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m20 6-11 11-5-5' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  color-scheme: light;
  --bg: #f3ecdf;
  --bg-soft: #ece2cf;
  --ink: #4a2e1a;
  --ink-2: #7a5a40;
  /* Décor seulement : 2,2:1 sur le fond, donc JAMAIS un texte (mesuré). */
  --ink-3: #b89d7c;
  --dot: #d9c9a8;
  --accent: #c75b3a;
  --accent-2: #e08365;
  /* Le corail des aplats qui portent du texte blanc : #c75b3a ne donne que
     4,2:1 avec du blanc, celui-ci 5,2:1 (hover : 6,4:1). */
  --accent-deep: #b64b2b;
  --accent-deep-hover: #a24024;
  /* Bordure d'un champ de saisie : 3,3:1 sur le fond, le minimum d'un
     composant d'interface (--dot, à 1,5:1, ne se voyait pas). */
  --line: #9b7b5a;
  --good: #4a8a45;
  --bad: #c54338;
  /* Le rouge d'un message d'erreur : --bad ne tient que 4,2:1 sur le fond. */
  --bad-ink: #a93228;
  --card: #fbf6ec;
  --shadow: 0 6px 24px -10px rgba(74, 46, 26, 0.35);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

html, body, #app { height: 100%; }

#app {
  position: relative;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* Un anneau de focus visible partout (le clavier, un bouton physique, un
   lecteur d'écran qui pilote la page) : brun sur crème, 10:1. */
:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}
/* Un titre qu'on focalise pour annoncer un changement d'écran n'a pas à
   s'encadrer : ce n'est pas une commande. */
h1[tabindex="-1"]:focus { outline: none; }

/* Texte réservé aux lecteurs d'écran. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Écrans (single-page transitions) ─────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bot);
  animation: fadeIn .22s ease-out;
}
.screen.is-active { display: flex; }

/* Écran de départ : start.js (script bloquant du <head>) pose `data-start`
   avant la première peinture, game.js retire l'attribut au premier changement
   d'écran. Le HTML sert l'accueil comme écran actif ; sans ces deux règles, un
   joueur qui revient le verrait s'effacer devant le menu dès que game.js a
   chargé. Ici le bon écran est déjà là au premier rendu. */
html[data-start="menu"] #screen-welcome.is-active { display: none; }
html[data-start="menu"] #screen-menu { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ── MENU ───────────────────────────────────────────────────── */
/* Le menu est plus haut que l'écran (mesuré : 891 px pour 844 à 390 de large,
   et plus que 800 sur ordinateur). Centré par `justify-content: center`, il
   débordait PAR LE HAUT, là où le défilement ne va pas : le titre était
   rogné et le lien « Portfolio » se posait dessus. Les marges automatiques
   centrent quand il y a la place et se réduisent à zéro sinon. */
#screen-menu {
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: calc(var(--safe-top) + 24px);
  padding-bottom: calc(var(--safe-bot) + 18px);
  text-align: center;
  background: var(--bg);
}
.menu-inner {
  width: min(420px, 88vw);
  margin-block: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
/* Le titre est le logo (les quatre flèches et « Arrows », dessinés ensemble
   en septembre 2026). Un <img> suffit ici : le jeu n'a qu'un thème, clair,
   donc une seule variante à charger. Son alt porte le nom du h1. */
.menu-title {
  margin: 0 0 4px;
  line-height: 0;
}
.menu-logo {
  display: block;
  height: clamp(56px, 17vw, 76px);
  width: auto;
  max-width: 100%;
  object-fit: contain;
}
.menu-tagline {
  margin: 0 0 18px;
  color: var(--ink-2);
  font-size: .98rem;
  line-height: 1.5;
  max-width: 28em;
}
.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.menu-stats {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
}
.menu-stats > div {
  background: var(--card);
  border-radius: 14px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.menu-stats strong {
  font-size: 1.4rem;
  color: var(--ink);
  font-weight: 700;
}
.menu-stats span {
  font-size: .72rem;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: .08em;
}
/* ── Compte joueur (menu) : une ligne, pas un formulaire ─────── */
.menu-account {
  margin-top: 14px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
/* `.btn` (plus bas dans la feuille) pose `flex-direction: column` : le double
   sélecteur garde l'icône sur la même ligne que le mot. */
.menu-account .menu-account-btn {
  gap: 8px;
  min-height: 44px;
  flex-direction: row;
  font-weight: 600;
}
.menu-account-hint {
  margin: 0;
  font-size: .78rem;
  color: var(--ink-2);
  line-height: 1.4;
}
.auth-logged {
  margin: 2px 0 2px;
  font-size: .92rem;
  color: var(--ink);
}
#accountUser { text-align: center; }
#accountGuest { display: flex; flex-direction: column; align-items: center; }
#accountGuest[hidden], #accountUser[hidden] { display: none; }

/* ── Classement ───────────────────────────────────────────── */
#screen-board { overflow-y: auto; }
.board-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 16px 16px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}
.board-row {
  display: grid;
  grid-template-columns: 34px 1fr auto auto;
  gap: 10px;
  align-items: center;
  background: var(--card);
  border-radius: 12px;
  padding: 11px 14px;
}
.board-row.is-me { outline: 2px solid var(--accent); outline-offset: -2px; }
.board-rank {
  font-weight: 700;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.board-row:nth-child(1) .board-rank,
.board-row:nth-child(2) .board-rank,
.board-row:nth-child(3) .board-rank { color: var(--accent); }
.board-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-done {
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
}
.board-best {
  color: var(--ink-2);
  font-size: .76rem;
}
.board-empty {
  text-align: center;
  color: var(--ink-2);
  padding: 34px 12px;
  font-size: .9rem;
  line-height: 1.5;
}
.board-me {
  text-align: center;
  color: var(--ink-2);
  font-size: .84rem;
  margin: 0;
  padding: 0 16px calc(18px + var(--safe-bot));
}

.menu-reset {
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--ink-2);
  font-size: .78rem;
  padding: 12px;
  min-height: 44px;
}
.menu-reset:hover { color: var(--bad-ink); }

.menu-legal {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: .76rem;
}
.menu-legal a {
  color: var(--ink-2);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  /* « CGU » ne fait que 27 px de large : sans plancher, la cible est trois fois
     plus étroite que haute. */
  min-width: 44px;
  padding: 0 4px;
}
.menu-legal a:hover { color: var(--ink); text-decoration: underline; }
.menu-legal span { color: var(--ink-3); }
.menu-edited {
  margin: 0;
  font-size: .78rem;
  color: var(--ink-2);
  text-align: center;
}
.menu-edited a {
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Boutons ───────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: 14px;
  padding: 14px 22px;
  font-size: 1rem;
  font-weight: 600;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform .12s ease, background .15s ease, opacity .15s;
  min-height: 50px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent-deep);
  color: white;
}
@media (hover: hover) {
  .btn-primary:hover { background: var(--accent-deep-hover); }
}

.btn-ghost {
  background: var(--card);
  color: var(--ink);
}
.btn-ghost:hover { background: var(--bg-soft); }

.btn-link {
  background: none;
  color: var(--ink-2);
  padding: 8px 12px;
  min-height: 44px;
  font-size: .9rem;
}
.btn-link:hover { color: var(--ink); }

.btn-sub {
  font-size: .72rem;
  font-weight: 500;
  opacity: .8;
  letter-spacing: .03em;
}
/* Du blanc à 80 % sur le corail profond ne donne que 3,9:1 : à 92 %, 4,9:1. */
.btn-primary .btn-sub { opacity: .92; }

/* ── Header de jeu (utilisé par game/levels/how) ──────────── */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 6px;
  gap: 12px;
}
.header-title {
  text-align: center;
  flex: 1;
  min-width: 0;
}
.header-title h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}
.header-title p {
  margin: 0;
  font-size: .76rem;
  color: var(--ink-2);
}
.header-actions {
  display: flex;
  gap: 6px;
}
.hbtn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: var(--card);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .12s, opacity .15s;
}
.hbtn:hover { background: var(--bg-soft); }
.hbtn:active { transform: scale(0.94); }
.hbtn:disabled { opacity: .35; cursor: not-allowed; }
.hbtn-placeholder { background: transparent; pointer-events: none; }

/* ── Status (vies / compteur) ─────────────────────────────── */
.game-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px 6px;
  min-height: 28px;
}
.lives {
  display: flex;
  gap: 6px;
}
.life {
  width: 18px;
  height: 16px;
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 21s-7-4.35-9.5-9A5.5 5.5 0 0 1 12 6a5.5 5.5 0 0 1 9.5 6c-2.5 4.65-9.5 9-9.5 9z'/></svg>") no-repeat center/contain;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 21s-7-4.35-9.5-9A5.5 5.5 0 0 1 12 6a5.5 5.5 0 0 1 9.5 6c-2.5 4.65-9.5 9-9.5 9z'/></svg>") no-repeat center/contain;
  transition: background .25s, transform .25s;
}
.life.is-lost {
  background: var(--ink-3);
  opacity: .35;
  transform: scale(0.85);
}
.counter {
  color: var(--ink-2);
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
}

/* ── Plateau ──────────────────────────────────────────────── */
.board-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  min-height: 0;
}
.board-dots {
  position: absolute;
  inset: 14px;
  background-image: radial-gradient(circle, var(--dot) 1.2px, transparent 1.4px);
  background-size: 18px 18px;
  background-position: center;
  opacity: .55;
  pointer-events: none;
  border-radius: 12px;
}
.board {
  position: relative;
  width: min(96vw, 78vh, 560px);
  height: min(96vw, 78vh, 560px);
  touch-action: none;
}

/* Cell + arrow.
   IMPORTANT : le plateau a un viewBox en unités-cellule (1 cellule = 1 unité),
   donc toutes les épaisseurs de trait sont en fractions de cellule (≈ 0.1),
   pas en px, sinon une flèche ferait plusieurs cellules de large. */
.cell {
  cursor: pointer;
}
.cell-hit {
  fill: transparent;
}
.arrow-line, .arrow-head {
  stroke: var(--ink);
  stroke-width: 0.11;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  pointer-events: none;
  transition: stroke .18s;
}
.cell.is-collide .arrow-line,
.cell.is-collide .arrow-head { stroke: var(--bad); }

.path-line {
  stroke: var(--bad);
  stroke-width: 0.08;
  stroke-linecap: round;
  fill: none;
  opacity: .8;
  pointer-events: none;
}
.path-line.is-bad { stroke: var(--bad); }

.collision-mark {
  fill: var(--bad);
  pointer-events: none;
  animation: pop .35s ease-out;
}
@keyframes pop {
  from { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); opacity: 1; }
  to { transform: scale(1); opacity: 1; }
}

.board-toast {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 12px;
  font-size: .85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  box-shadow: var(--shadow);
}
.board-toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Footer du jeu ────────────────────────────────────────── */
.game-footer {
  display: flex;
  gap: 10px;
  padding: 8px 14px 18px;
}
.game-footer .btn {
  flex: 1;
  min-height: 44px;
}

/* ── Sélecteur de niveaux ─────────────────────────────────── */
#screen-levels { overflow-y: auto; }
.levels-bands {
  display: flex;
  gap: 6px;
  padding: 4px 14px 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.band-btn {
  background: var(--card);
  border: none;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: .78rem;
  font-weight: 600;
  transition: background .15s, color .15s;
}
.band-btn.is-active {
  background: var(--ink);
  color: var(--bg);
}
.band-btn:hover:not(.is-active) { background: var(--bg-soft); }

.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  padding: 6px 14px 28px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.lvl-tile {
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: none;
  background: var(--card);
  color: var(--ink-2);
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform .12s ease, background .15s ease, color .15s;
}
.lvl-tile:active { transform: scale(0.94); }
.lvl-tile.is-done {
  background: var(--accent-deep);
  color: white;
}
.lvl-tile.is-done::after {
  /* Coche SVG (mask-image) : plus de glyphe texte, cf. règle typographie. */
  content: "";
  position: absolute;
  top: 4px;
  right: 6px;
  width: .6rem;
  height: .6rem;
  background-color: currentColor;
  -webkit-mask-image: var(--icon-check-arrow);
          mask-image: var(--icon-check-arrow);
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-size: contain;
          mask-size: contain;
  opacity: .8;
}
.lvl-tile.is-locked {
  opacity: .35;
  pointer-events: none;
}
.lvl-tile.is-current {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ── Comment jouer ────────────────────────────────────────── */
#screen-how { overflow-y: auto; }
.how-inner {
  padding: 14px 18px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}
.how-card {
  background: var(--card);
  padding: 16px 18px;
  border-radius: 16px;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: start;
}
.how-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-deep);
  color: white;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.how-card h3 {
  margin: 4px 0 4px;
  font-size: 1rem;
}
.how-card p {
  margin: 0;
  color: var(--ink-2);
  font-size: .88rem;
  line-height: 1.45;
  grid-column: 2;
}
.how-card > div:first-child + h3 { grid-column: 2; }
.how-card h3 { grid-column: 2; }
.how-demo {
  background: var(--card);
  border-radius: 16px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.how-go { margin-top: 8px; }

/* ── Modals ───────────────────────────────────────────────── */
.modal {
  position: absolute;
  inset: 0;
  background: rgba(74, 46, 26, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 10;
  animation: fadeIn .2s ease;
  backdrop-filter: blur(3px);
}
.modal.is-on { display: flex; }
.modal-card {
  background: var(--bg);
  border-radius: 22px;
  padding: 26px 22px 22px;
  width: min(380px, 100%);
  text-align: center;
  position: relative;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.4);
  animation: popIn .28s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-card h3 {
  margin: 4px 0 8px;
  font-size: 1.4rem;
}
.modal-card p {
  margin: 0 0 18px;
  color: var(--ink-2);
  font-size: .92rem;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  gap: 10px;
}
.modal-actions .btn { flex: 1; }

.win-burst {
  width: 60px;
  height: 60px;
  margin: 0 auto 6px;
  border-radius: 50%;
  background: var(--accent);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.win-burst::before {
  content: "";
  width: 2rem;
  height: 2rem;
  background-color: white;
  -webkit-mask-image: var(--icon-check-arrow);
          mask-image: var(--icon-check-arrow);
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-size: contain;
          mask-size: contain;
}
.win-burst::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: .3;
  animation: ripple 1.2s ease-out infinite;
}
@keyframes ripple {
  from { transform: scale(0.8); opacity: .55; }
  to { transform: scale(1.5); opacity: 0; }
}

/* ── ACCUEIL ─────────────────────────────────────────────────────
   Première visite, et « Compte » rouvert depuis le menu. Une page éditoriale,
   pas un menu de jeu : alignée à gauche, une démonstration qui joue, puis la
   carte d'accès. Sur téléphone tout s'empile dans l'ordre de lecture (titre,
   démonstration, compte, trois faits) ; à partir de 1024 px, deux colonnes.
   Aucune ombre, aucun dégradé : des filets, du crème, un seul corail. */
#screen-welcome {
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}
.wl {
  --wl-pad: 16px;
  --wl-top: 10px;
  --wl-bot: 14px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  /* Téléphone couché avec une encoche (viewport-fit=cover) : le contenu ne
     passe jamais dessous. Haut et bas sont déjà réservés par `.screen`. */
  padding: var(--wl-top) max(var(--wl-pad), env(safe-area-inset-right, 0px))
           var(--wl-bot) max(var(--wl-pad), env(safe-area-inset-left, 0px));
}
.wl-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
}
.wl-logo {
  display: block;
  height: 34px;
  width: auto;
  max-width: 100%;
}
/* Le retour n'existe qu'en mode « compte » : à la première visite il n'y a
   nulle part où revenir, la sortie est « Jouer sans compte ». */
.wl-back { display: none; flex: none; }
#screen-welcome[data-mode="account"] .wl-back { display: inline-flex; }

.wl-title {
  margin: 10px 0 0;
  font-size: clamp(2rem, 9.4vw, 2.9rem);
  line-height: 1.04;
  font-weight: 800;
  letter-spacing: -.028em;
  color: var(--ink);
}
.wl-deck {
  display: block;
  margin-top: 8px;
  max-width: 28em;
  font-size: clamp(1rem, 4.2vw, 1.15rem);
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-2);
}
.wl-noscript { margin: 12px 0 0; color: var(--bad-ink); font-weight: 600; }

/* La démonstration : le plateau du jeu, sur le même quadrillage de points. */
.wl-stage {
  --wl-size: clamp(176px, min(62vw, 34vh), 300px);
  position: relative;
  display: grid;
  place-items: center;
  margin-top: 16px;
  padding: 10px;
  background: var(--bg-soft);
  border: 1px solid #e0d3bb;
  border-radius: 18px;
  overflow: hidden;
}
.wl-board {
  display: block;
  width: var(--wl-size);
  height: var(--wl-size);
  overflow: visible;
}
.wl-board .cell { cursor: default; pointer-events: none; }
.wl-dot { fill: #c8b690; }
/* L'opacité de ces éléments est posée par welcome.js (attribut) : une règle
   `opacity` ici l'écraserait, une feuille bat toujours un attribut de présentation. */
.wl-ring { fill: none; stroke: var(--accent-deep); stroke-width: .05; }
.wl-path {
  fill: none;
  stroke: var(--accent-deep);
  stroke-width: .055;
  stroke-linecap: round;
  stroke-dasharray: .1 .14;
}
.wl-path.is-bad { stroke: var(--bad); }
.wl-mark { fill: var(--bad); }
.wl-win-disc { fill: var(--accent-deep); }
.wl-win-check {
  fill: none;
  stroke: #fff;
  stroke-width: .17;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.wl-win-ring { fill: none; stroke: var(--accent-deep); stroke-width: .05; }

/* Pause / lecture : la démonstration dure plus de cinq secondes, elle doit
   pouvoir s'arrêter (WCAG 2.2.2). */
.wl-play {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  transition: background .15s;
}
.wl-play .ico-play { display: none; }
.wl-stage[data-playing="false"] .wl-play .ico-pause { display: none; }
.wl-stage[data-playing="false"] .wl-play .ico-play { display: block; }

/* La carte d'accès. */
.wl-card {
  margin-top: 16px;
  padding: 0 16px 16px;
  background: var(--card);
  border: 1px solid var(--dot);
  border-radius: 18px;
}
.wl-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--dot);
}
.wl-tab {
  min-height: 52px;
  padding: 0 8px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  font-size: .95rem;
  font-weight: 600;
  color: var(--ink-2);
}
.wl-tab.is-on { color: var(--ink); border-bottom-color: var(--accent-deep); }
.wl-panel { padding-top: 14px; }
.wl-panel[hidden] { display: none; }
.wl-field { margin-bottom: 12px; min-width: 0; }
.wl-field label {
  display: block;
  margin-bottom: 5px;
  font-size: .84rem;
  font-weight: 600;
  color: var(--ink);
}
.wl-field input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 11px 12px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 10px;
}
.wl-field input:focus { border-color: var(--ink); }
.wl-field input[aria-invalid="true"] { border-color: var(--bad); }
.wl-pass { position: relative; }
.wl-pass input { padding-right: 52px; }
.wl-eye {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--ink-2);
}
.wl-eye .ico-eye-off { display: none; }
.wl-eye[aria-pressed="true"] .ico-eye { display: none; }
.wl-eye[aria-pressed="true"] .ico-eye-off { display: block; }
.wl-hint {
  margin: 6px 0 0;
  font-size: .78rem;
  line-height: 1.4;
  color: var(--ink-2);
}
/* La zone d'erreur existe toujours (un lecteur d'écran n'annonce qu'une zone
   déjà présente) mais ne prend aucune place tant qu'elle est vide. */
.wl-error {
  margin: 0;
  font-size: .86rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--bad-ink);
}
.wl-error:not(:empty) { margin-bottom: 10px; }
.wl-submit { width: 100%; }
.wl-submit[aria-busy="true"] { opacity: .75; cursor: progress; }
.wl-submit[aria-busy="true"] .btn-label::before {
  content: "";
  display: inline-block;
  width: .85em;
  height: .85em;
  margin-right: .55em;
  vertical-align: -.1em;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.wl-consent {
  margin: 12px 0 0;
  font-size: .78rem;
  line-height: 1.45;
  color: var(--ink-2);
}
.wl-consent a, .wl-hint a {
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* « ou » puis la sortie sans compte. */
.wl-alt {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.wl-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
  font-size: .82rem;
  color: var(--ink-2);
}
.wl-or::before, .wl-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--dot);
}
.wl-guest { width: 100%; }
.wl-how { align-self: center; }
/* Les libellés qui changent avec le mode (première visite ou compte). */
.wl-acct { display: none; }
#screen-welcome[data-mode="account"] .wl-acct { display: inline; }
#screen-welcome[data-mode="account"] .wl-first { display: none; }

/* Trois faits : des filets et des flèches, pas des cartes. */
.wl-facts { margin-top: 18px; }
.wl-facts ul { list-style: none; margin: 0; padding: 0; }
.wl-facts li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--dot);
}
.wl-facts li:last-child { border-bottom: 1px solid var(--dot); }
.wl-fact-ico { color: var(--accent-deep); margin-top: 1px; }
.wl-facts h3 { margin: 0 0 3px; font-size: 1rem; font-weight: 700; }
.wl-facts p {
  margin: 0;
  font-size: .92rem;
  line-height: 1.5;
  color: var(--ink-2);
}
.wl-foot {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Au survol seulement : sur un écran tactile `:hover` reste collé après le tap. */
@media (hover: hover) {
  .wl-tab:hover { color: var(--ink); }
  .wl-eye:hover { color: var(--ink); }
  .wl-play:hover { background: var(--bg-soft); }
}

/* Très petit écran : « Créer un compte » tient sur une ligne. */
@media (max-width: 359px) {
  .wl-tab { font-size: .88rem; padding: 0 2px; }
}

/* Tablette : toujours une colonne, mais plus large et plus aérée. */
@media (min-width: 760px) {
  .wl { max-width: 680px; --wl-pad: 24px; --wl-top: 16px; --wl-bot: 20px; }
  .wl-logo { height: 38px; }
  .wl-stage { --wl-size: clamp(220px, min(50vw, 46vh), 360px); }
}

/* Ordinateur : deux colonnes. Le titre et la démonstration à gauche, la carte
   d'accès et la sortie sans compte à droite, les trois faits en travers. */
@media (min-width: 1024px) {
  .wl { max-width: 1180px; --wl-pad: 40px; --wl-top: 22px; --wl-bot: 28px; }
  .wl-head { min-height: 56px; }
  .wl-logo { height: 42px; }
  .wl-cols {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
    gap: 64px;
    align-items: start;
    margin-top: 18px;
  }
  .wl-title { margin-top: 0; font-size: clamp(2.8rem, 4.3vw, 3.9rem); }
  .wl-deck { margin-top: 10px; font-size: 1.25rem; }
  .wl-stage {
    --wl-size: clamp(260px, min(32vw, 52vh), 430px);
    margin-top: 28px;
    padding: 16px;
  }
  .wl-card { margin-top: 0; padding: 0 24px 24px; }
  .wl-alt { margin-top: 10px; }
  .wl-facts { margin-top: 36px; }
  .wl-facts ul {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 40px;
  }
  .wl-facts li { border-bottom: 1px solid var(--dot); padding: 18px 0 20px; }
  .wl-foot { margin-top: 28px; align-items: flex-start; }
}

/* ── Responsive : ordinateur ──────────────────────────────── */
@media (min-width: 720px) {
  .board { width: min(70vmin, 600px); height: min(70vmin, 600px); }
  .game-header { padding: 18px 24px 8px; }
  .game-status { padding: 0 24px 8px; }
  .game-footer { padding: 10px 24px 22px; }
}
@media (min-width: 1024px) {
  #screen-menu { padding-top: 6vh; align-items: center; }
}

/* Évite que le bouton iOS "open in app" prenne le focus */
@supports (-webkit-touch-callout: none) {
  body { -webkit-user-select: none; user-select: none; }
  input { -webkit-user-select: text; user-select: text; }
}

/* ── Mouvement réduit ─────────────────────────────────────────
   Rien de ce que l'application anime n'est nécessaire à la comprendre : on
   coupe les entrées d'écran, les pulsations et les rotations. La démonstration
   de l'accueil, elle, s'arrête d'elle-même (welcome.js lit la même préférence). */
@media (prefers-reduced-motion: reduce) {
  .screen, .modal, .modal-card, .collision-mark { animation: none; }
  .win-burst::after { animation: none; }
  .wl-submit[aria-busy="true"] .btn-label::before { animation: none; }
  .btn, .hbtn, .life, .board-toast, .lvl-tile, .wl-play { transition: none; }
  .btn:active, .hbtn:active, .lvl-tile:active { transform: none; }
}

/* ── Téléphone : aucun champ sous 16 px ───────────────────────
   En dessous, iOS zoome tout seul au premier tap et laisse la page agrandie.
   La règle nomme la PORTEUSE (`.wl-field input`, 0,1,1) : un sélecteur sur
   `input` nu se ferait battre par elle et n'aurait aucun effet. Bloc en fin de
   fichier : une media query n'ajoute aucune priorité, seul l'ordre tranche. */
@media (max-width: 760px) {
  .wl-field input { font-size: 16px; }
}
