@media only screen and (max-width: 768px) {
    /* Root Elements */
    html, body {
        width: 100%;
        max-width: 100vw;
        margin: 0;
        padding: 0;
        overflow-x: hidden !important;
/*        -webkit-overflow-scrolling: touch;*/
        -webkit-overflow-x: hidden !important;
    }

    /* Main */
    main {
        width: 100%;
        max-width: 100vw;
        margin: 0;
        padding: 1rem 0 0 0;
        overflow-x: hidden;
        -webkit-overflow-x: hidden;
    }

    /* Container */
    div.container.body-content {
        width: 100%;
        max-width: 100vw;
        padding: 10px;
        box-sizing: border-box;
        overflow-x: hidden !important;
        -webkit-overflow-x: hidden !important;
    }

    /* Page Body */
    .page-body {
        width: min(max-content, 100%);
        max-width: 100%;
        overflow-x: hidden;
        -webkit-overflow-x: hidden;
        box-sizing: border-box;
        padding: 0;
        touch-action: pan-y;
    }

    /* Tiles */
    .tile.company, .tile.driver, .tile.pre-register {
        width: min(max-content, 100%);
        max-width: 100%;
        margin: 0;
        padding: 10px;
        box-sizing: border-box;
        touch-action: pan-y;
    }

    .tile-body .row, .tile-body .row.success {
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
    }

    .tile-body .col-xs-12, .tile-body .col-md-6 {
        padding-left: 5px;
        padding-right: 5px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Form Elements */
    .form-control, .form-control-md {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    select.form-control {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        width: min(max-content, 100%);
        max-width: 100%;
        text-overflow: ellipsis;
        -webkit-text-overflow: ellipsis;
        -webkit-box-sizing: border-box;
    }

    .tile-body form {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .tile-body input, .tile-body select {
        touch-action: none;
    }

        .tile-body input:focus, .tile-body select:focus {
            width: min(max-content, 100%);
            max-width: 100%;
            box-sizing: border-box;
            -webkit-overflow-x: hidden;
        }

    .pac-container, .pac-item {
        width: min(max-content, calc(100vw - 30px)) !important;
        max-width: calc(100vw - 30px) !important;
        box-sizing: border-box;
        left: 10px !important;
    }

    .error-message, .disableValidation {
        width: 100%;
        max-width: 100%;
        word-wrap: break-word;
    }

    /* Dynamic Content (TransporterList, DriverList) */
    .radio-group, .radio-loop, [data-bind*="foreach"] {
        width: min(max-content, 100%);
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden !important;
        -webkit-overflow-x: hidden !important;
    }

        .radio-loop .radio, [data-bind*="foreach"] * {
            width: min(max-content, 100%);
            max-width: 100%;
            word-wrap: break-word;
        }

    .alert-p.alert-warning {
        width: 100%;
        max-width: 100%;
        word-wrap: break-word;
    }

    /* Success Content (Driver Form-3, Transporter Form-3) */
    .tile-body p, .tile-body ul, .tile-body ul.iaa-id, .tile-body ul.iaa-id li {
        width: min(max-content, 100%);
        max-width: 100%;
        word-wrap: break-word;
        box-sizing: border-box;
    }

    .success-mark {
        display: flex;
        width: 3.5rem;
        height: 3.5rem;
        margin: 0 auto 1rem;
        border: 2px solid #238723;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

        .success-mark .icon-check {
            display: inline-block;
            width: 2rem;
            height: 2rem;
        }

    .icon-check svg {
        width: 2rem;
        height: 2rem;
        display: block;
        margin: 0 auto;
    }

    .list-bullet, .iaa-id {
        padding-left: 20px;
        margin: 0;
        width: 100%;
    }

        .list-bullet li, .iaa-id li {
            word-wrap: break-word;
        }

    /* Driver Section (Transporter Form-2) */
    .uploaded-image-wrapper, #dvImageSection {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

        .uploaded-image-wrapper img {
            max-width: 100%;
            height: auto;
        }

    .tile-head-driver, .tile-head-driver h3 {
        width: 100%;
        max-width: 100%;
        word-wrap: break-word;
    }

    /* Modal Styles */
    .modal {
        z-index: 9999 !important; /* CHANGED: Ensured base z-index */
    }

    .modal-backdrop {
        z-index: 1000; /* CHANGED: Ensured base z-index */
        position: fixed; /* ADDED: Explicit positioning */
        top: 0; /* ADDED */
        left: 0; /* ADDED */
        width: 100%; /* ADDED */
        height: 100%; /* ADDED */
    }

    .modal-open .modal {
        overflow-x: hidden;
        overflow-y: hidden;
        -webkit-overflow-x: hidden;
        -webkit-overflow-y: hidden;
    }

    .modal-dialog {
        z-index: 9999 !important; /* CHANGED: Ensured dialog is above backdrop */
        position: relative;
        /* will-change: transform; */ /* REMOVED: Avoid stacking context issues */
    }

        .modal-dialog.modal-sm {
            width: min(max-content, calc(100vw - 30px));
            max-width: calc(100vw - 30px);
            max-height: calc(100vh - 20px);
            margin: 10px auto;
            box-sizing: border-box;
            touch-action: pan-y;
        }

    .modal-content {
        width: min(max-content, 100%);
        max-width: 100%;
        max-height: calc(100vh - 20px);
        overflow: hidden;
        -webkit-overflow: hidden;
        box-sizing: border-box;
    }

    .modal-header, .modal-body, .modal-footer {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        padding: 10px;
    }

    .modal-body {
        max-height: calc(100vh - 100px);
        overflow: hidden;
    }

        .modal-body p, .modal-body h5, .modal-body .checkbox label {
            width: 100%;
            max-width: 100%;
            word-wrap: break-word;
            overflows: hidden;
            text-overflow: ellipsis;
        }

        .modal-body .checkbox {
            overflow: hidden;
        }

    .checkbox input[type="checkbox"] {
        margin-right: 5px;
    }

    .checkbox label {
        font-size: 0.9rem;
    }

    .modal-footer {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 10px;
        overflow: hidden;
    }

        .modal-footer .btn-container {
            width: auto;
            max-width: 100%;
        }

        .modal-footer .btn {
            flex: 1;
            min-width: 80px;
            max-width: 100%;
        }

    .modal.fade .modal-dialog {
        z-index: 9999 !important; /* CHANGED: Consistent z-index */
        position: relative;
    }

    .modal.in .modal-dialog {
        z-index: 9999 !important; /* CHANGED: Consistent z-index */
        position: relative;
    }

    /* iOS-Specific Modal Fix */
    @supports (-webkit-overflow-scrolling: touch) {
        .modal {
            z-index: 9999 !important; /* CHANGED: Higher z-index for iOS */
        }

        .modal-dialog {
            z-index: 9999 !important; /* CHANGED: Ensure dialog is above backdrop */
            position: relative;
            transform: none !important; /* ADDED: Disable transforms to avoid stacking issues */
        }

        .modal-backdrop {
            z-index: 1000; /* CHANGED: Lower z-index for backdrop */
        }

        .modal.fade .modal-dialog,
        .modal.in .modal-dialog {
            z-index: 9999 !important; /* CHANGED: Consistent z-index */
        }
    }

    /* Existing Styles */
    header {
        padding: 0;
    }

        header .logo {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
            padding: 10px 0;
        }

            header .logo img {
                max-width: 80px;
                height: auto;
            }

    .page-body.page-body-sm#TransPickId {
        padding: 0;
    }

    .tile.pre-register .tile-head {
        text-align: center;
        margin-bottom: 12px;
        margin-left: 0;
        margin-right: 0;
    }

    .tile.pre-register .tile-body {
        padding: 0;
    }

    .tile-body label {
        margin-bottom: 1rem;
    }

    .radio-group.d-flex {
        flex-direction: column;
        gap: 8px;
    }

    .radio-group .radio {
        margin-right: 0;
    }

        .radio-group .radio input[type="radio"] {
            margin-right: 4px;
        }

    .g-recaptcha#dvCaptcha {
        transform: scale(0.77);
        transform-origin: 0 0;
        margin: 8px auto;
        max-width: 304px;
        width: 100%;
    }

    .btn.btn-md.btn-primary#btnPreRegister {
        width: 100%;
        padding: 8px;
        margin-top: 1rem;
        margin-bottom: 1rem;
    }

    .overlay#dvLoader {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 1000;
    }

        .overlay#dvLoader .linear-loader {
            width: 80%;
            max-width: 280px;
        }

    footer.footer-align {
        text-align: center;
        padding: 8px 0;
    }

        footer.footer-align p {
            margin: 4px 0;
        }

        footer.footer-align a {
            margin: 0 4px;
        }

    hr {
        display: none;
    }

    /* Narrow Viewport Fix (S8+) */
    @media only screen and (max-width: 360px) {
        div.container.body-content {
            width: 100%;
            max-width: 100vw;
            padding: 5px;
        }

        .modal-dialog.modal-sm {
            width: 100%;
            max-width: 100vw;
            margin: 5px auto;
        }

        .pac-container, .pac-item {
            width: 100% !important;
            max-width: 100vw !important;
            left: 5px !important;
        }
    }

    /* Foldable Screen Fix (Z Fold 5) */
/*    @media only screen and (min-width: 400px) and (max-width: 450px) and (max-aspect-ratio: 22/18) {
        div.container.body-content {
            width: 100%;
            max-width: 100vw;
        }
    }*/
}
