:root {
    --ink: #0b1220;
    --panel: #161f38;
    --panel-alt: #1b2544;
    --panel-raised: #202b4d;
    --line: #2a3557;
    --line-soft: #202a48;
    --accent: #ff8a3d;
    --accent-dim: #b35a1f;
    --accent-glow: rgba(255, 138, 61, 0.22);
    --amber: #f2a93b;
    --violet: #8b5cf6;
    --live: #ff4d5e;
    --live-glow: rgba(255, 77, 94, 0.28);
    --text: #f3f5f9;
    --text-dim: #a7b0c2;
    --text-faint: #5f6a82;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    background: var(--ink);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.mono { font-family: 'JetBrains Mono', monospace; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

body::before {
    content: ""; position: fixed; inset: 0;
    background-image: linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 64px 64px; z-index: -2; pointer-events: none;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
main { flex: 1; }

/* ============ NAV ============ */
.pedia-nav {
    position: sticky; top: 0; z-index: 100;
    background: rgba(11,18,32,0.9); border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    padding: 0 32px; height: 68px; display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
}
.pedia-brand { display: flex; align-items: center; gap: 11px; }
.pedia-brand img { height: 30px; }
.pedia-brand-text { font-family: 'Barlow Condensed', sans-serif; font-size: 18px; font-weight: 600; }
.pedia-brand-text span { color: var(--accent); font-weight: 700; }
.pedia-brand-sep { color: var(--text-faint); font-size: 13px; margin: 0 2px; }

.pedia-links { display: flex; align-items: center; gap: 28px; }
.pedia-links a {
    font-size: 12.5px; font-weight: 600; letter-spacing: 0.03em; color: var(--text-dim);
    transition: color 0.2s ease;
}
.pedia-links a:hover, .pedia-links a.active { color: var(--accent); }
.pedia-back {
    font-size: 11.5px; color: var(--text-faint); font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.04em; display: flex; align-items: center; gap: 6px;
}
.pedia-back:hover { color: var(--accent); }

.pedia-toggle { display: none; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: 6px; }
.pedia-toggle span { width: 20px; height: 2px; background: var(--text); border-radius: 2px; }
.pedia-mobile-panel {
    display: none; flex-direction: column; padding: 14px 32px 20px; gap: 2px;
    background: rgba(11,18,32,0.98); border-bottom: 1px solid var(--line);
}
.pedia-mobile-panel.open { display: flex; }
.pedia-mobile-panel a { padding: 11px 0; font-size: 14px; font-weight: 600; color: var(--text-dim); border-bottom: 1px solid var(--line-soft); }

/* ============ HERO / PAGE HEADER ============ */
.pedia-hero {
    padding: 64px 24px 40px; text-align: center;
    background: radial-gradient(ellipse 900px 500px at 50% -10%, #182240 0%, var(--ink) 65%);
    border-bottom: 1px solid var(--line);
}
.pedia-hero-eyebrow {
    display: inline-flex; align-items: center; gap: 8px; font-size: 11px; color: var(--accent);
    letter-spacing: 0.14em; text-transform: uppercase; font-family: 'JetBrains Mono', monospace;
    border: 1px solid var(--accent-dim); padding: 6px 14px; border-radius: 20px; margin-bottom: 20px;
}
.pedia-hero h1 {
    font-family: 'Barlow Condensed', sans-serif; font-size: clamp(32px, 5vw, 52px);
    font-weight: 700; color: #fff; margin-bottom: 14px;
}
.pedia-hero h1 .accent {
    background: linear-gradient(135deg, var(--accent) 0%, #ffc98a 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.pedia-hero p { color: var(--text-dim); font-size: 15px; max-width: 560px; margin: 0 auto; line-height: 1.6; }

.page-header { padding: 48px 24px 8px; }
.page-header h1 { font-family: 'Barlow Condensed', sans-serif; font-size: 34px; font-weight: 700; margin-bottom: 6px; }
.page-header p { color: var(--text-dim); font-size: 14px; }

/* ============ SEARCH ============ */
.search-bar {
    position: relative; max-width: 560px; margin: 28px auto 0;
}
.search-bar input {
    width: 100%; padding: 15px 18px 15px 46px; background: var(--panel);
    border: 1px solid var(--line); color: var(--text); border-radius: 10px;
    font-family: 'Inter', sans-serif; font-size: 14px; outline: none; transition: border-color 0.2s ease;
}
.search-bar input:focus { border-color: var(--accent-dim); }
.search-bar input::placeholder { color: var(--text-faint); }
.search-bar svg {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none;
}
.search-results {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--panel-raised);
    border: 1px solid var(--line); border-radius: 10px; overflow: hidden; z-index: 50;
    box-shadow: 0 20px 50px -12px rgba(0,0,0,0.6); display: none; max-height: 360px; overflow-y: auto;
}
.search-results.open { display: block; }
.search-result-group-label {
    font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint);
    font-family: 'JetBrains Mono', monospace; padding: 10px 16px 4px;
}
.search-result-row {
    display: flex; align-items: center; gap: 10px; padding: 10px 16px; font-size: 13px;
    border-top: 1px solid var(--line-soft); transition: background 0.15s ease;
}
.search-result-row:hover { background: var(--panel-alt); }
.search-result-row img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; background: var(--panel); }
.search-result-empty { padding: 16px; font-size: 13px; color: var(--text-faint); text-align: center; }

.filter-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 22px 0 0; }
.filter-row select {
    background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 8px;
    padding: 9px 12px; font-family: 'Inter', sans-serif; font-size: 12.5px; outline: none;
}

/* ============ STAT ROW / TILES ============ */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; max-width: 900px; margin: 32px auto 0; }
.stat-tile {
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; text-align: center;
}
.stat-tile .v { font-family: 'Barlow Condensed', sans-serif; font-size: 30px; font-weight: 700; color: var(--accent); }
.stat-tile .l { font-size: 10.5px; color: var(--text-faint); letter-spacing: 0.1em; text-transform: uppercase; font-family: 'JetBrains Mono', monospace; margin-top: 4px; }

