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

body {
  background-color: #FFF;
}

.image-sequence {
  position: relative; /* serve da riferimento per l'overlay di selezione */
  display: flex;
  flex-direction: column;
  align-items: flex-end; /* allinea le immagini tra loro sul lato destro */
  width: 50%;
  max-width: 80%;
  margin: 0 auto; /* centra il blocco nella pagina */
}

.seq-img {
  display: block;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

/* ---------- Popup introduttivo ---------- */

#intro-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

#intro-popup-overlay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#intro-popup {
  position: relative;
  width: min(420px, 82vw);
  padding: 48px 40px;
  color: #111;
  font-family: "Garamond", serif;
  font-size: 15px;
  line-height: 1.6;
  text-align: center;

  background: rgba(255, 255, 255, 0.85);
  border-radius: 0px;
}

#intro-popup p {
  margin: 0;
}

#intro-popup-reopen {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 1500;

  background: none;
  border: none;
  padding: 0;
  margin: 0;

  color: #111;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 12px;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  opacity: 0.7;
}

#intro-popup-reopen:hover {
  opacity: 1;
}

/* ---------- Strumento di selezione ---------- */

.selection-toolbar {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.selection-toolbar button {
  background: #111;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.selection-toolbar button.active {
  background: #d33;
}

.selection-toolbar .hint {
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  max-width: 220px;
}

.selection-overlay {
  position: absolute;
  inset: 0;
  z-index: 500;
  cursor: crosshair;
  /* attivo solo mentre lo strumento è acceso */
  display: none;
}

.selection-overlay.active {
  display: block;
}

.selection-box {
  position: absolute;
  border: 1.5px dashed #fff;
  outline: 1.5px dashed #111;
  background: rgba(30, 144, 255, 0.15);
  pointer-events: none;
  display: none;
}

.selection-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
  padding: 12px;
  display: none;
  flex-direction: column;
  gap: 10px;
  max-width: 260px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.selection-panel.visible {
  display: flex;
}

.selection-panel img {
  max-width: 100%;
  max-height: 240px;
  display: block;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.selection-panel .panel-actions {
  display: flex;
  gap: 8px;
}

.selection-panel button {
  flex: 1;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

.selection-panel .download-btn {
  background: #111;
  color: #fff;
}

.selection-panel .redo-btn {
  background: #eee;
  color: #111;
}
