/* La Taverne de Tompew — interface.
   Neutres chauds, une seule couleur d'accent, beaucoup d'air : les cartes, qui sont
   déjà très chargées, doivent être la seule chose colorée à l'écran. */

:root {
  --fond:        #f6f5f2;
  --surface:     #ffffff;
  --surface-2:   #efede8;
  --surface-3:   #e6e3dc;
  --bord:        #e3e0d9;
  --bord-fort:   #cfcbc2;
  --texte:       #1c1a17;
  --texte-2:     #6c675e;
  --texte-3:     #9a948a;
  --accent:      #e0741a;
  --accent-fort: #c4600f;
  --accent-doux: #fdeee0;
  --sur-accent:  #ffffff;
  --ok:          #2a9d5c;
  --ok-doux:     #e3f5ea;
  --ko:          #d64545;
  --ko-doux:     #fbe6e6;
  --ombre:       0 1px 2px rgba(28, 26, 23, .06), 0 8px 24px -12px rgba(28, 26, 23, .18);
  --ombre-haute: 0 24px 60px -20px rgba(28, 26, 23, .35);
  --rayon:       14px;
  --rayon-petit: 9px;
  --police: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond:        #141311;
    --surface:     #1d1b19;
    --surface-2:   #262421;
    --surface-3:   #302d29;
    --bord:        #2e2b27;
    --bord-fort:   #403c36;
    --texte:       #f1eee8;
    --texte-2:     #a49e93;
    --texte-3:     #6f6a61;
    --accent:      #f0904a;
    --accent-fort: #f5a86e;
    --accent-doux: #3a2414;
    --sur-accent:  #2a1607;
    --ok:          #4fc27e;
    --ok-doux:     #17301f;
    --ko:          #f06a6a;
    --ko-doux:     #3a1c1c;
    --ombre:       0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --ombre-haute: 0 24px 60px -20px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  padding-block: calc(24px + env(safe-area-inset-top, 0px)) calc(40px + env(safe-area-inset-bottom, 0px));
  padding-inline: 20px;
  font: 16px/1.5 var(--police);
  color: var(--texte);
  background: var(--fond);
  -webkit-font-smoothing: antialiased;
}

.ecran { max-width: 720px; margin: 0 auto; }
#jeu { max-width: 920px; }
.cache { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }

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

/* ------------------------------------------------------------------ boutons */

.principal {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: 100%; min-height: 56px; padding: 12px 22px; cursor: pointer;
  font-weight: 600; font-size: 17px; line-height: 1.2;
  color: var(--sur-accent); background: var(--accent);
  border: 0; border-radius: var(--rayon-petit);
  transition: background .15s ease, transform .1s ease;
}
.principal small { font-size: 12.5px; font-weight: 500; opacity: .78; }
.principal:hover { background: var(--accent-fort); }
.principal:active { transform: scale(.99); }
.principal:disabled { opacity: .45; cursor: not-allowed; }
.principal.compact { width: auto; min-height: 44px; padding: 0 18px; font-size: 15px; }

.secondaire {
  width: 100%; min-height: 48px; padding: 10px 18px; cursor: pointer;
  font-weight: 600; font-size: 15px;
  color: var(--texte); background: var(--surface);
  border: 1px solid var(--bord-fort); border-radius: var(--rayon-petit);
  transition: background .15s ease;
}
.secondaire:hover { background: var(--surface-2); }

.discret {
  padding: 7px 12px; cursor: pointer;
  font-weight: 600; font-size: 14px; color: var(--texte-2);
  background: transparent; border: 0; border-radius: 8px;
}
.discret:hover { color: var(--texte); background: var(--surface-2); }

.segmente {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border-radius: 9px;
}
.segmente button {
  padding: 7px 14px; cursor: pointer; white-space: nowrap;
  font-weight: 600; font-size: 14px; color: var(--texte-2);
  background: transparent; border: 0; border-radius: 7px;
  transition: background .15s ease, color .15s ease;
}
.segmente button:hover { color: var(--texte); }
.segmente button.actif { color: var(--texte); background: var(--surface); box-shadow: var(--ombre); }
.segmente.petit button { padding: 5px 11px; font-size: 13px; }

