:root {
  --blue: #1e3a8a;
  --blue-light: #3b5bdb;
  --ok: #22c55e;
  --ok-dark: #16a34a;
  --no: #ef4444;
  --no-dark: #dc2626;
  --ink: #1f2937;
  --muted: #6b7280;
  --card-radius: 22px;
  --shadow-card: 0 18px 40px rgba(15, 23, 42, 0.18);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #1e3a8a 0%, #3b5bdb 55%, #6d8bff 100%);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---- Écrans ---- */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 24px 22px calc(24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}
.screen.is-active { display: flex; }

/* ---- Accueil ---- */
#screen-welcome { position: relative; }
.welcome {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
  color: #fff;
}
.welcome-signature {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  margin: 0;
  text-align: center;
}
.welcome-flag {
  font-size: 48px;
  line-height: 1;
  align-self: center;
  transform-origin: bottom center;
  animation: flag-wave 2.2s ease-in-out infinite;
}
@keyframes flag-wave {
  0%, 100% { transform: rotate(-8deg) translateY(0); }
  25% { transform: rotate(6deg) translateY(-3px); }
  50% { transform: rotate(-5deg) translateY(0); }
  75% { transform: rotate(7deg) translateY(-2px); }
}
.welcome-badge {
  align-self: center;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
}
.welcome-title {
  font-size: 30px;
  line-height: 1.15;
  font-weight: 700;
  margin: 6px 0 0;
}
.welcome-sub {
  font-size: 15px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.86);
  margin: 0 auto;
  max-width: 340px;
}

.name-form {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #fff;
  color: var(--ink);
  padding: 20px;
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  text-align: left;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input {
  font: inherit;
  padding: 13px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus { border-color: var(--blue-light); }
.form-error {
  color: var(--no-dark);
  font-size: 13px;
  margin: -4px 0 0;
  font-weight: 500;
}

.btn-primary {
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  color: #fff;
  background: var(--blue);
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s;
  text-align: center;
  text-decoration: none;
  display: block;
}
.btn-primary:hover { background: var(--blue-light); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary:disabled:hover { background: var(--blue); }

/* ---- Jeu ---- */
.game-header { color: #fff; margin-bottom: 10px; }
.progress { font-size: 14px; font-weight: 600; text-align: center; margin-bottom: 8px; }
.progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 999px;
  transition: width 0.35s ease;
}

.card-stack {
  position: relative;
  z-index: 1;
  flex: 1;
  margin: 8px 0 48px;
  min-height: 300px;
}

.card {
  position: absolute;
  inset: 0;
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-card);
  padding: 30px 26px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  cursor: grab;
  user-select: none;
  touch-action: none;
  will-change: transform;
  transform-origin: center bottom;
  /* transition douce pour le glissement des cartes vers l'avant */
  transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
              box-shadow 0.45s ease;
}
.card:active { cursor: grabbing; }

.card-kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--blue-light);
  margin-bottom: 16px;
}
.card-text {
  font-size: 21px;
  line-height: 1.4;
  font-weight: 500;
  color: var(--ink);
}

/* superposition arrière-plan de la pile */
.card--behind { transform: scale(0.95) translateY(12px); filter: brightness(0.99); }
.card--behind2 { transform: scale(0.9) translateY(22px); filter: brightness(0.97); }

/* étampes OK / NON pendant le swipe */
.stamp {
  position: absolute;
  top: 26px;
  padding: 6px 16px;
  border: 3px solid;
  border-radius: 12px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity 0.05s linear;
  pointer-events: none;
}
.stamp--ok { left: 22px; color: var(--ok-dark); border-color: var(--ok-dark); transform: rotate(-14deg); }
.stamp--no { right: 22px; color: var(--no-dark); border-color: var(--no-dark); transform: rotate(14deg); }

/* voile coloré */
.card-overlay {
  position: absolute;
  inset: 0;
  border-radius: var(--card-radius);
  opacity: 0;
  pointer-events: none;
}
.card-overlay--ok { background: rgba(34, 197, 94, 0.22); }
.card-overlay--no { background: rgba(239, 68, 68, 0.22); }

/* ---- Boutons ronds ---- */
.actions {
  position: relative;
  z-index: 5; /* toujours au-dessus des cartes */
  display: flex;
  justify-content: center;
  gap: 40px;
}
.round-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.1s ease, box-shadow 0.15s;
}
.round-btn:active { transform: scale(0.9); }
.round-btn svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.round-btn--no { background: var(--no); }
.round-btn--no svg { stroke: #fff; }
.round-btn--ok { background: var(--ok); }
.round-btn--ok svg { stroke: #fff; }
.actions-hint {
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 12.5px;
  margin: 12px 0 0;
}

/* ---- Résultats ---- */
.result {
  margin: auto 0;
  text-align: center;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.result-emoji {
  font-size: 64px;
  line-height: 1;
  animation: emoji-pop 0.6s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
}
@keyframes emoji-pop {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  60% { transform: scale(1.2) rotate(6deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.result-title {
  font-size: 26px;
  line-height: 1.25;
  font-weight: 700;
  margin: 0;
  max-width: 360px;
  margin-inline: auto;
}
.result-score {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
}
.result-thanks {
  font-size: 15.5px;
  line-height: 1.5;
  margin: 4px 0 2px;
}
.result-invite {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 2px;
  color: #fff;
}
.btn-contact { background: #fff; color: var(--blue); font-size: 16px; font-weight: 700; }
.btn-contact:hover { background: #f1f5ff; }
.signature {
  margin-top: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
}

/* ---- Confettis ---- */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* ---- Desktop ---- */
@media (min-width: 768px) {
  body { display: grid; place-items: center; }
  .app {
    max-width: 440px;
    min-height: auto;
    height: min(760px, 94dvh);
    background: transparent;
    border-radius: 28px;
  }
  .screen { min-height: 0; border-radius: 28px; }
}
