:root {
  --bg: #0f1a17;
  --glass: rgba(14, 24, 22, 0.72);
  --line: rgba(255, 255, 255, 0.1);
  --text: #eaf5ef;
  --dim: #93a8a0;
  --accent: #5ee08f;
  --accent-2: #2fbf71;
  --warn: #ffb547;
  --bad: #ff6262;
  --radius: 14px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cfe3f2; color: var(--text); }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h3 { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); font-weight: 700; }

.panel, .stat, .toolbar .group, .brand {
  background: var(--glass);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
}
.panel { padding: 12px 14px; }

#hud-left { position: fixed; left: 12px; top: 12px; width: 268px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
#hud-left > * { pointer-events: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 10px 14px; }
.brand b { font-size: 17px; letter-spacing: 0.02em; display: block; }
.brand small { color: var(--dim); font-size: 11px; }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06241a; font-size: 22px; }
.logo.big { width: 64px; height: 64px; font-size: 40px; border-radius: 18px; margin: 0 auto 8px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { padding: 8px 12px; }
.stat label { display: block; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.stat b { font-size: 19px; font-variant-numeric: tabular-nums; }
#s-cash { color: var(--accent); }
#s-cash.flash-bad { color: var(--bad); }

#rec-rows { display: grid; gap: 7px; }
.rec { display: grid; grid-template-columns: 62px 1fr 38px; align-items: center; gap: 8px; font-size: 12px; }
.rec .bar { height: 7px; background: rgba(255, 255, 255, 0.08); border-radius: 4px; overflow: hidden; }
.rec .bar i { display: block; height: 100%; width: 0; border-radius: 4px; transition: width 0.4s; }
.rec span:last-child { text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }
#goal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: 12px; color: var(--dim); }
#goal-list li::before { content: "\25CB"; margin-right: 7px; color: var(--dim); }
#goal-list li.done { color: var(--accent); text-decoration: line-through; text-decoration-color: rgba(94, 224, 143, 0.4); }
#goal-list li.done::before { content: "\2713"; }

#hud-right { position: fixed; right: 12px; top: 12px; width: 322px; max-height: calc(100% - 24px); display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
#hud-right > * { pointer-events: auto; }
.toolbar { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toolbar .group { display: flex; padding: 3px; gap: 2px; }
.toolbar button { background: transparent; border: 0; padding: 6px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; color: var(--dim); }
.toolbar button:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }
.toolbar button.on { background: var(--accent); color: #06241a; }
.only-small { display: none; }

#plant { overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3a4d46 transparent; }
.slider { margin-bottom: 10px; }
.slider label { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.slider label b { color: var(--text); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.row.motor { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; padding: 8px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.row.motor small { display: block; color: var(--dim); margin-top: 2px; }
.btn, #b-motor { border: 1px solid rgba(94, 224, 143, 0.5); background: rgba(94, 224, 143, 0.12); color: var(--accent); padding: 6px 10px; border-radius: 9px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.btn:hover:not(:disabled), #b-motor:hover:not(:disabled) { background: rgba(94, 224, 143, 0.25); }
.btn:disabled, #b-motor:disabled { opacity: 0.4; cursor: not-allowed; border-color: var(--line); color: var(--dim); background: transparent; }
.btn.build { border-color: rgba(255, 181, 71, 0.6); background: rgba(255, 181, 71, 0.12); color: var(--warn); }

.card-st { padding: 10px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: rgba(255, 255, 255, 0.03); }
.card-st.locked { opacity: 0.85; border-style: dashed; }
.card-st header { display: flex; align-items: center; gap: 8px; }
.card-st .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.card-st h4 { margin: 0; font-size: 13px; flex: 1; }
.card-st p { margin: 4px 0 8px; font-size: 11.5px; line-height: 1.4; color: var(--dim); }
.card-st footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pips { display: flex; gap: 3px; }
.pips i { width: 14px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); }
.pips i.on { background: var(--accent); }
.meta { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }

#tags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; will-change: transform; font-size: 11px; font-weight: 700; white-space: nowrap; transform: translate(-50%, -50%); }
.tag.st { background: rgba(10, 20, 18, 0.78); padding: 3px 8px; border-radius: 8px; border: 1px solid var(--line); letter-spacing: 0.06em; color: #fff; }
.tag.st small { color: var(--accent); margin-left: 5px; }
.tag.st.cool { border-color: var(--warn); }
.tag.bin { background: rgba(10, 20, 18, 0.82); padding: 4px 8px 6px; border-radius: 9px; border: 1px solid var(--line); min-width: 84px; text-align: center; }
.tag.bin .nm { display: flex; justify-content: space-between; gap: 8px; color: #fff; }
.tag.bin .nm span { color: var(--dim); font-weight: 600; }
.tag.bin .bar { height: 4px; background: rgba(255, 255, 255, 0.15); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.tag.bin .bar i { display: block; height: 100%; width: 0; border-radius: 2px; }
.tag.site { pointer-events: auto; cursor: pointer; background: rgba(255, 181, 71, 0.95); color: #2b1a00; padding: 6px 12px; border-radius: 10px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); text-align: center; line-height: 1.25; }
.tag.site:hover { background: #ffc46b; }
.tag.site.poor { background: rgba(80, 90, 96, 0.95); color: #cfd8dc; cursor: default; }
.tag.hidden { display: none; }

#pops { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.pop { position: absolute; left: 0; top: 0; font-weight: 800; font-size: 14px; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); white-space: nowrap; }
.pop.good { color: #7dffb0; }
.pop.bad { color: #ff7a7a; }
.pop.warn { color: #ffd27a; }
.pop.dim { color: #cfd8dc; font-weight: 600; font-size: 12px; }

#toasts { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; z-index: 5; width: min(520px, calc(100vw - 24px)); }
.toast { background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 9px 14px; border-radius: 10px; font-size: 13px; animation: tin 0.3s ease-out; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); }
.toast.warn { border-left-color: var(--warn); }
.toast.bad { border-left-color: var(--bad); }
.toast.info { border-left-color: #6fb7ff; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: 0.4s; }
@keyframes tin { from { opacity: 0; transform: translateY(-10px); } }

#tip { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); max-width: min(620px, calc(100vw - 24px)); background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; font-size: 12.5px; color: var(--dim); text-align: center; transition: opacity 0.6s; }
#tip b { color: var(--accent); margin-right: 6px; }
#drag-hint { position: fixed; left: 50%; bottom: 62px; transform: translateX(-50%); background: var(--accent); color: #06241a; font-weight: 700; font-size: 13px; padding: 7px 14px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
body.dragging #drag-hint { opacity: 1; }
body.dragging #gl, body.hovering #gl { cursor: grabbing; }
body.hovering:not(.dragging) #gl { cursor: grab; }

#modal { position: fixed; inset: 0; display: none; place-items: center; background: radial-gradient(circle at 50% 40%, rgba(6, 24, 18, 0.55), rgba(4, 12, 10, 0.88)); z-index: 10; padding: 16px; overflow-y: auto; }
#modal.show { display: grid; }
.card { width: min(520px, 100%); background: rgba(14, 26, 23, 0.94); border: 1px solid var(--line); border-radius: 22px; padding: 26px 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); }
.hero { text-align: center; }
.hero h1 { margin: 0; font-size: 34px; letter-spacing: 0.02em; }
.hero p { margin: 2px 0 0; color: var(--accent); font-weight: 600; }
.lead { color: #c4d6ce; line-height: 1.55; font-size: 14px; }
.how { list-style: none; padding: 0; margin: 14px 0 20px; display: grid; gap: 10px; font-size: 13px; color: #c4d6ce; }
.how li { padding-left: 14px; border-left: 3px solid var(--accent); line-height: 1.45; }
.how b { display: block; color: #fff; }
.primary { width: 100%; padding: 13px; border: 0; border-radius: 12px; font-weight: 800; font-size: 16px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06241a; box-shadow: 0 8px 24px rgba(47, 191, 113, 0.35); }
.primary:hover { filter: brightness(1.08); }
.kbd { display: block; text-align: center; margin-top: 12px; color: var(--dim); }

@media (max-width: 900px) {
  #hud-left { width: 190px; }
  .stat b { font-size: 15px; }
  .stat { padding: 6px 9px; }
  #goals { display: none; }
  #hud-right { width: min(310px, calc(100vw - 24px)); }
  .only-small { display: block; }
  body.panel-closed #plant { display: none; }
}
@media (max-width: 640px) {
  #recovery { display: none; }
  #hud-left { width: 168px; }
  .brand small { display: none; }
  #tip { display: none; }
}
