/* 足球赛事监控 — 布局与主题 */
html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    position: relative;
    background-color: #e8eeeb;
    color: #2c3e50;
    -webkit-tap-highlight-color: rgba(15, 107, 92, 0.12);
}

body.upcoming-sync-open {
    overflow: hidden;
    touch-action: none;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    background-image: var(--league-tile, none);
    background-repeat: repeat;
    background-size: 88px 88px;
    opacity: 0.09;
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(165deg, rgba(244, 247, 246, 0.88) 0%, rgba(236, 242, 239, 0.94) 45%, rgba(244, 247, 246, 0.9) 100%);
    pointer-events: none;
}

h1 {
    text-align: center;
    color: #0f6b5c;
    margin-bottom: 20px;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
    font-weight: 700;
    letter-spacing: 0.04em;
    font-size: clamp(1.1rem, 4.5vw, 1.65rem);
    padding: 0 8px;
}

/* 联赛导航：与页面浅灰绿底协调的「雾面浅卡」风，不用深色条 */
.tab-container {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px 12px;
    overflow-x: auto;
    margin-bottom: 22px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(15, 107, 92, 0.12);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(245, 250, 248, 0.88) 100%);
    box-shadow: 0 4px 24px rgba(15, 90, 80, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.tab {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 8px 18px 8px 10px;
    cursor: pointer;
    border-radius: 14px;
    white-space: nowrap;
    position: relative;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.02em;
    color: #3d5a54;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(15, 107, 92, 0.1);
    transition: transform 0.2s ease, box-shadow 0.22s ease, background 0.22s ease, color 0.2s ease;
    min-height: 44px;
    touch-action: manipulation;
}

.tab:hover {
    color: #0a4f44;
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(15, 107, 92, 0.12);
}

.tab.active {
    color: #fff;
    background: linear-gradient(145deg, #11998e 0%, #0d6b5c 48%, #0a5549 100%);
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow:
        0 6px 20px rgba(13, 107, 92, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.tab-emblem-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    flex-shrink: 0;
    border-radius: 14px;
    background: linear-gradient(160deg, #ffffff 0%, #eef5f3 100%);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 1), 0 2px 8px rgba(15, 80, 70, 0.1);
    border: 1px solid rgba(15, 107, 92, 0.12);
}

.tab.active .tab-emblem-wrap {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.12) 100%);
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.5);
}

.tab-emblem {
    width: 42px;
    height: 42px;
    object-fit: contain;
    display: block;
}

.tab-label {
    display: inline-block;
    max-width: 8em;
}

.tab--soon .tab-label {
    max-width: 10em;
}

.tab-emblem-wrap--symbol {
    background: linear-gradient(160deg, #fefce8 0%, #ecfdf5 100%);
}

.tab-symbol {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    font-size: 26px;
    line-height: 1;
}

.tab.active .tab-symbol-soon {
    filter: brightness(0) invert(1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-radius: 0 0 5px 5px;
}

th,
td {
    border: 1px solid #dcdde1;
    padding: 12px;
    text-align: center;
}

th {
    background-color: #3498db;
    color: white;
    position: sticky;
    top: 0;
}

th.col-result,
td.col-result {
    width: 100px;
    min-width: 88px;
    padding-left: 8px;
    padding-right: 8px;
    vertical-align: middle;
}

td.col-status {
    vertical-align: middle;
}

td.col-status .match-status-plain {
    font-weight: 400 !important;
    color: inherit;
}

td.col-status .match-status-live-min {
    display: inline-block;
    font-weight: 800 !important;
    font-size: 1.08rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
    color: #7f1d1d;
    letter-spacing: 0.02em;
    text-shadow: 0 0 1px rgba(255, 255, 255, 0.95), 0 1px 0 rgba(255, 255, 255, 0.75);
}

td.col-status .match-status-soon {
    display: inline-block;
    font-weight: 700 !important;
    color: #9a3412;
    background: linear-gradient(180deg, rgba(254, 243, 199, 0.95) 0%, rgba(253, 224, 71, 0.35) 100%);
    border: 1px solid rgba(217, 119, 6, 0.55);
    border-radius: 8px;
    padding: 4px 12px;
    box-shadow: 0 1px 3px rgba(180, 83, 9, 0.2);
    letter-spacing: 0.06em;
}

th.col-league,
td.col-league {
    min-width: 64px;
    max-width: 88px;
    font-size: 13px;
    font-weight: 600;
}

/* 即将开始表格的联赛标签 - 放大显示 */
#matchTable.upcoming-view .league-chip {
    font-size: 14px;
    font-weight: 700;
    padding: 3px 10px;
    gap: 6px;
}

#matchTable.upcoming-view .league-chip-logo {
    width: 22px;
    height: 22px;
}

.league-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(15, 107, 92, 0.1);
    color: #0f5c4e;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1;
}

