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

/* Prevent text selection during drag operations */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Prevent default drag behavior */
* {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
}

/* Allow text selection in specific elements if needed */
input,
textarea,
.sphere-popup,
.star-popup {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #32483a 0%, #3f5d4d 100%);
  min-height: 100vh;
  color: #333;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  overflow-x: auto;
}

header {
  text-align: center;
  margin-bottom: 30px;
  color: white;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
  font-size: 1.1rem;
  opacity: 0.9;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* Top Controls Bar */
.top-controls-bar {
  width: 100%;
  max-width: 1220px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Scene Gallery Styles */
.scene-gallery {
  flex: 1;
  display: flex;
  justify-content: flex-start;
  overflow-x: auto; /* enable horizontal scroll when needed */
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch; /* smooth scroll on iOS */
  /* Minimal scrollbar (Firefox) */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

/* Minimal scrollbar (WebKit) */
.scene-gallery::-webkit-scrollbar {
  height: 4px;
}
.scene-gallery::-webkit-scrollbar-track {
  background: transparent;
}
.scene-gallery::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 4px;
}
.scene-gallery:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.35);
}

.scene-thumbnails {
  display: flex;
  gap: 12px;
  justify-content: flex-start; /* align items from the start for scroll */
  flex-wrap: nowrap; /* keep on a single row */
  flex: 0 0 auto; /* prevent shrinking inside gallery */
}

.scene-thumbnail {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  flex: 0 0 auto; /* do not shrink; keep natural width for horizontal scroll */
}

.scene-thumbnail:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.2);
}

.scene-thumbnail.active {
  border-color: #4caf50;
  background: rgba(76, 175, 80, 0.15);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

/* Custom scene highlight */
.scene-thumbnail.custom {
  border-color: #c62828;
  background: rgba(198, 40, 40, 0.15);
  box-shadow: 0 2px 8px rgba(198, 40, 40, 0.3);
}

/* Light Object Selector */
.light-object-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 20px;
}

.selector-label {
  color: white;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

.object-buttons {
  display: flex;
  gap: 8px;
}

.object-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 80px;
}

