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

:root {
  --page-width: 300px;
  --page-height: 337px;
  --book-width: 600px;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #dfe8f6;
  font-family: Arial, Helvetica, sans-serif;
}

button {
  font-family: inherit;
}

.album-screen {
  width: 100vw;
  height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.album-scene {
  position: relative;
  width: min(100vw, calc(100svh * 16 / 9));
  height: min(100svh, calc(100vw * 9 / 16));
  overflow: hidden;
  isolation: isolate;
}

.album-bg,
.album-bg img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.album-bg img {
  object-fit: fill;
}

.album-header {
  position: absolute;
  top: 6.2%;
  left: 4.9%;
  right: 3.5%;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  color: #fff;
}

.album-header h1 {
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -1px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.progress-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(8px, 1vw, 12px);
  min-width: 40%;
  font-size: clamp(16px, 1.8vw, 23px);
  font-weight: 900;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.progress-bar {
  position: relative;
  width: min(22vw, 235px);
  height: clamp(12px, 1.5vw, 17px);
  overflow: hidden;
  border-radius: 999px;
  background: #d8e0e5;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.32);
}

.progress-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  border-radius: inherit;
  background: #ffad2e;
}

/* REVISTA */
.magazine-stage {
  position: absolute;
  top: 20.2%;
  height: var(--page-height);
  z-index: 4;
  transition: left 0.35s ease, width 0.35s ease, filter 0.35s ease;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.28));
}

.magazine-stage.page-cover,
.magazine-stage.page-last {
  left: 25.3%;
  width: var(--page-width);
  overflow: hidden;
}

.magazine-stage.page-spread {
  left: 11.3%;
  width: var(--book-width);
  overflow: visible;
}

#magazine {
  position: absolute !important;
  top: 0 !important;
  width: var(--book-width) !important;
  height: var(--page-height) !important;
  margin: 0 !important;
  overflow: visible !important;
  transition: left 0.35s ease;
}

.magazine-stage.page-cover #magazine {
  left: calc(var(--page-width) * -1) !important;
}

.magazine-stage.page-spread #magazine,
.magazine-stage.page-last #magazine {
  left: 0 !important;
}

#magazine .page-wrapper,
#magazine .page,
#magazine .turn-page,
.album-page {
  width: var(--page-width) !important;
  height: var(--page-height) !important;
}

#magazine .page,
#magazine .turn-page,
.album-page {
  background-size: 100% 100% !important;
  background-repeat: no-repeat !important;
  background-position: center center !important;
  background-color: transparent !important;
  overflow: hidden !important;
  image-rendering: -webkit-optimize-contrast;
}

#magazine .turn-page-corner {
  pointer-events: auto !important;
}

.open-album {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto !important;
}

/* PANEL DE CARTAS */
.cards-panel {
  position: absolute;
  top: 19.1%;
  width: 15.1%;
  height: 62.2%;
  z-index: 6;

  padding: clamp(12px, 1.6vw, 24px) clamp(8px, 1.2vw, 18px);
  display: flex;
  flex-direction: column;
  align-items: center;

  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  background: linear-gradient(
    110deg,
    rgba(32, 80, 158, 0.9),
    rgba(78, 121, 164, 0.72)
  );

  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.25),
    inset 0 0 22px rgba(255, 255, 255, 0.14);

  backdrop-filter: blur(2px);
  overflow: hidden;

  transition: right 0.35s ease, left 0.35s ease;
}

.album-screen.is-cover .cards-panel {
  right: 25.6%;
}

.album-screen.is-spread .cards-panel {
  right: 8.1%;
}

.cards-panel h2 {
  flex: 0 0 auto;
  color: #fff;
  font-size: clamp(18px, 1.2vw, 34px);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  margin: 0 0 clamp(14px, 2vh, 24px);
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}

/* Aquí queda el scroll interno */
.cards-list {
  width: 100%;
  flex: 1;
  min-height: 0;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 2.4vh, 28px);

  overflow-y: auto;
  overflow-x: hidden;

  padding: 4px 0 20px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.cards-list img {
  width: clamp(90px, 68%, 135px);
  height: auto;
  display: block;
  object-fit: contain;

  filter: drop-shadow(0 6px 11px rgba(0, 0, 0, 0.38));
  user-select: none;
  pointer-events: none;
}

