/* Modal Styles */
#modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 100;
    transition: opacity 0.3s ease;
    padding: 1rem; /* Add padding for smaller screens */
}

.modal {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    box-shadow: 0 0 30px rgba(var(--ui-theme-primary-rgb), 0.3); /* Updated shadow */
    border: 2px solid var(--primary-color); /* Uses new --ui-theme-primary (Purple) */
    max-width: 600px; /* Increased max width slightly */
    width: 100%; /* Ensure it uses available width up to max */
    display: none; /* Initially hidden, controlled by JS */
    max-height: 90vh; /* Limit height to 90% of viewport height */
    overflow-y: auto; /* Add vertical scrollbar if content overflows */
}

.modal.visible {
    display: block;
}

.modal h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color); /* Uses new --ui-theme-primary (Purple) */
    text-shadow: 0 0 10px rgba(var(--ui-theme-primary-rgb), 0.7); /* Updated shadow */
    letter-spacing: 2px;
}

.modal h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--secondary-color); /* Uses new --ui-theme-secondary (Green/Teal) */
    letter-spacing: 1px;
}

.modal h3 {
    font-size: 1.3rem;
    margin: 1.5rem 0 1rem;
    color: var(--secondary-color); /* Uses new --ui-theme-secondary (Green/Teal) */
}

.modal h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    text-shadow: 1px 2px black;
}

.modal p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Seed Input Styles */
.seed-input-container {
    margin: 1rem 0 2rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.seed-input-container label {
    font-size: 1rem;
    color: var(--text-secondary);
}

.seed-input {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--secondary-color); /* Uses new --ui-theme-secondary (Green/Teal) */
    background-color: rgba(20, 20, 40, 0.5);
    color: var(--text-color);
    text-align: center;
    width: 150px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.seed-input:focus {
    outline: none;
    border-color: var(--primary-color); /* Uses new --ui-theme-primary (Purple) */
    box-shadow: 0 0 10px rgba(var(--ui-theme-primary-rgb), 0.5); /* Updated shadow */
}

/* General Modal Content */
.modal .modal-content {
    margin-bottom: 1.5rem; /* Space before buttons */
}

/* Shop Item Container */
.shop-items {
    display: flex;
    flex-wrap: wrap; /* Allow items to wrap */
    justify-content: center; /* Center items horizontally */
    gap: 1rem; /* Space between shop items */
    margin-top: 1rem;
}

/* Individual Shop Item Card */
.shop-item {
    background-color: rgba(20, 20, 40, 0.6);
    border: 1px solid var(--text-secondary); /* Changed from var(--secondary-color) to match JS intent */
    border-radius: var(--border-radius);
    padding: 1rem;
    width: calc(50% - 1rem); /* Approximately 2 items per row, accounting for gap */
    min-width: 200px; /* Minimum width for smaller screens */
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Push button to bottom */
    text-align: left; /* Align text left within card */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative; /* Added for indicators */
}

.shop-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(var(--ui-theme-secondary-rgb), 0.2); /* Updated shadow */
}

/* NEW: Shop Item Header for Name + Icon */
.shop-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.shop-item h4 {
    color: var(--text-color); /* Changed from var(--secondary-color) to match JS intent */
    margin: 0; /* Removed margin-bottom */
    font-size: 1.1rem; /* Slightly larger name */
    line-height: 1;
}

.shop-item-icon-container {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    /* Color is set inline by JS based on affinity, using 'currentColor' in SVG */
    opacity: 0.8; 
}

.shop-item p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    flex-grow: 1; /* Allow description to take up available space */
}

.shop-item .buy-item-btn {
    /* Use existing button styles but make specific adjustments if needed */
    width: 100%; /* Make button full width of card */
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    margin-top: auto; /* Ensure it stays at the bottom */
}

/* Trerk Modal Options */
.trerk-options {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap; /* Allow trerks to wrap too */
    margin: 1.5rem 0;
    gap: 1rem;
}

.trerk-option {
    flex: 1; /* Allow flex grow */
    min-width: 150px; /* Minimum width for trerk options */
    max-width: calc(33% - 1rem); /* Aim for 3 per row */
    padding: 1rem;
    /* Use a standard background/border and rely on indicators */
    background-color: rgba(20, 20, 40, 0.6);
    border: 2px solid var(--text-secondary); /* Default border color, matches JS intent */
    transition: all 0.2s ease;
    cursor: pointer;
    text-align: center; /* Center text in trerk option */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    position: relative; 
}