.object-btn:hover {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.object-btn.active {
  border-color: #4caf50;
  background: rgba(76, 175, 80, 0.2);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.object-icon {
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.object-name {
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
}

.scene-thumbnail img {
  border-radius: 4px;
  object-fit: cover;
  margin-bottom: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 100px;
  height: 67px;
}

.scene-name {
  font-size: 0.7rem;
  color: #fff;
  text-align: center;
  font-weight: 400;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.image-container {
  position: relative;
  display: inline-block;
  border-radius: 15px;
  overflow: visible;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  background: white;
  padding: 10px;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  max-width: 1220px; /* 1200px + 20px padding */
  max-height: 820px; /* 800px + 20px padding */
  width: 100%;
  height: auto;
  transition: all 0.3s ease;
}

.image-container.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border-radius: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.95);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-width: 100vw;
  min-height: 100vh;
}

.image-container.fullscreen .tree-image {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  min-width: 100vw !important;
  min-height: 100vh !important;
  object-fit: contain !important;
  flex-shrink: 0 !important;
  display: block !important;
  position: relative !important;
  margin: 0 !important;
  padding: 0 !important;
}

.tree-image {
  width: 100%;
  height: auto;
  aspect-ratio: 3/2;
  object-fit: contain;
  cursor: crosshair;
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  display: block;
  max-width: 100%;
  max-height: 100%;
}

/* Fullscreen UI removed */

.spheres-container,
.stars-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.star-container {
  position: absolute;
  width: 36px; /* Default size, will be overridden by JavaScript calibration */
  height: 45px; /* Default size with correct aspect ratio (1133.86/907.09 ≈ 1.25) */
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 10;
  overflow: visible; /* Allow star to extend beyond container bounds */
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
}

.star-container:hover {
  transform: translate(-50%, -50%) scale(1.1);
  z-index: 20;
}

.star-container.dragging {
  z-index: 30;
  transform: translate(-50%, -50%) scale(1.05);
  opacity: 0.9;
  cursor: grabbing;
}

.sphere {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 255, 255, 0.9) 40%,
    rgba(255, 255, 255, 0.7) 70%,
    rgba(255, 255, 255, 0.5) 100%
  );
  transform: translate(-50%, -50%);
  pointer-events: auto;
  z-index: 10;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.sphere:hover {
  transform: translate(-50%, -50%) scale(1.2);
}

.sphere.dragging {
  transform: translate(-50%, -50%) scale(1.3);
}

.sphere.pulsing {
  animation: pulse 8s linear infinite;
}

/* Cosine-like brightness curve approximated with keyframes (0.4..1.0) */
@keyframes pulse {
  0% {
    opacity: 1;
    filter: brightness(1);
  }
  12.5% {
    opacity: 1;
    filter: brightness(0.912);
  }
  25% {
    opacity: 1;
    filter: brightness(0.7);
  }
  37.5% {
    opacity: 1;
    filter: brightness(0.488);
  }
  50% {
    opacity: 1;
    filter: brightness(0.4);
  }
  62.5% {
    opacity: 1;
    filter: brightness(0.488);
  }
  75% {
    opacity: 1;
    filter: brightness(0.7);
  }
  87.5% {
    opacity: 1;
    filter: brightness(0.912);
  }
  100% {
    opacity: 1;
    filter: brightness(1);
  }
}

.controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 15px;
  background: rgba(255, 255, 255, 0.1);
  padding: 15px 20px;
  border-radius: 10px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  background: linear-gradient(45deg, #2e7d32, #4caf50);
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  min-width: 44px;
  justify-content: center;
}

.btn-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.btn-text {
  display: none;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  background: linear-gradient(45deg, #4caf50, #2e7d32);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  background: linear-gradient(45deg, #4caf50, #2e7d32);
}

.btn:active {
  transform: translateY(0);
}

/* Tooltip styles */
.btn[data-tooltip] {
  position: relative;
}

.btn[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
  z-index: 1000;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn[data-tooltip]:hover::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
  margin-bottom: 3px;
  z-index: 1000;
}

.btn-secondary {
  background: linear-gradient(45deg, #2e7d32, #4caf50);
}

.btn-secondary:hover {
  background: linear-gradient(45deg, #4caf50, #2e7d32);
}

.btn-primary {
  background: linear-gradient(45deg, #2e7d32, #1b5e20);
}

.btn-primary:hover {
  background: linear-gradient(45deg, #1b5e20, #2e7d32);
}

.btn-success {
  background: linear-gradient(45deg, #2e7d32, #43a047);
}

.btn-success:hover {
  background: linear-gradient(45deg, #43a047, #2e7d32);
}

.btn-info {
  background: linear-gradient(45deg, #388e3c, #66bb6a);
  color: white;
}

.btn-info:hover {
  background: linear-gradient(45deg, #2e7d32, #43a047);
  transform: translateY(-2px);
}

/* Calibration line styles */
.calibration-line {
  position: absolute;
  background: #ff6b6b;
  height: 3px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 10000;
  box-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

.calibration-point {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #ff6b6b;
  border: 2px solid white;
  border-radius: 50%;
  pointer-events: none;
  z-index: 10000;
  box-shadow: 0 0 10px rgba(255, 107, 107, 0.8);
}

/* Calibration info box */
.calibration-info {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.95);
  color: white;
  padding: 20px 30px;
  border-radius: 15px;
  border: 2px solid #ff6b6b;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 10000;
  text-align: center;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  max-width: 350px;
  backdrop-filter: blur(10px);
  cursor: move;
  user-select: none;
}

.calibration-info .drag-handle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: rgba(255, 107, 107, 0.3);
  border-radius: 13px 13px 0 0;
  cursor: move;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  color: #ff6b6b;
  border-bottom: 1px solid rgba(255, 107, 107, 0.5);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  touch-action: none;
}

.calibration-info .content {
  margin-top: 30px;
}

/* Live calibration line */
.calibration-line-live {
  position: absolute;
  background: #ff6b6b;
  height: 4px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 10000;
  box-shadow: 0 0 15px rgba(255, 107, 107, 0.9);
  opacity: 1;
  width: 0;
  left: 0;
  top: 0;
}

.calibration-info h3 {
  margin: 0 0 15px 0;
  color: #ff6b6b;
  font-size: 18px;
}

.calibration-info p {
  margin: 0 0 15px 0;
  font-size: 14px;
  line-height: 1.4;
}

.calibration-info .step {
  background: rgba(255, 107, 107, 0.2);
  padding: 10px;
  border-radius: 8px;
  margin: 10px 0;
  border-left: 3px solid #ff6b6b;
}

.calibration-info .buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

.calibration-info button {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
}

.calibration-info .btn-cancel {
  background: #6c757d;
  color: white;
}

.calibration-info .btn-cancel:hover {
  background: #5a6268;
}

.calibration-info .btn-confirm {
  background: #ff6b6b;
  color: white;
}

.calibration-info .btn-confirm:hover {
  background: #ff5252;
}

/* Stile per il pulsante Mostra Ritardi (ID-specific per mantenere stato attivo/inattivo) */
#delay-tooltip-toggle {
  background: linear-gradient(
    45deg,
    #2e7d32,
    #66bb6a
  ) !important; /* stesso stile btn-info */
  color: white !important;
}

#delay-tooltip-toggle:hover {
  background: linear-gradient(45deg, #2e7d32, #43a047) !important;
}

#delay-tooltip-toggle.active {
  background: #90ee90 !important; /* Verde chiaro quando attivo */
  border-color: #90ee90 !important;
  box-shadow: 0 0 15px rgba(144, 238, 144, 0.5) !important;
  color: #2c3e50 !important; /* Testo scuro per contrasto */
  font-weight: 600 !important;
}

#delay-tooltip-toggle.active:hover {
  background: #98fb98 !important; /* Verde chiaro più brillante */
  box-shadow: 0 0 20px rgba(144, 238, 144, 0.7) !important;
}

/* Delay tooltip styles */
.delay-tooltip {
  position: fixed;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.delay-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
}

.delay-tooltip .delay-icon img {
  display: block;
}

/* Bottom Controls Layout */
.bottom-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 20px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Main Switch Container */
.main-switch-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.main-switch {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    #32483a 0%,
    #3f5d4d 100%
  ); /* Match page background */
  border: 2px solid #4caf50;
  /* Outer glow only */
  box-shadow: 0 0 0 0 rgba(0, 0, 0, 0), 0 0 22px 6px rgba(76, 175, 80, 0.45);
  animation: subtle-pulse 2s ease-in-out infinite;
}

.main-switch:hover {
  background: linear-gradient(135deg, #32483a 0%, #3f5d4d 100%);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.05);
}

/* Power Button SVG Styles */
.power-on {
  fill: #75fb4c; /* Verde chiaro di default (attivo) */
  transition: all 0.3s ease;
  /* Remove inner SVG glow; outer glow stays on container via box-shadow */
  filter: none;
}

.main-switch:not(.active) .power-on {
  fill: #666666; /* Grigio quando inattivo */
  filter: none;
}

.main-switch:not(.active) {
  background: linear-gradient(135deg, #32483a 0%, #3f5d4d 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 20px rgba(255, 165, 0, 0.5);
  animation: orange-pulse 2s ease-in-out infinite;
}

@keyframes subtle-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0), 0 0 22px 6px rgba(76, 175, 80, 0.55);
  }
  50% {
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0), 0 0 32px 10px rgba(76, 175, 80, 0.75);
  }
}

@keyframes orange-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0), 0 0 22px 6px rgba(255, 165, 0, 0.55);
  }
  50% {
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0), 0 0 32px 10px rgba(255, 165, 0, 0.75);
  }
}

