@media only screen and (max-width: 768px) {
    /* Fix Main Layout Whitespace */
    main {
        width: 96% !important;
        margin: 0 auto !important;
        margin-bottom: 80px !important;
    }

    /* Expand Plan Card to full width on mobile */
    .plan-card {
        max-width: 100% !important;
        width: 100% !important;
        padding: 10px !important;
        margin: 10px 0 !important;
        box-shadow: none !important;
        border: 1px solid #e0e0e0;
    }

    /* Adjust Roulette Container */
    .roulette-container {
        padding: 15px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    /* Header Adjustments */
    header {
        padding: 0px 0px !important;
    }
    header h1 {
        font-size: 1.15em !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    header i {
        margin: 20px 5px;
    }
    
    .logo {
        font-size: 1.3rem !important;
    }
    
    .tagline {
        display: none; /* Hide tagline to save space */
    }

    /* Recipe Card (Menu Block) Styling */
    .menu-block {
        padding-bottom: 0;
        margin-bottom: 0;
        border-bottom: 1px solid #eee;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Hide the HR since we use border-bottom for cleaner look */
    .menu-block + hr {
        height: 2px;
        display: block;
        padding: 0;
        margin: 0;
    }


    .row:has(#saveMenu){
        margin-top: 10px !important;
    } 

    /* Adjust Image Size */
    .fit-menu-image {
        max-width: 65px !important;
        max-height: 65px !important;
        object-fit: cover;
        border-radius: 4px;
    }

    /* Compact Input Groups */
    .input-group-text {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.8rem !important;
    }

    .form-select, .form-control {
        padding: 0.25rem .25rem 0.25rem 0.5rem !important;
        font-size: 0.9rem !important;
        background-position: right 0.25rem center !important;
    }

    /* Reduce Grid Padding */
    .menu-block .col, .menu-block .col-auto {
        padding-left: 0px !important;
        padding-right: 0px !important;
    }

    /* Theme Text */
    .theme-text-menu {
        font-size: 0.95rem !important;
        margin-bottom: 8px !important;
        color: #555;
    }

    main .container , main .card-body {
        padding: 0 !important;
        margin: 0 !important;
    }

    /* GRID LAYOUT FOR MENU BLOCK */
    
    /* Target the row holding Image and Inputs */
    .menu-block > .col > .container > .row:nth-child(2) {
        display: grid !important;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto auto;
        column-gap: 10px;
        row-gap: 5px;
        align-items: center;
        margin: 0 !important;
    }

    /* Flatten the Inputs Column structure */
    .menu-block > .col > .container > .row:nth-child(2) > .col,
    .menu-block > .col > .container > .row:nth-child(2) > .col > .container,
    .menu-block > .col > .container > .row:nth-child(2) > .col > .container > .row {
        display: contents !important;
    }

    /* Image Wrapper */
    .menu-block > .col > .container > .row:nth-child(2) > .col-auto:first-child {
        grid-column: 1;
        grid-row: 1 / span 2;
        align-self: start;
        justify-self: center;
    }

    /* Entree Wrapper */
    .menu-block > .col > .container > .row:nth-child(2) > .col > .container > .row:nth-child(1) > .col {
        grid-column: 2;
        grid-row: 1;
        width: 100%;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Side 1 Wrapper */
    .menu-block > .col > .container > .row:nth-child(2) > .col > .container > .row:nth-child(2) > .col:nth-child(1) {
        grid-column: 2;
        grid-row: 2;
        width: 100%;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Side 2 Wrapper */
    .menu-block > .col > .container > .row:nth-child(2) > .col > .container > .row:nth-child(2) > .col:nth-child(2) {
        grid-column: 2;
        grid-row: 3;
        width: 100%;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Servings Wrapper */
    .menu-block > .col > .container > .row:nth-child(2) > .col > .container > .row:nth-child(2) > .col-auto {
        grid-column: 1;
        grid-row: 3;
        width: 100%;
        padding: 0 !important;
    }

    /* Hide input group labels for Entree and Sides to save space */
    .menu-block .col > .input-group > .input-group-text {
        display: none !important;
    }

    .menu-block .input-group, .menu-block select {
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .menu-block .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Shopping List Mobile Optimization */
    #shoppinglist .row {
        flex-wrap: nowrap !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        align-items: center;
        border-bottom: 1px solid #eee;
        padding: 5px 0;
    }

    #shoppinglist .col, #shoppinglist .col-auto {
        padding-left: 2px !important;
        padding-right: 2px !important;
        font-size: 0.75rem !important;
    }

    #shoppinglist p {
        margin-bottom: 0 !important;
        font-size: 0.75rem !important;
        line-height: 1.2;
    }

    #shoppinglist input {
        font-size: 0.75rem !important;
        padding: 2px !important;
        height: auto !important;
    }

    .shoppinglistheader {
        background-color: #f8f9fa;
        border-bottom: 2px solid #dee2e6 !important;
    }
    
    .front-page-buttons-action{
        width:100%; 
        font-size: .8em;
    }

    /* Fix footer navigation spacing on mobile - only for pages with navigation */
    footer:has(nav) {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        padding: 5px 0;
    }

    footer nav {
        margin: 0;
        padding: 0;
    }

    footer nav a {
        padding: 8px 4px;
        text-align: center;
        display: flex;
        flex-direction: column-reverse;
        align-items: center;
        justify-content: center;
        gap: 4px;
        text-decoration: none;
        color: #666;
        transition: color 0.2s;
    }

    footer nav a.active-tab {
        color: #0071ce;
    }
    
    footer nav a.active-tab p {
        margin: 0;
        line-height: 1;
    }
    
    footer nav a.active-tab i {
        margin: 0;
        line-height: 1;
    }

    footer nav a p {
        font-size: 0.65rem;
        margin: 0;
        line-height: 1;
    }

    footer nav a i {
        font-size: 1.2rem;
        margin: 0;
        line-height: 1;
    }
    #toast-container{
        max-width: 80%
    }
    
}