/* ------------------------------------------------------------------ accueil */

.entete { text-align: center; padding-block: 12px 28px; }
.marque {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 15px; letter-spacing: .01em; color: var(--texte-2);
}
.marque-icone {
  width: 22px; height: 22px; border-radius: 6px; background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%23000'/%3E%3Cg fill='none' stroke='%23fff' stroke-width='2.8' stroke-linecap='round'%3E%3Cpath d='M10 13v6M16 9v14M22 12v8'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%23000'/%3E%3Cg fill='none' stroke='%23fff' stroke-width='2.8' stroke-linecap='round'%3E%3Cpath d='M10 13v6M16 9v14M22 12v8'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat;
}
h1 {
  margin: 18px 0 8px;
  font-size: clamp(28px, 5.4vw, 38px); font-weight: 800; line-height: 1.12; letter-spacing: -.022em;
  text-wrap: balance;
}
.sous-titre { margin: 0 auto; max-width: 46ch; color: var(--texte-2); font-size: 16px; text-wrap: balance; }

.carte-reglages {
  display: flex; flex-direction: column; gap: 6px;
  padding: 6px; background: var(--surface);
  border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre);
}
.reglage {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: var(--rayon-petit);
}
.reglage-texte { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; text-align: left; }
.reglage-titre { font-weight: 600; font-size: 15px; }
.reglage-detail { font-size: 13.5px; color: var(--texte-2); }
.reglage-bouton {
  width: 100%; cursor: pointer; background: transparent; border: 0;
  transition: background .15s ease;
}
.reglage-bouton:hover { background: var(--surface-2); }
.fleche { color: var(--texte-3); font-size: 22px; line-height: 1; }

.apercu-logos { display: flex; align-items: center; gap: 4px; }
.apercu-logos img {
  height: 26px; width: 40px; object-fit: contain;
  filter: grayscale(1) opacity(.7);
}
.apercu-logos .plus { font-size: 12.5px; font-weight: 600; color: var(--texte-3); margin-left: 4px; }
@media (max-width: 520px) { .apercu-logos { display: none; } }

.carte-reglages .principal { margin-top: 4px; }

.lien-defi {
  display: flex; align-items: center; gap: 12px; width: 100%;
  margin-top: 12px; padding: 14px 16px 14px 18px; cursor: pointer; text-align: left;
  background: transparent; border: 1px dashed var(--bord-fort); border-radius: var(--rayon);
  transition: background .15s ease, border-color .15s ease;
}
.lien-defi:hover { background: var(--surface); border-color: var(--accent); }
.lien-defi-titre { font-weight: 600; font-size: 15px; white-space: nowrap; }
.lien-defi-detail { flex: 1; font-size: 13.5px; color: var(--texte-2); }
@media (max-width: 520px) { .lien-defi-detail { display: none; } }

/* --------------------------------------------------------------- classement */

.tableau { margin-top: 40px; }
.tableau-entete {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.tableau h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }

.classement {
  list-style: none; margin: 0; padding: 4px;
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon);
  box-shadow: var(--ombre); counter-reset: rang;
}
.classement li {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px; border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.classement li + li { border-top: 1px solid var(--bord); }
.classement li::before {
  counter-increment: rang; content: counter(rang);
  flex: none; width: 26px; height: 26px; line-height: 26px; text-align: center;
  font-size: 12.5px; font-weight: 700; color: var(--texte-2);
  background: var(--surface-2); border-radius: 7px;
}
.classement li:nth-child(1)::before { color: var(--sur-accent); background: var(--accent); }
.classement .pseudo { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.classement .pts { font-weight: 700; font-size: 17px; }
.classement .sur { font-size: 13px; color: var(--texte-3); margin-left: -8px; }
.classement .vide { display: block; padding: 22px 12px; text-align: center; color: var(--texte-2); font-size: 14px; }

.pied { margin-top: 44px; text-align: center; font-size: 12.5px; color: var(--texte-3); }

/* ------------------------------------------------- panneau des extensions */

.panneau {
  width: min(680px, calc(100vw - 32px)); max-height: min(86vh, 820px);
  padding: 0; border: 0; border-radius: 18px;
  color: var(--texte); background: var(--surface); box-shadow: var(--ombre-haute);
  overflow: hidden;
}
.panneau::backdrop { background: rgba(20, 18, 16, .45); backdrop-filter: blur(6px); }
.panneau-entete {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 22px 14px;
}
.panneau-entete h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.panneau-entete p { margin: 2px 0 0; font-size: 13.5px; color: var(--texte-2); }
.panneau-actions { display: flex; align-items: center; gap: 4px; }
.fermer {
  width: 34px; height: 34px; margin-left: 6px; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--texte-2);
  background: var(--surface-2); border: 0; border-radius: 50%;
}
.fermer:hover { color: var(--texte); background: var(--surface-3); }

.grilleExt {
  overflow-y: auto; max-height: calc(min(86vh, 820px) - 150px);
  padding: 4px 22px 18px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  align-content: start;
}
@media (max-width: 520px) { .grilleExt { grid-template-columns: repeat(2, 1fr); } }
.annee {
  grid-column: 1 / -1;
  margin: 10px 0 -2px; font-size: 12px; font-weight: 700; letter-spacing: .08em;
  color: var(--texte-3);
}
.annee:first-child { margin-top: 0; }

.vignetteExt {
  position: relative; display: flex; flex-direction: column; gap: 7px;
  padding: 10px 10px 11px; cursor: pointer;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 12px;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.vignetteExt:hover { background: var(--surface-3); }
.vignetteExt input { position: absolute; opacity: 0; pointer-events: none; }
.vignetteExt .logo {
  display: grid; place-items: center; aspect-ratio: 3 / 2; width: 100%;
}
.vignetteExt .logo img { width: 92%; height: 92%; object-fit: contain; filter: grayscale(1) opacity(.5); transition: filter .15s ease; }
.vignetteExt .glyphe {
  width: 44%; height: 60%; background: var(--texte-3);
  -webkit-mask: var(--m) center/contain no-repeat; mask: var(--m) center/contain no-repeat;
  transition: background .15s ease;
}
.vignetteExt .libelle-seul { font-size: 15px; font-weight: 700; color: var(--texte-3); }
.vignetteExt .libelle { font-size: 13px; font-weight: 600; line-height: 1.25; color: var(--texte-2); }
.vignetteExt .nb { font-size: 12px; color: var(--texte-3); }
.vignetteExt.on { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.vignetteExt.on .logo img { filter: none; }
.vignetteExt.on .glyphe { background: var(--texte); }
.vignetteExt.on .libelle { color: var(--texte); }
.vignetteExt::after {
  content: ""; position: absolute; top: 8px; right: 8px; width: 20px; height: 20px;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10.5l3.2 3L15 7' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
  border-radius: 50%; opacity: 0; transform: scale(.7); transition: opacity .15s ease, transform .15s ease;
}
.vignetteExt.on::after { opacity: 1; transform: scale(1); }

.panneau-pied {
  display: flex; justify-content: flex-end; padding: 12px 22px 18px;
  border-top: 1px solid var(--bord); background: var(--surface);
}

/* --------------------------------------------------------------------- jeu */

.barre { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.jalons { flex: 1; display: flex; gap: 4px; justify-content: center; }
.jalons i {
  width: 100%; max-width: 22px; height: 6px; border-radius: 3px;
  background: var(--surface-3);
  transition: background .2s ease, transform .2s ease;
}
.jalons i.bon { background: var(--ok); }
.jalons i.rate { background: var(--ko); }
.jalons i.courant { background: var(--accent); transform: scaleY(1.5); }
.compte { min-width: 34px; text-align: right; font-weight: 800; font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.scene { text-align: center; }
.lecture {
  position: relative; display: grid; place-items: center;
  width: 92px; height: 92px; margin: 4px auto 0; cursor: pointer;
  color: var(--sur-accent); background: var(--accent);
  border: 0; border-radius: 50%; box-shadow: var(--ombre);
  transition: background .15s ease, transform .1s ease;
}
.lecture:hover { background: var(--accent-fort); }
.lecture:active { transform: scale(.97); }
.lecture svg { width: 38px; height: 38px; fill: currentColor; }
.lecture .ico-pause { display: none; }
.lecture.joue .ico-play { display: none; }
.lecture.joue .ico-pause { display: block; }
.lecture::before {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid var(--accent); opacity: 0;
}
.lecture.joue::before { animation: onde 1.6s ease-out infinite; }
@keyframes onde { 0% { transform: scale(.92); opacity: .5; } 100% { transform: scale(1.25); opacity: 0; } }

.manche { margin: 14px 0 0; font-weight: 600; font-size: 14px; color: var(--texte-2); }
.consigne { margin: 2px 0 22px; font-size: 13.5px; color: var(--texte-3); min-height: 1.4em; }

/* Les quatre propositions : la carte entière, cadre, stats et texte compris. */
.reponses {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
@media (max-width: 640px) { .reponses { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.reponses button {
  position: relative; padding: 0; cursor: pointer;
  background: transparent; border: 0; border-radius: 10px;
  transition: transform .15s ease, filter .2s ease;
}
.reponses button img {
  display: block; width: 100%; height: auto;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .22));
  transition: filter .2s ease;
}
.reponses button:hover:not(:disabled) { transform: translateY(-5px); }
.reponses button:disabled { cursor: default; }
.reponses { padding-top: 14px; }
.reponses .touche {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%); z-index: 1;
  width: 24px; height: 24px; line-height: 24px; text-align: center;
  font-size: 12px; font-weight: 700; color: var(--texte-2);
  background: var(--surface); border: 1px solid var(--bord-fort); border-radius: 7px;
  box-shadow: var(--ombre);
}
.reponses.revelee button:not(.bonne) img { filter: grayscale(.85) opacity(.4); }
.reponses.revelee button.mauvaise img { filter: grayscale(.4) opacity(.7); }
.reponses .etat {
  position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
  padding: 3px 10px; font-size: 12px; font-weight: 700; border-radius: 99px; white-space: nowrap;
  color: #fff; opacity: 0; transition: opacity .2s ease;
}
.reponses button.bonne .etat { background: var(--ok); opacity: 1; }
.reponses button.mauvaise .etat { background: var(--ko); opacity: 1; }

/* ------------------------------------------------------------------ saisie */

.saisie { position: relative; max-width: 480px; margin: 0 auto; }
.champ-groupe { display: flex; gap: 8px; }
.champ-groupe input {
  flex: 1; min-width: 0; padding: 0 14px; min-height: 44px;
  font: inherit; font-size: 16px; color: var(--texte);
  background: var(--surface); border: 1px solid var(--bord-fort); border-radius: var(--rayon-petit);
}
.champ-groupe input::placeholder { color: var(--texte-3); }
.champ-groupe input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-doux); }

.suggestions {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 5;
  list-style: none; margin: 0; padding: 4px; max-height: 280px; overflow-y: auto; text-align: left;
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon-petit);
  box-shadow: var(--ombre-haute);
}
.suggestions:empty { display: none; }
.suggestions li { padding: 9px 12px; cursor: pointer; border-radius: 7px; font-size: 15px; }
.suggestions li:hover, .suggestions li.vise { background: var(--accent-doux); color: var(--accent-fort); }

/* -------------------------------------------------------------- révélation */

.revelation {
  display: grid; grid-template-columns: 200px 1fr; gap: 24px; align-items: center;
  margin: 26px auto 0; max-width: 560px; padding: 18px;
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon);
  box-shadow: var(--ombre); text-align: left;
  animation: monte .25s ease-out;
}
@keyframes monte { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 560px) { .revelation { grid-template-columns: 1fr; justify-items: center; text-align: center; } }
.revelation img { width: 200px; height: auto; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .25)); }
.revelation.sans-image { grid-template-columns: 1fr; max-width: 480px; text-align: center; }
.revelation.sans-image img { display: none; }
.revelation.sans-image .verdict, .revelation.sans-image .principal { align-self: center; }
.revelation.sans-image .meta { justify-content: center; }
.revelation-texte { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.verdict {
  display: inline-flex; align-self: flex-start; align-items: center; gap: 6px;
  margin: 0 0 6px; padding: 4px 10px; border-radius: 99px;
  font-size: 12.5px; font-weight: 700;
}
@media (max-width: 560px) { .verdict { align-self: center; } }
.verdict.ok { color: var(--ok); background: var(--ok-doux); }
.verdict.ko { color: var(--ko); background: var(--ko-doux); }
.revelation h3 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.015em; line-height: 1.2; text-wrap: balance; }
.meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; font-size: 14px; color: var(--texte-2); }
@media (max-width: 560px) { .meta { justify-content: center; } }
.meta > span:last-child { min-width: 0; }
.meta .icone-ext {
  width: 16px; height: 16px; background: var(--texte-3); flex: none;
  -webkit-mask: var(--m) center/contain no-repeat; mask: var(--m) center/contain no-repeat;
}
.taux { margin: 0; font-size: 13px; color: var(--texte-3); min-height: 1.3em; }
.revelation .principal { margin-top: 12px; width: auto; align-self: flex-start; min-height: 46px; }
@media (max-width: 560px) { .revelation .principal { align-self: stretch; } }

