/* ── BLACK HEADER ── */
.black-header {
    width: 100%;
    height: 100px;
    background-color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0; left: 0;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}
.header-content {
    width: 100%;
    max-width: 1400px;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 40px;
    box-sizing: border-box;
}
.center-logo { position: relative; height: 58px; }
.center-logo img { height: 58px; width: auto; cursor: pointer; transition: transform 0.2s ease; }
.black-header, .header-content, .center-logo, .center-logo img {
    user-select: none; -webkit-user-select: none;
}

/* ── BODY ── */
body {
    font-family: Arial, sans-serif;
    background: url("https://i.postimg.cc/0yZsTQcy/matteblack.png") no-repeat top center fixed;
    background-size: cover;
    margin: 0; padding: 0; padding-top: 90px; /* reduced from 100px – everything closer to header */
    animation: fade-in 1s ease-in;
    min-height: 100vh;
}

/* ── MAIN CONTAINER ── */
.friends-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 20px 60px;
    max-width: 700px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* ── TABS ── */
.tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 24px;
    background: rgba(255,255,255,0.07);
    border-radius: 30px;
    padding: 6px;
    width: 100%;
    box-sizing: border-box;
}
.tab-btn {
    padding: 12px 10px;
    border: none;
    border-radius: 24px;
    background: transparent;
    color: rgba(255,255,255,0.6);
    font-weight: bold;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    white-space: nowrap;
}
.tab-btn:hover { background: rgba(255,255,255,0.1); color: white; }
.tab-btn.active { background: white; color: black; box-shadow: 0 2px 10px rgba(0,0,0,0.2); }

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    margin-left: 6px;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

/* ── TAB PANELS ── */
.tab-panel { width: 100%; }
.tab-panel.hidden { display: none; }

/* ── SEARCH BAR ── */
.search-bar-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
}
.search-bar-wrapper input {
    flex: 1;
    padding: 14px 18px;
    border-radius: 25px;
    border: none;
    font-size: 15px;
    outline: none;
    background: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    box-sizing: border-box;
}
.search-bar-wrapper button {
    padding: 14px 28px;
    border-radius: 25px;
    border: none;
    background: black;
    color: white;
    font-weight: bold;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}
