.shelf-page {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  color: #f6efe1;
}

.shelf-page h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.6rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.shelf-page p {
  margin: 0;
  color: rgba(246, 239, 225, 0.85);
  line-height: 1.6;
}

.shelf {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.shelf-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.25rem 1.5rem;
  border: 2px solid #372411;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--panel), rgba(11,11,26,0.6));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02), 0 12px 0 rgba(0,0,0,0.6);
  position: relative;
  min-height: 170px;
  align-items: flex-end;
}

.shelf-row::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -18px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--panel), rgba(11,11,26,0.6));
  box-shadow: 0 6px 6px rgba(0, 0, 0, 0.45);
}

.shelf-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  width: 140px;
  text-align: center;
  flex: 1 1 120px;
  position: relative;
}

.shelf-item figcaption {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(240, 230, 210, 0.95);
}

.shelf-item .shelf-tag {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 230, 0, 0.6);
  background: linear-gradient(135deg, var(--panel), rgba(255, 255, 255, 0.08));
  color: #f6efe1;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  line-height: 1.3;
  white-space: normal;
  max-width: 100%;
}

.shelf-item .shelf-note {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translate3d(-50%, 0.4rem, 0);
  width: min(260px, calc(100% + 1.25rem));
  max-width: 90vw;
  min-width: 180px;
  margin: 0;
  padding: 0.65rem 0.9rem;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
  background: rgba(5, 7, 25, 0.97);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
  text-align: left;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 160ms ease, transform 160ms ease;
  white-space: normal;
  word-break: break-word;
}

.shelf-item.shelf-item--tooltip-visible .shelf-note {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(-50%, 0.9rem, 0);
}

.shelf-cover {
  /* fixed visible cover size (matches the Sophie cover currently shown)
     width and height are fixed so all covers appear the same size */
  width: 140px;
  height: 215px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255,255,255,0.02), rgba(0,0,0,0.06));
  border: none;
  box-shadow: none;
  transition: transform 160ms ease;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shelf-cover img {
  /* make the image fit within the fixed box without stretching.
     'contain' ensures the whole image is visible and keeps its proportions.
     center it and avoid rounding issues by not forcing width/height to 100%. */
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  border-radius: inherit;
}

.shelf-cover--dragon-ball {
  background: radial-gradient(circle at 50% 38%, #ffd84a 0 12%, transparent 13%), linear-gradient(145deg, #ef6b2e, #b51f2b 58%, #321b4d);
  border: 2px solid rgba(255, 230, 0, 0.75);
  color: #fff4b0;
  font-family: Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.04em;
  text-align: center;
  text-shadow: 2px 2px 0 #6e1720;
}

.shelf-cover:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.6);
  outline-offset: 4px;
}

.shelf-cover:hover {
  transform: translateY(-3px);
}

.shelf-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.2rem;
}

.shelf-category {
  font-size: 0.65rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 0.2rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 234, 255, 0.35);
  background: rgba(0, 234, 255, 0.08);
  color: #f6efe1;
}

@media (max-width: 720px) {
  .shelf-row {
    justify-content: center;
  }

  .shelf-item {
    flex: 1 1 140px;
  }
}

@media (max-width: 520px) {
  .shelf-row {
    padding-bottom: 1.8rem;
  }

  .shelf-item {
    width: 120px;
  }

  .shelf-item .shelf-tag {
    font-size: 0.6rem;
    padding: 0.1rem 0.6rem;
    letter-spacing: 0.1em;
  }

  .shelf-meta {
    justify-content: center;
  }
}
