:root {
    --primary: #6b46c1;
    --secondary: #9f7aea;
    --accent: #d946ef;
    --background: #f0f0f0;
    --card-bg: #ffffff;
    --text: #000000;
    --text-light: #4a5568;
    --border: #000000;
    --shadow: 4px 4px 0px #000000;
    --physics: #8b5cf6;
    --economics: #a78bfa;
    --biology: #c084fc;
    --chemistry: #d946ef;
    --success: #a78bfa;
}

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

body {
    font-family: 'Space Mono', 'Courier New', monospace;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    background-image: radial-gradient(#000 1px, transparent 1px);
    background-size: 20px 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: var(--card-bg);
    border-bottom: 3px solid #000;
    padding: 3rem 0;
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: -2px;
    text-transform: uppercase;
    text-shadow: 4px 4px 0px var(--accent);
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.2rem;
    font-weight: bold;
    background: #000;
    color: #fff;
    display: inline-block;
    padding: 0.2rem 1rem;
    transform: rotate(-2deg);
}

/* Cards - Brutalist Style */
.card {
    background: var(--card-bg);
    border: 3px solid #000;
    border-radius: 0;
    padding: 2rem;
    margin: 2rem 0;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px #000;
}

/* Input Section */
.input-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.input-group input {
    flex: 1;
    min-width: 200px;
    padding: 1rem;
    border: 3px solid #000;
    border-radius: 0;
    font-size: 1.1rem;
    font-family: inherit;
    font-weight: bold;
}

.input-group input:focus {
    outline: none;
    background: #fff;
    box-shadow: 4px 4px 0 var(--secondary);
}

.input-group button, .data-btn {
    padding: 1rem 2rem;
    background: #000;
    color: white;
    border: 3px solid #000;
    border-radius: 0;
    font-size: 1.1rem;
    font-weight: 900;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.2);
}

.input-group button:hover, .data-btn:hover {
    background: var(--primary);
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 #000;
}

.help-text {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: #666;
}

/* Theme Selector */
.theme-selector {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 3px dashed #000;
    text-align: center;
}

.theme-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.theme-btn {
    width: 40px;
    height: 40px;
    border: 2px solid #000;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 2px 2px 0 #000;
}

.theme-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 4px 4px 0 #000;
}

.theme-btn.active {
    transform: translate(2px, 2px);
    box-shadow: none;
    outline: 2px solid #000;
    outline-offset: 2px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 1rem;
    margin: 3rem 0 0;
    overflow-x: auto;
    padding-bottom: 10px;
}

.tab-btn {
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    border: 3px solid #000;
    border-radius: 0;
    font-size: 1rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: 4px 4px 0 #000;
    text-transform: uppercase;
}

.tab-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 #000;
    background: var(--secondary);
    color: white;
}

.tab-btn.active {
    background: #000;
    color: #fff;
    transform: translate(2px, 2px);
    box-shadow: 0 0 0;
}

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

/* Viz Headers */
.viz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #000;
    padding-bottom: 1rem;
}

.viz-header h3 {
    text-transform: uppercase;
    font-weight: 900;
}

/* Displays (Gini, Pareto, etc) */
.gini-display, .r0-display, .pareto-display, .shannon-display {
    text-align: center;
    margin-bottom: 2rem;
}

.gini-value, .r0-value, .pareto-value, .shannon-value {
    display: inline-block;
    padding: 1.5rem 3rem;
    background: #fff;
    border: 3px solid #000;
    border-radius: 0;
    color: #000;
    box-shadow: 6px 6px 0 var(--accent);
}

.gini-value .label, .r0-value .label, .pareto-value .label, .shannon-value .label {
    font-size: 0.9rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 1;
    font-weight: bold;
    text-transform: uppercase;
}

.gini-value .value, .r0-value .value, .pareto-value .value, .shannon-value .value {
    font-size: 3rem;
    font-weight: 900;
    display: block;
    margin-top: 0.5rem;
}

/* Tooltip Button */
.tooltip-btn {
    background: #000;
    color: white;
    border: none;
    border-radius: 0;
    width: 30px;
    height: 30px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 2px 2px 0 var(--text-light);
}

.tooltip-btn:hover {
    background: var(--accent);
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 #000;
}

/* Matrix Table */
#miscibility-matrix, #periodic-table { overflow-x: auto; }

.matrix-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.matrix-table th, .matrix-table td {
    padding: 0.75rem;
    text-align: center;
    border: 2px solid #000;
}

.matrix-table th {
    background: #000;
    color: white;
    font-weight: 900;
}

/* Periodic Table */
.periodic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.element-card {
    aspect-ratio: 1;
    background: #fff;
    border: 2px solid #000;
    border-radius: 0;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    cursor: pointer;
    box-shadow: 2px 2px 0 #000;
}

.element-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 #000;
    background: var(--accent);
    color: white;
}

.element-symbol {
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 0.25rem;
}

.element-name {
    font-size: 0.75rem;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    width: 100%;
}

.element-value {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.25rem;
    font-family: monospace;
}

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

.modal-content {
    background: var(--card-bg);
    border: 3px solid #000;
    box-shadow: 8px 8px 0 var(--accent);
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    border-radius: 0;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #000;
    line-height: 1;
}

#modal-title {
    color: var(--primary);
    margin-bottom: 1rem;
    padding-right: 2rem;
    text-transform: uppercase;
    font-weight: 900;
    border-bottom: 2px solid #000;
    display: inline-block;
}

/* User Profile */
#profile-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: #fff;
    border: 2px solid #000;
    border-radius: 0;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.1);
}

.stat-item .label {
    font-size: 0.8rem;
    display: block;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    font-weight: bold;
    color: #666;
}

.stat-item .value {
    font-size: 1.8rem;
    font-weight: 900;
    color: #000;
    font-family: 'Space Mono', monospace;
}

/* Filter Controls */
.filter-controls {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 3px dashed #000;
    text-align: center;
}

.filter-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.filter-btn {
    padding: 0.75rem 1.5rem;
    background: white;
    border: 2px solid #000;
    border-radius: 0;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    color: #000;
    box-shadow: 3px 3px 0 #ddd;
    text-transform: uppercase;
}

.filter-btn:hover {
    background: #f0f0f0;
}

.filter-btn.active {
    background: #000;
    color: white;
    box-shadow: 3px 3px 0 var(--accent);
    transform: translate(-1px, -1px);
}

/* Loading */
.loading { text-align: center; padding: 2rem; }

.spinner {
    border: 6px solid #000;
    border-top: 6px solid var(--accent);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading p {
    font-weight: bold;
    font-size: 1.2rem;
    text-transform: uppercase;
    animation: blink 1s infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* Utilities */
.hidden { display: none !important; }

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    margin-top: 4rem;
    border-top: 3px solid #000;
    background: #fff;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 { font-size: 2rem; }
    .card { padding: 1rem; box-shadow: 4px 4px 0 #000; }
    .input-group { flex-direction: column; }
    .input-group input, .input-group button { width: 100%; }
}