/* Halaman Leaderboard (leaderboard.html). Senada dengan play.css / about.css.
   Selector diawali .lb-body supaya tidak bentrok dengan asset/main.css & css/caturid.css. */
body.lb-body {
    background: radial-gradient(ellipse at top, #363636 0%, #1e1e1e 70%) !important;
    color: #e8e8e8;
    margin: 0;
}
.lb-body .hidden { display: none !important; }
.lb-body .muted { color: #9a9a9a; font-size: 13px; }

.lb-page {
    --gold: #f5c342;
    --silver: #c9d1d9;
    --bronze: #d08a4f;
    --green: #2e7d32;
    --green-l: #66bb6a;
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 16px 40px;
    box-sizing: border-box;
}

.lb-body .eyebrow {
    display: inline-block;
    font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--green-l);
}

/* ---------- Kepala halaman ---------- */
.lb-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.lb-head h1 { margin: 4px 0 4px; font-size: clamp(28px, 4vw, 38px); line-height: 1.15; color: #f2f2f2; }
.lb-head p { margin: 0; color: #a8a8a8; }

.lb-body .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: #444; color: #e8e8e8; border: 1px solid #555; border-radius: 6px;
    padding: 9px 14px; font-size: 13px; font-weight: 600;
    cursor: pointer; text-decoration: none; transition: background 0.15s;
}
.lb-body .btn:hover:not(:disabled) { background: #505050; }
.lb-body .btn:disabled { opacity: 0.55; cursor: default; }
.lb-body .btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.lb-body .btn-primary:hover { background: #388e3c; }
.lb-body .btn .spin { display: inline-block; }
.lb-body .btn.loading .spin { animation: lb-spin 0.8s linear infinite; }
@keyframes lb-spin { to { transform: rotate(360deg); } }

/* ---------- Kartu "Peringkat Anda" ---------- */
.me-card {
    position: relative; overflow: hidden;
    display: grid; grid-template-columns: auto 56px minmax(0, 1fr) auto; gap: 16px; align-items: center;
    padding: 20px 24px; margin-bottom: 28px;
    background: linear-gradient(135deg, rgba(46, 125, 50, 0.28) 0%, #2b2b2b 60%);
    border: 1px solid rgba(102, 187, 106, 0.4);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.me-card .me-rank { text-align: center; min-width: 84px; }
.me-card .me-rank small { display: block; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: #b5d8b6; }
.me-card .me-rank strong { display: block; font-size: 34px; line-height: 1.1; font-family: ui-monospace, monospace; color: #fff; }
.me-card img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 2px solid var(--green-l); background: #333; }
.me-card .me-name { font-size: 18px; font-weight: 700; color: #fff; text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-card .me-name:hover { text-decoration: underline; }
.me-card .me-meta { font-size: 13px; color: #b5b5b5; margin-top: 2px; }
.me-card .me-progress { height: 6px; background: #1f1d1b; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.me-card .me-progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--green-l)); border-radius: 999px; transition: width 0.6s ease; }
.me-card .me-rating { text-align: right; }
.me-card .me-rating small { display: block; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: #9a9a9a; }
.me-card .me-rating strong { font-size: 28px; font-family: ui-monospace, monospace; color: #38bdf8; }
.me-card .me-actions { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

.me-card.guest { grid-template-columns: minmax(0, 1fr) auto; background: #2b2b2b; border-color: #444; }
.me-card.guest h3 { margin: 0 0 4px; font-size: 17px; color: #f2f2f2; }
.me-card.guest p { margin: 0; color: #a8a8a8; font-size: 14px; }

/* ---------- Podium ---------- */
.podium {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px;
    align-items: end; margin-bottom: 28px;
}
.podium-card {
    --c: var(--silver);
    position: relative;
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
    padding: 22px 14px 18px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--c) 14%, #2b2b2b) 0%, #2b2b2b 70%);
    border: 1px solid color-mix(in srgb, var(--c) 45%, #444);
    border-radius: 12px;
    color: #e8e8e8; text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
}
.podium-card:hover { transform: translateY(-4px); box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45); }
.podium-card.p1 { --c: var(--gold); padding-top: 34px; padding-bottom: 26px; box-shadow: 0 0 40px rgba(245, 195, 66, 0.12); }
.podium-card.p2 { --c: var(--silver); }
.podium-card.p3 { --c: var(--bronze); }
.podium-card .medal {
    position: absolute; top: -14px;
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--c); color: #1e1e1e; font-weight: 800; font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.podium-card img {
    width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
    border: 3px solid var(--c); background: #333; margin-bottom: 6px;
}
.podium-card.p1 img { width: 84px; height: 84px; }
.podium-card .crown { font-size: 22px; line-height: 1; margin-bottom: -2px; }
.podium-card .pd-name { font-weight: 700; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-card .pd-city { font-size: 12px; color: #9a9a9a; min-height: 1em; }
.podium-card .pd-rating { font-family: ui-monospace, monospace; font-size: 22px; font-weight: 700; color: var(--c); }
.podium-card.is-me { outline: 2px solid var(--green-l); outline-offset: 2px; }

/* ---------- Daftar ---------- */
.lb-list-card { background: #2b2b2b; border: 1px solid #444; border-radius: 12px; overflow: hidden; }
.lb-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid #3a3a3a; flex-wrap: wrap; }
.lb-toolbar h2 { margin: 0; font-size: 16px; color: #f2f2f2; }
.lb-search {
    flex: 0 1 240px; min-width: 0;
    background: #1f1d1b; color: #e8e8e8; border: 1px solid #444; border-radius: 6px;
    padding: 8px 12px; font-size: 14px;
}
.lb-search:focus { outline: none; border-color: var(--green); }

.lb-cols, .lb-row {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) minmax(0, 180px) 80px;
    gap: 12px; align-items: center;
    padding: 0 16px;
}
.lb-cols { padding-top: 10px; padding-bottom: 10px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #888; border-bottom: 1px solid #3a3a3a; }
.lb-cols span:last-child, .lb-row .r-rating { text-align: right; }

.lb-row {
    min-height: 56px;
    color: #e8e8e8; text-decoration: none;
    border-bottom: 1px solid #333;
    transition: background 0.15s;
    animation: lb-in 0.35s ease both;
}
.lb-row:last-child { border-bottom: none; }
.lb-row:hover, .lb-row:focus-visible { background: #333; outline: none; }
@keyframes lb-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.lb-row .r-rank { font-family: ui-monospace, monospace; font-weight: 700; color: #aaa; font-size: 15px; }
.lb-row .r-player { display: flex; align-items: center; gap: 12px; min-width: 0; }
.lb-row .r-player img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #444; flex-shrink: 0; }
.lb-row .r-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .r-city { display: block; font-size: 12px; color: #888; font-weight: 400; }
.lb-row .r-bar { height: 6px; background: #1f1d1b; border-radius: 999px; overflow: hidden; }
.lb-row .r-bar > span { display: block; height: 100%; background: linear-gradient(90deg, #1e5a8a, #38bdf8); border-radius: 999px; }
.lb-row .r-rating { font-family: ui-monospace, monospace; font-weight: 700; color: #38bdf8; font-size: 16px; }

.lb-row.is-me { background: rgba(46, 125, 50, 0.16); box-shadow: inset 3px 0 0 var(--green-l); }
.lb-row.is-me:hover { background: rgba(46, 125, 50, 0.24); }
.lb-body .you-badge {
    display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px;
    background: var(--green); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: 0.05em; vertical-align: middle;
}

/* Pemisah "..." + baris pemain sendiri bila di luar daftar */
.lb-gap { text-align: center; color: #666; letter-spacing: 0.3em; padding: 6px 0; border-bottom: 1px solid #333; }

.lb-empty { padding: 32px 16px; text-align: center; color: #888; }

/* Skeleton saat memuat */
.lb-skel { height: 56px; border-bottom: 1px solid #333; position: relative; overflow: hidden; }
.lb-skel::after {
    content: ''; position: absolute; inset: 14px 16px;
    border-radius: 6px;
    background: linear-gradient(90deg, #303030 0%, #3a3a3a 50%, #303030 100%);
    background-size: 200% 100%;
    animation: lb-shimmer 1.2s infinite linear;
}
@keyframes lb-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Responsif ---------- */
@media (max-width: 720px) {
    .lb-cols, .lb-row { grid-template-columns: 48px minmax(0, 1fr) 64px; }
    .lb-cols .c-bar, .lb-row .r-bar { display: none; }
    .me-card { grid-template-columns: auto 48px minmax(0, 1fr); padding: 16px; gap: 12px; }
    .me-card img { width: 48px; height: 48px; }
    .me-card .me-rank { min-width: 64px; }
    .me-card .me-rank strong { font-size: 26px; }
    .me-card .me-rating { grid-column: 1 / -1; text-align: left; display: flex; align-items: baseline; gap: 8px; }
    .me-card .me-rating strong { font-size: 22px; }
}
@media (max-width: 520px) {
    .lb-page { padding-top: 20px; }
    .podium { gap: 8px; }
    .podium-card { padding: 18px 6px 12px; }
    .podium-card.p1 { padding-top: 26px; padding-bottom: 18px; }
    .podium-card img { width: 48px; height: 48px; }
    .podium-card.p1 img { width: 62px; height: 62px; }
    .podium-card .pd-name { font-size: 13px; }
    .podium-card .pd-rating { font-size: 17px; }
    .lb-search { flex: 1 1 100%; }
}

/* ---------- Tab kategori ---------- */
.lb-tabs {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px;
    padding: 6px; margin-bottom: 24px;
    background: #2b2b2b; border: 1px solid #444; border-radius: 12px;
}
.lb-tab {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 10px 6px;
    background: transparent; color: #cfcfcf;
    border: 1px solid transparent; border-radius: 8px;
    font-size: 14px; font-weight: 700; cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.lb-tab small { font-size: 11px; font-weight: 400; color: #8a8a8a; }
.lb-tab:hover { background: #333; color: #fff; }
.lb-tab.active {
    background: linear-gradient(180deg, rgba(46, 125, 50, 0.35), rgba(46, 125, 50, 0.15));
    border-color: rgba(102, 187, 106, 0.5); color: #fff;
}
.lb-tab.active small { color: #b5d8b6; }
@media (max-width: 520px) {
    .lb-tab { font-size: 12px; padding: 8px 2px; }
    .lb-tab small { display: none; }
}
