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

:root {
    --color-bg-dark: #0f0f1e;
    --color-bg-dark-secondary: #1a1a2e;
    --color-bg-dark-tertiary: #16213e;
    --color-text-dark: #e8e8e8;
    --color-text-dark-secondary: #a0a0a0;
    --color-accent-dark: #0fa3b1;
    --color-border-dark: #2a2a3e;

    --color-bg-light: #f8f9fa;
    --color-bg-light-secondary: #ffffff;
    --color-bg-light-tertiary: #f0f2f5;
    --color-text-light: #1a1a1a;
    --color-text-light-secondary: #606060;
    --color-accent-light: #0fa3b1;
    --color-border-light: #e0e0e0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--color-bg-dark);
    color: var(--color-text-dark);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.light-mode {
    background-color: var(--color-bg-light);
    color: var(--color-text-light);
}

header {
    background: #0d1b2a;
    border-bottom: none;
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    box-shadow: 0 4px 12px rgba(15, 163, 177, 0.25);
}

body.light-mode header {
    background: #f0f2f5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 1.75em;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: white;
}

.header-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.footer-controls {
    display: flex;
    justify-content: flex-start;
    padding: 20px 0;
    margin-top: 30px;
}

.theme-toggle {
    background: transparent;
    backdrop-filter: none;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    color: var(--color-text-dark-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s ease;
}

body.light-mode .theme-toggle {
    background: transparent;
    backdrop-filter: none;
    border: 1.5px solid rgba(0, 0, 0, 0.2);
    color: var(--color-text-light-secondary);
}

.theme-toggle:hover {
    background: rgba(15, 163, 177, 0.1);
    border-color: var(--color-accent-dark);
    color: var(--color-text-dark);
}

body.light-mode .theme-toggle:hover {
    background: rgba(15, 163, 177, 0.1);
    border-color: var(--color-accent-light);
    color: var(--color-text-light);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 20px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
    background-color: var(--color-bg-dark-secondary);
    padding: 6px;
    border-radius: 12px;
    flex-wrap: wrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

body.light-mode .tabs {
    background-color: var(--color-bg-light-tertiary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--color-text-dark-secondary);
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    transition: all 0.2s ease;
}

body.light-mode .tab-btn {
    color: var(--color-text-light-secondary);
}

.tab-btn:hover {
    color: var(--color-text-dark);
    background: rgba(15, 163, 177, 0.1);
}

body.light-mode .tab-btn:hover {
    color: var(--color-text-light);
    background: rgba(15, 163, 177, 0.1);
}

.tab-btn.active {
    color: white;
    background: linear-gradient(135deg, var(--color-accent-dark), rgba(15, 163, 177, 0.8));
    box-shadow: 0 2px 8px rgba(15, 163, 177, 0.3);
}

body.light-mode .tab-btn.active {
    background: linear-gradient(135deg, var(--color-accent-light), rgba(15, 163, 177, 0.8));
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-section {
    background-color: var(--color-bg-dark-secondary);
    border: 1px solid var(--color-border-dark);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

body.light-mode .chart-section {
    background-color: var(--color-bg-light-secondary);
    border-color: var(--color-border-light);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    cursor: pointer;
    user-select: none;
}

.chart-header h3 {
    font-size: 0.95em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-accent-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

body.light-mode .chart-header h3 {
    color: var(--color-accent-light);
}

.toggle-icon {
    font-size: 0.8em;
    transition: transform 0.3s ease;
}

.toggle-icon.collapsed {
    transform: rotate(-90deg);
}

.chart-content {
    max-height: 400px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.chart-content.collapsed {
    max-height: 0;
}

.chart-container {
    position: relative;
    height: 300px;
    margin-bottom: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--color-bg-dark-secondary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

body.light-mode table {
    background-color: var(--color-bg-light-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

thead {
    background-color: var(--color-bg-dark-tertiary);
    border-bottom: 1px solid var(--color-border-dark);
    transition: all 0.3s ease;
}

body.light-mode thead {
    background-color: var(--color-bg-light-tertiary);
    border-bottom: 1px solid var(--color-border-light);
}

th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-accent-dark);
    transition: all 0.3s ease;
}

body.light-mode th {
    color: var(--color-accent-light);
}

th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 24px;
}

th.sortable:hover {
    background-color: rgba(15, 163, 177, 0.1);
}

th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 8px;
    opacity: 0.3;
}

th.sorted-asc::after {
    content: '↑';
    opacity: 1;
}

th.sorted-desc::after {
    content: '↓';
    opacity: 1;
}

.team-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table-wrapper table {
    min-width: 100%;
    width: max-content;
}

.matches-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 10px 0;
}

.match-card {
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    cursor: pointer;
}

.match-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(15, 15, 30, 0.85), rgba(15, 15, 30, 0.95));
    z-index: 1;
}

body.light-mode .match-card::before {
    background: linear-gradient(to bottom, rgba(248, 249, 250, 0.9), rgba(248, 249, 250, 0.95));
}

.match-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(15, 163, 177, 0.2);
    border-color: var(--color-accent-dark);
}

.match-card-content {
    position: relative;
    z-index: 2;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 180px;
}

.match-score-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex: 1;
}

.match-center-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.match-scores {
    display: flex;
    align-items: center;
    gap: 15px;
}

.match-team-avatar {
    width: 140px;
    height: 140px;
    max-height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--color-accent-dark);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

body.light-mode .match-team-avatar {
    border-color: var(--color-accent-light);
}

.match-score {
    font-size: 2.5em;
    font-weight: bold;
    color: var(--color-text-dark);
    min-width: 60px;
    text-align: center;
}

body.light-mode .match-score {
    color: var(--color-text-light);
}

.match-score.winner {
    color: var(--color-accent-dark);
}

body.light-mode .match-score.winner {
    color: var(--color-accent-light);
}

.match-score-divider {
    color: var(--color-text-dark-secondary);
    font-size: 1.5em;
}

body.light-mode .match-score-divider {
    color: var(--color-text-light-secondary);
}

.match-info-center {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 1.1em;
    color: var(--color-text-dark-secondary);
}

body.light-mode .match-info-center {
    color: var(--color-text-light-secondary);
}

.match-date-map {
    color: var(--color-accent-dark);
    font-weight: 700;
    font-size: 1.05em;
}

body.light-mode .match-date-map {
    color: var(--color-accent-light);
}

body.light-mode .match-link {
    color: var(--color-accent-light);
}

.match-link:hover {
    transform: scale(1.2);
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--color-border-dark);
    transition: all 0.3s ease;
}

