/* ============================================================
   A SU MEDIDA — lector vertical
   ============================================================ */

:root {
  --bg: #070609;
  --ink: #f7f1e8;
  --muted: rgba(247, 241, 232, 0.64);
  --dim: rgba(247, 241, 232, 0.38);
  --accent: #d59a5f;
  --accent-soft: rgba(213, 154, 95, 0.2);
  --line: rgba(255, 255, 255, 0.13);
  --glass: rgba(9, 8, 11, 0.48);
  --serif: "Bodoni MT", "Didot", "Playfair Display", "Times New Roman", Georgia, serif;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  background: var(--bg);
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 240 240' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

img {
  display: block;
  -webkit-user-drag: none;
  user-select: none;
}

::selection {
  background: var(--accent);
  color: #171009;
}

[hidden] {
  display: none !important;
}

/* ============================================================
   SPLASH
   ============================================================ */

.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: hidden;
  background: var(--bg);
  transition: opacity 0.85s var(--ease);
}

.splash.is-leaving {
  opacity: 0;
  pointer-events: none;
}

.splash__media {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #0a090c;
}

.splash__bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
  filter: blur(7px) saturate(0.86) brightness(0.62);
  transform: scale(1.05);
  animation: splashZoom 20s ease-out both;
}

@keyframes splashZoom {
  from { transform: scale(1.03); }
  to { transform: scale(1.11); }
}

.splash__shade {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 52% 38%, rgba(7, 6, 9, 0.08) 0%, rgba(7, 6, 9, 0.52) 54%, rgba(7, 6, 9, 0.94) 100%),
    linear-gradient(180deg, rgba(7, 6, 9, 0.76) 0%, rgba(7, 6, 9, 0.06) 38%, rgba(7, 6, 9, 0.16) 62%, rgba(7, 6, 9, 0.92) 100%);
}

.splash__shade::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 76% 20%, rgba(213, 154, 95, 0.18), transparent 42%);
}

.splash__inner {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100%;
  height: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: clamp(20px, 3.6vw, 46px);
  padding-top: max(clamp(20px, 3.6vw, 46px), calc(var(--safe-top) + 18px));
  padding-bottom: max(clamp(20px, 3.6vw, 46px), calc(var(--safe-bottom) + 18px));
}

.splash__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.splash__mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 50px;
  height: 50px;
  border: 1px solid rgba(213, 154, 95, 0.5);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  box-shadow: inset 0 0 0 4px rgba(213, 154, 95, 0.05);
}

.splash__mark i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.7;
}

.splash__kicker {
  margin: 0;
  color: rgba(247, 241, 232, 0.46);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.splash__content {
  align-self: center;
  justify-self: center;
  width: 100%;
  max-width: 900px;
  padding-bottom: 3vh;
  text-align: center;
}

.splash__eyebrow {
  margin: 0 0 20px;
  color: var(--accent);
  font-size: clamp(0.58rem, 1.4vw, 0.7rem);
  font-weight: 600;
  letter-spacing: 0.38em;
  text-transform: uppercase;
}

.splash__title {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  font-weight: 400;
  line-height: 0.82;
}

.splash__title-small {
  color: #e8dbc9;
  font-family: var(--serif);
  font-size: clamp(1.7rem, 4vw, 2.8rem);
  font-style: italic;
  letter-spacing: 0.02em;
}

.splash__title-big {
  margin-top: 0.06em;
  padding: 0 0.04em 0.08em;
  color: #fff8ed;
  background: linear-gradient(180deg, #fffaf2 6%, #e4c69f 56%, #a97c4d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-family: var(--serif);
  font-size: clamp(4rem, 14vw, 9rem);
  letter-spacing: 0.055em;
  line-height: 0.88;
  text-transform: uppercase;
  filter: drop-shadow(0 18px 45px rgba(0, 0, 0, 0.42));
}

.splash__quote {
  margin: clamp(22px, 4vh, 40px) auto 0;
  max-width: 35ch;
  color: rgba(247, 241, 232, 0.66);
  font-family: var(--serif);
  font-size: clamp(0.92rem, 1.4vw, 1.1rem);
  font-style: italic;
  line-height: 1.7;
}

.splash__meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  margin: 22px 0 0;
  color: rgba(247, 241, 232, 0.38);
  font-size: 0.59rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.splash__meta i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.75;
}

.splash__bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.begin {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(100%, 428px);
  padding: 11px 16px 11px 12px;
  border: 1px solid rgba(213, 154, 95, 0.38);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.105), rgba(255, 255, 255, 0.045));
  box-shadow:
    0 20px 55px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.13);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.35s ease, background 0.35s ease, transform 0.35s var(--ease), box-shadow 0.35s ease;
}

