html,
body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #07080a;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  /* Riserva 330px a destra così il canvas non finisce mai sotto la dashboard */
  padding-right: 330px;
}

/* Contenitore flessibile: occupa tutto lo spazio a sinistra della dashboard */
.golWrap {
  position: fixed;
  top: 24px;
  left: 24px;
  right: 338px; /* Lascia lo spazio per la dashboard (290px) + i margini */
  bottom: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  box-sizing: border-box;
  background-color: transparent;
}

/* Scala il canvas preservando esattamente le proporzioni (1:1, 9:16 o 16:9) */
.golWrap canvas {
  display: block;
  max-width: 100% !important;
  max-height: 100% !important;
  width: auto !important;
  height: auto !important;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.75);
  border-radius: 8px;
  touch-action: none;
}

/* --- Dashboard Fluttuante --- */
.dashboard {
  position: fixed;
  top: 24px;
  right: 24px;
  bottom: 24px;
  width: 290px;
  height: calc(100vh - 48px);
  box-sizing: border-box;
  background: rgba(18, 20, 29, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 20px 18px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65);
  color: #f1f3f5;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.dashboard-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dashboard-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.badge {
  font-size: 10px;
  background: rgba(76, 175, 80, 0.2);
  color: #4caf50;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #c0c4cc;
}

.value-display {
  font-weight: bold;
  color: #ffffff;
}

/* --- Select Dropdown & Text Input --- */
.styled-select {
  width: 100%;
  padding: 7px 10px;
  font-size: 12px;
  color: #f1f3f5;
  background-color: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.styled-select:hover:not(:disabled),
.styled-select:focus:not(:disabled) {
  border-color: #00bcd4;
}

.styled-select option {
  background-color: #161822;
  color: #f1f3f5;
}

.styled-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.text-seed-row {
  display: flex;
  gap: 8px;
}

.styled-text-input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: white;
  font-size: 13px;
  outline: none;
}

.styled-text-input:focus:not(:disabled) {
  border-color: #00bcd4;
}

.styled-text-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Selettore Formato (Segmented Buttons) --- */
.format-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 2px;
}

.format-btn {
  padding: 7px 0;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  color: #c0c4cc;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.format-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.format-btn.active {
  background: #00bcd4;
  color: #0b0c10;
  border-color: #00bcd4;
  font-weight: 700;
}

.format-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.info-row {
  display: flex;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: #9ba1b0;
}

.info-row strong {
  color: #00bcd4;
}

/* --- Sliders --- */
input[type="range"] {
  width: 100%;
  accent-color: #00bcd4;
  cursor: pointer;
}

/* --- Color Pickers Grid --- */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 2px;
}

.bg-color-picker {
  height: 32px;
  width: 100%;
}

.color-item {
  position: relative;
  width: 100%;
  height: 30px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.color-item input[type="color"] {
  position: absolute;
  top: -6px;
  left: -5px;
  width: calc(100% + 10px);
  height: calc(100% + 20px);
  border: none;
  cursor: pointer;
  background: none;
}

.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 2px 0;
}

.actions-group {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
}

/* --- Buttons --- */
#videoCaptureButton {
  width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  background-color: #4caf50;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

#videoCaptureButton:hover:not(:disabled) {
  filter: brightness(1.1);
}

#videoCaptureButton:disabled {
  cursor: not-allowed;
  opacity: 0.8;
}

.secondary-btn {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  background-color: transparent;
  color: #c0c4cc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.secondary-btn:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.secondary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Tooltip --- */
.title-with-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-tooltip {
  position: static;
  display: inline-flex;
}

.info-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: rgba(255, 255, 255, 0.15);
  color: #c0c4cc;
  border-radius: 50%;
  font-size: 10px;
  font-weight: bold;
  cursor: help;
}

.info-icon:hover {
  background: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.tooltip-content {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  width: auto;
  box-sizing: border-box;
  background: #1a1c23;
  color: #c0c4cc;
  font-size: 11px;
  line-height: 1.45;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.75);
  z-index: 300;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
  pointer-events: none;
}

.tooltip-content strong {
  color: #00bcd4;
}