.search-bar-wrapper button:hover { background: #333; }

/* ── USER LIST ── */
.user-list { display: flex; flex-direction: column; gap: 12px; width: 100%; }

/* ── USER CARD ── */
.user-card {
    background: white;
    border-radius: 16px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 20px rgba(255,255,255,0.08);
    animation: fade-in 0.3s ease;
    box-sizing: border-box;
}
.user-card-avatar {
    width: 54px; height: 54px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #f0f0f0;
    flex-shrink: 0;
    background: #eee;
}
.user-card-info { flex: 1; min-width: 0; }
.user-card-name {
    font-size: 16px; font-weight: bold; color: #1c1e21;
    margin: 0 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-card-bio { font-size: 13px; color: #65676B; margin: 0 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card-meta { font-size: 12px; color: #aaa; margin: 0; }

/* ── ACTION BUTTONS ── */
.user-card-actions {
    display: flex; gap: 8px; flex-shrink: 0;
    flex-wrap: wrap; justify-content: flex-end;
}

/* Message Button — Messenger blue */
.btn-message {
    padding: 8px 14px;
    border-radius: 20px;
    border: none;
    background: #0084ff;
    color: white;
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-message:hover {
    background: #0073e6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,132,255,0.3);
}

.btn-challenge {
    padding: 8px 14px;
    border-radius: 20px;
    border: none;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.btn-challenge:hover {
    background: linear-gradient(135deg, #0f3460 0%, #533483 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn-add {
    padding: 8px 18px; border-radius: 20px; border: none;
    background: black; color: white; font-weight: bold; font-size: 13px;
    cursor: pointer; transition: background 0.2s; white-space: nowrap;
}
.btn-add:hover { background: #333; }

.btn-pending {
    padding: 8px 18px; border-radius: 20px; border: 2px solid #ccc;
    background: transparent; color: #999; font-weight: bold; font-size: 13px;
    cursor: default; white-space: nowrap;
}
.btn-friends-label {
    padding: 8px 18px; border-radius: 20px; border: 2px solid #1c1e21;
    background: transparent; color: #1c1e21; font-weight: bold; font-size: 13px;
    white-space: nowrap; cursor: default;
}
.btn-accept {
    padding: 8px 16px; border-radius: 20px; border: none;
    background: black; color: white; font-weight: bold; font-size: 13px;
    cursor: pointer; transition: background 0.2s; white-space: nowrap;
}
.btn-accept:hover { background: #333; }

.btn-decline, .btn-remove {
    padding: 8px 14px;
    border-radius: 20px;
    border: 2px solid #ddd;
    background: transparent;
    color: #999;
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-decline:hover, .btn-remove:hover { border-color: #e74c3c; color: #e74c3c; }

/* ── STATES ── */
.loading-msg, .empty-msg, .error-msg {
    text-align: center; padding: 40px 20px;
    color: rgba(255,255,255,0.5); font-size: 15px;
}
.error-msg { color: #e74c3c; }

/* ── TOAST ── */
.toast {
    position: fixed; bottom: 30px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1c1e21; color: white;
    padding: 14px 28px; border-radius: 30px;
    font-size: 14px; font-weight: bold;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    opacity: 0; transition: all 0.3s ease;
    z-index: 9999; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: #c0392b; }

/* ─────────────────────────────────────────────────
   ── CHALLENGE MODAL ──
   Three-step flow: Bet → Game → Waiting
   ───────────────────────────────────────────────── */
#challengeModal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 20px;
    box-sizing: border-box;
}
#challengeModal.hidden { display: none; }

.chl-card {
    background: #0d1117;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 22px;
    padding: 28px 26px 24px;
    width: min(420px, 100%);
    box-shadow: 0 24px 80px rgba(0,0,0,0.8);
    position: relative;
    color: white;
    box-sizing: border-box;
}

.chl-close {
    position: absolute;
    top: 16px; right: 16px;
    background: rgba(255,255,255,0.08);
    border: none;
    color: rgba(255,255,255,0.55);
    font-size: 18px;
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}
.chl-close:hover { background: rgba(255,255,255,0.15); color: white; }

.chl-title {
    font-size: 18px;
    font-weight: 800;
    margin: 0 0 4px;
    color: white;
}
.chl-subtitle {
    font-size: 13px;
    color: rgba(255,255,255,0.45);
    margin: 0 0 22px;
}

/* ── Step: hidden ── */
.chl-step.hidden { display: none; }

/* ── Bet Step ── */
.chl-stakes {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}
.chl-stake-btn {
    padding: 16px 6px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    white-space: nowrap;
}
.chl-stake-btn:hover { border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.1); }
.chl-stake-btn.active {
    border-color: #4dffb5;
    background: rgba(77,255,181,0.1);
    color: #4dffb5;
    box-shadow: 0 0 0 2px rgba(77,255,181,0.2);
}
.chl-stake-label { display: block; font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.4); margin-top: 4px; }

.chl-next-btn {
    width: 100%;
    padding: 15px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(180deg, #60b6ff 0%, #2b6cff 55%, #1e4ed8 100%);
    color: white;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    transition: filter 0.15s, transform 0.1s;
    box-shadow: 0 10px 28px rgba(37,99,235,0.45);
}
.chl-next-btn:hover:not(:disabled) { filter: brightness(1.08); }
.chl-next-btn:active:not(:disabled) { transform: scale(0.98); }
.chl-next-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: rgba(255,255,255,0.12);
    box-shadow: none;
}

/* ── Custom Stake Input ── */
#chlCustomAmount {
    width: 100%;
    padding: 14px 18px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.07);
    color: white;
    font-size: 15px;
    font-weight: 700;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s;
}
#chlCustomAmount:focus {
    border-color: #4dffb5;
}
#chlCustomAmount::placeholder {
    color: rgba(255,255,255,0.25);
    font-weight: 400;
}
/* Remove browser number input arrows */
#chlCustomAmount::-webkit-outer-spin-button,
#chlCustomAmount::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#chlCustomAmount[type=number] { -moz-appearance: textfield; }

/* ── Back Button ── */
.chl-back-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.15s;
}
.chl-back-btn:hover { color: rgba(255,255,255,0.8); }

/* ── Game Step ── */
.chl-game-list { display: flex; flex-direction: column; gap: 10px; }
.chl-game-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.04);
    color: white;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    width: 100%;
}
.chl-game-btn:hover {
    border-color: rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.09);
    transform: translateY(-1px);
}
.chl-game-emoji { font-size: 28px; flex-shrink: 0; }
.chl-game-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.chl-game-info strong { font-size: 15px; font-weight: 800; }
.chl-game-info small { font-size: 12px; color: rgba(255,255,255,0.4); }
.chl-game-arrow { font-size: 22px; color: rgba(255,255,255,0.3); flex-shrink: 0; }

/* ── Waiting Step ── */
.chl-waiting {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0 6px;
    gap: 14px;
    text-align: center;
}

/* Animated Spinner */
.chl-spinner {
    width: 48px; height: 48px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #4dffb5;
    border-radius: 50%;
    animation: chl-spin 0.75s linear infinite;
}
@keyframes chl-spin { to { transform: rotate(360deg); } }

#chlWaitMsg {
    font-size: 18px;
    font-weight: 800;
    color: white;
    margin: 0;
}
#chlWaitSub {
    font-size: 13px;
    color: rgba(255,255,255,0.45);
    margin: 0;
}

