:root {
  --bg: #0a0f1f;
  --panel: rgba(17, 25, 50, 0.94);
  --line: #2a3a63;
  --ink: #e8ecf7;
  --muted: #9aa6c4;
  --gold: #ffcc4e;
  --ok: #34d399;
  --bad: #f87171;
  --teal: #2dd4bf;
  --left-w: 290px;
  --right-w: 330px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #1a2347 0%, var(--bg) 70%);
  color: var(--ink);
  font: 16px/1.5 'Be Vietnam Pro', system-ui, sans-serif;
}

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#leaders { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#labels { position: fixed; inset: 0; pointer-events: none; }

.panel {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

h2, h3 { margin: 14px 0 6px; font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h2:first-child { margin-top: 0; }

.title { top: 16px; left: 16px; width: var(--left-w); padding: 12px 18px; }
.title .tag { color: var(--gold); font-size: 13px; font-weight: 600; letter-spacing: .04em; }
.title h1 { margin: 2px 0 0; font-size: 21px; }

.lab {
  top: 100px; left: 16px; width: var(--left-w); padding: 14px 16px;
  max-height: calc(100vh - 100px - 48px); overflow-y: auto;
}
.desc { margin: 8px 0 0; font-weight: 600; font-size: 15px; }
.scenarios { display: flex; flex-direction: column; gap: 6px; }
.scn {
  font: inherit; font-size: 14.5px; text-align: left; color: var(--ink);
  background: rgba(10, 15, 31, 0.5); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; cursor: pointer;
}
.scn:hover { border-color: var(--gold); }
.scn.on { border-color: var(--gold); background: rgba(255, 204, 78, 0.12); }
.scnbox { margin-top: 10px; padding-left: 10px; border-left: 3px solid var(--gold); font-size: 14.5px; }
.scnbox p { margin: 0 0 6px; }
.scnbox summary, .assume summary { cursor: pointer; font-weight: 600; }
.assume { margin-top: 14px; font-size: 13.5px; color: var(--muted); }
.assume ul { padding-left: 18px; margin: 6px 0 0; }

.controls {
  top: 16px; right: 16px; width: var(--right-w); padding: 14px 16px;
  max-height: calc(100vh - 32px - 30px); overflow-y: auto;
}
.row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.row b { color: var(--gold); }
.row.ends { font-size: 14px; color: var(--muted); }

input[type=range] { width: 100%; accent-color: var(--gold); height: 26px; }
input[type=range]:disabled { opacity: 0.5; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font: inherit; font-size: 14.5px;
  color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px; cursor: pointer;
}
.chip:hover { border-color: var(--gold); }
.chip.on { background: var(--gold); border-color: var(--gold); color: #0a0f1f; font-weight: 600; }

.lensbox { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.vrow { display: flex; flex-direction: column; margin-top: 6px; font-size: 14px; }
.vrow .chips { margin-top: 4px; }
.hint2 { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.msg { margin: 8px 0 0; font-size: 14px; font-weight: 600; color: var(--gold); min-height: 1em; }
.msg:empty { display: none; }
.sub { margin: 10px 0 2px; font-size: 14px; }
.pump { display: grid; grid-template-columns: 60px 1fr; gap: 12px; align-items: center; margin-top: 10px; }
.pump svg { width: 60px; height: 110px; }
.big { font-size: 20px; color: var(--gold); }
.chart { width: 100%; height: 70px; display: block; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.dot.rich { background: #e3242b; }
.dot.poor { background: #5563e0; }

.phase { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.bar { position: relative; display: flex; height: 10px; border-radius: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; }
.bar i { position: absolute; top: -2px; width: 3px; height: 14px; background: #fff; border-radius: 2px; }
.phase p { margin: 8px 0 6px; font-weight: 600; min-height: 48px; }
.phase dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 14px; color: var(--muted); }
.phase dd { margin: 0; font-weight: 600; }
.phase dd.open { color: var(--ok); }
.phase dd.shut { color: var(--bad); }

.card {
  left: 50%; bottom: 44px; transform: translateX(calc(-50% + (var(--left-w) - var(--right-w)) / 2));
  width: min(440px, calc(100vw - var(--left-w) - var(--right-w) - 80px)); padding: 12px 16px;
}
.card h3 { margin: 0 0 4px; color: var(--gold); font-size: 19px; text-transform: none; letter-spacing: 0; }
.card p { margin: 0; }

.hint { position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%); margin: 0; color: var(--muted); font-size: 14px; pointer-events: none; }

.label {
  position: absolute; white-space: nowrap;
  font-size: 15px; font-weight: 600;
  padding: 3px 10px; border-radius: 6px;
  background: rgba(10, 15, 31, 0.85); border: 1px solid var(--c, #888);
  transform: translateY(-50%);
}

.modal { position: fixed; inset: 0; background: rgba(5, 8, 18, 0.7); display: grid; place-items: center; z-index: 10; }
.modal[hidden] { display: none; }
.sheet { position: relative; width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; padding: 18px 22px; }
.sheet h2 { color: var(--gold); font-size: 15px; }
.sheet .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.sheet table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sheet th, .sheet td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; }
.sheet th { color: var(--muted); font-weight: 500; }
.sheet .plot { width: 100%; height: auto; margin-top: 8px; }
.sheet textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.notes { padding-left: 18px; font-size: 14px; }
.notes small { color: var(--muted); }
.close { position: absolute; top: 10px; right: 12px; font: inherit; font-size: 22px; color: var(--ink); background: none; border: 0; cursor: pointer; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; font-size: 18px; color: var(--muted); pointer-events: none; }

.credit { position: fixed; bottom: 8px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--muted); pointer-events: none; }

@media (max-width: 900px) {
  :root { --left-w: calc(100vw - 32px); --right-w: calc(100vw - 32px); }
  .lab { top: auto; bottom: 40px; max-height: 30vh; }
  .controls { top: auto; bottom: calc(40px + 30vh + 8px); max-height: 30vh; }
  .card { transform: translateX(-50%); width: calc(100vw - 32px); bottom: auto; top: 90px; }
  .sheet .cols { grid-template-columns: 1fr; }
}
