@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Fira+Code:wght@400;500&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
* { font-family: inherit; }

:root {
    --bg:          #080808;
    --surface:     #111111;
    --card:        #181818;
    --card-hover:  #1f1f1f;
    --border:      #242424;
    --text:        #f2f2f2;
    --text2:       #b8b8b8;
    --muted:       #686868;
    --gold:        #f0c040;
    --blue:        #4a9eff;
    --purple:      #b060ff;
    --green:       #50c870;
    --header-h:    60px;
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    min-height: 100vh;
    line-height: 1.5;
}

/* Dot-grid atmosphere */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(circle, rgba(255,255,255,0.028) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
    z-index: 0;
}
.page, header, section, footer { position: relative; z-index: 1; }

a { text-decoration: none; color: inherit; }
button { cursor: pointer; }

/* ─── Header ─── */

.site-header {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-logo {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.header-name {
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text);
    white-space: nowrap;
}

.header-nav {
    display: flex;
    gap: 0.15rem;
    margin-left: auto;
    align-items: center;
}

.nav-link {
    padding: 0.4rem 0.85rem;
    border-radius: 5px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text2);
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}
.nav-link:hover  { color: var(--text); background: rgba(255,255,255,0.05); }
.nav-link.active { color: var(--text); background: rgba(255,255,255,0.08); }

.header-cwl-link {
    margin-left: 0.5rem;
    padding: 0.38rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.header-cwl-link:hover { color: var(--text2); border-color: #404040; }

/* ─── Page wrapper ─── */

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

/* ─── Hero ─── */

.hero {
    text-align: center;
    padding: 5rem 1.5rem 3rem;
    position: relative;
}

.hero-logo {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 1.5rem;
    box-shadow: 0 0 60px rgba(240,192,64,0.2), 0 0 120px rgba(240,192,64,0.06);
    border: 2px solid rgba(240,192,64,0.2);
}

.hero h1 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 4.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--gold) 0%, #fff 60%, var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-tagline {
    font-size: 0.95rem;
    color: var(--text2);
    max-width: 440px;
    margin: 0 auto 2rem;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ─── Reveal animation ─── */

.reveal {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeUp 0.38s ease forwards;
}
@keyframes fadeUp { to { opacity: 1; transform: none; } }
.reveal:nth-child(1) { animation-delay: 0.04s; }
.reveal:nth-child(2) { animation-delay: 0.10s; }
.reveal:nth-child(3) { animation-delay: 0.16s; }
.reveal:nth-child(4) { animation-delay: 0.22s; }
.reveal:nth-child(5) { animation-delay: 0.28s; }
.reveal:nth-child(6) { animation-delay: 0.34s; }

/* ─── Page hero card (leaderboards, players) ─── */

.page-hero {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin-bottom: 1.75rem;
    overflow: hidden;
}
.page-hero::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold) 0%, var(--purple) 55%, var(--blue) 100%);
}
.page-hero-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
}
.page-hero-sub {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.35rem;
}

/* ─── Section heading ─── */

.s-head {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

/* ─── Buttons ─── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.12s;
}
.btn:hover { opacity: 0.85; transform: translateY(-1px); }

.btn-discord {
    background: #5865f2;
    color: #fff;
}
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text2);
}
.btn-outline:hover { color: var(--text); border-color: #505050; }

/* ─── Stat cards ─── */

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    max-width: 860px;
    margin: 0 auto 3.5rem;
    padding: 0 1.5rem;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem 1.25rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
}
.stat-card.gold::before   { background: var(--gold); }
.stat-card.blue::before   { background: var(--blue); }
.stat-card.purple::before { background: var(--purple); }
.stat-card.green::before  { background: var(--green); }

.stat-value {
    font-family: 'Rajdhani', sans-serif;
    font-size: 2.6rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.4rem;
}
.stat-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.stat-card.gold   .stat-value { color: var(--gold); }
.stat-card.blue   .stat-value { color: var(--blue); }
.stat-card.purple .stat-value { color: var(--purple); }
.stat-card.green  .stat-value { color: var(--green); }

/* ─── Section heading ─── */

.section-head {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.section-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text2);
}

.section-sub {
    font-size: 0.78rem;
    color: var(--muted);
}

/* ─── Tables ─── */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead th {
    padding: 0.75rem 1rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text2);
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color 0.12s;
}
thead th:hover { color: var(--text); }
thead th.th-right { text-align: right; }
thead th.sorted-asc::after  { content: ' ↑'; color: var(--gold); }
thead th.sorted-desc::after { content: ' ↓'; color: var(--gold); }

tbody tr {
    border-bottom: 1px solid #161616;
    transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--card-hover); }

td {
    padding: 0.65rem 1rem;
    vertical-align: middle;
    color: var(--text);
    font-size: 0.875rem;
}
td.td-right { text-align: right; }
td.td-center { text-align: center; }

.td-rank    { color: var(--muted); font-size: 0.75rem; font-weight: 600; width: 40px; }
.td-name    { font-weight: 700; color: var(--text); }
.td-link    { color: var(--text); font-weight: 700; font-size: 0.9rem; }
.td-link:hover { color: var(--gold); }
.td-gold    { color: var(--gold); font-weight: 700; }
.td-blue    { color: var(--blue); font-weight: 700; }
.td-purple  { color: var(--purple); font-weight: 700; }
.td-muted   { color: var(--text2); }