.league-chip-logo {
    width: 16px;
    height: 16px;
    object-fit: contain;
    border-radius: 3px;
    flex-shrink: 0;
}

.cache-hint {
    text-align: center;
    font-style: italic;
    color: #7f8c8d;
    font-size: 13px;
    padding: 8px !important;
    background: rgba(250, 250, 250, 0.9);
}

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* 赛果列：主/客 SVG 内嵌文字 */
.result-side-wrap-svgonly {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.result-side-wrap-svgonly svg {
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* —— 赛程行：按联赛配置的参考列（北京 / 柏林 / 美东「日历日」）分组 —— */
tr.match-row[class*="match-day-palette--"]:not(.match-day-palette--neutral) {
    border-left: 4px solid var(--day-edge);
    background: linear-gradient(90deg, var(--day-tint) 0%, rgba(255, 255, 255, 0.96) 42%, #ffffff 100%);
    box-shadow: inset 0 0 0 1px var(--day-ring);
}

tr.match-row[class*="match-day-palette--"]:not(.match-day-palette--neutral) td {
    font-weight: 500;
}

/* 12 套区别明显的色相（同一日期 → JS 哈希到固定一档） */
tr.match-day-palette--0 {
    --day-edge: #0d9488;
    --day-tint: rgba(13, 148, 136, 0.16);
    --day-ring: rgba(13, 148, 136, 0.12);
}

tr.match-day-palette--1 {
    --day-edge: #d97706;
    --day-tint: rgba(217, 119, 6, 0.15);
    --day-ring: rgba(217, 119, 6, 0.12);
}

tr.match-day-palette--2 {
    --day-edge: #7c3aed;
    --day-tint: rgba(124, 58, 237, 0.13);
    --day-ring: rgba(124, 58, 237, 0.11);
}

tr.match-day-palette--3 {
    --day-edge: #e11d48;
    --day-tint: rgba(225, 29, 72, 0.12);
    --day-ring: rgba(225, 29, 72, 0.1);
}

tr.match-day-palette--4 {
    --day-edge: #0284c7;
    --day-tint: rgba(2, 132, 199, 0.14);
    --day-ring: rgba(2, 132, 199, 0.11);
}

tr.match-day-palette--5 {
    --day-edge: #65a30d;
    --day-tint: rgba(101, 163, 13, 0.14);
    --day-ring: rgba(101, 163, 13, 0.11);
}

tr.match-day-palette--6 {
    --day-edge: #ea580c;
    --day-tint: rgba(234, 88, 12, 0.14);
    --day-ring: rgba(234, 88, 12, 0.11);
}

tr.match-day-palette--7 {
    --day-edge: #4f46e5;
    --day-tint: rgba(79, 70, 229, 0.13);
    --day-ring: rgba(79, 70, 229, 0.1);
}

tr.match-day-palette--8 {
    --day-edge: #0891b2;
    --day-tint: rgba(8, 145, 178, 0.14);
    --day-ring: rgba(8, 145, 178, 0.11);
}

tr.match-day-palette--9 {
    --day-edge: #db2777;
    --day-tint: rgba(219, 39, 119, 0.12);
    --day-ring: rgba(219, 39, 119, 0.1);
}

tr.match-day-palette--10 {
    --day-edge: #059669;
    --day-tint: rgba(5, 150, 105, 0.14);
    --day-ring: rgba(5, 150, 105, 0.11);
}

tr.match-day-palette--11 {
    --day-edge: #6366f1;
    --day-tint: rgba(99, 102, 241, 0.13);
    --day-ring: rgba(99, 102, 241, 0.1);
}

/* 无日期数据时的兜底 */
tr.match-day-palette--neutral {
    background-color: #f1f5f4 !important;
    border-left: 3px solid #cbd5e1;
}

tr.match-day-palette--neutral td {
    color: #64748b;
}

/* 已结束：不参与「按日配色」，统一淡灰底避免干扰 */
tr.match-row--finished-flat {
    background: #f1f5f9 !important;
    border-left: 3px solid #cbd5e1 !important;
    box-shadow: none !important;
    filter: none !important;
}

tr.match-row--finished-flat td {
    color: #475569;
    font-weight: 400;
}

/* 同日内的状态分层：进行中更「亮」（已结束场次不用按日配色，见 .match-row--finished-flat） */
tr[class*="match-day-palette--"]:not(.match-day-palette--neutral).match-day-sub--live {
    border-left-width: 5px;
    box-shadow:
        inset 0 0 0 1px rgba(255, 140, 60, 0.28),
        0 3px 14px rgba(0, 0, 0, 0.07);
    filter: saturate(1.08);
}

tr[class*="match-day-palette--"]:not(.match-day-palette--neutral).match-day-sub--live td {
    font-weight: 600;
}

.highlight {
    color: #e67e22;
}

.halftime {
    color: #8e44ad;
}

.finished {
    color: #334155;
}

.team-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: left;
    flex-wrap: wrap;
}

.team-crest {
    width: 22px;
    height: 22px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 2px;
}

.team-crest-ph {
    display: inline-block;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* 已结束 — 主胜：电竞风 WIN 矢量徽标 */
.result-win-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    vertical-align: middle;
}

.result-win-svg {
    display: block;
    flex-shrink: 0;
    filter: drop-shadow(0 0 4px rgba(127, 29, 29, 0.55)) drop-shadow(0 0 2px rgba(69, 10, 10, 0.4));
}

/* 已结束 — 平局：主队与客队之间的「和」 */
.result-draw-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.result-draw-svg {
    display: block;
}

.result-draw-svg text {
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

/* 未开赛 / 非终局：赛果列「等待」待定标（灰蓝方角，区别于红盾、绿和） */
.result-wait-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    vertical-align: middle;
}

.result-wait-svg {
    display: block;
    filter: drop-shadow(0 1px 2px rgba(51, 65, 85, 0.15));
}

/* 「即将开始」聚合内进行中：赛果列「滚球」深红标 */
.result-roll-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    vertical-align: middle;
}

.result-roll-svg {
    display: block;
    filter: drop-shadow(0 1px 3px rgba(69, 10, 10, 0.35));
}

.control-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(6px);
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.display-meta {
    font-size: 13px;
    color: #5d6d7e;
    text-align: center;
    padding: 10px 8px !important;
    background: rgba(248, 249, 250, 0.95);
}

.display-meta strong {
    color: #0f766e;
    font-weight: 700;
}

.refresh-info {
    display: flex;
    flex-direction: column;
}

#refreshCountdown,
#refreshCount {
    color: #7f8c8d;
    margin: 5px 0;
}

