/* RHV V125 - Center incomplete final card rows on all subpage card grids.
   Keeps 3-card rows normal, centers a single lonely card, and centers 2-card final rows. */
@media (min-width: 901px) {
  html body .rhv-uniform-card-section .rhv-uniform-grid,
  html body .rhv-final-gallery-section .rhv-uniform-grid {
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 24px !important;
    align-items: stretch !important;
  }

  html body .rhv-uniform-card-section .rhv-uniform-grid > .rhv-uniform-card,
  html body .rhv-final-gallery-section .rhv-uniform-grid > .rhv-uniform-card {
    grid-column: span 2 !important;
    width: 100% !important;
    max-width: none !important;
  }

  /* If the last row has only 1 card, place it in the center column area. */
  html body .rhv-uniform-card-section .rhv-uniform-grid > .rhv-uniform-card:last-child:nth-child(3n + 1),
  html body .rhv-final-gallery-section .rhv-uniform-grid > .rhv-uniform-card:last-child:nth-child(3n + 1) {
    grid-column: 3 / span 2 !important;
  }

  /* If the last row has 2 cards, center them as a pair. */
  html body .rhv-uniform-card-section .rhv-uniform-grid > .rhv-uniform-card:nth-last-child(2):nth-child(3n + 1),
  html body .rhv-final-gallery-section .rhv-uniform-grid > .rhv-uniform-card:nth-last-child(2):nth-child(3n + 1) {
    grid-column: 2 / span 2 !important;
  }

  html body .rhv-uniform-card-section .rhv-uniform-grid > .rhv-uniform-card:last-child:nth-child(3n + 2),
  html body .rhv-final-gallery-section .rhv-uniform-grid > .rhv-uniform-card:last-child:nth-child(3n + 2) {
    grid-column: 4 / span 2 !important;
  }
}

@media (min-width: 641px) and (max-width: 900px) {
  html body .rhv-uniform-card-section .rhv-uniform-grid,
  html body .rhv-final-gallery-section .rhv-uniform-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 22px !important;
  }

  html body .rhv-uniform-card-section .rhv-uniform-grid > .rhv-uniform-card,
  html body .rhv-final-gallery-section .rhv-uniform-grid > .rhv-uniform-card {
    grid-column: span 2 !important;
  }

  /* Tablet/iPad: if one card is alone on the last row, center it. */
  html body .rhv-uniform-card-section .rhv-uniform-grid > .rhv-uniform-card:last-child:nth-child(2n + 1),
  html body .rhv-final-gallery-section .rhv-uniform-grid > .rhv-uniform-card:last-child:nth-child(2n + 1) {
    grid-column: 2 / span 2 !important;
  }
}

@media (max-width: 640px) {
  html body .rhv-uniform-card-section .rhv-uniform-grid,
  html body .rhv-final-gallery-section .rhv-uniform-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  html body .rhv-uniform-card-section .rhv-uniform-grid > .rhv-uniform-card,
  html body .rhv-final-gallery-section .rhv-uniform-grid > .rhv-uniform-card {
    grid-column: auto !important;
  }
}