:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --fg: #111111;
  --muted: #5d5a55;
  --line: #111111;
  --accent: #ff5a1f;
  --accent-fg: #111111;
  --accent-soft: rgba(255, 90, 31, 0.14);
  --shadow: 0 4px 0 #111111;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d10;
    --surface: #18181d;
    --fg: #f5f3ee;
    --muted: #a6a29a;
    --line: #f5f3ee;
    --accent-soft: rgba(255, 90, 31, 0.2);
    --shadow: 0 4px 0 #000000;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.35;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(14px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
           calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
.screen { flex: 1; display: flex; flex-direction: column; }
.screen[hidden] { display: none; }
button, a { font: inherit; }

/* Bouton son */
.sound {
  position: fixed; z-index: 20;
  top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right));
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--fg); border: 2px solid var(--line); cursor: pointer;
  opacity: 0.85;
}
.sound .off { display: none; }
.sound.muted .on { display: none; }
.sound.muted .off { display: block; }

/* Accueil */
.home { justify-content: center; gap: 18px; padding-bottom: 8vh; }
.badge {
  align-self: flex-start; background: var(--accent); color: var(--accent-fg);
  font-weight: 900; letter-spacing: 0.18em; font-size: 0.85rem; padding: 6px 12px; border-radius: 6px;
  border: 2px solid var(--line);
}
.home h1 { font-size: clamp(2.5rem, 12vw, 3.4rem); line-height: 0.98; font-weight: 900; letter-spacing: -0.035em; margin: 0; }
.subtitle { font-size: 1.15rem; color: var(--muted); margin: 0 0 14px; font-weight: 600; }

.primary, .secondary {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 58px; padding: 14px 20px;
  border-radius: 16px; border: 2px solid var(--line);
  font-size: 1.12rem; font-weight: 900; letter-spacing: 0.01em; text-decoration: none; cursor: pointer;
  transition: transform 0.12s var(--ease), box-shadow 0.12s var(--ease);
}
.primary { background: var(--accent); color: var(--accent-fg); box-shadow: var(--shadow); }
.secondary { background: var(--surface); color: var(--fg); }
.primary:active, .secondary:active { transform: translateY(3px) scale(0.98); box-shadow: none; }

/* Progression */
.progress { margin: 4px 56px 18px 0; }
.progress-label { display: block; font-size: 0.9rem; font-weight: 800; color: var(--muted); margin-bottom: 8px; letter-spacing: 0.02em; }
.progress-track { height: 8px; background: var(--accent-soft); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; width: 100%; background: var(--accent); transform-origin: left center; transform: scaleX(0); transition: transform 0.4s var(--ease); }

/* Cartes de question */
.stage { position: relative; flex: 1; }
.qcard { width: 100%; will-change: transform, opacity; }
.qcard.leaving { position: absolute; top: 0; left: 0; pointer-events: none; }
.qcard.from-right { transform: translateX(60px); opacity: 0; }
.qcard.from-left { transform: translateX(-60px); opacity: 0; }
.qcard.fade-in { opacity: 0; }
.qcard.enter { transform: none; opacity: 1; transition: transform 0.32s var(--ease), opacity 0.32s var(--ease); }
.qcard.to-left { transform: translateX(-60px); opacity: 0; transition: transform 0.32s var(--ease), opacity 0.24s var(--ease); }
.qcard.to-right { transform: translateX(60px); opacity: 0; transition: transform 0.32s var(--ease), opacity 0.24s var(--ease); }
.qcard.fade-out { opacity: 0; transition: opacity 0.25s ease; }

