:root {
  --accent: #7ee0ff; /* teinte de l'étage courant, pilotée par le jeu */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d0d10;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #e8e4da;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 0;
  pointer-events: none;
  z-index: 10;
}

#hud.hidden,
#dash-btn.hidden {
  display: none;
}

#meta-line {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 16px;
  margin-top: 6px;
}

#floor-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #ffd866;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

#objective-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  transition: color 0.6s;
}

#xp-bar-wrap {
  position: relative;
  height: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  overflow: hidden;
}

#xp-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent), 0 0 24px var(--accent);
  transition: width 0.15s ease-out, background 0.6s, box-shadow 0.6s;
}

#level-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

#timer {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

#hp-bar-wrap {
  position: relative;
  margin: 6px auto 0;
  width: min(320px, 60%);
  height: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 7px;
  overflow: hidden;
}

#hp-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #c0392b, #ff6b52);
  transition: width 0.1s ease-out;
}

#hp-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* ---------- Barre de boss ---------- */

#boss-bar-wrap {
  margin: 10px auto 0;
  width: min(440px, 78%);
}

#boss-bar-wrap.hidden {
  display: none;
}

#boss-name {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #ff5a4c;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  margin-bottom: 3px;
}

#boss-bar-bg {
  height: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 90, 76, 0.5);
  border-radius: 6px;
  overflow: hidden;
}

#boss-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #8f1d2c, #ff5a4c);
  transition: width 0.12s ease-out;
}

/* ---------- Classement live ---------- */

#live-rank {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 96px);
  right: 12px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  font-size: 11.5px;
  text-align: right;
  line-height: 1.65;
  pointer-events: none;
  z-index: 10;
}

#live-rank.hidden {
  display: none;
}

#live-rank .lr-rank {
  font-size: 13px;
  letter-spacing: 1px;
}

#live-rank .lr-rank b {
  color: #7ee0ff;
}

#live-rank b {
  color: #ffd866;
}

#live-rank.flash {
  animation: rank-flash 0.7s ease-out;
}

@keyframes rank-flash {
  0% {
    border-color: #ffd866;
    box-shadow: 0 0 22px rgba(255, 216, 102, 0.7);
    transform: scale(1.12);
  }
  100% {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: none;
    transform: scale(1);
  }
}

#floorclear-record.hidden {
  display: none;
}

/* ---------- Buffs stackés ---------- */

#buffs {
  position: fixed;
  left: 10px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  z-index: 10;
}

.buff {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  width: fit-content;
}

.buff .n {
  color: #7ee0ff;
}

.buff.maxed {
  border-color: rgba(255, 216, 102, 0.6);
  box-shadow: 0 0 8px rgba(255, 216, 102, 0.15);
}

.buff .max {
  color: #ffd866;
  font-size: 9px;
  letter-spacing: 1px;
}

.buff.pop {
  animation: buff-pop 0.35s ease-out;
}

@keyframes buff-pop {
  0% {
    transform: scale(1.45);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- Dash button (mobile) ---------- */

#dash-btn {
  position: fixed;
  right: 24px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 32px);
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  z-index: 10;
  color: rgba(255, 255, 255, 0.7);
}

#dash-btn.cooldown {
  opacity: 0.35;
}

#dash-btn .cost {
  font-size: 9px;
  opacity: 0.7;
  margin-top: 2px;
}

#dash-btn {
  flex-direction: column;
}

body.no-touch #dash-btn {
  display: none;
}

/* ---------- Boutons super pouvoirs (mobile) ---------- */

.power-btn {
  position: fixed;
  right: 108px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 32px);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 216, 102, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  z-index: 10;
  color: rgba(255, 255, 255, 0.7);
  opacity: 0.3;
  transition: opacity 0.2s, box-shadow 0.2s;
}

.power-btn.ready {
  opacity: 1;
  box-shadow: 0 0 14px rgba(255, 216, 102, 0.6);
}

#power-e-btn {
  right: 178px;
}

.power-btn .power-key {
  position: absolute;
  bottom: -16px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.6);
}

.power-btn.hidden,
body.no-touch .power-btn {
  display: none;
}

/* ---------- Charges des super pouvoirs (HUD) ---------- */