.begin__icon {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(145deg, #f0c08b, #c88a4d);
  color: #1b1108;
  box-shadow: 0 0 0 5px rgba(213, 154, 95, 0.1), 0 8px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.35s var(--ease), box-shadow 0.35s ease;
}

.begin__icon svg {
  width: 16px;
  height: 16px;
  margin-left: 2px;
}

.begin__text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.begin__text strong {
  color: var(--ink);
  font-size: 0.83rem;
  font-weight: 600;
  letter-spacing: 0.045em;
}

.begin__text small {
  color: rgba(247, 241, 232, 0.43);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.begin__arrow {
  margin-left: auto;
  padding-right: 4px;
  color: var(--accent);
  font-size: 1.12rem;
  opacity: 0.75;
  transition: transform 0.35s var(--ease), opacity 0.35s ease;
}

.begin-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 999px;
  color: rgba(247, 241, 232, 0.42);
  font-size: 0.55rem;
  font-weight: 500;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.3s ease, background 0.3s ease;
}

.begin-reset:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent);
}

.begin.is-loading {
  pointer-events: none;
  opacity: 0.82;
}

.begin.is-loading .begin__icon svg {
  opacity: 0;
}

.begin.is-loading .begin__icon::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(27, 17, 8, 0.25);
  border-top-color: #1b1108;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.splash__hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  color: rgba(247, 241, 232, 0.38);
  font-size: 0.57rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.splash__hint-line {
  width: 28px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(213, 154, 95, 0.7));
}

.reveal {
  opacity: 0;
  transform: translateY(16px);
  animation: reveal 0.95s var(--ease) forwards;
  animation-delay: var(--delay, 0s);
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   LECTOR
   ============================================================ */

.reader {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background: #050406;
  opacity: 0;
  transition: opacity 0.75s ease;
}

.reader.is-ready {
  opacity: 1;
}

/* Fondo ambiental: la misma viñeta, muy desenfocada. */
.ambient {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #060508;
}

.ambient__layer {
  position: absolute;
  inset: -12%;
  background-position: center;
  background-size: cover;
  filter: blur(46px) saturate(0.82) brightness(0.34);
  transform: scale(1.16);
  opacity: 0;
  transition: opacity 1.15s ease;
  will-change: opacity;
}

.ambient__layer.is-on {
  opacity: 1;
}

.ambient__veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(5, 4, 7, 0.04) 0%, rgba(5, 4, 7, 0.34) 55%, rgba(5, 4, 7, 0.8) 100%),
    linear-gradient(180deg, rgba(5, 4, 7, 0.58) 0%, transparent 20%, transparent 80%, rgba(5, 4, 7, 0.72) 100%);
}

.scroller {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow-x: hidden;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.scroller::-webkit-scrollbar {
  display: none;
}

.scroller:focus {
  outline: none;
}

.slides {
  width: 100%;
}

.slide {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.slide__frame,
.chapter-card {
  position: relative;
  width: min(100vw, calc(100vh * 0.5625));
  width: min(100vw, calc(100dvh * 0.5625));
  aspect-ratio: 720 / 1280;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  background: #0a090c;
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.56);
}

.chapter-card {
  container-type: inline-size;
}

.slide__frame::after,
.chapter-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: inherit;
  pointer-events: none;
}

@media (min-width: 760px) and (min-height: 620px) {
  .slide__frame,
  .chapter-card {
    border-radius: 9px;
  }
}

