html, body {
  height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(1200px 800px at 30% 30%, #0b1220 0%, #060a14 60%, #04060d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e6edf3;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

#canvas {
  width: min(90vmin, 800px);
  height: min(90vmin, 800px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.00));
}

/* Controls panel */
#controls.panel {
  position: fixed;
  top: 30px;
  left: 15px;
  width: min(360px, 82vw);
  max-height: 92vh;
  overflow: auto;
  backdrop-filter: blur(8px);
  background: rgba(10, 14, 25, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}

#controls-right.panel {
  position: fixed;
  top: 30px;
  right: 15px;
  width: min(360px, 82vw);
  max-height: 92vh;
  overflow: auto;
  backdrop-filter: blur(8px);
  background: rgba(10, 14, 25, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}

.group { 
  margin-bottom: 14px; 
  padding-bottom: 10px; 
  border-bottom: 1px dashed rgba(255,255,255,0.08);
}
.group:last-child { border-bottom: none; margin-bottom: 8px; }
.title { font-weight: 600; margin-bottom: 8px; font-size: 15px; color: #c7d7ea; }

label { 
  display: grid; 
  grid-template-columns: 1fr auto; 
  gap: 10px 12px; 
  align-items: center; 
  font-size: 14px;
  margin: 8px 0; 
}

label input[type="range"] { grid-column: 1 / -1; }
label select { grid-column: 1 / -1; }

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(90deg, rgba(125,170,255,0.5), rgba(255,255,255,0.1));
  border-radius: 999px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #aee0ff;
  border: 1px solid rgba(255,255,255,0.4);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #aee0ff;
  border: none;
}

.row { display: flex; gap: 8px; justify-content: flex-end; }
button {
  background: #27496d;
  color: #e6edf3;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}
button:hover { background: #305a86; }

/* Toggle checkbox row (override label grid) */
label.toggle {
  display: flex;
  gap: 10px;
  align-items: center;
  grid-template-columns: none;
}
label.toggle input[type="checkbox"] {
  width: 18px; height: 18px; cursor: pointer;
}

select {
  appearance: none;
  background: rgba(18,26,40,0.9);
  color: #e6edf3;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  padding: 8px 10px;
}
select:focus { outline: none; border-color: #5da3ff; box-shadow: 0 0 0 2px rgba(93,163,255,0.25); }
select option { background-color: #0f1726; color: #e6edf3; }
select option:checked { background-color: #1f4fff; color: #ffffff; }
select option:hover { background-color: #16325f; color: #ffffff; }

@media (max-width: 900px) {
  #controls.panel, #controls-right.panel {
    width: 92vw;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }
  #controls.panel { top: 12px; bottom: auto; }
  #controls-right.panel { top: auto; bottom: 12px; }
}
