/* --- 1. Global Settings --- */
:root {
    --color-bg: #1e2d3b; /* (สีม่วงเข้ม) */
    --color-bg-card: #ffffff;
    --color-text: #ffffff;
    --color-text-dark: #333;
    --color-primary: #fdd835; /* (สีเหลือง) */
    --color-accent: #22334d;
    --color-purple-light: #1e2d3b;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
body, html {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    height: 100%;
    overflow: hidden; 
}
* {
    box-sizing: border-box;
}

/* --- 2. Main Layout --- */
.schedule-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: var(--color-bg);
}

/* --- 3. Header --- */
.schedule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1.5rem;
    background: transparent; /* (โปร่งใส) */
    border-bottom: 2px solid var(--color-purple-light);
    flex-shrink: 0;
}
.schedule-header h1 {
    color: var(--color-text);
    font-size: 1.5rem;
    margin: 0;
}
#fullscreen-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: #eee;
}

/* --- 4. Main Navigation --- */
.main-nav {
    display: flex;
    justify-content: center; /* (จัดกลาง) */
    background: transparent;
    flex-shrink: 0;
    border-bottom: 1px solid var(--color-purple-light);
    padding: 0 1rem;
}
.nav-btn {
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: #eee;
    font-weight: 500;
    border-bottom: 3px solid transparent;
}
.nav-btn.active, .nav-btn:hover {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* --- 5. Body (Sidebar + Timeline) --- */
.schedule-body {
    display: flex;
    flex-direction: column; /* (เปลี่ยนเป็นแนวตั้ง) */
    flex: 1;
    overflow: hidden;
}

/* --- 6. Date Sidebar (Mobile First Design) --- */
.date-sidebar {
    flex-shrink: 0;
    width: 100%;
    background: rgba(0,0,0,0.1);
    border-bottom: 1px solid var(--color-purple-light);
    white-space: nowrap; 
    overflow-x: auto; 
    padding: 0.75rem;
    display: flex; 
}
.date-sidebar p {
    padding: 0.75rem 1rem;
    color: #aaa;
    margin: 0;
}
.date-btn {
    display: block;
    width: auto; 
    flex-shrink: 0;
    padding: 0.75rem 1.25rem;
    margin: 0 0.25rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 20px; /* (ปุ่มแบบ Pills) */
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.date-btn:hover {
    background: rgba(255,255,255,0.15);
}
.date-btn.active {
    background: var(--color-primary);
    color: var(--color-text-dark);
    font-weight: 700;
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(253, 216, 53, 0.3);
}

/* --- 7. Schedule Timeline --- */
.schedule-timeline {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    max-width: 800px;
    width: 100%;
    margin: 0 auto; /* (จัดกลาง) */
}
.loading, .schedule-timeline > p {
    text-align: center;
    font-size: 1.2rem;
    color: #aaa;
    margin-top: 3rem;
}

/* --- 8. Match Card Design (ดีไซน์ใหม่) --- */
.match-card {
    background: transparent;
    border: none;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

/* (ส่วนหัวของการ์ด: 🏆 ฟุตซอล 🕒 ช่วงพักเที่ยง) */
.match-card-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #eee;
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}
.sport-icon, .time-icon {
    font-size: 0.9rem;
    opacity: 0.8;
}
.sport-name {
    font-weight: 700;
    color: #fff;
}
.time-slot {
    font-weight: 700;
    color: var(--color-primary);
}

/* (ส่วนตัวการ์ด: สีฟ้า VS สีชมพู) */
.match-card-body {
    background: var(--color-bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    color: var(--color-text-dark);
}

/* (การ์ดแบบ Event) */
.match-card.event .match-card-body {
    background: var(--color-purple-light);
    color: #fff;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 500;
    display: block;
    padding: 1.5rem;
}
.match-card.event .match-desc {
    font-size: 1rem;
    opacity: 0.8;
    margin-top: 0.25rem;
}

/* (การ์ดแบบ VS) */
.match-card.vs .team {
    font-size: 1.8rem;
    font-weight: 900; /* (ตัวอักษรหนา) */
    flex: 1;
}
.match-card.vs .team-a {
    text-align: right;
    padding-right: 1rem;
}
.match-card.vs .team-b {
    text-align: left;
    padding-left: 1rem;
}

/* (ปุ่ม VS ตรงกลาง) */
.match-card.vs .vs-graphic {
    background: var(--color-primary);
    color: var(--color-text-dark);
    font-weight: 900;
    font-size: 1.2rem;
    padding: 0.75rem;
    border-radius: 8px;
    margin: 0 0.5rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* --- 9. Responsive --- */
@media (max-width: 768px) {
    .schedule-header h1 {
        font-size: 1.2rem;
    }
    .nav-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    .schedule-timeline {
        padding: 1rem 0.5rem;
    }

    .match-card-header {
        font-size: 0.9rem;
    }
    .match-card.vs .team {
        font-size: 1.1rem; /* (ย่อบนมือถือ) */
        padding: 0 0.5rem;
    }
    .match-card.vs .vs-graphic {
        padding: 0.5rem;
        font-size: 1rem;
        margin: 0;
    }
    .match-card-body {
        padding: 1rem 0.75rem;
    }
    .match-card.event .match-card-body {
        font-size: 1.1rem;
    }
}



/* --- CSS ?????????????????????? (Results) --- */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.result-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    overflow: hidden;
    border: 2px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease;
}
.result-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

/* Header ???????? */
.result-header {
    background: #f9f9f9;
    padding: 0.8rem 1rem;
    border-bottom: 2px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.result-sport-name {
    font-weight: 700;
    color: #555;
    font-size: 1rem;
}
.result-date {
    font-size: 0.85rem;
    color: #888;
    background: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid #ddd;
}

/* Body ??? VS (Scoreboard) */
.result-body-vs {
    padding: 1.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.vs-team {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}
.vs-team-name {
    font-weight: 700;
    font-size: 1.1rem;
}
.vs-score {
    font-size: 2rem;
    font-weight: 900;
    color: #333;
    background: #f4f4f4;
    width: 50px;
    height: 50px;
    line-height: 50px;
    border-radius: 8px;
}
.vs-divider {
    font-weight: bold;
    color: #ccc;
    margin: 0 10px;
}
/* ???????????? */
.vs-team.winner .vs-team-name { text-decoration: underline; }
.vs-team.winner .vs-score { background: #fff59d; color: #f57f17; border: 2px solid #fdd835; }
.vs-team.loser { opacity: 0.6; }

/* Body ??? Rank (List) */
.result-body-rank {
    padding: 1rem;
}
.rank-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.rank-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed #eee;
}
.rank-item:last-child { border-bottom: none; }
.rank-badge {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-right: 10px;
    font-size: 1.1rem;
}
.rank-team { font-weight: 600; font-size: 1rem; }
.rank-score { margin-left: auto; font-size: 0.9rem; color: #777; }

/* ???????? Fullscreen */
#schedule-container:fullscreen .result-card,
#schedule-container:-webkit-full-screen .result-card {
    border: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}
#schedule-container:fullscreen .results-grid {
     /* ???? Grid ???????? */
     grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
}