html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}
body {
  min-height: 100vh;
  width: 100vw;
  background: #509ee3;
  transition: background 1s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
#attribution {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #666;
  opacity: 0.3;
  pointer-events: none;
  user-select: none;
}

#color-ribbon {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: rgba(255,255,255,0.95);
  border-radius: 24px;
  box-shadow: 0 2px 24px 0 rgba(0,0,0,0.11);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  z-index: 20;
  max-width: calc(100vw - 16px);
}

.toggle-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}
.toggle-label {
  font-size: 1rem;
  color: #333;
  user-select: none;
}

/* Toggle Switch CSS */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.switch input { display: none; }
.slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  border-radius: 34px;
  transition: .2s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 16px; width: 16px;
  left: 2px; bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: .2s;
}
input:checked + .slider { background-color: #56d176; }
input:checked + .slider:before { transform: translateX(16px); }

.picker-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

#color-picker, #cycle-color-picker {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 0 4px 0 #ccc;
}
#add-color {
  background: #eee;
  border: none;
  font-size: 1.2rem;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: 0 0 4px 0 #ccc;
  transition: background .2s;
}
#add-color:disabled {
  background: #ddd;
  color: #bbb;
  cursor: default;
}

#palette {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}
.palette-color {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #aaa;
  cursor: pointer;
  position: relative;
  box-sizing: border-box;
  transition: border-color .2s, box-shadow .2s, transform .2s;
  margin-right: 2px;
}
.palette-color.active {
  border-color: #000;
  box-shadow: 0 0 0 3px #8882;
  transform: scale(1.11);
  z-index: 1;
}
.palette-color .remove {
  position: absolute;
  top: -7px;
  right: -7px;
  background: #fff;
  color: #e53935;
  border: none;
  font-size: 0.8rem;
  border-radius: 50%;
  padding: 0 3px;
  cursor: pointer;
  box-shadow: 0 0 4px 0 #aaa;
  line-height: 1;
  z-index: 2;
}

#controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin-left: 8px;
  margin-top: 2px;
}
#speed-range {
  width: 70px;
}
#speed-label {
  font-size: 12px;
  color: #888;
  margin-bottom: -6px;
}

/* Mobile: ribbon is full width bottom */
@media (max-width: 600px) {
  #color-ribbon {
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 18px 18px 0 0;
    padding: 10px 6px;
    max-width: 100vw;
    justify-content: center;
    gap: 10px;
  }
}
