/* Fenêtres superposées : menu principal, boutique, classement, pause, fin de partie */
.menu-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, rgba(15, 10, 30, 0.98), rgba(5, 5, 10, 0.98));
  padding: 40px;
  border-radius: 20px;
  border: 2px solid #444;
  box-shadow: 0 0 50px black;
  z-index: 100;
  pointer-events: auto;
  min-width: 500px;
  max-height: calc(100vh - 30px);
  overflow-y: auto; /* menus longs (Options...) : défilement plutôt que débordement */
  text-align: center;
  display: none;
}
.menu-overlay h1 {
  font-family: "Press Start 2P";
  color: #00ffff;
  font-size: 35px;
  margin-bottom: 30px;
  line-height: 1.5;
}
.menu-overlay h2 {
  color: #fff;
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-top: 25px;
}

.pseudo-input {
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid #555;
  color: #fff;
  padding: 15px;
  font-size: 18px;
  width: 100%;
  margin: 10px 0 20px 0;
  text-align: center;
  border-radius: 8px;
}
.ac-bar-bg {
  width: 100%;
  height: 10px;
  background: #111;
  border-radius: 5px;
  border: 1px solid #444;
  overflow: hidden;
}
.ac-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffd700, #ffaa00);
  width: 0%;
  transition: width 0.5s;
}
/* --- En-tête commun des menus (titre, sous-titre, or) : même style que le défi du jour --- */
.menu-overlay.menu-wide {
  width: min(880px, calc(100vw - 30px));
}
.menu-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  overflow: visible;
}
.menu-overlay .menu-head h2 {
  overflow: visible; /* sinon la lueur du titre est coupée (base.css) */
  margin: 0;
  font-weight: 900;
  letter-spacing: 3px;
  text-shadow: 0 0 16px var(--accent, #00ffff);
}
.menu-sub {
  color: var(--accent-soft, #9adfff);
  font-size: 13px;
}
.menu-sub:empty {
  display: none;
}
.gold-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 10px;
  border: 1px solid rgba(255, 215, 0, 0.5);
  border-radius: 999px;
  background: rgba(30, 20, 0, 0.6);
  color: #ffd700;
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.2);
}
.gold-pill .ico {
  font-size: 18px;
}
#shopMenu {
  --accent: #00ff88;
  --accent-soft: #7dffc4;
}
#inventoryMenu {
  --accent: #00ccff;
  --accent-soft: #8fe6ff;
  border-color: #00ccff;
}
#talentMenu {
  --accent: #aa66ff;
  --accent-soft: #c9a3ff;
}
#achievementMenu {
  --accent: #ffd700;
  --accent-soft: #ffe680;
}

/* --- Boutique --- */
#shopMenu {
  border-color: #00ff88;
}
.shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  border-bottom: 1px solid #444;
  padding-bottom: 10px;
}
.menu-overlay .shop-header h2 {
  color: #00ff88;
  margin: 0;
}
.shop-gold {
  color: #ffff00;
  font-weight: bold;
  font-size: 18px;
}
.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  padding: 15px;
  margin-bottom: 10px;
  border: 1px solid #444;
  border-radius: 8px;
}
.shop-item-info {
  text-align: left;
  width: 65%;
}
.shop-item-info h4 {
  color: #fff;
}
.shop-item-info p,
.shop-item-stats {
  color: #aaa;
  font-size: 12px;
}
.lvl-badge {
  display: none;
  color: #00ff88;
  font-size: 12px;
}
.shop-btn {
  width: auto;
  white-space: nowrap;
  margin: 0;
  font-size: 14px;
  padding: 5px 10px;
}

