/* FÖRDERWERK — HUD und Menüs. Dunkles Glas, dünne Linien, warmer Akzent. */

:root {
  --bg: #0b0f11;
  --glass: rgba(14, 20, 24, 0.58);
  --glass-strong: rgba(11, 16, 19, 0.86);
  --line: rgba(255, 255, 255, 0.13);
  --line-soft: rgba(255, 255, 255, 0.07);
  --text: #eef3f5;
  --muted: #9fb0b6;
  --accent: #ffb648;
  --ok: #7ef2a0;
  --warn: #ffb05e;
  --bad: #ff6b5e;
  --r: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
body { cursor: default; }
body.playing { cursor: none; }
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
b, strong { font-weight: 650; }

/* ------------------------------------------------------------------- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; user-select: none; }

.panel {
  position: absolute;
  background: var(--glass);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
}

#quests { top: 18px; left: 18px; width: 268px; }
#quests h2 {
  margin: 0 0 8px; font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
}
#quests ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
#quests li {
  display: grid; grid-template-columns: 13px 1fr; gap: 9px; align-items: start;
  color: var(--muted); transition: color 0.3s ease;
}
#quests li .txt { min-width: 0; }
#quests li::before {
  content: ""; width: 11px; height: 11px; margin-top: 4px; flex: none;
  border: 1.5px solid var(--line); border-radius: 4px;
  transition: all 0.35s cubic-bezier(0.2, 0.9, 0.2, 1);
}
#quests li.on { color: var(--text); }
#quests li.on::before { border-color: var(--accent); box-shadow: inset 0 0 0 2px rgba(255, 182, 72, 0.28); }
#quests li.done { color: rgba(126, 242, 160, 0.85); }
#quests li.done::before {
  background: var(--ok); border-color: var(--ok);
  box-shadow: 0 0 12px rgba(126, 242, 160, 0.45);
}
#quests li .sub { display: block; font-size: 11.5px; line-height: 1.35; color: var(--muted); opacity: 0.78; }

#readout { top: 18px; right: 18px; width: 208px; }
#readout .row { display: flex; justify-content: space-between; gap: 12px; }
#readout .k { color: var(--muted); }
#readout b { font-family: var(--mono); font-variant-numeric: tabular-nums; }

#perf {
  bottom: 18px; right: 18px; padding: 7px 12px;
  font-size: 12px; color: var(--muted);
}
#perf .sep { opacity: 0.4; margin: 0 6px; }

/* reticle ------------------------------------------------------------- */
#reticle {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px;
  transform: translate(-50%, -50%);
}
#reticle svg { width: 100%; height: 100%; overflow: visible; }
#reticle .tick {
  stroke: rgba(255, 255, 255, 0.85); stroke-width: 1.4; stroke-linecap: round;
  transition: transform 0.18s ease, opacity 0.18s ease;
  transform-origin: 22px 22px;
}
#reticle .dot { fill: rgba(255, 255, 255, 0.95); }
#reticle .ring { fill: none; stroke: rgba(255, 255, 255, 0.16); stroke-width: 2; opacity: 0; transition: opacity 0.2s ease; }
#reticle .progress {
  fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 22px 22px;
  stroke-dasharray: 94.2; stroke-dashoffset: 94.2;
  filter: drop-shadow(0 0 6px rgba(255, 182, 72, 0.7));
}
#reticle.busy .ring { opacity: 1; }
#reticle.target .tick { transform: scale(1.28); }
#reticle.target .dot { fill: var(--accent); }
#reticle.build .dot { fill: var(--ok); }
#reticle.blocked .dot { fill: var(--bad); }