/* ---------------------------------------------------------------- résultat */

.bilan { text-align: center; padding-block: 16px 8px; }
.bilan-titre { margin: 0; font-weight: 600; font-size: 14px; color: var(--texte-2); }
.bilan-score { margin: 4px 0 0; display: flex; align-items: baseline; justify-content: center; gap: 6px; font-variant-numeric: tabular-nums; }
.bilan-score strong { font-size: clamp(64px, 14vw, 88px); font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.bilan-score span { font-size: 24px; font-weight: 600; color: var(--texte-3); }
.bilan-mention { margin: 8px auto 0; max-width: 40ch; font-size: 16px; color: var(--texte-2); text-wrap: balance; }

.enregistrement { max-width: 440px; margin: 22px auto 0; }
.enregistrement label { display: block; margin-bottom: 8px; font-size: 13.5px; font-weight: 600; color: var(--texte-2); }
.rangObtenu { margin: 22px 0 0; text-align: center; font-weight: 700; font-size: 18px; color: var(--accent); }

.recap {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px;
  margin-top: 30px;
}
.recap button {
  position: relative; padding: 0; cursor: pointer;
  background: transparent; border: 0; border-radius: 8px;
  transition: transform .15s ease;
}
.recap button:hover { transform: translateY(-3px); }
.recap img { display: block; width: 100%; height: auto; }
.recap button.ko img { filter: grayscale(.7) opacity(.6); }
.recap .point {
  position: absolute; top: 3%; right: 12%; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--ko);
}
.recap button.ok .point { background: var(--ok); }

.actions-fin {
  display: grid; grid-template-columns: 1fr; gap: 10px;
  max-width: 440px; margin: 28px auto 0;
}
@media (min-width: 560px) { .actions-fin { grid-template-columns: 1.4fr 1fr 1fr; } }

/* -------------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%); z-index: 30;
  padding: 11px 18px; font-size: 14px; font-weight: 500;
  color: var(--surface); background: var(--texte); border-radius: 99px; box-shadow: var(--ombre-haute);
}