.info-tooltip:hover .tooltip-content {
  visibility: visible;
  opacity: 1;
}

/* --- Upload Sprite Grid --- */
.sprite-upload-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.sprite-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 0.2s ease;
}

.sprite-upload-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.6);
}

.sprite-upload-btn.has-image {
  background: rgba(0, 188, 212, 0.15);
  border: 1px solid #00bcd4;
  color: #00bcd4;
}

.sprite-upload-btn input[type="file"] {
  display: none;
}

.text-btn {
  background: none;
  border: none;
  color: #d9534f;
  font-size: 11px;
  text-align: right;
  padding: 4px 0 0 0;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.text-btn:hover {
  opacity: 1;
}

/* --- Checkbox Row --- */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  color: #9ba1b0;
  cursor: pointer;
  user-select: none;
}

.checkbox-row input[type="checkbox"] {
  accent-color: #00bcd4;
  cursor: pointer;
  margin: 0;
}

.checkbox-row:hover {
  color: #f1f3f5;
}

/* --- Audio-Reactive Visualizer Controls --- */
.audio-status-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #9ba1b0;
}

.audio-status-tag.live {
  background: rgba(0, 188, 212, 0.2);
  color: #00bcd4;
}

.audio-source-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 2px;
}

.audio-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  font-size: 12px;
  padding: 7px 6px;
  text-align: center;
}

.audio-upload-label input[type="file"] {
  display: none;
}

.audio-source-grid .secondary-btn {
  font-size: 12px;
  padding: 7px 6px;
}

.secondary-btn.is-active {
  background: rgba(0, 188, 212, 0.18);
  border-color: #00bcd4;
  color: #00bcd4;
  font-weight: 600;
}

.audio-active-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 6px 8px;
  margin-top: 4px;
}

.mini-icon-btn {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #f1f3f5;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.mini-icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.mini-icon-btn.danger {
  color: #ff6b6b;
  border-color: rgba(217, 83, 79, 0.35);
}

.audio-track-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.audio-track-name {
  font-size: 11px;
  color: #e2e6ee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-meter-bg {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
}

.audio-meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00bcd4, #ce5bbc);
  transition: width 0.06s linear;
}

/* --- Portfolio Link --- */
.portfolio-link {
  display: block;
  text-align: center;
  font-size: 11px;
  color: #888;
  text-decoration: none;
  margin-top: 4px;
  transition: color 0.2s ease;
}

.portfolio-link:hover {
  color: #00bcd4;
}

/* --- Pulsante Toggle Mobile (Nascosto su Desktop) --- */
.mobile-menu-toggle {
  display: none;
}

/* --- Layout Responsive Mobile & Tablet --- */
@media (max-width: 768px) {
  body {
    padding-right: 0;
  }

  .golWrap {
    top: 14px;
    left: 14px;
    right: 14px;
    bottom: 14px;
  }

  .mobile-menu-toggle {
    position: fixed;
    top: 22px;
    right: 22px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(18, 20, 29, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #f1f3f5;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 250;
    padding: 0;
    transition:
      background-color 0.2s ease,
      border-color 0.2s ease;
  }

  .mobile-menu-toggle:hover {
    background: rgba(30, 34, 48, 0.95);
    border-color: rgba(255, 255, 255, 0.3);
  }

  .mobile-menu-toggle .icon-close {
    display: none;
  }

  .mobile-menu-toggle.is-open .icon-menu {
    display: none;
  }

  .mobile-menu-toggle.is-open .icon-close {
    display: block;
  }

  /* Dashboard fluttuante a scomparsa */
  .dashboard {
    position: fixed;
    top: 14px;
    right: 14px;
    bottom: 14px;
    width: min(320px, calc(100vw - 28px));
    height: calc(100vh - 28px);
    height: calc(100dvh - 28px);
    z-index: 200;
    transform: translateX(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
    transition:
      transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.22s ease;
  }

  .dashboard.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  /* Lascia spazio a destra nell'header così la X non copre il badge MP4 */
  .dashboard-header {
    padding-right: 44px;
    min-height: 36px;
  }
}
