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

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --border: #e2e8f0;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-amber: #f59e0b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px 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);
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border: #334155;
    --accent-blue: #60a5fa;
    --accent-green: #34d399;
    --accent-amber: #fbbf24;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.theme-toggle {
    position: fixed;
    top: 20px;
    right: 80px;
    z-index: 1000;
}

#theme-button {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    font-size: 1.5rem;
}

#theme-button:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

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

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

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 25px;
    margin-bottom: 20px;
}

.logo-img {
    width: auto;
    height: 100px;
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    animation: pulse 2s ease-in-out infinite;
}

.logo-img:hover {
    transform: scale(1.05) rotate(2deg);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

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

.header-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-size: 0.9rem;
    color: var(--text-tertiary);
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.separator {
    color: var(--text-tertiary);
}

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

.stat-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

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

.stat-card:hover::before {
    transform: translateX(0);
}

.stat-card h3 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.filters {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.search-input, .filter-select {
    padding: 12px 20px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 0.95rem;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.search-input {
    flex: 1;
    min-width: 300px;
}

.filter-select {
    min-width: 180px;
    cursor: pointer;
}

.search-input:focus, .filter-select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.leaderboard-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.refresh-button {
    padding: 8px 16px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.refresh-button:hover {
    background: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.refresh-button span {
    display: inline-block;
    transition: transform 0.3s ease;
}

.refresh-button:hover span {
    transform: rotate(180deg);
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: var(--bg-secondary);
}

th {
    padding: 20px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody tr {
    border-top: 1px solid var(--border);
    transition: background-color 0.2s ease;
}

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

td {
    padding: 20px;
}

.rank {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.model-name {
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-word;
}

.model-link {
    color: var(--accent-blue);
    text-decoration: none;
    transition: all 0.2s ease;
    border-bottom: 1px solid transparent;
}

.model-link:hover {
    color: var(--accent-green);
    border-bottom-color: var(--accent-green);
}

.score {
    font-weight: 600;
    font-size: 1.2rem;
}

.ugi-score {
    color: var(--accent-blue);
}

.w10-score {
    color: var(--accent-green);
}

.ideology {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.ideology-liberalism,
.ideology-classical-liberalism {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
}

.ideology-centrism {
    background-color: rgba(156, 163, 175, 0.1);
    color: var(--text-secondary);
}

.ideology-conservatism {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.ideology-progressivism {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
}

.ideology-libertarianism {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--accent-amber);
}

.ideology-nationalism {
    background-color: rgba(217, 119, 6, 0.1);
    color: #d97706;
}

.ideology-socialism {
    background-color: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

.ideology-unknown {
    background-color: rgba(156, 163, 175, 0.1);
    color: var(--text-tertiary);
}

.loading {
    text-align: center;
    padding: 60px;
    color: var(--text-secondary);
}

.refresh-notification {
    position: fixed;
    bottom: 100px;
    left: 40%;
    transform: translateX(-50%);
    background: var(--accent-green);
    color: white;
    padding: 12px 24px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
    z-index: 100;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

footer {
    margin-top: 60px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding-bottom: 40px;
}

footer a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

footer a:hover {
    text-decoration: underline;
}

/* Info Section */
.info-section {
    margin-bottom: 30px;
    animation: fadeIn 0.6s ease;
}

.info-section h2 {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 25px;
    color: var(--text-primary);
}

.score-explanations {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.score-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.score-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

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

.score-card:hover::before {
    transform: scaleX(1);
}

.score-icon {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 15px;
    animation: gentle-float 4s ease-in-out infinite;
}

.score-icon-img {
    width: 80px;
    height: 80px;
    display: block;
    margin: 0 auto 15px;
    animation: gentle-float 4s ease-in-out infinite;
}

@keyframes gentle-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.score-card h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.score-range {
    font-size: 0.9rem;
    color: var(--accent-blue);
    font-weight: 600;
    margin-bottom: 15px;
}

.score-card > p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.score-factors {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
}

.score-factors h4 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.score-factors ul {
    list-style: none;
    padding: 0;
}

.score-factors li {
    color: var(--text-secondary);
    padding: 8px 0;
    padding-left: 20px;
    position: relative;
}

.score-factors li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--accent-green);
    font-weight: bold;
}

.methodology-note {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(16, 185, 129, 0.1));
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    border: 1px solid var(--border);
}

.methodology-note p {
    color: var(--text-secondary);
    margin: 0;
}

/* Tooltips */
.th-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tooltip {
    position: relative;
    display: inline-flex;
    cursor: help;
    font-size: 0.9rem;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.tooltip:hover {
    opacity: 1;
}

.tooltip-text {
    visibility: hidden;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    white-space: nowrap;
    max-width: 250px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
}

.tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: var(--text-primary) transparent transparent transparent;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

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

@media (max-width: 768px) {
    .theme-toggle {
        top: 10px;
        right: 40px;
    }
    
    #theme-button {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .logo-img {
        height: 80px;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .search-input, .filter-select {
        width: 100%;
        min-width: auto;
    }
    
    .leaderboard-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .refresh-button {
        width: 100%;
        justify-content: center;
    }
    
    table {
        font-size: 0.85rem;
    }
    
    th, td {
        padding: 12px 8px;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    .info-section h2 {
        font-size: 1.4rem;
    }
    
    .score-explanations {
        grid-template-columns: 1fr;
    }
    
    .score-card {
        padding: 20px;
    }
    
    .score-icon {
        font-size: 2.5rem;
    }
    
    .tooltip-text {
        white-space: normal;
        max-width: 200px;
        font-size: 0.8rem;
    }
}

/* Back to Top Button */
#back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1000;
}

#back-to-top:hover {
    background: var(--accent-green);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

#back-to-top:active {
    transform: translateY(-2px);
}

#back-to-top span {
    display: inline-block;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-5px);
    }
    60% {
        transform: translateY(-3px);
    }
}

#back-to-top.show {
    display: flex;
}

@media (max-width: 768px) {
    #back-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
}