/* ============================================================
   Leaderboard – Self-hosted stylesheet
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
    --color-page-bg:       #1A233A;
    --color-card-bg:       #272e48;
    --color-input-bg:      #1A233A;
    --color-border:        rgba(255, 255, 255, 0.1);
    --color-border-subtle: rgba(255, 255, 255, 0.05);
    --color-text:          #ffffff;
    --color-text-90:       rgba(255, 255, 255, 0.9);
    --color-text-80:       rgba(255, 255, 255, 0.8);
    --color-text-70:       rgba(255, 255, 255, 0.7);
    --color-text-60:       rgba(255, 255, 255, 0.6);
    --color-text-50:       rgba(255, 255, 255, 0.5);
    --color-text-40:       rgba(255, 255, 255, 0.4);
    --color-submit:        #5A8DEE;
    --color-submit-hover:  #3775ea;
    --color-grad-start:    #fa0002;
    --color-grad-end:      #790000;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    background-color: var(--color-page-bg);
    color: var(--color-text);
    font-family: var(--font);
    line-height: 1.5;
    min-height: 100vh;
}
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
a { text-decoration: none; color: inherit; }
input { font: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ---------- Utility ---------- */
.hidden { display: none !important; }

/* ---------- Page shell ---------- */
.page { min-height: 100vh; display: flex; flex-direction: column; }

.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ---------- Centered view (landing / loading / error) ---------- */
.center-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    text-align: center;
    padding: 3rem 1rem;
    gap: 1.125rem;
}

/* ---------- Landing page ---------- */
.landing-title {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 800;
    color: var(--color-text);
    line-height: 1.2;
}

.landing-subtitle {
    color: var(--color-text-70);
    font-size: 1rem;
    max-width: 420px;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 500px;
    margin-top: 0.25rem;
}

.search-input {
    flex: 1;
    padding: 0.625rem 0.875rem;
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 0.875rem;
    transition: border-color 0.15s;
}
.search-input::placeholder { color: var(--color-text-40); }
.search-input:focus { outline: none; border-color: var(--color-submit); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.btn-primary {
    background-color: var(--color-submit);
    color: #fff;
}
.btn-primary:hover { background-color: var(--color-submit-hover); }

.btn-outline {
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--color-text);
}
.btn-outline:hover { background-color: rgba(255, 255, 255, 0.08); }

/* ---------- Loading ---------- */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-submit);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text { color: var(--color-text-60); font-size: 0.9375rem; }

/* ---------- Error ---------- */
.error-icon  { font-size: 3rem; line-height: 1; }
.error-title { font-size: 1.375rem; font-weight: 700; }
.error-desc  { color: var(--color-text-60); max-width: 400px; font-size: 0.9375rem; }

/* ---------- Guild header ---------- */
.guild-header {
    text-align: center;
    padding: 2.75rem 0 2rem;
}

.guild-icon {
    width: 7rem;
    height: 7rem;
    border-radius: 50%;
    border: 3px solid var(--color-border);
    margin: 0 auto 1.25rem;
    object-fit: cover;
}

.guild-name {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 800;
    color: var(--color-text);
    margin-bottom: 0.375rem;
    word-break: break-word;
}

.guild-subtitle {
    font-size: 1.125rem;
    color: var(--color-text-80);
}

.guild-subtitle .accent {
    background-image: linear-gradient(to right, var(--color-grad-start), var(--color-grad-end));
    background-size: 100% 3px;
    background-repeat: no-repeat;
    background-position: 0 100%;
    padding-bottom: 2px;
}

/* ---------- Tabs ---------- */
.tabs-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding-bottom: 2px; /* prevent clipping scroll shadow */
    -webkit-overflow-scrolling: touch;
}

.tabs {
    display: inline-flex;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-70);
    background: var(--color-card-bg);
    transition: background-color 0.15s, color 0.15s;
    white-space: nowrap;
}
.tab:hover:not(.active) { color: var(--color-text); }
.tab.active {
    background-color: var(--color-submit);
    color: #fff;
}

/* ---------- Tab panels ---------- */
.tab-panel { padding-bottom: 3rem; }

/* ---------- Card ---------- */
.card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-body { padding: 1.25rem 1.5rem; }

/* ---------- Leaderboard table (desktop only) ---------- */
.lb-table-wrap {
    display: none;
    overflow-x: auto;
}

.lb-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-80);
    border-bottom: 1px solid var(--color-border);
}
.lb-table th.col-rank  { width: 68px; text-align: center; }
.lb-table th.col-right { text-align: right; }