#power-hud {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 8px;
}

.power-slot {
  display: flex;
  align-items: center;
  gap: 5px;
}

.power-slot-key {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 1px;
}

.power-slot-bar-bg {
  width: 70px;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.power-slot-bar {
  height: 100%;
  width: 0%;
  background: #ffd866;
  transition: width 0.2s;
}

.power-slot.ready .power-slot-bar {
  box-shadow: 0 0 8px #ffd866;
}

/* ---------- Pause + combo ---------- */

#pause-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 12px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  z-index: 11;
}

#pause-btn.hidden {
  display: none;
}

#pause-screen h2 {
  color: #e8e4da;
  letter-spacing: 8px;
}

#resume-btn,
#abandon-btn {
  padding: 12px 36px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

#resume-btn {
  color: #0d0d10;
  background: #e8e4da;
}

#abandon-btn {
  color: #e8e4da;
  background: rgba(255, 107, 82, 0.15);
  border: 1px solid rgba(255, 107, 82, 0.5);
}

#combo-label {
  text-align: center;
  margin-top: 6px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ffd866;
  text-shadow: 0 0 12px rgba(255, 216, 102, 0.6);
}

#combo-label.hidden {
  display: none;
}

#combo-label.pop {
  animation: buff-pop 0.25s ease-out;
}

/* ---------- Toast (annonces) ---------- */

#toast {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 10px 22px;
  background: rgba(155, 89, 182, 0.18);
  border: 1px solid rgba(155, 89, 182, 0.6);
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 15;
}

#toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 12, 0.82);
  backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 20;
  padding: 20px;
}

.overlay.hidden {
  display: none;
}

.overlay h2 {
  font-size: 30px;
  letter-spacing: 3px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

#levelup-screen h2 {
  color: #7ee0ff;
}

#gameover-screen h2 {
  color: #ff6b52;
}

#floorclear-screen h2 {
  color: #ffd866;
}

/* ---------- Menu / classes / classement ---------- */

#menu-screen h1 {
  font-size: 44px;
  letter-spacing: 10px;
  color: #e8e4da;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.9);
}

#player-name {
  padding: 10px 16px;
  font-size: 15px;
  text-align: center;
  color: #e8e4da;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  outline: none;
  width: min(240px, 70vw);
}

#class-cards {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 700px;
}

.class-card {
  width: 170px;
  padding: 18px 14px;
  background: linear-gradient(160deg, #23232e, #16161d);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  transition: transform 0.1s, border-color 0.1s;
}

.class-card:hover,
.class-card:active {
  transform: translateY(-4px);
  border-color: #ffd866;
}

.class-card .icon {
  font-size: 36px;
}

.class-card .name {
  font-weight: 700;
  font-size: 16px;
}

.class-card .desc {
  font-size: 12px;
  opacity: 0.7;
  line-height: 1.4;
}

#lb-toggle {
  padding: 9px 26px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #e8e4da;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  cursor: pointer;
}

#lb-panel,
#death-leaderboard {
  max-width: 520px;
  width: 92%;
  font-size: 13px;
}

#lb-panel.hidden {
  display: none;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
}

.lb-table th,
.lb-table td {
  padding: 5px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.lb-table th {
  color: #7ee0ff;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.lb-table tr.me td {
  color: #ffd866;
  font-weight: 700;
}

.lb-table td.sorted {
  color: #7ee0ff;
  font-weight: 700;
}

.lb-tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
}

.lb-tab {
  padding: 5px 13px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #e8e4da;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  cursor: pointer;
}

.lb-tab.active {
  color: #0d0d10;
  background: #7ee0ff;
  border-color: #7ee0ff;
}

.record-banner {
  color: #ffd866;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 10px;
  animation: record-pop 0.6s ease-out, record-glow 1.1s ease-in-out infinite alternate;
}

