:root {
  --bg: #05050a;
  --cyan: #00f6ff;
  --pink: #ff2bd6;
  --yellow: #f8ff2b;
  --text: #cfefff;
  --player-color: #00f6ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Orbitron', sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.hidden { display: none !important; }

/* ---------- TV / host ---------- */
#arena {
  position: fixed;
  inset: 0;
  display: block;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: rgba(5, 5, 10, 0.85);
  text-align: center;
}

.title {
  font-size: 3.2vw;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--cyan);
  text-shadow: 0 0 12px var(--cyan), 0 0 32px var(--cyan);
  margin: 0;
}
.title span { color: var(--pink); text-shadow: 0 0 12px var(--pink), 0 0 32px var(--pink); }

.lobby-grid {
  display: flex;
  gap: 60px;
  align-items: center;
}

.qr-box {
  background: #fff;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 0 24px var(--cyan);
}
.qr-box img { display: block; width: 220px; height: 220px; }
.qr-box p { color: #111; font-size: 12px; margin: 8px 0 0; word-break: break-all; }

.players-box { min-width: 280px; text-align: left; }
.players-box h2 { color: var(--cyan); text-shadow: 0 0 8px var(--cyan); margin-bottom: 12px; }
#players-list { list-style: none; padding: 0; margin: 0 0 20px; max-height: 30vh; overflow-y: auto; }
#players-list li {
  padding: 8px 12px;
  margin-bottom: 6px;
  border-left: 4px solid var(--item-color, var(--cyan));
  background: rgba(255,255,255,0.04);
  font-size: 1.1em;
}

button {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: transparent;
  border: 2px solid var(--cyan);
  color: var(--cyan);
  padding: 12px 28px;
  border-radius: 6px;
  cursor: pointer;
  text-shadow: 0 0 6px var(--cyan);
  box-shadow: 0 0 12px rgba(0, 246, 255, 0.4);
  transition: transform 0.1s, opacity 0.2s;
}
button:disabled { opacity: 0.35; cursor: not-allowed; }
button:not(:disabled):active { transform: scale(0.96); }

#countdown-number {
  font-size: 18vw;
  font-weight: 900;
  color: var(--yellow);
  text-shadow: 0 0 20px var(--yellow), 0 0 60px var(--yellow);
}

#winner-name {
  font-size: 4vw;
  color: var(--yellow);
  text-shadow: 0 0 20px var(--yellow), 0 0 60px var(--yellow);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* ---------- Mobile / player ---------- */
#join-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
}
#join-screen h1 { font-size: 6vw; color: var(--cyan); text-shadow: 0 0 10px var(--cyan); }
#join-screen h1 span { color: var(--pink); text-shadow: 0 0 10px var(--pink); }

#pseudo-input {
  font-family: 'Orbitron', sans-serif;
  background: rgba(255,255,255,0.06);
  border: 2px solid var(--cyan);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 1.1em;
  width: 80%;
  max-width: 320px;
  text-align: center;
}

#game-screen {
  position: relative;
  height: 100%;
  width: 100%;
}

#hp-bar {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  height: 14px;
  border: 2px solid var(--player-color);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255,255,255,0.06);
}
#hp-fill {
  height: 100%;
  width: 100%;
  background: var(--player-color);
  box-shadow: 0 0 10px var(--player-color);
  transition: width 0.15s linear;
}

#stats {
  position: fixed;
  top: 38px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--player-color);
  text-shadow: 0 0 8px var(--player-color);
}
#lives { font-size: 15px; }

#status {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  text-align: center;
  color: #ff2b2b;
  font-weight: 700;
  text-shadow: 0 0 8px #ff2b2b;
  animation: blink 0.7s step-start infinite;
}
@keyframes blink { 50% { opacity: 0.2; } }

#countdown {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30vw;
  color: var(--yellow);
  text-shadow: 0 0 24px var(--yellow);
  background: rgba(5,5,10,0.5);
}

/* Deux zones tactiles independantes, chacune centree dans sa moitie d'ecran.
   Toute la moitie est active : plus besoin de viser un bouton du bout du pouce. */
#pad-left, #pad-right {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  z-index: 1;
}
#pad-left { left: 0; }
#pad-right { right: 0; }

