/* 錦標賽容器 */
.tournament-container {
    text-align: center;
    padding: 10px;
}

/* 循環賽區塊樣式 */
.round-robin-section {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 20px auto;
    background-color: transparent;
    border: 2px solid #fb923c;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    text-align: left;
}

.round-robin-section h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #b45309;
    margin-bottom: 20px;
    text-align: center;
}

/* 組別容器 - 預設手機版單列 */
.round-robin-groups-container {
    display: block;
}

/* 單場比賽組別 */
.single-match-group {
    display: flex;
    flex-direction: column;
}

/* 單場比賽組別水平佈局 - 預設手機版垂直 */
.single-match-group .round-robin-match-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.single-match-group .round-robin-match {
    flex: 1;
    display: flex !important;
    flex-direction: column !important;
    align-items: center;
    margin-bottom: 12px;
    padding: 16px !important;
    gap: 12px !important;
    justify-content: center !important;
    width: 100%;
}

.single-match-group .round-robin-match .team-score-wrapper {
    flex: none !important;
    max-width: none !important;
}

/* 四強賽特殊佈局 - 預設手機版垂直 */
.semifinals-group .round-robin-match-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.semifinals-group .round-robin-match {
    flex: 1;
    display: flex !important;
    flex-direction: column !important;
    align-items: center;
    margin-bottom: 12px;
    padding: 16px !important;
    gap: 12px !important;
    justify-content: center !important;
    width: 100%;
}

.semifinals-group .round-robin-match .team-score-wrapper {
    flex: none !important;
    max-width: none !important;
}

/* 循環賽組別樣式 */
.round-robin-group {
    background: linear-gradient(135deg, #ffffff 0%, #fef7ec 100%);
    border: 2px solid #fb923c;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 8px 25px rgba(251, 146, 60, 0.15);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* 循環賽比賽容器 - 預設手機版垂直，大螢幕水平 */
.round-robin-group .round-robin-match-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.round-robin-group .round-robin-match {
    flex: 1;
    display: flex !important;
    flex-direction: column !important;
    align-items: center;
    margin-bottom: 12px;
    padding: 16px !important;
    gap: 12px !important;
    justify-content: center !important;
    width: 100%;
}

.round-robin-group .round-robin-match .team-score-wrapper {
    flex: none !important;
    max-width: none !important;
}

.round-robin-group::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #fb923c 0%, #f97316 50%, #ea580c 100%);
}

.round-robin-group:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 35px rgba(251, 146, 60, 0.25);
}

.round-robin-group h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #7c2d12;
    margin-bottom: 16px;
    border-bottom: none;
    padding-bottom: 0;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
}

.round-robin-group h3::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 3px;
    background: linear-gradient(90deg, #fb923c 0%, #f97316 100%);
    border-radius: 2px;
}

/* 比賽項目樣式 - 垂直佈局 */
.round-robin-match {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #fed7aa;
    background: linear-gradient(135deg, #fff 0%, #fef7ec 100%);
    border-radius: 8px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(251, 146, 60, 0.1);
}

.round-robin-match:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(251, 146, 60, 0.2);
}

.round-robin-match:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* 包裝器 - 垂直排列 */
.team-score-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
}

/* 隊伍容器和隊伍框 - 預設手機版 */
.team-container {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    min-height: 40px;
    width: 100%;
}

.team-container>span:not(.team-box) {
    font-weight: 700;
    color: #7c2d12;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    flex-shrink: 0;
}

.team-box {
    background: linear-gradient(135deg, #fef7ec 0%, #fed7aa 100%);
    border: 2px solid #f97316;
    border-radius: 8px;
    padding: 10px 12px;
    font-weight: 600;
    font-size: 0.85rem;
    color: #7c2d12;
    text-align: center;
    width: 60px;
    min-width: 60px;
    max-width: 60px;
    box-shadow: 0 2px 6px rgba(249, 115, 22, 0.15);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    line-height: 1.2;
    flex-shrink: 0;
}

.team-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(249, 115, 22, 0.25);
    border-color: #ea580c;
}

/* 比分容器和比分框 - 預設手機版 */
.score-container {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.score-box {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #ffffff 0%, #fef3e2 100%);
    border: 2px solid #fb923c;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.2rem;
    color: #ea580c;
    box-shadow: 0 2px 8px rgba(251, 146, 60, 0.15);
    transition: all 0.3s ease;
}

.score-box:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(251, 146, 60, 0.25);
}

