/* ==================================================================
   TWITCH ARENA — feuille de style
   Organisation : variables → base → HUD → écrans → composants → responsive
   ================================================================== */

:root {
  --purple: #9146ff;
  --purple-soft: #c07bff;
  --bg: #07070d;
  --panel: rgba(16, 16, 26, 0.94);
  --panel-2: rgba(28, 28, 42, 0.9);
  --line: rgba(255, 255, 255, 0.1);
  --text: #eef0f6;
  --muted: #9aa0b0;
  --green: #5ce1a0;
  --red: #ff4d6d;
  --gold: #ffb020;
  --blue: #33e1ff;
  --radius: 14px;
  --hud-pad: 16px;
  --font: 'Rajdhani', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Orbitron', var(--font);
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: none;
}

#game {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  image-rendering: auto;
}

#ui {
  position: fixed; inset: 0;
  pointer-events: none;          /* le canvas reçoit la souris par défaut */
  z-index: 10;
}
#ui button, #ui input, #ui select, #ui .panel, #ui .screen,
#ui .card, #ui .tab, #ui label { pointer-events: auto; }

.hidden { display: none !important; }

kbd {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.9em;
}

/* ==================================================================
   Chargement
   ================================================================== */

#loader {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
  background: radial-gradient(circle at 50% 45%, #1a1030, #07070d 70%);
  transition: opacity .5s ease, visibility .5s;
}
#loader.gone { opacity: 0; visibility: hidden; }
.loader-logo {
  font-family: var(--font-display);
  font-size: clamp(28px, 7vw, 56px);
  font-weight: 900; letter-spacing: 3px;
}
.loader-logo span { color: var(--purple-soft); }
.loader-bar {
  width: min(320px, 70vw); height: 4px;
  background: rgba(255, 255, 255, .08);
  border-radius: 4px; overflow: hidden;
}
.loader-bar i {
  display: block; height: 100%; width: 40%;
  background: linear-gradient(90deg, transparent, var(--purple), transparent);
  animation: slide 1.2s infinite ease-in-out;
}
@keyframes slide { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }
#loader p { color: var(--muted); font-size: 14px; letter-spacing: 1px; }

.fatal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: #07070d; text-align: center; padding: 24px;
}
.fatal h2 { font-family: var(--font-display); color: var(--gold); }
.fatal pre {
  background: #14141f; border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 8px;
  font-size: 14px; color: var(--green); user-select: all;
}

#fullscreen-btn {
  position: fixed; right: 12px; bottom: 12px; z-index: 60;
  width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 10px;
  background: rgba(16, 16, 26, .7); color: var(--text);
  font-size: 18px; cursor: pointer; backdrop-filter: blur(6px);
  transition: background .2s, transform .1s;
}
#fullscreen-btn:hover { background: var(--purple); transform: scale(1.06); }

/* ==================================================================
   HUD
   ================================================================== */

#hud { position: absolute; inset: 0; }

.hud-top-left {
  position: absolute; top: var(--hud-pad); left: var(--hud-pad);
  display: flex; flex-direction: column; gap: 7px; width: min(320px, 42vw);
}

.bar-group { display: flex; flex-direction: column; gap: 4px; }

