:root {
  --bg: #08070d;
  --panel: #14111f;
  --panel-2: #1d1930;
  --line: #322a4a;
  --text: #e9e4f5;
  --muted: #8f86a8;
  --gold: #ffc857;
  --hp: #ff4d6d;
  --xp: #6ee7c8;
  --accent: #b78bff;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#stage {
  position: relative;
  width: min(100vw, 177.78vh);
  aspect-ratio: 16 / 9;
  box-shadow: 0 0 80px rgba(0, 0, 0, .9);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  cursor: crosshair;
  background: #0d0b14;
}

.hidden { display: none !important; }

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

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: 2.2%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: clamp(10px, 1.5vh, 16px);
}

.hud-top, .hud-bottom {
  display: flex;
  align-items: center;
  gap: 1.5%;
}

.bar {
  position: relative;
  height: 2.6em;
  border: 2px solid var(--line);
  border-radius: 4px;
  background: rgba(8, 7, 13, .75);
  overflow: hidden;
}

.bar.hp { width: 34%; }
.bar.xp { flex: 1; height: 1.9em; }

.bar-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  transform-origin: left;
  transition: transform .12s linear;
}

.hp .bar-fill { background: linear-gradient(180deg, #ff7a90, var(--hp)); }
.xp .bar-fill { background: linear-gradient(180deg, #9df5dc, var(--xp)); }

.bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  letter-spacing: .06em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
}

.floor-info {
  flex: 1;
  text-align: center;
  font-weight: bold;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

.gold {
  color: var(--gold);
  font-weight: bold;
  letter-spacing: .05em;
  min-width: 5em;
  text-align: right;
}

.dash-pips { display: flex; gap: .4em; }

.pip {
  width: 1.5em;
  height: 1.5em;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: rgba(8, 7, 13, .75);
}

.pip.ready {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  border-color: var(--accent);
}

/* ---------- Écrans ---------- */

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4%;
}

#overlay:empty { pointer-events: none; }

.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5vh;
  background: radial-gradient(ellipse at center, rgba(20, 17, 31, .88), rgba(8, 7, 13, .97));
  animation: fade .25s ease-out;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.title {
  font-size: clamp(28px, 7vh, 76px);
  font-weight: bold;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--text);
  text-shadow: 0 0 30px rgba(183, 139, 255, .5);
}

.subtitle {
  color: var(--muted);
  font-size: clamp(11px, 2vh, 18px);
  letter-spacing: .12em;
  text-align: center;
  line-height: 1.7;
}

.subtitle b { color: var(--text); }

.btn {
  pointer-events: auto;
  padding: .8em 2.4em;
  font: inherit;
  font-size: clamp(12px, 2.2vh, 20px);
  font-weight: bold;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--panel-2);
  border: 2px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  transition: all .12s;
}

.btn:hover { border-color: var(--accent); color: #fff; transform: translateY(-2px); }
.btn.ghost { background: transparent; font-size: clamp(10px, 1.7vh, 15px); padding: .6em 1.6em; }

.btn.danger { color: var(--muted); }
.btn.danger:hover { border-color: var(--hp); color: var(--hp); }

.btn.armed,
.btn.armed:hover {
  border-color: var(--hp);
  background: rgba(255, 77, 109, .14);
  color: #ffd7de;
}

/* Cartes d'amélioration */

.cards {
  display: flex;
  gap: 2%;
  width: 100%;
  max-width: 900px;
  justify-content: center;
}

.card {
  pointer-events: auto;
  flex: 1;
  max-width: 280px;
  padding: 3vh 1.5vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2vh;
  text-align: center;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 2px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}

.card:hover {
  transform: translateY(-8px);
  border-color: var(--accent);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .6);
}

.card .icon { font-size: clamp(22px, 4.5vh, 44px); line-height: 1; }
.card .name { font-weight: bold; letter-spacing: .08em; font-size: clamp(12px, 2vh, 18px); }
.card .desc { color: var(--muted); font-size: clamp(10px, 1.6vh, 14px); line-height: 1.5; }

.card .stacks {
  margin-top: auto;
  padding: .25em .8em;
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: clamp(9px, 1.4vh, 12px);
  letter-spacing: .1em;
  color: var(--muted);
}

.card.rare { border-color: #6b5aa8; }
.card.rare .name { color: var(--accent); }
.card.rare:hover { box-shadow: 0 12px 30px rgba(183, 139, 255, .25); }

.card.spec {
  border-color: var(--gold);
  background: linear-gradient(180deg, #2a2213, var(--panel));
}

.card.spec .name { color: var(--gold); }
.card.spec:hover { box-shadow: 0 12px 34px rgba(255, 200, 87, .3); }

.title.small { font-size: clamp(20px, 4.5vh, 42px); }
.title.gold { color: var(--gold); text-shadow: 0 0 30px rgba(255, 200, 87, .45); }

/* Boutique méta */

.shop {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.2vh;
  width: 100%;
  max-width: 860px;
  max-height: 58vh;
  overflow-y: auto;
  padding: .4vh 1vh .4vh .4vh;
  pointer-events: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.shop::-webkit-scrollbar { width: 8px; }
.shop::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.shop-item {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 1.2em;
  padding: 1.4vh 1.6vh;
  text-align: left;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}

.shop-item:hover:not(.locked) { border-color: var(--gold); background: var(--panel-2); }
.shop-item.locked { opacity: .45; cursor: not-allowed; }
.shop-item .icon { font-size: clamp(18px, 3.2vh, 32px); }
.shop-item .info { flex: 1; }
.shop-item .name { font-weight: bold; font-size: clamp(11px, 1.8vh, 16px); }
.shop-item .desc { color: var(--muted); font-size: clamp(9px, 1.4vh, 13px); }
.shop-item .cost { color: var(--gold); font-weight: bold; white-space: nowrap; font-size: clamp(11px, 1.8vh, 16px); }
.shop-item .dots { letter-spacing: .2em; color: var(--gold); font-size: clamp(10px, 1.5vh, 14px); }

.row { display: flex; gap: 1em; align-items: center; }

.stats {
  display: flex;
  gap: 3em;
  color: var(--muted);
  font-size: clamp(10px, 1.7vh, 15px);
  letter-spacing: .08em;
}

.stats b { display: block; color: var(--text); font-size: clamp(16px, 3vh, 28px); text-align: center; }