.chl-cancel-link {
    background: none;
    border: none;
    color: rgba(255,255,255,0.3);
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
    margin-top: 4px;
    transition: color 0.15s;
}
.chl-cancel-link:hover { color: rgba(255,255,255,0.6); }

/* ── Hide "Cancel challenge" after decline or expiry ── */
.chl-waiting.terminal .chl-cancel-link {
    display: none;
}

/* Optional: slight padding adjustment to balance visual space when button is hidden */
.chl-waiting.terminal {
    padding-bottom: 24px;
}

/* ─────────────────────────────────────────────────
   ANIMATIONS & MOBILE
   ───────────────────────────────────────────────── */
@keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } }

@media screen and (max-width: 800px) {
    body { padding-top: 90px; }

    .black-header { height: 90px; }

    .header-content { padding: 0 20px; }

    .center-logo { height: 48px; }

    .center-logo img { height: 48px; }

    .friends-container { padding: 30px 12px 60px; }

    .tab-btn { font-size: 13px; padding: 10px 6px; flex: 0 0 calc(33.333% - 7px); box-sizing: border-box; overflow: hidden; }

    .user-card {
        padding: 14px 14px;
        gap: 12px;
        flex-wrap: wrap;
    }
    .user-card-avatar { width: 46px; height: 46px; }
    .user-card-name { font-size: 15px; }

    .user-card-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: -25px;
    }

    .btn-message { font-size: 12px; padding: 7px 11px; }
    .btn-challenge { font-size: 12px; padding: 7px 11px; }

    .search-bar-wrapper input { padding: 12px 14px; font-size: 14px; }
    .search-bar-wrapper button { padding: 12px 18px; font-size: 14px; }

    .chl-card { padding: 22px 18px 20px; border-radius: 18px; }
    .chl-stakes {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
    .chl-stake-btn { padding: 14px 6px; font-size: 13px; }
    .chl-stake-label { font-size: 10px; }

    /* ── Friends list now 4px lower on mobile only ── */
    .tab-panel {
        margin-top: 4px !important;
    }
    .user-list {
        margin-top: 4px !important;
    }

    /* ── iOS fix: force grey border on "Remove" button after canceling confirmation ── */
    .btn-remove.force-reset,
    .btn-remove.force-reset:hover,
    .btn-remove.force-reset:active,
    .btn-remove.force-reset:focus,
    .btn-remove.force-reset:focus-visible {
        border-color: #ddd !important;
        background: transparent !important;
        color: #999 !important;
        box-shadow: none !important;
        outline: none !important;
        transition: none !important;
        pointer-events: none !important; /* temporarily disable interaction */
    }
    .btn-remove.force-reset {
        animation: none !important;
    }
}