.lb-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--color-border-subtle);
    font-size: 0.875rem;
    color: var(--color-text-70);
    vertical-align: middle;
}
.lb-table td.col-rank  { text-align: center; }
.lb-table td.col-right { text-align: right; }
.lb-table tbody tr:last-child td { border-bottom: none; }
.lb-table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }

/* ---------- Rank badge (table) ---------- */
.rank-badge-img { width: 40px; height: 40px; display: inline-block; }
.rank-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    font-weight: 700;
    font-size: 0.9375rem;
    color: var(--color-text-70);
}

/* ---------- User cell ---------- */
.user-cell {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}
.user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
}

/* ---------- XP progress bar ---------- */
.xp-wrap { min-width: 180px; }

.xp-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.375rem;
    gap: 0.5rem;
}
.xp-level {
    font-size: 0.75rem;
    color: var(--color-text-60);
}
.xp-level strong { color: var(--color-text); font-weight: 600; }
.xp-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
}

.xp-bar {
    width: 100%;
    height: 6px;
    border-radius: 9999px;
    background: var(--color-input-bg);
    overflow: hidden;
}
.xp-bar-fill {
    height: 100%;
    border-radius: 9999px;
    background: linear-gradient(to right, var(--color-grad-start), var(--color-grad-end));
}

/* ---------- Balance ---------- */
.balance {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

/* ---------- Mobile leaderboard cards ---------- */
.lb-cards-wrap { display: block; padding: 1rem; }

.lb-card {
    background: var(--color-input-bg);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    padding: 0.875rem;
    margin-bottom: 0.5rem;
}
.lb-card:last-child { margin-bottom: 0; }

.lb-card-top {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.75rem;
}
.lb-card-top.no-meta { margin-bottom: 0; }

.lb-card-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.lb-card-value { flex-shrink: 0; }

.lb-card-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.lb-meta-item { display: flex; flex-direction: column; gap: 2px; }
.lb-meta-label { font-size: 0.6875rem; color: var(--color-text-50); }
.lb-meta-value { font-size: 0.8125rem; color: var(--color-text-90); font-weight: 500; }

/* Mobile rank number (smaller than table version) */
.rank-num-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--color-text-70);
    flex-shrink: 0;
}
.rank-badge-img-sm { width: 32px; height: 32px; flex-shrink: 0; }

/* ---------- Responsive: show table at lg (1024px) ---------- */
@media (min-width: 1024px) {
    .lb-table-wrap  { display: block; }
    .lb-cards-wrap  { display: none; }
}

/* ---------- Fishing cards grid ---------- */
.fishing-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}
@media (min-width: 640px)  { .fishing-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .fishing-grid { grid-template-columns: 1fr 1fr 1fr; } }

/* ---------- Fishing card ---------- */
.fishing-card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.fishing-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}
.fishing-card-icon  { font-size: 1.25rem; line-height: 1; flex-shrink: 0; }
.fishing-card-title { font-size: 1rem; font-weight: 600; color: var(--color-text); }

.fishing-card-body {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ---------- Fishing entry row ---------- */
.fishing-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-input-bg);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem;
    transition: background 0.12s;
}
.fishing-entry:hover { background: rgba(255, 255, 255, 0.04); }

.fishing-entry-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.fishing-rank {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    flex-shrink: 0;
}
.fishing-rank-1 { background: rgba(234, 179, 8, 0.2);  color: #eab308; }
.fishing-rank-2 { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }
.fishing-rank-3 { background: rgba(180, 83, 9, 0.2);   color: #f59e0b; }
.fishing-rank-n { background: rgba(255, 255, 255, 0.05); color: var(--color-text-60); }

.fishing-entry-avatar {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.fishing-entry-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fishing-entry-value {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
    flex-shrink: 0;
    margin-left: 0.5rem;
}

/* ---------- Empty state ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 1rem;
    text-align: center;
    gap: 0.5rem;
}
.empty-state-icon  { font-size: 3rem; opacity: 0.35; line-height: 1; }
.empty-state-title { font-size: 1rem; font-weight: 600; color: var(--color-text-80); }
.empty-state-desc  { font-size: 0.875rem; color: var(--color-text-60); max-width: 320px; }

.empty-inline {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.75rem 0;
    gap: 0.375rem;
    text-align: center;
}
.empty-inline-icon { font-size: 2rem; opacity: 0.3; line-height: 1; }
.empty-inline-text { font-size: 0.8125rem; color: var(--color-text-60); }
