* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #03040c;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #dfe4f5;
}

canvas#bg, canvas#view {
  position: fixed;
  inset: 0;
  display: block;
}
canvas#view { z-index: 1; touch-action: none; cursor: crosshair; }

#vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 55%, rgba(2, 3, 10, 0.55) 100%);
}

/* ---------------- floating control panel ---------------- */
#panel {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 312px;
  max-width: calc(100vw - 32px);
  background: rgba(9, 12, 26, 0.72);
  backdrop-filter: blur(16px) saturate(1.35);
  -webkit-backdrop-filter: blur(16px) saturate(1.35);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 16px;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  user-select: none;
}
#panel.hidden { display: none; }

#panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: grab;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
#panel-head:active { cursor: grabbing; }

#panel-title {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #ffd166, #ff5f7a, #7a5cff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

#stats {
  margin-left: auto;
  font-size: 11px;
  color: #8b93b8;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#btn-collapse {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: #cfd5ee;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
#btn-collapse:hover { background: rgba(255, 255, 255, 0.18); }

#panel-body {
  padding: 13px 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent;
}
#panel-body::-webkit-scrollbar { width: 8px; }
#panel-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }
#panel.min #panel-body { display: none; }
#panel.min #panel-head { border-bottom: none; }

.row { display: flex; flex-direction: column; gap: 7px; }
.row > label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: #9aa3c7;
}

select {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  color: #eef0ff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
select:hover { border-color: rgba(255, 255, 255, 0.32); }
select option { background: #10142a; }

/* sliders */
#controls { display: flex; flex-direction: column; gap: 9px; }
.srow { display: flex; flex-direction: column; gap: 3px; }
.shead { display: flex; justify-content: space-between; align-items: baseline; }
.shead span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #9aa3c7;
}
.shead b {
  color: #ffd166;
  font-weight: 600;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(255, 209, 102, 0.95), rgba(255, 95, 122, 0.95));
  opacity: 0.5;
}
input[type="range"]:hover::-webkit-slider-runnable-track { opacity: 1; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  margin-top: -5px;
  border: none;
  box-shadow: 0 0 9px rgba(255, 170, 80, 0.95);
  transition: transform 0.1s;
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.25); }
input[type="range"]::-moz-range-track {
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(255, 209, 102, 0.9), rgba(255, 95, 122, 0.9));
  opacity: 0.6;
}
input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 0 9px rgba(255, 170, 80, 0.95);
}

/* chips (palette + presets) */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #cfd5ee;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s, box-shadow 0.12s;
}
.chip:hover { background: rgba(255, 255, 255, 0.14); transform: translateY(-1px); }
.chip.pal { width: 27px; height: 27px; padding: 0; border-radius: 50%; }
.chip.on {
  border-color: #ffd166;
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.55);
  transform: scale(1.08);
}

/* toggles */
.togs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tog {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: #c6cde8;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 10px;
  border-radius: 10px;
  transition: background 0.15s;
}
.tog:hover { background: rgba(255, 255, 255, 0.11); }
.tog input { accent-color: #ff5f7a; width: 15px; height: 15px; cursor: pointer; flex: none; }

/* action buttons */
.btns { display: flex; gap: 9px; }
.btns button {
  flex: 1;
  padding: 9px 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  color: #eef0ff;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.btns button:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.35);
}
#btn-random {
  background: linear-gradient(135deg, rgba(255, 95, 122, 0.38), rgba(122, 92, 255, 0.38));
}

.sect {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #6f78a0;
}

/* bottom hint */
#hint {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 11.5px;
  letter-spacing: 0.4px;
  color: rgba(200, 210, 240, 0.5);
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
}
#hint b { color: rgba(255, 209, 102, 0.8); font-weight: 600; }
