:root {
    --page-bg: #f4f8ff;
    --page-text: #0b1b33;
    --text-muted: rgba(11, 27, 51, 0.68);
    --text-soft: rgba(11, 27, 51, 0.82);
    --text-invert: #ffffff;

    --surface: rgba(255, 255, 255, 0.92);
    --surface-solid: #ffffff;
    --surface-soft: rgba(255, 255, 255, 0.70);

    --border: rgba(15, 55, 120, 0.14);
    --border-strong: rgba(15, 55, 120, 0.22);
    --divider: rgba(15, 55, 120, 0.18);

    --shadow-1: 0 6px 16px rgba(11, 27, 51, 0.08);
    --shadow-2: 0 10px 22px rgba(11, 27, 51, 0.12);

    --brand-1: #2f80ed;
    --brand-2: #1b5bd6;
    --brand-soft-08: rgba(47, 128, 237, 0.08);
    --brand-soft-10: rgba(47, 128, 237, 0.10);
    --brand-soft-12: rgba(47, 128, 237, 0.12);
    --brand-soft-14: rgba(47, 128, 237, 0.14);
    --brand-soft-16: rgba(47, 128, 237, 0.16);
    --brand-soft-20: rgba(47, 128, 237, 0.20);

    --header-1: #0c3b8f;
    --header-2: #062a66;
    --header-divider: rgba(255, 255, 255, 0.12);
    --header-chip-bg: rgba(255, 255, 255, 0.10);
    --header-chip-border: rgba(255, 255, 255, 0.16);
    --header-chip-text: rgba(255, 255, 255, 0.88);

    --nav-1: #0a2f72;
    --nav-2: #061f4a;
    --nav-text: rgba(255, 255, 255, 0.72);
    --nav-active-text: var(--brand-1);
    --nav-active-bg: var(--brand-soft-14);

    --danger: #ff3b30;
}

html[data-theme="night"] {
    --page-bg: #0b1020;
    --page-text: #e5e7eb;
    --text-muted: rgba(229, 231, 235, 0.68);
    --text-soft: rgba(229, 231, 235, 0.82);
    --text-invert: #0b1020;

    --surface: rgba(17, 24, 39, 0.92);
    --surface-solid: #111827;
    --surface-soft: rgba(15, 23, 42, 0.85);

    --border: rgba(148, 163, 184, 0.18);
    --border-strong: rgba(148, 163, 184, 0.26);
    --divider: rgba(148, 163, 184, 0.20);

    --shadow-1: 0 10px 26px rgba(0, 0, 0, 0.28);
    --shadow-2: 0 18px 38px rgba(0, 0, 0, 0.36);

    --brand-1: #22d3ee;
    --brand-2: #4f46e5;
    --brand-soft-08: rgba(34, 211, 238, 0.08);
    --brand-soft-10: rgba(34, 211, 238, 0.10);
    --brand-soft-12: rgba(34, 211, 238, 0.12);
    --brand-soft-14: rgba(34, 211, 238, 0.14);
    --brand-soft-16: rgba(34, 211, 238, 0.16);
    --brand-soft-20: rgba(34, 211, 238, 0.20);

    --header-1: #0b1222;
    --header-2: #060913;
    --header-divider: rgba(255, 255, 255, 0.10);
    --header-chip-bg: rgba(255, 255, 255, 0.10);
    --header-chip-border: rgba(255, 255, 255, 0.16);
    --header-chip-text: rgba(255, 255, 255, 0.86);

    --nav-1: #0b1222;
    --nav-2: #060913;
    --nav-text: rgba(255, 255, 255, 0.70);
    --nav-active-text: var(--brand-1);
    --nav-active-bg: var(--brand-soft-14);

    --danger: #ff453a;
}

