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

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-light: #64748b;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 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: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-bottom: 15px;
}

.course-context {
    font-size: 0.95rem;
    color: var(--text-light);
    margin: 15px auto 0;
    max-width: 800px;
    line-height: 1.6;
}

.course-context a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.course-context a:hover {
    text-decoration: underline;
}

.meta {
    font-size: 0.9rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.separator {
    color: var(--border);
}

.info-banner {
    background: #dbeafe;
    border: 1px solid #3b82f6;
    border-radius: 8px;
    padding: 16px 20px;
    margin: 0 auto 30px;
    max-width: 900px;
    text-align: center;
    box-shadow: var(--shadow);
}

.info-banner p {
    margin: 0;
    color: #1e40af;
    font-size: 0.95rem;
    line-height: 1.6;
}

.info-banner p:not(:first-child) {
    margin-top: 12px;
}

.info-banner a {
    color: #1e40af;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: #3b82f6;
    text-underline-offset: 2px;
    transition: color 0.2s, text-decoration-color 0.2s;
}

.info-banner a:hover {
    color: #1e3a8a;
    text-decoration-color: #1e40af;
}

.info-banner strong {
    font-weight: 600;
}

.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    border: 4px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error {
    background: #fee2e2;
    border: 1px solid var(--danger);
    color: #991b1b;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    text-align: center;
}

.error code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.metrics-explainer {
    margin-bottom: 30px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.metrics-explainer details {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
}

.metrics-explainer summary {
    list-style: none;
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.metrics-explainer summary::-webkit-details-marker {
    display: none;
}

.summary-text {
    font-weight: 600;
    color: var(--text);
    font-size: 0.95rem;
}

.metrics-explainer details[open] summary {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.explainer-content {
    display: grid;
    gap: 12px;
}

.metric-explanation {
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.6;
}

.metric-explanation strong {
    color: var(--text);
    font-weight: 600;
}

.info-icon-small {
    font-size: 0.75rem;
    opacity: 0.6;
    cursor: help;
    margin-left: 4px;
}

.badges-explanation {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.8;
}

.badges-explanation strong {
    color: var(--text);
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
}

.badge-sample {
    display: inline-block;
    margin-right: 8px;
    margin-bottom: 4px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.leaderboard {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.leaderboard-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.leaderboard-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.view-toggle {
    display: flex;
    gap: 8px;
}

.view-toggle button {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.view-toggle button:hover {
    background: var(--bg);
}

.view-toggle button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

#leaderboard-content {
    padding: 0;
}

.leaderboard-item {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: background 0.2s;
}

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

.leaderboard-item:hover {
    background: var(--bg);
}

.rank {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-light);
    min-width: 50px;
    text-align: center;
}

.rank.rank-1 {
    color: #ffd700;
    font-size: 2rem;
}

.rank.rank-2 {
    color: #c0c0c0;
    font-size: 1.8rem;
}

.rank.rank-3 {
    color: #cd7f32;
    font-size: 1.8rem;
}

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

.student-domain {
    margin-bottom: 6px;
}

.primary-domain-link {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    display: inline-block;
}

.primary-domain-link:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}

.student-repo {
    font-size: 0.9rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.student-repo a {
    color: var(--primary);
    text-decoration: none;
}

.student-repo a:hover {
    text-decoration: underline;
}

.student-urls {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.url-link {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.illinihunt-link {
    background: #f0f9ff;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.illinihunt-link:hover {
    background: #e0f2fe;
    color: #075985;
    border-color: #7dd3fc;
}

.bolt-link {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.bolt-link:hover {
    background: #fde68a;
    color: #78350f;
    border-color: #fcd34d;
}

.badges {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.week-warrior {
    background: #fef3c7;
    color: #92400e;
}

.badge.pr-starter {
    background: #dbeafe;
    color: #1e40af;
}

.badge.merge-master {
    background: #d1fae5;
    color: #065f46;
}

.badge.commit-cadence {
    background: #e9d5ff;
    color: #6b21a8;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    margin-top: 12px;
}

.metric {
    text-align: center;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.info-icon {
    font-size: 0.7rem;
    opacity: 0.6;
    cursor: help;
    font-style: normal;
    user-select: none;
}

.info-icon:hover {
    opacity: 1;
}

.metric-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
}

.score {
    min-width: 80px;
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
}

.score-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.score-label {
    font-size: 0.7rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Simple view styles */
.leaderboard-item.simple {
    justify-content: space-between;
}

.leaderboard-item.simple .student-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.leaderboard-item.simple .metrics,
.leaderboard-item.simple .badges {
    display: none;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .stats-summary {
        grid-template-columns: 1fr;
    }

    .leaderboard-item {
        flex-wrap: wrap;
    }

    .score {
        text-align: left;
        margin-top: 10px;
    }

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

