:root {
  --scene-bg: #01070c;
  --scene-ink: #eaf7ff;
  --scene-accent: #58d7ff;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--scene-bg);
}

body {
  color: var(--scene-ink);
  font-family: "Source Sans 3", ui-sans-serif, system-ui, sans-serif;
}

.stage {
  position: fixed;
  inset: 0;
  isolation: isolate;
  background: var(--scene-bg);
}

canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: manipulation;
}

canvas:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--scene-accent) 82%, white);
  outline-offset: -6px;
}

.help {
  position: fixed;
  top: max(0.55rem, env(safe-area-inset-top));
  right: max(0.55rem, env(safe-area-inset-right));
  z-index: 20;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: color-mix(in srgb, var(--scene-accent) 80%, white);
  font: 700 1.05rem/1 "Source Sans 3", sans-serif;
  opacity: 0.52;
  text-decoration: none;
  transition: opacity 260ms ease;
}

.help:hover,
.help:focus-visible { opacity: 1; }

.help:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--scene-accent) 82%, white);
  outline-offset: 2px;
}

.scene-controls {
  position: fixed;
  left: max(0.8rem, env(safe-area-inset-left));
  bottom: max(0.8rem, env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  gap: 0.9rem;
  align-items: end;
  color: color-mix(in srgb, var(--scene-ink) 74%, transparent);
  font: 600 0.68rem/1.15 "Source Sans 3", sans-serif;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.scene-controls label { display: grid; gap: 0.38rem; }

.scene-controls select {
  min-width: 7.4rem;
  padding: 0.48rem 1.8rem 0.48rem 0.62rem;
  border: 1px solid color-mix(in srgb, var(--scene-accent) 46%, transparent);
  border-radius: 0;
  color: var(--scene-ink);
  background: color-mix(in srgb, var(--scene-bg) 88%, transparent);
  font: 600 0.8rem/1 "Source Sans 3", sans-serif;
}

.density-control { width: min(34vw, 11rem); }
.density-control output { color: var(--scene-ink); }
.density-control span { display: flex; justify-content: space-between; gap: 0.7rem; }

.density-control input {
  width: 100%;
  margin: 0;
  accent-color: var(--scene-accent);
}

.scene-controls select:focus-visible,
.scene-controls input:focus-visible,
.regen-button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--scene-accent) 82%, white);
  outline-offset: 2px;
}

.scene-actions {
  position: fixed;
  left: max(0.8rem, env(safe-area-inset-left));
  bottom: max(0.8rem, env(safe-area-inset-bottom));
  z-index: 20;
  transition: opacity 260ms ease;
}

body.ambient-idle .help,
body.ambient-idle .scene-actions {
  opacity: 0;
  pointer-events: none;
}

body.ambient-idle canvas { cursor: none; }

.regen-button {
  min-height: 44px;
  padding: 0.52rem 0.78rem;
  border: 1px solid color-mix(in srgb, var(--scene-accent) 46%, transparent);
  border-radius: 0;
  color: color-mix(in srgb, var(--scene-ink) 88%, transparent);
  background: color-mix(in srgb, var(--scene-bg) 88%, transparent);
  font: 700 0.68rem/1 "Source Sans 3", sans-serif;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  cursor: pointer;
}

.scene-controls .regen-button { align-self: end; }

.regen-button:hover {
  border-color: color-mix(in srgb, var(--scene-accent) 80%, transparent);
  color: var(--scene-ink);
}

.regen-button:active { transform: translateY(1px); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.embed .help,
body.dashboard-bg .help,
body.embed .scene-controls,
body.dashboard-bg .scene-controls,
body.embed .scene-actions,
body.dashboard-bg .scene-actions { display: none; }

@media (max-width: 520px) {
  .scene-controls { gap: 0.65rem; }
  .scene-controls select { min-width: 6.4rem; }
  .density-control { width: 7.5rem; }
  .regen-button { padding-inline: 0.62rem; }
}

@media (prefers-reduced-motion: reduce) {
  canvas { cursor: default; }
  .help,
  .scene-actions { transition: none; }
}
