:root {
  --bg: #0b0d10;
  --fg: #e7e9ec;
  --muted: #8a919a;
  --line: rgba(255, 255, 255, 0.09);
  --panel: rgba(20, 23, 28, 0.78);
  --accent: #ffb86b;
  --cool: #7cc4ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

a { color: inherit; }

.intro {
  position: fixed;
  top: 22px;
  left: 26px;
  max-width: 400px;
  pointer-events: none;
}
.intro a { pointer-events: auto; }
.back {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}
.back:hover { color: var(--fg); }
.intro h1 {
  margin: 6px 0 4px;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.lede { margin: 0; color: #b9bec5; }
.hint { margin: 8px 0 0; color: var(--accent); font-size: 13px; }

.panel {
  position: fixed;
  top: 16px;
  right: 16px;
  max-height: calc(100% - 32px);
  width: 300px;
  overflow: auto;
  background: var(--panel);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 18px 16px;
}
.panel > summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  margin-bottom: 10px;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::after { content: "–"; float: right; color: var(--muted); }
.panel:not([open]) > summary { margin-bottom: 0; }
.panel:not([open]) > summary::after { content: "+"; }

.group { margin-bottom: 12px; }
.label, .row label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.row { margin-bottom: 10px; }
.row output { color: var(--fg); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent); }

.materials {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.materials button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.materials button[aria-checked="true"] { border-color: var(--accent); background: rgba(255, 184, 107, 0.09); }
.swatch { width: 14px; height: 8px; border-radius: 2px; flex: none; }

.readout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 12px;
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.readout dt { color: var(--muted); }
.readout dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.about { margin-top: 12px; font-size: 12px; color: #b9bec5; }
.about summary { cursor: pointer; color: var(--muted); }
.about p { margin: 8px 0 0; }

.start, .toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 184, 107, 0.14);
  border: 1px solid rgba(255, 184, 107, 0.4);
  color: var(--accent);
  pointer-events: none;
  white-space: nowrap;
}
.start { top: 64%; animation: pulse 2.4s ease-in-out infinite; }
.start[hidden], .toast[hidden] { display: none; }
.toast { bottom: 24px; }
@keyframes pulse { 50% { opacity: 0.55; } }

@media (max-width: 860px) {
  .intro { top: 14px; left: 16px; right: 16px; }
  .intro h1 { font-size: 24px; }
  .lede { display: none; }
  .panel { top: auto; bottom: 12px; left: 12px; right: 12px; width: auto; max-height: 48%; }
  .start { top: 58%; }
  .toast { bottom: auto; top: 110px; }
}

@media (prefers-reduced-motion: reduce) {
  .start { animation: none; }
}