.slide__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 0.5s ease, transform 1.15s var(--ease);
  will-change: opacity, transform;
}

.slide__img.is-loaded {
  opacity: 1;
}

.slide.is-active .slide__img {
  transform: scale(1);
}

.slide__error {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  place-content: center;
  gap: 8px;
  padding: 30px;
  background: #121014;
  color: rgba(247, 241, 232, 0.7);
  text-align: center;
}

.slide.has-error .slide__error {
  display: grid;
}

.slide.has-error .slide__img {
  visibility: hidden;
}

.slide__error span {
  font-family: var(--serif);
  font-size: 1.25rem;
}

.slide__error small {
  color: rgba(247, 241, 232, 0.35);
  font-size: 0.62rem;
  word-break: break-all;
}

/* ============================================================
   PORTADILLAS DE CAPÍTULO / FINAL
   ============================================================ */

.chapter-card {
  isolation: isolate;
}

.chapter-card__bg {
  position: absolute;
  inset: -7%;
  z-index: -3;
  width: 114%;
  height: 114%;
  object-fit: cover;
  filter: blur(24px) saturate(0.78) brightness(0.52);
  transform: scale(1.06);
}

.chapter-card__veil {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 70% 22%, rgba(213, 154, 95, 0.13), transparent 42%),
    radial-gradient(ellipse at 50% 42%, rgba(10, 8, 12, 0.06) 0%, rgba(10, 8, 12, 0.38) 56%, rgba(10, 8, 12, 0.9) 100%),
    linear-gradient(180deg, rgba(10, 8, 12, 0.52), rgba(10, 8, 12, 0.04) 42%, rgba(10, 8, 12, 0.76));
}

.chapter-card__ghost {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: -1;
  color: transparent;
  font-family: var(--serif);
  font-size: clamp(12rem, 30vh, 20rem);
  letter-spacing: -0.04em;
  line-height: 1;
  -webkit-text-stroke: 1px rgba(247, 241, 232, 0.1);
  transform: translate(-50%, -54%);
  user-select: none;
  white-space: nowrap;
}

.chapter-card__content,
.end-card__content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 9%;
  text-align: center;
}

.chapter-card__eyebrow {
  color: var(--accent);
  font-size: clamp(0.58rem, 1.5vw, 0.68rem);
  font-weight: 600;
  letter-spacing: 0.38em;
  text-transform: uppercase;
}

.chapter-card__title {
  max-width: 11ch;
  margin: 20px 0 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(2.7rem, 7.6vh, 4.7rem);
  font-weight: 400;
  letter-spacing: 0.005em;
  line-height: 1.02;
  text-shadow: 0 16px 45px rgba(0, 0, 0, 0.5);
  text-wrap: balance;
}

.chapter-card__rule {
  position: relative;
  display: block;
  width: 62px;
  height: 1px;
  margin: 30px 0 18px;
  background: linear-gradient(90deg, transparent, rgba(213, 154, 95, 0.9), transparent);
}

.chapter-card__rule i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border: 1px solid var(--accent);
  background: #0a090c;
  transform: translate(-50%, -50%) rotate(45deg);
}

.chapter-card__count {
  margin: 0;
  color: var(--dim);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.chapter-card__hint {
  position: absolute;
  bottom: max(8%, 38px);
  left: 50%;
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(247, 241, 232, 0.43);
  font-size: 0.57rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-50%);
}

.chapter-card__hint svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
  animation: hintDrop 2s ease-in-out infinite;
}

@keyframes hintDrop {
  0%, 100% { transform: translateY(-2px); opacity: 0.45; }
  50% { transform: translateY(3px); opacity: 1; }
}

