:root {
    --bg-color: #0d0f17;
    --text-primary: #f0f4f8;
    --text-secondary: #a0aec0;
    --accent-color: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.4);
    --secondary-accent: #3b82f6;
    --danger: #ef4444;
    --success: #10b981;
    
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    --font-heading: 'Clash Display', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --transition-fast: 0.2s ease;
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

/* Background Effects */
.glow-bg {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.15), transparent 40%),
                radial-gradient(circle at bottom left, rgba(139, 92, 246, 0.1), transparent 40%);
    z-index: -2;
    pointer-events: none;
}

.blob-bg {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.5;
    pointer-events: none;
    animation: float 20s infinite alternate ease-in-out;
}

.blob-1 {
    top: -10%; left: -10%;
    width: 500px; height: 500px;
    background: rgba(139, 92, 246, 0.2);
}

.blob-2 {
    bottom: -10%; right: -10%;
    width: 600px; height: 600px;
    background: rgba(59, 130, 246, 0.15);
    animation-delay: -10s;
}

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

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* Navbar */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    background: rgba(13, 15, 23, 0.7);
    padding: 1rem 0;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #fff, #a0aec0);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-item {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition-fast);
    position: relative;
}

.nav-item:hover {
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--text-primary);
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-color);
    border-radius: 2px;
    box-shadow: 0 0 10px var(--accent-glow);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition-fast);
    border: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color), var(--secondary-accent));
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

.btn-secondary {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.heart {
    animation: beat 1.5s infinite alternate;
}

@keyframes beat {
    0% { transform: scale(1); }
    100% { transform: scale(1.2); }
}

/* Main Content */
main {
    flex: 1;
    padding: 3rem 0;
}

.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.hero {
    text-align: center;
    padding: 3rem 2rem;
    margin-bottom: 3rem;
}

.hero h2 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #8b5cf6, #3b82f6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 2rem;
    font-size: 1.1rem;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem 2rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: var(--success);
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-top: 3rem;
    text-align: left;
}

.feature-card {
    padding: 1.5rem;
    border-radius: 12px;
    transition: var(--transition-fast);
}

.feature-card:hover {
    transform: translateY(-5px);
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.feature-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
}

/* Tabs */
.tab-pane {
    display: none;
    animation: fadeIn var(--transition-slow);
}

.tab-pane.active {
    display: block;
}

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

.section-header {
    margin-bottom: 2rem;
}

.section-header h3 {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    color: var(--text-primary);
}

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

/* Tables */
.table-container {
    overflow: auto;
    max-height: 70vh;
    padding: 1px;
    margin-top: 0; /* No negative margin to avoid overlap issues */
    position: relative;
    min-height: 250px;
}

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

thead th {
    padding: 1.2rem 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--glass-border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #0f121b; /* solid color matching glass panel on dark bg */
}

/* First Column Sticky */
thead th:first-child,
tbody td:first-child {
    position: sticky;
    left: 0;
    background-color: #0f121b;
    z-index: 15;
}

thead th:first-child {
    z-index: 20; /* Top and left sticky */
}

/* Ensure borders are visible when sticky scrolling */
thead th {
    box-shadow: 0 2px 0 0 var(--glass-border);
}
tbody td:first-child {
    box-shadow: 1px 0 0 0 var(--glass-border);
}

tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-size: 0.95rem;
}

tbody tr {
    transition: var(--transition-fast);
}

tbody tr:hover td {
    background: rgba(255, 255, 255, 0.05);
}

tbody tr:hover td:first-child {
    background: #171b26; /* solid representation of hover on the sticky cell */
}

tbody tr:last-child td {
    border-bottom: none;
}

.highlight {
    color: var(--accent-color);
    font-weight: 600;
}

/* Select */
.game-selector-container,
.records-filter-container {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.futuristic-select {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font-body);
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0aec0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    min-width: 250px;
    transition: var(--transition-fast);
}

.futuristic-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.futuristic-select option {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

/* Cards Grid */
.records-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.record-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: var(--transition-fast);
}

.record-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border-color: rgba(139, 92, 246, 0.3);
}

.record-card h4 {
    font-family: var(--font-heading);
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.record-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.bot-names {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem;
    border-radius: 6px;
    margin-top: 0.5rem;
    color: var(--text-primary) !important;
}

.vs {
    color: var(--accent-color);
    font-weight: bold;
    font-size: 0.8rem;
    margin: 0 0.5rem;
}

.record-meta {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.badge {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-primary);
}

.game-type-badge {
    border: 1px solid var(--accent-color);
}

.plies-badge {
    border: 1px solid var(--secondary-accent);
}

.loser {
    display: block;
    color: var(--danger);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.failure-reason {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
    margin-bottom: 1rem;
}

.file-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    border: 1px solid transparent;
    transition: var(--transition-fast);
}

.file-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--glass-border);
}

/* Footer */
.footer {
    border-top: 1px solid var(--glass-border);
    padding: 2rem 0;
    margin-top: auto;
    background: rgba(0, 0, 0, 0.2);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.loader {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Tooltips */
.help-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--glass-border);
    border-radius: 50%;
    font-size: 10px;
    cursor: help;
    margin-left: 4px;
    color: var(--text-secondary);
    vertical-align: middle;
    position: relative;
    border: 1px solid var(--glass-border);
}

.help-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a202c;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: normal;
    width: 180px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    text-transform: none;
    font-weight: 400;
    line-height: 1.4;
    border: 1px solid var(--glass-border);
}

.help-tooltip:hover {
    z-index: 100;
}

/* Elevate the parent th cell so the tooltip isn't hidden under adjacent column headers */
thead th:has(.help-tooltip:hover) {
    z-index: 100;
}

.help-tooltip:hover::after {
    opacity: 1;
    top: calc(100% + 5px);
}

.metric-best {
    color: var(--success) !important;
    font-weight: 600;
}

.metric-best::after {
    content: '★';
    font-size: 0.6rem;
    vertical-align: super;
    margin-left: 2px;
    opacity: 0.8;
}

/* Docs */
.docs-content {
    padding: 2rem;
}

.doc-section {
    margin-bottom: 2rem;
}

.doc-section:last-child {
    margin-bottom: 0;
}

.doc-section h4 {
    font-family: var(--font-heading);
    color: var(--accent-color);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.doc-section p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.doc-section ul {
    list-style: none;
    padding-left: 0;
}

.doc-section li {
    margin-bottom: 0.8rem;
    color: var(--text-secondary);
}

.doc-section li strong {
    color: var(--text-primary);
}

.prompt-quote {
    padding: 1rem 1.5rem;
    margin: 1rem 0 2rem 0;
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-left: 4px solid var(--accent-color);
    background: rgba(0, 0, 0, 0.3);
    line-height: 1.8;
}

.doc-section h5 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

/* Hide Stability in per-game views usually? User wants "Summary and per games, on the same page" */
/* We will handle showing/hiding stability-col in JS based on selection */

/* Responsive */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 100%;
        left: 0;
        background: rgba(13, 15, 23, 0.95);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        padding: 1.5rem;
        border-bottom: 1px solid var(--glass-border);
        gap: 1.5rem;
        text-align: center;
        box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    }
    .nav-links.active {
        display: flex;
    }
    .mobile-menu-btn {
        display: block;
    }
    .hero h2 {
        font-size: 2rem;
    }
    .hero-stats {
        flex-direction: column;
    }
    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}
