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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #e74c3c;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --bg-color: #ecf0f1;
    --card-bg: #ffffff;
    --text-color: #2c3e50;
    --border-color: #bdc3c7;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.15);
    --body-gradient-1: #667eea;
    --body-gradient-2: #764ba2;
    --header-gradient-1: #2c3e50;
    --header-gradient-2: #34495e;
    --nav-bg: #34495e;
}

/* Dark Mode Variables */
body.dark-mode {
    --primary-color: #1e1e1e;
    --secondary-color: #e74c3c;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --bg-color: #1e1e1e;
    --card-bg: rgba(240, 240, 240, 0.95);
    --text-color: #1e1e1e;
    --border-color: #ccc;
    --shadow: 0 2px 10px rgba(0,0,0,0.5);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.7);
    --body-gradient-1: #1a1a2e;
    --body-gradient-2: #16213e;
    --header-gradient-1: #0f1419;
    --header-gradient-2: #1a1f26;
    --nav-bg: #1a1f26;
}

/* Dark Mode Specific Fixes for Better Visibility */
body.dark-mode .tab-content h2 {
    color: #1e1e1e;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 15px;
    border-radius: 5px;
    display: inline-block;
}

body.dark-mode .card,
body.dark-mode .input-section,
body.dark-mode .results-container {
    background: rgba(240, 240, 240, 0.95);
    color: #1e1e1e;
}

body.dark-mode .results-container p,
body.dark-mode .results-container div,
body.dark-mode label,
body.dark-mode h3,
body.dark-mode .description {
    color: #1e1e1e !important;
}

body.dark-mode small,
body.dark-mode .config-info {
    color: #2e2e2e !important;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background: white;
    color: #1e1e1e;
    border-color: #999;
}

body.dark-mode table {
    background: rgba(255, 255, 255, 0.95);
}

body.dark-mode th {
    background: #2c3e50;
    color: white;
}

body.dark-mode td {
    color: #1e1e1e;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #2a2a2a;
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
    margin: 0;
    overflow-x: hidden;
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><circle cx="20" cy="20" r="18" fill="none" stroke="rgba(255,255,255,0.6)" stroke-width="1.5"/><circle cx="20" cy="20" r="12" fill="none" stroke="rgba(255,255,255,0.4)" stroke-width="1"/><line x1="20" y1="0" x2="20" y2="8" stroke="rgba(255,255,255,0.8)" stroke-width="2"/><line x1="20" y1="32" x2="20" y2="40" stroke="rgba(255,255,255,0.8)" stroke-width="2"/><line x1="0" y1="20" x2="8" y2="20" stroke="rgba(255,255,255,0.8)" stroke-width="2"/><line x1="32" y1="20" x2="40" y2="20" stroke="rgba(255,255,255,0.8)" stroke-width="2"/><circle cx="20" cy="20" r="1.5" fill="rgba(255,0,0,0.8)"/></svg>') 20 20, crosshair;
}

/* WebGL Smoke Canvas - As the background */
#smoke-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    background: #1a1a1a;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: 15px;
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
    z-index: 10;
    cursor: default;
}

header {
    background: linear-gradient(135deg, var(--header-gradient-1) 0%, var(--header-gradient-2) 100%);
    color: white;
    padding: 30px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

/* Help Icon Styles */
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-color);
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    margin-left: 10px;
    transition: all 0.3s ease;
    border: 2px solid var(--accent-color);
}

.help-icon:hover {
    background: white;
    color: var(--accent-color);
    transform: scale(1.1);
    box-shadow: 0 0 10px var(--accent-color);
}

/* Help Modal Styles */
.help-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.7);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.help-modal-content {
    background: var(--card-bg);
    margin: 5% auto;
    padding: 30px;
    border: 2px solid var(--accent-color);
    border-radius: 15px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    animation: slideIn 0.3s;
    max-height: 85vh;
    overflow-y: auto;
}

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

.help-close {
    color: var(--text-color);
    float: right;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
    line-height: 24px;
}

.help-close:hover,
.help-close:focus {
    color: var(--secondary-color);
}

.help-modal-content h2 {
    color: var(--secondary-color);
    margin-top: 0;
    font-size: 24px;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 10px;
}

.help-modal-content h3 {
    color: var(--accent-color);
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 18px;
}

.help-modal-content p {
    line-height: 1.8;
    margin-bottom: 15px;
}

.help-modal-content ol,
.help-modal-content ul {
    line-height: 1.8;
    margin-left: 20px;
    margin-bottom: 15px;
}

.help-modal-content li {
    margin-bottom: 10px;
}

.help-modal-content strong {
    color: var(--secondary-color);
}

