/* Brave New Worlds — HUD boven een 3D-scène. Zelfde opzet als maanbasis:
   donker, strak, weinig chroom. Uitgebreid met een grondstoffenpaneel, want
   hier zijn het er vijf in plaats van één brandstof. */

:root {
  --bg: #05070d;
  --paneel: rgba(12, 18, 30, 0.82);
  --rand: rgba(140, 175, 220, 0.22);
  --tekst: #d9e4f2;
  --dim: #8496ad;
  --oranje: #ff8b45;
  --cyaan: #62d8ff;
  --groen: #6fd66a;
  --rood: #ff6b5e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--tekst);
  font: 13px/1.45 "Segoe UI", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  -webkit-touch-callout: none;
  cursor: grab;
}
#scene.dragging { cursor: grabbing; }
#scene.aanwijzen { cursor: pointer; }
#scene.bouwen    { cursor: crosshair; }

/* ------------------------------------------------------------------ laden */

#loader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
  color: var(--dim);
  z-index: 50;
  transition: opacity .6s;
  text-align: center;
  padding: 24px;
}
#loader.weg { opacity: 0; pointer-events: none; }
#loader[hidden] { display: none; }
.spin {
  width: 34px; height: 34px;
  border: 2px solid rgba(255,255,255,.15);
  border-top-color: var(--oranje);
  border-radius: 50%;
  animation: draai 1s linear infinite;
}
@keyframes draai { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------- bovenbalk */

#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 14px;
  background: linear-gradient(rgba(5,8,15,.88), rgba(5,8,15,0));
  z-index: 10;
  flex-wrap: wrap;
  pointer-events: none;
}
#hud .res, #hud .meter, #hud .tgl { pointer-events: auto; }

.res { display: flex; align-items: center; gap: 8px; }
.res .ico {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 1px solid var(--rand);
  border-radius: 8px;
  color: var(--oranje);
  font-size: 15px;
}
.res b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.res small { color: var(--dim); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.res.naam .ico { color: var(--tekst); }

#v-name {
  display: block;
  width: 148px;
  padding: 0 0 1px;
  background: none;
  border: 0;
  border-bottom: 1px dashed transparent;
  color: var(--tekst);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
}
#v-name:hover { border-bottom-color: var(--rand); }
#v-name:focus { outline: none; border-bottom-color: var(--oranje); }

.meter { width: 128px; }
.meter .lbl {
  display: flex; justify-content: space-between;
  font-size: 10px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--dim);
}
.meter .lbl span:last-child { color: var(--tekst); font-variant-numeric: tabular-nums; }
.meter .bar {
  height: 6px;
  margin: 3px 0 2px;
  border-radius: 3px;
  background: rgba(255,255,255,.09);
  overflow: hidden;
}
.meter .fill {
  display: block; height: 100%; width: 0;
  border-radius: 3px;
  transition: width .25s linear;
}
.fill.pw { background: linear-gradient(90deg, #2b6fb0, var(--cyaan)); }
.fill.fd { background: linear-gradient(90deg, #2f7a3a, var(--groen)); }
.meter .rate { font-size: 10px; color: var(--dim); font-variant-numeric: tabular-nums; }
.meter .rate.min { color: var(--rood); }
.meter .rate.plus { color: var(--groen); }

.spacer { flex: 1; }
.toggles { display: flex; gap: 6px; }
.tgl {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--rand);
  color: var(--dim);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.tgl:hover { color: var(--tekst); border-color: rgba(160,200,255,.45); }
.tgl.on { color: #0a0f18; background: var(--cyaan); border-color: var(--cyaan); }

/* -------------------------------------------------------- grondstoffen -- */

#grondstoffen {
  position: fixed;
  right: 14px; top: 66px;
  width: 190px;
  padding: 10px 12px;
  background: var(--paneel);
  border: 1px solid var(--rand);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  z-index: 9;
}
#grondstoffen h3 {
  margin: 0 0 6px; font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--dim); font-weight: 600;
}
#gr-lijst { list-style: none; margin: 0; padding: 0; font-size: 12px; }
#gr-lijst li { display: flex; align-items: center; gap: 7px; padding: 2px 0; }
#gr-lijst li.dim { color: var(--dim); font-style: italic; }
#gr-lijst .ico { width: 16px; text-align: center; color: var(--cyaan); }
#gr-lijst .naam { flex: 1; color: var(--dim); }
#gr-lijst .waarde { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- bouwbalk */

#buildbar {
  position: fixed;
  left: 14px; bottom: 14px; right: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--paneel);
  border: 1px solid var(--rand);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  z-index: 10;
}
#build-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.bouwknop {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--rand);
  border-radius: 9px;
  color: var(--tekst);
  font: inherit; font-size: 12px;
  cursor: pointer;
  text-align: left;
}
.bouwknop .glyph { font-size: 15px; color: var(--cyaan); }
.bouwknop .prijs { color: var(--dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.bouwknop:hover:not(:disabled) { border-color: rgba(160,200,255,.5); background: rgba(255,255,255,.09); }
.bouwknop.actief { border-color: var(--oranje); box-shadow: 0 0 0 1px var(--oranje) inset; }
.bouwknop:disabled { opacity: .38; cursor: not-allowed; }

.hint { color: var(--dim); font-size: 11px; }
.hint.dim { opacity: .7; }

/* -------------------------------------------------------------- zijpaneel */

#panel {
  position: fixed;
  right: 14px; top: 168px;
  width: 264px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  padding: 16px;
  background: var(--paneel);
  border: 1px solid var(--rand);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  z-index: 10;
}
#panel[hidden] { display: none; }
#p-close {
  position: absolute; top: 10px; right: 10px;
  background: none; border: 0; color: var(--dim);
  font-size: 14px; cursor: pointer;
}
#p-close:hover { color: var(--tekst); }
#panel h2 { margin: 0 0 4px; font-size: 16px; }
#panel p { margin: 0 0 10px; color: var(--dim); font-size: 12px; }
#p-stats { list-style: none; margin: 0 0 12px; padding: 0; font-size: 12px; }
#p-stats li {
  display: flex; justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
