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

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Oxygen, Ubuntu, Cantarell, sans-serif;
    background: radial-gradient(circle at top, #2a69ff 0%, #12306a 45%, #0b1a36 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    color: #1f2937;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: #f7f9ff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(6, 24, 67, 0.35);
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.container::before {
    content: "";
    position: absolute;
    top: -120px;
    right: -80px;
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(247, 201, 72, 0.2) 0%, rgba(32, 58, 135, 0) 70%);
    pointer-events: none;
}

.container::after {
    content: "";
    position: absolute;
    bottom: -140px;
    left: -90px;
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, rgba(42, 105, 255, 0.15) 0%, rgba(32, 58, 135, 0) 70%);
    pointer-events: none;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #d7dcf1;
    position: relative;
}

h1 {
    font-family: 'Roboto Slab', 'Roboto', serif;
    color: #2c54c7;
    font-size: 2.5em;
    margin-bottom: 10px;
}

.clan-tag {
    color: #4b5563;
    font-size: 1.1em;
    margin-bottom: 5px;
}

.last-updated {
    color: #6b7280;
    font-size: 0.95em;
    font-style: italic;
    margin-top: 5px;
}

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.brand-logo {
    width: 86px;
    height: 86px;
    object-fit: contain;
}

.brand-text {
    text-align: left;
}

.hero-art {
    margin-top: 8px;
}

.hero-art svg {
    width: 180px;
    height: 64px;
    opacity: 0.85;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
}

.next-refresh {
    font-size: 14px;
    color: #2c54c7;
    font-weight: 500;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: 500;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.loading {
    color: #667eea;
    font-weight: 500;
}

.table-container {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#statsTable {
    min-width: 920px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    table-layout: fixed;
}

thead {
    background: linear-gradient(135deg, #2a69ff 0%, #203a87 100%);
    color: white;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    position: relative;
    white-space: nowrap;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    white-space: normal;
    line-height: 1.2;
    max-width: 200px;
}

th.sortable:hover {
    background: rgba(255, 255, 255, 0.1);
}

th.sortable::after {
    content: ' ↕';
    opacity: 0.5;
    font-size: 0.8em;
}

th.sortable.sorted-asc::after {
    content: ' ↑';
    opacity: 1;
}

th.sortable.sorted-desc::after {
    content: ' ↓';
    opacity: 1;
}

tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.2s;
}

tbody tr:hover {
    background-color: #f5f5f5;
}

tbody tr:nth-child(even) {
    background-color: #f2f5ff;
}

tbody tr:nth-child(even):hover {
    background-color: #f0f0f0;
}

td {
    padding: 12px 15px;
    text-align: left;
    word-break: break-word;
}

td:first-child {
    font-weight: 500;
    color: #333;
}

td:not(:first-child) {
    text-align: center;
    font-weight: 600;
    color: #203a87;
}

.error {
    background: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 6px;
    margin-top: 20px;
    border-left: 4px solid #c33;
}

.highlights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.home-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin: 0 0 18px;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin: 10px 0 20px;
}

.dashboard-card {
    background: #ffffff;
    border: 1px solid #e1e6fb;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 12px rgba(32, 58, 135, 0.12);
}