/* 總比分隊伍顏色 */
.score-box.team-left {
    background: #dbeafe;
    border: 2px solid #3b82f6;
    color: #1d4ed8;
    box-shadow: 0 2px 8px rgba(219, 234, 254, 0.5);
}

.score-box.team-right {
    background: #fecaca;
    border: 2px solid #ef4444;
    color: #dc2626;
    box-shadow: 0 2px 8px rgba(254, 202, 202, 0.5);
}

/* 比賽狀態容器 - 預設手機版 */
.status-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: stretch;
}

/* 比賽信息按鈕（場次+時間） - 修改為對齊vs文字 */
.match-info {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 12px 60px 12px 16px;
    border-radius: 8px;
    border: 2px solid #fb923c;
    background: linear-gradient(135deg, #ffffff 0%, #fef3e2 100%);
    color: #7c2d12;
    text-align: center;
    box-shadow: 0 2px 4px rgba(251, 146, 60, 0.15);
    width: 200px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    line-height: 1.2;
    margin-bottom: 0;
    min-height: 44px;
    position: relative;
}

.match-info .match-number {
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    width: 100%;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
}

.match-info .match-time {
    font-size: 0.8rem;
    font-weight: 600;
    opacity: 0.9;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 100%;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

/* 循環賽隊伍列表 - 預設手機版 */
.round-robin-teams-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin: 30px 0 40px 0;
    padding: 15px;
    background: linear-gradient(135deg, #fef7ec 0%, #fff 100%);
    border-radius: 16px;
    border: 1px solid #fed7aa;
}

.round-robin-team-card {
    background: linear-gradient(135deg, #ffffff 0%, #fef3e2 100%);
    border: 2px solid #fb923c;
    border-radius: 12px;
    padding: 12px 16px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(251, 146, 60, 0.1);
    font-weight: 700;
    color: #7c2d12;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 45px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
}

.round-robin-team-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(251, 146, 60, 0.1), transparent);
    transition: left 0.6s ease;
}

.round-robin-team-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 8px 25px rgba(251, 146, 60, 0.25);
    border-color: #ea580c;
}

.round-robin-team-card:hover::before {
    left: 100%;
}

/* 決賽組別 - 預設手機版垂直佈局 */
.final-match-group {
    width: 100% !important;
    display: block !important;
    margin: 0 0 24px 0 !important;
}

/* 隊伍顏色標示 */
.team-box.team-left {
    background: #dbeafe;
    color: #1d4ed8;
    border: 2px solid #3b82f6;
    box-shadow: 0 2px 8px rgba(219, 234, 254, 0.5);
}

.team-box.team-right {
    background: #fecaca;
    color: #dc2626;
    border: 2px solid #ef4444;
    box-shadow: 0 2px 8px rgba(254, 202, 202, 0.5);
}

/* 局分顯示區塊 */
.set-scores {
    display: flex;
    flex-direction: row;
    gap: 8px;
    justify-content: center;
    align-items: center;
    margin-top: 8px;
    flex-wrap: wrap;
}

.set-score {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 50px;
    text-align: center;
}

.set-score.left-win {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #3b82f6;
    box-shadow: 0 2px 4px rgba(219, 234, 254, 0.5);
}

.set-score.right-win {
    background: #fecaca;
    color: #dc2626;
    border: 1px solid #ef4444;
    box-shadow: 0 2px 4px rgba(254, 202, 202, 0.5);
}

.set-score.unplayed {
    background: #e5e7eb;
    color: #9ca3af;
    border: 1px solid #d1d5db;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .set-scores {
        gap: 6px;
        margin-top: 6px;
    }

    .set-score {
        padding: 3px 6px;
        font-size: 0.7rem;
        min-width: 45px;
    }
}

@media (max-width: 480px) {
    .set-scores {
        gap: 4px;
        margin-top: 6px;
    }

    .set-score {
        padding: 2px 5px;
        font-size: 0.65rem;
        min-width: 40px;
    }
}

/* ==========================================================================
   響應式設計 (RWD) - Mobile First with min-width
   ========================================================================== */

