:root {
  color-scheme: dark;
  --bg: #050504;
  --panel: rgba(17, 18, 14, .95);
  --line: rgba(226, 213, 170, .22);
  --text: #f2ead5;
  --muted: #aaa38f;
  --green: #93d79b;
  --amber: #efbf6a;
  --red: #ff725f;
  --cyan: #7bd7ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    linear-gradient(rgba(239, 191, 106, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(239, 191, 106, .035) 1px, transparent 1px),
    radial-gradient(circle at 18% 10%, rgba(123, 215, 255, .11), transparent 26%),
    radial-gradient(circle at 84% 16%, rgba(147, 215, 155, .1), transparent 24%),
    var(--bg);
  background-size: 42px 42px, 42px 42px, auto, auto, auto;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  letter-spacing: 0;
}

a { color: inherit; }

.scene-header,
.scene-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(16px, 4vw, 48px);
  background: rgba(5, 5, 4, .9);
  border-bottom: 1px solid var(--line);
}

.scene-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: var(--muted);
}

.brand,
.scene-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand { text-decoration: none; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--green);
  color: var(--green);
  box-shadow: inset 0 0 18px rgba(147, 215, 155, .12);
}

.brand strong,
.brand small,
p span,
h2 span,
h2 small { display: block; }

.brand small,
.kicker,
.scene-nav {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
}

.scene-nav {
  flex-wrap: wrap;
}

.scene-nav a { text-decoration: none; }

main {
  padding: clamp(28px, 7vw, 82px) clamp(14px, 4vw, 48px);
}

.hero,
.workbench,
.factory-panel,
.notes-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(286px, 380px);
  gap: 20px;
}

.hero {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  align-items: end;
  margin-bottom: 24px;
}

.hero > *,
.workbench > *,
.factory-panel > *,
.notes-panel > *,
.panel { min-width: 0; }

h1 {
  margin: 6px 0 14px;
  font-size: clamp(38px, 7vw, 82px);
  line-height: .94;
}

h2 {
  margin: 0;
  font-size: clamp(20px, 3vw, 28px);
}

p { line-height: 1.75; }

.readout,
.panel {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(23, 24, 19, .96), rgba(7, 8, 6, .98));
  border-radius: 8px;
  box-shadow: inset 0 0 34px rgba(147, 215, 155, .05);
}

.readout {
  display: grid;
  gap: 12px;
  padding: 18px;
  color: var(--muted);
}

.readout span + span {
  border-top: 1px dashed rgba(242, 234, 213, .14);
  padding-top: 12px;
}

.panel { padding: 18px; }
.panel-head { margin-bottom: 14px; }

.stage-shell {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(242, 234, 213, .18);
  background:
    linear-gradient(rgba(147, 215, 155, .04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(147, 215, 155, .04) 1px, transparent 1px),
    #070906;
  background-size: 16px 16px;
  border-radius: 8px;
}

#sceneCanvas {
  display: block;
  width: 100%;
  max-width: 960px;
  image-rendering: pixelated;
  aspect-ratio: 16 / 9;
  cursor: grab;
}

#sceneCanvas:active {
  cursor: grabbing;
}

.transport,
.button-grid,
.factory-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

button,
select,
input::file-selector-button {
  min-height: 44px;
  border: 1px solid rgba(242, 234, 213, .22);
  border-radius: 6px;
  background: rgba(38, 38, 30, .92);
  color: var(--text);
  font: inherit;
}

button {
  width: 100%;
  cursor: pointer;
}

button:hover,
button.is-active {
  border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(147, 215, 155, .24), inset 0 0 20px rgba(147, 215, 155, .08);
}

button.primary {
  background: var(--green);
  color: #071007;
  font-weight: 900;
}

.control-stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

.select-row,
.range-row,
.file-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.range-row {
  grid-template-columns: 104px minmax(0, 1fr) 48px;
  margin-top: 12px;
}

.file-row {
  margin-top: 12px;
}

.path-tools {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

select,
input[type="range"],
input[type="file"] {
  width: 100%;
}

input[type="range"] {
  accent-color: var(--green);
}

.hint {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.factory-panel,
.guide-panel,
.notes-panel {
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
  margin-top: 28px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.factory-links {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0;
}

.factory-links a {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 110px;
  padding: 14px;
  text-decoration: none;
  border: 1px solid rgba(242, 234, 213, .2);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(22, 23, 18, .96), rgba(7, 8, 6, .98));
}

.factory-links strong {
  color: var(--green);
  font-size: 16px;
}

.factory-links span,
.notes-panel p {
  color: var(--muted);
  font-size: 12px;
}

.notes-panel small {
  color: var(--muted);
  margin-top: 6px;
}

.guide-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.guide-head h2 small {
  color: var(--muted);
  margin-top: 6px;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.guide-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(242, 234, 213, .2);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(22, 23, 18, .94), rgba(7, 8, 6, .98));
}

.guide-card h3 {
  margin: 4px 0 12px;
  font-size: 17px;
  color: var(--green);
}

.guide-card ol,
.guide-card dl {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

.guide-card ol {
  padding-left: 20px;
}

.guide-card dt {
  color: var(--text);
  font-weight: 800;
}

.guide-card dd {
  margin: 0 0 8px;
}

@media (max-width: 920px) {
  .scene-header,
  .hero,
  .workbench,
  .factory-panel,
  .guide-grid,
  .notes-panel {
    grid-template-columns: 1fr;
  }

  .scene-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .transport,
  .button-grid,
  .factory-links,
  .select-row,
  .range-row,
  .file-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: clamp(34px, 12vw, 56px);
    overflow-wrap: anywhere;
  }
}

@media (max-width: 430px) {
  main { padding-inline: 10px; }
  .panel { padding: 12px; }
}
