/* Shared phone/tablet adaptation layered over the desktop design. */
:root {
    --mobile-safe-top: env(safe-area-inset-top, 0px);
    --mobile-safe-right: env(safe-area-inset-right, 0px);
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-safe-left: env(safe-area-inset-left, 0px);
}

html {
    width: 100%;
    min-height: 100%;
    background: #111827;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    touch-action: manipulation;
}

body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    padding-left: var(--mobile-safe-left);
    padding-right: var(--mobile-safe-right);
    padding-bottom: var(--mobile-safe-bottom);
    box-sizing: border-box;
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
}

*, *::before, *::after {
    box-sizing: border-box;
}

button,
[role="button"],
input,
select,
textarea,
a {
    touch-action: manipulation;
}

button,
[role="button"],
input[type="button"],
input[type="submit"],
select {
    min-height: 44px;
}

input,
select,
textarea {
    font-size: max(16px, 1em);
}

button:active,
[role="button"]:active,
a:active {
    transform: scale(0.98);
}

img,
svg,
canvas {
    max-width: 100%;
}

.fullscreen-btn {
    display: none !important;
}

/* Keep the result-screen home label and icon centered as one unit. */
html.mobile-app #homeBtn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.45rem !important;
    text-align: center !important;
}

html.mobile-app #homeBtn .btn-text,
html.mobile-app #homeBtn .btn-icon {
    flex: 0 0 auto !important;
    margin: 0 !important;
    line-height: 1 !important;
}

html.mobile-app #homeBtn .btn-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.modal,
.dialog,
[class*="modal-content"],
[class*="dialog-content"] {
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100dvh - 24px) !important;
}

@supports (height: 100dvh) {
    body,
    .app-container,
    .page-container,
    .main-container {
        min-height: 100dvh;
    }
}

@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    h1 {
        font-size: clamp(1.55rem, 8vw, 2.35rem) !important;
        line-height: 1.1 !important;
    }

    h2 {
        font-size: clamp(1.2rem, 6vw, 1.75rem) !important;
    }

    .container,
    .app-container,
    .page-container,
    .main-container,
    .content,
    main {
        width: 100% !important;
        max-width: 100% !important;
    }

    .header,
    header,
    .top-bar,
    .toolbar,
    .actions,
    .footer,
    footer {
        max-width: 100%;
    }

    .button-group,
    .actions,
    .footer-actions,
    .navigation-buttons,
    .control-row {
        flex-wrap: wrap;
    }

    .table-container,
    .table-wrapper,
    .matrix-container,
    .matrix-wrapper,
    .results-table-container,
    [class*="table-scroll"],
    [class*="matrix-scroll"] {
        width: 100%;
        max-width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 0.82rem;
    }

    th,
    td {
        padding: 0.55rem 0.45rem;
    }

    .toast,
    .notification,
    .alert-message {
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        max-width: none !important;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    .container,
    .app-container,
    .page-container,
    .main-container,
    .content,
    main {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    button,
    .btn,
    [class*="-btn"] {
        max-width: 100%;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    h1 {
        font-size: 1.55rem !important;
    }

    .header,
    header {
        padding-top: 8px !important;
        padding-bottom: 8px !important;
    }
}
