/* ═══════════════════════════════════════════════════════════════
   KILL / SAVE — style.css (mobile-first)
   Palette tirée de killsave.com : noir, navy #0f1a2e, magenta glitch,
   rouge, bleu profond, gris techniques. Typo : JetBrains Mono.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg:        #000000;
  --panel:     #0f1a2e;
  --panel-2:   #0a1220;
  --line:      #212a3d;
  --grey:      #949494;
  --grey-2:    #576486;
  --grey-3:    #646464;
  --text:      #ffffff;
  --kill:      #df3131;
  --kill-glow: rgba(223, 49, 49, .55);
  --save:      #ff00e7;
  --save-glow: rgba(255, 0, 231, .55);
  --blue:      #3100c7;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --hud-h: 44px;
  --dock-h: 64px;
  --gutter: 16px;
  --radius: 4px;
  --ease: cubic-bezier(.2, .9, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  color-scheme: dark;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
b { font-weight: 800; }
[hidden] { display: none !important; }

.accent { color: var(--save); }
.kill { color: var(--kill); }
.save { color: var(--save); }

/* ── Scanlines ────────────────────────────────────────────────── */
.scanlines {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom, transparent 0 2px, rgba(0,0,0,.18) 2px 3px
  );
  opacity: .5;
}
@media (max-width: 479px) { .scanlines { opacity: .28; } }
@media (prefers-reduced-motion: reduce) { .scanlines { display: none; } }

/* ── Boutons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  background: transparent; color: var(--text);
  border: 1px solid var(--grey-2); border-radius: var(--radius);
  font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  transition: border-color .15s, background .15s, color .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) { border-color: var(--text); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn--primary { background: var(--save); border-color: var(--save); color: #000; }
.btn--primary:hover:not(:disabled) {
  background: #fff; border-color: #fff;
  box-shadow: 0 0 18px var(--save-glow);
}
.btn--dock { width: 100%; min-height: 48px; }
.link {
  background: none; border: 0; padding: 0;
  color: var(--grey); text-decoration: underline; text-underline-offset: 3px;
  letter-spacing: .05em;
}
.link:hover { color: var(--text); }

/* ── Glitch text ─────────────────────────────────────────────── */
.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after {
  content: attr(data-glitch);
  position: absolute; inset: 0;
  overflow: hidden; pointer-events: none;
  clip-path: inset(0 0 100% 0);
}
.glitch::before { color: var(--save); left: 2px; animation: glitch-a 3.2s infinite steps(1); }
.glitch::after  { color: var(--kill); left: -2px; animation: glitch-b 3.2s infinite steps(1); }
@keyframes glitch-a {
  0%, 92%, 100% { clip-path: inset(0 0 100% 0); }
  93% { clip-path: inset(10% 0 60% 0); transform: translateX(-3px); }
  95% { clip-path: inset(60% 0 10% 0); transform: translateX(3px); }
  97% { clip-path: inset(40% 0 40% 0); transform: translateX(-1px); }
}
@keyframes glitch-b {
  0%, 92%, 100% { clip-path: inset(0 0 100% 0); }
  94% { clip-path: inset(70% 0 5% 0);  transform: translateX(3px); }
  96% { clip-path: inset(20% 0 55% 0); transform: translateX(-3px); }
  98% { clip-path: inset(45% 0 35% 0); transform: translateX(2px); }
}
@media (prefers-reduced-motion: reduce) {
  .glitch::before, .glitch::after { display: none; }
}

/* ── HUD (header sticky) ─────────────────────────────────────── */
.hud {
  position: sticky; top: 0; z-index: 40;
  height: var(--hud-h);
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  padding: 0 var(--gutter);
  background: rgba(0,0,0,.88);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.hud__brand {
  color: var(--text); text-decoration: none;
  font-weight: 800; font-size: 12px; letter-spacing: .05em;
  white-space: nowrap;
}
.hud__meta { display: flex; gap: 12px; font-size: 11px; letter-spacing: .1em; color: var(--grey); }
.hud__status { color: var(--grey-2); }
.hud__count { color: var(--text); font-weight: 700; }
.hud__bar {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--line);
}
.hud__bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--kill), var(--save));
  box-shadow: 0 0 8px var(--save-glow);
  transition: width .35s var(--ease);
}

