:root {
    --bg-color: #05080e;
    --card-bg: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --accent-gold: #fbbf24;
    --accent-emerald: #10b981;
    --accent-cyan: #06b6d4;
    --accent-purple: #818cf8;
    --accent-rose: #f43f5e;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
}

.background-glow {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(129, 140, 248, 0.15) 0%, rgba(5, 8, 14, 0) 70%);
    z-index: -1;
    pointer-events: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* GLASSMORPHISM */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
}

/* HEADER */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3.5rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.logo-icon {
    font-size: 2rem;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(129, 140, 248, 0.1));
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    transition: var(--transition);
}

.logo-icon:hover {
    transform: rotate(10deg) scale(1.05);
    border-color: var(--accent-cyan);
}

.logo-text h1 {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.25rem;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text span {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    color: var(--accent-cyan);
    font-weight: 700;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
}

.lang-switcher {
    display: flex;
    background: rgba(255,255,255,0.05);
    padding: 0.15rem;
    border-radius: 100px;
    border: 1px solid var(--border-color);
    width: fit-content;
}

.lang-btn {
    padding: 0.3rem 0.75rem;
    border-radius: 100px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
}

.lang-btn.active {
    background: var(--accent-cyan);
    color: var(--bg-color);
    box-shadow: 0 4px 10px rgba(6, 182, 212, 0.2);
}

.last-update {
    color: var(--text-secondary);
    font-size: 0.75rem;
    background: rgba(255,255,255,0.03);
    padding: 0.4rem 0.85rem;
    border-radius: 100px;
}

/* STATS GRID */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 4rem;
}

.stat-card {
    padding: 2rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255,255,255,0.25);
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
}

.stat-footer {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* VARIATIONS */
.gold .stat-value { color: var(--accent-gold); }
.emerald .stat-value { color: var(--accent-emerald); }
.cyan .stat-value { color: var(--accent-cyan); }
.purple .stat-value { color: var(--accent-purple); }

/* CONTENT SECTIONS */
.section-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ELITE ACTIVE ROWS */
.active-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 4rem;
}

.match-row-card {
    cursor: pointer;
    overflow: hidden;
    transition: var(--transition);
}

.match-row-card:hover {
    border-color: rgba(255,255,255,0.2);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.row-main {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    justify-content: space-between;
}

.row-match-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 2.5; /* Slightly more space for info */
}

.row-time-league {
    display: flex;
    flex-direction: column;
    min-width: 100px;
    max-width: 150px;
    flex: 0 1 auto;
}

.row-league {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-time {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.row-teams {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    flex: 1;
}

.team-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 0; /* Allow shrinking */
}

.team-box.home {
    justify-content: flex-end;
    text-align: right;
}

.team-box.away {
    justify-content: flex-start;
    text-align: left;
}

.team-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
    flex-shrink: 0;
}

.row-team-name {
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-vs-badge {
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 900;
    background: rgba(255,255,255,0.05);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 1px;
    width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.row-market-odds {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 0 0 240px; /* Fixed width on desktop for perfect alignment */
    justify-content: flex-end;
}

.row-market {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
}

.row-odds {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--accent-gold);
}

.row-expansion-arrow {
    margin-left: 1.5rem;
    transition: transform 0.3s ease;
    opacity: 0.5;
}

.match-row-card.expanded .row-expansion-arrow {
    transform: rotate(180deg);
}

/* EXPANDED DETAILS */
.row-details {
    max-height: 0;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0,0,0,0.2);
    border-top: 1px solid var(--border-color);
}