.bar {
  position: relative; height: 18px;
  background: rgba(0, 0, 0, .6);
  border: 1px solid var(--line);
  border-radius: 6px; overflow: hidden;
}
.bar-fill { height: 100%; width: 100%; transition: width .12s linear; border-radius: 5px; }
.bar.hp .bar-fill { background: linear-gradient(90deg, #ff2d55, #ff6b81); }
.bar.shield { height: 8px; }
.bar.shield .bar-fill { background: linear-gradient(90deg, #1a9dff, var(--blue)); }
.bar.stam { height: 7px; }
.bar.stam .bar-fill { background: linear-gradient(90deg, #d19a00, #ffd166); }
.bar.xp { height: 12px; flex: 1; }
.bar.xp .bar-fill { background: linear-gradient(90deg, #2f9e6a, var(--green)); }
.bar-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  text-shadow: 0 1px 3px #000; letter-spacing: .5px;
}

.lvl-row { display: flex; align-items: center; gap: 8px; }
.lvl-badge {
  min-width: 30px; height: 26px; padding: 0 6px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--purple), #6a2fd0);
  border-radius: 7px;
  font-family: var(--font-display); font-weight: 900; font-size: 14px;
  box-shadow: 0 2px 10px rgba(145, 70, 255, .5);
}

.hud-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 3px 9px;
  background: rgba(0, 0, 0, .55);
  border: 1px solid var(--line); border-radius: 20px;
  font-size: 13px; font-weight: 600;
}

.hud-top-center {
  position: absolute; top: var(--hud-pad); left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-align: center;
}
.wave-label {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(15px, 2.4vw, 22px); letter-spacing: 2px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .9);
}
.wave-progress {
  width: min(220px, 40vw); height: 3px;
  background: rgba(255, 255, 255, .12); border-radius: 3px; overflow: hidden;
}
.wave-progress > div {
  height: 100%; width: 0;
  background: var(--purple-soft); transition: width .2s linear;
}
.timer {
  font-family: var(--font-display); font-size: clamp(22px, 4vw, 36px);
  font-weight: 900; line-height: 1;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .9);
}
.score { font-size: 15px; font-weight: 700; color: var(--gold); letter-spacing: 1px; }

.hud-top-right {
  position: absolute; top: var(--hud-pad); right: var(--hud-pad);
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.biome-badge {
  padding: 4px 11px;
  background: rgba(0, 0, 0, .55);
  border: 1px solid var(--line); border-radius: 20px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
#minimap {
  width: 150px; height: 150px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .4);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .6);
}
.perf {
  padding: 6px 10px; background: rgba(0, 0, 0, .7);
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 11px; line-height: 1.5; color: var(--green);
  font-variant-numeric: tabular-nums; text-align: right;
}

.hud-events {
  position: absolute; left: var(--hud-pad); top: 190px;
  display: flex; flex-direction: column; gap: 5px;
}
.ev-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 10px;
  background: rgba(145, 70, 255, .2);
  border: 1px solid rgba(145, 70, 255, .5);
  border-radius: 20px; font-size: 12px;
  animation: pop .3s ease;
}
.ev-chip i { color: var(--muted); font-style: normal; }

/* Fil d'actualité des envahisseurs (spectateurs entrés via !join) */
.invader-feed {
  position: absolute; left: var(--hud-pad); bottom: 76px;
  display: flex; flex-direction: column; gap: 4px;
  max-width: min(300px, 46vw);
}
.inv-entry {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 11px;
  background: rgba(12, 8, 22, .82);
  border-left: 3px solid var(--purple);
  border-radius: 7px;
  font-size: 13px;
  animation: slideIn .25s ease;
  transition: opacity .4s, transform .4s;
}
.inv-entry.out { opacity: 0; transform: translateX(-24px); }
.inv-entry.join { border-left-color: var(--purple-soft); }
.inv-entry.kill { border-left-color: var(--red); }
.inv-icon { font-size: 13px; }
.inv-text {
  flex: 1; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.inv-time { color: var(--gold); font-variant-numeric: tabular-nums; font-size: 12px; }

.chip.invaders { border-color: var(--purple); color: var(--purple-soft); }
/* Mode créatif : volontairement voyant, il doit rappeler en permanence que
   la partie ne compte pas. */
.chip.creatif {
  border-color: #8ee36b;
  color: #b9f59a;
  background: rgba(142, 227, 107, .1);
  font-weight: 700;
  letter-spacing: .04em;
}

.invader-table .row { grid-template-columns: 42px 1fr 76px 62px; }
.invader-table em { color: var(--green); font-style: normal; font-size: 12px; }

.boss-bar {
  position: absolute; top: 96px; left: 50%; transform: translateX(-50%);
  width: min(560px, 84vw); text-align: center;
}
.boss-name {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(14px, 2.6vw, 20px); letter-spacing: 2px;
  color: #fff; text-shadow: 0 0 18px rgba(255, 60, 60, .8);
  margin-bottom: 4px;
}
.boss-track {
  height: 15px; background: rgba(0, 0, 0, .75);
  border: 2px solid rgba(255, 255, 255, .25); border-radius: 8px; overflow: hidden;
}
.boss-fill { height: 100%; width: 100%; transition: width .18s ease; }
.boss-phase { margin-top: 3px; font-size: 12px; letter-spacing: 2px; color: var(--muted); }

.hud-bottom-left { position: absolute; left: var(--hud-pad); bottom: var(--hud-pad); }
.weapon-card {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 14px;
  background: rgba(0, 0, 0, .6);
  border: 1px solid var(--line); border-radius: 12px;
}
.w-icon { font-size: 22px; }
.w-name { font-weight: 700; font-size: 15px; letter-spacing: .5px; }

/* ---------------- Panneau de vote Twitch ---------------- */

.vote-panel {
  /* Agrandi par transformation plutôt qu'en retouchant chaque règle : le
     facteur reste réglable et tout l'intérieur suit d'un bloc. L'origine en
     bas à droite fait grandir le panneau vers l'intérieur de l'écran. */
  --vote-scale: 1.25;
  transform: scale(var(--vote-scale));
  transform-origin: bottom right;
  position: absolute; right: var(--hud-pad); bottom: var(--hud-pad);
  width: min(320px, 78vw);
  background: rgba(12, 8, 22, .93);
  border: 2px solid var(--purple);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 34px rgba(145, 70, 255, .35);
  /* Animation dédiée : `slideUp` remettait `transform: none` et annulait
     l'agrandissement pendant toute son exécution. */
  animation: votePanelIn .3s ease;
}
@keyframes votePanelIn {
  from { opacity: 0; transform: scale(var(--vote-scale)) translateY(22px); }
  to   { opacity: 1; transform: scale(var(--vote-scale)); }
}
.vote-panel.idle { border-color: rgba(145, 70, 255, .35); opacity: .8; }
.vote-panel.idle #vote-options { display: none; }

.vote-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(90deg, var(--purple), #6a2fd0);
  font-family: var(--font-display); font-weight: 700;
  font-size: 13px; letter-spacing: 1.5px;
}
.tw-logo { font-size: 15px; }
.vote-timer {
  margin-left: auto;
  min-width: 26px; padding: 1px 7px;
  background: rgba(0, 0, 0, .35); border-radius: 20px;
  text-align: center; font-variant-numeric: tabular-nums;
}

.vote-opt {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  font-size: 14px; overflow: hidden;
}
.vote-bg {
  position: absolute; inset: 0 auto 0 0;
  background: rgba(145, 70, 255, .22);
  transition: width .3s ease;
}
.vote-opt.mood-good .vote-bg { background: rgba(92, 225, 160, .2); }
.vote-opt.mood-bad  .vote-bg { background: rgba(255, 77, 109, .2); }
.vote-opt.lead { box-shadow: inset 3px 0 0 var(--gold); }
.vote-num {
  position: relative;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .12); border-radius: 5px;
  font-weight: 700; font-size: 12px;
}
.vote-icon, .vote-name, .vote-count { position: relative; }
.vote-name { flex: 1; font-weight: 600; font-size: 13px; }
.vote-count { font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.vote-foot { padding: 6px 12px; font-size: 11px; color: var(--muted); text-align: center; }

/* Jauge d'ambiance partagée (!cheer / !curse) */
.hype-wrap {
  display: flex; align-items: center; gap: 7px;
  padding: 0 10px 9px;
}
.hype-lbl { font-size: 10px; font-weight: 700; letter-spacing: .5px; }
.hype-lbl.curse { color: var(--red); }
.hype-lbl.cheer { color: var(--green); }
.hype-track {
  position: relative; flex: 1;
  height: 7px; border-radius: 5px;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
}
.hype-mid {
  position: absolute; left: 50%; top: 0; bottom: 0;
  width: 1px; background: rgba(255, 255, 255, .35);
}
.hype-fill {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 0; border-radius: 5px;
  transition: width .25s ease, left .25s ease, background .3s;
}

.bet-table .row { grid-template-columns: 42px 1fr 90px 70px; }

/* ---------------- Bannières & toasts ---------------- */

.event-banner {
  position: absolute; top: 22%; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px;
  background: rgba(10, 8, 18, .92);
  border: 2px solid var(--gold); border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .7);
  white-space: nowrap;
}
.event-banner.anim { animation: bannerIn .5s cubic-bezier(.2, 1.4, .4, 1); }
.eb-icon { font-size: 34px; }
.event-banner b {
  display: block;
  font-family: var(--font-display); font-size: 19px;
  letter-spacing: 1.5px; color: var(--gold);
}
.event-banner small { color: var(--muted); font-size: 13px; }

.toast-stack {
  position: absolute; top: 100px; right: var(--hud-pad);
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  padding: 9px 15px;
  background: rgba(14, 14, 24, .95);
  border-left: 3px solid var(--purple); border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .5);
  animation: slideIn .3s ease; transition: opacity .4s, transform .4s;
}
.toast.out { opacity: 0; transform: translateX(30px); }
.toast small { display: block; font-size: 10px; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; }
.toast span { font-weight: 700; font-size: 14px; }
.toast.gold { border-color: var(--gold); }
.toast.green { border-color: var(--green); }
.toast.red { border-color: var(--red); }
.toast.purple { border-color: var(--purple-soft); }