/* ── HERO ────────────────────────────────────────────────────── */
.hero {
  min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center;
  padding: calc(var(--gutter) * 2) var(--gutter);
  padding-bottom: calc(var(--gutter) * 2 + env(safe-area-inset-bottom));
  position: relative;
}
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 50% 110%, rgba(49, 0, 199, .35), transparent 70%),
    radial-gradient(ellipse 50% 40% at 100% 0%, rgba(255, 0, 231, .12), transparent 70%);
}
.hero__tag, .end__tag {
  margin: 0 0 20px; font-size: 11px; letter-spacing: .18em; color: var(--grey-2);
}
.hero__title {
  margin: 0 0 24px;
  font-size: clamp(28px, 9vw, 72px);
  font-weight: 800; line-height: 1; letter-spacing: -.02em;
}
.hero__lead {
  margin: 0 0 28px;
  font-size: clamp(16px, 4.5vw, 22px); line-height: 1.35;
}
.hero__rules {
  margin: 0 0 32px; padding: 0 0 0 1.6em;
  color: var(--grey); font-size: 13px; line-height: 1.7;
  border-left: 1px solid var(--line); list-style-position: outside;
}
.hero__rules li::marker { color: var(--grey-2); }
.hero .btn--primary { align-self: flex-start; }
.hero__foot { margin: 24px 0 0; font-size: 12px; color: var(--grey-2); letter-spacing: .05em; }

/* ── FEED / DUO ─────────────────────────────────────────────── */
/* Le HUD sticky occupe déjà --hud-h dans le flux : la scène prend le reste, sans déborder. */
.stage {
  min-height: calc(100dvh - var(--hud-h));
  display: flex; flex-direction: column;
}
.feed { flex: 1; display: flex; flex-direction: column; justify-content: center; position: relative; }

.duo {
  display: none;
  flex-direction: column; justify-content: center;
  gap: 18px;
  padding: 16px var(--gutter) calc(var(--dock-h) + 16px + env(safe-area-inset-bottom));
  outline: none;
}
.duo.is-active { display: flex; animation: duo-in .32s var(--ease) both; }
.duo.is-active.from-prev { animation-name: duo-in-rev; }
@keyframes duo-in     { from { opacity: 0; transform: translateX(32px); } to { opacity: 1; transform: none; } }
@keyframes duo-in-rev { from { opacity: 0; transform: translateX(-32px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .duo.is-active { animation: none; } }

/* Nav retour / suivant */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: 8px var(--gutter) calc(8px + env(safe-area-inset-bottom));
  background: rgba(0,0,0,.9); border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.nav__btn { min-height: 48px; padding: 0 12px; font-size: 12px; }
.nav__btn:first-child { justify-self: start; }
.nav__btn:last-child  { justify-self: end; }
#btn-next.is-ready { background: var(--save); border-color: var(--save); color: #000; }
.nav__pos { font-size: 11px; letter-spacing: .15em; color: var(--grey-2); white-space: nowrap; }
.duo__head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; letter-spacing: .15em; color: var(--grey-2);
}
.duo__num b { color: var(--text); }
.duo__cat { text-transform: uppercase; }

.duo__pair {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px;
}
.duo__vs {
  align-self: center; color: var(--grey-2); font-weight: 800; font-size: 14px;
  padding-top: 0;
}

/* Personnage */
.char { margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; cursor: pointer; }
.char__frame {
  position: relative; aspect-ratio: 1 / 1; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s, filter .3s, transform .3s var(--ease);
}
.char__ph {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background:
    repeating-linear-gradient(135deg, transparent 0 6px, rgba(255,255,255,.025) 6px 7px),
    linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  color: var(--grey-2);
}
.char__ph-ini { font-size: clamp(32px, 12vw, 64px); font-weight: 800; letter-spacing: -.04em; color: var(--grey); }
.char__ph-name { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; }
.char__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 15%; opacity: 0; transition: opacity .3s; }
.char[data-fit="contain"] .char__img { object-fit: contain; padding: 6%; }
.char__img.is-loaded { opacity: 1; }
.char__frame:has(.char__img.is-loaded) .char__ph-ini,
.char__frame:has(.char__img.is-loaded) .char__ph-name { opacity: 0; }
.char__x {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s;
  background:
    linear-gradient(45deg,  transparent calc(50% - 1.5px), var(--kill) calc(50% - 1.5px), var(--kill) calc(50% + 1.5px), transparent calc(50% + 1.5px)),
    linear-gradient(-45deg, transparent calc(50% - 1.5px), var(--kill) calc(50% - 1.5px), var(--kill) calc(50% + 1.5px), transparent calc(50% + 1.5px));
}
.char__name {
  font-weight: 700; font-size: clamp(12px, 3.6vw, 15px); line-height: 1.2;
  text-align: center; overflow-wrap: anywhere;
}
.char__verdict {
  min-height: 1.4em; text-align: center;
  font-size: 11px; font-weight: 800; letter-spacing: .25em;
  color: transparent; transition: color .2s;
}

