* { margin: 0; padding: 0; }
body { overflow: hidden; background: #87CEEB; }
canvas { display: block; }

/* ── Utilitaire HUD ──────────────────────────────────────────────────────── */
.hud-hidden { display: none !important; }

/* ── Menu HUD (haut centre) ──────────────────────────────────────────────── */
#hud-bar {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,0.45);
  padding: 5px 10px;
  border-radius: 12px;
  z-index: 100;
  user-select: none;
}

.hud-btn {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.5);
  font-size: 16px;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}
.hud-btn.active {
  background: rgba(255,255,255,0.22);
  color: white;
  border-color: rgba(255,255,255,0.45);
}
.hud-btn:hover { background: rgba(255,255,255,0.30); color: white; }

.hud-sep {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,0.25);
  margin: 0 2px;
}

/* ── Sélecteur de carte ──────────────────────────────────────────────────── */
#map-select-panel {
  display: none;
  position: fixed;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,18,28,0.96);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 14px;
  padding: 12px;
  z-index: 150;
  gap: 10px;
  flex-direction: row;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
}
#map-select-panel.open { display: flex; }

.map-card {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  color: white;
  font-family: sans-serif;
  cursor: pointer;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 160px;
  transition: background 0.15s, border-color 0.15s;
}
.map-card:hover        { background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.35); }
.map-card.active       { background: rgba(255,255,255,0.20); border-color: rgba(255,255,255,0.55); }
.map-card-emoji        { font-size: 28px; }
.map-card-name         { font-size: 14px; font-weight: bold; }
.map-card-desc         { font-size: 11px; color: rgba(255,255,255,0.6); text-align: center; line-height: 1.4; }

/* ── Barre de contrôles (haut centre, sous le menu) ─────────────────────── */
#controls-bar {
  position: fixed;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0,0,0,0.40);
  padding: 5px 10px;
  border-radius: 10px;
  z-index: 100;
  user-select: none;
  white-space: nowrap;
}

.ctrl-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  font-size: 15px;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
  padding: 0;
}
.ctrl-btn.ctrl-wide { width: auto; padding: 0 10px; }
.ctrl-btn:hover  { background: rgba(255,255,255,0.28); }
.ctrl-btn:active { background: rgba(255,255,255,0.5);  }

.ctrl-sep {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,0.25);
  margin: 0 2px;
}

.ctrl-hint {
  color: rgba(255,255,255,0.70);
  font-family: sans-serif;
  font-size: 13px;
  padding: 0 4px;
}

/* ── Infos caméra (haut droite) ──────────────────────────────────────────── */
#cam-info {
  position: fixed;
  top: 16px;
  right: 16px;
  color: white;
  font-family: monospace;
  font-size: 13px;
  text-shadow: 1px 1px 2px black;
  background: rgba(0,0,0,0.4);
  padding: 8px 14px;
  border-radius: 10px;
  pointer-events: none;
  line-height: 1.7;
}

/* ── Hints caméra (sous les infos caméra, haut droite) ──────────────────── */
#cam-hints {
  position: fixed;
  top: 120px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}
#cam-hints span {
  color: rgba(255,255,255,0.65);
  font-family: sans-serif;
  font-size: 12px;
  text-shadow: 1px 1px 2px black;
  background: rgba(0,0,0,0.35);
  padding: 4px 10px;
  border-radius: 8px;
  white-space: nowrap;
}

/* ── Inventaire (haut gauche) ────────────────────────────────────────────── */
#inventory {
  position: fixed;
  top: 16px;
  left: 16px;
  color: #fff;
  font-family: sans-serif;
  font-size: 15px;
  text-shadow: 1px 1px 2px black;
  background: rgba(0,0,0,0.45);
  padding: 8px 16px;
  border-radius: 10px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.inv-row   { display: flex; align-items: center; gap: 8px; }
.inv-icon  { font-size: 20px; }
.inv-count { font-weight: bold; min-width: 24px; }