/* ---------------- Panneau statistiques (Tab) ---------------- */

.stats-panel {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(620px, 92vw); max-height: 86vh; overflow-y: auto;
  padding: 22px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
}
.stats-panel h3 {
  font-family: var(--font-display); font-size: 13px;
  letter-spacing: 2px; color: var(--purple-soft);
  margin: 16px 0 8px;
}
.stats-panel h3:first-child { margin-top: 0; }
/* Synergies : progression des fusions en cours de construction */
.syn-list { display: flex; flex-direction: column; gap: 6px; }
.syn {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; opacity: .65;
}
.syn.done { opacity: 1; border-color: var(--purple-soft); background: rgba(192, 123, 255, .1); }
.syn-icon { font-size: 20px; }
.syn-body { flex: 1; min-width: 0; }
.syn-body b { font-size: 13.5px; }
.syn-body small { display: block; font-size: 11px; color: var(--muted); }
.syn-body i { font-style: normal; }
.syn-body i.ok { color: var(--green); }
.syn-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 2px; background: rgba(255, 255, 255, .07);
}
.syn-bar i { display: block; height: 100%; background: var(--purple-soft); }

/* Bouton du défi du jour */
.btn.daily {
  border-color: rgba(255, 176, 32, .55);
  color: var(--gold);
}
.btn.daily:hover { background: rgba(255, 176, 32, .14); }

