/* Thème sombre inspiré de l'interface Tesla : fond charbon, cartes gris foncé,
   texte blanc, accent bleu Tesla. Tout passe par les variables ci-dessous. */
:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --bg-glow: #161b22;
  --card: #171a20;
  --card-2: #1f242c;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f4f5;
  --muted: #8e939c;
  --blue: #3e6ae1;
  --blue-hi: #5c85f2;
  --ok: #30c26b;
  --ko: #e82127;
  --warn: #f5a623;
  --radius: 22px;
  --radius-sm: 14px;
  --gutter: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 700px at 50% -10%, var(--bg-glow), var(--bg) 70%);
  background-color: var(--bg);
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
  padding: var(--gutter);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Cartes */
.card {
  width: 100%;
  max-width: 960px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  animation: pop 0.3s ease;
}

@keyframes pop {
  from { transform: scale(0.97); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

h1 { font-size: 2rem; font-weight: 700; margin: 0 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 1.4rem; font-weight: 600; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.sub { font-size: 1.05rem; color: var(--muted); margin: 0 0 18px; }
.big-emoji { font-size: 3rem; line-height: 1; margin: 6px 0 10px; }

/* Boutons : pleins, arrondis, sans ombre portée (style Tesla) */
.btn {
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  min-height: 88px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.08s, border-color 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:hover { border-color: rgba(255, 255, 255, 0.2); }
.btn:disabled { cursor: default; }
.btn-big { font-size: 1.6rem; padding: 20px 24px; min-height: 104px; width: 100%; }
.btn-blue { background: var(--blue); border-color: transparent; color: #fff; }
.btn-blue:hover { background: var(--blue-hi); }
.btn-green { background: var(--ok); border-color: transparent; color: #04140b; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); min-height: 64px; font-size: 1.1rem; }
.btn-ghost:hover { color: var(--text); background: var(--card-2); }

/* Bouton de réponse : état après un choix */
.btn.is-ok { background: var(--ok); border-color: transparent; color: #04140b; }
.btn.is-ko { background: var(--ko); border-color: transparent; color: #fff; }
.btn:disabled.is-ok, .btn:disabled.is-ko { opacity: 1; }

/* Champs de saisie */
.field {
  font-family: inherit;
  font-size: 1.4rem;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  outline: none;
}
.field:focus { border-color: var(--blue); }

/* Grilles */
.grid-2, .grid-3, .grid-4 { display: grid; gap: 14px; width: 100%; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-2 > :only-child { grid-column: 1 / -1; } /* un seul jeu : pleine largeur */
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Tuile de jeu : fond sombre, liseré de couleur (--tile) */
.tile {
  background: var(--card-2);
  border: 1px solid var(--line);
  box-shadow: inset 4px 0 0 var(--tile, var(--blue));
  color: var(--text);
}

/* Pastilles de la barre du haut */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.pill {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}
.pill.coins { color: var(--warn); }

/* Barre de progression */
.bar {
  height: 6px;
  background: var(--card-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0 22px;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--blue);
  transition: width 0.4s ease;
  border-radius: 999px;
}

/* Questions */
.question {
  font-size: 3.4rem;
  font-weight: 700;
  margin: 8px 0 22px;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.answers .btn { font-size: 2rem; padding: 18px 10px; }
.feedback { font-size: 1.4rem; font-weight: 600; min-height: 1.6em; margin-top: 16px; }
.feedback.ok { color: var(--ok); }
.feedback.ko { color: var(--ko); }
.streak { font-size: 1rem; color: var(--warn); min-height: 1.2em; }

.hidden { display: none !important; }

/* Étoiles de fin */
.stars { font-size: 2.6rem; margin: 10px 0; letter-spacing: 8px; }
.stars .off { opacity: 0.2; filter: grayscale(1); }
.final { font-size: 2.6rem; font-weight: 700; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.final small { display: block; font-size: 1rem; font-weight: 500; color: var(--muted); margin-top: 4px; }

/* Photo d'outil dans le quiz « Quel outil ? » */
.tool-img {
  display: block;
  max-width: 100%;
  max-height: 38vh;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  object-fit: contain;
  background: #fff;
}

/* Crédits des photos (réglages) */
.credits { text-align: left; font-size: 0.85rem; color: var(--muted); margin-top: 28px; }
.credits h2 { font-size: 1.1rem; color: var(--text); }
.credits li { margin-bottom: 6px; }
.credits a { color: var(--blue-hi); }

/* Pièce ou billet dans une question de monnaie */
.chip {
  display: inline-block;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2px 12px;
  color: var(--warn);
  font-variant-numeric: tabular-nums;
}

/* Bingo : cases de la grille */
.bcell {
  flex-direction: column;
  min-height: 130px;
  gap: 6px;
  padding: 12px 8px;
}
.bcell-emoji { font-size: 2.6rem; line-height: 1; }
.bcell-label { font-size: 1rem; font-weight: 600; color: var(--muted); }
.bcell.is-ok .bcell-label { color: #04140b; }

/* Memory : grille de cartes retournables */
.mgrid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), 1fr);
  gap: 10px;
  width: 100%;
}
.mcard {
  aspect-ratio: 1 / 1;
  perspective: 700px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.mcard .inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.4s ease;
}
.mcard.flip .inner { transform: rotateY(180deg); }
.mcard .face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  font-size: 2.4rem;
}
.mcard .front {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
}
.mcard .back {
  background: var(--card-2);
  border: 1px solid var(--line);
  transform: rotateY(180deg);
}
.mcard.matched .back {
  background: rgba(48, 194, 107, 0.15);
  border-color: var(--ok);
}

/* Cellule d'album (autocollant ou badge) */
.cell {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  font-size: 0.95rem;
}
.cell .icon { font-size: 2.2rem; line-height: 1.1; }
.cell.locked { color: var(--muted); }
.cell.locked .icon { filter: grayscale(1); opacity: 0.35; }

/* Champ prénom et réglages */
.form { text-align: left; max-width: 420px; margin: 0 auto; }
.form label { display: block; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  font-size: 1.15rem;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.toggle-row input { width: 32px; height: 32px; accent-color: var(--blue); }

/* Mascotte (cochon) */
#mascot {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
#mascot .pig { font-size: 2.6rem; }
#mascot .pig.bounce { animation: bounce 0.3s ease; }
#mascot .bubble {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-weight: 600;
  font-size: 0.95rem;
  max-width: 220px;
  opacity: 0;
  transition: opacity 0.3s;
}
#mascot .bubble.show { opacity: 1; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* Barre de trajet, en bas de l'écran */
#trip {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 40;
  pointer-events: none;
}
#trip .trip-bar {
  display: inline-block;
  background: rgba(23, 26, 32, 0.92);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

/* Confettis (couleurs vives, peu nombreux : on reste calme pour le conducteur) */
.confetti {
  position: fixed;
  top: -20px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 99;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

/* Petits écrans */
@media (max-width: 600px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .question { font-size: 2.6rem; }
  .answers .btn { font-size: 1.7rem; }
  h1 { font-size: 1.7rem; }
}

/* Accessibilité : pas d'animations si l'utilisateur le demande */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Jeu « Devine ! » */
.cat-grid .btn { font-size: 1.05rem; min-height: 72px; padding: 10px; }
.clues { text-align: left; font-size: 1.7rem; font-weight: 600; line-height: 1.35; margin: 0 0 22px; padding-left: 1.4em; }
.clues li { margin-bottom: 10px; }
.clues li:not(:last-child) { color: var(--muted); font-size: 1.25rem; }
.word { font-size: 3rem; font-weight: 700; margin: 4px 0 18px; }
.quiz-q { font-size: 1.9rem; font-weight: 700; line-height: 1.3; margin: 4px 0 16px; }
.quiz-answers .btn { font-size: 1.4rem; }
.fact { background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; margin: 16px 0; font-size: 1.25rem; text-align: left; }

/* Message temporaire (autocollant gagné, arrivée) */
.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  background: var(--card, #1d1f24); color: var(--text, #fff);
  border: 2px solid #ffd93d; border-radius: 16px; padding: 14px 24px;
  font-size: 1.4rem; font-weight: 700; z-index: 50;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); animation: toast-in .25s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -12px); } }
