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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  color: #e8f0ff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

/* Le monde de jeu (canvas) est vu de dessus, à plat. */
#world {
  position: absolute;
  inset: 0;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

/* Zone tactile : englobe les deux cercles fixes ci-dessous, pas de tir au
   doigt (voir InputManager.isFiring dans input.js — automatique sur mobile),
   donc plus besoin de partager l'écran entre plus de deux contrôles. Cachée
   par défaut : n'a de sens que sur un appareil tactile, voir Game constructor
   qui ajoute .touch-enabled une fois InputManager.isTouchDevice constaté. */
#touch-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  touch-action: none;
  display: none;
}
#touch-layer.touch-enabled { display: block; }

/* Deux cercles fixes en bas des coins gauche/droite (voir input.js
   InputManager pour la logique) : gauche = direction (viser un cap absolu),
   droite = poussée du moteur (proportionnelle à l'écart au centre). Discrets
   par défaut (faible opacité) pour ne pas polluer l'écran de jeu, un peu plus
   marqués tant qu'un doigt est dessus (.active) pour confirmer la prise. */
.touch-zone {
  position: absolute;
  bottom: max(env(safe-area-inset-bottom, 0px), 22px);
  width: 104px; height: 104px;
  border-radius: 50%;
  border: 2px solid rgba(90, 209, 255, 0.22);
  background: rgba(10, 14, 24, 0.18);
  transition: opacity 0.15s ease, border-color 0.15s ease;
  opacity: 0.7;
}
.touch-zone.active { opacity: 1; border-color: rgba(90, 209, 255, 0.5); }
.touch-zone-left { left: max(env(safe-area-inset-left, 0px), 22px); }
.touch-zone-right { right: max(env(safe-area-inset-right, 0px), 22px); }

.touch-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 44px; height: 44px;
  margin-left: -22px; margin-top: -22px;
  border-radius: 50%;
  background: rgba(90, 209, 255, 0.4);
  box-shadow: 0 0 12px rgba(90, 209, 255, 0.35);
  pointer-events: none;
  transition: background 0.15s ease;
}
.touch-zone.active .touch-knob { background: rgba(90, 209, 255, 0.65); }

#hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  padding: env(safe-area-inset-top, 12px) env(safe-area-inset-right, 14px) env(safe-area-inset-bottom, 12px) env(safe-area-inset-left, 14px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

#hud-top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding-top: 8px;
  padding-right: 56px; /* laisse la place aux boutons pause/muet en haut à droite */
}
.hud-block { display: flex; flex-direction: column; align-items: flex-start; }
.hud-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(232, 240, 255, 0.55);
}
.hud-value {
  font-size: 20px;
  font-weight: 700;
  color: #5ad1ff;
  text-shadow: 0 0 10px rgba(90, 209, 255, 0.5);
}

#hud-top-right {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  right: env(safe-area-inset-right, 14px);
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.icon-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(90, 209, 255, 0.3);
  background: rgba(10, 14, 24, 0.6);
  color: #e8f0ff;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.icon-btn:active { background: rgba(90, 209, 255, 0.25); }

#hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 8px;
}
/* Objets accumulés, en bas à gauche. */
#hud-loadout { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.hud-hidden { display: none; }

#toast {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  padding: 8px 18px;
  background: rgba(10, 14, 24, 0.75);
  border: 1px solid rgba(255, 224, 102, 0.5);
  color: #ffe066;
  font-weight: 700;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(6px); }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2, 4, 10, 0.72);
  backdrop-filter: blur(3px);
}
.overlay.visible { display: flex; }

/* L'écran d'accueil a sa propre scène animée en fond (voir main.js) : pas de
   voile sombre/flou générique par-dessus, le panneau se charge de la
   lisibilité du texte. */
#overlay-start {
  background: #070912;
  backdrop-filter: none;
}
#hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.panel {
  position: relative;
  z-index: 1;
  max-width: 420px;
  width: min(88vw, 420px);
  max-height: 92vh;
  overflow-y: auto;
  touch-action: pan-y;
  text-align: center;
  background: linear-gradient(180deg, rgba(20, 26, 44, 0.9), rgba(10, 13, 24, 0.9));
  border: 1px solid rgba(90, 209, 255, 0.25);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
