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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: Georgia, 'Times New Roman', serif;
  color: #d8c9a3;
  user-select: none;
}

#screen {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  image-rendering: pixelated;
  cursor: crosshair;
}

/* ---- Viseur ---- */
#crosshair {
  position: absolute; left: 50%; top: 50%;
  width: 14px; height: 14px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
}
#crosshair::before, #crosshair::after {
  content: ""; position: absolute; background: rgba(232, 210, 160, .85);
}
#crosshair::before { left: 6px; top: 0; width: 2px; height: 14px; }
#crosshair::after  { left: 0; top: 6px; width: 14px; height: 2px; }

/* ---- Flash de dégâts ---- */
#damage-flash {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(160,0,0,.25), rgba(120,0,0,.75));
  opacity: 0; pointer-events: none; z-index: 6;
  transition: opacity .08s linear;
}

/* ---- HUD ---- */
#hud {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 12px 18px;
  z-index: 7; pointer-events: none;
  text-shadow: 1px 1px 2px #000;
}
.hud-label { font-size: 11px; letter-spacing: 3px; color: #9a8a66; }
#hud-left, #hud-right { background: rgba(10, 8, 4, .55); border: 1px solid #463a22; padding: 8px 12px; }
#hp-bar { width: 160px; height: 12px; background: #20150d; border: 1px solid #5a4326; margin: 4px 0; }
#hp-fill { height: 100%; width: 100%; background: linear-gradient(#c43, #801818); transition: width .15s; }
#hp-num { font-size: 22px; font-weight: bold; color: #e8d2a0; }
#kills { font-size: 22px; font-weight: bold; color: #e8d2a0; text-align: right; }
#hud-right { text-align: right; pointer-events: auto; }
#hud-msg {
  align-self: flex-end; margin: 0 14px; padding-bottom: 4px;
  font-style: italic; font-size: 15px; color: #cdb98c;
  min-height: 22px; text-align: center; flex: 1;
}
#btn-bestiaire {
  margin-top: 6px; cursor: pointer;
  background: #2a1f10; color: #d8c9a3; border: 1px solid #6a5430;
  font-family: inherit; font-size: 12px; padding: 4px 10px; letter-spacing: 1px;
}
#btn-bestiaire:hover { background: #3d2d16; }

/* ---- Overlays ---- */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(12,9,4,.82), rgba(0,0,0,.95));
  text-align: center; cursor: pointer; padding: 20px;
}
.overlay h1 {
  font-size: clamp(40px, 8vw, 86px); letter-spacing: 12px;
  color: #e8d2a0; text-shadow: 0 0 24px rgba(255, 150, 40, .35), 2px 2px 0 #000;
}
.overlay h2 { font-size: 20px; letter-spacing: 6px; color: #9a8a66; margin: 8px 0 24px; font-weight: normal; }
.lore { max-width: 560px; line-height: 1.6; color: #bda87c; font-style: italic; margin-bottom: 26px; }
.controls { line-height: 1.9; color: #8f8060; font-size: 15px; margin-bottom: 30px; }
.controls b { color: #d8c9a3; }
.click-hint { color: #e8d2a0; animation: pulse 1.6s ease-in-out infinite; letter-spacing: 2px; }
.death-title { color: #b22 !important; text-shadow: 0 0 30px rgba(200,0,0,.5), 2px 2px 0 #000 !important; }
#death-stats { color: #9a8a66; margin-bottom: 24px; font-size: 17px; }
@keyframes pulse { 0%,100% { opacity: .45; } 50% { opacity: 1; } }

.hidden { display: none !important; }

/* ---- Panneau bestiaire ---- */
#panel {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, 94vw); max-height: 92vh; overflow-y: auto;
  background: linear-gradient(#1c1408, #0e0a04);
  border: 2px solid #6a5430; box-shadow: 0 0 60px #000, inset 0 0 40px rgba(0,0,0,.6);
  padding: 22px 26px; z-index: 20;
}
#panel h2 { color: #e8d2a0; letter-spacing: 3px; font-size: 20px; margin-bottom: 16px; }
#panel h3 { color: #9a8a66; letter-spacing: 2px; font-size: 14px; margin: 18px 0 8px; }
.panel-cols { display: flex; gap: 24px; flex-wrap: wrap; }
.panel-col { flex: 1; min-width: 270px; }
#prev-wrap {
  width: 256px; height: 256px; margin: 10px 0;
  border: 1px solid #463a22;
  background:
    repeating-conic-gradient(#23211c 0 25%, #2e2b24 0 50%) 0 0 / 24px 24px;
}
#up-prev { width: 100%; height: 100%; image-rendering: auto; }
#panel label.row {
  display: flex; align-items: center; gap: 10px;
  margin: 9px 0; font-size: 14px; color: #bda87c;
}
#panel input[type=range] { flex: 1; accent-color: #b8860b; }
#panel input[type=text], #panel input[type=number] {
  background: #0a0703; color: #e8d2a0; border: 1px solid #5a4326;
  font-family: inherit; padding: 4px 8px; flex: 1;
}
#panel input[type=number] { flex: 0 0 64px; }
#panel span { min-width: 42px; text-align: right; color: #d8c9a3; }
.file-label {
  display: inline-block; cursor: pointer;
  background: #2a1f10; border: 1px solid #6a5430; padding: 8px 14px;
  color: #d8c9a3;
}
.file-label:hover { background: #3d2d16; }
.file-label input { display: none; }
#up-add, #up-close {
  cursor: pointer; font-family: inherit; letter-spacing: 1px;
  padding: 10px 18px; margin-top: 12px;
  background: #4a1410; color: #e8d2a0; border: 1px solid #8a4030; font-size: 15px;
}
#up-add:disabled { opacity: .35; cursor: default; }
#up-add:not(:disabled):hover { background: #6a1d15; }
#up-close { background: #2a1f10; border-color: #6a5430; }
#up-list { display: flex; flex-wrap: wrap; gap: 10px; min-height: 40px; color: #6a5e46; }
.beast-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 1px solid #463a22; background: rgba(0,0,0,.35); padding: 8px; width: 110px;
}
.beast-card img { width: 64px; height: 64px; object-fit: contain; }
.beast-card .bname { font-size: 12px; color: #d8c9a3; text-align: center; word-break: break-word; }
.beast-card button {
  cursor: pointer; font-family: inherit; font-size: 11px;
  background: #2a1f10; color: #d8c9a3; border: 1px solid #6a5430; padding: 3px 8px;
}
.beast-card button.del { border-color: #6a3020; color: #c08; color: #c87; }

#panel select {
  background: #0a0703; color: #e8d2a0; border: 1px solid #5a4326;
  font-family: inherit; padding: 4px 8px; flex: 1;
}
#wall-prev-wrap {
  width: 128px; height: 128px; margin: 10px 0;
  border: 1px solid #463a22;
  background: repeating-conic-gradient(#23211c 0 25%, #2e2b24 0 50%) 0 0 / 16px 16px;
}
#wall-prev { width: 100%; height: 100%; }
#wall-apply, #wall-reset {
  display: block; cursor: pointer; font-family: inherit; letter-spacing: 1px;
  padding: 8px 14px; margin-top: 10px; width: 100%;
  background: #2a1f10; color: #d8c9a3; border: 1px solid #6a5430; font-size: 14px;
}
#wall-apply:disabled { opacity: .35; cursor: default; }
#wall-apply:not(:disabled):hover, #wall-reset:hover { background: #3d2d16; }
.hint { font-size: 12px; color: #8f8060; font-style: italic; margin-top: 10px; line-height: 1.5; }
