*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #111;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: 'Segoe UI', sans-serif;
  color: #fff;
  padding: 20px;
  overflow-x: hidden; /* Evita scroll lateral en móviles */
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.2rem, 5vw, 1.8rem);
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #e60000;
  text-align: center;
}

#viewer-wrap {
  position: relative;
  width: 100%;
  max-width: 600px; /* Tamaño ideal */
  aspect-ratio: 1 / 1;
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
  cursor: grab;
  user-select: none;
  touch-action: none; /* Crucial para fluidez táctil */
}

#viewer-wrap.grabbing { cursor: grabbing; }

#viewer-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none; /* Usamos display en lugar de opacity para rendimiento */
  pointer-events: none;
}

#viewer-wrap img.active { display: block; }

#hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(0,0,0,.3);
  pointer-events: none;
  transition: opacity .3s;
  z-index: 10;
}

#hint.hidden { opacity: 0; }

.progress-bar {
  width: 100%;
  max-width: 600px;
  height: 4px;
  background: #333;
  margin-top: 15px;
  border-radius: 10px;
}

.progress-fill {
  height: 100%;
  background: #e60000;
  width: 0%;
}

.controls {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
}

.btn-circle {
  background: #222;
  border: 1px solid #444;
  border-radius: 50%;
  width: 50px; height: 50px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .2s;
}

.btn-circle:hover { background: #e60000; border-color: #e60000; }
.btn-circle svg { width: 24px; height: 24px; fill: #fff; }

.dots { display: flex; gap: 8px; }
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #444;
  transition: all .3s;
}
.dot.active { background: #e60000; transform: scale(1.3); }

#autoBtn {
  margin-top: 15px;
  background: transparent;
  border: 1px solid #e60000;
  color: #e60000;
  padding: 8px 20px;
  border-radius: 30px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.8rem;
}

#autoBtn.on { background: #e60000; color: #fff; }

/* Responsive */
@media (max-width: 600px) {
  #viewer-wrap { border-radius: 0; width: 100vw; }
}