/* look-at panel -------------------------------------------------------- */
#look {
  left: 50%; top: calc(50% + 46px); transform: translateX(-50%);
  min-width: 230px; max-width: 320px; padding: 11px 13px;
}
#look h3 { margin: 0 0 2px; font-size: 14px; }
#look .desc { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
#look .bars { display: grid; gap: 5px; }
#look .b { display: grid; grid-template-columns: 62px 1fr 42px; gap: 8px; align-items: center; font-size: 11.5px; }
#look .b span { color: var(--muted); }
#look .b i {
  height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.1);
  display: block; overflow: hidden; position: relative;
}
#look .b i::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: var(--v, 0%);
  background: var(--c, var(--accent)); border-radius: 99px;
  transition: width 0.2s linear;
}
#look .b em { font-family: var(--mono); font-style: normal; text-align: right; color: var(--text); }

/* prompt + toasts ------------------------------------------------------ */
#prompt {
  position: absolute; left: 50%; bottom: 182px; transform: translateX(-50%);
  background: var(--glass-strong); border: 1px solid var(--line);
  border-radius: 99px; padding: 7px 15px; font-size: 13px;
  backdrop-filter: blur(10px); box-shadow: var(--shadow); white-space: nowrap;
}
#prompt em { font-style: normal; color: var(--accent); margin-left: 4px; }
#prompt kbd, .keys kbd, #hint b {
  font-family: var(--mono); font-size: 11.5px; padding: 1px 6px;
  border-radius: 6px; background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line); margin: 0 2px;
}
#toasts {
  position: absolute; left: 50%; bottom: 226px; transform: translateX(-50%);
  display: grid; gap: 6px; justify-items: center;
}
.toast {
  background: var(--glass-strong); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 7px 14px; font-size: 13px;
  backdrop-filter: blur(10px); box-shadow: var(--shadow);
  animation: pop 0.28s cubic-bezier(0.2, 1.2, 0.3, 1) both;
}
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.out { animation: fade 0.4s ease forwards; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.96); } }
@keyframes fade { to { opacity: 0; transform: translateY(-6px); } }