.end-card__title {
  max-width: 100%;
  margin: 20px 0 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(2.2rem, 13.5cqw, 4.8rem);
  font-weight: 400;
  line-height: 0.95;
  text-shadow: 0 16px 45px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.chapter-card--end .chapter-card__ghost {
  font-size: clamp(9rem, 20vh, 15rem);
  letter-spacing: 0.05em;
  -webkit-text-stroke-color: rgba(247, 241, 232, 0.08);
}

.end-card__text {
  margin: 22px 0 0;
  color: rgba(247, 241, 232, 0.56);
  font-family: var(--serif);
  font-size: clamp(0.98rem, 1.7vw, 1.15rem);
  font-style: italic;
  line-height: 1.6;
}

.end-card__text em {
  color: rgba(247, 241, 232, 0.82);
}

.end-card__btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 34px;
  padding: 13px 24px;
  border: 1px solid rgba(213, 154, 95, 0.55);
  border-radius: 999px;
  background: rgba(213, 154, 95, 0.08);
  color: var(--accent);
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.3s ease, color 0.3s ease, transform 0.3s var(--ease);
}

.end-card__btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.end-card__note {
  margin: 26px 0 0;
  color: rgba(247, 241, 232, 0.28);
  font-size: 0.56rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ============================================================
   INTERFAZ DEL LECTOR
   ============================================================ */

.ui {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.rail {
  position: absolute;
  top: calc(var(--safe-top) + 8px);
  left: clamp(10px, 2.2vw, 26px);
  right: clamp(10px, 2.2vw, 26px);
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  pointer-events: auto;
}

.rail__seg {
  display: flex;
  align-items: center;
  height: 24px;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
}

.rail__track {
  display: block;
  width: 100%;
  height: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(247, 241, 232, 0.18);
  box-shadow: 0 1px 10px rgba(0, 0, 0, 0.4);
  transition: height 0.25s ease, background 0.25s ease;
}

.rail__fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(213, 154, 95, 0.5);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.45s var(--ease), background 0.3s ease, box-shadow 0.3s ease;
}

.rail__seg.is-complete .rail__fill {
  background: rgba(247, 241, 232, 0.62);
  box-shadow: none;
}

.rail__seg.is-active .rail__track {
  height: 4px;
  background: rgba(247, 241, 232, 0.26);
}

.rail__seg.is-active .rail__fill {
  background: var(--accent);
  box-shadow: 0 0 14px rgba(213, 154, 95, 0.7);
}

.chrome {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}

.ui.is-idle .chrome {
  opacity: 0;
}

.ui.is-idle .chrome,
.ui.is-idle .chrome * {
  pointer-events: none !important;
}

.chapter-chip {
  position: absolute;
  top: calc(var(--safe-top) + 36px);
  left: clamp(12px, 2.2vw, 26px);
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: calc(100vw - 154px);
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: var(--glass);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
  transition: border-color 0.3s ease, background 0.3s ease;
}

.chapter-chip__num {
  color: var(--accent);
}

.chapter-chip__sep {
  width: 1px;
  height: 10px;
  background: rgba(255, 255, 255, 0.18);
}

.chapter-chip__title {
  max-width: min(48vw, 240px);
  overflow: hidden;
  color: rgba(247, 241, 232, 0.82);
  text-overflow: ellipsis;
}

.hud-actions {
  position: absolute;
  top: calc(var(--safe-top) + 31px);
  right: clamp(12px, 2.2vw, 26px);
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.hud-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  background: rgba(9, 8, 11, 0.42);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(13px);
  -webkit-backdrop-filter: blur(13px);
  color: rgba(247, 241, 232, 0.82);
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.25s var(--ease);
}

.hud-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.hud-btn__off {
  display: none;
}

#sound-toggle.is-muted {
  color: rgba(247, 241, 232, 0.42);
}

#sound-toggle.is-muted .hud-btn__on {
  display: none;
}

#sound-toggle.is-muted .hud-btn__off {
  display: block;
}

.counter {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 18px);
  left: clamp(12px, 2.2vw, 26px);
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(9, 8, 11, 0.38);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.24);
  pointer-events: auto;
}