.trerk-option.rare-trerk-glow {
    /* Apply a distinct style for Rare trerks */
    border-color: var(--rare-glow-color, var(--ui-theme-accent));
    box-shadow: 0 0 10px 2px var(--rare-glow-color, var(--ui-theme-accent));
}

.trerk-option h4 {
    font-size: 1rem; /* Slightly smaller h4 */
    margin-bottom: 0.5rem;
    color: var(--text-color); /* Set text color default */
}

.trerk-option p {
    font-size: 0.8rem; /* Smaller description text */
    color: var(--text-secondary);
    line-height: 1.3;
}

.trerk-option:hover {
    background-color: rgba(var(--ui-theme-secondary-rgb), 0.1); 
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 5px 15px rgba(var(--ui-theme-secondary-rgb), 0.2); 
}

.trerk-option.selected {
     background-color: rgba(102, 255, 153, 0.25); 
     box-shadow: 0 0 15px rgba(102, 255, 153, 0.6); 
     transform: translateY(-2px) scale(1.01);
}

/* Active Trerk Management Styles */
.active-trerks-section {
    margin: 1rem 0;
}

.active-trerks-section h4 {
    color: var(--ui-theme-secondary);
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.trerk-management {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.trerk-card {
    background-color: rgba(20, 20, 40, 0.5);
    border: 2px solid var(--text-secondary);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    width: calc(50% - 0.5rem);
    min-width: 180px;
    max-width: 250px;
    position: relative;
    transition: all 0.2s ease;
}

.trerk-card.active-trerk {
    border-color: var(--ui-theme-primary);
    background-color: rgba(var(--ui-theme-primary-rgb), 0.1);
    box-shadow: 0 0 10px rgba(var(--ui-theme-primary-rgb), 0.3);
}

.trerk-card.inactive-trerk {
    opacity: 0.6;
    border-color: var(--disabled-color);
}

.trerk-card .trerk-name {
    font-weight: bold;
    font-size: 0.9rem;
    color: var(--text-color);
    margin: 0.5rem 0 0.25rem;
    text-align: center;
}

.trerk-card .trerk-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-align: center;
    line-height: 1.2;
}

.trerk-card .toggle-trerk-btn {
    width: 100%;
    padding: 0.4rem;
    font-size: 0.75rem;
    margin: 0;
}

/* Divider */
.modal-divider {
    border: none;
    height: 1px;
    background-color: rgba(255, 255, 255, 0.1);
    margin: 2rem 0;
}

/* NEW: Stage Affinity Indicators */
.affinity-indicators {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 10;
}

.affinity-dot {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 6px rgba(0,0,0,0.6);
}

/* Specific affinity color classes (no inline styles needed) */
.affinity-dot.affinity-primary {
    background-color: var(--stage-slingapult-color); /* ACCENT_PRIMARY */
    box-shadow: 0 0 8px rgba(var(--stage-slingapult-rgb), 0.9);
}

.affinity-dot.affinity-secondary {
    background-color: var(--stage-sorcerarcher-color); /* ACCENT_SECONDARY */
    box-shadow: 0 0 8px rgba(var(--stage-sorcerarcher-rgb), 0.9);
}

.affinity-dot.affinity-tertiary {
    background-color: var(--stage-samurocket-color); /* ACCENT_TERTIARY */
    box-shadow: 0 0 8px rgba(var(--stage-samurocket-rgb), 0.9);
}

.affinity-dot.affinity-text-secondary {
    background-color: #cccccc; /* TEXT_SECONDARY / general */
    box-shadow: 0 0 6px rgba(204, 204, 204, 0.6);
}

/* Trerk effect lines — use affinity classes rather than inline styles */
.trerk-effects-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

/* Generic effect styling */
.trerk-effect {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-secondary); /* default fallback */
    text-shadow: none;
    white-space: normal;
}

/* Affinity color classes (reuse same colors as affinity-dot for consistency) */
.trerk-effect.affinity-primary {
    color: var(--stage-slingapult-color); /* ACCENT_PRIMARY */
    text-shadow: 0 0 6px rgba(var(--stage-slingapult-rgb), 0.6);
}

.trerk-effect.affinity-secondary {
    color: var(--stage-sorcerarcher-color); /* ACCENT_SECONDARY */
    text-shadow: 0 0 6px rgba(var(--stage-sorcerarcher-rgb), 0.6);
}

.trerk-effect.affinity-tertiary {
    color: var(--stage-samurocket-color); /* ACCENT_TERTIARY */
    text-shadow: 0 0 6px rgba(var(--stage-samurocket-rgb), 0.6);
}

.trerk-effect.affinity-text-secondary {
    color: #cccccc; /* TEXT_SECONDARY / general */
    text-shadow: none;
}