.auto-refresh-toggle {
    display: flex;
    align-items: center;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
    margin-left: 10px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 24px;
}

.slider::before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #3498db;
}

input:checked + .slider::before {
    transform: translateX(26px);
}

.button-container {
    display: flex;
    gap: 10px;
}

/* 数据拉取中：与表格 .loader 同系旋转提示 */
#refreshButton {
    position: relative;
}

#refreshButton.refresh-button--busy {
    padding-left: 38px;
}

#refreshButton.refresh-button--busy::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    box-sizing: border-box;
    border: 2px solid rgba(0, 0, 0, 0.12);
    border-top-color: rgba(255, 255, 255, 0.92);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    color: white;
    background-color: #3498db;
    cursor: pointer;
    transition: background-color 0.3s;
    min-height: 44px;
    touch-action: manipulation;
}

button:hover {
    background-color: #2980b9;
}

button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

.loading {
    width: 100%;
    text-align: center;
    padding: 20px;
    color: #7f8c8d;
}

/* 「即将开始」全屏同步层（手机端可识别等待、防误触下层） */
/* z-index 10000 确保在最顶层，可根据项目需要调整 */
.upcoming-sync-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.upcoming-sync-overlay[hidden] {
    display: none !important;
}

.upcoming-sync-card {
    width: min(96vw, 440px);
    text-align: center;
    padding: 24px 18px 18px;
    border-radius: 18px;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.98) 0%, rgba(241, 245, 249, 0.96) 100%);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.upcoming-sync-arrow {
    display: inline-block;
    font-size: 2.2rem;
    line-height: 1;
    color: #0d9488;
    animation: upcoming-sync-spin 0.95s linear infinite;
    margin-bottom: 10px;
    filter: drop-shadow(0 2px 4px rgba(13, 148, 136, 0.35));
}