.match-row-card.expanded .row-details {
    max-height: 300px;
    opacity: 1;
    padding: 1.5rem;
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.details-team-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.details-title {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.details-subtitle {
    font-size: 0.6rem;
    font-weight: 400;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-top: -0.5rem;
    margin-bottom: 0.25rem;
}

.form-markers {
    display: flex;
    gap: 0.4rem;
}

.marker {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    line-height: 1;
}

.marker.w { background: var(--accent-emerald); }
.marker.d { background: var(--accent-gold); }
.marker.l { background: var(--accent-rose); }

.goals-stats {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.goals-val {
    font-size: 1.1rem;
    font-weight: 700;
}

.goals-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* BACK TO TOP */
#backToTop {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent-cyan);
    color: var(--bg-color);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(6, 182, 212, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: var(--transition);
}

#backToTop:hover {
    transform: translateY(-5px);
    background: #fff;
}

/* TABLES & HISTORY */
.history-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.5rem;
}

.history-filters {
    display: flex;
    gap: 1rem;
    background: var(--card-bg);
    padding: 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.5rem;
}

.filter-group select {
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: 0.4rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    outline: none;
}

.filter-group select option {
    background: #1e293b;
    color: white;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}

.page-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.page-btn:hover:not(:disabled) {
    background: var(--accent-cyan);
    color: var(--bg-color);
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.history-team-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}

.history-team-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
}

.league-logo-img {
    height: 16px;
    width: auto;
    vertical-align: middle;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.td-league {
    text-align: center;
    vertical-align: middle;
    min-width: 100px;
}

.history-league-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.history-league-box .league-logo-img {
    height: 24px;
    margin-right: 0;
}

.vs-inline {
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 800;
    opacity: 0.6;
    margin: 0.2rem 0;
}

.td-date {
    font-family: 'Outfit', monospace;
    font-size: 0.85rem;
    color: var(--accent-cyan);
    text-align: center;
}

.table-container {
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
    table-layout: fixed; /* Help with centering and predictable widths */
}

.history-table th {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
}

.history-table td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    text-align: center;
}

.history-table th:nth-child(1), .history-table td:nth-child(1) { width: 14%; } /* Date */
.history-table th:nth-child(2), .history-table td:nth-child(2) { width: 8%; }  /* League */
.history-table th:nth-child(3), .history-table td:nth-child(3) { width: 28%; } /* Match */
.history-table th:nth-child(4), .history-table td:nth-child(4) { width: 16%; } /* Market */
.history-table th:nth-child(5), .history-table td:nth-child(5) { width: 7%; }  /* Odds */
.history-table th:nth-child(6), .history-table td:nth-child(6) { width: 14%; } /* Outcome */
.history-table th:nth-child(7), .history-table td:nth-child(7) { width: 13%; } /* Profit */

.td-match { font-weight: 500; text-align: center; }
.vs-inline { color: var(--text-secondary); font-size: 0.8rem; margin: 0.2rem 0; }
.td-odds { color: var(--accent-gold); font-weight: 700; }

/* BADGES */
.badge {
    padding: 0.35rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.05rem;
}