/* États du personnage */
.char.is-kill .char__frame { border-color: var(--kill); box-shadow: 0 0 0 1px var(--kill), 0 0 18px var(--kill-glow); transform: scale(.96); }
.char.is-kill .char__ph, .char.is-kill .char__img { filter: grayscale(1) brightness(.55) contrast(1.1); }
.char.is-kill .char__x { opacity: 1; }
.char.is-kill .char__verdict { color: var(--kill); }
.char.is-kill .char__name { color: var(--grey); text-decoration: line-through; text-decoration-color: var(--kill); }
.char.is-save .char__frame { border-color: var(--save); box-shadow: 0 0 0 1px var(--save), 0 0 22px var(--save-glow); }
.char.is-save .char__verdict { color: var(--save); }
.char.is-save .char__name { color: var(--text); }

/* Switch */
.switch { display: flex; flex-direction: column; gap: 10px; outline: none; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.switch__rail {
  position: relative; height: 56px;
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--panel-2); border: 1px solid var(--grey-2); border-radius: 999px;
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.switch:focus-visible .switch__rail { border-color: var(--text); box-shadow: 0 0 0 3px rgba(255,255,255,.12); }
.switch__side {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 8px; min-width: 0;
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--grey); transition: color .2s, background .25s, opacity .2s;
}
.switch__word { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch__tag {
  font-size: 9px; letter-spacing: .25em; padding: 3px 6px; border-radius: 999px;
  border: 1px solid currentColor; opacity: 0; transform: scale(.8); transition: opacity .2s, transform .2s var(--ease);
}

/* Le curseur = l'étiquette KILL. On le glisse sur le nom de celui qui meurt. */
.switch__knob {
  position: absolute; top: 4px; bottom: 4px; width: 42%;
  left: 29%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--grey-3); border-radius: 999px;
  color: #000; font-weight: 800; font-size: 12px; letter-spacing: .3em;
  box-shadow: 0 2px 8px rgba(0,0,0,.6);
  transition: left .28s var(--ease), background .2s, box-shadow .2s, color .2s, width .28s var(--ease);
  will-change: left;
}
.switch__knob-ico { font-size: 16px; letter-spacing: 0; }
.switch.is-dragging .switch__knob { transition: background .2s; }
.switch__hint { margin: 0; text-align: center; font-size: 10px; letter-spacing: .1em; color: var(--grey-2); transition: opacity .2s; }