html[data-theme="orange"] {
    --page-bg: #0b0b0d;
    --page-text: #f5f5f7;
    --text-muted: rgba(245, 245, 247, 0.66);
    --text-soft: rgba(245, 245, 247, 0.82);
    --text-invert: #0b0b0d;

    --surface: rgba(19, 19, 22, 0.92);
    --surface-solid: #131316;
    --surface-soft: rgba(19, 19, 22, 0.86);

    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.20);
    --divider: rgba(255, 255, 255, 0.14);

    --shadow-1: 0 10px 26px rgba(0, 0, 0, 0.34);
    --shadow-2: 0 18px 38px rgba(0, 0, 0, 0.46);

    --brand-1: #ff2d55;
    --brand-2: #b80024;
    --brand-soft-08: rgba(255, 45, 85, 0.08);
    --brand-soft-10: rgba(255, 45, 85, 0.10);
    --brand-soft-12: rgba(255, 45, 85, 0.12);
    --brand-soft-14: rgba(255, 45, 85, 0.14);
    --brand-soft-16: rgba(255, 45, 85, 0.16);
    --brand-soft-20: rgba(255, 45, 85, 0.20);

    --header-1: #0b0b0d;
    --header-2: #141417;
    --header-divider: rgba(255, 255, 255, 0.10);
    --header-chip-bg: rgba(255, 255, 255, 0.10);
    --header-chip-border: rgba(255, 255, 255, 0.16);
    --header-chip-text: rgba(255, 255, 255, 0.90);

    --nav-1: #0b0b0d;
    --nav-2: #141417;
    --nav-text: rgba(255, 255, 255, 0.72);
    --nav-active-text: #ffffff;
    --nav-active-bg: var(--brand-soft-12);

    --danger: #ff453a;
}

/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

#app {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: #f4f8ff;
    background: var(--page-bg);
    color: #0b1b33;
    color: var(--page-text);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: calc(54px + env(safe-area-inset-bottom));
    -webkit-font-smoothing: antialiased;
    width: 100%;
    max-width: 100%;
    margin: 0;
    overflow-x: hidden;
}

/* 头部 */
.header {
    background: linear-gradient(180deg, var(--header-1) 0%, var(--header-2) 100%);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow:
        0 10px 26px rgba(0, 0, 0, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.10);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
    max-width: 100%;
}

.header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: var(--header-divider);
}

.header-top::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: var(--header-divider);
}

.header-top {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    height: 52px;
    padding: 0 16px;
    position: relative;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.00) 100%);
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
}

.site-name {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.96);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 1.2px;
    line-height: 1.1;
    text-shadow:
        0 1px 0 rgba(0, 0, 0, 0.22),
        0 6px 18px rgba(0, 0, 0, 0.22);
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
    max-width: calc(100vw - 160px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.theme-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.theme-toggle {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border: 1px solid var(--header-chip-border);
    background: rgba(255, 255, 255, 0.10);
    background: var(--header-chip-bg);
    color: rgba(255, 255, 255, 0.88);
    color: var(--header-chip-text);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 10px 18px rgba(0, 0, 0, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.theme-toggle:active {
    transform: scale(0.98);
}

.theme-toggle svg {
    display: block;
}

body.theme-overlay-open {
    overflow: hidden;
}

.theme-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 240;
}

.theme-overlay-backdrop {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.35);
}

html[data-theme="night"] .theme-overlay-backdrop {
    background: rgba(0, 0, 0, 0.55);
}

html[data-theme="orange"] .theme-overlay-backdrop {
    background: rgba(0, 0, 0, 0.62);
}

.theme-panel {
    position: absolute;
    left: 50%;
    top: 50%;
    right: auto;
    bottom: auto;
    width: calc(100% - 24px);
    max-width: 360px;
    border-radius: 16px;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.26);
    overflow: hidden;
    transform: translate(-50%, -50%) translateZ(0);
}

.theme-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid var(--border);
}

.theme-panel-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--page-text);
}

.theme-panel-close {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--page-text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.theme-panel-options {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theme-panel-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--page-text);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.theme-panel-option.active {
    border-color: var(--brand-soft-16);
    background: var(--brand-soft-10);
}

.theme-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.14),
        0 3px 10px rgba(0, 0, 0, 0.22);
}