.upg-list { display: flex; flex-wrap: wrap; gap: 6px; }
.upg-chip {
  padding: 3px 9px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid; border-radius: 20px;
  font-size: 12px;
}

/* ==================================================================
   Écrans
   ================================================================== */

.screen {
  position: fixed; inset: 0; z-index: 20;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.screen.visible { display: flex; animation: fadeIn .25s ease; }
.screen.overlay { background: rgba(4, 4, 10, .82); backdrop-filter: blur(4px); }

.panel {
  position: relative;
  width: min(760px, 96vw); max-height: 92vh;
  overflow-y: auto;
  padding: 26px;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .7);
  animation: panelIn .3s cubic-bezier(.2, 1.2, .4, 1);
}
.panel.wide { width: min(1080px, 97vw); }
.panel.narrow { width: min(440px, 94vw); text-align: center; }
.panel h2 {
  font-family: var(--font-display); font-size: clamp(18px, 3vw, 26px);
  letter-spacing: 2px;
}

.panel-head {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 14px; margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { flex: 1; }
.panel-foot {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  padding-top: 18px; margin-top: 20px;
  border-top: 1px solid var(--line);
}

.section-title {
  font-family: var(--font-display); font-size: 13px;
  letter-spacing: 2px; color: var(--purple-soft);
  margin: 20px 0 10px;
}
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
.hint.ok { color: var(--green); }

/* ---------------- Menu principal ---------------- */

/* ---------------- Accueil ---------------- */

/* Grille verticale qui tient dans la fenêtre : le contenu ne doit jamais
   déborder, même sur un écran court ou avec un zoom navigateur élevé. */
.home {
  display: flex; flex-direction: column;
  gap: clamp(10px, 2vh, 22px);
  width: min(880px, 96vw);
  max-height: 96vh;
  padding: clamp(8px, 2vh, 20px) 0;
}
.home-head { text-align: center; }

/* Deux cartes d'action principales, côte à côte */
.home-hero {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.hero-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: clamp(14px, 2.4vh, 24px) 18px;
  border: 2px solid var(--line); border-radius: 18px;
  background: var(--panel-2);
  color: var(--text); font-family: var(--font);
  cursor: pointer; text-align: center;
  transition: transform .13s, border-color .15s, box-shadow .15s;
}
.hero-card:hover { transform: translateY(-4px); }
.hero-card.play {
  background: linear-gradient(135deg, var(--purple), #5a24b8);
  border-color: transparent;
  box-shadow: 0 8px 30px rgba(145, 70, 255, .4);
}
.hero-card.play:hover { box-shadow: 0 14px 40px rgba(145, 70, 255, .55); }
.hero-card.daily { border-color: rgba(255, 176, 32, .5); }
.hero-card.daily:hover { border-color: var(--gold); box-shadow: 0 10px 34px rgba(255, 176, 32, .28); }
.hc-icon { font-size: clamp(20px, 3vh, 28px); line-height: 1; }
.hc-title {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(16px, 2.6vh, 24px); letter-spacing: 2px;
}
.hero-card.daily .hc-title { color: var(--gold); }
.hc-sub { font-size: 12px; color: rgba(255, 255, 255, .65); }
.hc-sub b { color: var(--gold); font-variant-numeric: tabular-nums; }
.hero-card.play .hc-sub { color: rgba(255, 255, 255, .8); }

/* Tuiles secondaires : compactes, toutes visibles d'un coup d'œil */
.home-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}
.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: clamp(8px, 1.6vh, 14px) 6px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid var(--line); border-radius: 13px;
  color: var(--text); font-family: var(--font);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.tile:hover { background: rgba(255, 255, 255, .1); border-color: var(--purple); transform: translateY(-2px); }
.tile span { font-size: clamp(16px, 2.2vh, 22px); line-height: 1; }
.tile b { font-size: 12px; font-weight: 700; letter-spacing: .3px; }
.tile i {
  position: absolute; top: 5px; right: 7px;
  font-style: normal; font-size: 10px; color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* Pied : identité du joueur + records */
.home-foot {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid var(--line); border-radius: 14px;
}
.hf-id { display: flex; align-items: center; gap: 10px; }
.hf-avatar {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--purple), #6a2fd0);
  border-radius: 11px; font-size: 19px;
}
.hf-id b { display: block; font-size: 14px; }
.hf-id small { color: var(--muted); font-size: 11px; }
.hf-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; flex: 1; min-width: 240px;
}
.hf-stat { text-align: center; }
.hf-stat span { display: block; font-size: 10px; color: var(--muted); }
.hf-stat b { font-size: 14px; font-variant-numeric: tabular-nums; }

