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

:root {
    --bg-deep: #0a0a12;
    --bg-primary: #0f0f1a;
    --bg-panel: #1a1a2e;
    --bg-panel-dark: #12121f;
    --bg-slot: #252536;
    --bg-slot-hover: #2d2d42;
    --stone-dark: #2a2833;
    --stone-mid: #3d3a4a;
    --stone-light: #4a4658;
    --stone-highlight: #5a5670;
    --gold-dark: #8b6914;
    --gold-primary: #c9a227;
    --gold-light: #f4d03f;
    --gold-pale: #ffeaa7;
    --gold-glow: rgba(201, 162, 39, 0.4);
    --text-parchment: #f5e6c8;
    --text-cream: #e8dcc8;
    --text-faded: #a08c5b;
    --text-dim: #6b6b7b;
    --eth-purple: #8b5cf6;
    --success: #4ade80;
    --danger: #ef4444;
    --tier-7: #c9a227;
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition-fast: 0.2s ease;
}

/* ========== Base ========== */

* {
    box-sizing: border-box;
}

body {
    background: var(--bg-deep);
    color: var(--text-parchment);
    font-family: 'Cinzel', serif;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
}

button,
input,
a {
    touch-action: manipulation;
}

.hidden {
    display: none;
}

/* ========== Fireflies ========== */

.fireflies-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.firefly {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    animation: fireflyFloat 6s ease-in-out infinite;
    opacity: 0;
}

.firefly.gold {
    background: var(--gold-light);
    box-shadow: 0 0 6px var(--gold-light), 0 0 12px var(--gold-glow);
}

.firefly.blue {
    background: #7eb8da;
    box-shadow: 0 0 6px #7eb8da, 0 0 12px rgba(126, 184, 218, 0.4);
}

@keyframes fireflyFloat {
    0%, 100% { opacity: 0; transform: translate(0, 0); }
    20% { opacity: 0.8; }
    50% { opacity: 1; transform: translate(var(--dx), var(--dy)); }
    80% { opacity: 0.6; }
}

/* ========== Layout ========== */

.leaderboard-container {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-xl);
    position: relative;
    z-index: 1;
}

/* ========== Header ========== */

.lb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--gold-dark);
    margin-bottom: var(--space-md);
    position: relative;
}

/* Decorative gold fade under header */
.lb-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
}

.lb-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: 28px;
    color: var(--gold-light);
    text-shadow: 0 0 20px var(--gold-glow);
    margin: 0;
    letter-spacing: 2px;
}

.lb-back-btn {
    background: linear-gradient(180deg, var(--stone-mid) 0%, var(--stone-dark) 100%);
    border: 1px solid var(--gold-primary);
    color: var(--gold-primary);
    padding: var(--space-sm) var(--space-md);
    font-family: 'Cinzel', serif;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
}

.lb-back-btn:hover {
    background: rgba(201, 162, 39, 0.15);
    border-color: var(--gold-light);
    box-shadow: 0 0 12px var(--gold-glow);
    color: var(--gold-light);
}

/* ========== Your Position ========== */

.user-position {
    margin-bottom: var(--space-md);
}

.user-position-label {
    font-family: 'Cinzel', serif;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: var(--text-faded);
    margin-bottom: var(--space-sm);
}

.user-position-card {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    background: linear-gradient(135deg, rgba(201, 162, 39, 0.08) 0%, rgba(201, 162, 39, 0.18) 50%, rgba(201, 162, 39, 0.08) 100%);
    border: 1px solid var(--gold-primary);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    box-shadow: 0 0 20px rgba(201, 162, 39, 0.12), inset 0 0 30px rgba(201, 162, 39, 0.04);
}

.user-position-rank {
    font-family: 'Cinzel Decorative', serif;
    font-size: 32px;
    font-weight: 700;
    color: var(--gold-light);
    text-shadow: 0 0 16px var(--gold-glow);
    min-width: 60px;
    text-align: center;
}

.user-position-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}

.user-position-score {
    font-family: 'Cinzel', serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--gold-light);
}

.user-position-creature {
    font-size: 12px;
    color: var(--text-faded);
    text-transform: capitalize;
    letter-spacing: 0.5px;
}

.user-position-wallet {
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    color: var(--text-cream);
    cursor: pointer;
    transition: color var(--transition-fast);
    margin-left: auto;
}

.user-position-wallet:hover {
    color: var(--gold-primary);
}

.user-position-message {
    font-style: italic;
    font-size: 13px;
    color: var(--text-cream);
    opacity: 0.85;
    margin-left: var(--space-md);
    flex-shrink: 1;
    min-width: 0;
}

/* ========== Search ========== */

.lb-search {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.lb-search-input {
    flex: 1;
    background: var(--bg-panel-dark);
    border: 1px solid var(--stone-mid);
    color: var(--text-parchment);
    padding: 10px var(--space-md);
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.lb-search-input:focus {
    border-color: var(--gold-primary);
    box-shadow: 0 0 8px rgba(201, 162, 39, 0.15);
}

.lb-search-input::placeholder {
    color: var(--text-dim);
}

.lb-search-btn {
    background: linear-gradient(180deg, var(--stone-mid) 0%, var(--stone-dark) 100%);
    border: 1px solid var(--gold-primary);
    color: var(--gold-primary);
    padding: 10px 20px;
    font-family: 'Cinzel', serif;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
}

.lb-search-btn:hover {
    background: rgba(201, 162, 39, 0.15);
    border-color: var(--gold-light);
    box-shadow: 0 0 12px var(--gold-glow);
    color: var(--gold-light);
}

/* ========== Search Result Card ========== */

.search-result {
    background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-panel-dark) 100%);
    border: 1px solid var(--gold-primary);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: 0 0 25px rgba(201, 162, 39, 0.15);
}