#p-stats li span:last-child { font-variant-numeric: tabular-nums; text-align: right; }
#p-stats li.waarschuwing span:last-child { color: var(--rood); }
#p-actions { display: flex; flex-direction: column; gap: 6px; }
.actie {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--rand);
  background: rgba(255,255,255,.05);
  color: var(--tekst);
  font: inherit; font-size: 12px;
  cursor: pointer;
}
.actie.primair { background: var(--oranje); border-color: var(--oranje); color: #180a03; font-weight: 600; }
.actie.gevaar { color: var(--rood); }
.actie:hover:not(:disabled) { filter: brightness(1.12); }
.actie:disabled { opacity: .4; cursor: not-allowed; }

/* ------------------------------------------------------------- meldingen */

#toast {
  position: fixed;
  left: 50%; bottom: 92px;
  transform: translateX(-50%) translateY(10px);
  padding: 9px 16px;
  background: rgba(10, 16, 26, .92);
  border: 1px solid var(--rand);
  border-radius: 999px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 20;
  white-space: nowrap;
}
#toast.zien { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.slecht { border-color: rgba(255,107,94,.6); color: #ffd2cd; }
#toast.goed { border-color: rgba(111,214,106,.55); color: #d6f5d4; }

/* ------------------------------------------------------------------ hulp */

#help {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: rgba(3, 6, 12, .72);
  z-index: 40;
  padding: 20px;
}
#help[hidden] { display: none; }
#help .card {
  max-width: 500px;
  max-height: 88vh;
  overflow: auto;
  padding: 24px 26px;
  background: #0b1220;
  border: 1px solid var(--rand);
  border-radius: 14px;
}
#help h2 { margin: 0 0 8px; }
#help h3 { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--oranje); }
#help p, #help li { color: var(--dim); font-size: 13px; }
#help ul { margin: 0; padding-left: 18px; }
#help li { margin: 3px 0; }
#help b { color: var(--tekst); }
#help-close {
  margin-top: 20px; width: 100%;
  padding: 10px;
  background: var(--oranje); color: #180a03;
  border: 0; border-radius: 9px;
  font: inherit; font-weight: 600; cursor: pointer;
}

@media (max-width: 900px) {
  .meter { width: 96px; }
  #grondstoffen { top: auto; bottom: 78px; left: 14px; right: auto; width: 170px; }
  #panel { top: auto; bottom: 78px; right: 14px; width: 230px; max-height: 50vh; }
  .res small { display: none; }
}