.counter__label {
  color: rgba(247, 241, 232, 0.4);
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.counter__value {
  display: flex;
  align-items: baseline;
  gap: 3px;
  color: rgba(247, 241, 232, 0.4);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.counter__value b {
  color: var(--ink);
  font-weight: 600;
}

.nav {
  position: absolute;
  right: clamp(12px, 2.2vw, 26px);
  bottom: calc(var(--safe-bottom) + 16px);
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.nav__btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  background: rgba(9, 8, 11, 0.42);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(13px);
  -webkit-backdrop-filter: blur(13px);
  color: rgba(247, 241, 232, 0.82);
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.25s var(--ease), opacity 0.25s ease;
}

.nav__btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.nav__btn:disabled {
  opacity: 0.24;
  cursor: default;
}

.scroll-hint {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 84px);
  left: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(9, 8, 11, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(13px);
  -webkit-backdrop-filter: blur(13px);
  color: rgba(247, 241, 232, 0.54);
  font-size: 0.55rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 0.45s ease, transform 0.45s var(--ease);
}

.scroll-hint.is-dismissed {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.scroll-hint__mouse {
  position: relative;
  display: block;
  width: 15px;
  height: 22px;
  border: 1px solid rgba(247, 241, 232, 0.45);
  border-radius: 9px;
}

.scroll-hint__mouse i {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 2px;
  height: 4px;
  border-radius: 99px;
  background: var(--accent);
  transform: translateX(-50%);
  animation: wheel 1.8s ease-in-out infinite;
}

@keyframes wheel {
  0%, 100% { opacity: 0.35; transform: translate(-50%, 0); }
  45% { opacity: 1; transform: translate(-50%, 5px); }
}

.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 82px);
  left: 50%;
  z-index: 40;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  background: rgba(12, 10, 14, 0.86);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: rgba(247, 241, 232, 0.82);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, 10px);
  transition: opacity 0.3s ease, transform 0.3s var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ============================================================
   MENÚ DE CAPÍTULOS
   ============================================================ */

.chapters {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: clamp(12px, 2vw, 28px);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.chapters.is-open {
  opacity: 1;
}

.chapters__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 3, 6, 0.74);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.chapters__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1020px, 100%);
  max-height: min(88vh, 900px);
  max-height: min(88dvh, 900px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 18px;
  background:
    radial-gradient(circle at 88% -10%, rgba(213, 154, 95, 0.14), transparent 42%),
    linear-gradient(160deg, #151217 0%, #0a090c 62%);
  box-shadow: 0 44px 130px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transform: translateY(20px) scale(0.985);
  transition: transform 0.45s var(--ease);
}

.chapters.is-open .chapters__panel {
  transform: none;
}

.chapters__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: clamp(22px, 3vw, 32px) clamp(20px, 3vw, 36px) 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chapters__kicker {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

.chapters__title {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  font-weight: 400;
  line-height: 0.95;
}

.chapters__close {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  color: rgba(247, 241, 232, 0.72);
  cursor: pointer;
  transition: border-color 0.25s ease, background 0.25s ease, color 0.25s ease, transform 0.3s var(--ease);
}

.chapters__close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.6;
}

.chapters__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
  padding: clamp(16px, 2.4vw, 24px) clamp(20px, 3vw, 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(213, 154, 95, 0.35) transparent;
}

.chapters__list::-webkit-scrollbar {
  width: 6px;
}

.chapters__list::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(213, 154, 95, 0.35);
}

.chapter-item {
  position: relative;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 15px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.3s ease, background 0.3s ease, transform 0.35s var(--ease);
}

.chapter-item.is-current {
  border-color: rgba(213, 154, 95, 0.48);
  background: rgba(213, 154, 95, 0.07);
}

.chapter-item:focus-visible {
  outline-offset: -2px;
}

.chapter-item.is-read:not(.is-current) {
  border-color: rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.035);
}

.chapter-item__thumb {
  position: relative;
  display: block;
  width: 84px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 7px;
  background: #141116;
}

.chapter-item__thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(7, 6, 9, 0.62) 100%);
}

.chapter-item__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.88) brightness(0.82);
  transform: scale(1.02);
  transition: transform 0.6s var(--ease), filter 0.4s ease;
}

