* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    margin: 0;
    overflow-x: hidden;
    background: #eef2f7;
    color: #172033;
    font-family: Arial, "Microsoft JhengHei", sans-serif;
    -webkit-text-size-adjust: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
}

.buy-app {
    min-height: 100vh;
    background: #eef2f7;
}

.compat-cashspan {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.buy-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: #ffffff;
    border-bottom: 1px solid #dbe3ef;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.buy-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 10px 14px;
}

.brand img {
    width: 168px;
    max-width: 38vw;
    height: auto;
}

.buy-title {
    display: grid;
    min-width: 0;
    margin-left: auto;
    text-align: right;
}

.buy-title strong {
    overflow: hidden;
    color: #991b1b;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.buy-title span {
    color: #64748b;
    font-size: 12px;
}

.member-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    min-height: 38px;
    padding: 5px 9px;
    color: #172033;
    background: #f8fafc;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
}

.member-chip span:first-child {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: #ffffff;
    background: #991b1b;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 800;
}

.member-chip strong {
    display: block;
    max-width: 130px;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-chip small {
    display: block;
    color: #059669;
    font-size: 12px;
    font-weight: 800;
}

.buy-main {
    display: grid;
    gap: 14px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px;
}

.game-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(106px, 1fr));
    gap: 8px;
    overflow: visible;
    padding: 0;
}

.game-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    min-height: 48px;
    padding: 7px 9px;
    color: #334155;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
    cursor: pointer;
}

.game-tab-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;
    width: 42px;
    height: 30px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.game-tab-logo img {
    display: block;
    max-width: 36px;
    max-height: 22px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.game-tab-text {
    min-width: 0;
    overflow: hidden;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.15;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-tab.is-active {
    color: #ffffff;
    background: #991b1b;
    border-color: #991b1b;
}

.game-tab.is-active .game-tab-logo {
    background: #ffffff;
    border-color: rgba(255, 255, 255, 0.75);
}

.buy-layout {
    display: grid;
    gap: 14px;
}

.game-panel,
.side-panel {
    min-width: 0;
    background: #ffffff;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 52px;
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
}

.panel-head h1,
.panel-head h2 {
    margin: 0;
    color: #172033;
    font-size: 18px;
}

.panel-head span {
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.panel-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    flex: 0 0 auto;
}

.panel-actions a,
.panel-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 11px;
    color: #334155;
    background: #f8fafc;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.frame-wrap {
    position: relative;
    width: 100%;
    min-width: 0;
    min-height: 460px;
    overflow: hidden;
    background: #f8fafc;
}

.frame-loading {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: none;
    min-height: 460px;
    padding: 28px 14px;
    color: #64748b;
    background: #ffffff;
    text-align: center;
    font-size: 14px;
    pointer-events: none;
}

#gameiframe {
    display: block;
    width: 100%;
    min-height: 460px;
    border: 0;
    background: #ffffff;
    opacity: 0;
    visibility: hidden;
    transition: opacity 120ms ease;
}

#gameiframe.is-ready {
    visibility: visible;
    opacity: 1;
}

.side-panel {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.balance-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.balance-card span {
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
}

.balance-card strong {
    color: #059669;
    font-size: 22px;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.action-grid a,
.full-action {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 10px;
    color: #ffffff;
    background: #991b1b;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 800;
}

.action-grid a:nth-child(2) {
    background: #0f766e;
}

.full-action {
    color: #172033;
    background: #fef3c7;
    border: 1px solid #fde68a;
}

.status-button,
.draw-button,
.mobile-status,
.mobile-draw {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 11px;
    color: #ffffff;
    background: #991b1b;
    border: 0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.draw-button,
.mobile-draw {
    background: #0f766e;
}

.mobile-checkout-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 48;
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    background: #ffffff;
    border-top: 1px solid #dbe3ef;
    box-shadow: 0 -12px 28px rgba(15, 23, 42, 0.18);
}

.mobile-checkout-meta {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 8px 9px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.mobile-checkout-meta span {
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
}

.mobile-checkout-meta strong {
    overflow: hidden;
    color: #991b1b;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-agree {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 6px;
    color: #334155;
    font-size: 13px;
    font-weight: 800;
}

.mobile-agree input {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.mobile-status {
    min-height: 42px;
    background: #334155;
}

.mobile-draw {
    min-height: 42px;
}

.mobile-submit {
    min-height: 42px;
    color: #ffffff;
    background: #991b1b;
    border: 0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
}

.mobile-submit:disabled {
    color: #94a3b8;
    background: #e2e8f0;
    cursor: not-allowed;
}

.order-drawer {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
}

.draw-result-viewer {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: none;
    background: #f4f7fb;
}

.draw-result-viewer.is-open {
    display: block;
}

.draw-result-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: #f4f7fb;
}

.draw-result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 54px;
    padding: 10px 12px;
    background: #ffffff;
    border-bottom: 1px solid #dbe3ef;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.draw-result-head strong {
    min-width: 0;
    overflow: hidden;
    color: #172033;
    font-size: 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.draw-result-head button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    color: #334155;
    background: #f8fafc;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

#draw-result-frame {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    border: 0;
    background: #ffffff;
}

.order-drawer.is-open {
    display: block;
}

.order-drawer-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    background: rgba(15, 23, 42, 0.55);
    border: 0;
    cursor: pointer;
}

.order-drawer-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    max-height: 88vh;
    max-height: 88dvh;
    overflow: auto;
    background: #f4f7fb;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -18px 40px rgba(15, 23, 42, 0.26);
}

