:root {
  color-scheme: dark;
  --bg: #080707;
  --panel: rgba(14, 12, 12, 0.9);
  --panel-strong: rgba(10, 9, 9, 0.96);
  --line: rgba(255, 210, 154, 0.18);
  --text: #fff7ed;
  --muted: #c1b3a3;
  --gold: #f2cf83;
  --red: #ff7668;
  --violet: #c3a0ff;
  --cyan: #9ee7ff;
  --memory: #aaa39a;
}

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

body {
  background:
    linear-gradient(rgba(255, 210, 154, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(158, 231, 255, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 18% 12%, rgba(255, 118, 104, 0.12), transparent 30%),
    radial-gradient(circle at 84% 16%, rgba(195, 160, 255, 0.09), transparent 28%),
    radial-gradient(circle at 58% 86%, rgba(242, 207, 131, 0.08), transparent 34%),
    var(--bg);
  background-size: 42px 42px, 42px 42px, 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(46px, 7vw, 96px);
  line-height: 0.92;
  letter-spacing: 0;
}

h1 small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: clamp(18px, 2.4vw, 30px);
  line-height: 1.2;
}

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

.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, 207, 131, 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(255, 210, 154, 0.16);
  border-radius: 6px;
  background: #030202;
  aspect-ratio: 1120 / 720;
}

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

.hud, .first-hint {
  position: absolute;
  border: 1px solid rgba(255, 247, 237, 0.16);
  background: rgba(0, 0, 0, 0.48);
  color: rgba(255, 247, 237, 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(455px, calc(100% - 28px));
  border-color: rgba(242, 207, 131, 0.24);
  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(255, 247, 237, 0.12);
}

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

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

button[data-ja]::after {
  content: attr(data-ja);
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.1;
}

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

.button-grid, .segmented { display: grid; gap: 8px; }
.action-grid { grid-template-columns: repeat(3, 1fr); }
.lens-grid { grid-template-columns: repeat(4, 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(255, 247, 237, 0.08);
  padding-bottom: 7px;
}

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

.status-list dt small {
  display: block;
  margin-top: 2px;
  color: rgba(193, 179, 163, 0.82);
  font-size: 10px;
  letter-spacing: 0;
}

.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(255, 247, 237, 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(255, 247, 237, 0.1);
}

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

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

.active { background: var(--red); }
.heat { background: var(--violet); }
.memory { background: var(--memory); }
.offering { background: var(--gold); }

.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(255, 247, 237, 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; }

.formula-card {
  border-color: rgba(195, 160, 255, 0.28);
  background: rgba(195, 160, 255, 0.045);
}

.shrine-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 34px;
  border-top: 1px solid rgba(255, 247, 237, 0.12);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.shrine-footer a {
  color: var(--gold);
  text-decoration: none;
}

@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; }
  .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; }
  .shrine-footer {
    display: grid;
    width: min(100% - 22px, 1240px);
  }
}
