* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================
   CONTAINER LAYOUT
   ============================================ */

.container {
    display: flex;
    gap: 5px;
    padding: 10px;
    margin: 0 auto;
}

.main {
    flex: 3;
    order: 1;
    min-width: 0;
}

.sidebar {
    flex: 1;
    max-width: 300px;
    min-width: 125px;
    order: 2;
    flex-shrink: 0;
}

.main h2 {
    font-family: "Lobster", cursive;
    font-size: clamp(2rem, 2.5vw, 2.6rem);
    font-weight: normal;
    color: black;
    margin-bottom: 10px;
}


/* ============================================
   FRIEND CARDS GRID — MAX 2 PER ROW
   ============================================ */

.friends-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;  /* ← EXACTLY 2 columns */
    gap: 10px;
    margin-top: 5px;
}

/* Individual Friend Card */
.friend-card {
    display: flex;
    border: 2px solid #3b5998;
    border-radius: 2px;
    background: #e9ebee;
    overflow: hidden;
    text-decoration: none;
    color: #1d1f23;
    transition: background 0.2s ease, transform 0.15s ease;
    cursor: pointer;
    min-width: 0;
}

.friend-card:hover {
    background: #dce0e6;
    transform: scale(1.01);
    border-color: #2f4a7a;
}

.friend-card:active {
    transform: scale(0.98);
}

/* Image container — ALWAYS SQUARE */
.friend-card-image {
    flex: 0 0 30%;
    aspect-ratio: 1 / 1;          /* ← Always square */
    overflow: hidden;
    background: #d1d5da;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    max-width: 120px;
}

.friend-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.friend-card-image div {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #3b5998;
    color: white;
    font-size: clamp(0.5rem, 1.2vw, 1.5em);
    font-weight: bold;
    font-family: Verdana, sans-serif;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    text-align: center;
}

/* Info Section */
.friend-card-info {
    flex: 1;
    padding: 0.3em 0.6em;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    overflow: hidden;
    min-width: 0;
}

.friend-card-info .friend-name {
    font-weight: bold;
    color: #3b5998;
    font-size: clamp(0.7rem, 1vw + 0.15rem, 1rem);
    font-family: Verdana, sans-serif;
    margin-bottom: 1px;
    word-break: break-word;
    line-height: 1.2;
}

.friend-card-info .friend-stat {
    color: #1d1f23;
    font-size: clamp(0.5rem, 0.7vw + 0.1rem, 0.7rem);
    line-height: 1.2;
    word-break: break-word;
}

/* ============================================
   SEARCH HIGHLIGHT
   ============================================ */

.search-highlight {
    background: #FFFF00;
    color: #000;
    padding: 0 2px;
    border-radius: 2px;
}

.search-counter {
    color: #999;
    font-size: 0.65em;
    margin-left: 4px;
    white-space: nowrap;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 700px) {
    .container {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .main {
        flex: 1 1 60%;
    }
    
    .sidebar {
        flex: 1 1 30%;
        max-width: 100%;
        min-width: 100px;
    }
}

@media (max-width: 600px) {
    .friends-cards-grid {
        grid-template-columns: 1fr;  /* ← Stack to 1 column on phones */
    }
    
    .friend-card-image {
        flex: 0 0 25%;
        min-width: 40px;
        max-width: 80px;
    }
    
    .friend-card-info {
        padding: 0.2em 0.4em;
    }
    
    .friend-card-info .friend-name {
        font-size: clamp(0.6rem, 0.8vw + 0.1rem, 0.8rem);
    }
    
    .friend-card-info .friend-stat {
        font-size: clamp(0.45rem, 0.6vw + 0.08rem, 0.6rem);
    }
}

@media (max-width: 500px) {
    .main {
        flex: 1 1 55%;
    }
    
    .sidebar {
        flex: 1 1 35%;
        min-width: 80px;
    }
    
    .filter-row {
        gap: 4px;
    }
    
    .filter-btn {
        padding: 3px 8px;
        font-size: 11px;
    }
}