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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a2f1a;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  user-select: none;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
  touch-action: none; /* désactive le zoom/scroll du navigateur sur le canvas */
}

/* ---------- Joystick virtuel (mobile) ---------- */
#joystick-zone {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 50%;
  height: 45%;
  z-index: 15;
  display: none;
  touch-action: none;
}

#joystick-base {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(30, 50, 30, 0.4);
  border: 2px solid rgba(74, 124, 63, 0.6);
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
}

#joystick-knob {
  position: absolute;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #8fc97e, #4a7c3f);
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
}

body.touch-device #joystick-zone { display: block; }
body.touch-device #controls-hint { display: none; }

/* Empêche le rebond de page / zoom sur double-tap sur mobile */
html, body {
  overscroll-behavior: none;
}

@media (max-width: 700px) {
  .hud-box { min-width: 0; padding: 5px 7px; }
  .stat { padding: 1px 2px; gap: 1px; }
  .stat-value { font-size: 10px; }
  .level-line { flex-direction: column; align-items: center; gap: 2px; }
  .level-name { font-size: 9px; }
  .boss-progress { font-size: 8px; }
  #minimap { width: 80px; height: 80px; bottom: 8px; right: 8px; }
  #gameover .panel { padding: 28px 24px; }
  #gameover h1 { font-size: 28px; }
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 15px;
  left: 15px;
  pointer-events: none;
  z-index: 10;
}

.hud-box {
  background: rgba(16, 28, 16, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 14px;
  color: #d9f2c8;
  min-width: 160px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: all 0.3s ease;
}

/* Barre de vie */
.hp-bar-wrap {
  margin-bottom: 5px;
}

.hp-bar-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #9fc78f;
  margin-bottom: 1px;
}

.hp-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff4d4d, #ff8a5c);
  border-radius: 7px;
  transition: width 0.2s ease;
  box-shadow: 0 0 8px rgba(255, 77, 77, 0.5);
}

/* Stats */
.hud-stats {
  display: flex;
  gap: 4px;
}

.stat {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  padding: 2px 3px;
}

.stat-icon {
  font-size: 10px;
}

.stat-label {
  display: none;
}

.stat-value {
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
}

.stat-value.gold {
  color: #ffd75e;
  text-shadow: 0 0 8px rgba(255, 215, 94, 0.5);
}

.stat-value.cyan {
  color: #6be0ff;
  text-shadow: 0 0 8px rgba(107, 224, 255, 0.5);
}

.stat-value.pink {
  color: #ff7ad9;
  text-shadow: 0 0 8px rgba(255, 122, 217, 0.5);
}

.stat-value.purple {
  color: #b48cff;
  text-shadow: 0 0 8px rgba(180, 140, 255, 0.5);
}

/* Ligne niveau / progression boss */
.level-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: 4px;
  padding-top: 3px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.level-name {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #d9f2c8;
}

.boss-progress {
  font-size: 9px;
  font-weight: 600;
  color: #9fc78f;
  white-space: nowrap;
}

.boss-progress.danger {
  color: #ff6b6b;
  animation: bossPulse 0.8s ease-in-out infinite;
}

@keyframes bossPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ---------- Minimap ---------- */
#minimap {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(16, 28, 16, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 2px 10px rgba(0,0,0,0.5);
  z-index: 10;
  pointer-events: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Le canvas de la minimap doit suivre sa taille CSS (sinon le rendu est flou) */
#minimap { display: block; }

/* ---------- Aide contrôles ---------- */
#controls-hint {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(217, 242, 200, 0.8);
  font-size: 13px;
  background: rgba(20, 35, 20, 0.75);
  padding: 8px 20px;
  border-radius: 20px;
  border: 1px solid rgba(74, 124, 63, 0.5);
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

/* ---------- Game over ---------- */
#gameover {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 10, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  animation: fadeIn 0.4s ease;
}

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

#gameover.hidden {
  display: none;
}

#gameover .panel {
  background: rgba(16, 28, 16, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 50px 80px;
  text-align: center;
  color: #d9f2c8;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255,255,255,0.2);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#gameover h1 {
  font-size: 48px;
  color: #ff6b6b;
  letter-spacing: 6px;
  margin-bottom: 16px;
  text-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
}

.go-score {
  font-size: 20px;
  margin-bottom: 28px;
}

#restart-btn {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 16px 48px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  text-transform: uppercase;
}

#restart-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.4);
  border-color: rgba(255, 255, 255, 0.6);
}

#restart-btn:active {
  transform: translateY(1px);
}