.dashboard-card h3 {
    color: #2c54c7;
    margin-bottom: 10px;
    font-size: 1.05em;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.stat-item {
    background: #f2f5ff;
    padding: 8px 10px;
    border-radius: 10px;
    color: #1f2937;
    font-size: 0.9em;
}

.list {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9ff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.9em;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: #e9edff;
    color: #2c54c7;
}

.badge-promote {
    background: #e6f7ef;
    color: #1f7a4d;
}

.badge-demote {
    background: #ffecec;
    color: #b42318;
}

.strategy-text {
    color: #4b5563;
    font-size: 0.9em;
    line-height: 1.4;
}

.highlight-card {
    background: #ffffff;
    border: 1px solid #e1e6fb;
    border-radius: 10px;
    padding: 14px;
    box-shadow: 0 2px 10px rgba(32, 58, 135, 0.12);
    text-align: left;
}

.highlight-card h4 {
    color: #2c54c7;
    margin-bottom: 8px;
    font-size: 1.05em;
}

.highlight-card p {
    color: #4b5563;
    margin: 0;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 16px;
}

.legend-item {
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eef2ff;
    color: #1f2937;
    border: 1px solid #d7dcf1;
}

.legend-green {
    background: #e6f7ef;
    color: #1f7a4d;
    border-color: #b7ebd1;
}

.legend-yellow {
    background: #fff7e6;
    color: #9c6b08;
    border-color: #ffe2b8;
}

.legend-red {
    background: #ffecec;
    color: #b42318;
    border-color: #f4b4b4;
}

.legend-na {
    background: #eef2f7;
    color: #475569;
    border-color: #d7dde6;
}

.menu-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 12px 0 18px;
    padding: 12px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #d7dcf1;
    box-shadow: 0 8px 18px rgba(36, 59, 143, 0.16);
    position: relative;
}

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid #d7dcf1;
    background: #ffffff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex-direction: column;
}

.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: #243b8f;
    border-radius: 999px;
}

.menu-tabs {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-left: auto;
}

.menu-tab {
    border: 1px solid #cbd5f5;
    background: #ffffff;
    color: #243b8f;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-tab:hover {
    background: #eef2ff;
}

.menu-tab.active {
    background: #243b8f;
    color: #ffffff;
    border-color: #243b8f;
}

.tab-panel {
    display: none;
}

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

.tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 10px 0 18px;
    flex-wrap: wrap;
}

.range-tab {
    border: 1px solid #d7dcf1;
    background: #ffffff;
    color: #2c54c7;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.range-tab:hover {
    background: #eef2ff;
}

.range-tab.active {
    background: #2c54c7;
    color: #ffffff;
    border-color: #2c54c7;
}

.member-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #475569;
    background: #ffffff;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid #d7dcf1;
}

.member-toggle input {
    width: 16px;
    height: 16px;
}

.player-tag {
    display: none;
    margin-left: 6px;
    font-size: 11px;
    color: #6b7280;
}

.name-cell:hover .player-tag {
    display: inline-block;
}

.former-member {
    opacity: 0.75;
}

.promotion-ready {
    color: #1f7a4d;
    font-weight: 700;
}

.promotion-badge {
    display: inline-block;
    margin-left: 6px;
    font-size: 11px;
    background: #e6f7ef;
    color: #1f7a4d;
    padding: 2px 6px;
    border-radius: 999px;
    font-weight: 700;
}

.info-icon {
    display: inline-block;
    margin-left: 6px;
    font-size: 11px;
    color: #64748b;
    border: 1px solid #cbd5f5;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    line-height: 14px;
    text-align: center;
    cursor: help;
    position: relative;
}

.info-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    top: calc(100% + 8px);
    transform: translateX(-50%);
    background: #0f172a;
    color: #f8fafc;
    font-size: 12px;
    line-height: 1.2;
    padding: 6px 8px;
    border-radius: 8px;
    white-space: normal;
    min-width: 200px;
    max-width: 260px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 20;
}

.info-icon:hover::after,
.info-icon:focus::after {
    opacity: 1;
}

.role-pill {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: #e9edff;
    color: #2c54c7;
    text-transform: capitalize;
}

.role-leader {
    background: #fef3c7;
    color: #92400e;
}

.role-coleader {
    background: #e0f2fe;
    color: #075985;
}

.role-elder {
    background: #ede9fe;
    color: #5b21b6;
}

.role-member {
    background: #e2e8f0;
    color: #334155;
}

.name-recent {
    color: #1f5eff;
    font-weight: 700;
}

.name-new-tag {
    display: inline-block;
    margin-left: 6px;
    font-size: 11px;
    background: #ffe7c2;
    color: #8a5a00;
    padding: 2px 6px;
    border-radius: 999px;
    font-weight: 700;
}

.score-green {
    color: #1f7a4d;
    background: #e6f7ef;
}