/* bottom bar ---------------------------------------------------------- */
#bottom {
  position: absolute; left: 0; right: 0; bottom: 16px;
  display: grid; justify-items: center; gap: 34px;
}
#inv { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 74vw; }
.chip {
  display: flex; align-items: center; gap: 7px;
  background: var(--glass); border: 1px solid var(--line-soft);
  border-radius: 99px; padding: 4px 11px 4px 6px; font-size: 12.5px;
  backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.chip .sw { width: 11px; height: 11px; border-radius: 3px; box-shadow: inset 0 -3px 5px rgba(0, 0, 0, 0.35); }
.chip .n { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.chip.bump { animation: bump 0.3s ease; }
@keyframes bump { 40% { transform: translateY(-4px) scale(1.06); } }

#hotbar { display: flex; gap: 8px; }
.slot {
  position: relative; width: 62px; height: 62px;
  background: var(--glass); border: 1px solid var(--line-soft);
  border-radius: 15px; backdrop-filter: blur(14px); box-shadow: var(--shadow);
  display: grid; place-items: center;
  transition: transform 0.16s cubic-bezier(0.2, 1.2, 0.3, 1), border-color 0.2s, background 0.2s;
}
.slot svg { width: 30px; height: 30px; opacity: 0.9; }
.slot .num {
  position: absolute; top: 4px; left: 7px; font-family: var(--mono);
  font-size: 10px; color: var(--muted);
}
.slot .ct {
  position: absolute; bottom: 3px; right: 7px; font-family: var(--mono);
  font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.slot.empty svg { opacity: 0.28; }
.slot.empty .ct { color: var(--bad); }
.slot.sel {
  transform: translateY(-7px) scale(1.06);
  border-color: rgba(255, 182, 72, 0.55);
  background: rgba(38, 30, 18, 0.72);
}
.slot.sel::after {
  content: ""; position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%);
  width: 26px; height: 3px; border-radius: 99px; background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
.slot .lbl {
  position: absolute; top: -26px; left: 50%; transform: translateX(-50%);
  font-size: 11.5px; white-space: nowrap; color: var(--muted);
  opacity: 0; transition: opacity 0.2s;
}
.slot.sel .lbl { opacity: 1; color: var(--text); }

#hint { margin: -24px 0 0; font-size: 11.5px; color: var(--muted); opacity: 0.75; }

/* ---------------------------------------------------------------- overlays */
.overlay {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(120% 90% at 50% 0%, rgba(9, 14, 17, 0.72), rgba(5, 8, 10, 0.94));
  backdrop-filter: blur(7px); z-index: 20; padding: 24px;
  animation: in 0.3s ease both;
}
@keyframes in { from { opacity: 0; } }
.sheet {
  width: min(560px, 100%); background: var(--glass-strong);
  border: 1px solid var(--line); border-radius: 22px; padding: 28px;
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.6); pointer-events: auto;
}
.sheet.wide { width: min(680px, 100%); }
.sheet.narrow { width: min(420px, 100%); text-align: center; }
.sheet header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.sheet h1 {
  margin: 4px 0 10px; font-size: clamp(38px, 7vw, 62px); line-height: 0.95;
  letter-spacing: -0.03em; font-weight: 700;
  background: linear-gradient(180deg, #fff 10%, #ffcf8b 95%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sheet h2 { margin: 0; font-size: 19px; letter-spacing: -0.01em; }
.eyebrow {
  margin: 0; font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent); font-weight: 600;
}
.lead { margin: 0 0 18px; color: #cfdbdf; font-size: 14.5px; line-height: 1.6; }
.fine { margin: 14px 0 0; font-size: 12px; color: var(--muted); }

.keys {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 7px 16px; margin: 0 0 22px; font-size: 12.5px; color: var(--muted);
}
.keys div { display: flex; align-items: center; gap: 5px; }
.keys span { margin-left: 4px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
button {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  border-radius: 12px; padding: 11px 20px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06); color: var(--text);
  transition: transform 0.14s ease, background 0.2s, border-color 0.2s;
}
button:hover { background: rgba(255, 255, 255, 0.12); transform: translateY(-1px); }
button:active { transform: translateY(0); }
button.primary {
  background: linear-gradient(180deg, #ffc768, var(--accent));
  color: #241804; border-color: rgba(255, 210, 140, 0.7);
  box-shadow: 0 10px 26px rgba(255, 182, 72, 0.24);
}
button.primary:hover { background: linear-gradient(180deg, #ffd382, #ffbe5c); }
button.ghost { background: transparent; }
button.danger { color: var(--bad); border-color: rgba(255, 107, 94, 0.35); }
button.close { padding: 6px 13px; font-size: 12.5px; font-weight: 500; }

.settings { display: grid; gap: 14px; margin-bottom: 22px; }
.set { display: grid; gap: 6px; font-size: 13px; }
.set > span { color: var(--muted); display: flex; justify-content: space-between; }
.set i { font-style: normal; font-family: var(--mono); color: var(--text); }
select, input[type=range] { font: inherit; accent-color: var(--accent); }
select {
  background: rgba(255, 255, 255, 0.07); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
}
input[type=range] { width: 100%; height: 22px; }

/* crafting bench ------------------------------------------------------ */
.cards { display: grid; gap: 9px; margin-bottom: 16px; }
.card {
  display: grid; grid-template-columns: 42px 1fr auto; gap: 13px; align-items: center;
  border: 1px solid var(--line-soft); border-radius: 14px; padding: 11px 13px;
  background: rgba(255, 255, 255, 0.035); transition: border-color 0.2s, background 0.2s;
}
.card.can { border-color: rgba(126, 242, 160, 0.3); }
.card .ic { display: grid; place-items: center; }
.card .ic svg { width: 28px; height: 28px; }
.card h4 { margin: 0; font-size: 14px; }
.card p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.card .afford { font-size: 15px; color: var(--muted); }
.card.can .afford { color: var(--ok); }
.card button { padding: 8px 15px; font-size: 13px; }
.card button[disabled] { opacity: 0.4; cursor: not-allowed; transform: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.bar { height: 5px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin: 18px 0 10px; }
.bar i {
  display: block; height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), #ffe0a8);
  transition: width 0.25s ease;
}
pre { white-space: pre-wrap; font-size: 12px; color: var(--warn); text-align: left; }

@media (max-width: 620px) {
  #quests, #readout { display: none; }
  .slot { width: 52px; height: 52px; }
  #hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ------------------------------------------------------- objective waypoint */
#waypoint {
  position: absolute; left: 0; top: 0; width: 0; height: 0;
  display: grid; place-items: center; will-change: transform;
}
#waypoint .ring {
  position: absolute; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--accent); box-shadow: 0 0 14px rgba(255, 182, 72, 0.65);
  animation: pulse 2.2s ease-in-out infinite;
}
#waypoint .ring::after {
  content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--accent);
}
#waypoint .dist {
  position: absolute; top: 20px; font-family: var(--mono); font-size: 12px;
  color: #fff; text-shadow: 0 1px 4px #000; white-space: nowrap;
}
#waypoint .what {
  position: absolute; top: 36px; font-size: 11.5px; color: var(--accent);
  text-shadow: 0 1px 4px #000; white-space: nowrap;
}
#waypoint.edge .ring { border-style: dashed; }
@keyframes pulse { 50% { transform: scale(1.28); opacity: 0.55; } }

/* ------------------------------------------------------------------- radio */
#radio {
  left: 50%; top: 76px; transform: translateX(-50%);
  width: min(560px, 76vw); border-left: 3px solid var(--accent);
  animation: pop 0.3s cubic-bezier(0.2, 1.2, 0.3, 1) both;
}
#radio .who {
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent); font-weight: 600;
}
#radio p { margin: 3px 0 0; font-size: 14px; line-height: 1.5; }

