:root {
  --bg: #0a0507;
  --panel: #16090c;
  --text: #f5f1ee;
  --muted: #cfc6c2;
  --gold: #f5c542;
  --yes: #4ade80;
  --no: #f87171;
  --cw: min(92vw, 380px);
  --ch: clamp(340px, calc(100dvh - 230px), 600px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(ellipse at 50% -10%, #3b0a10 0%, transparent 55%), var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

#app { position: fixed; inset: 0; }
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow-y: auto;
  opacity: 0; visibility: hidden; transform: translateY(18px) scale(0.98);
  transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s 0.6s;
}
.screen.active {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s 0s;
}
#screen-swipe { overflow: hidden; }

/* Tint de fond selon le sens du swipe */
#tint {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0; transition: opacity 0.15s linear;
}

/* Accueil */
#screen-home { justify-content: center; align-items: center; text-align: center; }
.home-wrap { width: 100%; max-width: 560px; }
.home-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 6vw, 3rem); line-height: 1.15;
  margin: 0 0 0.5rem; color: #fff; letter-spacing: 0.02em;
  text-shadow: 0 0 18px rgba(239, 68, 68, 0.55), 0 2px 0 #000;
}
.sub { color: var(--muted); margin: 0 0 2rem; font-size: 1.05rem; }
.users {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 1.1rem 1.2rem;
}
.user {
  width: 124px; padding: 0.5rem; border: 0; border-radius: 16px;
  background: none; color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  min-height: 44px;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.user:hover, .user:focus-visible { transform: translateY(-4px) scale(1.05); }
.avatar {
  width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center;
  font: 700 2.6rem Georgia, serif; color: #fff;
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.35), transparent 45%), var(--c);
  box-shadow: 0 0 0 3px #000a, 0 12px 30px -8px var(--c);
}
.uname { font-weight: 600; font-size: 1.05rem; color: var(--text); }