.drawer-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
}

.drawer-head strong {
    color: #172033;
    font-size: 16px;
}

.drawer-head button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: #334155;
    background: #f8fafc;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.order-drawer-content {
    min-height: 180px;
    padding: 12px;
    overflow-x: hidden;
    color: #172033;
    font-size: 14px;
    background: #f4f7fb;
}

.order-drawer-content * {
    max-width: 100% !important;
    box-sizing: border-box;
}

.order-drawer-content table {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: auto;
    border-spacing: 1px !important;
}

.order-drawer-content td {
    max-width: 100%;
    white-space: normal;
    word-break: break-all;
    overflow-wrap: anywhere;
}

.order-drawer-content img {
    max-width: 100%;
    height: auto;
}

.drawer-report-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    margin-bottom: 10px;
    color: #ffffff;
    background: #991b1b;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 800;
}

.drawer-empty {
    padding: 24px 12px;
    color: #64748b;
    text-align: center;
    font-size: 14px;
}

.drawer-status-summary,
.drawer-status-section,
.drawer-status-flow {
    margin-bottom: 10px;
    background: #ffffff;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}

.drawer-status-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
    padding: 9px 10px;
}

.drawer-summary-line {
    color: #334155;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
}

.drawer-summary-line.is-accent {
    color: #991b1b;
}

.drawer-status-title {
    padding: 8px 10px;
    color: #ffffff;
    background: #334155;
    border-radius: 8px 8px 0 0;
    font-size: 14px;
    font-weight: 800;
}

.drawer-status-list {
    display: grid;
    gap: 6px;
    padding: 7px;
    background: #eef2f7;
    border-radius: 0 0 8px 8px;
}

.drawer-status-card {
    display: grid;
    grid-template-columns: 42px minmax(0, 1.4fr) minmax(0, 1fr) 58px;
    gap: 0;
    padding: 0;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #dbe3ef;
    border-radius: 7px;
}

.drawer-status-card.is-bingo {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    overflow: hidden;
    border-color: #d7e1ee;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.04);
}

.bingo-card-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    background: #ffffff;
    border-bottom: 1px solid #e5edf6;
}

.bingo-no {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 26px;
    color: #ffffff;
    background: #334155;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 900;
}

