:root {
  --ink: #fffbe9;
  --gold: #ffd166;
  --card: rgba(24, 38, 18, 0.78);
  --line: rgba(214, 255, 173, 0.22);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: radial-gradient(130% 100% at 50% 0%, #27401b 0%, #17290f 55%, #0d1808 100%);
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
}

.hud.top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 14px; pointer-events: none; z-index: 10;
}
.hud.top > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { margin: 0; font-size: clamp(15px, 2.2vw, 22px); text-shadow: 0 2px 8px rgba(0,0,0,.55); }
.chip {
  background: linear-gradient(180deg, #ffe08a, #f5a623);
  color: #33210a; font-weight: 700; font-size: 12px;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}

.right { display: flex; align-items: center; gap: 10px; }
.steps { display: flex; gap: 6px; }
.step {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(255,255,255,.08);
  color: var(--ink); font-weight: 700; font-size: 14px; cursor: pointer;
  transition: transform .12s, background .2s;
}
.step:hover { background: rgba(255,255,255,.16); }
.step.active { background: linear-gradient(180deg, #ffe08a, #f5a623); color: #33210a; border-color: #ffe9ad; }
.step.done { background: rgba(120, 220, 120, 0.35); border-color: rgba(180, 255, 180, 0.5); }

.btn {
  border: 1px solid var(--line); background: rgba(255,255,255,.09);
  color: var(--ink); border-radius: 12px; padding: 9px 16px;
  font-size: 14px; font-family: inherit; cursor: pointer;
  transition: transform .12s, filter .2s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(180deg, #ffe08a, #ef9315); color: #33210a; font-weight: 700; border-color: #ffe9ad; }
.btn.ghost { background: rgba(255,255,255,.06); }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 10px; }

.goal-card {
  position: fixed; left: 14px; top: 62px; max-width: 400px;
  padding: 12px 14px; font-size: 13.5px; line-height: 1.45; z-index: 9;
}
.goal-card p { margin: 0; }
.formula {
  margin-top: 8px; font-family: ui-monospace, Consolas, monospace;
  font-size: 12px; color: #ffe9ad;
}

.readout {
  position: fixed; right: 14px; top: 62px; width: 250px;
  padding: 12px 14px; font-size: 13px; z-index: 9;
}
.readout .row { display: flex; justify-content: space-between; padding: 3px 0; }
.readout .row b { font-variant-numeric: tabular-nums; }
.meter-row {
  display: grid; grid-template-columns: 52px 1fr 46px;
  align-items: center; gap: 8px; padding: 5px 0;
}
.meter-row b { text-align: right; font-variant-numeric: tabular-nums; }
.meter {
  position: relative; height: 10px; border-radius: 6px;
  background: rgba(255,255,255,.12); overflow: hidden;
}
.meter .fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  border-radius: 6px; transition: width .18s;
}
.fill.gold { background: linear-gradient(90deg, #ffe08a, #f0932b); }

.cargo-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 0 2px;
}
.dots { display: flex; gap: 6px; }
.dot {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); background: transparent;
}
.dot.red { background: #ff5a5f; border-color: rgba(255,255,255,.65); }
.dot.purple { background: #b07ce8; border-color: rgba(255,255,255,.65); }
.dot.yellow { background: #ffd94d; border-color: rgba(255,255,255,.65); }

.species { margin-top: 6px; }
.sp-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 0; font-size: 12.5px;
}
.sp-chip {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  margin-right: 7px; vertical-align: -1px;
}
.sp-row b { font-variant-numeric: tabular-nums; }

.status {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 96px; max-width: min(92vw, 620px); text-align: center;
  font-size: 14px; text-shadow: 0 2px 6px rgba(0,0,0,.85);
  opacity: 0; transition: opacity .35s; z-index: 8; pointer-events: none;
}
.status.show { opacity: 1; }
.status.info { color: #f4ffd9; }
.status.ok { color: #a7f3a0; }
.status.warn { color: #ffcf6d; }
.status.bad { color: #ff8a70; }

.dock {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 12px; width: min(760px, calc(100vw - 20px));
  padding: 10px 16px; z-index: 10;
}
.dock p { margin: 0; }
.howto { font-size: 12px; text-align: center; opacity: .78; }

.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(8, 14, 5, .55);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  width: min(520px, 92vw); padding: 24px; text-align: center;
  display: flex; flex-direction: column; gap: 14px;
}
.modal h2 { margin: 0; font-size: 23px; color: var(--gold); }
.modal p { margin: 0; font-size: 14.5px; line-height: 1.5; }
.modal .fact {
  font-size: 12.5px; opacity: .85; border-top: 1px solid var(--line);
  padding-top: 12px; font-style: italic;
}
.modal .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.loading {
  position: fixed; inset: 0; z-index: 30; background: #14220d;
  display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center;
  transition: opacity .4s;
}
.loading.gone { opacity: 0; pointer-events: none; }
.load-bar { width: min(320px, 70vw); height: 10px; border-radius: 6px; background: rgba(255,255,255,.12); overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffe08a, #f5a623); transition: width .25s; }
.loading p { margin: 0; font-size: 13px; opacity: .8; }