@keyframes record-pop {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  60% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes record-glow {
  from {
    text-shadow: 0 0 6px rgba(255, 216, 102, 0.35);
  }
  to {
    text-shadow: 0 0 20px rgba(255, 216, 102, 0.95);
  }
}

.lb-records {
  margin-top: 8px;
  opacity: 0.75;
  font-size: 12px;
  text-align: center;
  line-height: 1.7;
}

@media (max-width: 620px) {
  .class-card {
    width: min(300px, 78vw);
    flex-direction: row;
    text-align: left;
    padding: 12px 14px;
  }

  .class-card .text {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
}

#victory-screen h2 {
  color: #4fd1a0;
}

#victory-stats {
  font-size: 15px;
  line-height: 1.8;
  text-align: center;
  opacity: 0.85;
}

#victory-restart-btn {
  margin-top: 8px;
  padding: 14px 44px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #0d0d10;
  background: #4fd1a0;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

#victory-restart-btn:active {
  transform: scale(0.96);
}

.subtitle {
  opacity: 0.7;
  font-size: 14px;
}

#upgrade-cards,
#power-cards {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 700px;
}

.upgrade-card {
  width: 180px;
  min-height: 170px;
  padding: 18px 14px;
  background: linear-gradient(160deg, #23232e, #16161d);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  transition: transform 0.1s, border-color 0.1s;
}

.upgrade-card:hover,
.upgrade-card:active {
  transform: translateY(-4px);
  border-color: #7ee0ff;
}

.upgrade-card .icon {
  font-size: 34px;
}

.upgrade-card .name {
  font-weight: 700;
  font-size: 15px;
}

.upgrade-card .desc {
  font-size: 12.5px;
  opacity: 0.75;
  line-height: 1.4;
}

.upgrade-card .stacks {
  font-size: 11px;
  color: #7ee0ff;
  opacity: 0.9;
}

.upgrade-card.rare {
  position: relative;
  border-color: rgba(255, 216, 102, 0.75);
  background: linear-gradient(160deg, #33301f, #1a1812);
  box-shadow: 0 0 18px rgba(255, 216, 102, 0.18);
}

.upgrade-card.rare:hover,
.upgrade-card.rare:active {
  border-color: #ffd866;
}

.upgrade-card .rarity {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #ffd866;
}

.upgrade-card.current {
  position: relative;
  border-color: rgba(126, 224, 255, 0.7);
  box-shadow: 0 0 14px rgba(126, 224, 255, 0.16);
}

.upgrade-card.current .rarity {
  color: #7ee0ff;
}

#run-stats {
  font-size: 15px;
  line-height: 1.8;
  text-align: center;
  opacity: 0.85;
}

#restart-btn {
  margin-top: 8px;
  padding: 14px 44px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #0d0d10;
  background: #e8e4da;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

#restart-btn:active {
  transform: scale(0.96);
}

@media (max-width: 620px) {
  #upgrade-cards {
    flex-direction: column;
    align-items: stretch;
  }

  .upgrade-card {
    width: min(320px, 80vw);
    min-height: 0;
    flex-direction: row;
    text-align: left;
    align-items: center;
  }

  .upgrade-card .text {
    display: flex;
    flex-direction: column;
    gap: 3px;
  }
}

/* ---------- God Mode panel ---------- */

#god-panel {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(5, 6, 12, 0.82);
  backdrop-filter: blur(6px);
  z-index: 60;
}

#god-panel.hidden {
  display: none;
}

#god-panel-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #ffd866;
  text-shadow: 0 0 14px rgba(255, 216, 102, 0.6);
}

#god-obj-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 520px;
}

.god-obj-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 18px;
  min-width: 90px;
  background: rgba(20, 22, 34, 0.9);
  border: 1px solid rgba(255, 216, 102, 0.3);
  border-radius: 10px;
  color: #e8e4da;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.god-obj-btn:hover,
.god-obj-btn:active {
  border-color: #ffd866;
  box-shadow: 0 0 16px rgba(255, 216, 102, 0.25);
  transform: scale(1.04);
}

.god-obj-icon {
  font-size: 26px;
}

.god-obj-name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.85;
}

#god-close-btn {
  padding: 8px 24px;
  background: transparent;
  border: 1px solid rgba(232, 228, 218, 0.25);
  border-radius: 8px;
  color: rgba(232, 228, 218, 0.55);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 1px;
  cursor: pointer;
}

#god-close-btn:hover {
  border-color: rgba(232, 228, 218, 0.5);
  color: #e8e4da;
}
