/* === RESET & BASE === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Courier New', monospace;
    background: #e8e8e8;
    color: #333;
    font-size: 14px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-text-size-adjust: 100%;
}

/* === TOUCH & TAP FEEDBACK (#14) === */
a, button, .cal-day, .filter-row label {
    -webkit-tap-highlight-color: rgba(52, 152, 219, 0.25);
}
a:active, button:active {
    opacity: 0.8;
}

/* === PREFERS REDUCED MOTION (#17) === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* === HEADER & NAV === */
header {
    background: #2c3e50;
    color: #fff;
    padding: 0.75rem 0;
    border-bottom: 3px solid #3498db;
    position: relative;
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-decoration: none;
    color: #fff;
}
nav {
    display: flex;
    gap: 2rem;
}
nav a {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    padding: 0.5rem 1rem;
    transition: background 0.2s;
}
nav a:hover, nav a.active {
    background: #3498db;
}

/* === HAMBURGER MENU === */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.75rem;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}
.hamburger span {
    display: block;
    width: 24px;
    height: 3px;
    background: #fff;
    margin: 4px 0;
    transition: all 0.3s;
}
.hamburger.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.hamburger.open span:nth-child(2) {
    opacity: 0;
}
.hamburger.open span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* === CONTAINER === */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
    flex: 1;
    width: 100%;
}

/* === HEADER BAR === */
.header-bar {
    background: #fff;
    border: 1px solid #ddd;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
}
.date-stamp {
    color: #666;
    font-weight: 600;
}
.date-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.date-nav button {
    background: #2c3e50;
    color: #fff;
    border: none;
    padding: 0.4rem 0.75rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.date-nav button:hover { background: #1a252f; }

/* === FILTER ROW === */
.search-bar {
    position: relative;
    margin-bottom: 1rem;
}
.search-bar input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1px solid #ddd;
    background: #fff;
    outline: none;
    box-sizing: border-box;
}
.search-bar input:focus {
    border-color: #3498db;
}
.search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.search-results.active {
    display: block;
}
.search-result-item {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}
.search-result-item:last-child {
    border-bottom: none;
}
.search-result-teams {
    font-weight: 700;
    color: #2c3e50;
}
.search-result-meta {
    color: #888;
    font-size: 0.8rem;
    text-align: right;
    white-space: nowrap;
}
.search-result-empty {
    padding: 1rem;
    text-align: center;
    color: #999;
}
.filter-row {
    background: #fff;
    border: 1px solid #ddd;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem 1rem;
    flex-wrap: wrap;
}
.filter-row label {
    font-weight: 600;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.5rem;
    border-radius: 3px;
    transition: background 0.15s;
    user-select: none;
}
.filter-row label:hover {
    background: #f0f0f0;
}
.filter-row label.no-matches {
    opacity: 0.45;
}
.filter-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #3498db;
}

/* === TABLE STYLES (home page - desktop) === */
.table-container {
    background: #fff;
    border: 1px solid #ddd;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table {
    width: 100%;
    border-collapse: collapse;
}
thead {
    background: #34495e;
    color: #fff;
}
th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 700;
    border-right: 1px solid #2c3e50;
    font-size: 0.85rem;
    text-transform: uppercase;
}
th:last-child { border-right: none; }
td {
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
    border-right: 1px solid #eee;
}
td:last-child { border-right: none; }
tbody tr:hover { background: #f8f9fa; }

.live-cell {
    background: #e74c3c;
    color: #fff;
    font-weight: 700;
    text-align: center;
}
.score-cell {
    font-weight: 700;
    text-align: center;
    font-size: 1.1rem;
}
.league-badge {
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
.watch-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 700;
    padding: 0.25rem;
}
.watch-link:hover { text-decoration: underline; }

/* === TEAM & LEAGUE LOGOS === */
.team-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 4px;
}
.league-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 2px;
}
.country-flag {
    width: 20px;
    height: 14px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 4px;
}
.match-card .team-logo { width: 20px; height: 20px; }
.filter-row .league-logo { width: 16px; height: 16px; }
.filter-row .country-flag { width: 16px; height: 11px; }
.match-table .team-logo { width: 20px; height: 20px; }
.match-table .league-logo { width: 16px; height: 16px; }
.match-table .country-flag { width: 16px; height: 11px; }
.league-badge .league-logo, .league-badge .country-flag { vertical-align: middle; }

