:root {
  --ink: #fff6e8;
  --gold: #ffb84d;
  --card: rgba(30, 20, 11, 0.8);
  --line: rgba(255, 214, 150, 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%, #33220f 0%, #20140a 55%, #140c06 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, #ffc25e, #f59b1e);
  color: #2b1503; 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, #ffc25e, #f59b1e); color: #2b1503; border-color: #ffd79a; }

.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, #ffc25e, #ef9315); color: #2b1503; font-weight: 700; border-color: #ffd79a; }
.btn.accent { background: linear-gradient(180deg, #8fd7ff, #4aa8e8); color: #06263a; font-weight: 700; border-color: #bde6ff; }
.btn.ghost { background: rgba(255,255,255,.06); }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 10px; }
.btn.big { padding: 12px 26px; font-size: 16px; border-radius: 14px; }

.goal-card {
  position: fixed; left: 14px; top: 62px; max-width: 390px;
  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: #ffd79a;
}

.readout {
  position: fixed; right: 14px; top: 62px; width: 252px;
  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: 64px 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 .zone { position: absolute; top: 0; bottom: 0; background: rgba(128,214,128,.45); }
.meter .fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  border-radius: 6px; transition: width .18s;
}
.fill.gold { background: linear-gradient(90deg, #ffd27a, #e8961e); }
.fill.burn { background: linear-gradient(90deg, #9a9a9a, #262626); }
.row.sides { color: #ffd79a; font-size: 12px; }

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

.dock {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 14px; width: min(680px, calc(100vw - 20px));
  padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; z-index: 10;
}
.heat-wrap { display: flex; align-items: center; gap: 12px; }
.heat-wrap label { font-size: 13px; font-weight: 700; white-space: nowrap; }
.heat-wrap b { font-variant-numeric: tabular-nums; width: 48px; text-align: right; font-size: 13px; }
input[type='range'] { flex: 1; accent-color: #f59b1e; height: 26px; cursor: pointer; }
.controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.howto { margin: 0; font-size: 11.5px; text-align: center; opacity: .7; }

.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(10, 6, 3, .55);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  width: min(480px, 92vw); padding: 24px; text-align: center;
  display: flex; flex-direction: column; gap: 14px;
}
.modal h2 { margin: 0; font-size: 23px; color: #ffd27a; }
.modal p { margin: 0; font-size: 14.5px; line-height: 1.5; }
.modal .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.loading {
  position: fixed; inset: 0; z-index: 30; background: #1c130b;
  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, #ffd27a, #f59b1e); transition: width .25s; }
.loading p { margin: 0; font-size: 13px; opacity: .8; }

@media (max-width: 640px) {
  .goal-card { left: 10px; right: 178px; top: 58px; max-width: none; font-size: 11.8px; padding: 9px 11px; }
  .goal-card .formula { font-size: 10.5px; }
  .readout { top: auto; bottom: 172px; right: 10px; width: 156px; font-size: 11.5px; padding: 9px 10px; }
  .meter-row { grid-template-columns: 46px 1fr 34px; }
  .brand h1 { font-size: 14px; }
  .step { width: 30px; height: 30px; font-size: 13px; }
  .dock { padding: 9px 10px; bottom: 8px; }
  .btn.big { padding: 10px 16px; font-size: 14px; }
  .status { bottom: 128px; font-size: 12.5px; }
  .howto { font-size: 10.5px; }
}

.mats { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.mats.hidden { display: none; }
.mats .btn.mat.active { background: linear-gradient(180deg, #8fd7ff, #4aa8e8); color: #06263a; font-weight: 700; border-color: #bde6ff; }
.fill.boil { background: linear-gradient(90deg, #9adcff, #2f8fd6); }
