/* Les couleurs et polices sont pilotées par config.js : ne les change pas ici */
:root {
  --fond: #0d0912;
  --accent: #ff7a18;
  --accent-clair: #ffb347;
  --texte: #fff4e6;
  --carte-haut: #2b1836;
  --carte-bas: #170d1f;
  --texte-hasard: #2a0e00;
  --ombre-hasard: #9a3f00;
  --police-titre: "Creepster";
  --police-texte: "Baloo 2";
  --assombrir: .45;
  --hauteur-perso: 160px;
  --bord: rgba(255, 255, 255, .09);
  --ombre: #07040a;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(120% 55% at 50% -12%, color-mix(in srgb, var(--accent) 22%, transparent) 0%, transparent 62%),
    radial-gradient(100% 45% at 50% 112%, #2c1247 0%, transparent 62%),
    var(--fond);
  color: var(--texte);
  font-family: var(--police-texte), system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
  overflow-x: hidden;
}

/* ---------- Fond image ---------- */
.fond {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--image-fond, none) center / cover no-repeat;
}
.fond.actif::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, var(--assombrir));
}

.brume {
  position: fixed;
  inset: -20% -40%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(30% 18% at 20% 70%, rgba(139, 77, 255, .10), transparent 70%),
    radial-gradient(28% 16% at 75% 35%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    radial-gradient(35% 20% at 55% 90%, rgba(139, 77, 255, .08), transparent 70%);
  animation: derive 18s ease-in-out infinite alternate;
}
@keyframes derive {
  from { transform: translate3d(-4%, 0, 0); }
  to   { transform: translate3d(4%, -3%, 0); }
}

header, main { position: relative; z-index: 1; }

/* ---------- En-tête ---------- */
header {
  padding: calc(env(safe-area-inset-top) + 22px) 16px 6px;
  text-align: center;
}

.surtitre {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent-clair);
  opacity: .85;
}
.surtitre:empty { display: none; }

.titre {
  margin: 0;
  font-family: var(--police-titre), var(--police-texte), cursive;
  font-weight: 400;
  font-size: clamp(46px, 14vw, 76px);
  line-height: 1;
  letter-spacing: .03em;
  color: var(--accent);
  text-shadow:
    0 0 22px color-mix(in srgb, var(--accent) 55%, transparent),
    0 4px 0 color-mix(in srgb, var(--accent) 35%, #000);
}

.logo {
  display: block;
  margin: 0 auto;
  width: auto;
  max-width: min(88vw, 520px);
  max-height: 170px;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .5));
}

.sous {
  margin: 8px 0 0;
  font-size: 16px;
  opacity: .78;
}
.sous:empty { display: none; }

.statut {
  display: inline-block;
  margin: 12px 0 0;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(0, 0, 0, .3);
  border: 1px solid rgba(255, 255, 255, .1);
}

.ambiance {
  position: absolute;
  z-index: 3;
  top: calc(env(safe-area-inset-top) + 14px);
  right: 14px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(0, 0, 0, .35);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: .5;
  filter: grayscale(1);
  transition: opacity .2s, filter .2s, box-shadow .2s;
}
.ambiance.active {
  opacity: 1;
  filter: none;
  box-shadow: 0 0 0 2px var(--accent), 0 0 18px color-mix(in srgb, var(--accent) 50%, transparent);
}

/* ---------- Cartes ---------- */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 14px calc(env(safe-area-inset-bottom) + var(--hauteur-perso) + 40px);
}