.score-yellow {
    color: #9c6b08;
    background: #fff7e6;
}

.score-red {
    color: #b42318;
    background: #ffecec;
}

.score-na {
    color: #475569;
    font-style: italic;
    background: #eef2f7;
}

.score-cell {
    border-radius: 6px;
}

.info-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.info-card {
    background: #f8f9ff;
    border: 1px solid #e6e8f5;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.08);
}

.info-card h3 {
    color: #5a67d8;
    font-size: 1.05em;
    margin-bottom: 8px;
}

.info-card p {
    color: #555;
    line-height: 1.4;
    font-size: 0.95em;
}

.summary-tables {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.summary-card {
    background: #ffffff;
    border: 1px solid #e1e6fb;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 12px rgba(32, 58, 135, 0.1);
}

.summary-card h3 {
    margin-top: 0;
    color: #2c54c7;
}

.summary-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.summary-table th,
.summary-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #eef2ff;
    text-align: left;
}

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

.summary-table tbody tr {
    cursor: pointer;
    transition: background 0.2s ease;
}

.summary-table tbody tr:hover {
    background: #eef2ff;
}

.summary-player {
    position: relative;
    font-weight: 600;
    color: #1f2937;
}

.summary-tag {
    margin-left: 6px;
    font-size: 11px;
    color: #64748b;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.summary-player:hover .summary-tag {
    opacity: 1;
}

.row-highlight {
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.5);
    background: #eef2ff;
    transition: background 0.3s ease;
}

.momentum-widget {
    display: flex;
    align-items: center;
    gap: 18px;
    margin: 12px 0 6px;
    flex-wrap: wrap;
}

.momentum-gauge {
    width: 220px;
    height: 120px;
}

.momentum-gauge svg {
    width: 100%;
    height: 100%;
}

.momentum-label {
    font-size: 10px;
    font-weight: 700;
    fill: #64748b;
}

.momentum-metrics {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.momentum-value {
    font-size: 1.2em;
    font-weight: 700;
    color: #1f2f7a;
}

.momentum-sub {
    font-size: 0.9em;
    color: #64748b;
}

.thermo-widget {
    display: flex;
    align-items: flex-end;
    gap: 18px;
    margin: 10px 0 6px;
    flex-wrap: wrap;
}

.thermo-scale {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 190px;
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
}

.thermo-meter {
    position: relative;
    width: 32px;
    height: 190px;
    border-radius: 16px;
    background: #e2e8f0;
    box-shadow: inset 0 0 0 2px rgba(148, 163, 184, 0.3);
    overflow: hidden;
}

.thermo-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(180deg, #22c55e 0%, #f59e0b 55%, #ef4444 100%);
    height: 0%;
}

.thermo-meter::after {
    content: "";
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(180deg, #f59e0b 0%, #ef4444 100%);
    box-shadow: inset 0 0 0 2px rgba(148, 163, 184, 0.25);
}

.thermo-metrics {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.site-footer {
    margin-top: 28px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
}

.version-tag {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.8);
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 1.8em;
    }

    header {
        text-align: center;
    }

    .brand {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .hero-art {
        display: none;
    }

    .menu-bar {
        align-items: flex-start;
        justify-content: flex-start;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .menu-tabs {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 10px;
        position: absolute;
        top: 56px;
        left: 12px;
        right: 12px;
        background: #ffffff;
        padding: 12px;
        border-radius: 14px;
        border: 1px solid #d7dcf1;
        box-shadow: 0 10px 24px rgba(36, 59, 143, 0.2);
    }

    .menu-tabs.open {
        display: flex;
    }

    .menu-tab {
        width: 100%;
    }

    .tabs {
        gap: 8px;
    }
    
    th, td {
        padding: 8px;
        font-size: 0.9em;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #statsTable {
        min-width: 900px;
    }

    th,
    td {
        white-space: nowrap;
    }

    .highlights,
    .home-cards,
    .dashboard,
    .info-section,
    .summary-tables {
        grid-template-columns: 1fr;
    }
}