/* 超小手機 (480px+) */
@media (min-width: 480px) {
    .round-robin-teams-list {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 20px;
        padding: 20px;
    }

    .round-robin-team-card {
        padding: 16px 20px;
        font-size: 1rem;
        min-height: 50px;
    }

    .team-container>span:not(.team-box) {
        min-height: 44px;
        font-size: 1rem;
    }

    .team-box {
        min-height: 44px;
        width: 90px;
        min-width: 90px;
        max-width: 90px;
    }
}

/* 手機橫向 (600px+) */
@media (min-width: 600px) {
    .score-container {
        gap: 12px;
    }

    .score-box {
        width: 50px;
        height: 50px;
        font-size: 1.4rem;
    }

    .team-container {
        min-height: 60px;
    }

    .round-robin-match {
        padding: 20px 24px;
    }

    .match-info {
        font-size: 0.9rem;
        padding: 14px 20px;
        min-height: 48px;
    }

    .match-info .match-number,
    .match-info .match-time {
        font-size: 0.85rem;
    }
}

/* 平板直向 (769px+) */
@media (min-width: 769px) {
    .tournament-container {
        padding: 20px;
    }

    .round-robin-section {
        margin-bottom: 40px;
        padding: 20px;
    }

    /* 單場比賽跨越兩列 */
    .single-match-group {
        grid-column: 1 / -1;
    }

    /* 四強賽改為水平並排 */
    .semifinals-group .round-robin-match-container {
        flex-direction: row;
        gap: 24px;
    }

    .semifinals-group .round-robin-match {
        margin-bottom: 0;
        padding: 20px 24px !important;
        width: auto;
    }

    /* 決賽組別水平排列 */
    .final-match-group {
        grid-column: auto !important;
        width: 48% !important;
        display: inline-block !important;
        vertical-align: top !important;
        margin: 0 1% !important;
        text-align: left !important;
    }

    .final-match-group .round-robin-match {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        align-items: center !important;
        padding: 20px 24px !important;
    }

    .final-match-group .team-score-wrapper {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 16px !important;
        width: 100% !important;
    }

    .team-box {
        width: 100px;
        min-width: 100px;
        max-width: 100px;
        font-size: 0.8rem;
        padding: 8px 10px;
    }

    .match-info {
        font-size: 0.8rem;
        padding: 12px 16px;
        width: 100%;
        min-height: 40px;
    }

    .match-info .match-number {
        font-size: 0.75rem;
    }

    .match-info .match-time {
        font-size: 0.75rem;
    }

    /* 循環賽組別樣式 */
    .round-robin-group {
        padding: 24px;
        margin-bottom: 24px;
    }

    .round-robin-group h3 {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }

    /* 循環賽組別內比賽改為兩個一列 */
    .round-robin-group .round-robin-match-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }

    .round-robin-group .round-robin-match {
        margin-bottom: 0;
        padding: 20px 24px !important;
        width: auto;
        grid-column: span 1;
    }

    .round-robin-group .round-robin-match:last-child:nth-child(odd) {
        grid-column: 1 / -1;
        max-width: 50%;
        margin: 0 auto;
    }

    /* 單場比賽組別改為水平並排 */
    .single-match-group .round-robin-match-container {
        flex-direction: row;
        gap: 24px;
        flex-wrap: wrap;
    }

    .single-match-group .round-robin-match {
        margin-bottom: 0;
        padding: 20px 24px !important;
        width: auto;
        min-width: 300px;
        flex: 1;
    }
}

