html,
body {
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

img {
    max-width: 100%;
    height: auto;
}

.result-mobile-list {
    display: none;
}

@media (max-width: 768px) {
    html.result-rwd-loading {
        background: #f4f7fb !important;
    }

    html.result-rwd-loading body > * {
        opacity: 0;
    }

    html.result-rwd-loading body::before {
        content: "\8f09\5165\4e2d";
        position: fixed;
        left: 50%;
        top: 50%;
        z-index: 99999;
        width: 104px;
        height: 104px;
        display: grid;
        place-items: end center;
        padding: 0 0 22px;
        box-sizing: border-box;
        color: #b91c1c;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 16px;
        box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
        font: 900 14px/1 Arial, "Microsoft JhengHei", sans-serif;
        transform: translate(-50%, -50%);
    }

    html.result-rwd-loading body::after {
        content: "";
        position: fixed;
        left: 50%;
        top: calc(50% - 14px);
        z-index: 100000;
        width: 28px;
        height: 28px;
        border: 4px solid #fee2e2;
        border-top-color: #b91c1c;
        border-radius: 999px;
        animation: result-spin 0.75s linear infinite;
        transform: translate(-50%, -50%);
    }

    @keyframes result-spin {
        to {
            transform: translate(-50%, -50%) rotate(360deg);
        }
    }

    html.result-rwd-active {
        background: #f4f7fb !important;
    }

    body {
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        background: #f4f7fb !important;
        color: #172033;
        font-family: Arial, "Microsoft JhengHei", sans-serif;
    }

    html.result-rwd-active body > *:not(.result-rwd-page) {
        display: none !important;
    }

    .result-rwd-page {
        box-sizing: border-box;
        display: block;
        width: 100%;
        max-width: 430px;
        min-height: 100vh;
        margin: 0 auto;
        padding: 10px;
        background: #f4f7fb;
    }

    .result-rwd-header {
        display: flex;
        align-items: center;
        gap: 10px;
        min-height: 44px;
        margin: 0 0 8px;
        padding: 0 4px;
    }

    .result-rwd-back {
        flex: 0 0 auto;
        min-height: 34px;
        padding: 6px 10px;
        color: #334155;
        background: #ffffff;
        border: 1px solid #cbd5e1;
        border-radius: 8px;
        font-size: 13px;
        font-weight: 800;
    }

    .result-rwd-title {
        min-width: 0;
        color: #111827;
        font-size: 18px;
        font-weight: 800;
        line-height: 1.25;
    }

    body > div[align="center"],
    table.hk,
    table[width="1000"],
    table[width="995"] {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        border: 0 !important;
    }

    table.hk > tbody > tr > td,
    table[width="995"] > tbody > tr > td {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    #PageContent {
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        background: #ffffff;
        border: 1px solid #dbe3ef;
        border-radius: 8px;
        padding: 10px !important;
    }

    #PageContent > div > table:first-child,
    #PageContent table[width="380"] {
        display: none !important;
    }

    html.has-mobile-result #PageContent table[border="1"] {
        display: none !important;
    }

    .result-mobile-list {
        display: grid;
        gap: 10px;
    }

    .result-mobile-card {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        align-items: start;
        justify-items: center;
        padding: 12px;
        background: #ffffff;
        border: 1px solid #dbe3ef;
        border-radius: 8px;
        box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
    }

    .result-mobile-period {
        color: #b91c1c;
        font-size: 16px;
        font-weight: 900;
        line-height: 1.2;
        text-align: center;
    }

    .result-mobile-date {
        color: #64748b;
        font-size: 13px;
        font-weight: 700;
        text-align: center;
    }

    .result-mobile-balls {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
    }

    .result-mobile-ball {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 30px;
        height: 30px;
        padding: 0 8px;
        color: #ffffff;
        background: #b91c1c;
        border-radius: 999px;
        font-size: 14px;
        font-weight: 900;
    }
}

@media (min-width: 769px) {
    html.result-rwd-active {
        background: #f4f7fb !important;
    }

    html.result-rwd-loading body > * {
        opacity: 0;
    }

    html.result-rwd-active body {
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        background: #f4f7fb !important;
        color: #172033;
        font-family: Arial, "Microsoft JhengHei", sans-serif;
    }

    html.result-rwd-active body > *:not(.result-rwd-page) {
        display: none !important;
    }

    html.result-rwd-active .result-rwd-page {
        box-sizing: border-box;
        display: block;
        width: min(100%, 920px);
        min-height: 100vh;
        margin: 0 auto;
        padding: 18px;
        background: #f4f7fb;
    }

    html.result-rwd-active .result-rwd-header {
        display: flex;
        align-items: center;
        gap: 10px;
        min-height: 44px;
        margin: 0 0 10px;
    }

    html.result-rwd-active .result-rwd-back {
        flex: 0 0 auto;
        min-height: 36px;
        padding: 7px 12px;
        color: #334155;
        background: #ffffff;
        border: 1px solid #cbd5e1;
        border-radius: 8px;
        font-size: 13px;
        font-weight: 800;
        cursor: pointer;
    }

    html.result-rwd-active .result-rwd-title {
        min-width: 0;
        color: #111827;
        font-size: 20px;
        font-weight: 900;
        line-height: 1.25;
    }

    html.result-rwd-active #PageContent {
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        background: #ffffff;
        border: 1px solid #dbe3ef;
        border-radius: 8px;
        padding: 14px !important;
    }

    html.result-rwd-active #PageContent > div > table:first-child,
    html.result-rwd-active #PageContent table[width="380"] {
        display: none !important;
    }

    html.result-rwd-active.has-mobile-result #PageContent table[border="1"] {
        display: none !important;
    }

    html.result-rwd-active .result-mobile-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    html.result-rwd-active .result-mobile-card {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        align-items: start;
        justify-items: center;
        padding: 12px;
        background: #ffffff;
        border: 1px solid #dbe3ef;
        border-radius: 8px;
        box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
    }

    html.result-rwd-active .result-mobile-period {
        color: #b91c1c;
        font-size: 16px;
        font-weight: 900;
        line-height: 1.2;
        text-align: center;
    }

    html.result-rwd-active .result-mobile-date {
        color: #64748b;
        font-size: 13px;
        font-weight: 700;
        text-align: center;
    }

    html.result-rwd-active .result-mobile-balls {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
    }

    html.result-rwd-active .result-mobile-ball {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 30px;
        height: 30px;
        padding: 0 8px;
        color: #ffffff;
        background: #b91c1c;
        border-radius: 999px;
        font-size: 14px;
        font-weight: 900;
    }
}
