/* La Patate Chaude 💣
   Palette : prune carbonisée, orange braise, jaune mèche, rose choc, vert menthe */
:root {
  --bg: #1e1420;
  --bg-card: #2c1e2e;
  --ink: #fff3e2;
  --ink-dim: #b79fae;
  --ember: #ff6b35;
  --fuse: #ffc53d;
  --shock: #ff3d7f;
  --mint: #3ddc97;
  --k: 0; /* tension 0→1, pilotée par le serveur */
  --amp: 0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow: hidden;
}

/* Vignette rouge qui pulse avec la tension */
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 61, 60, 0.55) 130%);
  opacity: var(--k);
  transition: opacity 0.4s;
}

/* ---------- Écrans ---------- */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.screen.active { display: flex; }

/* ---------- Accueil ---------- */
.logo { text-align: center; }
.logo-bomb {
  font-size: 84px;
  line-height: 1;
  animation: idle-swing 3s ease-in-out infinite;
}
@keyframes idle-swing {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}
h1 {
  font-family: 'Bungee', 'Nunito', sans-serif;
  font-size: clamp(36px, 11vw, 52px);
  line-height: 0.95;
  margin-top: 10px;
  color: var(--fuse);
  text-shadow: 3px 3px 0 var(--ember), 6px 6px 0 rgba(0, 0, 0, 0.35);
  letter-spacing: 1px;
}
.tagline { color: var(--ink-dim); margin-top: 10px; font-size: 15px; }

.card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 20px;
  width: min(340px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.3);
}

input {
  background: var(--bg);
  border: 2px solid #4a3350;
  border-radius: 12px;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  padding: 13px 14px;
  width: 100%;
  outline: none;
  text-align: center;
}
input:focus { border-color: var(--fuse); }
#code { text-transform: uppercase; letter-spacing: 6px; font-weight: 800; }

.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; min-width: 0; }
.join-row .btn { flex: 1.2; }

.btn {
  border: none;
  border-radius: 14px;
  font-family: 'Bungee', 'Nunito', sans-serif;
  font-size: 16px;
  letter-spacing: 0.5px;
  color: var(--bg);
  padding: 15px 18px;
  cursor: pointer;
  transition: transform 0.08s;
}
.btn:active { transform: scale(0.95); }
.btn-hot { background: var(--ember); box-shadow: 0 5px 0 #c24a1e; color: #fff; }
.btn-cool { background: var(--fuse); box-shadow: 0 5px 0 #c79422; }
.btn-mint { background: var(--mint); box-shadow: 0 5px 0 #26a06c; }
.btn-ghost {
  background: transparent;
  border: 2px solid #4a3350;
  color: var(--ink);
  box-shadow: none;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-dim);
  font-size: 13px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background: #4a3350;
  border-radius: 2px;
}

.hint { color: var(--ink-dim); font-size: 13px; text-align: center; }

/* ---------- Salon ---------- */
.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--ink-dim);
  font-weight: 800;
}
.room-code {
  font-family: 'Bungee', sans-serif;
  font-size: 64px;
  letter-spacing: 12px;
  padding-left: 12px; /* compense le letter-spacing du dernier caractère */
  color: var(--fuse);
  text-shadow: 3px 3px 0 var(--ember);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 360px;
}
.chip {
  background: var(--bg-card);
  border-radius: 999px;
  padding: 8px 14px 8px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 15px;
  border: 2px solid transparent;
}
.chip .em { font-size: 20px; }
.chip.host { border-color: var(--fuse); }
.chip.holder {
  border-color: var(--shock);
  background: #47203a;
  animation: chip-shake 0.35s infinite;
}
.chip.dead { opacity: 0.35; filter: grayscale(1); }
@keyframes chip-shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px) rotate(-2deg); }
  75% { transform: translate(2px, -1px) rotate(2deg); }
}

.chips-small .chip { padding: 5px 10px 5px 7px; font-size: 13px; }
.chips-small .chip .em { font-size: 16px; }

/* ---------- Mode équipes ---------- */
.chip.t0 { border-color: var(--shock); }
.chip.t1 { border-color: var(--mint); }

.mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border-radius: 999px;
  padding: 4px;
}
.mode-btn {
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 14px;
  background: transparent;
  color: var(--ink-dim);
}
.mode-btn.on { background: var(--fuse); color: var(--bg); }

.teams-wrap {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 380px;
  justify-content: center;
}
.team-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 16px;
  padding: 12px 8px;
}
.team-name { font-family: 'Bungee', sans-serif; font-size: 13px; letter-spacing: 1px; }
.tn0 { color: var(--shock); }
.tn1 { color: var(--mint); }

#lobby-action { display: flex; flex-direction: column; gap: 10px; align-items: center; }

.wait-note { color: var(--ink-dim); text-align: center; }

/* ---------- Jeu ---------- */
#s-game { justify-content: flex-start; gap: 14px; }
#game-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

#stage {
  flex: 1;
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

/* Spectateur : la bombe chez quelqu'un d'autre */
.spectate { text-align: center; }
.spectate .big-avatar {
  font-size: 110px;
  line-height: 1.1;
  display: inline-block;
  transform: translate(calc(var(--amp) * 1px), 0);
  animation: bomb-shake 0.25s infinite;
}
.spectate .who {
  font-family: 'Bungee', sans-serif;
  font-size: 22px;
  color: var(--shock);
  margin-top: 8px;
}
.spectate .sub { color: var(--ink-dim); margin-top: 6px; }

