/* =========================================================
   DRIFT — feuille de style
   Identité : abîme bioluminescent. Lumière = retour visuel.
   Palette
     --abyss  #03101d   le plus profond
     --deep   #0a2740   bleu profond
     --mid    #0f3a56   haut du dégradé (lumière lointaine)
     --aqua   #79f2da   la lueur (joueur / accents)
     --spore  #ffd27d   ambre (à capter)
     --danger #ff5d8f   le leurre / le danger
     --violet #b06bff   pouvoirs / profondeur
     --ink    #d7eef4   texte
     --muted  #6f93a1   texte discret
   Type
     Syne        — titres (sculptural, organique-futuriste)
     Space Mono  — données / HUD / légendes
   ========================================================= */

:root {
  --abyss: #03101d;
  --deep: #0a2740;
  --mid: #0f3a56;
  --aqua: #79f2da;
  --spore: #ffd27d;
  --danger: #ff5d8f;
  --violet: #b06bff;
  --mint: #7effb3;
  --ice: #96d6ff;
  --ink: #d7eef4;
  --muted: #6f93a1;

  --panel: rgba(8, 28, 45, 0.74);
  --hairline: rgba(121, 242, 218, 0.18);

  /* spectre d'aura : aqua -> menthe -> glace -> violet -> rose -> aqua (boucle) */
  --aura-gradient: linear-gradient(100deg, #79f2da, #7effb3, #96d6ff, #b06bff, #ff9ecf, #79f2da);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--abyss);
  color: var(--ink);
  font-family: "Space Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;            /* le glisser du doigt pilote la lueur (pas de scroll) */
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* léger vignettage par-dessus le canvas */
#game::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 38%, transparent 52%, rgba(0, 0, 0, 0.45) 100%);
  z-index: 1;
}

.is-hidden { display: none !important; }

/* =========================================================
   HUD
   ========================================================= */
.hud {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  padding:
    calc(14px + var(--safe-t))
    calc(14px + var(--safe-r))
    calc(14px + var(--safe-b))
    calc(14px + var(--safe-l));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hud-row { display: flex; justify-content: space-between; align-items: flex-start; }
.hud-bottom { display: flex; justify-content: flex-end; align-items: flex-end; }
.hud-top { display: flex; flex-direction: column; gap: 10px; }

/* Bouton de tir (mode survie) : en bas à droite, sous le pouce */
.fire-btn {
  pointer-events: auto;
  width: 66px; height: 66px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  border: 2px solid var(--aqua);
  background: radial-gradient(circle at 40% 35%, rgba(121, 242, 218, 0.22), rgba(8, 28, 45, 0.85) 70%);
  color: var(--aqua);
  box-shadow: 0 0 18px rgba(121, 242, 218, 0.35);
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.fire-btn svg { width: 30px; height: 30px; }
.fire-btn:active { transform: scale(0.92); }
.fire-btn .fire-label {
  position: absolute;
  bottom: -2px;
  font-family: "Space Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  background: var(--abyss);
  padding: 0 4px;
  border-radius: 6px;
}
.fire-btn.ready { animation: fireReady 1.8s ease-in-out infinite; }
.fire-btn.active {
  border-color: var(--spore);
  color: var(--spore);
  box-shadow: 0 0 26px rgba(255, 210, 125, 0.7);
}
.fire-btn.cooldown {
  border-color: var(--muted);
  color: var(--muted);
  box-shadow: none;
  opacity: 0.7;
}
.fire-btn.locked {
  border-color: var(--hairline);
  color: var(--muted);
  box-shadow: none;
  opacity: 0.55;
}
@keyframes fireReady {
  0%, 100% { box-shadow: 0 0 16px rgba(121, 242, 218, 0.35); }
  50% { box-shadow: 0 0 26px rgba(121, 242, 218, 0.65); }
}

.hud-cluster { display: flex; gap: 14px; align-items: center; }
.hud-cluster--right { gap: 12px; }

.stat { display: flex; flex-direction: column; line-height: 1; }
.stat--right { align-items: flex-end; text-align: right; }

.stat-label {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(121, 242, 218, 0.18);
}

.combo {
  font-weight: 700;
  font-size: 18px;
  color: var(--aqua);
  padding: 4px 10px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: rgba(121, 242, 218, 0.06);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.25s ease;
  text-shadow: 0 0 16px rgba(121, 242, 218, 0.55);
}
.combo.is-on { opacity: 1; }
.combo.bump { animation: combopop 0.32s ease; }
@keyframes combopop {
  0% { transform: scale(1); }
  45% { transform: scale(1.34); }
  100% { transform: scale(1); }
}

.icon-btn {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--hairline);
  background: rgba(8, 28, 45, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.1s ease;
}
.icon-btn:hover { border-color: rgba(121, 242, 218, 0.5); }
.icon-btn:active { transform: scale(0.94); }
.icon-pause {
  width: 12px; height: 14px;
  border-left: 3px solid var(--aqua);
  border-right: 3px solid var(--aqua);
  box-shadow: 0 0 12px rgba(121, 242, 218, 0.5);
}

.lives { display: flex; gap: 9px; align-items: center; }
.life {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, var(--aqua) 60%, rgba(121, 242, 218, 0) 72%);
  box-shadow: 0 0 12px rgba(121, 242, 218, 0.7);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.life.is-lost { opacity: 0.16; transform: scale(0.7); box-shadow: none; background: var(--muted); }

.powerups { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 100%; min-height: 0; }
.pill {
  position: relative;
  overflow: hidden;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 6px 10px 7px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  background: rgba(8, 28, 45, 0.6);
  color: var(--ink);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.pill .bar {
  position: absolute;
  left: 0; bottom: 0;
  height: 2px; width: 100%;
  transform-origin: left;
  transition: transform 0.1s linear;
}
.pill--shield { border-color: rgba(121, 242, 218, 0.45); color: var(--aqua); }
.pill--shield .bar { background: var(--aqua); }
.pill--slow { border-color: rgba(176, 107, 255, 0.45); color: var(--violet); }
.pill--slow .bar { background: var(--violet); }
.pill--x2 { border-color: rgba(255, 210, 125, 0.5); color: var(--spore); }
.pill--x2 .bar { background: var(--spore); }
.pill--magnet { border-color: rgba(126, 255, 179, 0.5); color: var(--mint); }
.pill--magnet .bar { background: var(--mint); }
.pill--pulse { border-color: rgba(255, 93, 143, 0.5); color: var(--danger); }
.pill--pulse .bar { background: var(--danger); }
.pill--phase { border-color: rgba(150, 214, 255, 0.5); color: var(--ice); }
.pill--phase .bar { background: var(--ice); }
.pill--beacon { border-color: rgba(198, 240, 255, 0.55); color: #c6f0ff; }
.pill--beacon .bar { background: #c6f0ff; }

/* =========================================================
   Écrans superposés
   ========================================================= */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px;
  background:
    radial-gradient(80% 60% at 50% 30%, rgba(15, 58, 86, 0.35), transparent 70%),
    rgba(3, 16, 29, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.panel {
  width: min(440px, 100%);
  margin: auto;
  text-align: center;
  padding: 34px 28px 30px;
  border-radius: 22px;
  border: 1px solid var(--hairline);
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(121, 242, 218, 0.12);
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--muted);
}

.title {
  font-family: "Syne", ui-sans-serif, system-ui, sans-serif;
  font-weight: 800;
  margin: 0;
  max-width: 100%;
  overflow-wrap: break-word;
  font-size: clamp(56px, 18vw, 88px);
  letter-spacing: 0.04em;
  line-height: 0.92;
  background: linear-gradient(180deg, #ffffff 0%, var(--aqua) 78%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 26px rgba(121, 242, 218, 0.35));
  animation: breathe 5.5s ease-in-out infinite;
}
.title--sm { font-size: clamp(30px, 8.5vw, 44px); letter-spacing: 0.01em; }
.title--lg { font-size: clamp(30px, 9vw, 46px); }

/* Wordmark Aura : aura iridescente animée + double halo (aqua + violet) */
.title--xl {
  font-size: clamp(56px, 15vw, 84px);
  white-space: nowrap;
  overflow-wrap: normal;
  background: var(--aura-gradient);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.02em;
  filter:
    drop-shadow(0 0 22px rgba(121, 242, 218, 0.45))
    drop-shadow(0 0 44px rgba(176, 107, 255, 0.25));
  animation: auraShift 9s linear infinite, breathe 5.5s ease-in-out infinite;
}
@keyframes auraShift {
  0% { background-position: 0% center; }
  100% { background-position: -100% center; }
}

@keyframes breathe {
  0%, 100% { filter: drop-shadow(0 0 22px rgba(121, 242, 218, 0.28)); }
  50% { filter: drop-shadow(0 0 38px rgba(121, 242, 218, 0.5)); }
}

.tagline {
  margin: 16px auto 0;
  max-width: 30ch;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  opacity: 0.86;
}

.legend {
  list-style: none;
  margin: 22px auto 26px;
  padding: 0;
  display: inline-flex;
  flex-direction: column;
  gap: 11px;
  text-align: left;
  font-size: 12px;
  color: var(--muted);
}
.legend li { display: flex; align-items: center; gap: 11px; }
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  flex: 0 0 auto;
}
.dot--spore { background: var(--spore); box-shadow: 0 0 12px rgba(255, 210, 125, 0.8); }
.dot--danger {
  background: radial-gradient(circle at 50% 50%, #1a0e22 40%, var(--danger) 100%);
  box-shadow: 0 0 12px rgba(255, 93, 143, 0.6);
}
.dot--power { background: var(--violet); box-shadow: 0 0 12px rgba(176, 107, 255, 0.8); }

.btn {
  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.06em;
  padding: 14px 26px;
  min-height: 48px;
  border-radius: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.1s ease, box-shadow 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:focus-visible { outline: 2px solid var(--aqua); outline-offset: 3px; }

.btn--primary {
  color: #042018;
  background: linear-gradient(180deg, #a8fbe9, var(--aqua));
  box-shadow: 0 10px 30px rgba(121, 242, 218, 0.28), 0 0 22px rgba(176, 107, 255, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn--primary:hover { box-shadow: 0 14px 40px rgba(121, 242, 218, 0.42), 0 0 30px rgba(176, 107, 255, 0.28); }

.btn--ghost {
  color: var(--ink);
  background: rgba(121, 242, 218, 0.05);
  border-color: var(--hairline);
}
.btn--ghost:hover { border-color: rgba(121, 242, 218, 0.45); background: rgba(121, 242, 218, 0.1); }

/* Bouton premium (achat unique) */
.btn--premium {
  background: linear-gradient(135deg, #d4a017 0%, #f5c842 50%, #d4a017 100%);
  color: #1a1000;
  font-weight: 800;
  border: none;
  box-shadow: 0 0 22px rgba(245, 200, 66, 0.55);
  letter-spacing: 0.03em;
  animation: premiumPulse 2.2s ease-in-out infinite;
}
.btn--premium:hover, .btn--premium:active { filter: brightness(1.12); }
@keyframes premiumPulse {
  0%, 100% { box-shadow: 0 0 18px rgba(245, 200, 66, 0.5); }
  50%       { box-shadow: 0 0 36px rgba(245, 200, 66, 0.9); }
}
/* Bloc verrou dans l'aperçu de niveau */
.premium-gate {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: rgba(212, 160, 23, 0.10);
  border: 1px solid rgba(245, 200, 66, 0.35);
  border-radius: 14px; padding: 18px 20px; margin: 6px 0 2px; text-align: center;
}
.premium-gate__desc { font-family: "Space Mono", monospace; font-size: 13px; color: #f5c842; margin: 0; opacity: 0.9; }
.premium-gate__legal { font-size: 11px; color: var(--muted); margin: 0; }
/* Badge Premium sur la carte */
.map-stars.prem {
  background: linear-gradient(135deg, #d4a017, #f5c842);
  color: #1a1000; font-weight: 800; font-size: 10px; padding: 2px 7px; border-radius: 8px;
}

.btn-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }

.hint {
  margin: 18px 0 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.best {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--aqua);
  letter-spacing: 0.06em;
}

/* tableau de score (game over) */
.scoreboard {
  margin: 22px auto 0;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.score-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 2px;
  border-bottom: 1px solid rgba(121, 242, 218, 0.1);
}
.score-line:last-child { border-bottom: none; }
.score-line__label {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.score-line__value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.score-line--best .score-line__value { color: var(--aqua); }

.newbest {
  margin: 16px 0 0;
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.08em;
  color: var(--spore);
  text-shadow: 0 0 22px rgba(255, 210, 125, 0.55);
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

/* =========================================================
   Mouvement réduit
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  .title, .title--xl, .newbest, .panel { animation: none; }
  .combo, .pill .bar, .icon-btn, .btn { transition: none; }
}

/* =========================================================
   Profil, formulaire & classement
   ========================================================= */
.profile {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 auto 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: rgba(121, 242, 218, 0.05);
  color: var(--ink);
  font-family: "Space Mono", monospace;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.profile:hover { border-color: rgba(121, 242, 218, 0.45); background: rgba(121, 242, 218, 0.1); }
.profile:focus-visible { outline: 2px solid var(--aqua); outline-offset: 3px; }
.profile-flag { font-size: 18px; line-height: 1; }
.profile-name {
  font-weight: 700; letter-spacing: 0.02em;
  max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-edit {
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  border-left: 1px solid var(--hairline); padding-left: 10px;
}

.field { display: block; text-align: left; margin: 0 auto 14px; max-width: 320px; }
.field-label {
  display: block; margin-bottom: 7px;
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted);
}
.field-input {
  width: 100%;
  font-family: "Space Mono", monospace;
  font-size: 16px;                 /* 16px : évite le zoom auto sur iOS */
  color: var(--ink);
  background: rgba(3, 16, 29, 0.6);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.field-input::placeholder { color: var(--muted); }
.field-input:focus {
  border-color: rgba(121, 242, 218, 0.55);
  box-shadow: 0 0 0 3px rgba(121, 242, 218, 0.12);
}
select.field-input {
  appearance: none; -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--aqua) 50%),
    linear-gradient(135deg, var(--aqua) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}
select.field-input option { background: #07182d; color: var(--ink); }
.identity-hint { color: var(--danger); }

.board-scroll {
  max-height: 56vh;
  min-height: 200px;
  overflow-y: auto;
  touch-action: pan-y;
  margin: 8px 0 18px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(121, 242, 218, 0.4) transparent;
}
.board-scroll::-webkit-scrollbar { width: 8px; }
.board-scroll::-webkit-scrollbar-thumb { background: rgba(121, 242, 218, 0.3); border-radius: 8px; }
.board-scroll::-webkit-scrollbar-track { background: transparent; }

.miniboard { margin: 16px 0 4px; }

.board-list { list-style: none; margin: 0; padding: 0; }
.board-row {
  display: grid;
  grid-template-columns: 34px 26px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px;
  border: 1px solid transparent;
}
.board-row + .board-row { margin-top: 4px; }
.board-rank { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.board-flag { font-size: 18px; line-height: 1; text-align: center; }
.board-name { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-score { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }

/* podium */
.board-list > li:nth-child(1) .board-rank { color: var(--spore); }
.board-list > li:nth-child(2) .board-rank { color: #cfe7ee; }
.board-list > li:nth-child(3) .board-rank { color: #e0a878; }

.board-row.is-mine { background: rgba(121, 242, 218, 0.06); }
.board-row.is-you {
  background: rgba(121, 242, 218, 0.14);
  border-color: rgba(121, 242, 218, 0.5);
  box-shadow: 0 0 22px rgba(121, 242, 218, 0.18);
}
.board-row.is-you .board-score { color: var(--aqua); }

.board-gap { grid-template-columns: 1fr; justify-items: center; padding: 2px; color: var(--muted); }
.board-dots { letter-spacing: 0.3em; }

.board-empty { color: var(--muted); font-size: 13px; line-height: 1.6; padding: 22px 0; }

.rankline {
  margin: 14px 0 0;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--aqua);
}

/* =========================================================
   Drapeaux en image + barre de langue
   ========================================================= */
.flag {
  width: 22px;
  height: 16px;
  border-radius: 2px;
  object-fit: cover;
  vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}
.board-flag { display: flex; align-items: center; justify-content: center; }
.profile-flag { display: inline-flex; align-items: center; }
.profile-flag:empty { display: none; }

.langbar {
  display: inline-flex;
  align-self: center;
  gap: 2px;
  margin-bottom: 16px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: rgba(3, 16, 29, 0.55);
}
.lang {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: "Space Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}
.lang:hover { color: var(--ink); }
.lang:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; }
.lang.is-active {
  color: var(--abyss);
  background: var(--aqua);
  box-shadow: 0 0 18px rgba(121, 242, 218, 0.35);
}

/* =========================================================
   Bouton son + bandeau de déblocage
   ========================================================= */
.hud-ctrls { display: flex; gap: 8px; align-items: center; pointer-events: none; }

.mute-btn svg { width: 20px; height: 20px; }
.mute-btn .spk { fill: var(--ink); }
.mute-btn .wave { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }
.mute-btn .slash { stroke: var(--danger); stroke-width: 2; stroke-linecap: round; display: none; }
.mute-btn.is-muted .wave { display: none; }
.mute-btn.is-muted .slash { display: block; }

.unlock {
  position: absolute;
  top: 21%;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  z-index: 2;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: rgba(3, 16, 29, 0.66);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: "Space Mono", monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
  color: var(--aqua);
  opacity: 0;
  pointer-events: none;
}
.unlock.show { animation: unlockPop 2.6s ease forwards; }
@keyframes unlockPop {
  0% { opacity: 0; transform: translateX(-50%) translateY(2px) scale(0.96); }
  12% { opacity: 1; transform: translateX(-50%) translateY(-6px) scale(1); }
  80% { opacity: 1; transform: translateX(-50%) translateY(-6px) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .unlock.show { animation: none; opacity: 1; transform: translateX(-50%) translateY(-6px); }
}

/* Toggle daltonien (menu) */
.opts { display: flex; justify-content: center; margin-top: 10px; }
.cb-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: auto;
  padding: 7px 14px;
}
.cb-toggle svg { width: 16px; height: 16px; opacity: 0.85; }
.cb-toggle.is-active {
  color: var(--abyss);
  background: var(--aqua);
  border-color: var(--aqua);
}

/* =========================================================
   Responsive — petits écrans (mobile) : on resserre pour que
   l'écran de fin tienne et que les boutons restent atteignables
   ========================================================= */
@media (max-width: 480px) {
  .overlay { padding: 16px; }
  .panel { padding: 24px 18px 20px; border-radius: 18px; }
  .title { font-size: clamp(42px, 15vw, 60px); }
  .title--sm { font-size: clamp(28px, 8vw, 40px); letter-spacing: 0.01em; }
  .title--lg { font-size: clamp(28px, 10vw, 42px); }
}
@media (max-height: 720px) {
  .panel { padding-top: 22px; padding-bottom: 18px; }
  .title--lg { font-size: clamp(26px, 8vh, 42px); }
}

/* =========================================================
   Mode Aventure — carte des niveaux + écrans victoire/échec
   ========================================================= */
.panel--map { width: min(440px, 100%); }

.map-path {
  position: relative;
  width: 100%;
  max-height: 56vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 0 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  margin: 6px 0 14px;
}
/* fil sinueux central */
.map-path::before {
  content: "";
  position: absolute;
  top: 6px; bottom: 6px; left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(to bottom,
    rgba(121, 242, 218, 0.4) 0 6px, transparent 6px 15px);
}
.map-row { position: relative; z-index: 1; display: flex; justify-content: center; }
.map-row.l { justify-content: flex-start; padding-left: 16%; }
.map-row.r { justify-content: flex-end; padding-right: 16%; }

.map-node {
  position: relative;
  width: 62px; height: 62px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 38% 32%, rgba(121, 242, 218, 0.28), rgba(10, 39, 64, 0.92) 70%);
  border: 2px solid var(--aqua);
  box-shadow: 0 0 16px rgba(121, 242, 218, 0.35), inset 0 0 12px rgba(121, 242, 218, 0.12);
  color: var(--ink);
  font-family: "Syne", ui-sans-serif, sans-serif;
  font-weight: 800; font-size: 22px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.map-node:hover { transform: scale(1.07); }
.map-node:active { transform: scale(0.96); }
.map-node.done { border-color: var(--mint); box-shadow: 0 0 16px rgba(126, 255, 179, 0.4); }
.map-node.boss { border-color: var(--danger); color: #fff; box-shadow: 0 0 20px rgba(255, 93, 143, 0.5); }
.map-node.current {
  box-shadow: 0 0 26px rgba(121, 242, 218, 0.7), 0 0 52px rgba(176, 107, 255, 0.35);
  animation: nodePulse 2.4s ease-in-out infinite;
}
.map-node.locked {
  border-color: var(--hairline);
  color: var(--muted);
  background: rgba(10, 39, 64, 0.7);
  box-shadow: none;
  cursor: not-allowed;
}
.map-node.premlock {
  border-color: #f5c842;
  color: #f5c842;
  box-shadow: 0 0 18px rgba(245, 200, 66, 0.45);
  cursor: pointer;
}
@keyframes nodePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

.map-stars {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 1px;
  white-space: nowrap;
  color: var(--spore);
}
.map-stars.prem {
  color: var(--violet);
  font-family: "Space Mono", monospace;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* étoiles de victoire */
.stars-big { display: flex; justify-content: center; gap: 12px; margin: 8px 0 2px; }
.stars-big .star { font-size: 42px; line-height: 1; color: var(--muted); }
.stars-big .star.on {
  color: var(--spore);
  filter: drop-shadow(0 0 14px rgba(255, 210, 125, 0.7));
  animation: starPop 0.5s ease both;
}
.stars-big .star.on:nth-child(2) { animation-delay: 0.12s; }
.stars-big .star.on:nth-child(3) { animation-delay: 0.24s; }
@keyframes starPop {
  0% { transform: scale(0) rotate(-35deg); opacity: 0; }
  70% { transform: scale(1.25); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.victory-name {
  font-family: "Space Mono", monospace;
  color: var(--ice);
  font-size: 14px;
  letter-spacing: 0.04em;
  margin: 4px 0 6px;
}
@media (prefers-reduced-motion: reduce) {
  .map-node.current { animation: none; }
  .stars-big .star.on { animation: none; }
}

/* Aperçu de niveau — objectif mis en avant */
.intro-boss {
  display: inline-block;
  margin: 2px auto 0;
  padding: 3px 12px;
  border-radius: 999px;
  border: 1px solid var(--danger);
  color: var(--danger);
  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.objective {
  margin: 16px 0 6px;
  padding: 20px 18px;
  border-radius: 16px;
  border: 1px solid var(--hairline);
  background: rgba(8, 28, 45, 0.5);
}
.objective-text {
  font-family: "Syne", ui-sans-serif, sans-serif;
  font-weight: 800;
  font-size: clamp(22px, 6vw, 30px);
  line-height: 1.1;
  background: linear-gradient(180deg, #ffffff 0%, var(--aqua) 85%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Barre de PV du boss */
.boss-bar {
  pointer-events: none;
  margin: 10px auto 0;
  width: min(440px, 86%);
  display: flex;
  align-items: center;
  gap: 10px;
}
.boss-bar-label {
  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--danger);
}
.boss-bar-track {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(8, 28, 45, 0.7);
  border: 1px solid var(--hairline);
  overflow: hidden;
}
.boss-bar-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--danger), var(--violet));
  box-shadow: 0 0 12px rgba(255, 93, 143, 0.5);
  transition: width 0.25s ease, background 0.3s ease;
}
.boss-bar-fill.vuln {
  background: linear-gradient(90deg, var(--aqua), var(--mint));
  box-shadow: 0 0 14px rgba(121, 242, 218, 0.6);
}

/* Strates de la carte (ambiance par tranche de 10 niveaux : descente dans l'abîme) */
.map-node.strata-0:not(.locked):not(.done):not(.boss) { border-color: #79f2da; background: radial-gradient(circle at 38% 32%, rgba(121,242,218,0.30), rgba(10,30,52,0.92) 70%); }
.map-node.strata-1:not(.locked):not(.done):not(.boss) { border-color: #96d6ff; background: radial-gradient(circle at 38% 32%, rgba(150,214,255,0.30), rgba(10,30,52,0.92) 70%); }
.map-node.strata-2:not(.locked):not(.done):not(.boss) { border-color: #6fc6e8; background: radial-gradient(circle at 38% 32%, rgba(111,198,232,0.30), rgba(10,30,52,0.92) 70%); }
.map-node.strata-3:not(.locked):not(.done):not(.boss) { border-color: #8aa0ff; background: radial-gradient(circle at 38% 32%, rgba(138,160,255,0.30), rgba(12,26,50,0.92) 70%); }
.map-node.strata-4:not(.locked):not(.done):not(.boss) { border-color: #b06bff; background: radial-gradient(circle at 38% 32%, rgba(176,107,255,0.30), rgba(14,22,46,0.92) 70%); }
.map-node.strata-5:not(.locked):not(.done):not(.boss) { border-color: #cf6bff; background: radial-gradient(circle at 38% 32%, rgba(207,107,255,0.30), rgba(16,20,44,0.92) 70%); }
.map-node.strata-6:not(.locked):not(.done):not(.boss) { border-color: #ff6bd5; background: radial-gradient(circle at 38% 32%, rgba(255,107,213,0.30), rgba(20,16,40,0.92) 70%); }
.map-node.strata-7:not(.locked):not(.done):not(.boss) { border-color: #ff5d8f; background: radial-gradient(circle at 38% 32%, rgba(255,93,143,0.30), rgba(22,14,36,0.92) 70%); }
.map-node.strata-8:not(.locked):not(.done):not(.boss) { border-color: #ff9d5d; background: radial-gradient(circle at 38% 32%, rgba(255,157,93,0.30), rgba(24,14,30,0.92) 70%); }
.map-node.strata-9:not(.locked):not(.done):not(.boss) { border-color: #ffe9a8; background: radial-gradient(circle at 38% 32%, rgba(255,233,168,0.32), rgba(26,16,24,0.92) 70%); box-shadow: 0 0 18px rgba(255,233,168,0.5); }

/* Code de récupération (écran profil) */
.recovery {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  text-align: left;
}
.recovery-title {
  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ice);
  margin: 0 0 4px;
}
.recovery-hint { margin: 0 0 10px; }
.recovery-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 8px; }
.recovery-row .field-input { flex: 1; min-width: 0; }
.recovery-code {
  font-family: "Space Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.btn--mini {
  flex: 0 0 auto;
  padding: 0 14px;
  min-height: 0;
  font-size: 13px;
  white-space: nowrap;
}
.recovery-msg { margin: 2px 0 0; color: var(--mint); min-height: 1em; }

/* Indicateur de spores (réserve de l'arme, mode survie) */
.ammo-box {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  transition: color 0.3s ease, text-shadow 0.3s ease;
}
.ammo-box .ammo-spark { font-size: 12px; }
.ammo-box.t0 { color: var(--muted); }
.ammo-box.t1 { color: var(--aqua); text-shadow: 0 0 8px rgba(121, 242, 218, 0.5); }
.ammo-box.t2 { color: var(--mint); text-shadow: 0 0 10px rgba(126, 255, 179, 0.6); }
.ammo-box.t3 { color: var(--spore); text-shadow: 0 0 12px rgba(255, 210, 125, 0.7); }
.ammo-box.t4 { color: var(--ice); text-shadow: 0 0 12px rgba(150, 214, 255, 0.75); }
.ammo-box.t5 { color: var(--violet); text-shadow: 0 0 14px rgba(176, 107, 255, 0.8); }
.ammo-box.t6 { color: #ff9ecb; text-shadow: 0 0 16px rgba(255, 93, 143, 0.85); }
.ammo-box.t7 { color: #ffe6a6; text-shadow: 0 0 20px rgba(255, 210, 125, 1); }

/* --- Lien vers la page Univers (codex) depuis le menu --- */
.codex-line { text-align: center; margin: 16px 0 0; }
.codex-link {
  font-family: "Space Mono", monospace; font-size: 13px; letter-spacing: .04em;
  color: var(--aqua); text-decoration: none; opacity: .82;
  border-bottom: 1px solid rgba(121, 242, 218, .3); padding-bottom: 2px;
  transition: opacity .2s ease;
}
.codex-link:hover, .codex-link:focus-visible { opacity: 1; }
.codex-link::after { content: " \2197"; opacity: .7; }

/* --- Annonce d'apparition du boss (révélation du nom) --- */
.boss-intro {
  position: absolute; top: 47%; left: 50%; transform: translate(-50%, -50%);
  z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 7px;
  text-align: center; pointer-events: none; opacity: 0; width: 90%;
}
.boss-intro-eyebrow {
  font-family: "Space Mono", monospace; font-size: 12px; letter-spacing: 0.26em;
  text-transform: uppercase; color: var(--muted);
}
.boss-intro-name {
  font-family: "Syne", sans-serif; font-weight: 800; line-height: 0.95;
  font-size: clamp(40px, 13vw, 72px); color: var(--danger);
  text-shadow: 0 0 26px currentColor;
}
.boss-intro-title {
  font-family: "Space Mono", monospace; font-size: 13px; letter-spacing: 0.14em;
  color: var(--ink); opacity: 0.85;
}
.boss-intro.show { animation: bossIntro 2.9s ease forwards; }
@keyframes bossIntro {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.86); }
  13%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  78%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.04); }
}
@media (prefers-reduced-motion: reduce) {
  .boss-intro.show { animation: none; opacity: 1; }
}

/* --- Onglets du classement (Jour / Semaine / Tout) --- */
.board-tabs { display: flex; gap: 6px; margin: 26px auto 18px; justify-content: center; width: 100%; max-width: 360px; }
.board-tab {
  flex: 1; padding: 8px 6px; border-radius: 999px;
  border: 1px solid var(--hairline); background: rgba(10, 39, 64, 0.35);
  color: var(--muted); font-family: "Space Mono", monospace; font-size: 12px;
  font-weight: 700; letter-spacing: 0.05em; cursor: pointer; transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.board-tab:hover { color: var(--ink); }
.board-tab.is-active { color: #03101d; background: var(--aqua); border-color: var(--aqua); }
.board-tab:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; }

/* --- Intro cinématique (premier lancement) --- */
.cine {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  align-items: center; justify-content: center; overflow: hidden;
  background: radial-gradient(900px 600px at 50% 22%, #0c2c43, #04141f 58%, #01070d 100%);
  opacity: 1; transition: opacity .7s ease;
}
.cine.is-hidden { display: none; }
.cine.fade-out { opacity: 0; }
.cine-stage { position: relative; width: min(420px, 82vw); height: min(380px, 48vh); }
.cine-orb {
  position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%);
  width: 160px; height: 160px; border-radius: 50%; filter: blur(2px);
  background: radial-gradient(circle, rgba(255,210,125,.85), rgba(255,210,125,.18) 45%, transparent 70%);
  transition: top 1.8s cubic-bezier(.45,0,.2,1), width 1.8s ease, height 1.8s ease, opacity 1.8s ease, background 1.8s ease;
}
.cine-orb::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 46px; height: 46px; border-radius: 50%;
  background: #fff6e6; box-shadow: 0 0 50px 12px rgba(255,210,125,.6);
  transition: width 1.8s ease, height 1.8s ease, background 1.8s ease, box-shadow 1.8s ease;
}
.cine-stage.scene-1 .cine-orb { top: 30%; }
.cine-stage.scene-2 .cine-orb { top: 72%; width: 60px; height: 60px; opacity: .5;
  background: radial-gradient(circle, rgba(255,210,125,.5), transparent 70%); }
.cine-stage.scene-2 .cine-orb::after { width: 14px; height: 14px; box-shadow: 0 0 22px 6px rgba(255,210,125,.4); }
.cine-stage.scene-3 .cine-orb { top: 50%; width: 150px; height: 150px; opacity: 1;
  background: radial-gradient(circle, rgba(121,242,218,.8), rgba(121,242,218,.16) 45%, transparent 70%); }
.cine-stage.scene-3 .cine-orb::after { width: 40px; height: 40px; background: #eafff9; box-shadow: 0 0 46px 12px rgba(121,242,218,.7); }
.cine-spores { position: absolute; inset: 0; }
.cine-spore { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: #ffd27d; box-shadow: 0 0 10px #ffd27d; opacity: 0; transition: opacity 1s ease; }
.cine-stage.scene-2 .cine-spore, .cine-stage.scene-3 .cine-spore { opacity: .85; animation: cineDrift 6s ease-in-out infinite; }
@keyframes cineDrift { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
.cine-text {
  font-family: "Syne", sans-serif; font-weight: 700; font-size: clamp(22px, 6vw, 34px);
  color: var(--ink); text-align: center; max-width: 620px; padding: 0 26px; margin: 20px 0 0;
  opacity: 0; transform: translateY(8px); transition: opacity .8s ease, transform .8s ease;
  text-shadow: 0 0 24px rgba(121,242,218,.25);
}
.cine-text.show { opacity: 1; transform: translateY(0); }
.cine-skip {
  position: absolute; bottom: 26px; right: 22px; padding: 8px 18px; border-radius: 999px;
  border: 1px solid var(--hairline); background: rgba(3,16,29,.5); color: var(--muted);
  font-family: "Space Mono", monospace; font-size: 13px; letter-spacing: .06em; cursor: pointer;
}
.cine-skip:hover { color: var(--ink); }
.cine-skip:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .cine-orb, .cine-orb::after { transition: opacity .8s ease; } .cine-spore { animation: none; }
}

/* --- Panneau classement élargi --- */
.panel--board { width: min(540px, 100%); }

/* --- Objectif affiché sur l'écran de pause (mode aventure) --- */
.pause-objective {
  margin: 4px auto 20px; max-width: 320px;
  background: rgba(10, 39, 64, 0.4); border: 1px solid var(--hairline); border-radius: 14px;
  padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.pause-objective.is-hidden { display: none; }
.pause-objective .po-label {
  font-family: "Syne", sans-serif; font-weight: 700; font-size: 18px; color: #eafff9;
}
.pause-objective .po-prog {
  font-family: "Space Mono", monospace; font-size: 14px; letter-spacing: 0.05em; color: var(--aqua);
}
