:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-hover: rgba(51, 65, 85, 0.8);
    --accent-color: #10b981;
    /* Neon Green */
    --accent-glow: rgba(16, 185, 129, 0.3);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: rgba(148, 163, 184, 0.1);

    --font-heading: 'Teko', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 20%);
}

/* Header */
.header {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0 20px;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 1px;
}

.highlight {
    color: var(--accent-color);
}

/* Navigation */
.nav {
    display: flex;
    gap: 20px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    transition: color 0.3s;
    position: relative;
}

.nav-link.active,
.nav-link:hover {
    color: var(--text-primary);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -24px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent-color);
    box-shadow: 0 -2px 10px var(--accent-glow);
}

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.filter-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.filter-btn.active,
.filter-btn:hover {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

/* Matches System */
.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 15px;
}

.section-header h2 {
    font-family: var(--font-heading);
    font-size: 32px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.live-pulse {
    color: #ef4444;
    /* Live Red */
    font-size: 18px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
        transform: scale(0.9);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }

    100% {
        opacity: 0.5;
        transform: scale(0.9);
    }
}

/* Grid Layout */
.matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}

@media (max-width: 768px) {
    .matches-grid {
        grid-template-columns: 1fr;
    }
}

/* Match Card */
.match-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.match-card:hover {
    transform: translateY(-4px);
    background: var(--bg-card-hover);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.5), 0 0 15px var(--accent-glow);
    border-color: rgba(16, 185, 129, 0.4);
}

.card-header {
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.match-status {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.match-status.live {
    color: #ef4444;
}

.match-status.finished {
    color: var(--accent-color);
}

.card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Team Row */
.team-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.team-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.team-flag {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    /* Circle flags */
    object-fit: cover;
    background: #1e293b;
    border: 2px solid rgba(255, 255, 255, 0.05);
}

.team-name {
    font-weight: 600;
    font-size: 16px;
}

.team-score {
    text-align: right;
}

.runs {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 600;
}

.overs {
    font-size: 12px;
    color: var(--text-secondary);
}

.card-footer {
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-secondary);
}

.match-result {
    color: var(--accent-color);
    font-weight: 500;
}

/* Loading Spinner */
.loading-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 20px;
    border: 3px solid rgba(16, 185, 129, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Match Detail Section */
.match-detail-section {
    position: fixed;
    top: 70px;
    /* Below Header */
    left: 0;
    width: 100%;
    height: calc(100vh - 70px);
    background: var(--bg-dark);
    z-index: 50;
    padding: 20px;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.back-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s;
}

.back-btn:hover {
    color: var(--accent-color);
}

.detail-header {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 20px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.detail-score-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin-top: 10px;
}

.detail-batting-score {
    font-size: 36px;
    font-family: var(--font-heading);
    font-weight: 700;
}

.detail-status {
    color: var(--accent-color);
    font-weight: 600;
    margin-top: 5px;
}

/* Tabs */
.detail-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    text-transform: uppercase;
}

.tab-btn.active {
    color: var(--accent-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent-color);
}

/* Scorecard Table */
.scorecard-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 30px;
}

.scorecard-table th {
    text-align: left;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
}

.scorecard-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 14px;
}

.batter-name {
    font-weight: 600;
}

.dismissal {
    color: var(--text-secondary);
    font-size: 12px;
}

.runs-cell {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    text-align: right;
}

.stat-cell {
    text-align: right;
    color: var(--text-secondary);
    font-size: 13px;
}

.scorecard-section-title {
    font-family: var(--font-heading);
    font-size: 20px;
    margin-bottom: 10px;
    color: var(--accent-color);
    padding-left: 5px;
    border-left: 3px solid var(--accent-color);
}

/* Commentary */
.comm-item {
    display: flex;
    gap: 15px;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.comm-over {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 50px;
}

.comm-ball-type {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    margin-bottom: 5px;
}

.comm-ball-type.four {
    background: #3b82f6;
    color: #fff;
}

.comm-ball-type.six {
    background: #8b5cf6;
    color: #fff;
}

.comm-ball-type.wicket {
    background: #ef4444;
    color: #fff;
}

.comm-text {
    line-height: 1.5;
    font-size: 14px;
    color: #e2e8f0;
}

/* Info Tab */
.info-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border-color);
}