/* === MOBILE MATCH CARDS (hidden on desktop, shown on mobile) === */
.match-cards {
    display: none;
}
.match-card {
    background: #fff;
    border: 1px solid #ddd;
    padding: 1rem;
    margin-bottom: 0.5rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.75rem;
    align-items: center;
}
.match-card-time {
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    min-width: 50px;
}
.match-card-status {
    font-size: 0.7rem;
    text-align: center;
    margin-top: 0.15rem;
}
.match-card-status.live {
    color: #e74c3c;
    font-weight: 700;
}
.match-card-teams {
    font-weight: 600;
    line-height: 1.4;
}
.match-card-meta {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.2rem;
}
.match-card-score {
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    min-width: 40px;
}
.match-card-league {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.5rem;
    border-top: 1px solid #eee;
    margin-top: 0.25rem;
}

/* === AD SPACE === */
.ad-row {
    background: #f5f5f5;
    border: 1px dashed #ccc;
    padding: 2rem;
    text-align: center;
    color: #999;
    margin: 1rem 0;
    font-weight: 600;
}
.ad-row .ad-mobile { display: none; }
.ad-row .ad-desktop { display: block; }

/* === STATS BAR === */
.stats-bar {
    background: #fff;
    border: 1px solid #ddd;
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    display: flex;
    justify-content: space-around;
}
.stat-item { text-align: center; }
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #3498db;
}
.stat-label {
    font-size: 0.75rem;
    color: #666;
}

/* === CALENDAR STYLES === */
.cal-nav {
    background: #fff;
    border: 1px solid #ddd;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cal-nav button {
    background: #34495e;
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-weight: 700;
    font-family: inherit;
    min-width: 44px;
    min-height: 44px;
}
.cal-nav button:hover { background: #3498db; }
.cal-month {
    font-size: 1.3rem;
    font-weight: 700;
}

.calendar-grid {
    background: #fff;
    border: 1px solid #ddd;
    touch-action: pan-y;
}
.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #34495e;
    color: #fff;
}
.cal-weekday {
    padding: 0.75rem;
    text-align: center;
    font-weight: 700;
    border-right: 1px solid #2c3e50;
}
.cal-weekday:last-child { border-right: none; }

.cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}
.cal-day {
    border: 1px solid #eee;
    padding: 0.75rem;
    min-height: 90px;
    cursor: pointer;
    transition: background 0.2s;
}
.cal-day:hover { background: #f8f9fa; }
.cal-day.today {
    background: #3498db;
    color: #fff;
    font-weight: 700;
}
.cal-day.today .day-count {
    background: #fff;
    color: #3498db;
}
.cal-days.has-selection .cal-day.today:not(.selected) {
    background: #d6eaf8;
    color: #2c3e50;
}
.cal-days.has-selection .cal-day.today:not(.selected) .day-count {
    background: #3498db;
    color: #fff;
}
.cal-day.has-matches {
    border-left: 3px solid #3498db;
}
.cal-day.other-month {
    opacity: 0.35;
    background: #f5f5f5;
}
.cal-day.other-month:hover {
    background: #f0f0f0;
}
.cal-day.selected {
    background: #2c3e50;
    color: #fff;
    font-weight: 700;
}
.cal-day.selected .day-count {
    background: #fff;
    color: #2c3e50;
}
.cal-day.today:not(.selected) {
    background: #3498db;
    color: #fff;
}
.day-num {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.day-count {
    font-size: 0.75rem;
    background: #3498db;
    color: #fff;
    padding: 0.2rem 0.4rem;
    display: inline-block;
}

.selected-date {
    background: #fff;
    border: 1px solid #ddd;
    padding: 1rem;
    margin-top: 1rem;
    scroll-margin-top: 70px;
}
.selected-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}
.match-table { width: 100%; border-collapse: collapse; }
.match-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
}
.time-col { font-weight: 700; width: 80px; }
.league-col { width: 120px; }
.teams-col { font-weight: 600; }
.link-col { width: 100px; text-align: right; }