/* 平板橫向/小筆電 (900px+) */
@media (min-width: 900px) {
    .round-robin-groups-container {
        gap: 24px;
    }

    .team-box {
        width: 130px;
        min-width: 130px;
        max-width: 130px;
        font-size: 0.9rem;
        padding: 10px 14px;
    }

    .team-container>span:not(.team-box) {
        font-size: 0.95rem;
    }

    .round-robin-match {
        padding: 18px 20px;
    }

    .score-box {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
}

/* 中等螢幕 (1024px+) */
@media (min-width: 1024px) {
    .round-robin-groups-container {
        gap: 28px;
    }

    .team-box {
        width: 120px;
        min-width: 120px;
        max-width: 120px;
        font-size: 0.95rem;
        padding: 12px 16px;
    }

    .team-container>span:not(.team-box) {
        font-size: 1rem;
    }

    .score-box {
        width: 50px;
        height: 50px;
        font-size: 1.4rem;
    }

    .match-info {
        font-size: 0.9rem;
        padding: 14px 20px;
        width: 100%;
        min-height: 48px;
    }

    .match-info .match-number {
        font-size: 0.85rem;
        text-align: center;
    }

    .match-info .match-time {
        font-size: 0.85rem;
    }
}

/* 大螢幕 (1200px+) */
@media (min-width: 1200px) {
    .round-robin-groups-container {
        gap: 32px;
    }
}
/* 手機橫向 (max-width: 599px) */
@media (max-width: 599px) {
    .round-robin-teams-list {
        grid-template-columns: repeat(2, 1fr);
        /* 固定2列顯示 */
        gap: 15px;
        padding: 15px;
    }

    .score-container {
        gap: 8px;
    }

    .score-box {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }

    .team-container {
        min-height: 40px;
    }

    .round-robin-match {
        padding: 16px;
    }
}

/* 手機直向 (max-width: 479px) */
@media (max-width: 479px) {
    .round-robin-teams-list {
        grid-template-columns: repeat(2, 1fr);
        /* 固定2列顯示 */
        gap: 12px;
        padding: 12px;
    }

    .round-robin-team-card {
        padding: 10px 12px;
        font-size: 0.8rem;
        min-height: 45px;
    }

    .team-score-wrapper {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        width: 100% !important;
        align-items: center !important;
    }

    .status-container {
        grid-column: unset !important;
        grid-row: unset !important;
        width: 100% !important;
        margin-bottom: 8px !important;
    }

    .team-container {
        grid-column: unset !important;
        grid-row: unset !important;
        min-height: 40px;
    }

    .set-scores {
        grid-column: unset !important;
        grid-row: unset !important;
        margin-top: 0 !important;
    }

    .score-container {
        grid-column: unset !important;
        grid-row: unset !important;
        min-width: 100px !important;
    }

    .team-container>span:not(.team-box) {
        min-height: 35px;
        font-size: 0.85rem;
        flex-shrink: 0;
    }

    .team-box {
        width: 60px;
        min-width: 60px;
        max-width: 60px;
        min-height: 35px;
        line-height: 1.15;
        font-size: 0.8rem;
        flex-shrink: 0;
    }

    .match-info {
        font-size: 0.7rem;
        padding: 0px 10px !important;
        min-width: 55px;
        min-height: 36px;
        width: 100% !important;
        justify-content: space-between !important;
    }

    .match-info .match-number {
        font-size: 0.65rem;
        text-align: left !important;
        position: static !important;
        width: auto !important;
        left: auto !important;
        top: auto !important;
        bottom: auto !important;
        transform: none !important;
        display: block !important;
    }

    .match-info .match-time {
        font-size: 0.7rem;
        right: auto !important;
        position: static !important;
        top: auto !important;
        transform: none !important;
        text-align: right !important;
        display: block !important;
        margin-left: auto !important;
        flex-shrink: 0 !important;
    }
}

/* 平板以下螢幕 (max-width: 768px and min-width: 480px) - 統一回復到垂直佈局 */
@media (max-width: 768px) and (min-width: 480px) {
    .team-score-wrapper {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        width: 100% !important;
        align-items: center !important;
    }
    
    .status-container {
        grid-column: unset !important;
        grid-row: unset !important;
        width: 100% !important;
        margin-bottom: 8px !important;
    }
    
    .team-container {
        grid-column: unset !important;
        grid-row: unset !important;
        width: 100% !important;
    }
    
    .set-scores {
        grid-column: unset !important;
        grid-row: unset !important;
        margin-top: 8px !important;
        gap: 6px;
    }
    
    .score-container {
        grid-column: unset !important;
        grid-row: unset !important;
        width: 100% !important;
        min-width: unset !important;
    }
    
    .match-info {
        width: 100% !important;
        padding: 12px 60px 12px 16px !important;
    }
    
    .match-info .match-time {
        right: 16px !important;
    }
    
    .set-score {
        padding: 3px 6px;
        font-size: 0.7rem;
        min-width: 45px;
    }
}
