:root {
    --tier-s: #ff7676;
    --tier-a: #ffbf76;
    --tier-b: #f9ff76;
    --tier-c: #7aff76;
    --tier-d: #76d2ff;
    --primary: #2c3e50;
    --secondary: #34495e;
    --accent: #3498db;
    --light: #ecf0f1;
    --dark: #2c3e50;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #172a4e, #3a6073);
    color: var(--light);
    min-height: 100vh;
    overflow-x: hidden;
}

header {
    background-color: rgba(0, 0, 0, 0.5);
    padding: 20px 0;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.chess-piece {
    position: absolute;
    opacity: 0.1;
    font-size: 100px;
    transform: rotate(25deg);
}

.knight-left {
    left: 10%;
    top: -20px;
}

.queen-right {
    right: 10%;
    top: -30px;
}

h1 {
    position: relative;
    z-index: 1;
    font-size: 2.5rem;
    margin: 0;
    padding: 10px 0;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.2rem;
    margin-top: 10px;
}

.container {
    max-width: 1200px;
    margin: 30px auto;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    padding: 30px;
    color: var(--dark);
    transform: translateY(0);
    transition: transform 0.3s ease;
    position: relative;
    opacity: 0;
    overflow-x: auto;
}

.container::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 15px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 15px 15px 0 0;
}

.filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
    flex-wrap: wrap;
    gap: 15px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.filter-group label {
    font-weight: 600;
    margin-right: 5px;
}

.tier-filter, .search-filter {
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid #ddd;
    background-color: white;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.tier-filter:hover, .search-filter:hover,
.tier-filter:focus, .search-filter:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
    outline: none;
}

.search-filter {
    width: 200px;
    padding-left: 30px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23999" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>');
    background-repeat: no-repeat;
    background-position: 8px center;
}

.platform-switch-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.platform-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--dark);
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background-color: var(--accent);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider:hover {
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.engines-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    border-radius: 10px;
    position: relative;
    z-index: 1;
    overflow-x: auto;
}

.engines-table th {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.engines-table th:first-child {
    border-top-left-radius: 10px;
}

.engines-table th:last-child {
    border-top-right-radius: 10px;
}

.engines-table tr {
    transition: all 0.3s ease;
}

.engines-table tr:hover {
    background-color: rgba(52, 152, 219, 0.05);
}

.engines-table td {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.engines-table tr:last-child td {
    border-bottom: none;
}

.rank {
    font-weight: bold;
    text-align: center;
    font-size: 1.2em;
    width: 50px;
    position: relative;
}

.rank-medal {
    display: inline-block;
    padding: 5px 11px;
    border-radius: 50%;
    font-weight: bold;
    color: white;
}

.rank-1 {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    box-shadow: 0 3px 10px rgba(255, 215, 0, 0.5);
}

.rank-2 {
    background: linear-gradient(135deg, #C0C0C0, #A9A9A9);
    box-shadow: 0 3px 10px rgba(192, 192, 192, 0.5);
}

.rank-3 {
    background: linear-gradient(135deg, #CD7F32, #8B4513);
    box-shadow: 0 3px 10px rgba(205, 127, 50, 0.5);
}

.engine-name, .creator-name {
    font-weight: bold;
    font-size: 1.1em;
    transition: color 0.3s ease;
}

tr:hover .engine-name, tr:hover .creator-name {
    color: var(--accent);
}

.engine-name a, .creator-name a {
    text-decoration: none;
    color: inherit;
}

.engine-name a:hover, .creator-name a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.tier-badge {
    display: inline-block;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    text-align: center;
    line-height: 35px;
    font-weight: bold;
    font-size: 1.2em;
    color: #333;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.tier-badge:hover {
    transform: scale(1.2);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.tier-s { background: linear-gradient(135deg, var(--tier-s), #ff9f9f); }
.tier-a { background: linear-gradient(135deg, var(--tier-a), #ffcf9f); }
.tier-b { background: linear-gradient(135deg, var(--tier-b), #ffffa0); }
.tier-c { background: linear-gradient(135deg, var(--tier-c), #a1ff9f); }
.tier-d { background: linear-gradient(135deg, var(--tier-d), #9fe5ff); }

.description {
    font-style: italic;
    color: #666;
    min-width: 300px;
    max-width: 500px;
}

.elo, .creator, .version {
    text-align: center;
    font-weight: bold;
}

.engines-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.tier-legend {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin: 20px 0;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.tier-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tier-item-badge {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
}

.tier-desc {
    font-size: 0.9em;
}

footer {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9em;
    margin-top: 40px;
    font-style: italic;
}

footer a {
    color: white;
    text-decoration: underline;
}

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

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto;
}

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

.fetch-status {
    margin-top: 20px;
    text-align: center;
    padding: 10px;
    border-radius: 5px;
    background-color: rgba(0, 0, 0, 0.05);
}

#status-message {
    margin-bottom: 8px;
    font-weight: 500;
}

.progress-container {
    height: 6px;
    background-color: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto;
    max-width: 300px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #9b59b6);
    width: 0;
    transition: width 0.3s ease;
}

.project-thumbnail {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.project-thumbnail:hover {
    transform: scale(1.1);
}

.no-thumbnail {
    width: 80px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.8em;
    color: #999;
}

.thumbnail-cell {
    text-align: center;
}

.info-icon {
    width: 22px;
    height: 22px;
    background-color: #4a6fa5;
    color: white;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-style: italic;
    font-weight: bold;
    font-size: 14px;
    cursor: help;
    transition: all 0.2s ease;
}

.info-icon:hover {
    background-color: #2c5282;
    transform: scale(1.1);
}

.tooltip-container {
    position: relative;
    display: inline-block;
}

#global-tooltip {
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 12px;
    font-style: italic;
    font-weight: normal;
    font-size: 14px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    line-height: 1.5;
    pointer-events: none;
    max-width: 300px;
    width: auto;
    animation: tooltipFadeIn 0.2s ease-out forwards;
}

#global-tooltip::after {
    content: "";
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px 8px 0 8px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

td.info-cell {
    text-align: center;
    width: 40px;
    position: relative;
}

/* Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .container {
        margin: 15px;
        padding: 15px;
    }

    .filters {
        flex-direction: column;
        gap: 10px;
    }

    .engines-table {
        font-size: 0.85em;
        display: block;
        overflow-x: auto;
    }

    .engines-table td, .engines-table th {
        padding: 10px 8px;
        white-space: nowrap;
    }

    .description {
        max-width: 200px;
    }

    .tier-legend {
        padding: 10px;
    }

    .tier-item {
        font-size: 0.8em;
    }

    .platform-switch-container {
        flex-wrap: wrap;
        justify-content: center;
    }

    .search-filter {
        width: 100%;
    }
}