/* ── Minimap (bas droite) ────────────────────────────────────────────────── */
#minimap-wrap {
  position: fixed;
  bottom: 20px;
  right: 16px;
  pointer-events: none;
}
#minimap {
  display: block;
  border: 2px solid rgba(255,255,255,0.55);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.1s, box-shadow 0.1s;
}
#minimap:hover {
  transform: scale(1.04);
  box-shadow: 0 4px 14px rgba(0,0,0,0.7);
}
#minimap-label {
  text-align: center;
  color: rgba(255,255,255,0.8);
  font-family: sans-serif;
  font-size: 11px;
  text-shadow: 1px 1px 2px black;
  margin-top: 4px;
}

/* ── Grande carte (modale) ───────────────────────────────────────────────── */
#map-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
#map-modal.open { display: flex; }
#map-large {
  border: 3px solid rgba(255,255,255,0.7);
  border-radius: 12px;
  box-shadow: 0 6px 32px rgba(0,0,0,0.8);
  width: min(80vw, 80vh);
  height: min(80vw, 80vh);
  image-rendering: pixelated;
}

/* ── Modale d'aide ───────────────────────────────────────────────────────── */
#help-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
#help-modal.open { display: flex; }

#help-content {
  position: relative;
  background: rgba(20,20,30,0.96);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  padding: 32px 36px;
  max-width: 520px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  color: white;
  font-family: sans-serif;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8);
}

#help-content h2 {
  font-size: 20px;
  margin-bottom: 20px;
  text-align: center;
  opacity: 0.95;
}
#help-content h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.5);
  margin: 20px 0 8px;
}
#help-content h3:first-of-type { margin-top: 0; }

#help-content table {
  width: 100%;
  border-collapse: collapse;
}
#help-content td {
  padding: 5px 8px;
  font-size: 14px;
  line-height: 1.5;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
#help-content td:first-child {
  font-family: monospace;
  font-size: 13px;
  color: rgba(255,220,100,0.9);
  white-space: nowrap;
  width: 1%;
  padding-right: 16px;
}

#help-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
#help-close:hover { color: white; }

/* ── Message toast (centre bas) ─────────────────────────────────────────── */
#game-message {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10,10,20,0.88);
  color: rgba(255,220,100,0.95);
  font-family: sans-serif;
  font-size: 15px;
  padding: 10px 22px;
  border-radius: 10px;
  border: 1px solid rgba(255,200,50,0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 200;
  white-space: nowrap;
}
#game-message.visible { opacity: 1; }

/* ── Menu développeur (bas gauche) ──────────────────────────────────────── */
#dev-menu {
  position: fixed;
  bottom: 20px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(10,10,20,0.88);
  border: 1px solid rgba(255,200,50,0.35);
  border-radius: 10px;
  padding: 10px 14px;
  z-index: 100;
}
#dev-menu button {
  background: rgba(255,200,50,0.12);
  border: 1px solid rgba(255,200,50,0.4);
  color: rgba(255,220,80,0.95);
  font-family: sans-serif;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
#dev-menu button:hover { background: rgba(255,200,50,0.28); }