.theme-dot-night {
    background: linear-gradient(135deg, #4f46e5 0%, #22d3ee 100%);
}

.theme-dot-blue {
    background: linear-gradient(135deg, #1b5bd6 0%, #2f80ed 100%);
}

.theme-dot-orange {
    background: linear-gradient(135deg, #b80024 0%, #ff2d55 100%);
}

.theme-option-text {
    flex: 1;
}

.theme-option-mark {
    opacity: 0;
    font-size: 12px;
    line-height: 1;
}

.theme-panel-option.active .theme-option-mark {
    opacity: 1;
}

.logo-img {
    max-width: 100%;
    height: auto;
    max-height: 50px;
    object-fit: contain;
}

/* 分类标签 */
.category-tabs {
    display: flex;
    overflow-x: auto;
    padding: 10px 12px;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%);
    border-top: none;
}
.category-tabs::-webkit-scrollbar { display: none; }
.category-tab {
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.10);
    background: var(--header-chip-bg);
    border-radius: 16px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.88);
    color: var(--header-chip-text);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border: 1px solid var(--header-chip-border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.category-tab.active {
    background: linear-gradient(180deg, var(--brand-1) 0%, var(--brand-2) 100%);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.20);
}
.category-tab:active { transform: scale(0.95); }

html[data-theme="night"] .category-tab {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
    color: var(--nav-text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

html[data-theme="night"] .category-tab.active {
    background: var(--nav-active-bg);
    border-color: rgba(255, 255, 255, 0.18);
    color: var(--nav-active-text);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
}

html[data-theme="blue"] .category-tab {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.16);
    color: var(--nav-text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

html[data-theme="blue"] .category-tab.active {
    background: var(--nav-active-bg);
    border-color: rgba(255, 255, 255, 0.18);
    color: var(--nav-active-text);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22);
}

html[data-theme="orange"] .category-tab {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
    color: var(--nav-text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

html[data-theme="orange"] .category-tab.active {
    background: var(--nav-active-bg);
    border-color: rgba(255, 255, 255, 0.18);
    color: var(--nav-active-text);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
}

.notice-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px;
    padding: 12px;
    border-radius: 12px;
    background: linear-gradient(180deg, var(--brand-soft-14) 0%, var(--brand-soft-08) 100%);
    border: 1px solid var(--brand-soft-20);
    color: var(--page-text);
    box-shadow: var(--shadow-1);
}

#homePage.has-notice .games-list {
    padding-top: 0;
}

.notice-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: var(--brand-1);
}

.notice-title {
    flex: 0 0 auto;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.6px;
    color: var(--page-text);
}

.notice-marquee {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.notice-track {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    will-change: transform;
}

.notice-track.scrolling {
    animation: noticeMarquee var(--notice-duration, 12s) linear infinite;
}

.notice-item {
    padding-right: 40px;
    font-size: 13px;
    color: var(--text-soft);
}

@keyframes noticeMarquee {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* 主体 */
.main {
    padding: 0;
    max-width: 100%;
    margin: 0;
    background: #f4f8ff;
    background: var(--page-bg);
    width: 100%;
}
.page { animation: fadeIn 0.3s; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 游戏列表 */
.games-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
}
.game-card {
    background: #ffffff;
    background: var(--surface-solid);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0;
    box-shadow: 0 6px 16px rgba(11, 27, 51, 0.08);
    box-shadow: var(--shadow-1);
    border: 1px solid rgba(15, 55, 120, 0.14);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    width: 100%;
}
.game-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(11, 27, 51, 0.12);
    box-shadow: var(--shadow-2);
}

.game-main-section {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 15px;
    background: var(--surface-solid);
}
.game-icon-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.game-icon-wrapper {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.game-name-below-icon {
    font-size: 13px !important;
    color: var(--text-soft) !important;
    text-align: center !important;
    max-width: 80px !important;
    line-height: 1.2 !important;
    font-weight: 500 !important;
    display: -webkit-box !important;
    margin-top: 4px !important;
    white-space: normal !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    min-height: 30px !important;
}
.game-icon-text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(180deg, var(--brand-1) 0%, var(--brand-2) 100%);
}
.game-icon-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    padding: 0;
    box-sizing: border-box;
    transform: none;
}

@media (max-width: 360px) {
    .game-name-below-icon {
        font-size: 12px !important;
    }
}

.game-right-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}
.game-period-info {
    display: flex;
    flex-direction: row;
    gap: 15px;
    font-size: 13px;
    align-items: center;
    flex-wrap: nowrap;
}
@media (max-width: 400px) {
    .game-period-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    .game-period-info .period-text { width: 100%; }
}
.period-text { color: var(--page-text); font-weight: 600; white-space: nowrap; }
.period-value { color: var(--brand-2); font-weight: 800; }

.game-numbers-section { padding: 5px 0 0 0; background: var(--surface-solid); }
.result-numbers {
    display: flex;
    flex-wrap: nowrap;
    gap: 3px;
    justify-content: flex-start;
    align-items: center;
    padding: 0;
    min-height: 26px;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.result-numbers::-webkit-scrollbar {
    display: none;
}
.number-ball {
    flex-shrink: 0;
    min-width: 20px;
    width: auto;
    height: 26px;
    aspect-ratio: 1;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: #fff;
    position: relative;
    border: none;
    transition: transform 0.2s;
    padding: 0 2px;
    box-sizing: border-box;
    white-space: nowrap;
    text-shadow:
        -1px -1px 0 #000,
        0 -1px 0 #000,
        1px -1px 0 #000,
        -1px 0 0 #000,
        1px 0 0 #000,
        -1px 1px 0 #000,
        0 1px 0 #000,
        1px 1px 0 #000,
        0 0 1px #000,
        0 0 2px #000;
}
.number-ball[class*="racing-num-"] {
    color: #ffffff !important;
    font-weight: bold !important;
    border: none !important;
}

/* 六合彩号码样式 - 使用图片背景 */
.number-ball.lhc-red,
.number-ball.lhc-blue,
.number-ball.lhc-green {
    background-size: 100% 100% !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    color: #000 !important;
    font-weight: bold !important;
    text-shadow: none !important;
    border: none !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    /* 使用固定像素padding，确保在不同屏幕尺寸下位置一致（参考mxj实现：24px球用4px padding） */
    /* 默认值，JS会根据实际球大小动态设置 */
    padding-top: 4px !important;
    padding-left: 4px !important;
    padding-right: 0 !important;
    padding-bottom: 0 !important;
    box-sizing: border-box !important;
    position: relative !important;
    line-height: 1 !important;
}

.number-ball:active { transform: scale(0.95); }

/* ========== 加拿大28 号码球：精确还原 mxj 原始比例 ========== */
:root {
    /* 
     * 【微调指南】
     * --pc163-scale: 控制图标的缩放比例，1 为刚好填满，1.12 为稍微放大。
     * --pc163-tweak-y: 上下微调，正数向下，负数向上 (px)
     * --pc163-tweak-x: 左右微调，正数向右，负数向左 (px)
     */
    --pc163-scale: 1.2;
    --pc163-tweak-y: 4px;
    --pc163-tweak-x: 2px;
}

.b163{
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 2px !important; /* 保证水平排列时的垂直对齐 */
    font-size: 0 !important;
    text-indent: -9999px;
    background-color: transparent !important;
    background-image: url(imgn/ball_pc28.png) !important;
    background-repeat: no-repeat !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    border-radius: 50%;
    box-sizing: border-box;
    flex-shrink: 0;
    overflow: hidden;
    text-shadow: none !important;
    padding: 0 !important;
    /* 动态球体大小，由 app.js 传入，默认 24px */
    --s: var(--ball-size, 24px);
    /* 完美的等比缩放：宽度 = 球大小 * 缩放比例，高度 = 宽度 * 28个球 */
    background-size: calc(var(--s) * var(--pc163-scale)) calc(var(--s) * 28 * var(--pc163-scale)) !important;
}

/* 使用绝对居中数学公式，彻底解决号码歪斜和缩放偏移问题 */
.b163.b163-0{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 0.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-1{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 1.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-2{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 2.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-3{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 3.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-4{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 4.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-5{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 5.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-6{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 6.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-7{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 7.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-8{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 8.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-9{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 9.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-10{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 10.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-11{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 11.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-12{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 12.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-13{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 13.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-14{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 14.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-15{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 15.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-16{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 16.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-17{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 17.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-18{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 18.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-19{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 19.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-20{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 20.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-21{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 21.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-22{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 22.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-23{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 23.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-24{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 24.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-25{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 25.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-26{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 26.5 + var(--pc163-tweak-y)) !important;}
.b163.b163-27{background-position: calc(50% + var(--pc163-tweak-x)) calc(var(--s) / 2 - var(--s) * var(--pc163-scale) * 27.5 + var(--pc163-tweak-y)) !important;}

/* 游戏底部 */
.game-footer-section {
    background: linear-gradient(180deg, var(--brand-soft-20) 0%, var(--brand-soft-10) 100%);
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
}
.countdown-section { display: flex; align-items: baseline; gap: 5px; }
.countdown-time-wrapper { display: flex; align-items: flex-start; gap: 4px; }
.countdown-item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.countdown-number {
    font-size: 20px;
    font-weight: bold;
    color: var(--page-text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    letter-spacing: 0.5px;
    line-height: 1;
    height: 20px;
    display: flex;
    align-items: center;
    font-variant-numeric: tabular-nums;
}
.countdown-label { font-size: 12px; color: var(--text-muted); line-height: 1; }
.countdown-status { display: flex; align-items: center; justify-content: center; }
.countdown-status-text { font-size: 14px; color: var(--text-soft); font-weight: 800; }
.countdown-separator {
    font-size: 20px;
    font-weight: bold;
    color: var(--page-text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    letter-spacing: 0.5px;
    line-height: 1;
    height: 20px;
    display: flex;
    align-items: center;
    font-variant-numeric: tabular-nums;
}

.game-actions { display: flex; gap: 0; align-items: center; }
.action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-soft);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s;
    cursor: pointer;
}
.action-btn svg { width: 16px; height: 16px; stroke: currentColor; flex-shrink: 0; }
.action-divider {
    width: 1px;
    height: 28px;
    align-self: center;
    background: var(--divider);
    flex-shrink: 0;
    margin: 0 6px;
}
.action-btn:hover { color: var(--brand-2); background: var(--brand-soft-12); }
.action-btn:active { transform: scale(0.95); }

/* 历史开奖页面 */
#historyPage {
    background: var(--page-bg);
    min-height: 100vh;
    padding-bottom: 60px;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
}

/* 历史页面头部 */
.history-header {
    background: linear-gradient(180deg, var(--header-1) 0%, var(--header-2) 100%);
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.8px;
    box-shadow:
        0 10px 26px rgba(0, 0, 0, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.10);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    max-width: 100%;
}
.history-header::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.00) 100%);
    pointer-events: none;
}
.history-header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: var(--header-divider);
}
.history-header-title {
    flex: 1;
    text-align: center;
    letter-spacing: 1px;
}
.history-header-menu {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--header-chip-border);
    background: var(--header-chip-bg);
    color: var(--header-chip-text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.history-header-menu svg {
    display: block;
}

/* 游戏和日期选择器 */
.history-selector {
    display: flex;
    background: var(--page-bg);
    padding: 12px 16px;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}
.history-game-selector,
.history-date-selector {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--surface-soft);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px; /* 确保点击区域足够大 */
    user-select: none; /* 防止文本选择 */
}
.history-game-selector:active,
.history-date-selector:active {
    background: var(--brand-soft-10);
}
.selector-label {
    font-size: 14px;
    color: var(--page-text);
    flex: 1;
    text-align: left;
    pointer-events: none;
    user-select: none;
    position: relative;
    z-index: 1;
}
.selector-arrow {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 8px;
    pointer-events: none; /* 设置为none，让容器统一处理点击 */
    user-select: none;
    cursor: pointer;
    flex-shrink: 0; /* 防止图标被压缩 */
    position: relative;
    z-index: 1;
}

/* 隐藏的原生选择器，但保持可用 - 覆盖整个选择器区域（包括边框） */
#historyGameSelect,
#historyDate {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
    font-size: 16px; /* 防止iOS缩放 */
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
}

/* 当前期开奖信息 */
.current-draw-section {
    background: var(--surface);
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.current-draw-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.current-draw-title {
    font-size: 16px;
    font-weight: bold;
    color: var(--page-text);
}
.current-draw-info {
    font-size: 13px;
    color: var(--text-muted);
}
.current-draw-numbers {
    display: flex;
    flex-wrap: nowrap;
    gap: 3px;
    margin-bottom: 12px;
    justify-content: center;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
}
.current-draw-numbers::-webkit-scrollbar {
    display: none;
}
.current-draw-countdown {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.countdown-text {
    color: var(--danger);
    font-weight: bold;
}

/* 历史内容区域 */
.history-content {
    background: var(--surface);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
}
.history-content-title {
    padding: 16px;
    font-size: 16px;
    font-weight: bold;
    color: var(--page-text);
    border-bottom: 1px solid var(--border);
    background: transparent;
}

/* 标签页 */
.history-tabs {
    display: flex;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.history-tabs::-webkit-scrollbar { display: none; }
.history-tab {
    flex: 1;
    padding: 12px 8px;
    text-align: center;
    font-size: 14px;
    color: var(--text-soft);
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    min-width: 60px;
    position: relative;
    background: transparent;
}
.history-tab.active {
    color: var(--brand-2);
    font-weight: 800;
    background: transparent;
}
.history-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--brand-1) 0%, var(--brand-2) 100%);
}

/* 历史列表 */
.history-list {
    padding: 0;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
}
.history-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
    transition: background 0.2s;
    background: transparent;
    width: 100%;
    box-sizing: border-box;
}
.history-item:last-child {
    border-bottom: none;
}
.history-item:active {
    background: var(--brand-soft-08);
}
.history-item-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 100px;
    flex-shrink: 0;
    align-items: flex-start;
}
.history-item-header span:first-child {
    font-size: 14px;
    color: var(--page-text);
    font-weight: 700;
    line-height: 1.4;
}
.history-item-header span:last-child {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}
.history-item-numbers {
    display: flex;
    flex-wrap: nowrap;
    gap: 3px;
    align-items: center;
    justify-content: flex-start;
    flex: 1;
    min-width: 0;
    min-height: 32px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.history-item-numbers::-webkit-scrollbar {
    display: none;
}

/* 按钮 */
.btn {
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}
.btn-primary {
    background: linear-gradient(180deg, var(--brand-1) 0%, var(--brand-2) 100%);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}
.btn-secondary {
    background: var(--surface-solid);
    color: var(--page-text);
    border: 1px solid var(--border-strong);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 16px;
    gap: 10px;
}
.page-info { color: var(--text-muted); font-size: 13px; flex: 1; text-align: center; }

/* 底部导航 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, var(--nav-1) 0%, var(--nav-2) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.10);
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 54px;
    padding: 0 0 env(safe-area-inset-bottom);
    box-sizing: border-box;
    z-index: 150;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.22);
    width: 100%;
    max-width: 100%;
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none;
    color: var(--nav-text);
    transition: all 0.3s;
    height: 100%;
    padding: 6px 0;
    border-radius: 10px;
    flex: 1;
}
.nav-item.active {
    color: var(--nav-active-text);
    background: var(--nav-active-bg);
}
.nav-item:active { transform: scale(0.97); }
.nav-icon { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex-shrink: 0; }
.nav-icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; transition: all 0.3s; }
.nav-item.active .nav-icon svg { stroke: var(--nav-active-text); fill: none; }
.nav-label { font-size: 11px; line-height: 1.2; white-space: nowrap; }

/* 加载与空状态 */
.loading, .no-data {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}
.no-result {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

/* 历史标签页特殊样式 */
.history-size-ball {
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.history-oddeven-ball {
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.history-pair-ball {
    transition: all 0.2s;
}

.history-pair-ball:hover {
    transform: scale(1.05);
}

.history-sum-ball {
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* 香港彩生肖文本样式 - 增大字体 */
.hk-zodiac-text {
    font-size: 18px !important;
    color: #111111 !important;
    text-shadow: none;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    font-weight: bold;
}

html[data-theme="night"] .hk-zodiac-text,
html[data-theme="orange"] .hk-zodiac-text {
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

/* 响应式 */
@media (min-width: 768px) {
    .main { max-width: 100%; padding: 0; }
    .games-list { 
        display: grid; 
        grid-template-columns: repeat(2, 1fr); 
        gap: 12px; 
        padding: 12px;
    }
    .history-controls { flex-direction: row; }
    .select-input, .date-input { flex: 1; }
    #historyPage { max-width: 100%; }
}
