/* ═══════════════════════════════════════════════════════════════
   SAPNU PUAS — Le Nudien Faible
   WoW Night Elf / Dark Fantasy Aesthetic
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* ── Night Elf Palette ────────────────────────────────────── */
  --bg-deep:       #0d0b1a;
  --bg-surface:    #151228;
  --bg-card:       #1c1835;
  --bg-elevated:   #261f4a;
  --border:        #3a2d6b;
  --border-glow:   #c026d340;

  --text-primary:  #e0daf0;
  --text-secondary:#9b8ec4;
  --text-muted:    #5e4f8a;

  /* Main accents: magenta/pink + ice blue */
  --accent:        #e040a0;
  --accent-bright: #ff5ec4;
  --accent-glow:   #e040a050;
  --ice:           #00d4ff;
  --ice-glow:      #00d4ff35;

  --danger:        #ff3366;
  --success:       #00e68a;
  --purple:        #a855f7;
  --cyan:          #00d4ff;
  --gold:          #fbbf24;

  --font-display:  'Cinzel', 'Oswald', serif;
  --font-body:     'Outfit', sans-serif;
  --font-mono:     'JetBrains Mono', monospace;

  --radius-sm:     6px;
  --radius-md:     12px;
  --radius-lg:     20px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Flash messages ─────────────────────────────────────────── */
