.rim-menu {
    display: flex;
    width: 100%;
    overflow: hidden;
    /* Maintain a fixed overall menu height on desktop */
    /* (align-items: stretch by default keeps all items same height) */
}
.rim-menu-item {
    flex: 1;
    position: relative;
    /* Fixed height on desktop to prevent vertical scaling on hover */
    height: 300px;  /* adjust this value as needed for desired height */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    text-decoration: none;
    /* Only transition the flex property (remove transform scaling) */
    transition: flex 0.3s ease;
}
.rim-menu-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 1.2rem;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
}
/* Active menu item stays larger (flex: 2) but **no** background override so image stays visible */
.rim-menu-item.active {
    flex: 2;
}
/* On hover (desktop): enlarge the hovered item (flex: 2) without changing height */
.rim-menu-item:not(.active):hover {
    flex: 2;
}
/* (Removed the transform: scale(0.9) on inactive items to avoid any vertical shrinking) */

@media (max-width: 800px) {
    .rim-menu {
        flex-direction: column;
        /* NEW: allow vertical scrolling when content exceeds viewport height */
        max-height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;  /* for smooth momentum scrolling on iOS */
    }
    .rim-menu-item {
        width: 100%;
        flex: none;
        /* NEW: fixed height for inactive menu items */
        height: 50px;
    }
    .rim-menu-item.active {
        /* NEW: fixed height for the active menu item */
        height: 100px;
    }
}