:root {
    color-scheme: dark;
    --bg: #0b0e13;
    --surface: #131820;
    --surface-2: #19212c;
    --surface-3: #202a36;
    --line: #303b49;
    --line-soft: #26313d;
    --text: #f7f9fc;
    --text-2: #d8e0ea;
    --muted: #a8b3c2;
    --muted-2: #7f8b9b;
    --green: #4bd487;
    --gold: #f0c66c;
    --red: #f06c72;
    --cyan: #5bc7df;
    --violet: #b99cff;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% -10%, rgba(75, 212, 135, 0.18), transparent 32rem),
        radial-gradient(circle at 90% 4%, rgba(240, 198, 108, 0.13), transparent 28rem),
        linear-gradient(180deg, #10151d 0%, var(--bg) 42%);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 74px;
    padding: 14px 28px;
    border-bottom: 1px solid var(--line-soft);
    background: rgba(11, 14, 19, 0.92);
    backdrop-filter: blur(18px);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar-brand h1 {
    margin: 0;
    font-size: 20px;
    line-height: 1.05;
}

.topbar-brand p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.topnav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.nav-button {
    min-height: 38px;
    border-radius: 8px;
    padding: 0 14px;
    background: var(--surface-2);
    color: var(--text-2);
    cursor: pointer;
    font-size: 13px;
    font-weight: 850;
}

.nav-button:hover,
.nav-button.is-active {
    border-color: rgba(240, 198, 108, 0.75);
    background: rgba(240, 198, 108, 0.13);
    color: var(--text);
}

button,
input,
select {
    font: inherit;
}

button,
select,
input {
    border: 1px solid var(--line);
    background: #0f141b;
    color: var(--text);
    outline: none;
}

a {
    color: inherit;
    text-decoration: none;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(91, 199, 223, 0.2);
}

.shell {
    display: grid;
    grid-template-columns: 352px minmax(0, 1fr);
    min-height: calc(100vh - 74px);
}

.shell.no-sidebar {
    grid-template-columns: minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 74px;
    height: calc(100vh - 74px);
    padding: 24px 20px;
    border-right: 1px solid var(--line-soft);
    background: rgba(11, 14, 19, 0.9);
    backdrop-filter: blur(18px);
    overflow: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.brand-mark,
.profile-avatar,
.creature-mark,
.avatar-shell {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: linear-gradient(135deg, var(--green), var(--cyan) 58%, var(--gold));
    color: #071016;
    font-weight: 900;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.avatar-shell,
.profile-avatar {
    overflow: hidden;
    position: relative;
    background: transparent;
    box-shadow: none;
}

.avatar-shell.has-avatar,
.profile-avatar.has-avatar {
    background: transparent;
    box-shadow: none;
}

.avatar-shell img,
.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.avatar-sprite-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.avatar-shell span,
.profile-avatar span {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 8px;
}

.brand h1,
.profile-head h2,
.section-head h3 {
    margin: 0;
    letter-spacing: 0;
}

.brand h1 {
    font-size: 22px;
    line-height: 1.1;
}

.brand p,
.profile-head p,
.eyebrow,
.muted {
    color: var(--muted);
}

.brand p,
.profile-head p,
.eyebrow {
    margin: 4px 0 0;
    font-size: 13px;
}

.home-button {
    width: 100%;
    height: 42px;
    margin-bottom: 14px;
    border-radius: 8px;
    border-color: var(--line);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    font-weight: 900;
}

.home-button:hover {
    background: var(--surface-3);
}

.eyebrow {
    color: var(--gold);
    font-weight: 800;
    text-transform: uppercase;
}

.search-row,
.collection-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 116px;
    gap: 10px;
}

.search-row input,
.search-row select,
.collection-tools input,
.collection-tools select {
    width: 100%;
    height: 42px;
    border-radius: 8px;
    padding: 0 12px;
    background: var(--surface);
}

.search-row input::placeholder {
    color: var(--muted-2);
}

.collection-tools input::placeholder {
    color: var(--muted-2);
}

.user-list {
    height: calc(100vh - 136px);
    margin-top: 16px;
    overflow: auto;
    padding-right: 6px;
}

.user-list::-webkit-scrollbar {
    width: 8px;
}

.user-list::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 999px;
}

.user-row {
    width: 100%;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    min-height: 66px;
    margin-bottom: 9px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px;
    background: rgba(19, 24, 32, 0.7);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.user-row:hover {
    border-color: var(--line);
    background: var(--surface);
    transform: translateY(-1px);
}

.user-row.is-active {
    border-color: rgba(75, 212, 135, 0.8);
    background: linear-gradient(135deg, rgba(75, 212, 135, 0.16), rgba(91, 199, 223, 0.08));
}

.user-initial {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-weight: 900;
}

.user-name,
.creature-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-name {
    display: block;
    color: var(--text);
    font-weight: 850;
}

.user-sub,
.metric-label,
.creature-sub,
.board-sub {
    display: block;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.user-score {
    min-width: 42px;
    color: var(--gold);
    font-size: 14px;
    font-weight: 900;
    text-align: right;
}

.content {
    width: min(100%, 1480px);
    padding: 28px;
    overflow: visible;
}

.shell.no-sidebar .content {
    width: min(100%, 1180px);
    margin: 0 auto;
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 12px;
}

.overview-card,
.profile-panel,
.stats-panel,
.collection-panel,
.catalog-panel,
.pokedex-panel,
.rankings-panel > .stats-panel {
    border: 1px solid var(--line-soft);
    background: rgba(19, 24, 32, 0.9);
    box-shadow: var(--shadow);
}

.overview-card {
    min-height: 98px;
    border-radius: 8px;
    padding: 16px;
}

.home-panel {
    display: grid;
    gap: 16px;
    margin-top: 16px;
}

.home-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.75fr);
    gap: 24px;
    align-items: center;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(75, 212, 135, 0.14), transparent 42%),
        linear-gradient(315deg, rgba(240, 198, 108, 0.12), transparent 38%),
        rgba(19, 24, 32, 0.92);
    box-shadow: var(--shadow);
}

.home-hero h2 {
    margin: 0;
    font-size: 32px;
    line-height: 1.05;
}

.home-hero p:not(.eyebrow) {
    max-width: 760px;
    margin: 10px 0 0;
    color: var(--text-2);
}

.home-hero-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 10px;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.home-wide-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
    gap: 16px;
}