.flash {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  padding: 12px 24px; border-radius: var(--radius-md); z-index: 9999;
  font-weight: 500; animation: flashIn 0.4s ease, flashOut 0.4s 3s ease forwards;
}
.flash--notice { background: var(--success); color: #000; }
.flash--alert  { background: var(--danger); color: #fff; }

@keyframes flashIn  { from { opacity:0; transform: translateX(-50%) translateY(-20px); } }
@keyframes flashOut { to   { opacity:0; transform: translateX(-50%) translateY(-20px); } }

/* ── Shared Components ──────────────────────────────────────── */
.page-bg {
  background:
    radial-gradient(ellipse at 30% 0%, #7c3aed15 0%, transparent 50%),
    radial-gradient(ellipse at 70% 100%, #e040a012 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, #00d4ff08 0%, transparent 70%),
    var(--bg-deep);
  min-height: 100dvh;
}

.container {
  max-width: 1200px; margin: 0 auto; padding: 20px;
}

.container--narrow {
  max-width: 500px; margin: 0 auto; padding: 20px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.1;
}

.title-accent {
  color: var(--accent);
  text-shadow: 0 0 40px var(--accent-glow);
}

.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 100px; font-size: 0.75rem;
  font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge--lobby    { background: var(--purple); color: #fff; }
.badge--playing  { background: var(--success); color: #000; }
.badge--voting   { background: var(--gold); color: #000; }
.badge--revealing{ background: var(--cyan); color: #000; }
.badge--eliminated{ background: var(--danger); color: #fff; }
.badge--finale   { background: linear-gradient(135deg, var(--gold), var(--accent)); color: #000; }
.badge--finished { background: var(--text-muted); color: #fff; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border: none; border-radius: var(--radius-md);
  font-family: var(--font-display); font-size: 1rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  cursor: pointer; transition: all 0.2s;
  text-decoration: none; font-weight: 600;
}
.btn:active { transform: scale(0.97); }

.btn--primary {
  background: linear-gradient(135deg, var(--accent), #a020c0);
  color: #fff; box-shadow: 0 4px 25px var(--accent-glow);
}
.btn--primary:hover { box-shadow: 0 4px 35px #e040a070; }

.btn--danger {
  background: linear-gradient(135deg, var(--danger), #cc1144);
  color: #fff;
}

.btn--success {
  background: linear-gradient(135deg, var(--success), #00b36b);
  color: #000;
}

.btn--ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn--large { padding: 16px 36px; font-size: 1.2rem; }
.btn--small { padding: 8px 14px; font-size: 0.8rem; }
.btn--full  { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card--glow {
  box-shadow: 0 0 30px #c026d315, 0 0 60px #00d4ff08, inset 0 1px 0 #ffffff08;
}

.card__title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

.form-group label {
  display: block; margin-bottom: 6px;
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em;
}

.form-group input, .form-group select {
  width: 100%; padding: 12px 16px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-primary);
  font-family: var(--font-body); font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ═══════════════════════════════════════════════════════════════
   HOME PAGE
   ═══════════════════════════════════════════════════════════════ */
.home {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100dvh; text-align: center;
  padding: 40px 20px;
}

.home__logo {
  font-family: var(--font-display); font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 700; text-transform: uppercase;
  background: linear-gradient(135deg, var(--ice), var(--accent-bright), var(--purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 30px #c026d340);
  margin-bottom: 8px;
}

.home__sub {
  color: var(--text-muted); font-size: 1rem;
  letter-spacing: 0.3em; text-transform: uppercase;
  margin-bottom: 48px;
}

.home__actions {
  display: flex; flex-direction: column; gap: 16px;
  width: 100%; max-width: 360px;
}

.home__join-form {
  display: flex; gap: 8px;
}

.home__join-form input {
  flex: 1; padding: 14px 18px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--ice);
  font-family: var(--font-mono); font-size: 1.2rem;
  text-transform: uppercase; text-align: center;
  letter-spacing: 0.3em;
}

.home__join-form input::placeholder {
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.2em; font-size: 0.9rem;
}

.home__divider {
  color: var(--text-muted); font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.2em;
  padding: 8px 0;
}

.home__games {
  margin-top: 48px; width: 100%; max-width: 500px;
}

.home__games h3 {
  font-size: 0.85rem; color: var(--text-muted);
  letter-spacing: 0.1em; margin-bottom: 16px;
}

.game-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  margin-bottom: 8px; text-decoration: none;
  transition: border-color 0.2s;
}
.game-list-item:hover { border-color: var(--accent); }

.game-list-item__name { color: var(--text-primary); font-weight: 500; }
.game-list-item__code {
  font-family: var(--font-mono); color: var(--ice);
  font-size: 0.9rem;
}

/* ═══════════════════════════════════════════════════════════════
   CHAIN DISPLAY
   ═══════════════════════════════════════════════════════════════ */
.chain {
  display: flex; flex-direction: column-reverse; gap: 4px;
  width: 100%;
}

.chain__step {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 6px 16px; border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-weight: 500;
  font-size: 0.95rem; transition: all 0.3s;
  background: var(--bg-surface); border: 1px solid transparent;
  color: var(--text-muted);
}

.chain__step--active {
  background: linear-gradient(90deg, transparent, var(--accent-glow));
  border-color: var(--accent); color: var(--accent-bright);
  font-weight: 700;
  box-shadow: 0 0 20px var(--accent-glow);
}

/* ═══════════════════════════════════════════════════════════════
   PLAYER AVATARS
   ═══════════════════════════════════════════════════════════════ */
.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.player-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 8px; border-radius: var(--radius-md);
  background: var(--bg-card); border: 2px solid var(--border);
  transition: all 0.3s; position: relative;
}

.player-card--eliminated {
  opacity: 0.35;
  border-color: var(--danger) !important;
}

.player-card--eliminated::after {
  content: "☠"; position: absolute; top: 6px; right: 8px;
  color: var(--danger); font-size: 1.1rem;
}

.player-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 1.3rem;
  font-weight: 700; color: #fff; margin-bottom: 8px;
  box-shadow: 0 0 15px #00000060;
}

.player-name {
  font-weight: 600; font-size: 0.9rem;
  text-align: center; word-break: break-word;
}

.player-stats {
  font-size: 0.75rem; color: var(--text-muted);
  margin-top: 4px; font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════════════════════════
   RÉGIE (Control Room)
   ═══════════════════════════════════════════════════════════════ */
.regie {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  grid-template-rows: auto 1fr;
  gap: 16px; padding: 16px;
  min-height: 100dvh;
}

.regie__header {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-md);
}

.regie__header-title {
  font-family: var(--font-display);
  font-size: 1.2rem; color: var(--accent);
}

.regie__header-info {
  display: flex; align-items: center; gap: 16px;
}

.regie__header-code {
  font-family: var(--font-mono); font-size: 1.1rem;
  color: var(--ice); letter-spacing: 0.15em;
  text-shadow: 0 0 10px var(--ice-glow);
}

.regie__main {
  display: flex; flex-direction: column; gap: 16px;
}

.regie__controls {
  display: flex; flex-wrap: wrap; gap: 8px;
}

.regie__bank-display {
  font-family: var(--font-display); font-size: 2.5rem;
  color: var(--gold);
  text-shadow: 0 0 30px #fbbf2440;
}

.regie__round-info {
  display: flex; gap: 24px; align-items: baseline;
}

.regie__stat { display: flex; flex-direction: column; }
.regie__stat-label {
  font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-muted);
}
.regie__stat-value {
  font-family: var(--font-display); font-size: 1.8rem;
  color: var(--text-primary);
}

.regie__add-player {
  display: flex; gap: 8px; margin-top: 12px;
}
.regie__add-player input {
  flex: 1; padding: 8px 12px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font-body);
}

/* ═══════════════════════════════════════════════════════════════
   ANIMATEUR (Host View)
   ═══════════════════════════════════════════════════════════════ */
.animateur {
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 20px; min-height: 100dvh;
}

.animateur__bank {
  font-family: var(--font-display); font-size: clamp(3rem, 10vw, 6rem);
  font-weight: 700; color: var(--gold);
  text-shadow: 0 0 60px #fbbf2450;
  margin: 32px 0;
}

.animateur__chain {
  max-width: 400px; width: 100%; margin: 24px 0;
}

.animateur__state {
  font-family: var(--font-display); font-size: 1.4rem;
  text-transform: uppercase; letter-spacing: 0.15em;
  color: var(--text-secondary); margin-bottom: 16px;
}

.animateur__players {
  display: flex; flex-wrap: wrap; gap: 12px;
  justify-content: center; margin-top: 32px;
}

.animateur__player {
  padding: 10px 20px; border-radius: var(--radius-md);
  background: var(--bg-card); border: 2px solid var(--border);
  font-weight: 600; font-size: 1.1rem;
  transition: all 0.3s;
}
.animateur__player--eliminated {
  opacity: 0.3; text-decoration: line-through;
  border-color: var(--danger);
}

/* ═══════════════════════════════════════════════════════════════
   JOUEUR (Player Mobile View)
   ═══════════════════════════════════════════════════════════════ */
.joueur {
  display: flex; flex-direction: column;
  min-height: 100dvh; padding: 16px;
}

.joueur__header {
  text-align: center; padding: 16px 0;
}

.joueur__name {
  font-family: var(--font-display); font-size: 1.4rem;
}

.joueur__status {
  font-size: 0.85rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-top: 4px;
}

.joueur__waiting {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
}

.joueur__waiting-icon {
  font-size: 3rem; margin-bottom: 16px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.1); }
}

.joueur__vote {
  flex: 1; display: flex; flex-direction: column;
}

.joueur__vote h2 {
  text-align: center; font-size: 1.3rem;
  margin-bottom: 16px;
}

.joueur__vote-targets {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-bottom: 16px;
}

.vote-target {
  padding: 12px; border-radius: var(--radius-md);
  border: 2px solid var(--border); background: var(--bg-card);
  cursor: pointer; transition: all 0.2s;
  text-align: center; font-weight: 600;
}
.vote-target:active { transform: scale(0.96); }
.vote-target--selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--bg-card), #e040a015);
  box-shadow: 0 0 25px var(--accent-glow);
}

.joueur__canvas-wrapper {
  flex: 1; position: relative;
  border: 2px solid var(--border); border-radius: var(--radius-lg);
  background: #fff; min-height: 200px;
  touch-action: none; overflow: hidden;
}

.joueur__canvas-wrapper canvas {
  width: 100%; height: 100%;
  display: block; cursor: crosshair;
}

.joueur__canvas-label {
  position: absolute; top: 12px; left: 16px;
  font-size: 0.75rem; color: #999;
  text-transform: uppercase; letter-spacing: 0.08em;
  pointer-events: none;
}

.joueur__canvas-actions {
  display: flex; gap: 8px; margin-top: 12px;
}

.joueur__voted {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
}

.joueur__voted-check {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--success); display: flex;
  align-items: center; justify-content: center;
  font-size: 2rem; margin-bottom: 16px;
}

/* ═══════════════════════════════════════════════════════════════
   SPECTATEUR (Audience View)
   ═══════════════════════════════════════════════════════════════ */
.spectateur {
  min-height: 100dvh; overflow: hidden;
}

.spectateur__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 40px;
}

.spectateur__title {
  font-family: var(--font-display); font-size: 1.6rem;
  background: linear-gradient(135deg, var(--ice), var(--accent-bright));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 12px #c026d340);
}

.spectateur__round {
  font-family: var(--font-display); font-size: 1.1rem;
  color: var(--text-muted); text-transform: uppercase;
}

.spectateur__bank {
  text-align: center; padding: 24px;
}

.spectateur__bank-amount {
  font-family: var(--font-display); font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 700; color: var(--gold);
  text-shadow: 0 0 60px #fbbf2440;
}

.spectateur__bank-label {
  font-size: 0.85rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.15em;
}

.spectateur__chain-bar {
  display: flex; justify-content: center; padding: 0 40px;
}

.spectateur__chain-horizontal {
  display: flex; gap: 4px; justify-content: center;
  flex-wrap: wrap;
}

.spectateur__chain-step {
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-weight: 500;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.9rem;
  transition: all 0.4s;
}

.spectateur__chain-step--active {
  background: var(--accent); color: #fff;
  box-shadow: 0 0 30px var(--accent-glow);
  transform: scale(1.1);
}

.spectateur__players {
  display: flex; flex-wrap: wrap; gap: 16px;
  justify-content: center; padding: 32px 40px;
}

/* ── Vote Reveal ────────────────────────────────────────────── */
.vote-reveal {
  display: flex; flex-direction: column;
  align-items: center; padding: 40px;
}

.vote-reveal__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px; width: 100%; max-width: 1100px;
  margin-top: 32px;
}

.vote-reveal__card {
  background: var(--bg-card); border: 2px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  text-align: center;
  animation: voteSlideIn 0.5s ease both;
}

@keyframes voteSlideIn {
  from { opacity: 0; transform: translateY(30px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.vote-reveal__voter {
  font-family: var(--font-display); font-size: 0.85rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-secondary); margin-bottom: 12px;
}

.vote-reveal__handwriting {
  background: #fff; border-radius: var(--radius-md);
  padding: 8px; margin-bottom: 12px; min-height: 100px;
  display: flex; align-items: center; justify-content: center;
}

.vote-reveal__handwriting svg { max-width: 100%; max-height: 120px; }

.vote-reveal__voted-for {
  font-family: var(--font-display); font-size: 1.2rem;
  font-weight: 700;
}

/* ── Tally Results ──────────────────────────────────────────── */
.tally {
  display: flex; flex-direction: column; gap: 12px;
  max-width: 500px; width: 100%; margin-top: 32px;
}

.tally__row { display: flex; align-items: center; gap: 16px; }

.tally__name {
  width: 120px; text-align: right;
  font-family: var(--font-display); font-size: 1.1rem;
}

.tally__bar-bg {
  flex: 1; height: 40px; background: var(--bg-surface);
  border-radius: var(--radius-sm); overflow: hidden;
}

.tally__bar {
  height: 100%; border-radius: var(--radius-sm);
  display: flex; align-items: center; padding-left: 12px;
  font-family: var(--font-display); font-weight: 700;
  transition: width 1s ease;
}

.tally__bar--most {
  background: linear-gradient(90deg, var(--accent), var(--danger));
  color: #fff;
}
.tally__bar--other {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════
   JOIN PAGE
   ═══════════════════════════════════════════════════════════════ */
.join-page {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100dvh; padding: 40px 20px;
  text-align: center;
}

.join-page__code {
  font-family: var(--font-mono); font-size: 2rem;
  color: var(--ice); letter-spacing: 0.3em;
  margin: 16px 0 32px;
  text-shadow: 0 0 15px var(--ice-glow);
}

.join-page form { width: 100%; max-width: 360px; }

.join-page input[type="text"] {
  width: 100%; padding: 16px 20px; margin-bottom: 16px;
  background: var(--bg-card); border: 2px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-primary);
  font-family: var(--font-body); font-size: 1.2rem;
  text-align: center;
}

.join-page input[type="text"]::placeholder { color: var(--text-muted); }
.join-page input[type="text"]:focus {
  outline: none; border-color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .regie {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .regie__chain { display: none; }
}

@media (max-width: 600px) {
  .spectateur__header { padding: 12px 16px; }
  .spectateur__players { padding: 16px; }
  .vote-reveal { padding: 16px; }
  .vote-reveal__grid { grid-template-columns: 1fr 1fr; gap: 12px; }
}