td.numeric {
    text-align: center;
}

body.light-mode td {
    border-bottom: 1px solid var(--color-border-light);
}

tbody tr:nth-child(odd) {
    background-color: rgba(255, 255, 255, 0.02);
}

body.light-mode tbody tr:nth-child(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

tbody tr:hover {
    background-color: var(--color-bg-dark-tertiary);
}

body.light-mode tbody tr:hover {
    background-color: var(--color-bg-light-tertiary);
}

.player-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.avatar-preview {
    position: fixed;
    display: none;
    z-index: 1000;
    pointer-events: none;
    background: var(--color-bg-dark-secondary);
    border: 2px solid var(--color-accent-dark);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    max-width: 300px;
    max-height: 300px;
}

body.light-mode .avatar-preview {
    background: var(--color-bg-light-secondary);
    border-color: var(--color-accent-light);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.avatar-preview img {
    max-width: 280px;
    max-height: 280px;
    width: auto;
    height: auto;
    border-radius: 8px;
    object-fit: contain;
    display: block;
}

.avatar-preview.show {
    display: block;
}

.easter-egg {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    transition: filter 0.3s ease;
}

.easter-egg img {
    width: 150px;
    height: 150px;
    display: block;
}

.search-filter {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.search-filter input,
.search-filter select {
    padding: 10px 12px;
    background-color: var(--color-bg-dark-secondary);
    border: 1px solid var(--color-border-dark);
    border-radius: 6px;
    color: var(--color-text-dark);
    font-size: 0.95em;
    transition: all 0.3s ease;
}

body.light-mode .search-filter input,
body.light-mode .search-filter select {
    background-color: var(--color-bg-light-secondary);
    border-color: var(--color-border-light);
    color: var(--color-text-light);
}

.search-filter input::placeholder {
    color: var(--color-text-dark-secondary);
}

body.light-mode .search-filter input::placeholder {
    color: var(--color-text-light-secondary);
}

.search-filter input:focus,
.search-filter select:focus {
    outline: none;
    border-color: var(--color-accent-dark);
    box-shadow: 0 0 0 3px rgba(15, 163, 177, 0.1);
}

body.light-mode .search-filter input:focus,
body.light-mode .search-filter select:focus {
    border-color: var(--color-accent-light);
    box-shadow: 0 0 0 3px rgba(15, 163, 177, 0.15);
}

.loading {
    text-align: center;
    padding: 40px;
    font-size: 1em;
    color: var(--color-text-dark-secondary);
}

body.light-mode .loading {
    color: var(--color-text-light-secondary);
}

.error {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    padding: 20px;
    border-radius: 8px;
    color: #ef4444;
    text-align: center;
    margin: 20px 0;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: var(--color-text-dark-secondary);
}

body.light-mode .no-data {
    color: var(--color-text-light-secondary);
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
    }

    header h1 {
        font-size: 1.5em;
        text-align: center;
    }

    .header-controls {
        width: 100%;
        justify-content: flex-start;
    }

    .container {
        padding: 20px 15px;
    }

    .tabs {
        margin-bottom: 20px;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.85em;
    }

    table {
        font-size: 0.85em;
    }

    th, td {
        padding: 10px 8px;
    }

    .chart-container {
        height: 250px;
    }

    .search-filter {
        flex-direction: column;
    }

    .search-filter input,
    .search-filter select {
        width: 100%;
    }

    .player-avatar img {
        width: 32px;
        height: 32px;
    }

    .matches-grid {
        gap: 15px;
    }

    .match-card-content {
        min-height: 100px;
        gap: 5px;
        padding: 10px;
    }

    .match-team-avatar {
        width: 60px;
        height: 60px;
    }

    .match-score {
        font-size: 2em;
    }

    .match-scores {
        gap: 8px;
    }

    .match-info-center {
        font-size: 0.95em;
    }

    .table-wrapper {
        position: relative;
        overflow-x: scroll;
        width: 100%;
    }

    .table-wrapper table {
        display: table;
        width: max-content;
    }

    .table-wrapper table th:first-child,
    .table-wrapper table td:first-child {
        position: -webkit-sticky;
        position: sticky;
        left: 0;
        z-index: 10;
        background-color: var(--color-bg-dark-secondary);
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    }

    body.light-mode .table-wrapper table th:first-child,
    body.light-mode .table-wrapper table td:first-child {
        background-color: var(--color-bg-light-secondary);
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
    }

    .table-wrapper table th:first-child {
        z-index: 11;
        background-color: var(--color-bg-dark-tertiary);
    }

    body.light-mode .table-wrapper table th:first-child {
        background-color: var(--color-bg-light-tertiary);
    }

    table {
        font-size: 0.75em;
        border-collapse: separate;
        border-spacing: 0;
    }

    th, td {
        padding: 8px 6px;
        white-space: nowrap;
    }

    .team-cell {
        gap: 6px;
    }

    .player-avatar img {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 480px) {
    .easter-egg img {
        width: 60px;
        height: 60px;
    }

    header h1 {
        font-size: 1.3em;
        text-align: center;
    }

    .container {
        padding: 15px 10px;
    }

    .tab-btn {
        padding: 8px 5px;
        font-size: 0.8em;
        white-space: nowrap;
    }

    .tabs {
        gap: 8px;
    }

    table {
        font-size: 0.8em;
    }

    th, td {
        padding: 8px 6px;
    }
}

/* Kills Matrix Styles */
.kills-matrix-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
    border-radius: 8px;
    background: var(--color-bg-dark-secondary);
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.light-mode .kills-matrix-wrapper {
    background: var(--color-bg-light-secondary);
}

.kills-matrix-table {
    border-collapse: separate;
    border-spacing: 4px;
    min-width: 100%;
}

.kills-matrix-table th,
.kills-matrix-table td {
    padding: 12px;
    text-align: center;
    min-width: 70px;
    position: relative;
}

.kills-matrix-table th {
    background: var(--color-bg-dark-tertiary);
    font-weight: 600;
    position: sticky;
    z-index: 10;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

body.light-mode .kills-matrix-table th {
    background: var(--color-bg-light-tertiary);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.kills-matrix-table th.row-header {
    left: 0;
    z-index: 30;
    text-align: left;
    min-width: 180px;
}

.kills-matrix-table thead th {
    top: 0;
    z-index: 20;
}

.kills-matrix-table thead th.row-header {
    z-index: 40;
}

.kills-matrix-table .player-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    min-width: 150px;
}

.kills-matrix-table .player-cell img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--color-border-dark);
}

body.light-mode .kills-matrix-table .player-cell img {
    border-color: var(--color-border-light);
}

.kills-matrix-table thead .player-cell {
    flex-direction: column;
    justify-content: center;
}

.kills-matrix-table .kill-cell {
    background: var(--color-bg-dark-tertiary);
    border-radius: 6px;
    font-weight: 600;
    cursor: help;
    transition: all 0.2s ease;
    font-size: 1em;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.light-mode .kills-matrix-table .kill-cell {
    background: var(--color-bg-light-tertiary);
}

.kills-matrix-table .kill-cell:hover {
    transform: scale(1.15);
    z-index: 50;
    box-shadow: 0 6px 16px rgba(15, 163, 177, 0.4);
}

.kills-matrix-table .kill-cell.heat-0 {
    background: rgba(15, 163, 177, 0.05);
    color: var(--color-text-dark-secondary);
}

.kills-matrix-table .kill-cell.heat-1 {
    background: rgba(15, 163, 177, 0.25);
}

.kills-matrix-table .kill-cell.heat-2 {
    background: rgba(15, 163, 177, 0.45);
}

.kills-matrix-table .kill-cell.heat-3 {
    background: rgba(15, 163, 177, 0.65);
}

.kills-matrix-table .kill-cell.heat-4 {
    background: rgba(15, 163, 177, 0.85);
    color: #ffffff;
}

.kills-matrix-table .kill-cell.heat-5 {
    background: rgba(15, 163, 177, 1);
    color: #ffffff;
    font-weight: 700;
}

body.light-mode .kills-matrix-table .kill-cell.heat-0 {
    color: var(--color-text-light-secondary);
}

body.light-mode .kills-matrix-table .kill-cell.heat-5 {
    color: #ffffff;
}

.matrix-legend {
    margin-top: 20px;
    padding: 15px;
    background: var(--color-bg-dark-tertiary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

body.light-mode .matrix-legend {
    background: var(--color-bg-light-tertiary);
}

.matrix-legend-title {
    font-weight: 600;
    margin-right: 10px;
}

.matrix-legend-scale {
    display: flex;
    align-items: center;
    gap: 10px;
}

.matrix-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9em;
}

.matrix-legend-color {
    width: 30px;
    height: 20px;
    border-radius: 3px;
}