#overlay-start .panel {
  background: linear-gradient(180deg, rgba(10, 13, 22, 0.62), rgba(6, 8, 14, 0.8));
  backdrop-filter: blur(5px);
}
.panel h1 {
  font-size: 30px;
  letter-spacing: 0.06em;
  color: #5ad1ff;
  text-shadow: 0 0 18px rgba(90, 209, 255, 0.6);
  margin-bottom: 6px;
}
.panel h2 {
  font-size: 22px;
  color: #e8f0ff;
  margin-bottom: 10px;
}
.tagline { color: rgba(232,240,255,0.75); margin-bottom: 16px; }
.instructions {
  text-align: left;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(232,240,255,0.8);
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 20px;
  /* La liste peut devenir longue (plusieurs mécaniques) : elle défile dans
     sa propre zone plutôt que de pousser le bouton "Jouer" hors de l'écran. */
  max-height: 34vh;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
.instructions p { margin: 6px 0; }

.btn-primary, .btn-secondary {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 10px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}
.btn-primary {
  background: linear-gradient(180deg, #5ad1ff, #2a9fe0);
  color: #04101c;
  box-shadow: 0 8px 20px rgba(90, 209, 255, 0.35);
}
.btn-primary:active { transform: translateY(1px); }
.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: #e8f0ff;
  border: 1px solid rgba(255,255,255,0.15);
}

@media (min-width: 700px) {
  .hud-value { font-size: 22px; }
}

/* ---- Combo (Module 4) : "pop" bref à chaque palier de multiplicateur ---- */
.hud-combo { display: inline-block; transform-origin: center; }
.hud-combo.pop { animation: combo-pop 0.28s ease; }
@keyframes combo-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.5); color: #ffe066; text-shadow: 0 0 18px rgba(255, 224, 102, 0.85); }
  100% { transform: scale(1); }
}

/* ---- Barre d'XP / niveau de build (remplace visuellement les vies) : en bas
   à droite du HUD, à l'horizontale (Lv + jauge côte à côte, remplissage en
   largeur). ---- */
#hud-xp-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
#hud-charlevel-label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(232, 240, 255, 0.75);
  white-space: nowrap;
}
#hud-xp-bar {
  width: 120px;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
#hud-xp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5affc8, #7cffe0);
  box-shadow: 0 0 8px rgba(90, 255, 200, 0.6);
  transition: width 0.2s ease;
}

/* ---- Bouclier : bloc de stat au même rang que Score/Combo/Wave/... dans
   #hud-top (voir index.html), avec son propre libellé. 3 crans reflétant
   build.shieldLevel (0 à STACK_MAX_LEVEL) en lieu du #hud-value textuel
   habituel — voir build.js pour pourquoi il vit hors de acquisitions. ---- */
#hud-shield-pips { display: flex; gap: 4px; margin-top: 2px; }
.shield-pip {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  background: radial-gradient(circle at 35% 30%, rgba(122, 200, 255, 0.06), rgba(10, 14, 24, 0.75) 70%);
  border: 1px solid rgba(122, 200, 255, 0.2);
  opacity: 0.4;
  filter: grayscale(0.7);
  transition: opacity 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease;
}
.shield-pip.filled {
  opacity: 1;
  filter: none;
  background: radial-gradient(circle at 35% 30%, rgba(122, 200, 255, 0.35), rgba(10, 14, 24, 0.75) 70%);
  border-color: rgba(122, 200, 255, 0.75);
  box-shadow: 0 0 6px rgba(122, 200, 255, 0.55), inset 0 0 4px rgba(0, 0, 0, 0.5);
}

/* ---- Pile d'améliorations (Module 3, remplace les vies) ---- */
#hud-upgrades { display: flex; gap: 4px; flex-wrap: wrap; max-width: 180px; }
/* Badge "hublot holographique" plutôt qu'un simple emoji flottant : dégradé
   radial + liseré lumineux + ombre portée, pour que les icônes d'améliorations
   se lisent comme un vrai module lumineux du HUD plutôt que du texte brut. */