.search-result-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.search-result-rank {
    font-family: 'Cinzel Decorative', serif;
    font-size: 22px;
    color: var(--gold-light);
    font-weight: 700;
    text-shadow: 0 0 12px var(--gold-glow);
}

.search-result-score {
    font-size: 15px;
    color: var(--text-parchment);
}

.search-result-creature {
    text-transform: capitalize;
    color: var(--text-faded);
    font-size: 13px;
}

.search-result-wallet {
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-cream);
    transition: color var(--transition-fast);
}

.search-result-wallet:hover {
    color: var(--gold-primary);
}

.search-result-message {
    font-style: italic;
    color: var(--text-faded);
    font-size: 13px;
}

.search-not-found {
    text-align: center;
    color: var(--text-dim);
    padding: var(--space-md);
    font-style: italic;
}

/* ========== Table ========== */

.lb-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--stone-dark);
    border-radius: var(--radius-md);
    -webkit-overflow-scrolling: touch;
}

.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

/* Header row */
.lb-table thead th {
    background: rgba(18, 18, 31, 0.7);
    color: var(--text-faded);
    font-family: 'Cinzel', serif;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    padding: 14px var(--space-md);
    text-align: left;
    border-bottom: 2px solid var(--gold-dark);
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Data rows */
.lb-table tbody tr {
    border-bottom: 1px solid rgba(42, 40, 51, 0.6);
    transition: background var(--transition-fast);
}

/* Alternating row tint */
.lb-table tbody tr:nth-child(even) {
    background: rgba(26, 26, 46, 0.15);
}

.lb-table tbody tr:hover {
    background: rgba(45, 45, 66, 0.5);
}

.lb-table tbody td {
    padding: 12px var(--space-md);
    vertical-align: middle;
}

/* ========== Column-specific styles ========== */

.col-rank {
    width: 55px;
    text-align: center;
    font-weight: 700;
    font-family: 'Cinzel', serif;
    font-size: 14px;
    color: var(--text-faded);
}

/* Rank numbers 4+ get a subtle style */
td.col-rank {
    color: var(--text-faded);
}

.col-score {
    width: 80px;
    text-align: center;
    font-family: 'Cinzel Decorative', serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--gold-light);
    text-shadow: 0 0 6px rgba(244, 208, 63, 0.2);
}

.col-creature {
    width: 110px;
    text-transform: capitalize;
    color: var(--text-faded);
    font-size: 13px;
    letter-spacing: 0.5px;
}

.col-wallet {
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.col-wallet:hover {
    color: var(--gold-primary);
}

.col-message {
    font-style: italic;
    color: var(--text-cream);
    max-width: 180px;
    font-size: 13px;
    opacity: 0.85;
}

/* ========== Wallet display ========== */

.ens-name {
    color: var(--gold-light);
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 600;
}

.addr-suffix {
    color: var(--text-dim);
    font-family: 'Fira Code', monospace;
    font-size: 10px;
    margin-left: 6px;
}

/* ========== Own-row highlight ========== */

.own-row {
    background: rgba(201, 162, 39, 0.1) !important;
    border-left: 3px solid var(--gold-primary) !important;
    box-shadow: inset 0 0 30px rgba(201, 162, 39, 0.06);
}

.own-row:hover {
    background: rgba(201, 162, 39, 0.15) !important;
}

.own-row td.col-rank {
    color: var(--gold-light);
    text-shadow: 0 0 8px var(--gold-glow);
}

.own-row td.col-score {
    text-shadow: 0 0 12px rgba(244, 208, 63, 0.4);
}


/* ========== Footer ========== */

.lb-footer {
    text-align: center;
    padding: var(--space-md) 0;
    color: var(--text-dim);
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

/* ========== Toast ========== */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background: var(--bg-panel);
    border: 1px solid var(--gold-primary);
    color: var(--text-parchment);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    font-family: 'Cinzel', serif;
    font-size: 12px;
    margin-top: var(--space-sm);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
    box-shadow: 0 0 10px var(--gold-glow);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ========== Loading state ========== */

.lb-loading {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-dim);
    font-size: 14px;
}

/* ========== Empty state ========== */

.lb-empty {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-dim);
    font-style: italic;
}

@media (max-width: 900px) {
    .leaderboard-container {
        padding: var(--space-md);
    }

    .lb-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-sm);
    }

    .lb-title {
        font-size: 24px;
        text-align: center;
    }

    .lb-back-btn {
        min-height: 42px;
        font-size: 12px;
        letter-spacing: 1.2px;
        text-align: center;
    }

    .user-position-card {
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .user-position-wallet,
    .user-position-message {
        margin-left: 0;
        width: 100%;
    }

    .lb-search {
        flex-direction: column;
    }

    .lb-search-input {
        font-size: 16px;
        min-height: 44px;
    }

    .lb-search-btn {
        min-height: 44px;
        font-size: 12px;
    }

    .lb-table {
        min-width: 680px;
    }

    .toast-container {
        right: 12px;
        left: 12px;
        bottom: 12px;
    }

    .toast {
        margin-top: 0;
        margin-bottom: var(--space-sm);
    }
}

@media (max-width: 560px) {
    .leaderboard-container {
        padding: 12px 10px;
    }

    .lb-title {
        font-size: 20px;
        letter-spacing: 1px;
    }

    .search-result,
    .user-position-card {
        padding: var(--space-md);
    }

    .lb-table {
        min-width: 620px;
    }

    .lb-table thead th,
    .lb-table tbody td {
        padding-left: 10px;
        padding-right: 10px;
    }
}
