:root {
  color-scheme: dark;
  --bg: #070707;
  --panel: rgba(13, 13, 15, 0.88);
  --panel-strong: rgba(9, 9, 11, 0.96);
  --line: rgba(235, 224, 201, 0.18);
  --text: #fbf7ee;
  --muted: #b9b0a1;
  --gold: #f2cd7b;
  --male: #88d7ff;
  --female: #ff9ac1;
  --memory: #d7d1c2;
  --green: #9be0b2;
  --red: #ff7f77;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  background:
    linear-gradient(rgba(242, 205, 123, 0.034) 1px, transparent 1px),
    linear-gradient(90deg, rgba(136, 215, 255, 0.022) 1px, transparent 1px),
    radial-gradient(circle at 18% 10%, rgba(242, 205, 123, 0.12), transparent 30%),
    radial-gradient(circle at 84% 18%, rgba(255, 154, 193, 0.10), transparent 28%),
    radial-gradient(circle at 55% 85%, rgba(136, 215, 255, 0.08), transparent 36%),
    var(--bg);
  background-size: 44px 44px, 44px 44px, auto, auto, auto, auto;
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 30px 34px 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.18em;
}

.brand { color: var(--text); font-weight: 900; text-decoration: none; }
.signal { text-align: right; }

main {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding-bottom: 44px;
}

.hero { padding: 42px 0 32px; }

.eyebrow, .kicker {
  margin: 0 0 14px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 1040px;
  font-size: clamp(44px, 7.2vw, 96px);
  line-height: 0.92;
  letter-spacing: 0;
}

.lead {
  max-width: 920px;
  margin: 24px 0 0;
  color: #dfd6c8;
  font-size: 18px;
  line-height: 1.8;
}

.sublead {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.stage-panel, .control-panel, .legend, .doc-shell {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
}

.stage-panel, .control-panel, .doc-shell { border-radius: 8px; }

.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

.stage-note { margin: 0; color: var(--muted); line-height: 1.7; }

.status-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(242, 205, 123, 0.42);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}

.canvas-wrap {
  position: relative;
  margin: 0 18px 18px;
  overflow: hidden;
  border: 1px solid rgba(235, 224, 201, 0.16);
  border-radius: 6px;
  background: #020202;
  aspect-ratio: 1120 / 720;
}

canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }

.hud, .first-hint {
  position: absolute;
  border: 1px solid rgba(251, 247, 238, 0.16);
  background: rgba(0, 0, 0, 0.46);
  color: rgba(251, 247, 238, 0.78);
  pointer-events: none;
}

.hud {
  top: 14px;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.hud-left { left: 14px; }
.hud-right { right: 14px; }
.hud-bottom { right: 14px; bottom: 14px; top: auto; }

.first-hint {
  left: 14px;
  bottom: 14px;
  z-index: 2;
  width: min(430px, calc(100% - 28px));
  border-color: rgba(242, 205, 123, 0.25);
  border-radius: 7px;
  padding: 12px 40px 12px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  pointer-events: auto;
}

.first-hint strong { display: block; margin-bottom: 4px; color: var(--text); }

.first-hint button {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 26px;
  min-height: 26px;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
}

.first-hint.is-hidden { display: none; }

.control-panel { padding: 14px; background: var(--panel-strong); }

.panel-block {
  padding: 16px 0;
  border-bottom: 1px solid rgba(251, 247, 238, 0.12);
}

.panel-block:first-child { padding-top: 4px; }
.panel-block:last-child { border-bottom: 0; }

button {
  min-height: 38px;
  border: 1px solid rgba(251, 247, 238, 0.16);
  border-radius: 6px;
  background: rgba(251, 247, 238, 0.055);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
}

button span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

button:hover, button.is-active {
  border-color: rgba(242, 205, 123, 0.58);
  background: rgba(242, 205, 123, 0.14);
}

button:hover span, button.is-active span { color: #f5dfaa; }

.button-grid, .segmented { display: grid; gap: 8px; }
.action-grid { grid-template-columns: repeat(3, 1fr); }
.lens-grid { grid-template-columns: repeat(3, 1fr); }

.ranges label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.ranges label:last-child { margin-bottom: 0; }
.ranges strong { color: var(--text); }
.ranges input { grid-column: 1 / -1; width: 100%; accent-color: var(--gold); }

.status-list dl { display: grid; gap: 8px; margin: 0; }

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(251, 247, 238, 0.08);
  padding-bottom: 7px;
}

.status-list dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.status-list dd {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.narrative-text, .report-text { margin: 0; color: var(--muted); line-height: 1.65; }

.report-text {
  width: 100%;
  resize: vertical;
  border: 1px solid rgba(251, 247, 238, 0.14);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px;
}

.legend {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 18px 0;
  border-radius: 8px;
  overflow: hidden;
}

.legend div {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px;
  color: var(--muted);
  line-height: 1.55;
  border-right: 1px solid rgba(251, 247, 238, 0.1);
}

.legend div:last-child { border-right: 0; }

.dot {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  margin-top: 5px;
  border-radius: 50%;
}

.male { background: var(--male); }
.female { background: var(--female); }
.memory { background: var(--memory); }
.extinct { background: var(--red); }

.doc-shell { margin-top: 18px; padding: 24px; }
.doc-head p:last-child { max-width: 880px; color: var(--muted); line-height: 1.75; }
.doc-shell h2, .doc-card h3 { margin: 0; letter-spacing: 0; }
.doc-shell h2 { font-size: 28px; }

.doc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 20px;
}

.doc-card {
  border: 1px solid rgba(251, 247, 238, 0.12);
  border-radius: 8px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.16);
}

.doc-card dl { display: grid; gap: 12px; margin: 16px 0 0; }
.doc-card dt { color: var(--text); font-weight: 900; margin-bottom: 4px; }
.doc-card dd { margin: 0; color: var(--muted); line-height: 1.65; }

.doc-card code {
  border: 1px solid rgba(242, 205, 123, 0.18);
  border-radius: 4px;
  background: rgba(242, 205, 123, 0.08);
  color: #fff7de;
  padding: 1px 5px;
}

.formula-card {
  border-color: rgba(242, 205, 123, 0.26);
  background: rgba(242, 205, 123, 0.055);
}

.site-footer {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 34px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid rgba(251, 247, 238, 0.12);
}

.site-footer a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 900;
}

@media (max-width: 1080px) {
  .workbench { grid-template-columns: 1fr; }
  .doc-grid { grid-template-columns: repeat(2, 1fr); }
  .control-panel { order: 2; }
}

@media (max-width: 720px) {
  .site-header { align-items: flex-start; flex-direction: column; padding-inline: 18px; }
  main { width: min(100% - 22px, 1240px); }
  .hero { padding-top: 28px; }
  .lead { font-size: 16px; }
  .sublead { font-size: 13px; }
  .stage-head { align-items: flex-start; flex-direction: column; }
  .status-badge { display: inline-flex; margin-top: 4px; }
  .action-grid, .lens-grid, .legend, .doc-grid { grid-template-columns: 1fr; }
  .hud-left { max-width: calc(100% - 28px); }
  .hud-right { display: none; }
  .site-footer { width: min(100% - 22px, 1240px); }
}
