/* 内容包装器样式 */
.content-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
    position: relative;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* 表格边框全局样式 */
:root {
    --table-border-width: 1.5px;
    --table-border-color: #ccc;
    --table-border: var(--table-border-width) solid var(--table-border-color);
}

/* 基本樣式 */
body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background-color: #fff;
    font-size: clamp(14px, 1vw, 16px);
}

.container {
    width: 100%; 
    max-width: 100%;
    margin: 0;
    padding: 10px;
    box-sizing: border-box;
}

/* 搜尋區域樣式 */
.search-section {
    margin: 15px 0 20px;
    padding: 20px;
    background-color: #f8f8f8;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #eee;
    width: 100%;
    box-sizing: border-box;
}

.search-title {
    font-size: 1.25em;
    margin-bottom: 20px;
    color: #333;
    position: relative;
    padding-left: 15px;
    font-weight: bold;
}

.search-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 18px;
    background-color: #fa363a;
    border-radius: 2px;
}

.team-filters {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
}

/* 隊伍按鈕基本樣式 */
.team-btn {
    padding: 10px 14px;
    border: 2px solid #555;
    border-radius: 8px;
    background-color: #fff;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
    font-size: 1em;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex: 1;
    min-width: 90px;
    max-width: 150px;
    text-align: center;
    font-weight: 500;
}

/* 隊伍按鈕懸停效果 */
.team-btn:hover {
    background-color: #f0f0f0;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    border-color: #333;
}

/* 隊伍按鈕選中狀態 */
.team-btn.selected {
    background-color: #dc3545;
    color: #fff;
    border-color: #dc3545;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
    transform: translateY(-1px);
}

/* 取消按鈕樣式 */
.cancel-btn {
    padding: 8px 12px;
    border: 2px solid #555;
    border-radius: 8px;
    background-color: #fff;
    color: #333;
    cursor: pointer;
    font-size: 0.9em;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    width: auto;
    min-width: 60px;
}