.grille {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
body[data-cartes="petit"] .grille { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
body[data-cartes="grand"] .grille { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) {
  .grille { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body[data-cartes="petit"] .grille { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  body[data-cartes="grand"] .grille { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.carte {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 136px;
  padding: 14px 14px 13px;
  border-radius: 22px;
  border: 1px solid var(--bord);
  background: linear-gradient(160deg, var(--carte-haut), var(--carte-bas));
  color: var(--texte);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--ombre), 0 12px 26px rgba(0, 0, 0, .45);
  transition: transform .07s ease, box-shadow .07s ease, border-color .2s;
  animation: entree .45s cubic-bezier(.2, .8, .3, 1.2) both;
  animation-delay: var(--d, 0ms);
}
.carte:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 var(--ombre), 0 4px 12px rgba(0, 0, 0, .4);
}

.visuel { display: block; line-height: 1; }
.emoji {
  display: inline-block;
  font-size: 36px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .45));
}

/* Carte avec image */
.carte.avec-image { padding: 8px 8px 12px; gap: 10px; }
.carte.avec-image .visuel {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 15px;
  overflow: hidden;
  background: rgba(0, 0, 0, .25);
}
.carte.avec-image .visuel img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.carte.avec-image .texte { padding: 0 6px; }
body.sans-texte .carte.avec-image { padding: 6px; }
body.sans-texte .carte.avec-image .texte { display: none; }

.texte {
  font-weight: 700;
  font-size: 16.5px;
  line-height: 1.18;
}
body[data-cartes="petit"] .texte { font-size: 13.5px; }
body[data-cartes="petit"] .emoji { font-size: 28px; }
body[data-cartes="grand"] .texte { font-size: 20px; }

.badge {
  position: absolute;
  top: 11px;
  right: 12px;
  z-index: 1;
  font-size: 13px;
  opacity: .6;
  text-shadow: 0 1px 3px #000;
}
body.sans-badges .badge { display: none; }

/* Carte qui parle */
.carte.joue {
  border-color: var(--accent);
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 30%, var(--carte-haut)), var(--carte-bas));
  box-shadow:
    0 0 0 2px var(--accent),
    0 0 32px color-mix(in srgb, var(--accent) 55%, transparent),
    0 6px 0 var(--ombre);
}
.carte.joue .emoji { animation: parle .32s ease-in-out infinite alternate; }
.carte.joue .visuel img { animation: pulse .32s ease-in-out infinite alternate; }

/* Roulette du bouton hasard */
.carte.vise {
  border-color: var(--accent-clair);
  box-shadow: 0 0 0 3px var(--accent-clair), 0 0 26px color-mix(in srgb, var(--accent-clair) 60%, transparent), 0 6px 0 var(--ombre);
  transform: scale(1.03);
}

@keyframes parle {
  from { transform: scale(1) rotate(-6deg); }
  to   { transform: scale(1.2) rotate(6deg); }
}
@keyframes pulse {
  from { transform: scale(1); }
  to   { transform: scale(1.06); }
}
@keyframes entree {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Barre du bas ---------- */
.barre {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(to top, var(--fond) 55%, color-mix(in srgb, var(--fond) 0%, transparent));
  pointer-events: none;
}
.barre-interieur {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 728px;
  margin: 0 auto;
}

.perso {
  position: relative;
  flex: 0 0 auto;
  width: calc(var(--hauteur-perso) * .72);
  height: 64px;
  pointer-events: auto;
  cursor: pointer;
}
.perso img {
  position: absolute;
  left: 50%;
  bottom: -6px;
  height: var(--hauteur-perso);
  width: auto;
  max-width: none;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .55));
}
.perso .perso-parle { opacity: 0; }
.perso.bouche .perso-parle { opacity: 1; }
.perso.bouche.a-bouche .perso-repos { opacity: 0; }
.perso.parle img { animation: sautille .26s ease-in-out infinite alternate; }

@keyframes sautille {
  from { transform: translateX(-50%) rotate(-2deg) scaleY(1); }
  to   { transform: translateX(-50%) rotate(2deg) scaleY(1.04); }
}