#joystick-base {
  position: absolute;
  width: 168px;
  height: 168px;
  margin: -84px 0 0 -84px;   /* left/top pointent le centre */
  left: 50%;
  top: 50%;
  border-radius: 50%;
  border: 2px solid var(--player-color);
  background: rgba(255,255,255,0.04);
  opacity: 0.55;
  transition: opacity 0.15s;
}
#joystick-base.active { opacity: 1; }
#joystick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 66px;
  height: 66px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--player-color);
  box-shadow: 0 0 16px var(--player-color);
}

#fire-btn {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 3px solid var(--pink);
  color: var(--pink);
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 1.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 0 8px var(--pink);
  box-shadow: 0 0 18px rgba(255, 43, 214, 0.5);
  pointer-events: none;   /* c'est toute la moitie droite qui tire */
  transition: transform 0.08s, background 0.08s;
}
#pad-right.firing #fire-btn {
  background: rgba(255, 43, 214, 0.25);
  transform: scale(0.95);
}

/* Bonus actifs : le joueur voyait son tir triple disparaitre sans explication. */
#buffs {
  position: fixed;
  top: 84px;
  left: 0;
  right: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}
.buff {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--buff-color);
  border: 1px solid var(--buff-color);
  background: rgba(5,5,10,0.75);
  text-shadow: 0 0 6px var(--buff-color);
}

#game-screen.eliminated #pad-left,
#game-screen.eliminated #pad-right {
  opacity: 0.25;
  pointer-events: none;
}

/* ---------- Legende des bonus (TV) ---------- */
#legend {
  position: fixed;
  left: 24px;
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(5, 5, 10, 0.72);
  border: 1px solid rgba(0, 246, 255, 0.35);
  font-size: 14px;
}
.legend-title {
  color: var(--cyan);
  font-weight: 900;
  letter-spacing: 0.14em;
  text-shadow: 0 0 8px var(--cyan);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
}
.legend-item i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  color: var(--c);
  border: 2px solid var(--c);
  box-shadow: 0 0 10px var(--c);
  border-radius: 4px;
}

.gameover-actions { display: flex; gap: 16px; }

/* Classement final : le vainqueur au score, pas le survivant. */
#winner-sub { margin: 0; color: var(--text); font-size: 1.1vw; opacity: 0.85; }
#final-ranking {
  list-style: none;
  counter-reset: rang;
  padding: 0;
  margin: 0;
  min-width: 26vw;
}
#final-ranking li {
  counter-increment: rang;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 14px;
  margin-bottom: 6px;
  border-left: 4px solid var(--c);
  background: rgba(255,255,255,0.04);
  font-size: 1.15em;
}
#final-ranking li::before {
  content: counter(rang);
  color: var(--c);
  font-weight: 900;
  min-width: 1.2em;
}
#final-ranking li span { flex: 1; text-align: left; }
#final-ranking li b { color: var(--yellow); }

/* Scores en jeu (TV) */
#scoreboard {
  position: fixed;
  top: 20px;
  right: 24px;
  min-width: 250px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(5, 5, 10, 0.72);
  border: 1px solid rgba(0, 246, 255, 0.35);
  font-size: 15px;
}
.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 6px;
  border-left: 3px solid var(--c);
  margin-bottom: 3px;
}
.score-row.out { opacity: 0.35; text-decoration: line-through; }
.score-name { flex: 1; color: var(--c); text-shadow: 0 0 8px var(--c); }
.score-lives { font-size: 11px; color: #ff5a7a; letter-spacing: 1px; }
.score-pts { font-weight: 900; color: var(--yellow); min-width: 3.2em; text-align: right; }

.legend-sep { width: 1px; height: 22px; background: rgba(0, 246, 255, 0.35); }

/* Titre en cours (TV) : discret, sert aussi a voir que Deezer repond. */
#now-playing {
  position: fixed;
  right: 24px;
  bottom: 20px;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(5, 5, 10, 0.72);
  border: 1px solid rgba(255, 43, 214, 0.35);
  color: var(--pink);
  text-shadow: 0 0 8px var(--pink);
  font-size: 13px;
  letter-spacing: 0.06em;
  max-width: 30vw;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#start-error {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 10px 20px;
  border-radius: 8px;
  color: #ff5050;
  border: 2px solid #ff5050;
  background: rgba(5, 5, 10, 0.92);
  text-shadow: 0 0 8px #ff5050;
}