.main-switch:not(.active):hover .power-on {
  filter: none;
}

.main-switch:hover .power-on {
  filter: none;
}

/* Popup Styles */
.sphere-popup,
.star-popup {
  position: fixed;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 15px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 1000;
  min-width: 200px;
  pointer-events: auto;
  /* Use fixed positioning for body-level popup */
}

.sphere-popup.popup-above {
  transform: translate(-50%, -100%);
  margin-top: -5px;
}

.sphere-popup.popup-above::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid rgba(255, 255, 255, 0.95);
}

.sphere-popup.popup-below {
  transform: translate(-50%, 0);
  margin-top: 5px;
}

.sphere-popup.popup-below::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid rgba(255, 255, 255, 0.95);
}

.popup-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #333;
  text-align: center;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.color-option {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.color-option:hover {
  transform: scale(1.1);
  border-color: #333;
}

.color-option.selected {
  border-color: #333;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

/* Special transition option */
.color-option.transition-option {
  background: linear-gradient(
    90deg,
    #ff0000,
    #ff4000,
    #ff8000,
    #ffbf00,
    #ffff00,
    #bfff00,
    #80ff00,
    #40ff00,
    #00ff00,
    #00ff40,
    #00ff80,
    #00ffbf,
    #00ffff,
    #00bfff,
    #0080ff,
    #0040ff,
    #0000ff,
    #4000ff,
    #8000ff,
    #bf00ff,
    #ff00ff,
    #ff00bf,
    #ff0080,
    #ff0040,
    #ff0000
  );
  background-size: 400% 100%;
  animation: gradientFlow 20s linear infinite;
  position: relative;
  overflow: hidden;
}

.color-option.transition-option::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='48px' viewBox='0 -960 960 960' width='48px'%3E%3Cpath d='m482-200 114-113-114-113-42 42 43 43q-28 1-54.5-9T381-381q-20-20-30.5-46T340-479q0-17 4.5-34t12.5-33l-44-44q-17 25-25 53t-8 57q0 38 15 75t44 66q29 29 65 43.5t74 15.5l-38 38 42 42Zm165-170q17-25 25-53t8-57q0-38-14.5-75.5T622-622q-29-29-65.5-43T482-679l38-39-42-42-114 113 114 113 42-42-44-44q27 0 55 10.5t48 30.5q20 20 30.5 46t10.5 52q0 17-4.5 34T603-414l44 44ZM480-80q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-83 31.5-156t86-127Q252-817 325-848.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82-31.5 155T763-197.5q-54 54.5-127 86T480-80Zm0-60q142 0 241-99.5T820-480q0-142-99-241t-241-99q-141 0-240.5 99T140-480q0 141 99.5 240.5T480-140Zm0-340Z' fill='%23ffffff'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transform: translate(-50%, -50%);
  z-index: 2;
  animation: rotate 4s linear infinite;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.8))
    drop-shadow(0 0 4px rgba(0, 0, 0, 0.6));
}