@keyframes upcoming-sync-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.upcoming-sync-title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}

.upcoming-sync-progress {
    margin: 0 0 6px;
    font-size: 1.35rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #0f766e;
    letter-spacing: 0.04em;
}

.upcoming-sync-sub {
    margin: 0 0 10px;
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.45;
    min-height: 1.35em;
}

.upcoming-sync-countdown {
    margin: 0 0 10px;
    font-size: 0.8rem;
    color: #94a3b8;
    min-height: 1.2em;
    font-variant-numeric: tabular-nums;
}

.upcoming-sync-countdown--active {
    color: #eab308;
    font-weight: 600;
}

.upcoming-sync-table-wrap {
    width: 100%;
    max-height: min(38vh, 280px);
    overflow: auto;
    margin: 0 0 12px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(255, 255, 255, 0.65);
}

.upcoming-sync-league-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    text-align: left;
}

.upcoming-sync-league-table th,
.upcoming-sync-league-table td {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
    vertical-align: top;
}

.upcoming-sync-league-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(241, 245, 249, 0.98);
    font-weight: 700;
    color: #334155;
}

.upcoming-sync-league-table tr:last-child td {
    border-bottom: none;
}

.upcoming-sync-col-league {
    width: 22%;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
}

.upcoming-sync-col-state {
    width: 12%;
    text-align: center;
    font-weight: 800;
    font-size: 1rem;
}

.upcoming-sync-col-state--ok {
    color: #15803d;
}

.upcoming-sync-col-state--err {
    color: #b91c1c;
}

.upcoming-sync-col-state--pending,
.upcoming-sync-col-state--working {
    color: #64748b;
}

.upcoming-sync-col-state--abort,
.upcoming-sync-col-state--idle {
    color: #94a3b8;
}

.upcoming-sync-col-note {
    color: #475569;
    word-break: break-word;
}

.upcoming-sync-col-note--ok {
    color: #166534;
}

.upcoming-sync-col-note--skip {
    color: #1d4ed8;
}

.upcoming-sync-col-note--err {
    color: #991b1b;
}

.upcoming-sync-col-note--pending,
.upcoming-sync-col-note--working {
    color: #64748b;
}

.upcoming-sync-col-note--abort,
.upcoming-sync-col-note--idle {
    color: #94a3b8;
}

.upcoming-sync-abort {
    width: 100%;
    margin: 0;
    background: #64748b;
    font-size: 0.9rem;
}

.upcoming-sync-abort:hover {
    background: #475569;
}

@media (max-width: 768px) {

    td,
    th {
        padding: 8px;
        font-size: 14px;
    }

    body {
        padding: 10px;
    }

    .switch {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .tab {
        padding: 8px 14px 8px 10px;
        font-size: 13px;
    }

    .tab-emblem-wrap {
        width: 48px;
        height: 48px;
    }

    .tab-emblem {
        width: 38px;
        height: 38px;
    }

    .control-panel {
        flex-direction: column;
        gap: 15px;
    }

    .button-container {
        width: 100%;
        justify-content: center;
    }

    .table-container {
        overflow-x: auto;
    }
}

.loader {
    border: 3px solid #f3f3f3;
    border-radius: 50%;
    border-top: 3px solid #3498db;
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 10px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}