.info-title {
    font-family: var(--font-heading);
    color: var(--accent-color);
    font-size: 24px;
    margin-bottom: 16px;
    letter-spacing: 0.5px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.info-value {
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
    max-width: 60%;
}

/* Detailed Score Panel (New) */
.desc-score-card {
    background: #111827;
    /* Darker than normal card */
    border-radius: 12px;
    padding: 24px;
    border-left: 6px solid #f97316;
    /* Orange accent */
    margin-bottom: 24px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
    /* Subtle border */
    border-left-width: 6px;
    /* Ensure overrides */
}

.dsc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 13px;
    color: #94a3b8;
}

.dsc-series-info {
    font-weight: 500;
}

.dsc-status {
    color: #f97316;
    /* Orange status text */
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 14px;
    text-transform: uppercase;
}

.dsc-team-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-family: var(--font-heading);
}

.dsc-team-name {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 600;
}

.dsc-team-flag {
    width: 24px;
    height: 24px;
    /* Logically smaller flag than card */
    border-radius: 4px;
    /* Rounded rectangle flags usually look sharper here */
    background: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.dsc-score {
    font-size: 24px;
    font-weight: 700;
    text-align: right;
}

.dsc-overs {
    font-size: 16px;
    color: #94a3b8;
    font-weight: 400;
    margin-left: 8px;
}

.dsc-footer-equation {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 500;
}

/* Commentary Toggles */
.comm-toggles {
    display: flex;
    gap: 10px;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.comm-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.comm-toggle-btn.active,
.comm-toggle-btn:hover {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.comm-item.summary {
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid var(--accent-color);
    margin: 5px 0;
    border-radius: 4px;
}

/* Commentary Timeline */
/* Adjust layout for timeline look */
#comm-list {
    position: relative;
    padding-left: 10px;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    margin-left: 10px;
}

.comm-item {
    display: grid;
    grid-template-columns: 50px 1fr;
    gap: 15px;
    align-items: start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 16px 10px;
    margin-left: 0;
    width: 100%;
    position: relative;
    border-left: none;
    /* Reset simple border */
}

/* Fix for Summary Items (End of Over) to span full width */
.comm-item.summary {
    display: block;
    /* Override grid */
    padding-left: 15px;
    border-left: 3px solid var(--accent-color);
    background: rgba(16, 185, 129, 0.05);
}

.comm-item.summary .comm-text {
    width: 100%;
    color: var(--accent-color);
    font-weight: 600;
}

/* Over Number Column */
.comm-over {
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Connect ball type to line */
.comm-ball-type {
    position: absolute;
    left: -35px;
    /* Move onto the border line */
    top: 2px;
    width: 24px;
    height: 24px;
    z-index: 2;
    border: 2px solid var(--bg-card);
    /* Gap effect */
}

/* No ball type? Use generic dot */
.comm-over:not(:has(.comm-ball-type))::before {
    content: '';
    position: absolute;
    left: -28px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #475569;
    border: 2px solid var(--bg-card);
    z-index: 2;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    .match-detail-section {
        padding: 0;
        top: 60px;
        height: calc(100vh - 60px);
        z-index: 200;
    }

    .detail-header {
        border-radius: 0;
        margin-bottom: 5px;
        padding: 15px;
    }

    .desc-score-card {
        border-radius: 0;
        border-left: none;
        border-top: 4px solid #f97316;
        margin-bottom: 10px;
        padding: 15px;
    }

    .dsc-team-row {
        margin-bottom: 8px;
    }

    .dsc-team-name {
        font-size: 16px;
        /* Decrease for mobile */
    }

    .dsc-score {
        font-size: 18px;
        /* Ensure it fits */
        white-space: nowrap;
        /* Prevent wrapping weirdly */
    }

    .dsc-team-row {
        /* Ensure row doesn't break layout */
        flex-wrap: nowrap;
    }

    .detail-tabs {
        overflow-x: auto;
        white-space: nowrap;
        background: var(--bg-card);
        position: sticky;
        top: 0;
        z-index: 10;
        border-bottom: 1px solid var(--border-color);
        padding: 0 10px;
    }

    .tab-btn {
        padding: 12px 16px;
        font-size: 13px;
    }

    .scorecard-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .scorecard-table th,
    .scorecard-table td {
        padding: 8px 10px;
        font-size: 13px;
    }

    .comm-text {
        font-size: 13px;
    }
}