/* Scroll bonito */
.cards-list::-webkit-scrollbar {
  width: 6px;
}

.cards-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 20px;
}

.cards-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 20px;
}

.cards-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.75);
}

.back-button {
  position: absolute;
  right: 2.1%;
  bottom: 3.4%;
  z-index: 8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: clamp(90px, 10vw, 160px);
  height: clamp(40px, 5vh, 55px);
  padding: 0 clamp(16px, 2.5vw, 24px) 1px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 7px;
  color: #fff;
  background: rgba(19, 63, 139, 0.82);
  font-size: clamp(15px, 2.2vw, 18px);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
}

.back-button:hover {
  background: rgba(27, 82, 173, 0.92);
}

/* TABLET / PANTALLAS MEDIAS HORIZONTALES */
@media (min-width: 769px) and (max-width: 1180px) and (orientation: landscape) {
  .magazine-stage.page-cover,
  .magazine-stage.page-last {
    left: 25.3%;
  }

  .magazine-stage.page-spread {
    left: 10.6%;
  }

  .album-screen.is-cover .cards-panel {
    right: 24.5%;
  }

  .album-screen.is-spread .cards-panel {
    right: 7.4%;
  }

  .cards-panel {
    width: 16%;
    height: 63%;
  }

  .cards-panel h2 {
    font-size: clamp(18px, 2.2vw, 28px);
  }

  .cards-list img {
    width: clamp(78px, 68%, 118px);
  }
}

/* PANTALLAS BAJITAS */
@media (max-height: 620px) and (orientation: landscape) {
  .cards-panel {
    top: 18%;
    height: 66%;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .cards-panel h2 {
    font-size: clamp(16px, 1.8vw, 26px);
    margin-bottom: 12px;
  }

  .cards-list {
    gap: 14px;
  }

  .cards-list img {
    width: clamp(72px, 62%, 105px);
  }
}

/* CELULAR VERTICAL */
@media (max-width: 768px) and (orientation: portrait) {
  .album-scene {
    width: min(100vw, calc(100svh * 9 / 16));
    height: min(100svh, calc(100vw * 16 / 9));
  }

  .album-bg img {
    object-fit: cover;
  }

  .album-header {
    top: 4%;
    left: 6%;
    right: 6%;
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .album-header h1 {
    font-size: clamp(24px, 8vw, 36px);
  }

  .progress-box {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
  }

  .progress-bar {
    flex: 1;
    width: auto;
    max-width: 220px;
  }

  .magazine-stage.page-cover,
  .magazine-stage.page-last,
  .magazine-stage.page-spread {
    left: 50%;
    top: 23%;
    transform: translateX(-50%);
    width: var(--page-width);
    overflow: hidden;
  }

  .magazine-stage.page-spread #magazine,
  .magazine-stage.page-cover #magazine,
  .magazine-stage.page-last #magazine {
    left: calc(var(--page-width) * -1) !important;
  }

  .cards-panel,
  .album-screen.is-cover .cards-panel,
  .album-screen.is-spread .cards-panel {
    top: auto;
    right: 5%;
    bottom: 9%;
    width: 90%;
    height: 17%;
    padding: 10px 14px;

    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
  }

  .cards-panel h2 {
    flex: 0 0 auto;
    font-size: clamp(18px, 5vw, 26px);
    margin: 0 14px 0 0;
    white-space: nowrap;
  }

  .cards-list {
    flex: 1;
    min-width: 0;
    height: 100%;

    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 18px;

    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 10px 0 0;
  }

  .cards-list img {
    flex: 0 0 auto;
    width: auto;
    height: 88%;
    max-height: 118px;
  }

  .cards-list::-webkit-scrollbar {
    height: 5px;
    width: 5px;
  }

  .back-button {
    right: 4%;
    bottom: 1%;
    min-width: clamp(85px, 22vw, 140px);
    height: clamp(38px, 7vh, 52px);
    font-size: clamp(14px, 3.5vw, 17px);
  }
}