:root {
    /* Simplified Color Palette */
    --bg-main: #0f172a;
    --card-bg: #1e293b;
    --border: #334155;
    --gold: #f59e0b;
    --primary: #3b82f6;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --font-sans: 'Inter', system-ui, sans-serif;
}

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

body {
    background: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.35; /* Reduced from 1.5 */
    padding: 0.5rem; /* Reduced from 1rem */
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

/* Header - Simple & Clean */
header {
    text-align: center;
    margin-bottom: 0.5rem; /* Reduced from 1.5rem */
}

h1 {
    font-size: 1.75rem; /* Reduced from 2rem */
    color: #ffffff;
    margin-bottom: 0.1rem; /* Reduced */
}

.subtitle {
    color: var(--text-muted);
}

/* Search Box - Flat Design */
.search-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background: var(--card-bg);
    padding: 6px; /* Reduced from 8px */
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 0.5rem; /* Added slight gap below search */
}

.input-wrapper {
    display: flex;
    flex: 1;
    align-items: center;
    min-width: 250px;
}

.selected-clans {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem; /* Reduced from 0.5rem */
    margin-left: 0.5rem;
}

.clan-pill {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.clan-pill-remove {
    cursor: pointer;
    font-weight: bold;
    opacity: 0.7;
}

.clan-pill-remove:hover {
    opacity: 1;
}

input[type="text"] {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    padding: 6px 10px; /* Reduced top/bottom padding */
    font-size: 1rem;
    outline: none;
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px; /* Reduced from 10px 20px */
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.primary-btn:hover {
    filter: brightness(1.1);
}

/* Clan Header & Stats Grid */
.clan-header {
    padding: 0.5rem 0.75rem; /* Reduced from 0.75rem 1rem */
    border-radius: 8px;
}

.clan-title h2 {
    font-size: 1.2rem; /* Reduced from 1.3rem */
    margin-bottom: 0.15rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem; /* Reduced from 0.75rem */
    margin: 0.25rem 0; /* Reduced from 0.5rem 0 */
}

.stat-card {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.15rem 0.5rem; /* Reduced from 0.25rem 0.75rem */
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.7rem; /* Slightly smaller */
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-value {
    font-size: 1rem; /* Reduced from 1.1rem */
    font-weight: bold;
}

/* Overriding default browser margins on the injected h3 */
.members-section h3 {
    font-size: 1rem;
    margin: 0.25rem 0; /* Replaces the huge default 1em top/bottom margin */
}

/* Table - Minimalist */
.table-container {
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: rgba(0, 0, 0, 0.2);
    text-align: left;
    padding: 4px 8px; /* Reduced from 5px 10px */
    font-size: 0.8rem;
    color: var(--text-muted);
}

td {
    padding: 3px 8px; /* Reduced from 5px 10px */
    border-top: 1px solid var(--border);
    font-size: 0.9rem; /* Ensures text doesn't feel cramped despite low padding */
}

/* Cursor for clickable header */
.clan-header-clickable {
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.clan-header-clickable:hover {
    background: rgba(255, 255, 255, 0.05);
}

.clan-result {
    margin-bottom: 0.5rem; /* Reduced from 0.75rem */
}

.expand-indicator {
    text-align: center;
    font-size: 0.7rem; /* Reduced from 0.75rem */
    margin-top: 0.25rem; /* Reduced from 0.5rem */
    padding-top: 0.15rem; /* Reduced from 0.25rem */
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    opacity: 0.7;
}

.clan-header-clickable:hover .expand-indicator {
    opacity: 1;
}

/* Utility */
.hidden {
    display: none;
}

.gold-text {
    color: var(--gold);
}

.success-text {
    color: #10b981;
    font-weight: bold;
}

.error-text {
    color: #ef4444;
    font-weight: bold;
}

.neutral-text {
    color: var(--text-muted);
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

th.sortable:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Simple Mobile Fix */
@media (max-width: 600px) {
    .search-box {
        flex-direction: column;
    }

    h1 {
        font-size: 1.5rem; /* Reduced mobile size too */
    }
}
