:root {
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface2: #f5f5f7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.1);
  --accent: #0066ff;
  --accent-press: #0050cc;
  --on-accent: #ffffff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 4px 18px rgba(0, 0, 0, 0.08);
  --nav-bg: rgba(251, 251, 253, 0.78);
  --radius: 22px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface2: #2c2c2e;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --line: rgba(255, 255, 255, 0.14);
    --accent: #2f8bff;
    --accent-press: #5aa5ff;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
    --shadow-sm: 0 4px 18px rgba(0, 0, 0, 0.5);
    --nav-bg: rgba(0, 0, 0, 0.72);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface2: #2c2c2e;
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #2f8bff;
  --accent-press: #5aa5ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 4px 18px rgba(0, 0, 0, 0.5);
  --nav-bg: rgba(0, 0, 0, 0.72);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, textarea, input { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Navigation */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.nav-in {
  max-width: 1120px; margin: 0 auto; padding: 0 20px;
  height: 52px; display: flex; align-items: center; gap: 20px;
}
.marque { font-weight: 700; font-size: 19px; letter-spacing: -0.02em; color: var(--text); }
.marque:hover { text-decoration: none; }
.liens { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.liens::-webkit-scrollbar { display: none; }
.liens a {
  color: var(--muted); font-size: 14px; padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}
.liens a:hover { color: var(--text); text-decoration: none; }
.liens a[aria-current="page"] { color: var(--text); background: var(--surface2); font-weight: 600; }
.nav-actions { display: flex; gap: 8px; }
/* Sur téléphone, les quatre outils passent sur une seconde ligne, tous visibles. */
@media (max-width: 860px) {
  .nav-in { height: auto; flex-wrap: wrap; padding: 8px 16px; row-gap: 6px; }
  .nav-actions { margin-left: auto; }
  .liens { order: 3; flex-basis: 100%; justify-content: center; }
}
@media (max-width: 640px) {
  /* Les libellés sont plus longs dans certaines langues : le menu passe à la ligne
     plutôt que de cacher un outil. */
  .liens { justify-content: center; flex-wrap: wrap; overflow: visible; gap: 2px 4px; }
  .liens a { padding: 6px 7px; font-size: 13px; }
  /* Le nom du site et les deux boutons doivent tenir sur une seule ligne. */
  .nav-in { column-gap: 10px; }
  .marque { font-size: 17px; }
  .nav-actions { gap: 6px; }
  .nav-actions .btn-petit { padding: 6px 11px; font-size: 13px; }
}

/* Boutons */
.btn {
  border: 0; border-radius: 999px; padding: 10px 18px;
  background: var(--surface2); color: var(--text);
  font-size: 15px; font-weight: 500; cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, opacity 0.2s ease;
}
.btn:hover { background: var(--line); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primaire { background: var(--accent); color: var(--on-accent); }
.btn-primaire:hover { background: var(--accent-press); }
.btn-petit { padding: 7px 14px; font-size: 14px; }
.btn-grand { padding: 15px 34px; font-size: 19px; font-weight: 600; }

/* Mise en page */
main { max-width: 1120px; margin: 0 auto; padding: 0 20px 80px; }

.intro { text-align: center; padding: 44px 0 32px; }
.intro h1 {
  margin: 0; font-size: clamp(34px, 6vw, 64px); line-height: 1.05;
  font-weight: 700; letter-spacing: -0.035em;
}
.intro p {
  margin: 14px auto 0; max-width: 560px;
  font-size: clamp(17px, 2.2vw, 21px); color: var(--muted);
}

.outil {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  gap: 40px; align-items: start;
}
@media (max-width: 860px) {
  .outil { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .intro { padding: 36px 0 28px; }
}

/* Roue */
.scene {
  position: relative; width: 100%; margin: 0 auto; aspect-ratio: 1;
  /* La roue entière doit tenir à l'écran sous le titre, sans défilement. */
  max-width: min(600px, max(300px, calc(100vh - 330px)));
}
.scene canvas {
  width: 100%; height: 100%; display: block; border-radius: 50%;
  box-shadow: var(--shadow); cursor: pointer; touch-action: manipulation;
}
.moyeu {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 23%; aspect-ratio: 1; border-radius: 50%; border: 0;
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: clamp(13px, 2.3vw, 20px); letter-spacing: -0.01em;
  box-shadow: 0 6px 26px rgba(0, 0, 0, 0.22); cursor: pointer;
  transition: transform 0.15s ease;
}
.moyeu:hover { transform: translate(-50%, -50%) scale(1.04); }
.moyeu:active { transform: translate(-50%, -50%) scale(0.97); }
.moyeu:disabled { cursor: default; opacity: 0.9; }
.repere {
  position: absolute; right: -12px; top: 50%; transform: translateY(-50%);
  width: 0; height: 0;
  border-top: 15px solid transparent; border-bottom: 15px solid transparent;
  border-right: 28px solid var(--text);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}
.astuce { text-align: center; color: var(--muted); font-size: 14px; margin: 18px 0 0; }
.astuce kbd {
  font-family: inherit; font-size: 13px; padding: 2px 8px; border-radius: 6px;
  background: var(--surface2); border: 1px solid var(--line);
}

/* Panneau */
.panneau {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm);
}
.panneau h2 { margin: 0 0 4px; font-size: 19px; letter-spacing: -0.01em; }
.aide { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.compte { float: right; font-size: 14px; color: var(--muted); font-weight: 400; }
textarea {
  width: 100%; min-height: 240px; resize: vertical;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface2); padding: 14px 16px;
  font-size: 17px; line-height: 1.6;
}
textarea:focus { outline: 3px solid var(--accent); outline-offset: 0; }
.rangee { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

details { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }
summary { cursor: pointer; font-weight: 600; font-size: 15px; list-style: none; display: flex; justify-content: space-between; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; color: var(--muted); font-weight: 400; font-size: 20px; line-height: 1; }
details[open] summary::after { content: "–"; }
.option { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; font-size: 15px; }
.option + .option { border-top: 1px solid var(--line); }

/* Interrupteur */
.inter { position: relative; width: 50px; height: 30px; flex: none; }
.inter input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.inter span {
  position: absolute; inset: 0; border-radius: 999px; background: var(--surface2);
  border: 1px solid var(--line); transition: background 0.2s ease; pointer-events: none;
}
.inter span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}
.inter input:checked + span { background: #30d158; border-color: transparent; }
.inter input:checked + span::after { transform: translateX(20px); }
.inter input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Sélecteur segmenté */
.segments { display: inline-flex; background: var(--surface2); border-radius: 12px; padding: 3px; gap: 2px; }
.segments button {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 9px;
  font-size: 15px; font-weight: 500; cursor: pointer; color: var(--muted); min-width: 40px;
}
.segments button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); }

.historique { list-style: none; margin: 10px 0 0; padding: 0; max-height: 220px; overflow: auto; }
.historique li { padding: 8px 0; font-size: 15px; display: flex; justify-content: space-between; gap: 12px; }
.historique li + li { border-top: 1px solid var(--line); }
.historique small { color: var(--muted); }
.vide { color: var(--muted); font-size: 14px; margin: 10px 0 0; }

/* Emplacement publicitaire */
.pub {
  margin: 44px auto 0; max-width: 728px; min-height: 90px;
  border: 1px dashed var(--line); border-radius: 14px;
  display: grid; place-items: center; color: var(--muted); font-size: 13px;
}

/* Texte d'explication */
.seo { max-width: 720px; margin: 72px auto 0; }
.seo h2 { font-size: clamp(24px, 3.4vw, 34px); letter-spacing: -0.025em; line-height: 1.15; margin: 0 0 14px; }
.seo h3 { font-size: 19px; margin: 28px 0 6px; letter-spacing: -0.01em; }
.seo p, .seo li { color: var(--muted); }
.seo ol { padding-left: 22px; }
.autres { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 18px; }
.carte {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px 20px; color: var(--text); transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.carte:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.carte strong { display: block; font-size: 17px; letter-spacing: -0.01em; }
.carte span { color: var(--muted); font-size: 14px; }

footer { border-top: 1px solid var(--line); padding: 26px 20px 40px; text-align: center; color: var(--muted); font-size: 13px; }

/* Fenêtre de résultat */
dialog {
  border: 0; border-radius: 30px; padding: 44px 36px 32px;
  background: var(--surface); color: var(--text);
  width: min(92vw, 600px); text-align: center; box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.4); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
dialog[open] { animation: entree 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes entree { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sur-titre { margin: 0; color: var(--muted); font-size: 15px; font-weight: 600; }
.gagnant {
  margin: 8px 0 28px; font-size: clamp(40px, 10vw, 92px); line-height: 1.05;
  font-weight: 700; letter-spacing: -0.035em; overflow-wrap: anywhere;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* Message bref */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 999px;
  font-size: 15px; display: flex; align-items: center; gap: 14px; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow-sm);
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: transparent; color: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; }

.confettis { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

/* Dés */
.plateau { display: flex; flex-wrap: wrap; gap: 22px; justify-content: center; align-items: center; min-height: 240px; padding: 20px 0; }
.de {
  /* Tailles dérivées du côté du dé : un pourcentage se calculerait sur le plateau. */
  --cote: clamp(84px, 17vw, 132px);
  width: var(--cote); height: var(--cote); background: var(--surface);
  border: 1px solid var(--line); border-radius: calc(var(--cote) * 0.22); box-shadow: var(--shadow-sm);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  padding: calc(var(--cote) * 0.15); gap: calc(var(--cote) * 0.05);
}
.de i { border-radius: 50%; background: transparent; }
.de i.on { background: var(--text); }
.de.roule { animation: secousse 0.35s linear infinite; }
@keyframes secousse {
  0% { transform: rotate(0) translateY(0); } 25% { transform: rotate(-9deg) translateY(-8px); }
  50% { transform: rotate(6deg) translateY(0); } 75% { transform: rotate(-4deg) translateY(-5px); } 100% { transform: rotate(0); }
}
.total { text-align: center; margin: 8px 0 0; }
.total strong { display: block; font-size: clamp(56px, 12vw, 110px); line-height: 1; font-weight: 700; letter-spacing: -0.04em; }
.total span { color: var(--muted); font-size: 15px; }
.centre { text-align: center; margin-top: 26px; }
.reglage { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-bottom: 8px; color: var(--muted); font-size: 15px; }

/* Pièce */
.piste { perspective: 1100px; display: grid; place-items: center; min-height: 300px; }
.piece {
  width: clamp(170px, 34vw, 250px); aspect-ratio: 1; position: relative;
  transform-style: preserve-3d; transition: transform 1.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.piece div {
  position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  font-size: clamp(30px, 6vw, 46px); font-weight: 700; letter-spacing: -0.02em;
  box-shadow: var(--shadow), inset 0 0 0 10px rgba(255, 255, 255, 0.28);
}
.piece .cote-pile { background: #ffd60a; color: #1d1d1f; }
.piece .cote-face { background: #0a84ff; color: #ffffff; transform: rotateY(180deg); }
.compteurs { display: flex; gap: 14px; justify-content: center; margin-top: 22px; }
.compteur { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px 22px; min-width: 110px; text-align: center; }
.compteur strong { display: block; font-size: 30px; letter-spacing: -0.02em; }
.compteur span { color: var(--muted); font-size: 14px; }

/* Nombre aléatoire */
.champs { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; align-items: flex-end; }
.champ { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.champ input {
  width: 150px; height: 46px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); padding: 0 14px; font-size: 20px; font-weight: 600; text-align: center;
}
.champ input:focus { outline: 3px solid var(--accent); outline-offset: 0; }
.champ .pas { height: 46px; }
.champ .pas button { height: 40px; }
.erreur { text-align: center; color: #d70015; font-size: 15px; margin: 14px 0 0; }
.tirage { text-align: center; min-height: 230px; display: flex; flex-direction: column; justify-content: center; padding: 20px 0 0; }
.nombre {
  margin: 0; font-size: clamp(72px, 19vw, 190px); line-height: 1; font-weight: 700;
  letter-spacing: -0.05em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.jetons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 820px; margin: 0 auto; }
.jetons span {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-sm);
  padding: 10px 18px; font-size: clamp(22px, 4vw, 34px); font-weight: 700; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
body.classe .tirage { min-height: 60vh; }
body.classe .nombre { font-size: min(34vh, 24vw); }
body.classe .jetons span { font-size: clamp(30px, 6vh, 64px); }

/* Groupes */
.groupes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.groupe { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px 20px; box-shadow: var(--shadow-sm); animation: entree 0.3s ease both; }
.groupe h3 { margin: 0 0 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.groupe h3 i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.groupe ul { list-style: none; margin: 0; padding: 0; font-size: 18px; line-height: 1.7; font-weight: 500; }
.pas { display: inline-flex; align-items: center; gap: 4px; background: var(--surface2); border-radius: 12px; padding: 3px; }
.pas button { border: 0; background: var(--surface); width: 36px; height: 34px; border-radius: 9px; font-size: 20px; cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.pas output { min-width: 40px; text-align: center; font-weight: 600; }

/* Mode classe */
.quitter { display: none; }
body.classe { overflow: hidden; }
body.classe .nav, body.classe .intro, body.classe .panneau, body.classe .pub,
body.classe .seo, body.classe footer, body.classe .astuce, body.classe .masque-classe { display: none !important; }
body.classe main { max-width: none; min-height: 100vh; padding: 3vh 3vw; display: grid; place-items: center; }
body.classe .outil { display: block; width: 100%; }
body.classe .scene { max-width: min(90vh, 90vw); }
body.classe .quitter { display: inline-block; position: fixed; top: 16px; right: 16px; z-index: 30; }
body.classe .plateau { min-height: 46vh; gap: 4vw; }
body.classe .de { --cote: clamp(110px, min(22vh, 13vw), 260px); }
body.classe .piece { width: min(50vh, 60vw); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .erreur { color: #ff6961; } }
:root[data-theme="dark"] .erreur { color: #ff6961; }

/* Choix de la langue, en pied de page */
.langues { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; margin-top: 12px; font-size: 14px; }
.langues span { color: var(--text); font-weight: 600; }
.langues a { color: var(--muted); }

/* Très petits téléphones : le bouton de thème s'efface, le site suit déjà le réglage de l'appareil. */
@media (max-width: 360px) {
  #theme { display: none; }
}

/* Aucune régie publicitaire n'est encore branchée : les emplacements réservés restent masqués.
   Retirer cette règle le jour où la publicité est activée. */
.pub { display: none; }
footer .langues + .langues { margin-top: 8px; }
footer a { color: var(--muted); }

/* Tirage de Noël : liens secrets et révélation */
.liens-secrets { display: grid; gap: 10px; }
.lien-secret { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; box-shadow: var(--shadow-sm); animation: entree 0.3s ease both; }
.lien-secret strong { font-size: 17px; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.revelation { max-width: 560px; margin: 0 auto 40px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 44px 24px; box-shadow: var(--shadow-sm); }
.revelation .aide { font-size: 17px; }
.revelation .nom { font-size: clamp(40px, 10vw, 72px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; margin: 6px 0 20px; overflow-wrap: anywhere; }
.outil[hidden], .revelation[hidden] { display: none; }
