:root {
  --bg: #111827;
  --surface: #1f2937;
  --surface-strong: #374151;
  --text: #f8fafc;
  --accent: #f59e0b;
  --accent-strong: #f97316;
  --success: #22c55e;
  --danger: #ef4444;
  --border: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: radial-gradient(circle at top, rgba(245, 158, 11, 0.16), transparent 40%), #0f172a;
  color: var(--text);
}

button, input, select {
  font: inherit;
}

/* ─── App shell ───────────────────────────────────────────── */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ──────────────────────────────────────────────── */

.app-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem 1.5rem;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  text-align: center;
}

.header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 3rem);
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 0 40px rgba(245, 158, 11, 0.35);
}

.flag-fr {
  display: inline-block;
  width: 1.2em;
  height: 0.85em;
  background: linear-gradient(to right,
    #002395 33.33%,
    #fff    33.33%, #fff 66.66%,
    #ED2939 66.66%
  );
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 0.1em;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.header-subtitle {
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  color: var(--accent);
  font-weight: 500;
}

.header-nav {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.nav-button {
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent;
  color: var(--text);
  padding: 0.8rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.nav-button.active,
.nav-button:hover {
  background: rgba(245, 158, 11, 0.16);
  border-color: var(--accent);
}

/* ─── Main layout — centrage horizontal, flux vertical ────── */

main {
  flex: 1;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.screen {
  display: none;
  width: 100%;
  max-width: 900px;
}

.screen.active {
  display: block;
  animation: fadeIn 0.2s ease both;
}

/* ─── Cards ───────────────────────────────────────────────── */

.hero-card,
.quote-card,
.finish-card,
.details-card,
.scores-card {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--border);
  border-radius: 32px;
  padding: 2.5rem;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ─── Accueil ─────────────────────────────────────────────── */

.modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.hint {
  color: rgba(255,255,255,0.5);
  font-size: 0.95rem;
  margin: 0;
}

/* ─── Boutons globaux ─────────────────────────────────────── */

.mode-button,
.primary-button {
  border: none;
  border-radius: 16px;
  padding: 1rem 1.25rem;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #111827;
  font-weight: 700;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.mode-button:hover,
.primary-button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.mode-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-align: center;
  padding: 1.5rem 1rem;
}

.mode-icon {
  font-size: 2rem;
  line-height: 1;
}

.mode-name {
  font-size: 1rem;
  font-weight: 700;
}

.mode-desc {
  font-size: 0.78rem;
  opacity: 0.75;
  font-weight: 400;
}

.secondary-button {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  border-radius: 16px;
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.secondary-button:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.24);
}

/* ─── Écran de jeu ────────────────────────────────────────── */

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.timer-row {
  font-weight: 700;
  color: var(--accent);
}

.progress-bar-wrap {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: 4px;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.quote-card {
  position: relative;
}

/* Citation : italique, guillemets CSS, bonne lisibilité */
.quote-text {
  font-size: clamp(1.3rem, 1.6vw, 1.85rem);
  line-height: 1.65;
  font-style: italic;
  margin: 0 0 2rem;
  quotes: "\00AB\00A0" "\00A0\00BB";
}

.quote-text::before { content: open-quote; color: var(--accent); }
.quote-text::after  { content: close-quote; color: var(--accent); }

/* ─── Grille de choix ─────────────────────────────────────── */

.choices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}

.choice-button {
  padding: 1.1rem 1.25rem;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  text-align: left;
  border-radius: 18px;
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.choice-letter {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.choice-button:hover:not(:disabled) .choice-letter {
  background: rgba(245, 158, 11, 0.3);
}

.choice-button.selected .choice-letter {
  background: rgba(245, 158, 11, 0.4);
}

.choice-button:hover:not(:disabled) {
  transform: translateY(-2px);
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.4);
}

.choice-button.selected {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.2);
  font-weight: 600;
}

.choice-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.choice-button.selected:disabled {
  opacity: 1;
}

.choice-button--correct,
.choice-button--correct:disabled {
  background: rgba(34, 197, 94, 0.2);
  border-color: var(--success);
  opacity: 1;
}

.choice-button--correct .choice-letter {
  background: rgba(34, 197, 94, 0.45);
}

.choice-button--wrong,
.choice-button--wrong:disabled {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--danger);
  opacity: 1;
}

.choice-button--wrong .choice-letter {
  background: rgba(239, 68, 68, 0.45);
}

/* ─── Contexte inline ─────────────────────────────────────── */

.inline-context {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.9rem;
  animation: fadeIn 0.25s ease both;
}

.inline-context-source {
  margin: 0 0 0.5rem;
  color: rgba(255, 255, 255, 0.55);
  font-style: italic;
}

.inline-context-text {
  margin: 0;
  color: var(--text);
  line-height: 1.6;
}

.next-button {
  display: block;
  margin: 1rem 0 0 auto;
  border: none;
  border-radius: 16px;
  padding: 0.85rem 1.5rem;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #111827;
  font-weight: 700;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.next-button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ─── Feedback ────────────────────────────────────────────── */

@keyframes feedbackIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.feedback {
  margin-top: 1rem;
  min-height: 2.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: 12px;
  padding: 0;
}

.feedback.success {
  color: var(--success);
  background: rgba(34, 197, 94, 0.1);
  padding: 0.7rem 1rem;
  animation: feedbackIn 0.2s ease;
}

.feedback.error {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
  padding: 0.7rem 1rem;
  animation: feedbackIn 0.2s ease;
}

/* ─── Mini-classement inline ──────────────────────────────── */

.mini-leaderboard {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
}

.mini-leaderboard-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 0 0 0.75rem;
  font-weight: 600;
}

.mini-leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.mini-leaderboard-list li {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  gap: 0.5rem;
  font-size: 0.875rem;
  align-items: center;
}

.mini-rank { color: var(--accent); font-weight: 700; }
.mini-score { font-weight: 600; color: var(--text); }
.mini-leaderboard-empty {
  color: rgba(255,255,255,0.35);
  font-size: 0.85rem;
  font-style: italic;
}

/* ─── Score visuel ────────────────────────────────────────── */

.score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem;
  border-radius: 20px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.score-big {
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.score-grade {
  font-size: 1.1rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ─── Écran de fin ────────────────────────────────────────── */

.score-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
}

.score-form input {
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

.finish-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ─── Écran détails ───────────────────────────────────────── */

.detail-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  line-height: 1.6;
}

.details-card a {
  display: inline-block;
  margin-top: 1rem;
  color: var(--accent);
}

/* ─── Classement ──────────────────────────────────────────── */

.scores-filter {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.leaderboard {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.leaderboard li strong {
  color: var(--accent);
}

/* ─── Publicité AdSense ───────────────────────────────────── */

.ad-footer {
  width: 100%;
  max-width: 900px;
  margin: 1.5rem auto 0;
  padding: 1rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  text-align: center;
}

/* ─── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
  .app-header {
    padding: 1.5rem 1rem;
    gap: 1rem;
  }

  .app-header h1 {
    font-size: clamp(1.8rem, 3vw, 2.5rem);
  }

  .header-subtitle {
    font-size: clamp(0.9rem, 1.8vw, 1.2rem);
  }

  .header-nav {
    gap: 0.75rem;
  }

  .nav-button {
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
  }

  main {
    padding: 1.25rem 1rem;
  }

  .hero-card,
  .quote-card,
  .finish-card,
  .details-card,
  .scores-card {
    padding: 1.75rem 1.5rem;
    border-radius: 24px;
  }

  .game-header {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 480px) {
  .ad-footer {
    margin-top: 1rem;
    padding: 0.75rem 0;
    border-radius: 8px;
  }

  .app-header {
    padding: 1rem 0.75rem;
  }

  .header-nav {
    width: 100%;
  }

  .nav-button {
    flex: 1;
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
  }

  main {
    padding: 1rem 0.75rem;
  }

  .hero-card,
  .quote-card,
  .finish-card,
  .details-card,
  .scores-card {
    padding: 1.25rem 1.1rem;
    border-radius: 20px;
  }

  .next-button {
    width: 100%;
    margin-left: 0;
  }

  .choice-button {
    padding: 0.65rem 0.9rem;
    min-height: 44px;
    font-size: 0.92rem;
  }

  .choices-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .quote-text {
    margin-bottom: 1.25rem;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .modes-grid {
    grid-template-columns: 1fr;
  }

  .mode-button {
    padding: 0.85rem 1rem;
  }
}

@media (max-width: 360px) {
  .quote-text {
    font-size: 1.1rem;
  }

  .hero-card,
  .quote-card,
  .finish-card,
  .details-card,
  .scores-card {
    padding: 1rem 0.85rem;
  }
}