.bingo-id {
    min-width: 0;
    color: #0f172a;
    font-size: 13px;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.bingo-time {
    color: #475569;
    font-size: 12px;
    font-weight: 800;
}

.bingo-number {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 9px 10px;
    background: #f8fafc;
    border-bottom: 1px solid #e5edf6;
}

.bingo-number span,
.bingo-meta span {
    color: #64748b;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0;
}

.bingo-number strong {
    min-width: 0;
    color: #172033;
    font-size: 15px;
    font-weight: 900;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.bingo-card-stats,
.bingo-card-footer {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bingo-card-footer {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    background: #ffffff;
}

.bingo-meta {
    display: grid;
    gap: 3px;
    min-width: 0;
    padding: 8px 10px;
    border-right: 1px solid #e5edf6;
    border-bottom: 1px solid #e5edf6;
}

.bingo-meta:last-child {
    border-right: 0;
}

.bingo-card-footer .bingo-meta {
    border-bottom: 0;
}

.bingo-meta strong {
    min-width: 0;
    color: #172033;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.bingo-meta.is-money {
    background: #fff7ed;
}

.bingo-meta.is-money strong {
    color: #9f1239;
}

.bingo-meta.is-status {
    background: #f0fdf4;
}

.bingo-meta.is-status strong {
    color: #b91c1c;
}

.drawer-status-card.is-power {
    border-color: #ead0df;
}

.drawer-status-card.is-power .bingo-no {
    background: #b0005b;
}

.drawer-status-card.is-power .bingo-number {
    background: #fff7fb;
}

.drawer-status-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    align-items: start;
    min-height: 44px;
    padding: 6px 7px;
    border-right: 1px solid #eef2f7;
    border-bottom: 1px solid #eef2f7;
}

.drawer-status-field:last-child {
    border-right: 0;
}

.drawer-status-field span {
    color: #64748b;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.1;
}

.drawer-status-field strong {
    min-width: 0;
    color: #172033;
    font-size: 12px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.drawer-status-card.is-current .drawer-status-field:nth-child(1) {
    grid-row: span 2;
    align-content: center;
    text-align: center;
    background: #fff7ed;
}

.drawer-status-card.is-current .drawer-status-field:nth-child(5) {
    grid-column: 2 / span 1;
}

.drawer-status-card.is-current .drawer-status-field:nth-child(8),
.drawer-status-card.is-current .drawer-status-field:nth-child(9) {
    grid-column: span 2;
    min-height: 38px;
    background: #f8fafc;
}

.drawer-status-card.is-current .drawer-status-field:nth-child(9) strong {
    color: #991b1b;
    font-weight: 900;
}

.drawer-status-card.is-previous .drawer-status-field:nth-child(3) {
    grid-column: span 2;
}

.drawer-status-card.is-previous .drawer-status-field:nth-child(5) {
    grid-column: span 2;
    background: #f8fafc;
}

.drawer-status-empty {
    padding: 14px 10px;
    color: #64748b;
    text-align: center;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
}

.drawer-status-flow {
    padding: 12px;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.5;
}

body.drawer-open {
    overflow: hidden;
}

.help-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.help-list li {
    padding: 10px 11px;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
}

.login-required {
    display: grid;
    gap: 14px;
    max-width: 480px;
    margin: 72px auto;
    padding: 24px;
    text-align: center;
    background: #ffffff;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
}

.login-required h1 {
    margin: 0;
    color: #991b1b;
    font-size: 24px;
}

.login-required p {
    margin: 0;
    color: #64748b;
}

.login-required a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    color: #ffffff;
    background: #991b1b;
    border-radius: 8px;
    font-weight: 800;
}

@media (min-width: 900px) {
    .buy-layout {
        grid-template-columns: minmax(0, 1fr) 286px;
        align-items: start;
    }

    .side-panel {
        position: sticky;
        top: 78px;
    }
}

@media (max-width: 560px) {
    .buy-topbar {
        padding: 8px 10px;
    }

    .buy-title {
        display: none;
    }

    .member-chip strong {
        max-width: 92px;
    }

    .buy-main {
        padding: 10px 10px 164px;
    }

    .game-tab {
        min-height: 44px;
        padding: 6px 8px;
    }

    .game-tab-logo {
        flex-basis: 38px;
        width: 38px;
        height: 28px;
    }

    .game-tab-logo img {
        max-width: 32px;
        max-height: 20px;
    }

    .game-tab-text {
        font-size: 12px;
    }

    .panel-head {
        min-height: 48px;
        padding: 10px 12px;
    }

    #gameiframe {
        min-height: 460px;
    }

    .status-button {
        display: none;
    }

    .side-panel {
        display: none;
    }

    .mobile-checkout-bar {
        display: grid;
    }

    .mobile-agree {
        grid-column: 1 / -1;
        min-height: 32px;
    }

    .mobile-submit,
    .mobile-status {
        width: 100%;
    }

    .order-drawer-content {
        padding: 10px;
        font-size: 13px;
    }

    .order-drawer-content table,
    .order-drawer-content tbody,
    .order-drawer-content tr,
    .order-drawer-content td {
        display: block !important;
        width: 100% !important;
    }

    .order-drawer-content table {
        min-width: 0 !important;
        margin: 0 0 10px !important;
        border-spacing: 0 !important;
    }

    .order-drawer-content tr {
        margin: 0 0 8px !important;
        overflow: hidden;
        background: #ffffff !important;
        border: 1px solid #dbe3ef !important;
        border-radius: 8px;
    }

    .order-drawer-content td {
        padding: 7px 8px !important;
        color: #172033 !important;
        background: #ffffff !important;
        border: 0 !important;
        border-bottom: 1px solid #eef2f7 !important;
        font-size: 12px !important;
        line-height: 1.45 !important;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .order-drawer-content tr td:first-child,
    .order-drawer-content td[colspan] {
        color: #ffffff !important;
        background: #991b1b !important;
        font-weight: 800 !important;
    }

    .order-drawer-content tr td:last-child {
        border-bottom: 0 !important;
    }

    .order-drawer-content table table {
        display: block !important;
        margin-bottom: 8px !important;
    }

    .drawer-report-link {
        min-height: 38px;
        font-size: 13px;
    }

    .drawer-status-list {
        gap: 5px;
        padding: 6px;
    }

    .drawer-status-card {
        grid-template-columns: 38px minmax(0, 1.35fr) minmax(0, 1fr) 52px;
    }

    .drawer-status-card.is-bingo {
        grid-template-columns: minmax(0, 1fr);
    }

    .drawer-status-field {
        min-height: 40px;
        padding: 5px 6px;
    }

    .drawer-status-field strong {
        font-size: 12px;
    }
}

@media (min-width: 700px) {
    .order-drawer-panel {
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: min(420px, 92vw);
        max-height: none;
        border-radius: 0;
    }
}