.logo {
  font-family: var(--font-display); font-weight: 900;
  /* Borné par la hauteur aussi : sur un écran court le titre ne doit pas
     pousser le reste du menu hors de la fenêtre. */
  font-size: clamp(30px, min(9vw, 9vh), 76px);
  letter-spacing: clamp(2px, 1vw, 8px); line-height: .95;
  text-shadow: 0 0 40px rgba(145, 70, 255, .55);
}
.logo span {
  display: block;
  background: linear-gradient(90deg, var(--purple), var(--blue));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.tagline {
  color: var(--muted);
  font-size: clamp(12px, 1.8vh, 17px);
  margin-top: 4px; letter-spacing: 1px;
}

.menu-buttons { display: flex; flex-direction: column; gap: 9px; width: min(320px, 84vw); }
/* Modificateur « en ligne ». Nommé `inline` et NON `row` : `.row` est déjà la
   classe des lignes de tableau (`display: grid`, colonnes fixes). La collision
   plaçait les boutons dans les colonnes du tableau et écrasait le premier. */
.menu-buttons.inline {
  display: flex; flex-direction: row; flex-wrap: wrap;
  justify-content: center; width: auto;
}
.menu-buttons.inline .btn { flex: 0 0 auto; white-space: nowrap; }

.menu-foot {
  display: flex; gap: 18px; flex-wrap: wrap; justify-content: center;
  margin-top: 26px; font-size: 13px; color: var(--muted);
}

/* ---------------- Boutons ---------------- */

.btn {
  padding: 11px 20px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line); border-radius: 11px;
  color: var(--text); font-family: var(--font);
  font-size: 15px; font-weight: 700; letter-spacing: 1px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s;
  text-align: center;
}
.btn:hover { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .25); }
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--purple), #6a2fd0);
  border-color: transparent;
  box-shadow: 0 5px 22px rgba(145, 70, 255, .4);
}
.btn.primary:hover { filter: brightness(1.15); }
.btn.big { padding: 15px 26px; font-size: 18px; font-family: var(--font-display); }
.btn.small { padding: 7px 13px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(255, 77, 109, .5); color: #ff8fa3; }
.btn.danger:hover { background: rgba(255, 77, 109, .15); }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------------- Cartes ---------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.card-grid.small { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

.card {
  --accent: var(--purple);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 15px 12px;
  background: var(--panel-2);
  border: 2px solid var(--line); border-radius: var(--radius);
  color: var(--text); text-align: center;
  cursor: pointer; font-family: var(--font);
  transition: transform .12s, border-color .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 8px 26px rgba(0, 0, 0, .5);
}
.card.locked { opacity: .5; cursor: not-allowed; filter: grayscale(.7); }
.card.locked:hover { transform: none; border-color: var(--line); }
.card-icon { font-size: 34px; line-height: 1; }
.card b { font-size: 16px; letter-spacing: .5px; }
.card p { font-size: 12px; color: var(--muted); line-height: 1.35; }
.card small { font-size: 11px; color: var(--muted); }
.card small.lock { color: var(--gold); }
.wstats { display: flex; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 3px; }
.shop-card .btn { margin-top: 8px; width: 100%; }

/* ---------------- Onglets ---------------- */

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  padding: 7px 14px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line); border-radius: 20px;
  color: var(--muted); font-family: var(--font);
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: all .15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--purple); border-color: transparent; color: #fff; }

/* ---------------- Tableaux ---------------- */

.table { display: flex; flex-direction: column; gap: 2px; }
.row {
  display: grid;
  grid-template-columns: 46px 1fr 96px 66px 76px;
  gap: 8px; align-items: center;
  padding: 9px 12px;
  background: rgba(255, 255, 255, .03);
  border-radius: 8px; font-size: 14px;
}
.row.head {
  background: none; color: var(--muted);
  font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase;
}
.row.me { background: rgba(145, 70, 255, .2); box-shadow: inset 3px 0 0 var(--purple); }
.row.top1 { background: rgba(255, 176, 32, .13); }
.row.top2 { background: rgba(200, 200, 210, .1); }
.row.top3 { background: rgba(205, 127, 50, .1); }