.dark-mode-btn {
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dark-mode-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.tagline {
    font-size: 1.1em;
    opacity: 0.9;
}

/* Tab Navigation with Dropdowns */
.tab-navigation {
    display: flex;
    background: var(--nav-bg);
    border-bottom: 3px solid var(--secondary-color);
    justify-content: center;
    gap: 0;
}

/* Dropdown Container */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

/* Dropdown Button */
.nav-dropdown-btn {
    padding: 18px 30px;
    background: #34495e;
    border: none;
    color: white;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-right: 1px solid rgba(255,255,255,0.1);
}

.nav-dropdown-btn:hover {
    background: #2c3e50;
}

/* Dropdown Content */
.nav-dropdown-content {
    display: none;
    position: absolute;
    background: #2c3e50;
    min-width: 250px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    z-index: 1000;
    border-radius: 0 0 8px 8px;
}

/* Show dropdown on hover */
.nav-dropdown:hover .nav-dropdown-content {
    display: block;
}

/* Tab buttons in dropdown */
.nav-dropdown-content .tab-btn {
    display: block;
    width: 100%;
    padding: 15px 20px;
    background: transparent;
    border: none;
    color: white;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.nav-dropdown-content .tab-btn:hover {
    background: rgba(231, 76, 60, 0.8);
    padding-left: 25px;
}

.nav-dropdown-content .tab-btn.active {
    background: var(--secondary-color);
    font-weight: bold;
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s ease;
}

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

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

.tab-content h2 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 2em;
}

.description {
    color: #7f8c8d;
    margin-bottom: 20px;
    font-style: italic;
}

/* Input Grid Layout */
.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin: 25px 0;
}

.input-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.input-section h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 5px;
}

.input-section h4 {
    color: var(--primary-color);
    margin: 15px 0 10px 0;
    font-size: 1.1em;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--primary-color);
}

.input-group input[type="number"],
.input-group input[type="text"],
.input-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.input-group input[type="number"]:focus,
.input-group input[type="text"]:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

.input-group input[type="checkbox"],
.input-group input[type="radio"] {
    margin-right: 8px;
    width: auto;
}

.input-group small {
    display: block;
    color: #7f8c8d;
    font-size: 0.85em;
    margin-top: 3px;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 15px;
    margin: 25px 0;
    flex-wrap: wrap;
}

button {
    padding: 12px 30px;
    font-size: 1em;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.btn-primary {
    background: var(--secondary-color);
    color: white;
    box-shadow: 0 3px 10px rgba(231, 76, 60, 0.3);
}

.btn-primary:hover {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}

.btn-secondary {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 3px 10px rgba(52, 152, 219, 0.3);
}

.btn-secondary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.btn-small {
    padding: 8px 15px;
    font-size: 0.9em;
    margin: 3px;
}

/* Results Container */
.results-container {
    margin: 25px 0;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid var(--border-color);
}

.results-container h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    background: white;
    box-shadow: var(--shadow);
    border-radius: 8px;
    overflow: hidden;
}

.results-table thead {
    background: var(--primary-color);
    color: white;
}

.results-table th,
.results-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.results-table tbody tr:hover {
    background: #ecf0f1;
}

.results-table tbody tr:last-child td {
    border-bottom: none;
}

.result-card {
    background: white;
    padding: 20px;
    margin: 15px 0;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent-color);
}

.result-card h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.result-value {
    font-size: 2em;
    font-weight: bold;
    color: var(--secondary-color);
    margin: 10px 0;
}

.result-label {
    color: #7f8c8d;
    font-size: 0.9em;
}

/* Charts */
canvas {
    max-width: 100%;
    height: auto !important;
    margin: 20px 0;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

/* Twist Rate Presets */
.twist-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Comparison Container */
.comparison-container {
    margin: 20px 0;
}

#load-inputs {
    display: grid;
    gap: 20px;
    margin-bottom: 20px;
}

.load-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    position: relative;
}

.load-card h4 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.load-card .remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 1.2em;
}

.load-card .remove-btn:hover {
    background: #c0392b;
}

/* Database */
.database-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.database-controls input,
.database-controls select {
    flex: 1;
    min-width: 200px;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1em;
}

.database-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.ammo-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.ammo-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-3px);
    border-color: var(--accent-color);
}

.ammo-card h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.ammo-card .manufacturer {
    color: var(--secondary-color);
    font-weight: bold;
    margin-bottom: 8px;
}

.ammo-card .specs {
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: #555;
    font-size: 0.95em;
}

.ammo-card .specs span {
    display: flex;
    justify-content: space-between;
}

.ammo-card .use-btn {
    margin-top: 15px;
    width: 100%;
    background: var(--success-color);
    color: white;
}

.ammo-card .use-btn:hover {
    background: #229954;
}

/* Energy Comparison List */
#energy-comparison-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.comparison-item {
    background: white;
    padding: 10px;
    margin: 8px 0;
    border-radius: 5px;
    border-left: 4px solid var(--accent-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.comparison-item .remove-comparison {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: white;
    margin-top: 20px;
}

footer a {
    color: white;
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }
    
    .input-grid {
        grid-template-columns: 1fr;
    }
    
    .tab-navigation {
        flex-direction: column;
    }
    
    .tab-btn {
        width: 100%;
        min-width: auto;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    button {
        width: 100%;
    }
    
    .database-controls {
        flex-direction: column;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.hidden {
    display: none;
}

/* Info Boxes */
.info-box {
    background: #e8f4f8;
    border-left: 4px solid var(--accent-color);
    padding: 15px;
    margin: 15px 0;
    border-radius: 5px;
}

.warning-box {
    background: #fff3cd;
    border-left: 4px solid var(--warning-color);
    padding: 15px;
    margin: 15px 0;
    border-radius: 5px;
}

.success-box {
    background: #d4edda;
    border-left: 4px solid var(--success-color);
    padding: 15px;
    margin: 15px 0;
    border-radius: 5px;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}