/* 取消按鈕懸停效果 */
.cancel-btn:hover {
    background-color: #f0f0f0;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* 取消按鈕點擊狀態 */
.cancel-btn:active {
    background-color: #dc3545;
    color: #fff;
    border-color: #dc3545;
    transform: translateY(1px);
}

/* 確保選中狀態的優先級 */
.team-filters .team-btn.selected {
    background-color: #dc3545;
    color: #fff;
    border-color: #dc3545;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

/* 防止其他狀態覆蓋選中狀態 */
.team-filters .team-btn.selected:hover {
    background-color: #dc3545;
    color: #fff;
    border-color: #dc3545;
    transform: none;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

/* 表格基本樣式 - 使用表格布局而非網格布局 */
.schedule-table {
    width: 100%;
    min-width: 320px; /* 確保最小寬度適合小屏幕 */
    border-collapse: collapse;
    margin: 0;
    border: var(--table-border);
    table-layout: fixed;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.schedule-table th,
.schedule-table td {
    padding: 12px 10px;
    text-align: center;
    border: var(--table-border);
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9em;
}

/* 設置列寬比例 */
.schedule-table th:nth-child(1),
.schedule-table td:nth-child(1) {
    width: 18%; /* 日期列 */
}

.schedule-table th:nth-child(2),
.schedule-table td:nth-child(2),
.schedule-table th:nth-child(4),
.schedule-table td:nth-child(4) {
    width: 32%; /* 隊伍名稱列，縮小 */
}

.schedule-table th:nth-child(3),
.schedule-table td:nth-child(3) {
    width: 18%; /* 比分列，放大 */
    min-width: 60px; /* 確保比分欄有足夠寬度 */
}

/* 表頭樣式 */
.schedule-table thead tr {
    background-color: #dc3545;
    color: white;
    font-weight: bold;
}

.schedule-table th {
    background-color: #dc3545;
    color: white;
    font-weight: bold;
    font-size: 1.05em;
    padding: 14px 10px;
}

/* 表格雙數行背景色 */
.schedule-table tbody tr:nth-child(even) {
    background-color: #ffffff;
}

/* 表格所有行默認背景 */
.schedule-table tbody tr {
    background-color: #ffffff;
}

/* 表格行懸停效果 */
.schedule-table tbody tr:hover {
    background-color: #f8f8f8;
    transition: background-color 0.2s ease;
}

/* 選中隊伍的效果 */
.schedule-table td.highlight-team {
    font-weight: bold;
    background-color: #ffd6d9;
    border-left: 3px solid #dc3545;
}

/* 日期單元格 */
.date-cell {
    font-weight: bold; /* 改為粗體 */
    vertical-align: middle;
    white-space: nowrap;
    background-color: #f9f9f9;
    font-size: 0.95em;
    color: #000; /* 改為黑色 */
}

/* 可點擊日期樣式 */
.clickable-date {
    color: #dc3545;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s;
}

.clickable-date:hover {
    color: #a71d2a;
}

/* 表格隊伍名稱欄位樣式 */
.team-cell {
    text-align: center !important;
    font-weight: bold;
    padding: 10px 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

/* 被選中高亮的隊伍單元格 */
.highlight-team {
    background-color: #ffebec !important;
    font-weight: bold;
    border-left: 3px solid #dc3545 !important;
    color: #dc3545 !important;
}

/* 高亮隊伍行樣式 */
tr:has(.highlight-team) {
    background-color: #fff9f9 !important;
}

/* 調整客場隊伍的文字位置 */
.schedule-table td:nth-child(2) {
    text-align: center; /* 改為置中 */
    padding-right: 8px;
}

/* 調整主場隊伍的文字位置 */
.schedule-table td:nth-child(4) {
    text-align: center; /* 改為置中 */
    padding-left: 8px;
}

/* 比分單元格 */
.score-cell {
    font-weight: normal;
    text-align: center;
    vertical-align: middle;
    padding: 5px 8px; /* 增加水平內邊距 */
    position: relative;
    min-width: 60px; /* 增加比分欄最小寬度 */
    background-color: #fafafa;
}

/* 比分樣式 */
.score {
    font-weight: bold;
    font-size: 1.4em; /* 放大比分數字 */
    display: inline-block;
    margin: 0 2px;
    color: #dc3545;
}

/* 比分之間的分隔符 */
.score-cell .score-separator {
    display: inline-block;
    margin: 0 3px;
    color: #888;
    font-size: 1.2em;
    font-weight: 300;
    position: relative;
    top: -1px;
}

/* 響應式設計 - 平板 */
@media screen and (max-width: 768px) {
    .container {
        padding: 5px;
        overflow-x: hidden; /* 改为hidden，因为包裹器已添加overflow-x:auto */
    }
    
    .content-wrapper {
        margin-bottom: 15px;
        -webkit-overflow-scrolling: touch;
    }
    
    .schedule-table th,
    .schedule-table td {
        padding: 10px 5px;
        font-size: 0.9em;
        border: var(--table-border);
    }
    
    .schedule-table th:nth-child(1),
    .schedule-table td:nth-child(1) {
        width: 20%;
    }
    
    .schedule-table th:nth-child(2),
    .schedule-table td:nth-child(2),
    .schedule-table th:nth-child(4),
    .schedule-table td:nth-child(4) {
        width: 35%;
    }
    
    .schedule-table th:nth-child(3),
    .schedule-table td:nth-child(3) {
        width: 16%;
        min-width: 50px;
    }
    
    .search-section {
        padding: 15px;
        margin: 10px 0 15px;
    }
    
    .search-title {
        font-size: 1.2em;
    }
    
    .team-btn {
        padding: 8px 12px;
        font-size: 0.95em;
        min-width: 80px;
    }
    
    .team-cell {
        font-size: 1em;
    }
    
    .score {
        font-size: 1.3em;
    }
    
    .schedule-table th {
        padding: 12px 5px;
        font-size: 1em;
    }
    
    .schedule-table td:nth-child(2) {
        padding-right: 5px;
        text-align: center;
    }
    
    .schedule-table td:nth-child(4) {
        padding-left: 5px;
        text-align: center;
    }
    
    .schedule-table {
        min-width: 280px;
    }
}

/* 響應式設計 - 手機 (480px) */
@media screen and (max-width: 480px) {
    .content-wrapper {
        padding: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .schedule-table th,
    .schedule-table td {
        padding: 10px 5px;
        font-size: 0.85em;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .schedule-table th:nth-child(1),
    .schedule-table td:nth-child(1) {
        width: 18%;
        min-width: 60px; /* 為日期保留足夠寬度 */
    }

    .schedule-table th:nth-child(2),
    .schedule-table td:nth-child(2),
    .schedule-table th:nth-child(4),
    .schedule-table td:nth-child(4) {
        width: 32%;
        padding: 10px 2px;
    }

    .schedule-table th:nth-child(3),
    .schedule-table td:nth-child(3) {
        width: 18%; 
        min-width: 50px;
    }

    .team-cell {
        font-size: 0.9em;
        padding: 8px 3px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .highlight-team {
        background-color: #ffeaec !important;
        border-left: 2px solid #dc3545 !important;
    }

    .score {
        font-size: 0.9em;
        font-weight: bold;
        padding: 2px 0;
    }

    .score-cell .score-separator {
        margin: 0 2px;
        font-size: 0.9em;
        font-weight: normal;
        color: #666;
    }

    .date-cell {
        font-size: 0.85em;
        font-weight: bold;
    }

    .team-btn {
        padding: 8px 10px;
        font-size: 0.8em;
        min-width: 70px;
        max-width: 120px;
        border-width: 1px;
        margin: 3px 2px;
    }

    .team-btn.selected {
        transform: none;
        box-shadow: 0 1px 3px rgba(220, 53, 69, 0.3);
    }

    .filter-row {
        flex-wrap: wrap;
        gap: 5px;
        margin-bottom: 5px;
        justify-content: center;
    }
    
    .search-title {
        font-size: 1.1em;
        margin-bottom: 12px;
        text-align: center;
        padding-left: 0;
    }
    
    .search-title::before {
        left: 50%;
        transform: translateX(-50%);
        top: -8px;
        width: 30px;
        height: 3px;
    }

    .schedule-table th {
        font-size: 0.9em;
        padding: 10px 5px;
    }

    .schedule-table td:nth-child(2) {
        text-align: center !important;
        padding-right: 5px;
    }

    .schedule-table td:nth-child(4) {
        text-align: center !important;
        padding-left: 5px;
    }

    .schedule-table tbody tr {
        transition: background-color 0.2s ease;
    }

    .score-cell {
        padding: 10px 2px;
        font-weight: bold;
    }
    
    .date-cell {
        font-weight: bold;
        color: #000;
    }
    
    /* 搜尋區域在小屏幕上的樣式 */
    .search-section {
        padding: 15px 10px;
        margin: 10px 0 15px;
    }
    
    .search-title {
        font-size: 1.1em;
        margin-bottom: 15px;
    }
}

/* iPhone 6/7/8, Plus和类似尺寸设备 */
@media screen and (max-width: 414px) {
    .content-wrapper {
        margin-bottom: 8px;
    }
    
    .schedule-table {
        min-width: 250px;
    }
    
    .team-cell {
        font-size: 0.82em;
        line-height: 1.25;
    }
    
    .score {
        font-size: 1.15em;
        line-height: 1;
    }
    
    .score-cell .score-separator {
        font-size: 0.95em;
        top: -1px;
    }
    
    .schedule-table th:nth-child(3),
    .schedule-table td:nth-child(3) {
        width: 22%; 
        min-width: 40px;
    }
    
    .schedule-table td:nth-child(2),
    .schedule-table td:nth-child(4) {
        text-align: center;
    }
}

/* 中小型手机适配（例如iPhone SE、iPhone 8等） */
@media screen and (max-width: 375px) {
    .content-wrapper {
        margin-bottom: 8px;
    }
    
    .schedule-table th,
    .schedule-table td {
        font-size: 0.75em;
        padding: 6px 1px;
        border: var(--table-border);
    }
    
    .schedule-table th:nth-child(1),
    .schedule-table td:nth-child(1) {
        width: 15%;
        min-width: 45px;
    }
    
    .schedule-table th:nth-child(2),
    .schedule-table td:nth-child(2),
    .schedule-table th:nth-child(4),
    .schedule-table td:nth-child(4) {
        width: 30%;
        min-width: 70px;
    }
    
    .team-cell {
        font-size: 0.8em;
        line-height: 1.2;
    }
    
    .date-cell {
        font-size: 0.7em;
    }
    
    .score {
        font-size: 1.1em;
        margin: 0 1px;
        line-height: 1;
    }
    
    .score-cell .score-separator {
        margin: 0;
        font-size: 0.9em;
        top: -1px;
    }
    
    .team-btn {
        padding: 5px 6px;
        font-size: 0.75em;
        min-width: 60px;
        max-width: 85px;
    }
    
    .schedule-table th:nth-child(3),
    .schedule-table td:nth-child(3) {
        width: 22%;
        min-width: 38px;
    }
    
    .schedule-table td:nth-child(2),
    .schedule-table td:nth-child(4) {
        text-align: center;
    }
    
    .schedule-table {
        min-width: 240px;
    }
}

/* 超小型手机适配（例如iPhone 5/SE等） */
@media screen and (max-width: 320px) {
    .content-wrapper {
        margin-bottom: 5px;
    }
    
    .schedule-table th,
    .schedule-table td {
        font-size: 0.7em;
        padding: 4px 1px;
        border: var(--table-border);
    }
    
    .schedule-table th:nth-child(1),
    .schedule-table td:nth-child(1) {
        width: 15%;
        min-width: 40px;
    }
    
    .schedule-table th:nth-child(2),
    .schedule-table td:nth-child(2),
    .schedule-table th:nth-child(4),
    .schedule-table td:nth-child(4) {
        width: 28%;
        min-width: 60px;
    }
    
    .team-cell {
        font-size: 0.75em;
        line-height: 1.1;
    }
    
    .date-cell {
        font-size: 0.65em;
    }
    
    .score {
        font-size: 1em;
        margin: 0;
        line-height: 1;
    }
    
    .score-cell .score-separator {
        margin: 0;
        font-size: 0.85em;
        top: -1px;
    }
    
    .search-section {
        padding: 10px;
        margin: 10px 0;
    }
    
    .team-btn {
        padding: 4px 5px;
        font-size: 0.7em;
        min-width: 55px;
        max-width: 80px;
        margin: 2px;
    }
    
    .filter-row {
        gap: 3px;
    }
    
    .cancel-btn {
        padding: 4px 6px;
        font-size: 0.7em;
    }
    
    .search-title {
        font-size: 1em;
        margin-bottom: 10px;
    }
    
    .schedule-table th:nth-child(3),
    .schedule-table td:nth-child(3) {
        width: 24%;
        min-width: 35px;
    }
    
    .schedule-table {
        min-width: 220px;
    }
    
    .score-cell {
        padding: 3px 1px;
        min-width: 35px;
    }
    
    .schedule-table td:nth-child(2),
    .schedule-table td:nth-child(4) {
        text-align: center;
    }
}

/* iPhone 13/14 Pro和类似尺寸设备 */
@media screen and (max-width: 390px) and (min-width: 376px) {
    .content-wrapper {
        margin-bottom: 8px;
    }
    
    .schedule-table {
        min-width: 245px;
    }
    
    .schedule-table th,
    .schedule-table td {
        font-size: 0.78em;
        padding: 6px 1px;
    }
    
    .team-cell {
        font-size: 0.79em;
        line-height: 1.25;
        white-space: normal;
        word-break: break-word;
    }
    
    .date-cell {
        font-size: 0.72em;
    }
    
    .score {
        font-size: 1.02em;
    }
    
    .team-btn {
        padding: 5px 8px;
        font-size: 0.78em;
        min-width: 62px;
        max-width: 88px;
    }
    
    .schedule-table td:nth-child(2),
    .schedule-table td:nth-child(4) {
        text-align: center;
    }
}

/* 改進加載條樣式 */
.loading-bar {
    width: 100%;
    height: 3px;
    background-color: #f0f0f0;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.loading-progress {
    width: 0%;
    height: 100%;
    background-color: #dc3545;
    background-image: linear-gradient(45deg, 
        rgba(255,255,255,0.2) 25%, 
        transparent 25%, 
        transparent 50%, 
        rgba(255,255,255,0.2) 50%, 
        rgba(255,255,255,0.2) 75%, 
        transparent 75%, 
        transparent);
    background-size: 16px 16px;
    animation: loading-animation 1s linear infinite;
    transition: width 0.3s ease;
}

@keyframes loading-animation {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 16px 0;
    }
}

/* 改進表格初始載入動畫 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.schedule-table tbody tr {
    animation: fadeInUp 0.3s ease-out forwards;
    animation-delay: calc(var(--row-index, 0) * 0.05s);
    opacity: 0;
}

/* 滾動時改進表格行的顯示效果 */
@media (prefers-reduced-motion: no-preference) {
    .schedule-table {
        scroll-behavior: smooth;
    }
    
    /* 為表格行添加交錯淡入效果 */
    .schedule-table tbody tr:nth-child(odd) {
        --row-index: 1;
    }
    
    .schedule-table tbody tr:nth-child(even) {
        --row-index: 2;
    }
}

/* 頁面切換過渡效果 */
.content-container {
    transition: opacity 0.2s ease;
}

/* 模態框改進樣式 */
.match-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.match-modal.visible {
    opacity: 1;
}

.match-modal-content {
    position: relative;
    width: 90%;
    height: 80%;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: scale(0.95);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.match-modal.visible .match-modal-content {
    transform: scale(1);
}

.match-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.3s ease 0.1s;
}

.match-modal.visible .match-iframe {
    opacity: 1;
}

.modal-close {
    position: absolute;
    right: -15px;
    top: -15px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #fa363a;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    z-index: 9999999;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.modal-close:hover {
    background-color: #e62e32;
    transform: scale(1.1);
}

/* 改進可點擊比賽行的觸覺反饋 */
@media (hover: hover) {
    tr.clickable-match:hover {
        transform: translateY(-1px);
    }
}

/* 提升移動設備觸摸體驗 */
@media (hover: none) {
    tr.clickable-match:active {
        background-color: #ffeeef;
    }
}

/* 保留其他樣式 */
.banner {
    width: 100%;
    margin: 0;
    padding: 0;
    line-height: 0;
    border: 2px solid #555;
}

.banner-image {
    width: 100%;
    height: auto;
    display: block;
}

.schedule-hint {
    margin: 15px 0;
    padding: 12px 15px;
    background-color: #f8f8f8;
    border-left: 4px solid #dc3545;
    color: #333;
    font-size: 0.95em;
    position: relative;
    border-radius: 0 4px 4px 0;
}

/* 提醒圖標 */
.schedule-hint::before {
    content: "⚠️";
    margin-right: 8px;
}

/* 可點擊比賽行樣式 */
tr.clickable-match {
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    border-left: 2px solid transparent;
}

tr.clickable-match:hover {
    background-color: #f0f0f0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    border-left: 2px solid #dc3545;
}

tr.clickable-match:hover .team-cell {
    color: #dc3545; /* 懸停時隊伍名稱變紅色 */
    font-weight: 500;
}

/* 添加漸變效果，更明顯的視覺提示 */
tr.clickable-match:active {
    transform: translateY(1px);
    background-color: #f8d7da;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.1s ease;
}

/* 移除可點擊比賽的指示符文字 */

/* 模態框相關樣式 */
.match-link {
    color: #fa363a;
    text-decoration: none;
    cursor: pointer;
}

.match-link:hover {
    text-decoration: underline;
}

/* 表格行增加間隔效果，改善視覺識別度 */
.schedule-table tbody tr {
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

.schedule-table tbody tr:last-child {
    border-bottom: none;
}

/* 提高表格整體視覺質感 */
.schedule-table {
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e5e5;
}

/* 改進表頭樣式 */
.schedule-table th {
    background-color: #dc3545;
    color: white;
    font-weight: bold;
    font-size: 1.05em;
    padding: 14px 6px;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
    border-bottom: 2px solid #c82333;
}