:root {
  --fond: #f5ead8;
  --surface: #ebddc5;
  --texte: #201e1d;
  --silhouette: #2e2b25;
  --accent: #c67139;
  --accent-fonce: #8c491a;
  --discret: #645c50;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 12px;
}

.top {
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.top h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.01em;
}

.top h1 span { color: var(--accent-fonce); font-weight: 600; }

/* Jour et niveau de difficulté du défi */
.titre { display: flex; flex-direction: column; gap: 4px; }
.niveau {
  margin: 0;
  align-self: flex-start;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: #f0fae1;
  color: #3d472b;
}
.niveau[data-niveau="moyen"] { background: #ffe1d0; color: #643312; }
.niveau[data-niveau="difficile"] { background: #643312; color: #fff2eb; }

.stats {
  display: flex;
  gap: 14px;
  font-size: 15px;
  color: var(--discret);
}

.stats strong { color: var(--texte); font-variant-numeric: tabular-nums; }
.stats .objectif strong { color: var(--accent-fonce); }

@media (max-width: 420px) {
  .top { flex-wrap: wrap; }
  .stats { gap: 10px; font-size: 14px; }
}

.jeu {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.cible {
  background: var(--surface);
  border-radius: 16px;
  padding: 8px 12px 12px;
  text-align: center;
}

.etiquette {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--discret);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#cible {
  width: 100%;
  height: 120px;
  display: block;
}

#cible path { fill: var(--silhouette); fill-rule: nonzero; }

/* Mode test (?solution) : emplacement des pièces dans la forme à obtenir */
#cible .solution { stroke: #fff9f0; stroke-width: 0.04; stroke-linejoin: round; }
#cible .solution.a-deplacer { stroke: #201e1d; stroke-width: 0.09; stroke-dasharray: 0.18 0.12; }
.mode-test {
  margin: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: #8c491a;
}

.passe {
  margin: 0;
  text-align: center;
  font-size: 14px;
  color: var(--discret);
}

.plateau-zone {
  background: #fff9f0;
  border-radius: 16px;
  box-shadow: inset 0 0 0 1px rgba(32, 30, 29, 0.08);
}

#plateau {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  touch-action: none;       /* le doigt déplace les pièces, pas la page */
  user-select: none;
}

#plateau .piece {
  stroke: #fff9f0;
  stroke-width: 0.04;
  stroke-linejoin: round;
  cursor: grab;
  transition: filter 0.15s;
}

#plateau .piece.selection {
  stroke: var(--texte);
  stroke-width: 0.07;
  filter: drop-shadow(0 0.08px 0.12px rgba(0, 0, 0, 0.35));
}

#plateau .piece.deplacement { cursor: grabbing; filter: drop-shadow(0 0.15px 0.2px rgba(0, 0, 0, 0.35)); }

.outils {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

button {
  font: inherit;
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  background: var(--accent);
  color: var(--texte);
  font-size: 18px;
  cursor: pointer;
}

button:hover { background: #d67f48; }
button:disabled { opacity: 0.35; cursor: default; }
button.secondaire { background: var(--surface); font-size: 15px; }
button.secondaire:hover { background: #dcd3c4; }

.regles {
  background: var(--surface);
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.45;
}

.regles summary { font-weight: 700; cursor: pointer; }
.regles ol { margin: 8px 0 2px; padding-left: 20px; }
.regles li { margin: 4px 0; }

.maquette {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px dashed rgba(32, 30, 29, 0.2);
}

/* Installer l'application (sous les flèches des défis) */
.installer { text-align: center; }
.installer button { width: 100%; }
.installer p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--discret); }

.fenetre {
  position: fixed;
  inset: 0;
  background: rgba(32, 30, 29, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.panneau {
  background: var(--fond);
  border-radius: 20px;
  padding: 22px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.panneau h2 { margin: 0 0 8px; font-size: 28px; }
.panneau p { margin: 6px 0; }
.score { font-weight: 700; color: var(--accent-fonce); }
.actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
.copie { font-size: 14px; color: var(--discret); }
.cachee { display: none !important; }

/* ---------- Statistiques, série, écran de fin ---------- */
.top { position: relative; }
button.icone { min-width: 44px; padding: 0; font-size: 20px; flex: none; }
.top .stats { order: 3; width: 100%; }
.top { flex-wrap: wrap; }

.deja {
  margin: 0;
  padding: 8px 12px;
  border-radius: 12px;
  background: #f0fae1;
  color: #3d472b;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.serie { font-size: 18px; font-weight: 700; margin: 10px 0 4px; }

.mini-stats, .grille-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 10px 0;
}
.mini-stats div, .grille-stats div {
  background: var(--surface);
  border-radius: 12px;
  padding: 8px 4px;
  font-size: 12px;
  color: var(--discret);
  line-height: 1.25;
}
.mini-stats strong, .grille-stats strong {
  display: block;
  font-size: 20px;
  color: var(--texte);
  font-variant-numeric: tabular-nums;
}

.prochain { font-size: 14px; color: var(--discret); font-variant-numeric: tabular-nums; }

.panneau h3 { margin: 14px 0 6px; font-size: 15px; }
.temps-niveaux { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.temps-niveaux div { display: flex; justify-content: space-between; padding: 6px 10px; background: var(--surface); border-radius: 10px; }
.note { font-size: 12px; color: var(--discret); margin-top: 12px; }
.actions { flex-wrap: wrap; }

/* ---------- Pied de page et réseaux sociaux ---------- */
.pied {
  width: 100%;
  max-width: 520px;
  margin-top: 18px;
  padding: 10px 0 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  font-size: 13px;
  color: var(--discret);
  border-top: 1px solid rgba(32, 30, 29, 0.12);
}
.pied a { color: #8c491a; }
.social { display: flex; align-items: center; gap: 2px; }
.social-label { font-size: 13px; margin-right: 4px; color: var(--discret); }
.social a { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; color: var(--texte); }
.social a:hover { background: var(--surface); }
.social svg { width: 20px; height: 20px; }
.panneau .social { justify-content: center; margin-top: 10px; }