/* ---------------- Statistiques ---------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.stat-grid.compact { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, .04);
  border-radius: 8px; font-size: 13px;
}
.stat span { color: var(--muted); }
.stat b { font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---------------- Succès ---------------- */

.ach-progress {
  height: 6px; margin-bottom: 16px;
  background: rgba(255, 255, 255, .08);
  border-radius: 6px; overflow: hidden;
}
.ach-progress > div {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--purple), var(--gold));
  transition: width .5s ease;
}
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 9px;
}
.ach {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--line); border-radius: 11px;
  opacity: .55;
}
.ach.done {
  opacity: 1;
  border-color: rgba(255, 176, 32, .5);
  background: rgba(255, 176, 32, .08);
}
.ach-icon { font-size: 26px; }
.ach b { display: block; font-size: 14px; }
.ach small { color: var(--muted); font-size: 12px; }

/* ---------------- Profil ---------------- */

.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.avatar {
  width: 62px; height: 62px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--purple), #6a2fd0);
  border-radius: 16px; font-size: 30px;
}
.name-input {
  width: 100%; max-width: 260px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); font-family: var(--font);
  font-size: 17px; font-weight: 700;
}
.auth-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }

/* ---------------- Tutoriel ---------------- */

.tuto { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; }
.tuto-block {
  padding: 15px 18px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.tuto-block h3 { font-size: 16px; margin-bottom: 9px; color: var(--purple-soft); }
.tuto-block ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.tuto-block li { font-size: 13.5px; color: #cfd3de; line-height: 1.45; }
.biome-list { display: flex; flex-wrap: wrap; gap: 6px; }
.biome-chip {
  --accent: var(--purple);
  padding: 4px 10px;
  border: 1px solid var(--accent); border-radius: 20px;
  font-size: 12px; color: var(--accent);
}

/* ---------------- Paramètres ---------------- */

.settings { display: flex; flex-direction: column; gap: 3px; }
.setting {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .03);
  border-radius: 9px; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.setting:hover { background: rgba(255, 255, 255, .06); }
.setting > span { flex: 1; }
.setting .sval { min-width: 52px; text-align: right; color: var(--purple-soft); font-variant-numeric: tabular-nums; }

.setting input[type=range] {
  width: 150px; height: 4px;
  background: rgba(255, 255, 255, .15);
  border-radius: 4px; appearance: none; cursor: pointer;
}
.setting input[type=range]::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 16px;
  background: var(--purple); border-radius: 50%; cursor: pointer;
  box-shadow: 0 0 8px rgba(145, 70, 255, .7);
}
.setting input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border: none;
  background: var(--purple); border-radius: 50%; cursor: pointer;
}
.setting input[type=checkbox] { display: none; }
/* L'interrupteur sert aussi dans l'écran de configuration avant partie */
.setting .switch, .setup-field .switch {
  width: 42px; height: 23px; flex: none;
  background: rgba(255, 255, 255, .15);
  border-radius: 20px; position: relative;
  transition: background .2s;
}
.setting .switch::after, .setup-field .switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 17px; height: 17px;
  background: #fff; border-radius: 50%;
  transition: transform .2s;
}
.setting input:checked ~ .switch,
.setup-field input:checked ~ .switch { background: var(--purple); }
.setting input:checked ~ .switch::after,
.setup-field input:checked ~ .switch::after { transform: translateX(19px); }
/* Écran de configuration avant partie */
.setup { text-align: left; }
.setup h2 { text-align: center; }
.setup > .hint { text-align: center; margin-bottom: 16px; }
.setup-field {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px; margin-bottom: 10px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line); border-radius: 12px;
}
.setup-field > span { font-size: 14px; font-weight: 700; }
.setup-field > span b { color: var(--purple-soft); font-variant-numeric: tabular-nums; }
.setup-field small { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.setup-field input[type=text] {
  padding: 9px 12px;
  background: rgba(0, 0, 0, .35);
  border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); font-family: var(--font); font-size: 15px;
}
.setup-field input[type=text]:focus { outline: none; border-color: var(--purple); }
.setup-field input[type=range] {
  width: 100%; height: 4px;
  background: rgba(255, 255, 255, .15);
  border-radius: 4px; appearance: none; cursor: pointer;
}
.setup-field input[type=range]::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 16px;
  background: var(--purple); border-radius: 50%; cursor: pointer;
}
.setup-field.row { flex-direction: row; align-items: center; cursor: pointer; }
.setup-field.row > span { flex: 1; }
.setup-field.row input[type=checkbox] { display: none; }
.setup-actions { margin-top: 16px; }

.setting select, .setting input[type=text] {
  padding: 6px 11px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font-family: var(--font); font-size: 14px;
}

