/* ==========================================
    1. CSS 變數隔離 (黑底 + 亮黃/亮藍點綴)
========================================== */
#fsm-app {
    --fsm-bg-body: #000000;
    /* 純黑背景 */
    --fsm-bg-card: #141414;
    /* 深灰卡片底色 */
    --fsm-border: #2a2a2a;
    /* 暗色邊線 */
    --fsm-accent: #ffcc00;
    /* 亮黃色強調 */
    --fsm-accent-blue: #3b50ff;
    /* 亮藍色強調 */
    --fsm-text-main: #ffffff;
    /* 白色主文字 */
    --fsm-text-muted: #999999;
    /* 灰色次要文字 */
    --fsm-transition: all 0.3s ease;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--fsm-bg-body);
    color: var(--fsm-text-main);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    min-height: 100vh;
}

#fsm-app * {
    box-sizing: border-box;
}

/* 專屬容器 */
.fsm-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ==========================================
           2. 頁首區塊
           ========================================== */
.fsm-header {
    background-color: rgba(0, 0, 0, 0.85);
    border-bottom: 1px solid var(--fsm-border);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.fsm-header-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.fsm-logo {
    font-size: 1.5rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 1px;
}

.fsm-logo i {
    color: var(--fsm-accent);
}

.fsm-search-wrapper {
    position: relative;
    flex-grow: 1;
    max-width: 300px;
}

.fsm-search-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--fsm-text-muted);
}

.fsm-search-input {
    width: 100%;
    padding: 10px 15px 10px 35px;
    border: 1px solid var(--fsm-border);
    border-radius: 8px;
    background-color: var(--fsm-bg-card);
    color: var(--fsm-text-main);
    outline: none;
    transition: var(--fsm-transition);
}

.fsm-search-input::placeholder {
    color: var(--fsm-text-muted);
}

.fsm-search-input:focus {
    border-color: var(--fsm-accent);
    box-shadow: 0 0 0 3px rgba(255, 204, 0, 0.15);
}

/* ==========================================
           3. 橫幅與共用元件
           ========================================== */
.fsm-main {
    padding-bottom: 60px;
}

.fsm-banner {
    width: 100%;
    height: 250px;
    object-fit: cover;
    border-radius: 12px;
    margin: 30px 0;
    border: 1px solid var(--fsm-border);
    opacity: 0.9;
}

.fsm-section-title {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: var(--fsm-text-main);
    border-left: 4px solid var(--fsm-accent);
    padding-left: 12px;
    font-weight: bold;
}

.fsm-hidden {
    display: none !important;
}

.fsm-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
}

/* 外層科技光環 (正向旋轉) */
.fsm-loader-ring {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--fsm-accent);       /* 亮黃色 */
    border-bottom-color: var(--fsm-accent-blue); /* 亮藍色 */
    animation: fsm-spin 1.5s linear infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

/* 內層科技光環 (反向旋轉) */
.fsm-loader-ring::before {
    content: "";
    position: absolute;
    top: 5px; left: 5px; right: 5px; bottom: 5px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-left-color: var(--fsm-accent-blue);
    border-right-color: var(--fsm-accent);
    animation: fsm-spin-reverse 1s linear infinite;
}

/* 懸浮跳動的足球 */
.fsm-bouncing-ball {
    font-size: 20px;
    color: var(--fsm-text-main);
    /* 抵銷外層的旋轉，讓球保持正向並上下跳動 */
    animation: fsm-spin-reverse 1.5s linear infinite, fsm-bounce 0.5s alternate infinite ease-in-out;
}


.fsm-loader-text {
    font-size: 1.1rem;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--fsm-accent);
    animation: fsm-pulse 1.5s ease-in-out infinite;
}

.fsm-loader-text::after {
    content: '';
    display: inline-block;
    width: 1em;
    text-align: left;
    animation: fsm-dots 1.5s steps(4, end) infinite;
}

/* 動畫關鍵影格 (Keyframes) */
@keyframes fsm-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes fsm-spin-reverse {
    0% { transform: rotate(360deg); }
    100% { transform: rotate(0deg); }
}
@keyframes fsm-bounce {
    0% { margin-top: -10px; }
    100% { margin-top: 10px; }
}
@keyframes fsm-pulse {
    0%, 100% { opacity: 0.6; text-shadow: none; }
    50% { opacity: 1; text-shadow: 0 0 10px rgba(255, 204, 0, 0.5); }
}
@keyframes fsm-dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: ''; }
}



/* ==========================================
           4. 聯賽卡片區塊
           ========================================== */
.fsm-league-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.fsm-league-card {
    background-color: var(--fsm-bg-card);
    border: 1px solid var(--fsm-border);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: var(--fsm-transition);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.fsm-league-card:hover {
    transform: translateY(-5px);
    border-color: var(--fsm-accent);
    box-shadow: 0 10px 20px rgba(255, 204, 0, 0.05);
}

.fsm-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.fsm-league-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--fsm-text-main);
    margin: 0;
}

.fsm-match-count {
    background-color: #222222;
    color: var(--fsm-text-muted);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    border: 1px solid var(--fsm-border);
    flex-shrink: 0;
}

.fsm-card-footer {
    display: flex;
    justify-content: flex-end;
}

.fsm-view-btn {
    color: var(--fsm-accent);
    font-weight: bold;
    font-size: 0.9rem;
    transition: var(--fsm-transition);
}

/* ==========================================
           5. 賽程詳細列表元件 (為 JS 動態生成保留)
           ========================================== */
.fsm-back-btn {
    background: transparent;
    border: 1px solid var(--fsm-border);
    color: var(--fsm-text-main);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 25px;
    transition: var(--fsm-transition);
}

.fsm-back-btn:hover {
    background: var(--fsm-bg-card);
    border-color: var(--fsm-accent);
    color: var(--fsm-accent);
}


.fsm-match-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.fsm-match-item {
    background: var(--fsm-bg-card);
    border: 1px solid var(--fsm-border);
    border-radius: 12px;
    padding: 20px;
}

.fsm-match-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--fsm-text-muted);
    border-bottom: 1px solid var(--fsm-border);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.fsm-status {
    color: var(--fsm-accent);
    font-weight: bold;
}

.fsm-match-teams {
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* 核心：強制左右均分，中間自適應 */
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: bold;
}

/* 確保左邊隊伍靠左齊行 */
.fsm-team {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* 內容靠左 */
    gap: 10px;
    /* (可選) 避免隊名太長破版，超出自動變成... */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 確保右邊隊伍靠右齊行 */
.fsm-team-away {
    justify-content: flex-end; /* 內容靠右 */
}

/* 中間的比分板 */
.fsm-score-board {
    justify-self: center; /* 在網格的正中間 */
    padding: 5px 15px;
    background: #000;
    color: var(--fsm-accent);
    border: 1px solid var(--fsm-border);
    border-radius: 6px;
    font-size: 1.2rem;
    letter-spacing: 2px;
    white-space: nowrap;
}

/* ==========================================
           6. 響應式
           ========================================== */
@media (max-width: 768px) {
    .fsm-header-content {
        flex-direction: column;
        align-items: stretch;
    }

    .fsm-search-wrapper {
        max-width: 100%;
    }

    .fsm-banner {
        height: 150px;
    }
}


#fsm-leagues-view {
    padding-bottom: 15px;
}

#fsm-matches-view {
    padding-bottom: 15px;
}