* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #1b1b23;
  color: #eee;
}

.hidden { display: none !important; }

/* --- Auth --- */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
.auth-form {
  background: #2a2a35;
  padding: 2rem;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-width: 280px;
}
.auth-form h1 { margin: 0 0 0.5rem; text-align: center; font-size: 1.4rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; }
.auth-form input {
  padding: 0.5rem;
  border-radius: 4px;
  border: 1px solid #555;
  background: #1b1b23;
  color: #eee;
}
.auth-form button {
  padding: 0.6rem;
  border: none;
  border-radius: 4px;
  background: #4a7c59;
  color: white;
  font-weight: bold;
  cursor: pointer;
}
.auth-switch { font-size: 0.85rem; text-align: center; }
.auth-switch a { color: #9fd3a8; }
.flash { color: #ff8080; list-style: none; padding: 0; margin: 0; font-size: 0.85rem; }

/* --- Game --- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  background: #2a2a35;
}
.gold-counter { font-weight: bold; color: #ffd166; }
.link-btn {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  text-decoration: underline;
}

main {
  max-width: 680px;
  margin: 1rem auto;
  padding: 0 1rem;
}

#scene {
  width: 100%;
  aspect-ratio: 640 / 200;
  image-rendering: pixelated;
  background: #3a5a40;
  border-radius: 6px;
  display: block;
  overflow: hidden;
}

.hp-bars { margin-top: 0.8rem; display: flex; flex-direction: column; gap: 0.4rem; }
.hp-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; }
.hp-row span:first-child { width: 4.5rem; }
.hp-bar {
  flex: 1;
  height: 14px;
  background: #111;
  border-radius: 4px;
  overflow: hidden;
}
.hp-fill { height: 100%; width: 100%; transition: width 0.2s; }
.hp-fill.hero { background: #4a90d9; }
.hp-fill.monster { background: #d94a4a; }

/* --- Panneau d'équipement + sac à dos (Phase 2) ---
   Cadre à double bordure dorée (liseré or clair + anneau brun sombre en
   inset), fond violet foncé avec un léger grain diagonal, slots biseautés.
   Vide pour l'instant : prêt à recevoir des sprites d'objets. */
:root {
  --gear-gold: #e8b923;
  --gear-gold-dark: #7a5a1a;
  --gear-purple: #2b2035;
  --gear-purple-dark: #221a2a;
  --gear-red: #c9433d;
  --slot-bg: #3a3548;
}

.gear-panel {
  margin-top: 1rem;
  background:
    repeating-linear-gradient(
      135deg,
      rgba(0, 0, 0, 0.12) 0px,
      rgba(0, 0, 0, 0.12) 2px,
      transparent 2px,
      transparent 14px
    ),
    var(--gear-purple);
  border: 3px solid var(--gear-gold);
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 3px var(--gear-purple-dark),
    inset 0 0 0 4px var(--gear-gold-dark),
    0 3px 8px rgba(0, 0, 0, 0.5);
  padding: 0.9rem;
}

.gear-header {
  text-align: center;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.9rem;
  color: #2a1a12;
  background: linear-gradient(#f0cf6e, #c9922f);
  border: 2px solid var(--gear-gold-dark);
  border-radius: 6px;
  padding: 0.35rem;
  margin: -0.2rem -0.2rem 0.8rem;
}

.gear-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.eq-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.eq-center {
  position: relative;
  width: 110px;
  height: 120px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
}
#doll-canvas {
  position: relative;
  z-index: 1;
  image-rendering: pixelated;
}
.eq-shadow {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 12px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 50%;
  filter: blur(1px);
}

.gear-divider {
  height: 3px;
  margin: 0.8rem 0;
  background: linear-gradient(90deg, transparent, var(--gear-red), transparent);
  opacity: 0.7;
}

.backpack-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.item-slot {
  aspect-ratio: 1;
  width: 100%;
  border: 2px solid var(--gear-gold);
  border-radius: 5px;
  background: var(--slot-bg);
  box-shadow:
    inset 0 0 0 2px var(--gear-purple-dark),
    inset 1px 1px 0 rgba(255, 255, 255, 0.08),
    inset -1px -1px 3px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  opacity: 0.7;
}

.eq-slot {
  width: 30px;
  height: 30px;
}

.danger-btn, .primary-btn {
  margin-top: 1rem;
  width: 100%;
  padding: 0.7rem;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
}
.danger-btn { background: #a0453f; color: white; }
.primary-btn { background: #4a7c59; color: white; }

.hero-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #ccc;
}

.upgrades {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.upgrade-btn {
  background: #2a2a35;
  border: 1px solid #444;
  border-radius: 6px;
  color: #eee;
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: flex-start;
  cursor: pointer;
  font-size: 0.85rem;
}
.upgrade-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.upgrade-btn strong { font-size: 0.95rem; }

.popup {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #2a2a35;
  border: 1px solid #ffd166;
  border-radius: 8px;
  padding: 1rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.popup button {
  background: #ffd166;
  border: none;
  border-radius: 4px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  font-weight: bold;
}