@keyframes gradientFlow {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 400% 50%;
  }
}

@keyframes rotate {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.pulse-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pulse-toggle label {
  font-size: 13px;
  color: #333;
  font-weight: 500;
}

.delay-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.delay-toggle label {
  font-size: 13px;
  color: #333;
  font-weight: 500;
}

.random-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 0;
  padding: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.random-toggle label {
  font-size: 13px;
  color: #333;
  font-weight: 500;
}

.random-switch {
  background: #4caf50 !important;
  border-color: #4caf50 !important;
}

.random-switch.active::after {
  transform: translateX(20px) !important;
}

.transition-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 0;
  padding: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.transition-toggle label {
  font-size: 13px;
  color: #333;
  font-weight: 500;
}

.transition-switch {
  background: #9c27b0 !important;
  border-color: #9c27b0 !important;
}

.transition-switch.active::after {
  transform: translateX(20px) !important;
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 20px;
  background: #ccc;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.toggle-switch.active {
  background: #4caf50;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.toggle-switch.active::after {
  transform: translateX(20px);
}

.popup-buttons {
  display: flex;
  gap: 8px;
}

.popup-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.popup-btn.confirm {
  background: #cc4d00;
  color: #fff;
}
.popup-btn.confirm:hover {
  background: #b54500;
}

.popup-btn.cancel {
  background: transparent;
  color: #333;
  border: 2px solid #bbb;
  border-radius: 6px;
}
.popup-btn.cancel:hover {
  border-color: #888;
  background: rgba(0, 0, 0, 0.04);
}

.popup-btn.delete {
  background: #f44336;
  color: white;
}
.popup-btn.delete:hover {
  background: #da190b;
}

/* Delay Selection Styles */
.delay-selection {
  margin-bottom: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.delay-selection label {
  font-size: 13px;
  color: #333;
  font-weight: 500;
  display: block;
  margin-bottom: 8px;
}

.delay-options {
  display: flex;
  gap: 6px;
  justify-content: space-between;
}

.delay-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(0, 0, 0, 0.05);
}

.delay-option:hover {
  background: rgba(0, 0, 0, 0.1);
  border-color: #ddd;
}

.delay-option.selected {
  border-color: #4caf50;
  background: rgba(76, 175, 80, 0.1);
  transform: scale(1.05);
}

/* Removed checkmark - only border selection remains */

.delay-option.random-selected {
  border-color: #ff9800;
  background: rgba(255, 152, 0, 0.1);
  position: relative;
}

.delay-option.random-selected::after {
  content: "🎲";
  position: absolute;
  top: -5px;
  right: -5px;
  font-size: 10px;
  background: #ff9800;
  border-radius: 50%;
  width: 15px;
  height: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delay-option.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.delay-option.disabled:hover {
  transform: none;
  background: rgba(0, 0, 0, 0.05);
  border-color: transparent;
}

.delay-letter {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin-bottom: 2px;
}

.delay-label {
  font-size: 10px;
  color: #666;
  text-align: center;
}

/* Predefined Layouts Popup Styles */
.predefined-layouts-popup {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(15px);
  border: 2px solid rgba(76, 175, 80, 0.3);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

.layouts-list {
  max-height: 300px;
  overflow-y: auto;
  margin: 15px 0;
}

.layout-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  margin: 8px 0;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(76, 175, 80, 0.05);
}

.layout-option:hover {
  background: rgba(76, 175, 80, 0.1);
  border-color: rgba(76, 175, 80, 0.3);
  transform: translateX(5px);
}

.layout-name {
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.layout-info {
  color: #666;
  font-size: 12px;
  background: rgba(76, 175, 80, 0.1);
  padding: 4px 8px;
  border-radius: 12px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  header h1 {
    font-size: 2rem;
  }

  header p {
    font-size: 1rem;
  }

  .top-controls-bar {
    flex-direction: column;
    gap: 15px;
    padding: 15px;
  }

  .scene-gallery {
    margin-bottom: 0;
    justify-content: center;
  }

  .light-object-selector {
    margin-left: 0;
    justify-content: center;
  }

  .scene-thumbnails {
    gap: 8px;
  }

  .scene-thumbnail {
    padding: 6px;
  }

  .scene-name {
    font-size: 0.65rem;
  }

  .image-container {
    padding: 5px;
    max-width: 100%;
    max-height: 100%;
  }

  .info-display {
    flex-wrap: wrap;
    gap: 5px;
  }

  .info-display > div {
    flex: 1 1 calc(50% - 5px);
    min-width: 120px;
  }

  .bottom-controls {
    flex-direction: column;
    gap: 15px;
  }

  .controls {
    padding: 15px;
    flex-direction: row;
    gap: 10px;
    flex-wrap: wrap;
  }

  .btn {
    min-width: 44px;
    padding: 12px;
  }

  .btn-text {
    display: none !important;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 1.8rem;
  }

  .container {
    padding: 10px;
  }

  .top-controls-bar {
    flex-direction: column;
    gap: 10px;
    padding: 10px;
  }

  .light-object-selector {
    margin-left: 0;
    justify-content: center;
  }

  .object-btn {
    min-width: 70px;
    padding: 6px 8px;
  }

  .object-name {
    font-size: 0.7rem;
  }

  .scene-gallery {
    margin-bottom: 8px;
  }

  .scene-thumbnails {
    gap: 6px;
  }

  .scene-thumbnail {
    padding: 4px;
  }

  .scene-thumbnail img {
    width: 60px;
    height: 40px;
  }

  .scene-name {
    font-size: 0.6rem;
    max-width: 60px;
  }

  .image-container {
    max-width: 100%;
    max-height: 100%;
  }

  .info-display {
    flex-direction: column;
    gap: 3px;
    font-size: 0.6rem;
  }

  .info-display > div {
    flex: none;
    text-align: center;
    padding: 2px 0;
  }

  .sphere {
    width: 16px;
    height: 16px;
  }
}

/* When Three.js glow overlay is enabled, remove CSS glow entirely */
.image-container.glow-overlay-enabled .sphere,
.image-container.glow-overlay-enabled .sphere.dragging,
.image-container.glow-overlay-enabled .sphere:hover,
.fullscreen .glow-overlay-enabled .sphere,
.fullscreen .glow-overlay-enabled .sphere.dragging,
.fullscreen .glow-overlay-enabled .sphere:hover {
  box-shadow: none !important;
  filter: none !important;
  background: currentColor !important; /* color is set inline by JS */
}

/* Custom Tooltip Styles */
.custom-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.2s ease;
  max-width: 200px;
  text-align: center;
}

.custom-tooltip::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
}

.custom-tooltip.show {
  opacity: 1;
}

/* Pulse toggle tooltip */
.pulse-toggle {
  position: relative;
}

.pulse-toggle .tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 10px;
  line-height: 1.3;
  white-space: normal;
  z-index: 10000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.2s ease;
  margin-bottom: 8px;
  text-align: center;
  max-width: 180px;
  word-wrap: break-word;
}

