*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, sans-serif;
}
canvas {
  display: block;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#panel {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 230px;
  background: rgba(8, 8, 18, 0.78);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 18px;
  padding: 20px 18px 16px;
  color: #fff;
  z-index: 200;
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition:
    opacity 0.35s ease,
    transform 0.35s ease;
  max-height: calc(100vh - 44px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}
#panel::-webkit-scrollbar {
  width: 3px;
}
#panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
}
#panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
}
#panel h2 {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  text-align: center;
  margin-bottom: 18px;
}

.group {
  margin-bottom: 13px;
}
.group label {
  display: block;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 6px;
}
.group select {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 7px 10px;
  border-radius: 9px;
  cursor: pointer;
  outline: none;
  font-size: 12px;
  appearance: none;
}
.group select option {
  background: #111;
}

input[type="range"] {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 3px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
  cursor: pointer;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.range-val {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  min-width: 32px;
  text-align: right;
}

.color-row {
  display: flex;
  gap: 8px;
}
.color-wrap {
  flex: 1;
}
.color-label {
  display: block;
  text-align: center;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.28);
  letter-spacing: 1px;
  margin-top: 4px;
}
.color-wrap input[type="color"] {
  width: 100%;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  padding: 2px 3px;
}

.btn {
  display: block;
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 8px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  transition: background 0.18s;
  outline: none;
  margin-bottom: 6px;
}
.btn:hover {
  background: rgba(255, 255, 255, 0.14);
}
#startBtn {
  background: linear-gradient(
    135deg,
    rgba(80, 80, 255, 0.35),
    rgba(180, 60, 255, 0.35)
  );
  border-color: rgba(140, 80, 255, 0.45);
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 14px;
}
#startBtn.active {
  background: linear-gradient(
    135deg,
    rgba(255, 60, 60, 0.35),
    rgba(255, 130, 50, 0.35)
  );
  border-color: rgba(255, 80, 60, 0.45);
}

.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.07);
  margin: 14px 0;
}

/* Collapsible sections */
details {
  margin-bottom: 2px;
}
summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  padding: 10px 2px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}
summary::-webkit-details-marker {
  display: none;
}
summary:hover {
  color: rgba(255, 255, 255, 0.55);
}
summary::after {
  content: "›";
  margin-left: auto;
  font-size: 14px;
  display: inline-block;
  transition: transform 0.2s;
  opacity: 0.5;
}
details[open] > summary::after {
  transform: rotate(90deg);
}
details .group:first-of-type {
  margin-top: 4px;
}

/* Checkbox */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.check-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  position: relative;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.check-row input[type="checkbox"]:checked {
  background: rgba(140, 80, 255, 0.45);
  border-color: rgba(160, 100, 255, 0.6);
}
.check-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 1px;
  width: 5px;
  height: 8px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}
.check-row span {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.5px;
}

.hint {
  text-align: center;
  color: rgba(255, 255, 255, 0.2);
  font-size: 10px;
  margin-top: 10px;
  line-height: 1.5;
}
.privacy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.15);
  font-size: 9px;
  letter-spacing: 0.5px;
  cursor: default;
  transition: color 0.3s;
  position: relative;
}
.privacy svg {
  width: 9px;
  height: 9px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.privacy:hover {
  color: rgba(255, 255, 255, 0.45);
}
.privacy .tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 8, 18, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 10px;
  width: 190px;
  font-size: 10px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.55);
  text-align: left;
  pointer-events: none;
  white-space: normal;
  letter-spacing: 0;
  z-index: 999;
}
.privacy:hover .tip {
  display: block;
}

#toggleBtn {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 300;
  width: 40px;
  height: 40px;
  background: rgba(8, 8, 18, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    border-color 0.2s,
    opacity 0.35s ease;
  outline: none;
  padding: 0;
}
#toggleBtn svg {
  width: 18px;
  height: 18px;
  stroke: rgba(255, 255, 255, 0.45);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  transition: stroke 0.2s;
}
#toggleBtn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
}
#toggleBtn:hover svg {
  stroke: #fff;
}
#toggleBtn.panel-hidden svg {
  stroke: rgba(255, 255, 255, 0.6);
}
#toggleBtn.hidden-ui {
  opacity: 0;
  pointer-events: none;
}
#home-link.hidden-ui {
  opacity: 0;
  pointer-events: none;
}

#statusDot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  margin-right: 6px;
  vertical-align: middle;
  position: relative;
  top: -1px;
  transition: background 0.3s;
}
#statusDot.active {
  background: #4f4;
  box-shadow: 0 0 6px #4f4;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}
#home-link {
  position: fixed;
  top: 1rem;
  left: 1.2rem;
  font-family: "Space Mono", "Courier New", monospace;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.2);
  text-decoration: none;
  transition: color 0.2s;
  z-index: 100;
}
#home-link:hover {
  color: rgba(255, 255, 255, 0.7);
}
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 1001;
  padding: 0.5rem 1rem;
  background: rgba(80, 80, 255, 0.9);
  color: #fff;
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
  text-decoration: none;
}
.skip-link:focus {
  top: 0;
}
:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  #statusDot.active {
    animation: none;
  }
  * {
    transition-duration: 0.01ms !important;
  }
}