/* Barre du haut */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  width: 100%; max-width: 560px; margin: 0 auto; flex-wrap: wrap;
}
.link-btn {
  background: none; border: 1px solid #5b2a30; color: var(--text);
  padding: 0.45rem 0.75rem; border-radius: 999px; font-size: 0.9rem;
  cursor: pointer; min-height: 40px;
}
.link-btn:hover { background: #2a0d12; }
.who { font-weight: 700; color: #fff; }

/* Pile de cartes : plein cadre façon Tinder */
.deck-wrap { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; position: relative; z-index: 1; }
.deck { position: relative; width: var(--cw); height: var(--ch); }
.card {
  position: absolute; inset: 0; border-radius: 28px; overflow: hidden;
  background: #000; color: #fff;
  box-shadow: 0 24px 50px -12px #000c, 0 0 0 1px #ffffff14, 0 0 40px -10px rgba(177, 18, 38, 0.45);
  touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: grab; will-change: transform;
}
.card.dragging { cursor: grabbing; }
.card.flying, .card:not(.is-top) { pointer-events: none; }
.card.enter { animation: cardIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
@keyframes cardIn {
  from { opacity: 0; transform: translate3d(0, 60px, 0) scale(0.9) rotate(-5deg); }
}
.media {
  position: absolute; inset: 0; overflow: hidden;
  background: linear-gradient(160deg, #2a0a0e, #7f1d1d 60%, #0a0507);
}
.media img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; pointer-events: none; -webkit-user-drag: none; z-index: 1;
}
.shade {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: linear-gradient(transparent 30%, rgba(5, 2, 3, 0.6) 60%, rgba(5, 2, 3, 0.96) 100%);
}
.fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.4rem; padding: 1rem;
  text-align: center; color: #fff;
}
.ghost { font-size: 3.6rem; filter: drop-shadow(0 0 12px #ef4444); }
.fb-name { font-weight: 700; font-size: 1.1rem; text-shadow: 0 2px 6px #000; }
.body {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 1rem 1.1rem 1.1rem; color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
}
.venue {
  margin: 0; color: #fecaca; font-size: 0.78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em;
}
.title {
  margin: 0.15rem 0 0.5rem; font: 800 1.9rem/1.08 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #fff;
}
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.6rem; }
.chip {
  background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.28);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  color: #fff; padding: 0.25rem 0.65rem; border-radius: 999px; font-size: 0.82rem; font-weight: 600;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.chip-anim { background: rgba(22, 163, 74, 0.85); border-color: #86efac; }
.chip-noanim { background: rgba(127, 29, 29, 0.85); border-color: #fca5a5; }
.chip-nc { background: rgba(75, 85, 99, 0.85); border-color: #d1d5db; }
.chip-gm { background: rgba(74, 222, 128, 0.85); border-color: #bbf7d0; color: #052e16; text-shadow: none; }
.chip-probable { background: rgba(217, 119, 6, 0.9); border-color: #fcd34d; }
.chip-gm-neutral { background: rgba(75, 85, 99, 0.85); border-color: #d1d5db; }
.d-anim-quote { margin: 0.5rem 0 0; color: #fff; font-style: italic; }
.d-anim-quote a { color: #fca5a5; margin-left: 0.3rem; font-style: normal; }
.desc-row { display: flex; align-items: flex-end; gap: 0.6rem; }
.desc {
  margin: 0; flex: 1; min-width: 0; font-size: 0.9rem; line-height: 1.4; color: #fff;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.more, .info {
  position: relative; display: grid; place-items: center; flex: none;
  color: #fff; cursor: pointer; touch-action: manipulation;
  background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.4);
}
.more { width: 44px; height: 44px; border-radius: 50%; font-size: 1.3rem; }
.info {
  position: absolute; top: 40px; right: 14px; z-index: 3;
  width: 44px; height: 44px; border-radius: 50%; font: 700 1.2rem/1 Georgia, serif;
}
.ok6 {
  position: absolute; top: 40px; left: 14px; z-index: 3;
  padding: 0.3rem 0.75rem; border-radius: 999px;
  background: linear-gradient(90deg, #16a34a, #22c55e); color: #fff;
  font-weight: 800; font-size: 0.8rem; letter-spacing: 0.04em; box-shadow: 0 4px 14px -4px #0008;
}
.progress { display: flex; gap: 4px; width: var(--cw); margin: 0 auto 10px; }
.progress span { flex: 1; height: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.28); }
.progress span.on { background: #fff; }
.progress[hidden] { display: none; }
.media img.in-next { animation: photoInNext 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
.media img.in-prev { animation: photoInPrev 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
.media.nudge { animation: photoNudge 0.32s ease-in-out; }
@keyframes photoInNext {
  from { opacity: 0.3; transform: translate3d(12%, 0, 0); }
  to { opacity: 1; transform: none; }
}
@keyframes photoInPrev {
  from { opacity: 0.3; transform: translate3d(-12%, 0, 0); }
  to { opacity: 1; transform: none; }
}
@keyframes photoNudge {
  0%, 100% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(-6px, 0, 0); }
  75% { transform: translate3d(6px, 0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .media img.in-next, .media img.in-prev, .media.nudge { animation: none; }
}

.badge {
  position: absolute; top: 26px; z-index: 2; opacity: 0; pointer-events: none;
  padding: 0.25rem 0.7rem; border: 4px solid; border-radius: 10px; background: #0008;
  font: 900 1.9rem/1 system-ui, sans-serif; letter-spacing: 0.05em;
}
.badge.yes { right: 18px; color: var(--yes); border-color: var(--yes); transform: rotate(12deg); }
.badge.no { left: 18px; color: var(--no); border-color: var(--no); transform: rotate(-12deg); }

/* Boutons d'action */
.actions { display: flex; justify-content: center; gap: 2.2rem; padding: 0.6rem 0 0.2rem; position: relative; z-index: 1; }
.act {
  width: 88px; height: 88px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; font-size: 2rem; color: #fff;
  box-shadow: 0 10px 25px -6px #000; transition: transform 0.15s ease;
}
.act:active { transform: scale(0.88); box-shadow: 0 4px 12px -4px #000; }
.act-no { background: linear-gradient(#ef4444, #b91c1c); border: 2px solid #fecaca; color: #fff; }
.act-yes {
  background: linear-gradient(#22c55e, #15803d); border: 2px solid #bbf7d0;
  animation: heartbeat 2.8s ease-in-out infinite;
}
.act-yes.shake { animation: shake 0.45s ease-in-out; }
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.12); }
  28% { transform: scale(1); }
  42% { transform: scale(1.08); }
  56% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-5px) rotate(-6deg); }
  40% { transform: translateX(5px) rotate(6deg); }
  60% { transform: translateX(-3px) rotate(-3deg); }
  80% { transform: translateX(3px) rotate(3deg); }
}
.hint { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 0.4rem 0 0; }
.empty { text-align: center; color: var(--muted); font-size: 1.05rem; line-height: 1.6; margin: 0; }

/* Résultats */
.res-wrap { width: 100%; max-width: 560px; margin: 0 auto; }
.res-title {
  font-family: Georgia, serif; text-align: center; color: #fff;
  font-size: clamp(1.6rem, 5vw, 2.2rem); margin: 1rem 0 0.2rem;
}
.voters { text-align: center; color: var(--muted); margin: 0 0 1rem; }
.winner { min-height: 40px; }
.w-card[data-id] { cursor: pointer; }
.w-card, .w-tie {
  text-align: center; padding: 1.2rem; border-radius: 20px;
  background: linear-gradient(160deg, #4a0b12, #1a0709);
  border: 1px solid #b11226; box-shadow: 0 0 40px -6px rgba(239, 68, 68, 0.6);
}
.w-card.pop, .w-tie.pop { animation: pop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes pop {
  0% { opacity: 0; transform: scale(0.6) rotate(-4deg); }
  70% { transform: scale(1.06); }
  100% { opacity: 1; transform: none; }
}
.w-kicker { color: var(--gold); text-transform: uppercase; letter-spacing: 0.15em; font-size: 0.8rem; margin: 0; }
.w-name { font-family: Georgia, serif; font-size: 1.7rem; margin: 0.3rem 0; color: #fff; }
.w-venue { color: #f3b4b4; margin: 0; }
.w-likes { font-size: 1.3rem; font-weight: 700; color: #fca5a5; margin: 0.4rem 0 0; }
.w-names { color: #fff; font-weight: 700; margin: 0.4rem 0; }
.w-empty { text-align: center; color: var(--muted); margin: 0.5rem 0; }
.ranking { list-style: none; padding: 0; margin: 1.2rem 0 2rem; display: grid; gap: 0.7rem; }
.rank-btn { width: 100%; margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.rank-item { background: var(--panel); border: 1px solid #3a1418; border-radius: 14px; padding: 0.8rem 1rem; }
.rank-item.top { border-color: var(--gold); box-shadow: 0 0 18px -6px var(--gold); }
.rank-head { display: flex; align-items: center; gap: 0.6rem; }
.pos {
  width: 2rem; height: 2rem; border-radius: 50%; flex: none;
  background: #2a0d12; display: grid; place-items: center; font-weight: 700; color: #fff;
}
.rank-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rank-title strong { color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-title .venue { color: var(--muted); font-size: 0.82rem; }
.score { font-weight: 700; color: var(--gold); white-space: nowrap; }
.nope { color: #fca5a5; font-weight: 500; margin-left: 0.4rem; font-size: 0.9rem; }
.bar { height: 10px; border-radius: 999px; background: #2a0d12; margin: 0.6rem 0 0.5rem; overflow: hidden; }
.fill {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, #7f1d1d, #ef4444);
  transition: width 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.likers { margin: 0; font-size: 0.85rem; color: var(--muted); }

/* Confettis et toast */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; display: none; }
.confetti.on { display: block; }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; max-width: 90vw;
  transform: translate(-50%, 160%); transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: #1c0a0d; color: #fff; border: 1px solid #b11226;
  padding: 0.7rem 1rem; border-radius: 12px;
}
.toast.show { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .act-yes { animation: none !important; }
  .confetti { display: none !important; }
}

/* Fiche détail : bottom-sheet mobile, modale centrée desktop */
.detail { position: fixed; inset: 0; z-index: 70; }
.detail-backdrop {
  position: absolute; inset: 0; background: rgba(5, 2, 3, 0.8);
  opacity: 0; transition: opacity 0.32s ease;
}
.detail.open .detail-backdrop { opacity: 1; }
.detail-panel {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  background: var(--panel); color: var(--text); outline: none;
  transform: translate3d(0, 100%, 0);
  transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.detail.open .detail-panel { transform: none; }
.detail-panel.dragging { transition: none; }
.detail-grip {
  position: absolute; top: 0; left: 50%; z-index: 4; transform: translateX(-50%);
  width: 84px; height: 30px; touch-action: none; cursor: grab;
}
.detail-grip::before {
  content: ""; position: absolute; left: 50%; top: 12px; width: 44px; height: 5px;
  margin-left: -22px; border-radius: 999px; background: var(--muted); opacity: 0.6;
}
.detail-close {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  background: rgba(22, 9, 12, 0.9); border: 1px solid #5b2a30; color: #fff; font-size: 1.1rem;
}
.detail-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.d-media {
  position: relative; height: min(40dvh, 320px); min-height: 180px; overflow: hidden;
  background: linear-gradient(160deg, #2a0a0e, #7f1d1d 60%, #0a0507); touch-action: none;
}
.d-media img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  pointer-events: none; -webkit-user-drag: none; z-index: 1;
}
.d-media::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 35%; z-index: 2;
  background: linear-gradient(transparent, var(--panel)); pointer-events: none;
}
.d-content { padding: 0.8rem 1.2rem max(1.4rem, env(safe-area-inset-bottom)); color: #fff; }
.d-sec { padding: 0.9rem 1.2rem 0; color: #fff; border-bottom: 1px solid #3a1418; }
.d-anim { padding-top: 3.2rem; }
.d-anim-state { margin: 0; font-weight: 700; font-size: 1.05rem; color: #fff; }
.d-anim-kind, .d-anim-det { margin: 0.3rem 0 0; color: var(--muted); }
.d-venue { margin: 0; color: #fecaca; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; }
.d-title { margin: 0.25rem 0 0.4rem; font: 800 1.7rem/1.15 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #fff; }
.d-rating { margin: 0 0 0.6rem; color: var(--muted); font-size: 0.9rem; }
.d-rating .star { color: var(--gold); font-weight: 700; margin-right: 0.5rem; }
.d-h { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--gold); margin: 1.1rem 0 0.4rem; }
.d-chips .chip { background: #2a0d12; border-color: #5b2a30; text-shadow: none; }
.d-desc { margin: 0; line-height: 1.55; color: #fff; }
.d-video { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; }
.d-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.d-gallery {
  display: flex; gap: 0.6rem; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -1.2rem; padding: 0 1.2rem 0.4rem; scrollbar-width: thin;
}
.d-shot {
  flex: none; width: 72%; max-width: 360px; aspect-ratio: 4 / 3; padding: 0; border: 0; border-radius: 14px;
  overflow: hidden; scroll-snap-align: start; cursor: zoom-in; background: #2a0a0e;
}
.d-shot img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.d-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.d-btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0.5rem 0.9rem;
  border-radius: 999px; border: 1px solid #5b2a30; background: #2a0d12; color: #fff;
  text-decoration: none; font-weight: 600; font-size: 0.9rem;
}
.d-src { color: #fff; }
.d-src li { line-height: 1.4; }
.d-src strong { color: var(--gold); }
.d-src-note { color: var(--muted); font-size: 0.85rem; }
.d-alias { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.9rem; }
.d-warn { margin: 0.9rem 0 0; color: #fde68a; font-weight: 600; font-size: 0.9rem; }
.d-reviews { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; color: var(--muted); font-size: 0.9rem; }
.d-addr { margin: 0; color: #fff; }
.d-map { display: inline-flex; margin-top: 0.4rem; color: #fca5a5; min-height: 40px; align-items: center; }
.d-cta {
  display: flex; align-items: center; justify-content: center; margin-top: 1.3rem; min-height: 50px;
  padding: 0.7rem 1.3rem; border-radius: 999px; border: 1px solid #fecaca;
  background: linear-gradient(#22c55e, #15803d); color: #fff; font-weight: 800; text-decoration: none;
}
.lightbox {
  position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, 0.95);
  display: flex; align-items: center; justify-content: center; padding: 12px; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

@media (min-width: 720px) {
  .detail-panel {
    inset: auto; top: 50%; left: 50%;
    width: min(640px, 92vw); max-height: 90dvh; border-radius: 22px; overflow: hidden;
    border: 1px solid #ffffff1f; box-shadow: 0 30px 80px -20px #000;
    transform: translate3d(-50%, -46%, 0) scale(0.96); opacity: 0;
    transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease;
  }
  .detail.open .detail-panel { transform: translate3d(-50%, -50%, 0) scale(1); opacity: 1; }
  .detail-grip { display: none; }
  .d-media { height: 240px; min-height: 0; }
  .d-anim { padding-top: 0.9rem; }
}
