/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(6px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}
.modal-overlay.visible { display: flex; }
.modal-box {
    background: rgba(10,10,30,0.95);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    padding: 24px;
    color: #e0e0e0;
    min-width: 600px;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-box h2 { font-size: 16px; margin-bottom: 14px; color: #fff; }
.modal-close {
    float: right;
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
    margin: 0;
    flex: none;
}
.modal-close:hover { color: #fff; }

/* ─── Leaderboard Modal ─── */
.lb-modal { min-width: 680px; max-width: 860px; padding: 28px 32px; }
.lb-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 18px; margin-bottom: 20px; color: #fff; font-weight: 700;
}
.lb-title svg { color: #4a9eff; }

/* Podium - top 3 cards */
.lb-podium {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.lb-podium:empty { display: none; }
.lb-podium-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 16px 14px 14px;
    position: relative;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.lb-podium-card:hover {
    background: rgba(255,255,255,0.06);
    transform: translateY(-2px);
}
.lb-podium-card.gold {
    border-color: rgba(255, 204, 0, 0.35);
    background: rgba(255, 204, 0, 0.06);
    box-shadow: 0 0 20px rgba(255, 204, 0, 0.08), inset 0 1px 0 rgba(255, 204, 0, 0.15);
    order: 0;
}
.lb-podium-card.gold:hover { background: rgba(255, 204, 0, 0.1); }
.lb-podium-card.silver {
    border-color: rgba(192, 192, 192, 0.25);
    background: rgba(192, 192, 192, 0.04);
    box-shadow: 0 0 15px rgba(192, 192, 192, 0.05), inset 0 1px 0 rgba(192, 192, 192, 0.1);
    order: -1;
}
.lb-podium-card.silver:hover { background: rgba(192, 192, 192, 0.08); }
.lb-podium-card.bronze {
    border-color: rgba(205, 127, 50, 0.25);
    background: rgba(205, 127, 50, 0.04);
    box-shadow: 0 0 15px rgba(205, 127, 50, 0.05), inset 0 1px 0 rgba(205, 127, 50, 0.1);
    order: 1;
}
.lb-podium-card.bronze:hover { background: rgba(205, 127, 50, 0.08); }

.lb-trophy {
    font-size: 28px;
    margin-bottom: 6px;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}
.lb-podium-rank {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
    opacity: 0.6;
}
.lb-podium-name {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.lb-podium-score {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
}
.gold .lb-podium-score { color: #ffcc00; }
.silver .lb-podium-score { color: #d0d0d0; }
.bronze .lb-podium-score { color: #cd9a5c; }

.lb-podium-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    width: 100%;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.lb-podium-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}
.lb-podium-stat-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #555;
}
.lb-podium-stat-val {
    font-size: 11px;
    color: #bbb;
    font-weight: 500;
}

/* ─── Settings Modal ─── */
.settings-modal {
    min-width: 0;
    max-width: 900px;
    width: calc(100vw - 48px);
    max-height: calc(100vh - 48px);
    overflow: hidden;
    padding: 28px 32px;
}
.settings-layout {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 28px;
}
@media (max-width: 700px) {
    .settings-layout { grid-template-columns: 1fr; }
    .settings-modal { padding: 20px; }
}
.settings-col {
    display: flex;
    flex-direction: column;
}
.settings-group {
    margin-bottom: 16px;
}
.settings-label {
    display: block;
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
}
.settings-select {
    width: 100%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: #e0e0e0;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}
.settings-select option {
    background: #1a1a2e;
    color: #e0e0e0;
}

/* Table for rank 4+ */
.lb-table-wrap { margin-bottom: 8px; }
.score-table { width: 100%; border-collapse: separate; border-spacing: 0 3px; font-size: 12px; }
.score-table th {
    text-align: left; color: #555; text-transform: uppercase;
    font-size: 9px; letter-spacing: 1.2px; font-weight: 600;
    padding: 8px 10px 6px;
}
.score-table td {
    padding: 10px 10px;
    background: rgba(255,255,255,0.025);
    border: none;
    transition: background 0.15s;
}
.score-table td:first-child { border-radius: 8px 0 0 8px; }
.score-table td:last-child { border-radius: 0 8px 8px 0; }
.score-table tr:hover td { background: rgba(74, 158, 255, 0.06); }
.score-table .rank {
    color: #4a9eff; font-weight: 700; font-size: 13px;
    min-width: 32px; text-align: center;
}
.score-table .player-name { font-weight: 500; color: #e0e0e0; }
.score-table .score-val { color: #ffcc00; font-weight: 600; }

/* ─── Collection Modal ─── */
.collection-modal {
    max-width: 820px;
    max-height: 80vh;
    overflow-y: auto;
}
.collection-title {
    font-size: 16px;
    margin-bottom: 16px;
    color: #fff;
    font-weight: 700;
}
.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    padding: 4px;
}
.collection-tile {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}
.collection-tile:hover {
    transform: scale(1.05);
    box-shadow: 0 0 18px rgba(74, 158, 255, 0.2);
    border-color: rgba(74, 158, 255, 0.3);
}
.collection-tile-thumb {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.collection-tile-spinner {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 24px; height: 24px;
    border: 2px solid rgba(255,255,255,0.15);
    border-top-color: #4a9eff;
    border-radius: 50%;
    animation: collection-spin 0.8s linear infinite;
}
@keyframes collection-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}
.collection-tile-level {
    position: absolute;
    top: 6px; right: 6px;
    background: rgba(0,0,0,0.65);
    color: #4a9eff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    letter-spacing: 0.3px;
    pointer-events: none;
}
.collection-tile-bar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    padding: 20px 8px 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.collection-tile-name {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.collection-tile-rename {
    flex: none;
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
}
.collection-tile-rename:hover {
    color: #fff;
    background: rgba(255,255,255,0.12);
}
.collection-empty {
    text-align: center;
    color: #555;
    padding: 40px 20px;
    font-size: 13px;
}

/* Empty state */
.lb-empty {
    text-align: center; color: #555; padding: 40px 20px;
    font-size: 13px; display: none;
}

/* Pagination */
.lb-pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; margin-top: 16px; padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.lb-page-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #aaa; cursor: pointer;
    transition: all 0.15s;
}
.lb-page-btn:hover:not(:disabled) { background: rgba(74,158,255,0.15); border-color: rgba(74,158,255,0.3); color: #fff; }
.lb-page-btn:disabled { opacity: 0.3; cursor: default; }
.lb-page-info { font-size: 11px; color: #666; font-weight: 500; min-width: 80px; text-align: center; }

/* ─── Profile Modal ─── */
.profile-modal {
    min-width: 0;
    max-width: 1100px;
    width: calc(100vw - 48px);
    max-height: calc(100vh - 48px);
    overflow: hidden;
    padding: 28px 32px;
}
.profile-layout {
    display: grid;
    grid-template-columns: 200px 1fr 240px;
    gap: 28px;
    min-height: 0;
}
@media (max-width: 900px) {
    .profile-layout { grid-template-columns: 1fr; }
    .profile-modal { padding: 20px; }
}
.profile-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}
.profile-avatar-wrap {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 8px;
}
.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(74,158,255,0.3);
    display: none;
}
.profile-avatar.loaded { display: block; }
.profile-avatar-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(74,158,255,0.12);
    border: 3px solid rgba(74,158,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    color: #4a9eff;
    font-weight: 700;
    text-transform: uppercase;
}
.profile-avatar.loaded + .profile-avatar-placeholder { display: none; }
.profile-avatar-edit {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(10,10,30,0.9);
    border: 1px solid rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #aaa;
    transition: all 0.15s;
}
.profile-avatar-edit:hover { color: #fff; border-color: #4a9eff; background: rgba(74,158,255,0.2); }
.profile-username {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    word-break: break-all;
}
.profile-rank {
    font-size: 12px;
    font-weight: 600;
    color: #4a9eff;
    background: rgba(74,158,255,0.1);
    padding: 3px 12px;
    border-radius: 12px;
    letter-spacing: 0.5px;
}
.profile-since {
    font-size: 10px;
    color: #666;
    margin-top: 4px;
}
.profile-center {
    min-width: 0;
}
.profile-section-label {
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    font-weight: 600;
}
.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.profile-stat-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    padding: 12px 10px;
    text-align: center;
}
.profile-stat-value {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
}
.profile-stat-label {
    font-size: 9px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}
.profile-bridge-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 160px;
    overflow-y: auto;
}
.profile-bridge-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    color: #ccc;
    transition: background 0.15s;
}
.profile-bridge-item:hover {
    background: rgba(74,158,255,0.08);
}
.profile-right {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.profile-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.profile-field-label {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.profile-input {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    color: #e0e0e0;
    padding: 7px 10px;
    font-size: 12px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.profile-input:focus { border-color: rgba(74,158,255,0.5); }
.profile-input::placeholder { color: #444; }
.profile-btn {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.15s;
    letter-spacing: 0.3px;
    margin-top: 4px;
}
.profile-btn-save {
    background: #4a9eff;
    color: #fff;
}
.profile-btn-save:hover { background: #3a8eef; }
.profile-btn-secondary {
    background: rgba(255,255,255,0.08);
    color: #ccc;
}
.profile-btn-secondary:hover { background: rgba(255,255,255,0.15); color: #fff; }
.profile-btn-danger-outline {
    background: rgba(255,100,50,0.1);
    border: 1px solid rgba(255,100,50,0.25);
    color: #ff6432;
}
.profile-btn-danger-outline:hover { background: rgba(255,100,50,0.2); }
.profile-btn-danger {
    background: rgba(255,68,68,0.15);
    border: 1px solid rgba(255,68,68,0.3);
    color: #ff4444;
}
.profile-btn-danger:hover { background: rgba(255,68,68,0.25); }
.profile-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 10px 0;
}
