/* ===== Sanctuary Survivors — style gothique Diablo ===== */
@import url('https://fonts.googleapis.com/css2?family=MedievalSharp&family=Cinzel:wght@400;700&family=Metamorphous&display=swap');

:root {
  --shadow: #171513;
  --umber: #30251d;
  --wood: #49382a;
  --blood: #7c2823;
  --blood-light: #a34335;
  --gold: #a8864a;
  --gold-bright: #d9b356;
  --parchment: #b9ac8d;
}

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

html, body {
  width: 100%; height: 100%;
  background: #000;
  overflow: hidden;
  font-family: 'MedievalSharp', cursive;
  user-select: none;
}

#game-container { position: fixed; inset: 0; }

canvas#game { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }

/* ================= HUD bas façon D2 avec le cadre fourni =================
   L'image hud_frame.png contient : démon-gauche, orbe-gauche, slots 1234,
   orbe-droite, gorgone (fente FS à droite). On aligne les éléments DOM dessus. */
#hud { position: absolute; inset: 0; pointer-events: none; color: var(--parchment); }

#hud-bottom {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(100vw, 1024px); height: 128px;
  pointer-events: none;
  z-index: 4;
}
/* Les orbes désormais superposées exactement aux cercles du cadre */
.orb {
  position: absolute; bottom: 12px; width: 92px; height: 92px; border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, #1b100b 58%, #0a0605 100%);
  overflow: hidden; border: none;
}
.orb.hp { left: 200px; }   /* cercle gauche du cadre */
.orb.mp { right: 200px; }  /* cercle droit du cadre */
.orb-fill { position: absolute; bottom: 0; left: 0; right: 0; height: 100%; transition: height .22s; }
.hp .orb-fill { background: linear-gradient(#d85540, #7c2823 45%, #43110d); }
.mp .orb-fill { background: linear-gradient(#5a6ecb, #2b3670 45%, #101534); }
.orb-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: 'Cinzel', serif; font-weight: 700; font-size: 15px; color: #f2e7cf; text-shadow: 1px 1px 0 #000, 0 0 8px rgba(0,0,0,.9); }

/* Barre de sorts centrée entre les orbes, calée sur les fentes 1-2-3-4 */
#skill-bar {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 14px; pointer-events: auto;
}
.skill-slot {
  width: 44px; height: 44px; position: relative;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; pointer-events: auto;
  filter: drop-shadow(0 0 3px rgba(0,0,0,.8));
}
.skill-slot.active { filter: drop-shadow(0 0 6px rgba(217,179,86,.9)); }
.skill-slot.empty { opacity: .4; }
.skill-slot img { width: 36px; height: 36px; image-rendering: pixelated; }
.skill-key { display: none; }
.skill-cooldown { position: absolute; inset: 2px; background: rgba(10,8,14,.6); border-radius: 4px; transform-origin: bottom; transform: scaleY(0); pointer-events: none; }
.skill-mana { display: none; }
.skill-name { display: none; }

/* Cadre image : doit s'étendre en bas sous les DOM */
#hud-frame-img {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  height: 128px; width: auto; max-width: min(100vw, 1024px);
  object-fit: contain; object-position: bottom;
  pointer-events: none; z-index: 3; display: none;
}
#hud-frame-img.visible { display: block; }
/* Si pas de cadre image, fallback bandeau sombre */
#hud-bottom.noframe {
  background: linear-gradient(180deg, rgba(10,8,6,0) 0%, rgba(12,9,6,.88) 45%, rgba(6,5,4,.96) 100%);
  border-top: 2px solid #050403;
  width: 100vw; left: 0; transform: none;
}
#hud-bottom.noframe .orb.hp { left: 18px; }
#hud-bottom.noframe .orb.mp { right: 18px; }
#hud-bottom::before {
  content: ''; position: absolute; inset: 0;
  background: url('../img/border-fake.png'); /* none: décor géré par ombres */
  display: none;
}
.orb {
  width: 108px; height: 108px; margin: 6px 18px 10px 18px; border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, #1b100b 58%, #0a0605 100%);
  border: 3px solid #3d3226; box-shadow: 0 0 0 2px #14100a, inset 0 4px 20px rgba(0,0,0,.9), 0 6px 22px rgba(0,0,0,.8);
  overflow: hidden; position: relative; flex: 0 0 auto;
}
.orb-fill { position: absolute; bottom: 0; left: 0; right: 0; height: 100%; transition: height .22s; }
.hp .orb-fill { background: linear-gradient(#d85540, #7c2823 45%, #43110d); }
.mp .orb-fill { background: linear-gradient(#5a6ecb, #2b3670 45%, #101534); }
.orb-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: 'Cinzel', serif; font-weight: 700; font-size: 16px; color: #f2e7cf; text-shadow: 1px 1px 0 #000, 0 0 8px rgba(0,0,0,.9); }

/* Barre de sorts entre les orbes */
#skill-bar {
  flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 8px;
  padding-bottom: 16px; pointer-events: auto;
}
.skill-slot {
  width: 56px; height: 56px; position: relative;
  background: linear-gradient(#2a2018, #191310);
  border: 2px solid #5b4a33; box-shadow: 0 0 0 1px #0c0906, inset 0 0 10px rgba(0,0,0,.8);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; pointer-events: auto; transition: border-color .15s, box-shadow .15s;
}
.skill-slot:hover { border-color: var(--gold); }
.skill-slot.active { border-color: var(--gold-bright); box-shadow: 0 0 0 1px #0c0906, 0 0 14px rgba(217,179,86,.45), inset 0 0 10px rgba(0,0,0,.6); }
.skill-slot.empty { opacity: .35; cursor: default; }
.skill-slot img { width: 36px; height: 36px; image-rendering: pixelated; }
.skill-key { position: absolute; bottom: 1px; right: 3px; font-size: 11px; color: #e8d9b0; text-shadow: 1px 1px 0 #000; font-family: 'Cinzel', serif; }
.skill-cooldown { position: absolute; inset: 0; background: rgba(10,8,14,.72); transform-origin: bottom; transform: scaleY(0); pointer-events: none; }
.skill-name {
  position: absolute; bottom: 62px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-family: 'Cinzel', serif; font-size: 12px;
  background: rgba(12,9,6,.95); border: 1px solid var(--gold); padding: 3px 9px;
  display: none; z-index: 6; color: var(--parchment);
}
.skill-slot:hover .skill-name { display: block; }
.skill-mana { position: absolute; bottom: 0; left: 0; height: 3px; background: #5a6ecb; width: 0%; transition: width .15s; }

/* Barre d'XP dorée fine : COUR le long du bas de l'écran, juste au-dessus du cadre */
#xp-bar {
  position: absolute; bottom: 4px; left: 300px; right: 300px; height: 5px;
  background: #0d0a07; border: 1px solid #3d3226; box-shadow: 0 0 0 1px #000;
  z-index: 5;
}
#xp-fill { height: 100%; background: linear-gradient(90deg, #6e5528, #d9b356 60%, #f0d98a); width: 0%; transition: width .25s; }

/* ================= HUD haut ================= */
#hud-top { position: absolute; top: 10px; left: 14px; right: 14px; display: flex; justify-content: space-between; align-items: flex-start; }
.gold-block { font-family: 'Cinzel', serif; font-size: 17px; display: flex; gap: 7px; align-items: center; color: var(--gold-bright); text-shadow: 1px 1px 0 #000; }
.essence-block { font-family: 'Cinzel', serif; font-size: 15px; display: flex; gap: 6px; align-items: center; color: #b07ce8; text-shadow: 0 0 8px rgba(150,90,220,.5); }
.meta-block { text-align: right; }
.timer { font-family: 'Cinzel', serif; font-size: 24px; letter-spacing: 2px; text-shadow: 1px 1px 0 #000; }
.kills { font-size: 13px; opacity: .8; text-align: right; }
#hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
#btn-settings {
  pointer-events: auto; cursor: pointer; margin-top: 4px;
  background: rgba(20,15,10,.9); border: 1px solid #5b4a33; color: var(--parchment);
  font-family: 'Cinzel', serif; font-size: 13px; padding: 4px 12px;
}
#btn-settings:hover { border-color: var(--gold); color: #fff; }

#fps { position: absolute; top: 3px; left: 8px; font-size: 10px; opacity: .4; font-family: monospace; color: #9a8; }
#build-badge { position: absolute; bottom: 132px; right: 10px; font-size: 10px; opacity: .45; color: var(--parchment); font-family: monospace; }

/* Toasts */
#toasts { position: absolute; top: 120px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 5; }
.toast { background: rgba(20,15,10,.93); border: 1px solid var(--gold); color: var(--parchment); padding: 6px 16px; font-family: 'Cinzel', serif; font-size: 14px; }

/* ===== Overlays ===== */
.overlay {
  position: absolute; inset: 0; background: rgba(4,3,2,.86);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 12; text-align: center; overflow-y: auto; padding: 20px;
}
.hidden, .overlay.hidden { display: none !important; }

.title { font-family: 'MedievalSharp', cursive; font-size: 46px; color: var(--blood-light); text-shadow: 2px 2px 0 #000, 0 0 34px rgba(163,67,53,.35); letter-spacing: 3px; }
.subtitle { font-size: 16px; color: var(--gold); margin-top: 8px; letter-spacing: 4px; font-family: 'Cinzel', serif; }
.press-start { margin-top: 40px; font-size: 16px; color: var(--parchment); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.controls-hint { margin-top: 20px; font-size: 13.5px; color: #8d7f6a; line-height: 1.55; }

.btn {
  font-family: 'Cinzel', serif; font-size: 16px; letter-spacing: 2px;
  background: linear-gradient(#2e241c, #1c1611); color: var(--parchment);
  border: 2px solid var(--gold); padding: 11px 26px; cursor: pointer; transition: all .16s;
  pointer-events: auto;
}
.btn:hover:not(:disabled) { background: var(--blood); color: #fff; border-color: var(--gold-bright); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.danger { border-color: var(--blood-light); }
.btn.small { font-size: 13px; padding: 7px 15px; }

/* ===== Cards de level up ===== */
#levelup-overlay h2 { font-size: 32px; color: var(--gold-bright); margin-bottom: 18px; font-family: 'Metamorphous', cursive; text-shadow: 2px 2px 0 #000; }
#levelup-cards { display: flex; gap: 18px; margin-bottom: 16px; flex-wrap: wrap; justify-content: center; }
.card {
  width: 185px; min-height: 225px; background: linear-gradient(#2b211a, #181310);
  border: 2px solid #5b4a33; box-shadow: 0 0 0 1px #0b0906; padding: 15px 11px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  transition: transform .15s, box-shadow .18s, border-color .18s;
}
.card:hover { transform: translateY(-7px); box-shadow: 0 10px 26px rgba(0,0,0,.85), 0 0 20px rgba(217,179,86,.22); border-color: var(--gold); }
.card img { width: 52px; height: 52px; image-rendering: pixelated; margin-bottom: 10px; }
.card h3 { font-size: 15px; color: var(--gold-bright); margin-bottom: 8px; }
.card p { font-size: 12.5px; color: var(--parchment); line-height: 1.5; }
.card .lvl-ind { margin-top: auto; font-size: 11px; color: #7d7261; text-transform: uppercase; letter-spacing: 1px; }
.card.rarity-rare { border-color: #4a7fa8; box-shadow: 0 0 14px rgba(74,127,168,.35); }
.card.rarity-epic { border-color: #8a4ad0; box-shadow: 0 0 14px rgba(138,74,208,.4); }

/* ===== Boutique / Sanctuaire ===== */
.shop-panel {
  background: linear-gradient(#241b14, #120d09); border: 2px solid var(--gold);
  box-shadow: 0 0 0 2px #0a0805, 0 20px 60px rgba(0,0,0,.9);
  padding: 22px 26px; max-width: 640px; width: 92%;
}
.shop-panel h2 { font-family: 'Metamorphous', cursive; color: var(--gold-bright); font-size: 26px; margin-bottom: 4px; }
.shop-panel .shop-sub { font-size: 13px; color: #8d7f6a; margin-bottom: 14px; }
.shop-items { display: flex; flex-direction: column; gap: 9px; margin-bottom: 16px; max-height: 46vh; overflow-y: auto; padding-right: 4px; }
.shop-item {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: rgba(35,26,18,.7); border: 1px solid #4a3a27; padding: 9px 12px;
}
.shop-item img { width: 34px; height: 34px; image-rendering: pixelated; flex: 0 0 auto; }
.shop-item .si-name { font-family: 'Cinzel', serif; font-size: 14.5px; color: var(--parchment); }
.shop-item .si-desc { font-size: 12px; color: #8d7f6a; }
.shop-item .si-cost { margin-left: auto; font-family: 'Cinzel', serif; font-size: 14px; color: var(--gold-bright); display: flex; align-items: center; gap: 5px; }
.shop-item.sold { opacity: .5; }
.shop-item.sold .si-cost { color: #6a5f45; }
.shop-item button { pointer-events: auto; }
.shop-panel .shop-money { display: flex; gap: 18px; justify-content: center; margin-bottom: 12px; font-family: 'Cinzel', serif; }

/* ===== Écran de choix de classe ===== */
.class-cards { display: flex; gap: 20px; margin: 26px 0 20px; flex-wrap: wrap; justify-content: center; }
.class-card {
  width: 200px; background: linear-gradient(#2a201a, #171210); border: 2px solid #5b4a33;
  padding: 18px 14px; cursor: pointer; text-align: center; transition: all .18s;
}
.class-card:hover { border-color: var(--gold-bright); transform: translateY(-6px); box-shadow: 0 10px 30px rgba(0,0,0,.85); }
.class-card img { width: 56px; height: 56px; image-rendering: pixelated; margin-bottom: 10px; }
.class-card h3 { color: var(--gold-bright); font-size: 17px; margin-bottom: 6px; }
.class-card p { font-size: 12px; color: #8d7f6a; line-height: 1.5; }

/* ===== Réglages ===== */
.settings-panel { background: linear-gradient(#241b14, #120d09); border: 2px solid var(--gold); padding: 24px 30px; min-width: 340px; }
.settings-panel h2 { font-family: 'Metamorphous', cursive; color: var(--gold-bright); font-size: 24px; margin-bottom: 16px; }
.set-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; text-align: left; }
.set-row label { font-family: 'Cinzel', serif; font-size: 14px; width: 130px; color: var(--parchment); }
.set-row input[type=range] { flex: 1; accent-color: var(--gold); pointer-events: auto; }
.set-row input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--gold); pointer-events: auto; }

/* ===== Stats de fin ===== */
.stats-table { margin: 18px 0; font-family: 'Cinzel', serif; font-size: 15px; color: var(--parchment); }
.stats-table td { padding: 4px 14px; }
.stats-table td:first-child { color: var(--gold); text-align: right; }

/* ===== Boutique flottante in-game (indicateur) ===== */
#shop-nearby {
  position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%);
  background: rgba(20,15,10,.94); border: 1px solid var(--gold-bright);
  color: var(--gold-bright); font-family: 'Cinzel', serif; font-size: 15px;
  padding: 8px 20px; display: none; z-index: 4;
}
.key-hint { color: #e8d9b0; font-weight: 700; }

/* Essence popup au ramassage */
#achv-popup {
  position: absolute; top: 30%; left: 50%; transform: translateX(-50%) scale(.9);
  background: linear-gradient(#2b1c22, #161014); border: 2px solid #b07ce8;
  color: #d9b7f2; font-family: 'Cinzel', serif; text-align: center;
  padding: 18px 34px; z-index: 11; opacity: 0; transition: opacity .3s, transform .3s;
  box-shadow: 0 0 40px rgba(150,90,220,.35);
}
#achv-popup.show { opacity: 1; transform: translateX(-50%) scale(1); }
#achv-popup .achv-title { font-size: 14px; letter-spacing: 3px; color: #b07ce8; margin-bottom: 6px; }
#achv-popup .achv-name { font-size: 20px; color: #fff; }
#achv-popup .achv-desc { font-size: 13px; margin-top: 6px; color: #a98cc4; }

/* Scrolling combat text reste canvas-side */