/* ============ SECTIONS ============ */
.section { padding: 56px 24px; }
.section-title-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; }
.section-title-row h2 { font-family: 'Barlow Condensed', sans-serif; font-size: 24px; font-weight: 600; }
.section-title-row a { font-size: 12px; color: var(--accent); font-weight: 600; }

/* ============ CARD GRID ============ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; max-width: 1180px; margin: 0 auto; }
.entity-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px;
    transition: border-color 0.2s ease, transform 0.2s ease; display: block;
}
.entity-card:hover { border-color: var(--accent-dim); transform: translateY(-2px); }
.entity-card .ec-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.entity-card .ec-logo { width: 40px; height: 40px; border-radius: 8px; object-fit: contain; background: var(--panel-alt); flex-shrink: 0; }
.entity-card .ec-name { font-family: 'Barlow Condensed', sans-serif; font-size: 17px; font-weight: 600; line-height: 1.2; }
.entity-card .ec-meta { font-size: 11.5px; color: var(--text-faint); font-family: 'JetBrains Mono', monospace; margin-top: 2px; }
.entity-card .ec-org {
    display: inline-block; font-size: 9.5px; color: var(--text-faint); border: 1px solid var(--line);
    padding: 2px 7px; border-radius: 10px; font-family: 'JetBrains Mono', monospace; letter-spacing: 0.05em;
}
.entity-card .ec-line { font-size: 12.5px; color: var(--text-dim); margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.entity-card .ec-mvp { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.entity-card .ec-mvp img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }

/* ============ DATA TABLE ============ */
.table-wrap { max-width: 1180px; margin: 0 auto; overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
.data-table th {
    text-align: left; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint);
    font-family: 'JetBrains Mono', monospace; padding: 14px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.data-table tbody tr { transition: background 0.15s ease; }
.data-table tbody tr.linkable { cursor: pointer; }
.data-table tbody tr.linkable:hover { background: var(--panel-alt); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-family: 'JetBrains Mono', monospace; }
.data-table .entity-cell { display: flex; align-items: center; gap: 10px; }
.data-table .entity-cell img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--panel-alt); flex-shrink: 0; }
.data-table .entity-cell .name { font-weight: 600; }
.data-table .entity-cell .sub { font-size: 11px; color: var(--text-faint); }