.home-compact-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.7fr);
    gap: 16px;
}

.home-list,
.activity-list,
.featured-grid {
    display: grid;
    gap: 8px;
}

.home-user-row,
.activity-row {
    width: 100%;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    min-height: 58px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    padding: 9px;
    background: #10151c;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.home-user-row:hover,
.activity-row:hover,
.featured-card:hover {
    border-color: var(--line);
    background: var(--surface);
}

.featured-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.featured-card {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    padding: 12px;
    background: #10151c;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.featured-avatar {
    width: 56px;
    height: 56px;
    border-radius: 8px;
}

.featured-stats {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.featured-stats span {
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    padding: 6px;
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 800;
    text-align: center;
}

.overview-value,
.metric-value {
    color: var(--text);
    font-size: 26px;
    font-weight: 950;
    line-height: 1.05;
}

.overview-label,
.metric-label {
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    text-transform: uppercase;
}

.profile-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 430px);
    gap: 24px;
    align-items: center;
    margin-top: 16px;
    border-radius: 8px;
    padding: 22px;
}

.profile-main {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.profile-avatar {
    width: 84px;
    height: 84px;
    border-radius: 8px;
    font-size: 32px;
}

.profile-head {
    min-width: 0;
}

.profile-head h2 {
    overflow-wrap: anywhere;
    font-size: 34px;
    line-height: 1.05;
}

.profile-head p {
    color: var(--text-2);
}

.profile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 14px;
}

.profile-actions button,
.profile-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border-radius: 8px;
    padding: 0 14px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    font-weight: 850;
}

.profile-actions button {
    border-color: rgba(75, 212, 135, 0.75);
    background: rgba(75, 212, 135, 0.16);
}

.profile-actions a.is-disabled {
    pointer-events: none;
    opacity: 0.52;
}

.rank-block {
    padding: 16px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: #10151c;
}

.rank-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 850;
}

.progress-track {
    height: 12px;
    margin: 11px 0;
    border-radius: 999px;
    background: #080b10;
    overflow: hidden;
}

.progress-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--green), var(--gold));
    transition: width 0.2s ease;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.stats-panel,
.collection-panel,
.catalog-panel,
.pokedex-panel,
.rankings-panel > .stats-panel {
    border-radius: 8px;
    padding: 18px;
    overflow: visible;
}

.users-empty-panel,
.rankings-panel,
.catalog-panel,
.pokedex-panel {
    margin-top: 16px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.section-head h3 {
    color: var(--text);
    font-size: 18px;
}

.section-percent {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    margin-left: 8px;
    border: 1px solid rgba(75, 212, 135, 0.38);
    border-radius: 999px;
    padding: 0 8px;
    background: rgba(75, 212, 135, 0.1);
    color: var(--green);
    font-size: 12px;
    font-weight: 900;
    vertical-align: middle;
}

.section-head span,
.pill {
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(112px, 1fr));
    gap: 10px;
}

.metric {
    min-height: 82px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    padding: 13px;
    background: #10151c;
}

.metric-value {
    margin-top: 6px;
}

.rarity-stack {
    display: grid;
    gap: 9px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
}

.rarity-row {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr) 48px;
    gap: 12px;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

.bar {
    height: 10px;
    border-radius: 999px;
    background: #090d12;
    overflow: hidden;
}

.bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
}

.tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
    margin-bottom: 12px;
}

.tab {
    height: 38px;
    border-radius: 8px;
    background: #10151c;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 850;
}

.tab.is-active {
    border-color: rgba(240, 198, 108, 0.8);
    background: rgba(240, 198, 108, 0.13);
    color: var(--text);
}