.question-text { font-size: 1.55rem; line-height: 1.18; font-weight: 900; letter-spacing: -0.015em; margin: 0 0 20px; }
.options { display: flex; flex-direction: column; gap: 12px; }
.option {
  position: relative; display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 60px; padding: 14px 16px 14px 18px; text-align: left;
  background: var(--surface); color: var(--fg);
  border: 2px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  font-size: 1.05rem; font-weight: 700; line-height: 1.25; cursor: pointer; overflow: hidden;
  transition: transform 0.14s var(--ease), box-shadow 0.14s var(--ease), background-color 0.14s ease;
}
.option .label { flex: 1; position: relative; z-index: 1; }
.option .check {
  position: relative; z-index: 1; flex: 0 0 auto; width: 22px; height: 22px;
  opacity: 0; transform: translateX(-14px); transition: transform 0.18s var(--ease), opacity 0.18s ease;
}
.option::before {
  content: ""; position: absolute; inset: 0; background: var(--accent);
  transform: scaleX(0); transform-origin: left center; transition: transform 0.18s var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .option:hover { background: var(--accent-soft); border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 0 var(--line); }
}
.option:active { transform: scale(0.97); box-shadow: 0 1px 0 var(--line); transition-duration: 0.05s; }
.option.selected { border-color: var(--accent); box-shadow: 0 4px 0 var(--accent); }
.option.selected .check { opacity: 1; transform: none; color: var(--accent); }
.option.chosen { color: var(--accent-fg); transform: scale(0.98); box-shadow: 0 2px 0 var(--line); }
.option.chosen::before { transform: scaleX(1); }
.option.chosen .check { opacity: 1; transform: none; color: var(--accent-fg); }

.options.compact { gap: 9px; }
.options.compact .option { min-height: 56px; padding: 10px 14px 10px 16px; }
.options.tight { gap: 8px; }
.options.tight .option { min-height: 56px; padding: 8px 14px 8px 16px; font-size: 1rem; box-shadow: 0 3px 0 var(--line); }

.back {
  align-self: flex-start; margin-top: 14px; min-height: 48px; padding: 12px 0;
  background: none; border: 0; color: var(--muted); font-size: 0.95rem; font-weight: 700; cursor: pointer;
}

/* Final */
.final { justify-content: center; align-items: stretch; gap: 12px; text-align: left; }
.final-label { font-size: 1.3rem; font-weight: 900; margin: 0; text-align: center; letter-spacing: 0.01em; transition: opacity 0.3s ease; }
.final.rolling { justify-content: center; }
.final.revealed .final-label { display: none; }
.flag-wrap { width: 100%; display: flex; justify-content: center; }
.flag {
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: 10px; border: 2px solid var(--line); box-shadow: var(--shadow); background: var(--surface);
}
.final.rolling .flag { width: 62%; }
.final.revealed .flag { animation: pop 0.7s var(--ease) both; }
@keyframes pop {
  0% { transform: scale(0.62); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
.reveal-item { opacity: 0; transform: translateY(16px); transition: opacity 0.45s var(--ease), transform 0.45s var(--ease); }
.reveal-item.shown { opacity: 1; transform: none; }
.final.rolling .reveal-item { display: none; }
.country { font-size: clamp(2.2rem, 11vw, 3rem); line-height: 1.02; font-weight: 900; letter-spacing: -0.03em; margin: 10px 0 0; }
.percent { font-size: 1.35rem; font-weight: 900; margin: 0; color: var(--accent); font-variant-numeric: tabular-nums; }
.sentence { font-size: 1.08rem; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.actions { display: flex; flex-direction: column; gap: 12px; }

.flash { position: fixed; inset: 0; background: #ffffff; opacity: 0; pointer-events: none; z-index: 30; }
.flash.go { animation: flash 0.45s ease-out; }
@keyframes flash { 0% { opacity: 0.85; } 100% { opacity: 0; } }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 25; display: none; }

@media (max-height: 680px) {
  .question-text { font-size: 1.3rem; margin-bottom: 14px; }
  .progress { margin-bottom: 12px; }
  .options.tight { gap: 7px; }
  .options.tight .option { min-height: 56px; padding: 6px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .final.revealed .flag { animation: none; }
  .progress-bar, .option, .option::before, .option .check { transition-duration: 0.01s; }
  .reveal-item { transform: none; }
}
@media (min-width: 600px) { .app { padding-top: 56px; } }