#quests h2 i { font-style: normal; color: var(--muted); font-weight: 400; letter-spacing: 0; }
#questHint {
  margin: 9px 0 0; padding-top: 8px; border-top: 1px solid var(--line-soft);
  font-size: 11.5px; color: var(--accent); opacity: 0.9;
}

/* ------------------------------------------------- inventory + research pane */
.sheet.huge { width: min(1080px, 100%); max-height: 88vh; overflow-y: auto; }
.benchGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.benchGrid h3 {
  margin: 0 0 10px; font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
}
.benchGrid h3:not(:first-child) { margin-top: 22px; }
.invGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.cell {
  border: 1px solid var(--line-soft); border-radius: 12px; padding: 9px 10px;
  background: rgba(255, 255, 255, 0.035);
}
.cell.zero { opacity: 0.35; }
.cell .top { display: flex; align-items: center; gap: 6px; }
.cell .sw { width: 12px; height: 12px; border-radius: 3px; box-shadow: inset 0 -3px 5px rgba(0,0,0,0.35); }
.cell .nm { font-size: 11px; color: var(--muted); }
.cell .qty { font-family: var(--mono); font-size: 19px; font-variant-numeric: tabular-nums; }

.techs { display: grid; gap: 8px; }
.tech {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
  border: 1px solid var(--line-soft); border-radius: 14px; padding: 11px 13px;
  background: rgba(255, 255, 255, 0.03);
}
.tech h4 { margin: 0; font-size: 13.5px; }
.tech p { margin: 3px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.tech .cost { font-family: var(--mono); font-size: 11.5px; color: var(--accent); }
.tech.open { border-color: rgba(255, 182, 72, 0.4); }
.tech.done { border-color: rgba(126, 242, 160, 0.35); background: rgba(126, 242, 160, 0.06); }
.tech.done h4::before { content: "✓ "; color: var(--ok); }
.tech.locked { opacity: 0.45; }
.tech button { padding: 8px 14px; font-size: 12.5px; }
.tech button[disabled] { opacity: 0.4; cursor: not-allowed; transform: none; }
#techProgress { font-style: normal; color: var(--accent); font-weight: 400; letter-spacing: 0; }

@media (max-width: 880px) { .benchGrid { grid-template-columns: 1fr; } }