.chapter-item__num {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.51rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.chapter-item__body {
  display: block;
  min-width: 0;
}

.chapter-item__title {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.05rem, 1.7vw, 1.3rem);
  font-weight: 400;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-item__meta {
  display: block;
  margin-top: 6px;
  color: rgba(247, 241, 232, 0.36);
  font-size: 0.5rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.chapter-item__meta b {
  color: var(--accent);
  font-weight: 600;
}

.chapter-item__bar {
  display: block;
  height: 2px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(247, 241, 232, 0.14);
}

.chapter-item__bar i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(213, 154, 95, 0.55);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.5s var(--ease);
}

.chapter-item.is-read .chapter-item__bar i {
  background: rgba(247, 241, 232, 0.56);
  box-shadow: none;
}

.chapters__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(20px, 3vw, 36px) 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.16);
}

.chapters__summary {
  margin: 0;
  color: rgba(247, 241, 232, 0.34);
  font-size: 0.52rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.chapters__continue {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid rgba(213, 154, 95, 0.5);
  border-radius: 999px;
  background: rgba(213, 154, 95, 0.08);
  color: var(--accent);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.3s ease, color 0.3s ease, transform 0.3s var(--ease);
}

.chapters__continue svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

/* ============================================================
   HOVER / PUNTERO FINO
   ============================================================ */

@media (hover: hover) and (pointer: fine) {
  .begin:hover {
    border-color: rgba(213, 154, 95, 0.72);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.06));
    box-shadow: 0 24px 65px rgba(0, 0, 0, 0.44), inset 0 1px 0 rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
  }

  .begin:hover .begin__icon {
    transform: scale(1.05);
    box-shadow: 0 0 0 7px rgba(213, 154, 95, 0.12), 0 10px 24px rgba(0, 0, 0, 0.32);
  }

  .begin:hover .begin__arrow {
    opacity: 1;
    transform: translateX(3px);
  }

  .rail__seg:hover .rail__track {
    height: 5px;
  }

  .nav__btn:hover:not(:disabled) {
    border-color: rgba(213, 154, 95, 0.6);
    background: rgba(213, 154, 95, 0.13);
    color: var(--accent);
    transform: translateY(-2px);
  }

  .hud-btn:hover {
    border-color: rgba(213, 154, 95, 0.6);
    background: rgba(213, 154, 95, 0.13);
    color: var(--accent);
    transform: translateY(-1px);
  }

  .chapter-chip:hover {
    border-color: rgba(213, 154, 95, 0.5);
    background: rgba(26, 21, 24, 0.66);
  }

  .chapter-item:hover {
    border-color: rgba(213, 154, 95, 0.42);
    background: rgba(213, 154, 95, 0.06);
    transform: translateY(-1px);
  }

  .chapter-item:hover .chapter-item__thumb img {
    filter: saturate(1) brightness(0.95);
    transform: scale(1.07);
  }

  .chapters__close:hover {
    border-color: rgba(213, 154, 95, 0.6);
    background: rgba(213, 154, 95, 0.12);
    color: var(--accent);
    transform: rotate(90deg);
  }

  .chapters__continue:hover {
    background: var(--accent);
    color: #1a1109;
    transform: translateY(-1px);
  }

  .end-card__btn:hover {
    background: var(--accent);
    color: #1a1109;
    transform: translateY(-2px);
  }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 640px) {
  .ambient__layer {
    filter: blur(26px) saturate(0.82) brightness(0.34);
  }

  .splash__inner {
    padding: 20px 18px;
    padding-top: max(20px, calc(var(--safe-top) + 16px));
    padding-bottom: max(18px, calc(var(--safe-bottom) + 14px));
  }

  .splash__mark {
    width: 44px;
    height: 44px;
    font-size: 0.74rem;
  }

  .splash__kicker {
    font-size: 0.53rem;
    letter-spacing: 0.2em;
  }

  .splash__content {
    padding-bottom: 1vh;
  }

  .splash__quote {
    max-width: 30ch;
    font-size: 0.9rem;
  }

  .splash__hint {
    font-size: 0.52rem;
    letter-spacing: 0.14em;
  }

  .begin {
    width: 100%;
    padding: 10px 14px 10px 10px;
  }

  .begin__text strong {
    font-size: 0.78rem;
  }

  .begin__text small {
    font-size: 0.56rem;
  }

  .chapter-chip {
    top: calc(var(--safe-top) + 32px);
    max-width: calc(100vw - 122px);
    padding: 8px 11px;
    font-size: 0.53rem;
    letter-spacing: 0.13em;
  }

  .chapter-chip__title {
    max-width: 42vw;
  }

  .hud-actions {
    top: calc(var(--safe-top) + 28px);
    gap: 7px;
  }

  .hud-btn {
    width: 36px;
    height: 36px;
  }

  .hud-btn svg {
    width: 15px;
    height: 15px;
  }

  .counter {
    padding: 7px 10px;
  }

  .counter__label {
    font-size: 0.49rem;
  }

  .counter__value {
    font-size: 0.67rem;
  }

  .nav__btn {
    width: 38px;
    height: 38px;
  }

  .nav__btn svg {
    width: 17px;
    height: 17px;
  }

  .scroll-hint {
    bottom: calc(var(--safe-bottom) + 76px);
    padding: 7px 12px;
    font-size: 0.51rem;
    letter-spacing: 0.14em;
  }

  .chapter-card__title {
    font-size: clamp(2.3rem, 7vh, 3.6rem);
  }

  .chapter-card__hint {
    font-size: 0.52rem;
    letter-spacing: 0.14em;
  }

  .end-card__btn {
    margin-top: 28px;
    padding: 12px 20px;
    font-size: 0.58rem;
  }

  .begin-reset {
    font-size: 0.51rem;
    letter-spacing: 0.14em;
  }

  .chapters {
    place-items: end center;
    padding: 0;
  }

  .chapters__panel {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 20px 20px 0 0;
    transform: translateY(42px);
  }

  .chapters__head {
    padding: 18px 18px 14px;
  }

  .chapters__title {
    font-size: 1.9rem;
  }

  .chapters__close {
    width: 38px;
    height: 38px;
  }

  .chapters__list {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px 16px;
  }

  .chapter-item {
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 13px;
    padding: 8px;
  }

  .chapter-item__thumb {
    width: 62px;
    border-radius: 6px;
  }

  .chapter-item__title {
    font-size: 1.05rem;
  }

  .chapter-item__meta {
    margin-top: 5px;
    font-size: 0.47rem;
  }

  .chapter-item__bar {
    margin-top: 7px;
  }

  .chapters__foot {
    padding: 12px 16px;
    padding-bottom: max(12px, calc(var(--safe-bottom) + 8px));
  }

  .chapters__summary {
    font-size: 0.47rem;
    letter-spacing: 0.12em;
  }

  .chapters__continue {
    padding: 9px 15px;
    font-size: 0.5rem;
    letter-spacing: 0.13em;
  }
}

@media (max-height: 690px) {
  .splash__quote {
    display: none;
  }

  .splash__meta {
    margin-top: 16px;
  }

  .splash__content {
    padding-bottom: 0;
  }

  .splash__title-big {
    font-size: clamp(3.4rem, 12vw, 6.4rem);
  }

  .splash__bottom {
    gap: 10px;
  }

  .splash__hint {
    display: none;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .splash__inner {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto 1fr;
    gap: 12px 28px;
    padding: 16px 24px;
  }

  .splash__top {
    grid-column: 1 / -1;
  }

  .splash__content {
    align-self: center;
    justify-self: start;
    max-width: 520px;
    padding: 0;
    text-align: left;
  }

  .splash__title {
    align-items: flex-start;
  }

  .splash__title-big {
    font-size: clamp(3.2rem, 10vw, 5.8rem);
  }

  .splash__eyebrow {
    margin-bottom: 10px;
  }

  .splash__meta {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .splash__bottom {
    align-self: end;
    justify-self: end;
    width: min(360px, 42vw);
  }

  .splash__quote,
  .splash__hint {
    display: none;
  }
}

/* ============================================================
   ACCESIBILIDAD / MOVIMIENTO REDUCIDO
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }

  .splash__bg {
    animation: none;
  }
}
