/* Tournament Leaderboard Specific Styles */

/* Basic page adjustments */
body {
    /* Let styles.css handle base body styles */
    display: flex;       /* Use flexbox for overall layout */
    flex-direction: column;
    height: 100vh;       /* Full viewport height */
    overflow: hidden;    /* Prevent body scroll */
}

.leaderboard-page-container {
    /* Override base .container max-width */
    width: 100%; 
    max-width: none; /* Remove max-width constraint */
    /* Set padding to control side margins */
    padding-left: 5%;
    padding-right: 5%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent this container scrolling */
    padding-bottom: 0; /* Override default container padding */
    box-sizing: border-box; /* Ensure padding is included in width */
}

/* Header styling */
.leaderboard-header {
    /* Inherit base .header styles */
    flex-shrink: 0; /* Prevent header shrinking */
    padding: 10px 0 0 0; /* Remove side padding, container handles it */
    margin-bottom: 10px;
    text-align: center; /* Center header text */
}

.leaderboard-header h1 {
    /* Inherit base .header h1 styles */
    font-size: 20px; /* Slightly smaller */
    padding: 0;
    margin-bottom: 5px;
}

.leaderboard-header p {
    font-size: 12px;
    color: var(--tg-theme-hint-color);
    margin: 0;
    font-family: inherit; /* Use base body font */
}

/* Leaderboard container - takes remaining space and scrolls */
.leaderboard-container {
    flex: 1; /* Take remaining vertical space */
    min-height: 0; /* Necessary for flex item to shrink */
    background: var(--tg-theme-secondary-bg-color, rgba(0, 0, 0, 0.85)); /* Ensure darker bg */
    border-radius: 12px;
    border: 1px solid rgba(var(--tg-theme-link-color-rgb, 51, 144, 236), 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Hide internal overflow initially */
    margin-bottom: 15px; /* Space before back button */
    width: 100%; /* Take full width within the padded container */
}

/* Sticky Header Row */
.leaderboard-header-row {
    display: grid;
    grid-template-columns: 50px 1fr 80px; /* Rank | Player | Score */
    gap: 10px;
    padding: 10px 15px;
    background: rgba(var(--tg-theme-link-color-rgb, 51, 144, 236), 0.15);
    font-size: 11px;
    color: var(--tg-theme-link-color, #3390ec);
    position: sticky; /* Keep header visible */
    top: 0;
    z-index: 1;
    flex-shrink: 0;
}

.header-rank { text-align: center; }
.header-player { /* Default left align */ }
.header-score { text-align: right; }

/* Scrollable Entries Area */
#leaderboardEntries {
    flex: 1; /* Take remaining space */
    overflow-y: auto; /* Enable vertical scrolling ONLY here */
    padding: 0 15px 15px 15px;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Individual Leaderboard Entry */
.leaderboard-entry {
    display: grid;
    grid-template-columns: 50px 1fr 80px; /* Match header */
    gap: 10px;
    padding: 12px 0; /* Vertical padding only */
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    align-items: center;
}

.leaderboard-entry:last-child {
    border-bottom: none;
}

.rank {
    font-size: 12px;
    text-align: center;
    color: white;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden; /* Prevent long names overflowing */
}

.player-avatar-container {
    width: 30px;
    height: 30px;
    margin-right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
}

.player-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

/* Styles for Initials Avatar Fallback */
.initials-avatar {
    display: inline-flex; /* Use flex to center text */
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    /* Inherits width, height, border-radius from .player-avatar */
}

/* Added style for the text span inside the avatar div */
.initials-avatar-text {
    line-height: 1; /* Ensure text is vertically centered */
}

.player-name {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: white;
}

.score {
    font-size: 12px;
    text-align: right;
    color: #32ff32; /* Score color */
}

/* Highlight current user */
.current-user {
    background: rgba(var(--tg-theme-link-color-rgb, 51, 144, 236), 0.1);
    border-radius: 4px;
}

.current-user .player-name {
    font-weight: bold;
}

/* Top 3 Rank Styling */
.leaderboard-entry:nth-child(1) .rank { color: gold; }
.leaderboard-entry:nth-child(2) .rank { color: silver; }
.leaderboard-entry:nth-child(3) .rank { color: #cd7f32; } /* Bronze */

.leaderboard-entry:nth-child(-n+3) .rank::after {
    content: ' 🏆';
    font-size: 10px;
    vertical-align: middle;
    margin-left: 2px;
}

/* Back button container */
.back-button-container {
    flex-shrink: 0; /* Prevent shrinking */
    padding: 10px 0 20px 0; /* Adjust padding */
    text-align: center;
    margin-top: 0; /* Remove default margin */
}

/* Back button inherits from .button.secondary */
.back-button {
    /* Styles inherited */
}

/* --- Wallet Info Modal --- */
.wallet-info-modal {
    /* Base modal styles */
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 15, 25, 0.85); /* Dark overlay */
    backdrop-filter: blur(8px) saturate(110%);
    -webkit-backdrop-filter: blur(8px) saturate(110%);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Make modal visible */
.wallet-info-modal.visible {
    display: flex;
    opacity: 1;
}

.wallet-modal-content {
    /* Inherits base message-modal-content styles (adjust if needed) */
    background: linear-gradient(155deg, #2a3040, #1f2430);
    border-radius: 10px;
    padding: 25px 30px 30px 30px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 215, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s ease-out;
}

/* Animate content when modal is visible */
.wallet-info-modal.visible .wallet-modal-content {
    transform: scale(1);
    opacity: 1;
}

.wallet-modal-username {
    font-size: 16px;
    font-weight: bold;
    color: var(--tg-theme-link-color, #3390ec);
    margin-bottom: 15px;
    word-break: break-all;
}

.wallet-address-container {
    margin-bottom: 20px;
    background-color: rgba(0, 0, 0, 0.15);
    padding: 10px 12px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.wallet-modal-address {
    /* Inherits base code styles from styles.css */
    display: block;
    font-size: 12px;
    color: var(--tg-theme-text-color, #ffffff);
    word-break: break-all;
    line-height: 1.5;
    background: none; /* Override default code bg */
    padding: 0; /* Override default code padding */
}

.wallet-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Inherit button styles from message-modal or define specific ones */
.wallet-modal-copy-btn,
.message-player-btn {
    /* Style as primary action buttons */
}

/* Ensure admin usernames are clickable */
.player-name[onclick] {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: var(--tg-theme-link-color, #3390ec);
} 