:root {
    --ems-safe-top: env(safe-area-inset-top, 0px);
    --ems-safe-right: env(safe-area-inset-right, 0px);
    --ems-safe-bottom: env(safe-area-inset-bottom, 0px);
    --ems-safe-left: env(safe-area-inset-left, 0px);
}

html,
body {
    min-width: 320px;
    min-height: 100%;
}

body {
    overscroll-behavior: none;
    touch-action: manipulation;
}

.mission-device-layout {
    width: auto;
    max-width: 1680px;
    padding-right: calc(16px + var(--ems-safe-right));
    padding-bottom: calc(16px + var(--ems-safe-bottom));
    padding-left: calc(16px + var(--ems-safe-left));
}

.device-orientation-notice {
    position: fixed;
    z-index: 10000;
    inset: 0;
    display: grid;
    place-content: center;
    gap: 0.75rem;
    padding: 2rem;
    background: rgba(5, 8, 12, 0.96);
    text-align: center;
}

.device-orientation-notice[hidden] {
    display: none;
}

.device-orientation-notice strong {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
}

.device-orientation-notice span {
    max-width: 32rem;
    color: var(--muted, #aab4bc);
    font-size: 1rem;
}

.device-profile-badge {
    position: fixed;
    z-index: 9000;
    right: calc(0.5rem + var(--ems-safe-right));
    bottom: calc(0.5rem + var(--ems-safe-bottom));
    padding: 0.25rem 0.45rem;
    border: 1px solid var(--panel-border, #555);
    border-radius: 0.25rem;
    background: rgba(5, 8, 12, 0.78);
    color: var(--muted, #aab4bc);
    font-size: 0.68rem;
    line-height: 1;
    pointer-events: none;
    opacity: 0.72;
}

.orientation-landscape .ems-topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    padding-top: calc(0.65rem + var(--ems-safe-top));
}

.input-touch button,
.input-touch select,
.input-touch input[type="text"],
.input-touch input[type="number"] {
    min-height: 44px;
}

.input-touch button,
.input-touch select {
    font-size: 1rem;
}

.input-touch .signup-table th,
.input-touch .signup-table td {
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

.device-tablet.orientation-landscape .ems-main,
.device-kiosk.orientation-landscape .ems-main {
    padding: 0;
}

.device-tablet.orientation-landscape .ems-topbar h1,
.device-kiosk.orientation-landscape .ems-topbar h1 {
    font-size: clamp(1.35rem, 2vw, 2rem);
}

.device-tablet.orientation-landscape .ems-topbar p,
.device-kiosk.orientation-landscape .ems-topbar p {
    margin: 0.15rem 0 0;
}

.display-compact.orientation-landscape .signup-table {
    min-width: 920px;
}

.display-compact.orientation-landscape .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.device-tablet .limit-note,
.device-kiosk .limit-note {
    display: none;
}

.adv-mech-choice-cell {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: nowrap;
}

.adv-mech-choice-cell .mech-id-lookup {
    flex: 0 0 4.8rem;
    width: 4.8rem;
    max-width: 4.8rem;
    text-align: center;
}

.adv-mech-choice-cell .mech-chassis-select {
    flex: 1 1 auto;
    min-width: 0;
}

.mech-lookup-status {
    min-height: 1.1rem;
    margin-top: 0.18rem;
    font-size: 0.78rem;
}

.browser-safari .table-wrap {
    -webkit-overflow-scrolling: touch;
}

.browser-firefox select {
    text-overflow: ellipsis;
}

@media (orientation: portrait) and (max-width: 900px) {
    .device-profile-badge {
        display: none;
    }
}

@media (max-height: 720px) and (orientation: landscape) {
    .ems-topbar {
        padding-top: calc(0.4rem + var(--ems-safe-top));
        padding-bottom: 0.4rem;
    }

    .ems-topbar p {
        display: none;
    }

    .mission-sheet-state {
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
    }
}

@media (min-width: 1024px) and (orientation: landscape) {
    .device-orientation-notice {
        display: none !important;
    }
}