.pulse-toggle .tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
}

.pulse-toggle .tooltip.show {
  opacity: 1;
}

/* Informazioni secondarie sotto l'immagine */
.info-display {
  margin-top: 1px;
  padding: 1px 10px;
  width: calc(100% - 20px);
  max-width: 1220px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.65rem;
  color: #adb5bd;
  font-weight: 400;
  line-height: 1.1;
}

.info-display > div {
  flex: 1;
  text-align: center;
  padding: 0 2px;
}

.info-display span {
  color: #adb5bd;
  font-size: 0.65rem;
}

.info-display #sphere-count,
.info-display #calibration-text,
.info-display #current-layout-text,
.info-display #current-scene-text {
  color: #ced4da;
  font-weight: 500;
}

/* Star-specific styles */
.star-color-selection {
  margin-bottom: 15px;
}

.star-color-selection > label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #333;
  margin-bottom: 8px;
}

.star-color-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.star-color-option {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  background: white;
}

.star-color-option:hover {
  border-color: #007bff;
  background: #f8f9fa;
}

.star-color-option.selected {
  border-color: #007bff;
  background: #e3f2fd;
}

.star-color-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.star-color-option .color-preview {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #ddd;
  margin-right: 10px;
  flex-shrink: 0;
}

.star-color-option.selected .color-preview {
  border-color: #007bff;
}