/* --- Améliorations --- */
#upgradeMenu {
  border-color: #ffd700;
}
.menu-overlay#upgradeMenu h2 {
  color: #ffd700;
}
#upgradeMenu .menu-sub {
  margin: -12px 0 6px;
  color: #ffe680;
}
/* Coffre de boss : cadre doré qui pulse */
#upgradeMenu.boss-chest {
  border-color: #ffd700;
  box-shadow:
    0 0 50px black,
    0 0 40px rgba(255, 215, 0, 0.45);
  animation: pulseGold 1.6s infinite;
}
.menu-overlay#upgradeMenu.boss-chest h2 {
  text-shadow: 0 0 18px #ffaa00;
  letter-spacing: 3px;
}
.upgrade-option {
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  padding: 15px;
  margin: 12px 0;
  border-radius: 8px;
  border: 1px solid #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  text-align: left;
}
.upgrade-option:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(10px);
  border-color: #fff;
}
/* Carte choisie au clavier (lueur intérieure : la liste coupe ce qui déborde) */
.upgrade-option.selected {
  background: rgba(0, 255, 255, 0.08);
  box-shadow: inset 0 0 14px rgba(0, 255, 255, 0.45);
  border-color: #00ffff;
}
/* Numéro de la carte (touche 1 / 2 / 3) */
.upg-key {
  position: absolute;
  top: 6px;
  left: 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  color: #888;
}
.upgrade-option.selected .upg-key {
  color: #00ffff;
}
.rarity-tag {
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.rarity-common {
  border-left: 4px solid #adadad;
}
.rarity-rare {
  border-left: 4px solid #0088ff;
}
.rarity-epic {
  border-left: 4px solid #aa00ff;
}
.rarity-legendary {
  border-left: 4px solid #ffaa00;
  animation: pulseGold 2s infinite;
}
.rarity-evolution {
  border: 1px solid #ff2a6d;
  border-left: 4px solid #ff2a6d;
  background: linear-gradient(90deg, rgba(255, 42, 109, 0.18), rgba(255, 215, 0, 0.08));
  box-shadow: 0 0 18px rgba(255, 42, 109, 0.45);
  animation: pulseGold 1.2s infinite;
}
.upg-recipe {
  margin-top: 4px;
  font-size: 11px;
  color: #ff7aa8;
}
.icon {
  width: 45px;
  height: 45px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  margin-right: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border: 1px solid #555;
}
.upg-info h4 {
  font-size: 16px;
  margin-bottom: 4px;
  color: #fff;
}
.upg-info p {
  font-size: 12px;
  color: #bbb;
}

/* --- Classement --- */
.menu-overlay#leaderboardMenu h2 {
  color: #ffd700;
}
.lb-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 15px;
  font-size: 14px;
}
.lb-table th {
  text-align: left;
  padding: 10px;
  color: #00ffff;
  background: rgba(255, 255, 255, 0.05);
}
.lb-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #333;
  color: #ddd;
}
.lb-rank {
  font-weight: bold;
  color: #ffd700;
}
.lb-table td.lb-empty {
  text-align: center;
  padding: 20px;
  color: #666;
}

/* --- Pause --- */
.inv-list {
  max-height: 200px;
  overflow-y: auto;
  text-align: left;
  margin-bottom: 15px;
  background: #111;
  padding: 10px;
  border-radius: 5px;
}
.inv-item {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid #333;
  color: #ccc;
  font-size: 14px;
}
.inv-empty {
  text-align: center;
  padding: 10px;
  color: #666;
}

/* --- Fin de partie --- */
.menu-overlay#gameOver h1 {
  color: #ff3333;
  font-size: 40px;
  margin-bottom: 20px;
}
.final-pseudo {
  color: #fff;
  font-size: 20px;
  margin-bottom: 20px;
}
.final-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 14px;
  color: #aaa;
}
.final-stats span {
  color: #fff;
}
.rewards-box {
  background: rgba(0, 0, 0, 0.5);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid #333;
}
.reward-xp {
  font-size: 18px;
}
.reward-gold {
  font-size: 18px;
  color: #ffff00;
  margin-top: 5px;
  font-weight: bold;
}
#newRecordMsg {
  display: none;
  color: #ffd700;
  font-weight: bold;
  margin-top: 15px;
  animation: pulseGold 1s infinite;
}

/* --- Onglets du classement --- */
.lb-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 15px;
}
.lb-tab {
  background: linear-gradient(180deg, #333, #1a1a1a);
  color: #888;
  padding: 10px;
  font-size: 13px;
}
.lb-tab.active {
  background: linear-gradient(180deg, #ffd700, #aa8800);
  color: #000;
}
.lb-scroll {
  max-height: 50vh;
  overflow-y: auto;
  margin-bottom: 15px;
}
.lb-scroll .lb-table {
  margin-bottom: 0;
}
#onlineStatus {
  margin-top: 10px;
  font-size: 12px;
  color: #888;
  min-height: 15px;
}

/* Statistiques de fin de partie */
.run-stats {
  margin: 12px 0;
  text-align: left;
}
.run-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.run-tile {
  padding: 8px;
  border: 1px solid #333;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  text-align: center;
}
.run-tile b {
  display: block;
  font-size: 16px;
  color: #fff;
}
.run-tile span {
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.dmg-row {
  display: grid;
  grid-template-columns: 110px 1fr 56px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: #ccc;
  margin: 4px 0;
}
.dmg-bar {
  height: 8px;
  border-radius: 4px;
  background: #222;
  overflow: hidden;
}
.dmg-bar div {
  height: 100%;
  background: linear-gradient(90deg, #00ffff, #ff00ff);
  box-shadow: 0 0 6px #00ffff;
}
.dmg-row em {
  font-style: normal;
  text-align: right;
  color: #fff;
}
@media (max-width: 760px) {
  .run-tiles {
    grid-template-columns: 1fr 1fr;
  }
}

/* Écran bas (téléphone en paysage) : en-tête sur une seule ligne */
@media (max-height: 560px) {
  .menu-head {
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-bottom: 10px;
  }
  .menu-head .menu-sub:not(#achievementCount) {
    display: none;
  }
  .menu-overlay .menu-head h2 {
    margin: 0;
  }
  .gold-pill {
    padding: 3px 12px 3px 8px;
    font-size: 14px;
  }
}