.leaderboard {
    display: grid;
    gap: 8px;
}

.board-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    min-height: 52px;
    padding: 10px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: #10151c;
}

.board-rank {
    color: var(--gold);
    font-weight: 950;
}

.board-value {
    color: var(--text);
    font-weight: 950;
}

.collection-panel {
    margin-top: 16px;
    scroll-margin-top: 92px;
}

.pokedex-panel {
    scroll-margin-top: 92px;
}

.collection-tools {
    grid-template-columns: minmax(220px, 1fr) auto 140px 96px;
    align-items: center;
    position: relative;
    z-index: 5;
}

.catalog-tools {
    grid-template-columns: minmax(220px, 1fr) auto 140px;
}

.native-select {
    display: none !important;
}

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-button {
    width: 100%;
    height: 42px;
    border-radius: 8px;
    padding: 0 12px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.custom-select-button::after {
    content: "";
    float: right;
    width: 8px;
    height: 8px;
    margin-top: 15px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
}

.custom-select-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 50;
    display: grid;
    max-height: 260px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px;
    background: #0f141b;
    box-shadow: var(--shadow);
}

.custom-select-option {
    min-height: 36px;
    border: 0;
    border-radius: 6px;
    padding: 0 10px;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    text-align: left;
}

.custom-select-option:hover {
    background: var(--surface-2);
    color: var(--text);
}

.collection-count {
    min-width: 132px;
    text-align: right;
}

.toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 10px;
    background: #0f141b;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 800;
}

.toggle input {
    width: 15px;
    height: 15px;
    accent-color: var(--green);
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 12px;
}

.creature-card {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-height: 98px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    padding: 13px;
    background: #10151c;
}

.creature-card:hover {
    border-color: var(--line);
    background: var(--surface);
}

.creature-mark {
    width: 50px;
    height: 50px;
    border-radius: 8px;
}

.creature-name {
    color: var(--text);
    font-weight: 950;
}

.creature-sub {
    margin-top: 2px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
}

.chip {
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    padding: 4px 8px;
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 850;
}

.chip-success {
    border-color: rgba(75, 212, 135, 0.45);
    background: rgba(75, 212, 135, 0.12);
    color: var(--green);
}

.chip-muted {
    border-color: rgba(168, 179, 194, 0.28);
    background: rgba(168, 179, 194, 0.08);
    color: var(--muted);
}

.creature-card.is-missing {
    opacity: 0.68;
}

.scroll-top-button {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 80;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 8px;
    border-color: var(--line);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-size: 22px;
    font-weight: 950;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.scroll-top-button.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.scroll-top-button:hover {
    background: var(--surface-3);
}

.rarity-mitico { color: var(--violet); }
.rarity-legendario { color: var(--gold); }
.rarity-epico { color: var(--red); }
.rarity-raro { color: var(--cyan); }
.rarity-comun { color: var(--green); }

.fill-mitico { background: var(--violet); }
.fill-legendario { background: var(--gold); }
.fill-epico { background: var(--red); }
.fill-raro { background: var(--cyan); }
.fill-comun { background: var(--green); }

@media (max-width: 1180px) {
    .shell {
        grid-template-columns: 300px minmax(0, 1fr);
    }

    .overview-grid {
        grid-template-columns: repeat(3, minmax(130px, 1fr));
    }

    .profile-panel,
    .home-hero,
    .home-compact-grid,
    .home-wide-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .home-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(130px, 1fr));
    }
}

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 12px 16px;
    }

    .topnav {
        width: 100%;
        justify-content: stretch;
    }

    .nav-button {
        flex: 1 1 auto;
    }

    .shell {
        display: block;
    }

    .sidebar {
        position: relative;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line-soft);
    }

    .user-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        height: auto;
        max-height: 380px;
    }

    .content {
        padding: 16px;
    }

    .overview-grid,
    .metric-grid,
    .tabs,
    .search-row {
        grid-template-columns: 1fr 1fr;
    }

    .profile-main {
        align-items: flex-start;
    }

    .profile-avatar {
        width: 66px;
        height: 66px;
        font-size: 24px;
    }

    .profile-head h2 {
        font-size: 26px;
    }

    .home-hero h2 {
        font-size: 30px;
    }

    .home-grid,
    .home-compact-grid,
    .featured-grid {
        grid-template-columns: 1fr;
    }

    .collection-tools {
        grid-template-columns: 1fr 130px 92px;
    }
}

@media (max-width: 500px) {
    .overview-grid,
    .metric-grid,
    .collection-tools,
    .tabs,
    .search-row {
        grid-template-columns: 1fr;
    }

    .profile-main {
        display: grid;
    }

    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .home-hero-stats,
    .featured-stats {
        grid-template-columns: 1fr;
    }

    .collection-count {
        min-width: 0;
        text-align: left;
    }

    .rarity-row {
        grid-template-columns: 88px minmax(0, 1fr) 38px;
    }
}