.switch[data-state] .switch__knob { background: var(--kill); color: #fff; box-shadow: 0 0 16px var(--kill-glow); width: 50%; }
.switch[data-state="L"] .switch__knob { left: 4px; }
.switch[data-state="R"] .switch__knob { left: calc(50% - 4px); }
.switch[data-state] .switch__rail { border-color: var(--grey); }
.switch[data-state] .switch__hint { opacity: 0; }

/* Côté couvert par KILL : nom masqué. Côté libre : nom en magenta + tag SAVE. */
.switch[data-state="L"] .switch__side--left,
.switch[data-state="R"] .switch__side--right { opacity: 0; }
.switch[data-state="L"] .switch__side--right,
.switch[data-state="R"] .switch__side--left  { color: var(--save); background: rgba(255,0,231,.08); }
.switch[data-state="L"] .switch__side--right .switch__tag,
.switch[data-state="R"] .switch__side--left .switch__tag { opacity: 1; transform: none; }

/* Flash à la validation */
.duo.is-flash .duo__pair { animation: flash .35s steps(2) 1; }
@keyframes flash { 50% { filter: invert(1) hue-rotate(180deg); } }
@media (prefers-reduced-motion: reduce) { .duo.is-flash .duo__pair { animation: none; } }

/* ── END ─────────────────────────────────────────────────────── */
.end {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 16px;
  min-height: calc(100dvh - var(--hud-h));
  padding: 12px var(--gutter) calc(24px + env(safe-area-inset-bottom));
  position: relative;
}
.end__links { display: flex; gap: 20px; margin-top: 8px; font-size: 12px; }
.end::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(ellipse 70% 50% at 50% 0%, rgba(223,49,49,.18), transparent 70%);
}
.end__title { margin: 0; font-size: clamp(26px, 8vw, 56px); font-weight: 800; line-height: 1; }
.end__lead { margin: 0 0 8px; color: var(--grey); }

/* ── MODALE ──────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.92);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  overflow-y: auto;
}
.modal__inner {
  width: 100%; max-width: 560px;
  background: var(--bg); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 8px 8px 0 0;
  padding: 16px var(--gutter) calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
  max-height: 100dvh; overflow-y: auto;
}
.modal__head { display: flex; align-items: center; justify-content: space-between; }
.modal__head h2 { margin: 0; font-size: 13px; letter-spacing: .15em; }
.modal__close { background: none; border: 1px solid var(--line); border-radius: var(--radius); width: 36px; height: 36px; color: var(--grey); }
.modal__preview {
  width: 100%; aspect-ratio: 1080 / 1350;
  max-height: 55dvh;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: var(--panel-2);
  display: flex; align-items: center; justify-content: center;
}
.modal__preview canvas { width: auto; height: 100%; max-width: 100%; object-fit: contain; }
.modal__actions { display: flex; flex-direction: column; gap: 8px; }
.modal__actions .btn { width: 100%; }
.modal__actions .link { align-self: center; margin-top: 4px; font-size: 12px; }

/* ── Tablette ────────────────────────────────────────────────── */
@media (min-width: 480px) {
  :root { --gutter: 24px; }
  body { font-size: 15px; }
  .duo__pair { gap: 14px; }
  .switch__side { font-size: 13px; }
  .char__name { font-size: 16px; }
  .modal { align-items: center; padding: 24px; }
  .modal__inner { border-radius: 8px; border-bottom: 1px solid var(--line); }
}

/* ── Desktop ─────────────────────────────────────────────────── */
@media (min-width: 900px) {
  :root { --gutter: 32px; --hud-h: 52px; }
  .hud { padding: 0 48px; }
  .hud__brand { font-size: 14px; }
  .hud__meta { font-size: 12px; }

  .hero, .end { align-items: center; text-align: center; }
  .hero__rules { text-align: left; }
  .hero .btn--primary { align-self: center; }

  .stage { justify-content: center; }
  .feed { flex: 0 0 auto; }
  .duo {
    width: 100%; max-width: 680px; margin: 0 auto;
    padding: 24px 0 20px;
    gap: 20px;
  }
  .char__frame { max-width: 260px; margin: 0 auto; }
  .char { align-items: center; }
  .nav {
    position: static; width: 100%; max-width: 680px; margin: 0 auto 32px;
    background: none; border: 0; backdrop-filter: none; padding: 0;
  }
  .nav__btn { min-width: 160px; }
  .duo__pair { gap: 24px; }
  .duo__vs { font-size: 20px; }
  .char__name { font-size: 18px; }
  .char__verdict { font-size: 12px; }
  .char:hover .char__frame { border-color: var(--grey); }
  .switch__rail { height: 60px; }
  .switch__side { font-size: 13px; }
  .switch__knob { font-size: 13px; }
  .switch__hint { font-size: 11px; }

  .modal__inner { max-width: 640px; }
  .modal__preview { max-height: 60dvh; }
  .modal__actions { flex-direction: row; flex-wrap: wrap; }
  .modal__actions .btn { width: auto; flex: 1; }
  .modal__actions .link { width: 100%; }
}
