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

:root {
    --bg-main: #F9FAFB;
    --bg-card: #FFFFFF;
    --primary-blue: #2563EB;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.background-glow {
    display: none;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Branding inside card */
.branding {
    font-size: clamp(1.4rem, 4.48vw, 1.96rem);
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.025em;
    line-height: 1.1;
    margin-bottom: 0.5rem;
}


/* Loading State */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1.5rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Error State */
.error {
    text-align: center;
    padding: 4rem 2rem;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.retry-btn {
    padding: 0.75rem 1.75rem;
    background: var(--primary-blue);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.retry-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

/* Player Card */
.player-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.6s ease-out;
}

.card-glow {
    display: none;
}

.player-header {
    margin-bottom: 2.5rem;
}

.game-info {
    margin-bottom: 0.75rem;
}

.game-title {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.player-name-section {
    margin-bottom: 0;
}

.player-name {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 0.25rem;
}

.team-name {
    font-size: 1.25rem;
    color: var(--primary-blue);
    font-weight: 600;
}

/* Stats Container */
.stats-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}

.stats-row.primary-stats {
    border-bottom: 1px solid var(--border-color);
}

.stat-item {
    text-align: center;
    padding: 1.5rem 1rem;
    background: transparent;
    border-right: 1px solid var(--border-color);
}

.stat-item:last-child {
    border-right: none;
}

.stat-item.highlight {
    background: white;
}

.stat-value {
    display: block;
    font-size: clamp(1.5rem, 4vw, 2.25rem);
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.stat-item.highlight .stat-value {
    color: var(--primary-blue);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* Leaderboard */
.leaderboard {
    margin-top: 3rem;
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

.leaderboard h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    letter-spacing: -0.01em;
}

.leaderboard-list {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.leaderboard-item:hover {
    background: #F9FAFB;
}

.rank {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #F3F4F6;
    color: var(--text-secondary);
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.8125rem;
    margin-right: 1.25rem;
    flex-shrink: 0;
}

.leaderboard-item.top .rank {
    background: #EFF6FF;
    color: var(--primary-blue);
}

.leaderboard-player-info {
    flex: 1;
    min-width: 0;
}

.leaderboard-player-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-team {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.leaderboard-stats {
    display: grid;
    grid-template-columns: repeat(4, 55px);
    gap: 0.5rem;
    margin-left: 1rem;
}

.lb-stat {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9375rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lb-stat small {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 1px;
}

.lb-stat.best {
    color: var(--primary-blue);
    background: #EFF6FF;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}

.lb-stat.best small {
    color: #3b82f6;
    /* Lighter blue for the label */
}

/* Footer */
.footer {
    margin-top: auto;
    padding-top: 4rem;
    padding-bottom: 2rem;
    text-align: center;
}

.footer p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Utility */
.hidden {
    display: none !important;
}

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

/* Responsive */
@media (max-width: 600px) {
    .player-card {
        padding: 1.5rem;
    }

    .container {
        padding: 1.5rem 1rem;
    }

    .stats-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }

    .stat-item {
        padding: 1rem 0.25rem;
    }

    .leaderboard-item {
        flex-wrap: wrap;
        padding: 1.25rem 1rem;
    }

    .leaderboard-player-info {
        width: calc(100% - 45px);
    }

    .leaderboard-stats {
        width: 100%;
        margin-left: 3rem;
        margin-top: 1rem;
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }

    .lb-stat {
        text-align: left;
        align-items: flex-start;
    }
}