:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: ui-sans-serif, system-ui, sans-serif;
  background: #101512;
  color: #e8eee8;
}

/* Full-screen stage: canvas fills the viewport. viz.js keeps its buffer
   square and sizes it from clientWidth, so we center a square box sized
   to the shorter viewport axis (aspect-ratio keeps it square; viz.js's
   own resize listener + per-frame check re-fires on window resizes). */
.stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

#viz {
  width: min(100vw, 100vh);
  height: min(100vw, 100vh);
  aspect-ratio: 1;
  display: block;
}

/* Collapsible corner settings panel (pure <details>, no JS needed). */
.panel {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10;
  width: min(19rem, calc(100vw - 1.5rem));
  background: rgba(22, 29, 23, 0.92);
  border: 1px solid #263124;
  border-radius: 8px;
  backdrop-filter: blur(4px);
  /* On very short viewports (e.g. 667×375 landscape) the open panel can
     exceed the viewport height — cap it and scroll internally so the
     master slider stays reachable without body scrollbars. */
  max-height: calc(100vh - 1.5rem);
  overflow-y: auto;
}

.panel summary {
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  user-select: none;
  list-style: none;
}

.panel summary::-webkit-details-marker {
  display: none;
}

.panel summary::before {
  content: '▸ ';
}

.panel details[open] summary::before {
  content: '▾ ';
}

.panel-body {
  padding: 0 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

h1 {
  font-size: 1.25rem;
  margin: 0;
}

.play-button {
  font: inherit;
  font-size: 1rem;
  padding: 0.5rem 1rem;
  border: 1px solid #3b4f3b;
  border-radius: 6px;
  background: #1a241a;
  color: #e8eee8;
  cursor: pointer;
}

.play-button:hover {
  background: #263626;
}

.scenes {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.scenes button {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid #3b4f3b;
  border-radius: 6px;
  background: #16211a;
  color: #e8eee8;
  cursor: pointer;
}

.scenes button.active {
  background: #2c4a2c;
  border-color: #4c6b4c;
}

.mixer {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.layer {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.layer label {
  font-size: 0.95rem;
}

.master {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  border-top: 1px solid #263124;
  padding-top: 0.75rem;
}

.master label {
  font-size: 0.95rem;
}

.layer input[type='range'],
.master input[type='range'] {
  width: 100%;
}

@media (max-width: 480px) {
  .panel {
    top: 0.5rem;
    right: 0.5rem;
  }
}