/* ─── Tabs ─── */

.tab-bar {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 0.7rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.15s;
    margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text2); }
.tab-btn.wars.active    { color: var(--gold);   border-bottom-color: var(--gold); }
.tab-btn.cwl.active     { color: var(--blue);   border-bottom-color: var(--blue); }
.tab-btn.legends.active { color: var(--purple); border-bottom-color: var(--purple); }

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

/* ─── Search bar ─── */

.search-bar {
    width: 100%;
    max-width: 380px;
    padding: 0.62rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    margin-bottom: 1.25rem;
    transition: border-color 0.15s;
}
.search-bar:focus { border-color: #404040; }
.search-bar::placeholder { color: var(--muted); }

/* ─── Player profile ─── */

.profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.profile-header-left {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
}

.profile-clan-right {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    text-align: right;
    line-height: 1.2;
    flex-shrink: 0;
}

.profile-avatar {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--card);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.profile-name {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 0.3rem;
}

.profile-tag {
    font-size: 0.78rem;
    color: var(--muted);
    font-family: 'Courier New', monospace;
}

.profile-meta {
    font-size: 0.85rem;
    color: var(--text2);
    margin-top: 0.3rem;
}

/* ─── Info cards (profile) ─── */

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.info-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.4rem 1.25rem;
}

.info-card-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}
.info-card-title.gold   { color: var(--gold); }
.info-card-title.blue   { color: var(--blue); }
.info-card-title.purple { color: var(--purple); }

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.42rem 0;
    border-bottom: 1px solid #1c1c1c;
    font-size: 0.875rem;
}
.info-row:last-child { border-bottom: none; }
.info-row-label { color: var(--text2); }
.info-row-value { font-weight: 600; }

/* ─── Legends best-rank podium (profile) ─── */

.leg-best-rank {
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--purple);
    text-align: center;
    line-height: 1;
    margin: 1rem 0 0.6rem;
    letter-spacing: -0.02em;
}

.leg-best-meta {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    font-size: 0.88rem;
    color: var(--text2);
    font-weight: 600;
    padding-bottom: 0.5rem;
}

/* ─── Legends recent days bar chart ─── */

.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-top: 1rem;
}

.day-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.day-bar {
    width: 100%;
    background: var(--card-hover);
    border-radius: 3px;
    position: relative;
    overflow: hidden;
    height: 48px;
}

.day-bar-gain {
    position: absolute;
    bottom: 50%;
    left: 0; right: 0;
    background: var(--green);
    opacity: 0.75;
    border-radius: 2px 2px 0 0;
    min-height: 2px;
}

.day-bar-loss {
    position: absolute;
    top: 50%;
    left: 0; right: 0;
    background: #e05050;
    opacity: 0.65;
    border-radius: 0 0 2px 2px;
    min-height: 2px;
}

.day-label {
    font-size: 0.62rem;
    color: var(--muted);
}

.day-net-pos { font-size: 0.7rem; font-weight: 600; color: var(--green); }
.day-net-neg { font-size: 0.7rem; font-weight: 600; color: #e05050; }

/* ─── Legends snapshot (home) ─── */

.legends-snapshot {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    max-width: 560px;
    margin: 0 auto 3rem;
}

.legends-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid #161616;
    transition: background 0.1s;
}
.legends-row:last-child { border-bottom: none; }
.legends-row:hover { background: var(--card-hover); }

.legends-rank { font-size: 0.95rem; font-weight: 800; color: var(--muted); min-width: 28px; }
.legends-rank.r1 { color: var(--gold); }
.legends-rank.r2 { color: #b8b8b8; }
.legends-rank.r3 { color: #c87840; }
.legends-name { flex: 1; font-weight: 600; font-size: 0.9rem; }
.legends-trophy { color: var(--purple); font-weight: 700; font-size: 0.9rem; }

/* ─── CTA (home) ─── */

.cta-block {
    text-align: center;
    padding: 2.5rem 1.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 560px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}
.cta-block::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, var(--gold), var(--purple));
}
.cta-block h2 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.cta-block p {
    color: var(--text2);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ─── Loading / Empty ─── */

.loading {
    text-align: center;
    padding: 4rem;
    color: var(--muted);
    font-size: 0.875rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}
.empty-state p { color: var(--text2); font-size: 0.9rem; }

/* ─── Back link ─── */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 1.5rem;
    padding: 0.45rem 0.9rem 0.45rem 0.7rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.back-link:hover {
    color: var(--text);
    border-color: #404040;
    background: var(--card-hover);
}

/* ─── Scrollbar ─── */

::-webkit-scrollbar       { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ─── Responsive ─── */

@media (max-width: 640px) {
    .hero h1 { font-size: 2rem; }
    .hero-logo { width: 84px; height: 84px; }
    .stat-row { grid-template-columns: repeat(2, 1fr); padding: 0; }
    .header-name { display: none; }
    .header-cwl-link { display: none; }
    .profile-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .profile-clan-right { text-align: left; font-size: 1.2rem; }
    .cards-grid { grid-template-columns: 1fr; }
    .days-grid { grid-template-columns: repeat(7, 1fr); }
    .tab-btn { padding: 0.55rem 0.9rem; font-size: 0.8rem; }
}