.star-color-option .color-name {
  font-size: 12px;
  font-weight: 500;
  color: #333;
  flex: 1;
}

.star-color-option.selected::after {
  content: "✓";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #007bff;
  font-weight: bold;
  font-size: 14px;
}

/* Star delay options - override existing styles */
.star-popup .delay-option {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border: 2px solid #e0e0e0;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  background: white;
  margin-bottom: 4px;
}

.star-popup .delay-option:hover {
  border-color: #007bff;
  background: #f8f9fa;
}

.star-popup .delay-option.selected {
  border-color: #007bff;
  background: #e3f2fd;
}

.star-popup .delay-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Removed checkmark for stars - only border selection remains */

/* Star popup arrow/tail styles */
.star-popup.popup-above {
  transform: translate(-50%, -100%);
  margin-top: -5px;
}

.star-popup.popup-above::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid rgba(255, 255, 255, 0.95);
}

.star-popup.popup-below {
  transform: translate(-50%, 0);
  margin-top: 5px;
}

.star-popup.popup-below::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid rgba(255, 255, 255, 0.95);
}

/* -----------------------
   Post-scenes compact bar
   ----------------------- */
.post-scenes-bar {
  width: 100%;
  max-width: 1220px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 0;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.compact-object-selector {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.post-scenes-bar .object-buttons {
  display: flex;
  gap: 8px;
}
.post-scenes-bar .object-buttons .object-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  min-width: auto;
}

.post-scenes-bar .object-icon {
  margin-bottom: 0;
  font-size: 1.1rem;
  line-height: 0;
  display: inline-flex;
}
.post-scenes-bar .object-name {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Info ticker */
.info-ticker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #e9f5ec;
  flex: 1 1 auto;
  min-width: 0;
}

.info-icon {
  color: #cdebd5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.info-icon-svg {
  display: block;
}

.ticker-viewport {
  position: relative;
  overflow: hidden;
  height: 2.6em; /* allow up to two lines */
  line-height: 1.3em;
  flex: 1 1 auto;
}

.ticker-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ticker-item {
  color: #e9f5ec;
  font-size: 0.78rem;
  white-space: normal; /* allow wrapping */
  overflow: hidden; /* crop beyond two lines height */
  padding-right: 8px;
}

/* Responsive tweaks for the post-scenes bar */
@media (max-width: 768px) {
  .post-scenes-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .compact-object-selector {
    justify-content: center;
  }
  .ticker-viewport {
    height: 2.8em;
    line-height: 1.35em;
  }
}

@media (max-width: 480px) {
  .post-scenes-bar {
    flex-direction: column;
    gap: 8px;
    padding: 10px;
  }
  .compact-object-selector {
    justify-content: center;
  }
  .ticker-viewport {
    height: 2.8em;
    line-height: 1.35em;
  }
  .post-scenes-bar .object-name {
    font-size: 0.75rem;
  }
}
