:root {
  --glass-bg:     rgba(255, 255, 255, 0.62);
  --glass-border: rgba(255, 255, 255, 0.85);
  --shadow:       0 8px 32px rgba(80, 40, 120, 0.12), 0 2px 8px rgba(80, 40, 120, 0.07);
  --accent:       #7c3aed;
  --accent-light: rgba(124, 58, 237, 0.15);
  --text:         #2d1f4e;
  --text-dim:     #8b7aa8;
  --radius-lg:    20px;
  --radius-md:    12px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
  background: linear-gradient(145deg, #f0ecff 0%, #fce8f6 45%, #e8f0ff 100%);
}

/*Full canvas*/
#canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

h1 {
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.025em;
  text-shadow: 0 1px 4px rgba(255,255,255,0.8);
  line-height: 1.15;
}

.subtitle {
  font-size: clamp(0.58rem, 1.1vw, 0.72rem);
  color: var(--text-dim);
  margin-top: 0.15rem;
}

/* Glass*/
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1.5px solid var(--glass-border);
  box-shadow: var(--shadow);
}

/*Controls overlay */
.controls {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1.25rem 0.7rem;
  z-index: 20;
  width: min(96vw, 760px);
}

.controls-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.55rem;
}

.controls-title {
  flex: 1;
  min-width: 0;
}


.sliders {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.ctrl-item {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  flex: 1;
  min-width: 130px;
}

.ctrl-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ctrl-item label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-dim);
  white-space: nowrap;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(124, 58, 237, 0.18);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

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 0 3px rgba(124,58,237,0.2), 0 2px 6px rgba(124,58,237,0.35);
  transition: box-shadow .15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 5px rgba(124,58,237,0.2), 0 2px 8px rgba(124,58,237,0.45);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.val {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 34px;
  text-align: right;
}

.ctrl-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ctrl-footer button {
  padding: 0.38rem 0.95rem;
  border: 1.5px solid rgba(124,58,237,0.25);
  background: rgba(124,58,237,0.07);
  color: var(--accent);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  transition: all .18s;
  white-space: nowrap;
}

.ctrl-footer button:hover {
  background: var(--accent-light);
  border-color: rgba(124,58,237,0.5);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124,58,237,0.2);
}

.ctrl-footer button.paused {
  background: var(--accent-light);
  border-color: var(--accent);
}

.ball-count {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
  padding-top: 0.15rem;
}

.ball-count span {
  color: var(--accent);
  font-size: 0.88rem;
}

.hint-remove {
  font-size: 0.65rem;
  color: var(--text-dim);
  opacity: 0.7;
  white-space: nowrap;
}


@media (max-width: 520px) {
  .controls { padding: 0.6rem 0.8rem 0.55rem; top: 0.5rem; }
  .ctrl-item { min-width: 110px; }
  .subtitle { display: none; }
  h1 { font-size: 0.9rem; }
}
