:root {
    --bg-color: #c4c8cd; /* Darker grey background */
    --card-bg: #ffffff;
    --text-main: #1a1a1a;
    --border-color: #e2e8f0;
    --header-bg: #0a2a23; /* New header background */
    --header-text: #e4ff4b; /* New header text color */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 1.5rem;
    color: var(--text-main);
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

.team-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Team Header Styling */
.team-header {
    display: flex;
    align-items: center;
    background: var(--header-bg);
    color: var(--header-text);
    padding: 10px 16px;
    gap: 12px;
}

.team-jersey {
    width: 35px;
    height: auto;
    object-fit: contain;
}

.team-info {
    flex-grow: 1;
    min-width: 0; /* This is the magic rule that lets truncation work in flexbox! */
}

.team-info h2 {
    margin: 0;
    font-size: 1.05rem;
    text-transform: uppercase;
    font-weight: 700;
	white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-code {
    font-size: 0.75rem;
    color: #a0aec0;
}

/* Rider List */
.rider-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.rider-row {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
    min-height: 32px;
}

.blank-row {
    background-color: #fafafa;
}

.rider-summary {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rider-bib {
    font-weight: 700;
    width: 25px;
    color: #000000; /* Bibs are now black */
    font-size: 0.95rem;
}

/* New Cropped Rider Thumbnail */
.rider-thumb {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top; /* Crops to the top half/face */
    border: 1px solid var(--border-color);
    background: #eee;
}

.rider-name {
    flex-grow: 1;
    font-weight: 600;
    font-size: 0.9rem;
}

.flag {
    width: 20px;
    border-radius: 2px;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 2px solid #0a2a23;
    color: #0a2a23;
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s ease;
}

.info-icon:hover {
    background-color: #0a2a23;
    color: #e4ff4b;
}

.team-ds {
    background: #f7fafc;
    padding: 8px 16px;
    font-size: 0.8rem;
    border-top: 1px solid var(--border-color);
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 450px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 15px; right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.modal-portrait {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top;
}

select#modalDropdown {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    font-size: 1rem;
}

.modal-body ul {
    padding-left: 20px;
    margin: 0;
    font-size: 0.9rem;
}

.modal-body li {
    margin-bottom: 6px;
}

.full-results-list {
    max-height: 300px;
    overflow-y: auto;
}
/* --- Modal Updates --- */
.modal-portrait.uncropped {
    object-fit: contain;
    border-radius: 4px;
    background: transparent;
    border: none;
    max-height: 80px;
    width: auto;
}

.modal-header-text h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px 0;
    font-size: 1.25rem;
}

.modal-flag {
    width: 24px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.modal-team-name {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Results Table Styling */
.results-table {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    max-height: 350px;
    overflow-y: auto;
}

.result-row {
    display: flex;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.result-row:last-child {
    border-bottom: none;
}

.result-row:nth-child(even) {
    background-color: #f8fafc;
}

.res-rnk {
    font-weight: 700;
    width: 50px;
    flex-shrink: 0;
    color: var(--header-bg);
}

.res-details {
    flex-grow: 1;
    font-size: 0.9rem;
}

.res-prefix {
    font-weight: 600;
    color: var(--accent);
}

.res-year {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.modal-footer {
    text-align: center;
    font-size: 0.75rem;
    color: #a0aec0;
    margin-top: 20px;
    border-top: 1px dashed var(--border-color);
    padding-top: 10px;
}