:root {
  --bg-deep: #050505;
  --bg-card: #0f0f12;
  --bg-input: #16161a;
  --header-bg: rgba(17, 17, 17, 1);
  --primary: #FF5E57;
  --primary-hover: #a5403b;
  --success: #10b981;
  --danger: #ef4444;
  --text-main: #ffffff;
  --text-muted: #e0e0e0;
  --border: #222226;
  --radius: 100px;
  --font-main: 'Inter', sans-serif;
  --texts: #007bff;
  --ui-bg: rgba(15, 15, 18, 0.75);
  --ui-border: rgba(255, 255, 255, 0.08);
  --ui-hover: rgba(255, 255, 255, 0.12);
  --ui-radius: 16px;
  --shadow-premium: 0 20px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --max-width: 900px;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: black;
  font-family: var(--font-main);
  color: var(--text-main);
}

/* =========================================
   1. BARRA DE PROGRESO Y FONDO
========================================= */
.gradient {
  background: linear-gradient(to top, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.8) 50%, rgba(0, 0, 0, 0.6) 100%),
    url("images/fondo.923fd6d562be.webp") no-repeat center center / cover;
  position: absolute;
  top: -42px;
  left: 0;
  width: 100%;
  height: 40vh;
  z-index: -1;
}

#readingProgressBar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 4px;
  background-color: var(--texts);
  z-index: 9999;
}

/* =========================================
   2. TIPOGRAFÍA Y BREADCRUMB
========================================= */
h1 {
  text-align: center;
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  line-height: 1.4;
  max-width: var(--max-width);
  margin: 30px auto 0;
  padding: 0 15px;
  word-wrap: break-word;
}

.unique-manga-title {
  color: #d57aff;
  text-decoration: none;
  transition: color 0.3s ease;
}

.unique-manga-title:hover {
  color: #713d8a;
}

.breadcrumb {
  background-color: var(--bg-card);
  color: var(--text-muted);
  padding: 10px 15px;
  margin: 15px auto;
  border-radius: var(--radius);
  font-size: 0.9rem;
  width: 90%;
  max-width: var(--max-width);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.breadcrumb a {
  color: var(--texts);
  text-decoration: none;
  font-weight: bold;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

/* =========================================
   3. BOTONES DE NAVEGACIÓN Y COMPARTIR
========================================= */
.nav-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 25px auto;
  max-width: var(--max-width);
  padding: 0 10px;
}

.nav-buttons a,
#prevPage,
#nextPage {
  flex: 1;
  min-width: 100px;
  max-width: 150px;
  padding: 10px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.nav-buttons a:hover,
#prevPage:hover:not(:disabled),
#nextPage:hover:not(:disabled) {
  background-color: var(--border);
}

#prevPage:disabled,
#nextPage:disabled {
  background-color: var(--bg-deep);
  color: #555;
  border-color: #333;
  cursor: not-allowed;
}

.share-container {
  text-align: center;
  margin: 20px auto;
}

.share-container h4 {
  margin-bottom: 12px;
  font-size: 1.1rem;
  color: var(--text-main);
}

.share-buttons {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.share-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.share-btn:hover {
  transform: translateY(-2px);
}

.facebook {
  background-color: #3b5998;
}

.twitter {
  background-color: #1da1f2;
}

.whatsapp {
  background-color: #25d366;
}

.telegram {
  background-color: #0088cc;
}

.native-share {
  background-color: var(--border);
}

/* =========================================
   4. ÁREA DE LECTURA (CASCADA Y PÁGINA)
========================================= */
.chapter-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-height: 40vh;
}

#page-by-page-view,
#cascade-view {
  width: 100%;
  margin: 0 auto;
}

.manga-image {
  width: 100%;
  max-width: 800px;
  height: auto;
  transform: translateZ(0);
  will-change: transform, opacity;
  content-visibility: auto;
  contain-intrinsic-size: 1000px;
  display: block;
  margin: 0 auto;
}

#pageDisplayArea {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 0 auto;
  position: relative;
}

#pageDisplayArea.mode-double {
  gap: 15px;
}

#pageDisplayArea.rtl {
  flex-direction: row-reverse;
}

#pageDisplayArea.ltr {
  flex-direction: row;
}

/* MODO 1 PÁGINA */
.mode-single .single-manga-page {
  width: 100%;
  max-width: var(--max-width);
}

/* MODO 2 PÁGINAS (LIBRO) */
.mode-double .single-manga-page {
  width: 100%;
  max-width: clamp(200px, calc(50% - 7.5px), var(--max-width));
}

.click-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 10;
}

#click-zone-left {
  left: 0;
  cursor: w-resize;
}

#click-zone-right {
  right: 0;
  cursor: e-resize;
}

.end-chapter {
  text-align: center;
  margin: 40px auto 20px;
  padding: 20px;
}

/* =========================================
   5. COMPONENTES UI Y BOTÓN FLOTANTE
========================================= */
.u-icon {
  font-size: 1.1em;
  line-height: 1;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
  color: var(--text-muted);
  font-style: normal;
  font-weight: normal;
}

