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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    color: #333;
}

.container {
    max-width: 100%;
    margin: 0;
    padding: 0;
    background: white;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    text-align: center;
    padding: 8px 20px;
    background: #1a1a1a;
    color: white;
    flex-shrink: 0;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

/* Controls below map */
.controls-container {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 10px 20px;
    background: #fafafa;
    border-top: 1px solid #e0e0e0;
    flex-wrap: wrap;
    align-items: center;
    flex-shrink: 0;
}

.control-group {
    background: white;
    padding: 8px 14px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.control-group h3 {
    font-size: 0.7rem;
    margin-bottom: 4px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    padding: 8px 16px;
    background: #f0f0f0;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    background: #e0e0e0;
    border-color: #999;
}

.btn.active {
    background: #0066cc;
    color: white;
    border-color: #0066cc;
}

.toggle-group {
    display: flex;
    gap: 8px;
}

.toggle-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 6px 10px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.toggle-item:hover {
    background: #f5f5f5;
    border-color: #0066cc;
}

.toggle-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.toggle-item span {
    font-size: 0.85rem;
    user-select: none;
}

/* Map container - fill remaining viewport space */
#map-container {
    position: relative;
    overflow: hidden;
    background: white;
    width: 100%;
    flex: 1;
    min-height: 0;
}

#map {
    width: 100%;
    height: 100%;
    display: block;
    background: white;
}

svg {
    background: white;
}

.state,
.senate {
    stroke: #fff;
    stroke-width: 1.5px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.congressional {
    stroke: #ffffff;
    stroke-width: 0.8px;
    stroke-opacity: 0.9;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.state:hover,
.congressional:hover,
.senate:hover {
    opacity: 0.8;
    stroke: #333;
    stroke-width: 1.5px;
}

.tooltip {
    position: absolute;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 0.9rem;
    line-height: 1.6;
    max-width: 300px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.tooltip.visible {
    opacity: 1;
}

.tooltip strong {
    color: #fff;
    font-weight: 600;
}

/* Info cards - auto height, vertically centered, not full height */
.info-card {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
    max-height: calc(100% - 40px);
    background: white;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.25);
    padding: 0;
    z-index: 100;
    font-size: 0.9rem;
    line-height: 1.6;
    border-top: 5px solid #333;
    transition: opacity 0.3s ease, transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.info-card.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) translateX(10px);
}

.info-card-left { left: 20px; }
.info-card-right { right: 20px; }

.info-card.party-republican { border-top-color: #E8565C; }
.info-card.party-democrat { border-top-color: #005599; }
.info-card.party-independent { border-top-color: #FFA500; }
.info-card.party-vacant { border-top-color: #999; }

.info-card .card-close {
    position: absolute;
    top: 6px;
    right: 10px;
    background: rgba(0,0,0,0.4);
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #fff;
    line-height: 1;
    padding: 2px 8px;
    border-radius: 50%;
    z-index: 10;
}

.info-card .card-close:hover { background: rgba(0,0,0,0.7); }

.info-card .card-photo {
    width: 100%;
    height: auto;
    display: block;
    background: #e0e0e0;
    border-radius: 10px 10px 0 0;
}

.info-card .card-photo-placeholder {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e8e8e8;
    color: #999;
    font-size: 3rem;
    border-radius: 10px 10px 0 0;
}

.info-card .card-body {
    padding: 12px 16px 16px;
}

.info-card.party-republican .card-body,
.info-card.party-democrat .card-body,
.info-card.party-independent .card-body {
    color: white;
}

.info-card h3 {
    font-size: 1.05rem;
    margin-bottom: 2px;
    color: #1a1a1a;
    padding-right: 20px;
}

.info-card.party-republican h3,
.info-card.party-democrat h3,
.info-card.party-independent h3 {
    color: white;
}

.info-card .card-subtitle {
    font-size: 0.82rem;
    color: #666;
    margin-bottom: 10px;
}

.info-card.party-republican .card-subtitle,
.info-card.party-democrat .card-subtitle,
.info-card.party-independent .card-subtitle {
    color: rgba(255,255,255,0.75);
}

.info-card .detail-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid #f0f0f0;
}

.info-card.party-republican .detail-row,
.info-card.party-democrat .detail-row,
.info-card.party-independent .detail-row {
    border-bottom-color: rgba(255,255,255,0.2);
}

.info-card .detail-label {
    font-weight: 600;
    color: #555;
    font-size: 0.8rem;
}

.info-card.party-republican .detail-label,
.info-card.party-democrat .detail-label,
.info-card.party-independent .detail-label {
    color: rgba(255,255,255,0.8);
}

.info-card .detail-value {
    color: #1a1a1a;
    text-align: right;
    font-size: 0.8rem;
}

.info-card.party-republican .detail-value,
.info-card.party-democrat .detail-value,
.info-card.party-independent .detail-value {
    color: white;
}

.info-card .detail-value a {
    color: #0066cc;
    text-decoration: none;
}

.info-card .detail-value a:hover {
    text-decoration: underline;
}

.info-card .party-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 0.78rem;
}

.info-card .save-act-section {
    margin-top: 8px;
    padding: 8px 10px;
    background: #f8f8f8;
    border-radius: 6px;
    border-left: 3px solid #999;
}

.info-card .save-act-section.position-support {
    border-left-color: #28a745;
    background: #f0faf3;
}

.info-card .save-act-section.position-oppose {
    border-left-color: #dc3545;
    background: #fdf0f0;
}

.info-card .save-act-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    margin-bottom: 2px;
}

.info-card .save-act-position {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.info-card .save-act-citation {
    font-size: 0.72rem;
    color: #666;
    line-height: 1.4;
}

.info-card .save-act-citation a {
    color: #0066cc;
    text-decoration: none;
}

.info-card .save-act-citation a:hover {
    text-decoration: underline;
}

.info-card .contact-links {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.info-card .contact-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    font-size: 0.75rem;
    color: #333;
    text-decoration: none;
    transition: background 0.15s;
}

.info-card.party-republican .contact-link,
.info-card.party-democrat .contact-link,
.info-card.party-independent .contact-link {
    color: white;
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
}

.info-card .contact-link:hover {
    background: rgba(0,0,0,0.05);
}

.info-card.party-republican .contact-link:hover,
.info-card.party-democrat .contact-link:hover,
.info-card.party-independent .contact-link:hover {
    background: rgba(255,255,255,0.3);
}

/* Legend inline in controls */
.legend {
    background: white;
    padding: 8px 14px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.legend-title {
    font-size: 0.7rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legend-items {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 24px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid #ddd;
}

.legend-label {
    font-size: 0.82rem;
}

.party-republican {
    background-color: #E8565C !important;
}

.party-democrat {
    background-color: #005599 !important;
}

.party-independent {
    background-color: #FFA500;
}

.party-vacant {
    background-color: #cccccc;
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.4rem;
    }

    .controls-container {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }

    .toggle-group {
        flex-direction: column;
    }

    .info-card {
        width: 260px;
    }
}