.win { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.loss { background: rgba(244, 63, 94, 0.15); color: #f43f5e; }
.open { background: rgba(6, 182, 212, 0.15); color: #06b6d4; }

.txt-win { color: var(--accent-emerald); font-weight: 600; }
.txt-loss { color: var(--accent-rose); font-weight: 600; }

footer {
    margin-top: 5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding-bottom: 2rem;
}

/* ANIMATIONS */
.animate-in {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.5s ease-out forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}.row-market {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    white-space: nowrap; /* Prevent wrapping */
}

.row-odds {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--accent-gold);
    min-width: 45px;
    text-align: right;
}

.row-expansion-arrow {
    margin-left: 1rem;
    transition: transform 0.3s ease;
    opacity: 0.5;
}

/* MEDIA QUERIES */
@media (max-width: 768px) {
    .container { padding: 1rem 0.75rem; }
    
    .header {
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.5rem; }
    
    .history-section-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        flex-wrap: wrap; 
    }

    .history-filters {
        width: auto;
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
        padding: 0.4rem;
        background: rgba(255,255,255,0.02);
        border-radius: 0.5rem;
    }

    .filter-group {
        flex-direction: row;
        align-items: center;
        gap: 0.35rem;
    }

    .filter-group .details-title { display: none; } /* Icon-only feel on mobile */

    .filter-group select {
        width: auto;
        min-width: 80px;
        max-width: 120px;
    }

    .history-table { min-width: 480px; } /* Slightly wider than screen but scrollable if needed */
    .history-table th, .history-table td {
        padding: 0.6rem 0.25rem;
        font-size: 0.7rem;
    }
    
    .history-league-box span { 
        display: block;
        max-width: 75px; /* Forced wrap for long names */
        margin: 0 auto;
        line-height: 1.1;
        word-break: break-word;
        font-size: 0.65rem;
    }
    .history-league-box .league-logo-img { height: 18px; margin-bottom: 2px; }
    
    .td-date { font-size: 0.7rem; min-width: 65px; }
    .td-match { font-size: 0.75rem; }
}

@media (max-width: 600px) {
    /* MOBILE HEADER */
    .header { text-align: center; }
    .logo-area { flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
    .header-right { align-items: center; width: 100%; }

    /* HISTORY HEADER - Title top, Filters bottom for better mobile flow */
    .history-section-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .history-section-header .section-title {
        font-size: 1.4rem;
        margin-bottom: 0;
    }

    .history-filters {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr; /* Nice 2-column grid below title */
        gap: 0.75rem;
        padding: 0.75rem;
        background: rgba(255,255,255,0.03);
        border-radius: 0.75rem;
        border: 1px solid var(--border-color);
    }

    .filter-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    .filter-group .details-title { 
        display: block; 
        font-size: 0.6rem;
        opacity: 0.6;
    }

    .filter-group select {
        width: 100%;
        font-size: 0.8rem;
        padding: 0.4rem;
        height: 38px;
    }

    /* TABLE MOBILE FIXES - ULTRA COMPACT */
    .table-container { margin: 0 -0.8rem; width: calc(100% + 1.6rem); overflow-x: auto; }
    .history-table { min-width: 375px; table-layout: fixed; } 
    
    .history-table th, .history-table td {
        padding: 0.5rem 0.1rem;
        font-size: 0.68rem;
    }

    /* Fixed mobile widths for perfect fit (approx 375px) */
    .history-table th:nth-child(1), .history-table td:nth-child(1) { width: 18%; } /* Date */
    .history-table th:nth-child(2), .history-table td:nth-child(2) { width: 10%; } /* League */
    .history-table th:nth-child(3), .history-table td:nth-child(3) { width: 26%; } /* Match */
    .history-table th:nth-child(4), .history-table td:nth-child(4) { width: 17%; } /* Market */
    .history-table th:nth-child(5), .history-table td:nth-child(5) { width: 8%; }  /* Odds */
    .history-table th:nth-child(6), .history-table td:nth-child(6) { width: 11%; } /* Res */
    .history-table th:nth-child(7), .history-table td:nth-child(7) { width: 10%; } /* Prof */
    
    .history-team-row {
        flex-direction: column;
        gap: 0.1rem;
        line-height: 1;
    }
    
    .history-team-logo {
        width: 16px;
        height: 16px;
        margin: 0 auto;
    }

    .vs-inline {
        font-size: 0.6rem;
        margin: 0;
    }
    
    .history-league-box span { 
        font-size: 0.6rem;
    }
    
    .history-league-box .league-logo-img { height: 16px; }

    /* MOBILE ACTIVE CARD COMPACT VIEW */
    .row-main {
        flex-direction: column;
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .row-match-info {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }
    
    .row-time-league {
        width: calc(100% - 40px); /* Leave room for arrow */
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 0.5rem;
    }
    
    .row-teams {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        align-items: center; /* Center match elements */
    }
    
    .team-box {
        width: 100%;
        justify-content: center !important; /* Center teams on mobile */
        text-align: center !important;
        gap: 0.75rem;
    }
    
    .team-box.away {
        flex-direction: row !important;
    }
    
    .team-logo {
        width: 32px;
        height: 32px;
    }
    
    .row-team-name {
        font-size: 1.1rem;
        white-space: normal;
        overflow: visible;
    }

    .row-vs-badge {
        display: flex;
        justify-content: center;
        margin: -0.25rem 0;
    }
    
    .row-market-odds {
        flex: none;
        width: 100%;
        justify-content: space-between;
        margin-top: 0.5rem;
        padding: 0.75rem;
        background: rgba(255,255,255,0.03);
        border-radius: 0.75rem;
    }

    .row-market {
        font-size: 0.85rem;
        padding: 0.4rem 0.75rem;
    }

    .row-expansion-arrow {
        position: absolute;
        top: 1.1rem;
        right: 1.25rem;
        margin: 0;
    }

    .details-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}
