/* Base Styles */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --accent-primary: #00fff5;
    --accent-secondary: #0f3460;
    --accent-success: #00ff88;
    --accent-warning: #ffaa00;
    --accent-error: #ff0055;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #707070;
    --border-color: #2a2a3e;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.game-container {
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Stats Bar */
.stats-bar {
    background: var(--bg-secondary);
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.game-title h1 {
    font-size: 1.8rem;
    color: var(--accent-primary);
    margin-bottom: 0.2rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stats-display {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.stat-icon {
    font-size: 1.2rem;
}

.stat-value {
    font-weight: bold;
    color: var(--accent-primary);
}

.stat-rate {
    color: var(--accent-success);
    font-size: 0.85rem;
}

/* Tab Navigation */
.tab-nav {
    background: var(--bg-tertiary);
    padding: 0.5rem 2rem;
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
    border-radius: 8px 8px 0 0;
    white-space: nowrap;
}

.tab-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--bg-primary);
    color: var(--accent-primary);
    border-bottom: 2px solid var(--accent-primary);
}

/* Content Area */
.content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-header {
    margin-bottom: 2rem;
}

.tab-header h2 {
    font-size: 2rem;
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
}

.tab-description {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Cards */
.building-card,
.model-card,
.research-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.3s;
}

.building-card:hover,
.model-card:hover,
.research-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(0, 255, 245, 0.3);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--text-primary);
}

.card-count {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-primary);
}

.card-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.card-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.card-stat {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.card-cost {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.cost-item {
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--bg-tertiary);
}

.cost-item.affordable {
    color: var(--accent-success);
    border: 1px solid var(--accent-success);
}

.cost-item.unaffordable {
    color: var(--accent-error);
    border: 1px solid var(--accent-error);
}

.card-button {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.card-button:hover:not(:disabled) {
    background: var(--accent-success);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
}

.card-button:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Categories */
.building-categories,
.model-categories,
.research-categories,
.achievement-categories {
    display: grid;
    gap: 2rem;
}

.building-category h3,
.model-category h3,
.research-category h3,
.achievement-category h3 {
    color: var(--accent-secondary);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* Footer */
.game-footer {
    background: var(--bg-secondary);
    padding: 1.5rem 2rem;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-secondary,
.btn-danger,
.btn-primary {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary {
    background: var(--accent-secondary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.btn-danger {
    background: var(--accent-error);
    color: var(--text-primary);
}

.btn-danger:hover {
    background: #ff3377;
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.5);
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: var(--accent-success);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
}

.footer-info {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 6rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-secondary);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent-primary);
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.toast.success {
    border-left-color: var(--accent-success);
}

.toast.warning {
    border-left-color: var(--accent-warning);
}

.toast.error {
    border-left-color: var(--accent-error);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 2px solid var(--accent-primary);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 255, 245, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: var(--accent-primary);
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.modal-close:hover {
    color: var(--accent-error);
    transform: rotate(90deg);
}

.modal-body {
    padding: 2rem;
}

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

.save-textarea {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    resize: vertical;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.save-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(0, 255, 245, 0.3);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Responsive Design */
@media (max-width: 768px) {
    .stats-bar,
    .tab-nav,
    .content,
    .game-footer {
        padding: 1rem;
    }
    
    .stats-display {
        gap: 1rem;
    }
    
    .stat {
        font-size: 0.85rem;
    }
    
    .tab-btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .toast-container {
        right: 1rem;
        left: 1rem;
    }
    
    .toast {
        max-width: 100%;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .modal-body {
        padding: 1.5rem;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-actions button {
        width: 100%;
    }
}