:root {
  /* Render native UI (scrollbars, form widgets, popups) dark to match the app. */
  color-scheme: dark;

  /* Theme palette — every static color in the UI lives here. Colors that appear
     at several opacities are stored as raw "r, g, b" channels (--*-rgb) so one
     edit re-tints all of them; the rgba() wrappers below pick the opacity.

     Surface — the panel; --panel-bg layers it translucently over the page,
     --surface is the opaque version native popups need (the <select> list paints
     over a white canvas, where a translucent color would wash out). */
  --panel-rgb: 12, 14, 22;
  --panel-bg: rgba(var(--panel-rgb), 0.72);
  --surface: rgb(var(--panel-rgb));

  /* Background — the page void and the start-overlay gradient. */
  --bg: #05060a;
  --bg-2: #0a0e1c;

  /* Accent — interactive blue (sliders, active chips, start button). */
  --accent-rgb: 140, 190, 255;
  --accent: rgba(var(--accent-rgb), 0.9);

  /* Text. */
  --fg-rgb: 235, 240, 255;
  --fg: rgba(var(--fg-rgb), 0.9);
  --fg-dim: rgba(var(--fg-rgb), 0.5);

  /* Highlight — white overlays for borders and subtle fills. */
  --hi-rgb: 255, 255, 255;
  --panel-border: rgba(var(--hi-rgb), 0.08);

  /* Title — the "Aeon" heading gradient. */
  --grad-1: #9cc4ff;
  --grad-2: #c9a8ff;
  --grad-3: #8ce0d0;
}

* { box-sizing: border-box; }

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

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

/* ---- Controls panel ---- */
#panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 280px;
  padding: 24px 20px;
  overflow-y: auto;
  background: var(--panel-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-left: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 22px;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.5s;
  transform: translateX(0);
  opacity: 1;
}
body.panel-hidden #panel {
  transform: translateX(110%);
  opacity: 0;
  pointer-events: none;
}

.group { display: flex; flex-direction: column; gap: 10px; }
.group-title {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.slider-row { display: flex; flex-direction: column; gap: 6px; }
.slider-row span {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 3px;
  background: rgba(var(--hi-rgb), 0.14);
  outline: none;
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.6);
}
input[type='range']::-moz-range-thumb {
  width: 16px; height: 16px; border: none; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.layer-row > span:first-child {
  flex: 1;
  letter-spacing: 0.06em;
  color: var(--fg);
  text-transform: capitalize;
}

.chip {
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(var(--hi-rgb), 0.04);
  color: var(--fg-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.chip:hover { color: var(--fg); border-color: rgba(var(--hi-rgb), 0.25); }
.chip.on {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}
.chip.wide { width: 100%; padding: 8px; }

.panel-hint {
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
  opacity: 0.6;
}
.panel-hint kbd { font-family: inherit; }

.select, .seed-input {
  font: inherit;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(var(--hi-rgb), 0.04);
  color: var(--fg);
}
.seed-input { flex: 1; min-width: 0; }

/* The <select> sets a near-transparent background that reads as dark over the
   panel — but Chrome on Windows paints the open option list on that same color,
   which lands on white. Give the options a solid dark background so the list is
   readable. (macOS renders the popup dark on its own; this just matches it.) */
.select option {
  background: var(--surface);
  color: var(--fg);
}

/* ---- Start overlay ---- */
#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, var(--bg-2) 0%, var(--bg) 70%);
  z-index: 10;
  transition: opacity 1.2s ease;
  text-align: center;
  padding: 24px;
}
#overlay.gone { opacity: 0; pointer-events: none; }
.overlay-inner { max-width: 460px; }
.overlay-inner h1 {
  font-weight: 300;
  font-size: 64px;
  letter-spacing: 0.3em;
  margin: 0 0 18px;
  padding-left: 0.3em;
  background: linear-gradient(120deg, var(--grad-1), var(--grad-2), var(--grad-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.overlay-inner p {
  color: var(--fg-dim);
  line-height: 1.7;
  font-size: 14px;
  margin: 0 0 30px;
}
.begin {
  font: inherit;
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 14px 34px;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--fg);
  cursor: pointer;
  transition: all 0.3s;
}
.begin:hover {
  background: rgba(var(--accent-rgb), 0.18);
  border-color: var(--accent);
  box-shadow: 0 0 30px rgba(var(--accent-rgb), 0.25);
}
.overlay-inner small {
  display: block;
  margin-top: 26px;
  color: rgba(var(--fg-rgb), 0.3);
  font-size: 11px;
  letter-spacing: 0.08em;
}

/* ---- Panel toggle (always-visible tap target; mirrors the H key) ---- */
#panel-toggle {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 11; /* above the panel (which can cover the full width on mobile) */
  width: 44px;
  height: 44px;
  font-size: 20px;
  line-height: 1;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  color: var(--fg);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
#panel-toggle:hover { color: rgb(var(--hi-rgb)); border-color: rgba(var(--hi-rgb), 0.25); }

@media (max-width: 560px) {
  /* Keep a strip of canvas visible beside the panel; the toggle hides it fully. */
  #panel { width: min(300px, 82vw); }
  .overlay-inner h1 { font-size: 44px; }
}
