* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0 0 16px;
}

body:not(.dark-mode) {
    background-color: #eef2f7;
}

.page-wrapper {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 20px;
}

.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Hero Banner (full-bleed like .leaderboard-section / .gradient-bg) */
.player-hero {
    width: 100%;
    padding: 16px 20px 22px;
    border-radius: 0 0 14px 14px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.14);
    margin-bottom: 22px;
    text-align: center;
}

.hero-inner {
    max-width: 1320px;
    margin: 0 auto;
}

.hero-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.32);
    color: inherit;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background-color 0.2s, transform 0.15s;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.hero-theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.18);
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background-color 0.2s;
}

.hero-theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.hero-title-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.hero-title-row h1 {
    margin: 0;
    font-size: 1.85rem;
    line-height: 1.2;
}

.mode-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 16px;
}

.kpi-card {
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 10px;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kpi-label {
    font-size: 0.75rem;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.kpi-value {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Content Cards (matches .game-container) */
.section-card {
    background-color: #ffffff;
    border: 1px solid #ddd;
    border-top: 4px solid #4f46e5;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    padding: 18px;
    margin-bottom: 20px;
}

.dark-mode .section-card {
    background-color: #242424;
    border-color: #333;
    border-top: 4px solid #58a6ff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.card-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

/* Chart Controls */
.chart-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.pill-group {
    display: inline-flex;
    flex-wrap: wrap;
    background: #eef0f4;
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}

.dark-mode .pill-group {
    background: #1a1a1a;
}

.pill-btn {
    border: none;
    background: transparent;
    color: inherit;
    padding: 7px 13px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
}

.pill-btn.active {
    background: #4f46e5;
    color: #ffffff;
}

.dark-mode .pill-btn.active {
    background: #58a6ff;
    color: #111;
}

.chart-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.zoom-toggle-btn {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    padding: 6px 11px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.2s, border-color 0.2s;
}

.zoom-toggle-btn.active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #ffffff;
}

.dark-mode .zoom-toggle-btn {
    background: #2f2f2f;
    border-color: #444;
    color: #d6d6d6;
}

.dark-mode .zoom-toggle-btn.active {
    background: #58a6ff;
    border-color: #58a6ff;
    color: #111;
}

.plot-readout {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    background: #f3f5f9;
    font-size: 0.88rem;
    margin-bottom: 8px;
}

.dark-mode .plot-readout {
    background: #1d1d1d;
}

.plot-readout-hint {
    opacity: 0.7;
    font-size: 0.8rem;
}

.plot-wrapper {
    position: relative;
    width: 100%;
}

.plot-container {
    width: 100%;
    height: 430px;
    touch-action: pan-y;
}

.plot-container.zoom-enabled {
    touch-action: none;
}

.plot-empty {
    display: none;
    padding: 48px 16px;
    text-align: center;
    opacity: 0.75;
    font-style: italic;
}

/* Opponents Table */
.search-input {
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid #ccc;
    background: #f9f9f9;
    color: #333;
    font-size: 0.9rem;
    min-width: 180px;
}

.dark-mode .search-input {
    border-color: #444;
    background: #1b1b1b;
    color: #eaeaea;
}

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

.opponents-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.opponents-table th,
.opponents-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
}

.dark-mode .opponents-table th,
.dark-mode .opponents-table td {
    border-bottom-color: #333;
}

.opponents-table th {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.85;
}

.opponents-table tbody tr:hover {
    background: rgba(79, 70, 229, 0.05);
}

.dark-mode .opponents-table tbody tr:hover {
    background: rgba(88, 166, 255, 0.08);
}

.num-col {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.sort-btn {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    padding: 2px 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.num-col .sort-btn {
    justify-content: flex-end;
    width: 100%;
}

.sort-indicator {
    font-size: 0.8em;
    opacity: 0.5;
}

.sortable-th.sort-active .sort-indicator {
    opacity: 1;
}

.opponent-link {
    color: #4f46e5;
    font-weight: 600;
    text-decoration: none;
}

.opponent-link:hover {
    text-decoration: underline;
}

.dark-mode .opponent-link {
    color: #58a6ff;
}

.score-positive {
    color: #16a34a;
    font-weight: 700;
}

.dark-mode .score-positive {
    color: #4ade80;
}

.score-negative {
    color: #dc2626;
    font-weight: 700;
}

.dark-mode .score-negative {
    color: #f87171;
}

.empty-opponents {
    text-align: center;
    padding: 24px 12px;
    opacity: 0.75;
    font-style: italic;
}

/* Mobile Layout */
@media (max-width: 600px) {
    .page-wrapper {
        padding: 0 8px;
    }

    .player-hero {
        padding: 12px 12px 16px;
        margin-bottom: 14px;
    }

    .hero-title-row h1 {
        font-size: 1.45rem;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .kpi-value {
        font-size: 1.1rem;
    }

    .section-card {
        padding: 14px 10px;
        margin-bottom: 14px;
    }

    .chart-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .pill-group {
        width: 100%;
        justify-content: space-between;
    }

    .pill-btn {
        flex: 1;
        text-align: center;
        padding: 8px 8px;
        font-size: 0.82rem;
    }

    .chart-actions {
        justify-content: space-between;
    }

    .plot-container {
        height: 300px;
    }

    .search-input {
        width: 100%;
    }

    .opponents-table th,
    .opponents-table td {
        padding: 8px 6px;
        font-size: 0.88rem;
    }
}

/* Desktop 2-Column Dashboard */
@media (min-width: 1024px) {
    .dashboard-grid {
        display: grid;
        grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr);
        gap: 20px;
        align-items: stretch;
    }

    .section-card {
        margin-bottom: 0;
        height: clamp(500px, 64vh, 620px);
        display: flex;
        flex-direction: column;
    }

    .plot-wrapper {
        flex: 1;
        min-height: 0;
    }

    .plot-container {
        height: 100%;
    }

    .opponents-table-wrap {
        overflow-y: auto;
        flex: 1;
        min-height: 0;
    }

    .opponents-table thead th {
        position: sticky;
        top: 0;
        background-color: #ffffff;
        z-index: 2;
    }

    .dark-mode .opponents-table thead th {
        background-color: #242424;
    }
}
