body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: #f4f4f9;
    color: #333;
}

header {
    background-color: #0056b3;
    color: white;
    padding: 1rem 0;
    text-align: center;
}

main {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

h2 {
    color: #0056b3;
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
    margin-top: 30px;
}

.loading {
    font-size: 1.2rem;
    color: #666;
    text-align: center;
    padding: 20px;
}

.error {
    color: #d9534f;
    background-color: #f2dede;
    border: 1px solid #ebccd1;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

#players-section {
    flex: 3;
    min-width: 300px;
}

.formation-row {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    /* Wrap on small screens */
}

.formation-row .character-card {
    flex: 1;
    min-width: 200px;
    /* Ensure cards don't get too squished */
    max-width: 300px;
}

#staff-section {
    flex: 1;
    min-width: 250px;
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.character-card {
    background: white;
    padding: 10px;
    /* Reduced padding */
    margin-bottom: 10px;
    /* Reduced margin */
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Header layout: Name + Attributes */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.card-header h4 {
    margin: 0;
    font-size: 0.95rem;
    /* Slightly smaller if needed */
    color: #444;
}

.element-select-inline {
    width: auto;
    padding: 2px;
    font-size: 0.9rem;
}

/* Remove old style */
/* .character-card h4 { ... } */
/* .element-selector { ... } */

.skill-slot {
    margin-bottom: 4px;
    /* Reduced spacing */
    display: flex;
    align-items: center;
}

.skill-slot label {
    display: inline-block;
    width: 30px;
    /* Reduced width since we use "1:", "2:" etc */
    font-size: 0.85em;
    color: #666;
    margin-right: 5px;
}

select {
    padding: 3px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 100%;
    /* Full width of container minus label */
    flex: 1;
    /* Let it grow */
    font-size: 0.9rem;
}

button {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #218838;
}

#output-area {
    margin-top: 20px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-increase {
    font-weight: bold;
    color: #007bff;
}


.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.player-result {
    background: #f9f9f9;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #eee;
}

.stat-list {
    list-style: none;
    padding: 0;
    margin: 5px 0 0 0;
}

.stat-list li {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    border-bottom: 1px dotted #e0e0e0;
    padding: 2px 0;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#modal-body .skill-slot {
    margin-bottom: 15px;
    /* More spacing in popup */
    display: block;
    /* Stack vertically in popup */
}

#modal-body .skill-slot label {
    display: block;
    /* Label on top or side */
    width: auto;
    margin-bottom: 5px;
    font-weight: bold;
}

#modal-body select {
    width: 100%;
}

#modal-done-btn {
    margin-top: 15px;
    width: 100%;
    background-color: #0056b3;
}

/* Tab Styles for Results Area */
.tabs-nav {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #ddd;
    padding-bottom: 0;
}

.tab-button {
    background: #e9ecef;
    color: #495057;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 10px 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-button:hover {
    background: #dee2e6;
}

.tab-button.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
    margin-bottom: -2px;
    /* Overlap the bottom border */
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#conditions-container-tab {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 10px;
}