.upgrade-icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(90, 209, 255, 0.22), rgba(10, 14, 24, 0.75) 70%);
  border: 1px solid rgba(90, 209, 255, 0.45);
  box-shadow: 0 0 6px rgba(90, 209, 255, 0.35), inset 0 0 4px rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
}

/* ---- Barre de vie du boss (voir boss.js / Game._updateHud), affichée
   uniquement pendant un combat de boss, centrée en haut de l'écran ---- */
#hud-boss-wrap {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  left: 50%;
  transform: translateX(-50%);
  width: min(58vw, 360px);
  text-align: center;
  pointer-events: none;
}
#hud-boss-name {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffb3b3;
  text-shadow: 0 0 10px rgba(255, 90, 90, 0.5);
  margin-bottom: 3px;
}
#hud-boss-bar {
  height: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 120, 120, 0.35);
  overflow: hidden;
}
#hud-boss-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff6a6a, #ffb066);
  box-shadow: 0 0 10px rgba(255, 106, 106, 0.6);
  transition: width 0.2s ease;
}

/* ---- Bouton de capacité (Trou noir) avec anneau de cooldown ---- */
#btn-ability {
  position: relative;
  border-color: rgba(198, 139, 255, 0.4);
}
#btn-ability::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  z-index: -1;
  background: conic-gradient(rgba(198, 139, 255, 0.9) var(--cooldown, 100%), rgba(255, 255, 255, 0.08) 0);
}
#btn-ability.ready { box-shadow: 0 0 12px rgba(198, 139, 255, 0.75); }

/* ---- Écran de montée de niveau : choix de 3 cartes ---- */
.panel-wide { max-width: 640px; width: min(92vw, 640px); }
#card-choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}
@media (max-width: 560px) {
  #card-choices { grid-template-columns: 1fr; }
}
.card-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 16px 10px;
  border-radius: 12px;
  border: 1px solid rgba(90, 209, 255, 0.25);
  background: rgba(255, 255, 255, 0.04);
  color: #e8f0ff;
  cursor: pointer;
}
.card-btn:active { background: rgba(90, 209, 255, 0.16); transform: translateY(1px); }
/* Même traitement "hublot holographique" que .upgrade-icon (voir plus haut),
   à plus grande échelle pour l'écran de choix (cartes de montée de niveau et
   d'évolution du vaisseau). */
.card-icon {
  font-size: 30px;
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 35% 30%, rgba(90, 209, 255, 0.22), rgba(10, 14, 24, 0.75) 70%);
  border: 1px solid rgba(90, 209, 255, 0.4);
  box-shadow: 0 0 10px rgba(90, 209, 255, 0.3), inset 0 0 8px rgba(0, 0, 0, 0.5);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}
.card-name { font-weight: 700; font-size: 14px; }
.card-desc { font-size: 12px; color: rgba(232, 240, 255, 0.7); line-height: 1.35; }
.card-key { font-size: 11px; color: rgba(232, 240, 255, 0.45); }

/* ---- Aperçu du vrai vaisseau (voir main.js drawShipPreview) sur les cartes
   de choix d'évolution : la silhouette facettée réelle plutôt qu'une icône
   emoji, dans le même "hublot holographique" que .card-icon ci-dessus. ---- */
.card-ship-canvas {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(90, 209, 255, 0.18), rgba(10, 14, 24, 0.8) 70%);
  border: 1px solid rgba(90, 209, 255, 0.4);
  box-shadow: 0 0 10px rgba(90, 209, 255, 0.3), inset 0 0 8px rgba(0, 0, 0, 0.5);
}

/* ---- Écran de choix d'évolution du vaisseau (voir Game._enterShipEvolutionChoice
   / ship.js SHIP_FORM_STATS) : réutilise .card-btn, avec en plus une rangée de
   badges de stats (vert = avantage, rouge = inconvénient). ---- */
#evolution-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.evo-stats { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.evo-stat {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}
.evo-good { color: #7cffa0; }
.evo-bad { color: #ff8a8a; }
.evo-neutral { color: rgba(232, 240, 255, 0.6); }