.hasard {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 64px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--accent-clair), var(--accent));
  color: var(--texte-hasard);
  font: 800 21px var(--police-texte), system-ui, sans-serif;
  letter-spacing: .01em;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 6px 0 var(--ombre-hasard), 0 14px 32px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform .07s ease, box-shadow .07s ease;
}
.hasard:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 var(--ombre-hasard), 0 6px 16px color-mix(in srgb, var(--accent) 30%, transparent);
}
.hasard-icone { height: 40px; width: auto; }
.hasard.roule .hasard-de,
.hasard.roule .hasard-icone { animation: tourne .5s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

/* Sans bouton hasard : le perso seul, centré, sert de bouton */
body.sans-hasard .barre-interieur { justify-content: center; }
body.sans-hasard .perso { width: calc(var(--hauteur-perso) * .8); height: 40px; }
body.sans-hasard .barre { padding-top: 10px; }
.perso.roule img { animation: secoue .1s linear infinite alternate; }
@keyframes secoue {
  from { transform: translateX(-50%) rotate(-4deg); }
  to   { transform: translateX(-50%) rotate(4deg); }
}

/* ---------- Écran de départ ---------- */
.depart {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 20px) 20px calc(env(safe-area-inset-bottom) + 24px);
  background: color-mix(in srgb, var(--fond) 62%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: opacity .35s ease, transform .35s ease;
}
.depart.sortie { opacity: 0; transform: scale(1.06); pointer-events: none; }

.depart-contenu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 520px;
  text-align: center;
}
.depart-logo {
  width: auto;
  max-width: 90%;
  max-height: 24vh;
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, .55));
}
.depart-perso {
  width: auto;
  max-width: 90%;
  max-height: 46vh;
  filter: drop-shadow(0 12px 26px rgba(0, 0, 0, .6));
  animation: flotte 2.4s ease-in-out infinite alternate;
}
@keyframes flotte {
  from { transform: translateY(0) rotate(-1.5deg); }
  to   { transform: translateY(-10px) rotate(1.5deg); }
}

.bouton-depart {
  width: min(100%, 360px);
  height: 72px;
  border: 0;
  border-radius: 22px;
  background: linear-gradient(180deg, var(--accent-clair), var(--accent));
  color: var(--texte-hasard);
  font: 800 24px var(--police-texte), system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 7px 0 var(--ombre-hasard), 0 16px 40px color-mix(in srgb, var(--accent) 45%, transparent);
  animation: appel 1.2s ease-in-out infinite;
}
.bouton-depart:active { transform: translateY(6px); box-shadow: 0 1px 0 var(--ombre-hasard); }
@keyframes appel {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

/* ---------- Aide installation ---------- */
.depart { overflow-y: auto; }
.bouton-installer {
  width: min(100%, 360px);
  height: 52px;
  margin-top: -4px;
  border: 2px solid rgba(255, 255, 255, .22);
  border-radius: 18px;
  background: rgba(0, 0, 0, .3);
  color: var(--texte);
  font: 700 17px var(--police-texte), system-ui, sans-serif;
  cursor: pointer;
}
.bouton-installer:active { background: rgba(255, 255, 255, .1); }

.bulle-install {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, .55);
  animation: apparait .2s ease-out both;
}
.bulle {
  position: absolute;
  left: 16px;
  right: 16px;
  max-width: 400px;
  margin: 0 auto;
  padding: 14px 18px;
  border-radius: 16px;
  background: #fff;
  color: #1a1a1a;
  font: 600 16px/1.4 var(--police-texte), system-ui, sans-serif;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.bulle b { color: #000; font-weight: 800; }
.bulle .ico-partage { width: 19px; height: 19px; vertical-align: -4px; color: #0a7aff; }
.bulle-install.bas .bulle { bottom: calc(env(safe-area-inset-bottom) + 46px); }
.bulle-install.haut .bulle { top: calc(env(safe-area-inset-top) + 46px); }
.fleche {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
}
.bulle-install.bas .fleche {
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  border-top: 20px solid #fff;
  animation: rebond-bas .7s ease-in-out infinite alternate;
}
.bulle-install.haut .fleche {
  top: calc(env(safe-area-inset-top) + 14px);
  border-bottom: 20px solid #fff;
  animation: rebond-haut .7s ease-in-out infinite alternate;
}
.fleche.centre { left: calc(50% - 14px); }
.fleche.droite { right: 20px; }
@keyframes rebond-bas { to { transform: translateY(8px); } }
@keyframes rebond-haut { to { transform: translateY(-8px); } }
@keyframes apparait { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .brume, .carte, .carte.joue .emoji, .carte.joue .visuel img,
  .perso.parle img, .depart-perso, .bouton-depart { animation: none; }
}