/* ---------------- Montée de niveau ---------------- */

.levelup-inner { text-align: center; width: 100%; }
.levelup-title {
  font-family: var(--font-display); font-size: clamp(26px, 5vw, 44px);
  font-weight: 900; letter-spacing: 3px;
  color: var(--gold); text-shadow: 0 0 34px rgba(255, 176, 32, .6);
  animation: pop .4s cubic-bezier(.2, 1.5, .4, 1);
}
.levelup-sub { color: var(--muted); margin-bottom: 24px; letter-spacing: 2px; font-size: 14px; }

.upgrade-row {
  display: flex; gap: 14px; justify-content: center; flex-wrap: wrap;
}
.upgrade-card {
  --tier: var(--purple);
  position: relative;
  width: min(240px, 82vw); min-height: 230px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 22px 16px;
  background: linear-gradient(180deg, rgba(28, 28, 44, .96), rgba(16, 16, 26, .96));
  border: 2px solid var(--tier); border-radius: 18px;
  color: var(--text); font-family: var(--font);
  cursor: pointer; text-align: center;
  box-shadow: 0 0 26px -8px var(--tier);
  transition: transform .14s, box-shadow .14s;
  animation: cardIn .35s cubic-bezier(.2, 1.3, .4, 1) backwards;
}
.upgrade-card:nth-child(2) { animation-delay: .07s; }
.upgrade-card:nth-child(3) { animation-delay: .14s; }
.upgrade-card:hover { transform: translateY(-8px) scale(1.03); box-shadow: 0 12px 40px -6px var(--tier); }
.uc-tier {
  font-size: 10px; letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--tier); font-weight: 700;
}
.uc-icon { font-size: 46px; line-height: 1; }
.upgrade-card h3 { font-size: 19px; letter-spacing: .5px; }
.upgrade-card p { font-size: 14px; color: #c3c8d4; line-height: 1.4; flex: 1; }
.uc-level {
  font-size: 11px; padding: 3px 10px;
  background: rgba(255, 255, 255, .1); border-radius: 20px; color: var(--muted);
}

/* ---------------- Marchand ---------------- */

.merchant-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.merchant-card {
  width: 130px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 15px 10px;
  background: var(--panel-2);
  border: 2px solid var(--gold); border-radius: var(--radius);
  color: var(--text); font-family: var(--font); cursor: pointer;
  transition: transform .12s;
}
.merchant-card:hover:not(:disabled) { transform: translateY(-4px); }
.merchant-card.sold { opacity: .4; border-color: var(--line); }
.merchant-card.poor { border-color: rgba(255, 77, 109, .5); }
.mc-icon { font-size: 30px; }
.merchant-card b { font-size: 13px; }
.mc-price { font-size: 13px; color: var(--gold); font-weight: 700; }

/* ---------------- Fin de partie ---------------- */

.go-title {
  text-align: center; color: var(--red);
  text-shadow: 0 0 30px rgba(255, 77, 109, .5);
  letter-spacing: 4px;
}
.go-score {
  text-align: center;
  font-family: var(--font-display); font-size: clamp(40px, 9vw, 76px);
  font-weight: 900; color: var(--gold);
  text-shadow: 0 0 40px rgba(255, 176, 32, .5);
  margin: 6px 0 14px;
  animation: pop .5s cubic-bezier(.2, 1.5, .4, 1);
}
.go-records { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.record-badge {
  padding: 5px 14px;
  background: linear-gradient(135deg, var(--gold), #ff8c00);
  border-radius: 20px; color: #1a1000;
  font-weight: 700; font-size: 13px; letter-spacing: 1px;
  animation: pop .4s ease;
}
.unlock-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.unlock {
  padding: 6px 14px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line); border-radius: 20px; font-size: 13px;
}
.unlock.gold { border-color: var(--gold); color: var(--gold); }
.coins-badge { color: var(--gold); font-weight: 700; font-size: 16px; }

/* ==================================================================
   Animations
   ================================================================== */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes panelIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(26px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes bannerIn {
  0% { opacity: 0; transform: translateX(-50%) scale(.8); }
  60% { transform: translateX(-50%) scale(1.05); }
  100% { opacity: 1; transform: translateX(-50%) scale(1); }
}

/* ==================================================================
   Responsive
   ================================================================== */

/* Tablettes */
@media (max-width: 900px) {
  :root { --hud-pad: 10px; }
  #minimap { width: 108px; height: 108px; }
  .vote-panel { width: min(260px, 60vw); }
  .row { grid-template-columns: 38px 1fr 76px 50px 60px; font-size: 13px; }
}

/* Mobiles */
@media (max-width: 620px) {
  .hud-top-left { width: 54vw; }
  .bar { height: 15px; }
  .bar-text { font-size: 11px; }
  #minimap { width: 82px; height: 82px; }
  .biome-badge { font-size: 11px; padding: 3px 8px; }
  .hud-events { top: 150px; }
  .vote-panel {
    left: var(--hud-pad); right: var(--hud-pad);
    width: auto; bottom: 74px;
    /* Déjà pleine largeur sur mobile : l'agrandir déborderait de l'écran */
    --vote-scale: 1;
  }
  /* Le panneau de vote occupe le bas de l'écran : le fil remonte au-dessus */
  .invader-feed { bottom: auto; top: 200px; max-width: 62vw; }
  .inv-entry { font-size: 12px; padding: 3px 8px; }
  .vote-name { font-size: 12px; }
  .weapon-card { padding: 5px 10px; }
  .w-name { font-size: 13px; }
  .upgrade-card { width: min(300px, 88vw); min-height: 0; padding: 16px; }
  .uc-icon { font-size: 36px; }
  .panel { padding: 18px 14px; border-radius: 16px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .toast-stack { top: 74px; }

  /* Accueil compacté sur mobile */
  .home-hero { grid-template-columns: 1fr; }
  .home-tiles { grid-template-columns: repeat(3, 1fr); }
  .home-foot { justify-content: center; }
  .hf-stats { grid-template-columns: repeat(2, 1fr); min-width: 0; }
}

/* Écran tactile : on rappelle les zones de contrôle */
@media (pointer: coarse) {
  body::after {
    content: 'Déplacement';
    position: fixed; left: 24px; bottom: 24px; z-index: 5;
    font-size: 11px; color: rgba(255, 255, 255, .25);
    letter-spacing: 2px; pointer-events: none;
  }
  body.in-menu::after { display: none; }
}

/* Très grands écrans : on limite l'étirement du HUD */
@media (min-width: 1900px) {
  :root { --hud-pad: 28px; }
  #minimap { width: 190px; height: 190px; }
}

/* ------------------------------------------------------------------ */
/* Améliorations à voie exclusive                                      */
/* ------------------------------------------------------------------ */

.uc-voie {
  display: block; margin-top: 6px;
  font-size: 11px; line-height: 1.3;
  color: #ffb020;
}
/* Liseré ambré : la carte se repère au premier coup d'œil parmi les autres */
.upgrade-card.exclusive { box-shadow: inset 0 0 0 1px rgba(255, 176, 32, .45); }

/* ------------------------------------------------------------------ */
/* Confirmation d'arme trouvée au sol                                  */
/* ------------------------------------------------------------------ */

.weapon-compare {
  display: flex; align-items: stretch; justify-content: center;
  gap: 10px; margin: 14px 0 18px;
}
.wc-card {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 12px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 12px; text-align: center;
}
/* L'arme proposée est mise en avant : c'est elle qui fait l'objet du choix */
.wc-card.offered { border-color: rgba(145, 70, 255, .55); background: rgba(145, 70, 255, .1); }
.wc-card.current { opacity: .82; }
.wc-label {
  font-size: 10px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--muted);
}
.wc-icon { font-size: 34px; line-height: 1.1; }
.wc-card b { font-size: 16px; }
.wc-rarity { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; }
.wc-desc { font-size: 12px; color: var(--muted); line-height: 1.35; }
.wc-arrow { align-self: center; color: var(--muted); font-size: 22px; }

@media (max-width: 560px) {
  .weapon-compare { flex-direction: column; }
  .wc-arrow { transform: rotate(90deg); }
}

/* ------------------------------------------------------------------ */
/* Panneau admin                                                       */
/* ------------------------------------------------------------------ */

/* `.admin-row` et non `.row` : cette dernière est une grille de tableau,
   la réutiliser ici casserait l'alignement du classement. */
.admin-row {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  gap: 8px; margin: 8px 0;
}
.admin-field {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted);
}
.admin-field.grow { flex: 1 1 220px; }
.admin-field input,
.admin-field select {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px; padding: 8px 10px;
  color: #fff; font: inherit; font-size: 14px; text-transform: none;
  letter-spacing: 0;
}
.admin-field input:focus,
.admin-field select:focus { outline: 2px solid var(--purple); outline-offset: 1px; }
.admin-field input[type="number"] { width: 110px; }

.hint.bad { color: var(--red); }

.admin-check {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
}
.admin-check input { accent-color: var(--purple); }

/* La tuile admin se démarque : elle n'a rien à faire dans un menu public */
.tile.admin-tile, .btn.admin-tile {
  border-color: rgba(255, 176, 32, .45);
  box-shadow: inset 0 0 0 1px rgba(255, 176, 32, .18);
}

/* Accessibilité : respect de la préférence « moins d'animations » */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