@keyframes bomb-shake {
  0%, 100% { transform: translate(calc(var(--amp) * -1px), calc(var(--amp) * 0.5px)) rotate(calc(var(--amp) * -0.6deg)); }
  50% { transform: translate(calc(var(--amp) * 1px), calc(var(--amp) * -0.5px)) rotate(calc(var(--amp) * 0.6deg)); }
}

/* Porteur : carte défi */
.challenge {
  background: var(--bg-card);
  border-radius: 20px;
  border: 3px solid var(--shock);
  padding: 22px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.3);
  animation: bomb-shake 0.25s infinite;
}
.challenge h2 {
  font-family: 'Bungee', sans-serif;
  font-size: 19px;
  color: var(--fuse);
  text-align: center;
  line-height: 1.3;
}
.challenge.flash-wrong { animation: wrong-flash 0.4s; }
@keyframes wrong-flash {
  0%, 100% { border-color: var(--shock); }
  50% { border-color: #ff2222; background: #58202a; transform: translateX(-6px); }
}

.you-have-it {
  font-family: 'Bungee', sans-serif;
  color: var(--shock);
  font-size: 16px;
  animation: chip-shake 0.35s infinite;
}

/* Défi : tape ! */
.tap-btn {
  font-size: 30px;
  padding: 28px 20px;
  width: 100%;
  border-radius: 20px;
}
.tap-count { font-family: 'Bungee', sans-serif; font-size: 40px; color: var(--ink); }

/* Défi : mot */
.word-target { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.word-target .slot {
  width: 30px;
  height: 38px;
  border-radius: 8px;
  background: var(--bg);
  border: 2px solid #4a3350;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: var(--mint);
}
.word-target .slot.filled { border-color: var(--mint); }
.letters { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.letter-btn {
  width: 48px;
  height: 52px;
  border-radius: 12px;
  border: none;
  background: var(--fuse);
  box-shadow: 0 4px 0 #c79422;
  font-family: 'Bungee', sans-serif;
  font-size: 22px;
  color: var(--bg);
}
.letter-btn:active { transform: scale(0.9); }
.letter-btn.used { opacity: 0.25; pointer-events: none; }

/* Défi : maths + emoji */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.opt-btn {
  border: none;
  border-radius: 14px;
  background: var(--fuse);
  box-shadow: 0 4px 0 #c79422;
  font-family: 'Bungee', sans-serif;
  font-size: 24px;
  padding: 16px;
  color: var(--bg);
}
.opt-btn:active { transform: scale(0.93); }
.emoji-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; }
.emoji-btn {
  border: none;
  border-radius: 14px;
  background: var(--bg);
  border: 2px solid #4a3350;
  font-size: 32px;
  padding: 10px 0;
}
.emoji-btn:active { transform: scale(0.9); }

/* Défi : mémoire */
.seq-show {
  font-size: 42px;
  letter-spacing: 4px;
  animation: boom-pop 0.4s cubic-bezier(0.2, 2, 0.4, 1);
}

/* Défi : stroop */
.stroop-word {
  font-family: 'Bungee', sans-serif;
  font-size: 46px;
  line-height: 1;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.35);
}
.opt-btn.small { font-size: 15px; padding: 14px 6px; }

/* Défi : comptage */
.count-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: 100%;
  font-size: 28px;
  text-align: center;
}

/* Défi : ordre croissant */
.letter-btn.num { width: 56px; font-size: 18px; }

/* Défi : chrono aveugle */
.hold-time {
  font-family: 'Bungee', sans-serif;
  font-size: 36px;
  min-height: 44px;
  color: var(--ink);
}
.challenge .hint { font-size: 12px; }

/* Choix de la victime */
.picker { width: 100%; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.picker h2 {
  font-family: 'Bungee', sans-serif;
  color: var(--mint);
  font-size: 20px;
  text-align: center;
}
.victim-btn {
  width: 100%;
  border: none;
  border-radius: 16px;
  background: var(--bg-card);
  border: 2px solid var(--shock);
  color: var(--ink);
  font-family: 'Bungee', sans-serif;
  font-size: 20px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.victim-btn:active { transform: scale(0.95); background: #47203a; }

/* ---------- Overlay boum / fin ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 8, 14, 0.92);
  text-align: center;
}
.overlay.active { display: flex; }
.overlay .boom-word {
  font-family: 'Bungee', sans-serif;
  font-size: clamp(60px, 22vw, 110px);
  color: var(--fuse);
  text-shadow: 4px 4px 0 var(--shock), 8px 8px 0 rgba(0, 0, 0, 0.4);
  animation: boom-pop 0.5s cubic-bezier(0.2, 2.5, 0.4, 1);
  line-height: 1;
}
@keyframes boom-pop {
  0% { transform: scale(0.2) rotate(-12deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.overlay .boom-sub { font-size: 20px; font-weight: 800; margin-top: 18px; }
.overlay .boom-emoji { font-size: 72px; margin-top: 14px; }
.overlay .btn { margin-top: 24px; }
.overlay .err { color: var(--shock); font-weight: 800; font-size: 18px; }

/* Bannière transitoire (manche 1, passé à X...) */
.banner {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  z-index: 8;
  background: var(--bg-card);
  border: 2px solid var(--fuse);
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  transition: transform 0.3s cubic-bezier(0.2, 1.6, 0.4, 1);
  pointer-events: none;
}
.banner.show { transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .logo-bomb, .chip.holder, .spectate .big-avatar, .challenge, .you-have-it { animation: none; }
}