.rank-badge {
    display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
    border-radius: 7px; font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 12px;
    background: var(--panel-alt); color: var(--text-dim);
}
.rank-badge.r1 { background: linear-gradient(135deg, #f2c94c, #f2a93b); color: #2b1a00; }
.rank-badge.r2 { background: linear-gradient(135deg, #d9dee6, #a7b0c2); color: #16203a; }
.rank-badge.r3 { background: linear-gradient(135deg, #d9985b, #b35a1f); color: #2b1400; }

.alias-chip {
    display: inline-block; font-size: 11px; color: var(--text-dim); background: var(--panel-alt);
    border: 1px solid var(--line); padding: 3px 9px; border-radius: 12px; margin: 2px 4px 2px 0;
}
.identity-warning {
    display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--amber);
    border: 1px solid var(--amber); padding: 4px 10px; border-radius: 12px; letter-spacing: 0.04em;
    text-transform: uppercase; font-family: 'JetBrains Mono', monospace;
}
/* ============ PAGINATION ============ */
.pagination { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 24px 0 0; }
.pagination button {
    background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: 8px 16px;
    border-radius: 7px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
}
.pagination button:hover:not(:disabled) { border-color: var(--accent-dim); color: var(--accent); }
.pagination button:disabled { opacity: 0.35; cursor: not-allowed; }
.pagination .p-info { font-size: 12px; color: var(--text-faint); font-family: 'JetBrains Mono', monospace; }

/* ============ EMPTY / LOADING ============ */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-faint); font-size: 13.5px; }

/* ============ ENTITY HEADER (player/team/tournament detail) ============ */
.entity-header {
    max-width: 1180px; margin: 0 auto; padding: 40px 24px; display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
}
.entity-header .eh-pic {
    width: 88px; height: 88px; border-radius: 50%; object-fit: cover; border: 2px solid var(--line); background: var(--panel);
}
.entity-header .eh-logo {
    width: 88px; height: 88px; border-radius: 14px; object-fit: contain; background: var(--panel); border: 1px solid var(--line); padding: 8px;
}
.entity-header h1 { font-family: 'Barlow Condensed', sans-serif; font-size: 36px; font-weight: 700; }
.entity-header .eh-tag { color: var(--accent); font-family: 'JetBrains Mono', monospace; font-size: 14px; margin-left: 8px; }
.entity-header .eh-sub { font-size: 12.5px; color: var(--text-faint); margin-top: 6px; }
.entity-header .eh-aliases { margin-top: 10px; }

/* ============ FOOTER ============ */
footer { border-top: 1px solid var(--line); padding: 32px 24px; text-align: center; }
footer p { font-size: 11.5px; color: var(--text-faint); }
footer a { color: var(--accent); }

@media (max-width: 860px) {
    .pedia-links { display: none; }
    .pedia-toggle { display: flex; }
    .card-grid { grid-template-columns: 1fr; }
    .entity-header { flex-direction: column; text-align: center; }
}

/* ============ MOBILE (≤700px) ============ */
@media (max-width: 700px) {
    .wrap { padding: 0 16px; }
    .pedia-nav { padding: 0 16px; height: 58px; }
    .pedia-brand img { height: 24px; }
    .pedia-brand-text { font-size: 15px; }
    .pedia-mobile-panel { padding: 10px 16px 16px; }
    .pedia-mobile-panel a { padding: 13px 2px; font-size: 15px; }

    .pedia-hero { padding: 40px 16px 32px; }
    .pedia-hero-eyebrow { font-size: 10px; padding: 5px 11px; margin-bottom: 16px; }
    .pedia-hero p { font-size: 13.5px; }
    .page-header { padding: 32px 16px 4px; }
    .page-header h1 { font-size: 27px; }
    .page-header p { font-size: 13px; }

    .search-bar { margin-top: 20px; }
    .search-bar input { padding: 13px 16px 13px 42px; font-size: 16px; } /* 16px avoids iOS auto-zoom on focus */
    .search-bar svg { left: 14px; width: 15px; height: 15px; }

    .filter-row { margin-top: 16px; }
    .filter-row select { flex: 1 1 auto; padding: 11px 12px; font-size: 13px; }

    .stat-row { gap: 10px; margin-top: 22px; grid-template-columns: repeat(2, 1fr); }
    .stat-tile { padding: 14px 10px; }
    .stat-tile .v { font-size: 24px; }
    .stat-tile .l { font-size: 9.5px; }

    .section { padding: 36px 16px; }
    .section-title-row h2 { font-size: 20px; }

    .card-grid { gap: 12px; }
    .entity-card { padding: 16px; }

    .entity-header { padding: 28px 16px; gap: 14px; }
    .entity-header .eh-pic, .entity-header .eh-logo { width: 68px; height: 68px; }
    .entity-header h1 { font-size: 26px; }

    .table-wrap { border-radius: 10px; }

    /* ---- data table → stacked cards ---- */
    .data-table { min-width: 0; width: 100%; }
    .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr {
        display: flex; flex-wrap: wrap; align-items: center; column-gap: 12px; row-gap: 6px;
        padding: 13px 14px; border-bottom: 1px solid var(--line-soft);
    }
    .data-table tbody tr:last-child { border-bottom: none; }
    .data-table td { width: auto; padding: 0; border: none; }
    .data-table td.tc-lead { order: 1; flex: 0 0 auto; }
    .data-table td.tc-entity { order: 2; flex: 1 1 150px; min-width: 0; }
    .data-table td.tc-entity .entity-cell .name { font-size: 13.5px; }
    .data-table td[data-label] {
        order: 3; flex: 0 1 auto; text-align: left; font-size: 12.5px; color: var(--text);
        white-space: nowrap;
    }
    .data-table td[data-label]::before {
        content: attr(data-label); display: block; font-size: 9px; letter-spacing: 0.08em;
        text-transform: uppercase; color: var(--text-faint); font-family: 'JetBrains Mono', monospace;
        margin-bottom: 1px;
    }

    .pagination { gap: 8px; }
    .pagination button { padding: 9px 14px; }
    .pagination .p-info { font-size: 11px; }

    footer { padding: 24px 16px; }
}

@media (max-width: 400px) {
    .stat-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .pedia-hero h1 { font-size: 30px; }
    .entity-header h1 { font-size: 22px; }
    .data-table tr { padding: 12px; }
}