/* ── Stockage abri ───────────────────────────────────────────────────────── */
#storage-modal {
  display: none;
  position: fixed;
  top: 56px;
  right: 12px;
  z-index: 300;
}
#storage-panel {
  position: relative;
  background: rgba(15,10,5,0.96);
  border: 2px solid #6a8a40;
  border-radius: 10px;
  padding: 20px 24px;
  color: #fff;
  font-family: sans-serif;
  min-width: 320px;
}
#storage-panel h2 { margin: 0 0 16px; font-size: 1.15rem; color: #a8d060; text-align: center; }
#storage-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; color: #e05050;
  font-size: 18px; cursor: pointer; line-height: 1;
}
#storage-close:hover { color: #ff7070; }
.storage-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.storage-table th {
  color: #a8d060; font-weight: normal; padding: 4px 8px;
  border-bottom: 1px solid rgba(168,208,96,0.3); text-align: center;
}
.storage-table td { padding: 7px 8px; text-align: center; }
.storage-table tr:nth-child(even) td { background: rgba(255,255,255,0.04); }
.st-btn {
  padding: 3px 10px; background: #3a5a18; color: #cef080;
  border: 1px solid #6a8a40; border-radius: 4px; cursor: pointer; font-size: 0.9rem;
}
.st-btn:hover { background: #4a7a22; }
.storage-all-btns {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: center;
}
.st-btn-all {
  flex: 1;
  padding: 6px 12px;
  background: #2a4a10;
  color: #cef080;
  border: 1px solid #6a8a40;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: background 0.15s;
}
.st-btn-all:hover { background: #3a6018; }

/* ── Menu crafting (établi) ─────────────────────────────────────────────── */
#crafting-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
#crafting-modal.open { display: flex; }
#crafting-panel {
  background: rgba(20,14,8,0.96);
  border: 2px solid #8b6010;
  border-radius: 10px;
  padding: 24px 32px;
  color: #fff;
  min-width: 280px;
  text-align: center;
  font-family: sans-serif;
}
#craft-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: #e05050;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
#craft-close:hover { color: #ff7070; }
#crafting-panel { position: relative; }
#crafting-panel h2 { margin: 0 0 16px; font-size: 1.2rem; color: #f5c842; }
.recipe-row { margin-bottom: 8px; }
.recipe-label { font-size: 0.95rem; }
.recipe-stock { display: block; font-size: 0.82rem; color: #aaa; margin-top: 4px; }
#craft-progress-bar-wrap {
  background: #333;
  border-radius: 4px;
  height: 10px;
  margin: 12px 0;
  display: none;
}
#craft-progress-bar {
  background: #8b6010;
  height: 100%;
  border-radius: 4px;
  width: 0%;
  transition: width 0.1s linear;
}
#craft-btn {
  padding: 8px 24px;
  background: #8b6010;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  margin-top: 8px;
}
#craft-btn:disabled { background: #555; cursor: not-allowed; }
.crafting-hint { font-size: 0.75rem; color: #888; margin-top: 10px; margin-bottom: 0; }

/* ── Éclair ──────────────────────────────────────────────────────────────── */
#lightning-overlay {
  position: fixed;
  inset: 0;
  background: #e8f0ff;
  opacity: 0;
  pointer-events: none;
  z-index: 60;
  transition: opacity 0.06s;
}

/* ── Cycle jour/nuit (HUD bar) ──────────────────────────────────────────────── */
#dn-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}
#daynight-bar {
  width: 60px;
  height: 5px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  overflow: hidden;
}
#daynight-fill {
  height: 100%;
  background: #ffe566;
  border-radius: 3px;
  width: 100%;
  transition: width 1s linear;
}
#dn-icon {
  font-size: 13px;
  line-height: 1;
}

/* ── Météo HUD ───────────────────────────────────────────────────────────── */
#weather-hud {
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  cursor: default;
}

/* ── Mini-widget fabrication (bas droite, au-dessus de la minimap) ─────── */
#craft-widget {
  position: fixed;
  bottom: 200px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(20,14,8,0.92);
  border: 1px solid #8b6010;
  border-radius: 10px;
  padding: 10px 14px;
  z-index: 150;
  font-family: sans-serif;
  min-width: 190px;
}
#craft-widget-icon { font-size: 22px; }
#craft-widget-info { flex: 1; display: flex; flex-direction: column; gap: 6px; }
#craft-widget-label { font-size: 0.82rem; color: #f5c842; white-space: nowrap; }
#craft-widget-bar-wrap {
  background: #333;
  border-radius: 3px;
  height: 8px;
  width: 100%;
}
#craft-widget-bar {
  background: #8b6010;
  height: 100%;
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}

/* ── Chaleur volcanique ──────────────────────────────────────────────────── */
#heat-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 20%, rgba(220,30,0,0.75) 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
  z-index: 50;
}