#floatingSettingsBtn {
  position: fixed;
  bottom: 30px;
  right: max(20px, calc(50vw - 480px));
  width: 52px;
  height: 52px;
  background: var(--ui-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-main);
  border: 1px solid var(--ui-border);
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  z-index: 999;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#floatingSettingsBtn .u-icon {
  margin: 0;
  color: var(--text-main);
  transition: transform 0.4s ease;
}

#floatingSettingsBtn:hover {
  background: var(--ui-hover);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
}

#floatingSettingsBtn:hover .u-icon {
  transform: rotate(90deg);
}

/* =========================================
   6. PANEL DE AJUSTES (GLASSMORPHISM)
========================================= */
.settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.settings-overlay.active {
  display: block;
  opacity: 1;
}

.settings-panel {
  position: absolute;
  background: var(--ui-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-premium);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid var(--ui-border);
}

.mobile-drag-handle {
  display: none;
  width: 40px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 4px;
  margin: 12px auto 0;
  opacity: 0.3;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--ui-border);
}

.settings-header h3 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  letter-spacing: 0.5px;
}

#closeSettingsBtn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: 0.2s ease;
}

#closeSettingsBtn:hover {
  background: var(--danger);
  color: #fff;
  transform: scale(1.1);
}

.settings-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-item label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.setting-btn-primary,
.setting-select {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border: 1px solid var(--ui-border);
  padding: 10px 16px;
  border-radius: var(--ui-radius);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.setting-btn-primary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.custom-select-wrapper {
  position: relative;
  width: 160px;
}

.custom-select-wrapper::after {
  content: "▾";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 14px;
}

.setting-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  outline: none;
}

.setting-select:focus {
  border-color: var(--primary);
}

.setting-select option {
  background: var(--bg-card);
  color: var(--text-main);
}

/* =========================================
   7. CONTROLES AUTO-SCROLL
========================================= */
.autoscroll-inline-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.speed-stepper {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--ui-border);
  border-radius: 20px;
  overflow: hidden;
}

.stepper-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.2rem;
  width: 32px;
  height: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.stepper-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

#menuSpeedValue {
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 26px;
  text-align: center;
  color: var(--text-main);
  user-select: none;
}

.play-circle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--ui-bg);
  color: #fff;
  font-size: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.play-circle-btn:hover {
  transform: scale(1.1);
}

.play-circle-btn.is-playing {
  background: var(--ui-bg);
}

/* Indicador temporal creado por Javascript para gestos de velocidad */
#speed-overlay {
  position: fixed;
  bottom: 100px;
  right: 20px;
  background: var(--bg-card);
  color: var(--texts);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: bold;
  z-index: 9999;
  display: none;
  pointer-events: none;
  backdrop-filter: blur(5px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border);
}

/* =========================================
   8. CONTENEDOR DE COMENTARIOS
========================================= */
.coments {
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

#coments2 {
  width: 100%;
}

/* =========================================
   9. RESPONSIVE (MEDIA QUERIES)
========================================= */
@media (min-width: 851px) {
  .settings-panel {
    top: 0;
    right: 0;
    width: 380px;
    height: 100%;
    transform: translateX(100%);
    border-radius: 20px 0 0 20px;
    border-right: none;
  }

  .settings-overlay.active .settings-panel {
    transform: translateX(0);
  }
}

@media (max-width: 850px) {
  .breadcrumb {
    font-size: 0.8rem;
    padding: 8px;
  }

  .coments {
    padding: 15px;
  }

  #floatingSettingsBtn {
    bottom: 20px;
    right: 20px;
    opacity: 0.8;
  }

  .mobile-drag-handle {
    display: block;
  }

  .settings-panel {
    bottom: 0;
    left: 0;
    width: 100%;
    border-radius: 24px 24px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 20px);
    transform: translateY(100%);
    border-bottom: none;
  }

  .settings-overlay.active .settings-panel {
    transform: translateY(0);
  }

  .custom-select-wrapper {
    width: 140px;
  }

  /* Desactiva modo libro en móviles y centra en single */
  #pageDisplayArea {
    flex-direction: column !important;
  }

  .single-manga-page {
    max-width: 100% !important;
    width: 100%;
  }

  #current-page-2 {
    display: none !important;
  }
}

@media (max-width: 480px) {

  .nav-buttons a,
  #prevPage,
  #nextPage {
    font-size: 0.85rem;
    padding: 8px;
  }
}

#autoscroll-hint {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13px;
  text-align: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(6px);
  transition: all 0.3s ease;
  max-width: 260px;
  line-height: 1.4;
}

#autoscroll-hint.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

#autoscroll-hint small {
  display: block;
  opacity: 0.7;
  font-size: 11px;
  margin-top: 4px;
}

.help-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--ui-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.help-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.1);
}

/* Bloquea la selección de imágenes/texto y el menú al mantener presionado (iOS/Safari) */
body.is-reading-autoscroll {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
}

body.is-reading-autoscroll img {
  -webkit-user-drag: none !important;
  /* Evita que la imagen se "arrastre" como fantasma */
}