/* === LEAGUE PAGE STYLES === */
.league-header {
    background: #fff;
    border: 1px solid #ddd;
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.league-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.league-meta {
    color: #666;
    font-weight: 600;
}

.filter-bar {
    background: #fff;
    border: 1px solid #ddd;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 1rem;
}
.filter-bar select {
    background: #34495e;
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    min-height: 44px;
}

.standings-box {
    background: #fff;
    border: 1px solid #ddd;
    margin-bottom: 1rem;
}
.box-title {
    background: #34495e;
    color: #fff;
    padding: 0.75rem 1rem;
    font-weight: 700;
    font-size: 1.1rem;
}
.standings-table { width: 100%; border-collapse: collapse; }
.standings-table th {
    background: #2c3e50;
    color: #fff;
    padding: 0.75rem;
    text-align: left;
    font-weight: 700;
}
.standings-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
}
.standings-table tbody tr:hover { background: #f8f9fa; }
.pos-col { font-weight: 700; text-align: center; width: 50px; }
.pts-col { font-weight: 700; text-align: center; background: #ecf0f1; }

.matches-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.match-row {
    background: #fff;
    border: 1px solid #ddd;
    padding: 1rem;
    display: grid;
    grid-template-columns: 100px 1fr 120px;
    gap: 1rem;
    align-items: center;
}
.match-time {
    font-size: 1.3rem;
    font-weight: 700;
}
.match-date {
    font-size: 0.8rem;
    color: #666;
}
.match-teams { font-weight: 600; }
.match-venue {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.25rem;
}
.match-link {
    background: #3498db;
    color: #fff;
    padding: 0.5rem 1rem;
    text-decoration: none;
    font-weight: 700;
    display: inline-block;
    text-align: center;
    min-height: 44px;
    min-width: 44px;
    line-height: calc(44px - 1rem);
}
.match-link:hover { background: #2980b9; }

/* === LOADING & SKELETON STATES (#13) === */
.loading {
    text-align: center;
    padding: 3rem;
    color: #666;
    font-weight: 600;
}
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #999;
    font-weight: 600;
}

/* Skeleton pulse animation */
@keyframes skeleton-pulse {
    0% { opacity: 0.6; }
    50% { opacity: 0.3; }
    100% { opacity: 0.6; }
}
.skeleton {
    background: #ddd;
    border-radius: 3px;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-row {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid #eee;
}
.skeleton-block {
    height: 1rem;
    background: #ddd;
    border-radius: 3px;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-block.w-sm { width: 50px; }
.skeleton-block.w-md { width: 120px; }
.skeleton-block.w-lg { flex: 1; }

/* === FOOTER === */
footer {
    background: #2c3e50;
    color: #fff;
    padding: 1.5rem 0;
    margin-top: auto;
    border-top: 3px solid #3498db;
}
.footer-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.footer-brand {
    font-weight: 700;
    letter-spacing: 2px;
}
.footer-links {
    display: flex;
    gap: 1.5rem;
}
.footer-links a {
    color: #bdc3c7;
    text-decoration: none;
    font-weight: 600;
    padding: 0.5rem 0;
}
.footer-links a:hover { color: #3498db; }
.footer-legal {
    display: flex;
    gap: 1.5rem;
}
.footer-legal a {
    color: #7f8c8d;
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.25rem 0;
}
.footer-legal a:hover { color: #3498db; }
.footer-meta {
    color: #7f8c8d;
    font-size: 0.85rem;
}

/* === LEGAL PAGES === */
.legal-content {
    max-width: 800px;
    line-height: 1.7;
    padding: 1rem 0 2rem;
}
.legal-content h2 {
    color: #2c3e50;
    margin: 1.5rem 0 0.5rem;
    font-size: 1.1rem;
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.25rem;
}
.legal-content h3 {
    color: #34495e;
    margin: 1rem 0 0.25rem;
    font-size: 0.95rem;
}
.legal-content p {
    margin: 0.5rem 0;
}
.legal-content ul {
    margin: 0.5rem 0 0.5rem 1.5rem;
}
.legal-content li {
    margin: 0.25rem 0;
}
.legal-content a {
    color: #3498db;
}
.legal-content a:hover {
    text-decoration: underline;
}

/* ===========================================================
   RESPONSIVE: TABLET (max-width: 968px)
   =========================================================== */
@media (max-width: 968px) {
    .hamburger { display: flex; }

    nav {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #2c3e50;
        z-index: 100;
        border-top: 1px solid #34495e;
    }
    nav.nav-open { display: flex; }
    nav a {
        padding: 1rem 1.5rem;
        border-bottom: 1px solid #34495e;
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    .container { padding: 1rem; }

    table { font-size: 0.8rem; }
    th, td { padding: 0.5rem; }

    .cal-day {
        min-height: 70px;
        padding: 0.5rem;
    }
    .day-num { font-size: 0.9rem; }

    .match-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .header-bar { flex-direction: column; gap: 0.5rem; text-align: center; }
    .page-title { font-size: 1.3rem; }

    .footer-content { flex-direction: column; text-align: center; }
    .footer-links { justify-content: center; }
    .footer-legal { justify-content: center; }

    .filter-row { flex-direction: column; gap: 0.5rem; }
    .filter-bar { flex-direction: column; }
    .filter-bar select { width: 100%; }

    /* League title scale down */
    .league-title { font-size: 1.5rem; }
    .league-header { padding: 1rem; }

    /* Calendar match-table fixed widths removed */
    .time-col { width: auto; }
    .league-col { width: auto; }
    .link-col { width: auto; }
}

/* ===========================================================
   RESPONSIVE: PHONE (max-width: 600px)
   =========================================================== */
@media (max-width: 600px) {
    body { font-size: 13px; }
    .container { padding: 0.75rem; }

    /* (#2) Home page: hide table, show cards */
    .table-container { display: none; }
    .match-cards { display: block; }

    /* (#3) Calendar compact */
    .cal-weekday {
        padding: 0.5rem 0.15rem;
        font-size: 0.7rem;
    }
    .cal-day {
        min-height: 55px;
        padding: 0.35rem;
    }
    .day-num { font-size: 0.8rem; margin-bottom: 0.2rem; }
    .day-count {
        font-size: 0.6rem;
        padding: 0.1rem 0.25rem;
    }
    .cal-month { font-size: 1rem; }
    .cal-nav button { padding: 0.5rem 0.75rem; font-size: 0.85rem; }

    /* Calendar selected-date */
    .selected-date { padding: 0.75rem; }
    .selected-title { font-size: 1rem; }
    .match-table td { padding: 0.5rem 0.25rem; font-size: 0.85rem; }

    /* (#5) Font scaling */
    .page-title { font-size: 1.1rem; }
    .league-title { font-size: 1.3rem; }

    /* (#7) Stats bar stack */
    .stats-bar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    .stat-item {
        flex: 1 0 30%;
        min-width: 80px;
    }
    .stat-value { font-size: 1.2rem; }

    /* (#8) Ad row mobile sizing */
    .ad-row {
        padding: 1.25rem 0.5rem;
        font-size: 0.8rem;
    }
    .ad-row .ad-desktop { display: none; }
    .ad-row .ad-mobile { display: block; }

    /* (#9) Filter touch targets */
    .filter-row label {
        padding: 0.6rem 0.75rem;
        min-height: 44px;
    }
    .filter-row input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }

    /* (#12) Selects full width */
    .filter-bar select {
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 14px;
    }

    /* Match rows on leagues page */
    .match-row { padding: 0.75rem; }
    .match-time { font-size: 1.1rem; }
    .match-link {
        width: 100%;
        text-align: center;
    }

    /* Footer compact */
    footer { padding: 1rem 0; }
    .footer-brand { font-size: 0.9rem; }
    .footer-links { gap: 1rem; }
    .footer-links a { font-size: 0.85rem; }
    .footer-meta { font-size: 0.75rem; }
}

/* ===========================================================
   RESPONSIVE: SMALL PHONE (max-width: 380px) (#1)
   =========================================================== */
@media (max-width: 380px) {
    body { font-size: 12px; }
    .container { padding: 0.5rem; }
    .logo { font-size: 1rem; letter-spacing: 1px; }

    .cal-day { min-height: 48px; padding: 0.25rem; }
    .day-num { font-size: 0.75rem; }
    .day-count { font-size: 0.55rem; }

    .match-card { padding: 0.75rem; gap: 0.5rem; }
    .match-card-time { font-size: 0.95rem; min-width: 40px; }
    .match-card-teams { font-size: 0.9rem; }

    .stat-item { flex: 1 0 45%; }

    .header-bar { padding: 0.75rem; }
}

/* ===========================================================
   LANDSCAPE ON PHONES (#19)
   =========================================================== */
@media (max-height: 500px) and (orientation: landscape) {
    header {
        padding: 0.4rem 0;
        position: relative;
    }
    header .logo { font-size: 1rem; }
    .hamburger { min-height: 36px; min-width: 36px; padding: 0.4rem; }
    .hamburger span { margin: 3px 0; }

    nav a { padding: 0.6rem 1.5rem; min-height: 40px; }

    .container { padding: 0.5rem 1rem; }
    .header-bar { padding: 0.5rem; margin-bottom: 0.5rem; }
    .page-title { font-size: 1rem; }

    .cal-day { min-height: 45px; }

    footer { padding: 0.5rem 0; }
    .footer-content { gap: 0.5rem; }
}
