/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f35;
    --bg-card-hover: #242b45;
    --text-primary: #e8eaf0;
    --text-secondary: #8b92a8;
    --text-muted: #5a6178;
    --accent: #4fc3f7;
    --accent-glow: rgba(79, 195, 247, 0.3);
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.15);

    /* Category Colors */
    --cat-nonmetal: #56bb4b;
    --cat-noble-gas: #8b6fd0;
    --cat-alkali-metal: #e24d4d;
    --cat-alkaline-earth-metal: #e8893c;
    --cat-metalloid: #3db5a6;
    --cat-halogen: #4ecdc4;
    --cat-transition-metal: #4a90d9;
    --cat-post-transition-metal: #4a9b8f;
    --cat-lanthanide: #ce6dad;
    --cat-actinide: #c88ac4;
    --cat-unknown: #666;

    --font-main: "Poppins", sans-serif;
    --font-display: "Orbitron", sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ===== Page System ===== */
.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    transition:
        opacity 0.3s ease,
        transform 0.3s ease;
}
.page.active {
    display: flex;
    z-index: 10;
}
.page.slide-in {
    animation: slideIn 0.35s ease forwards;
}
.page.slide-out {
    animation: slideOut 0.35s ease forwards;
}
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-30%);
        opacity: 0;
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* ===== SPLASH PAGE ===== */
#page-splash {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #0d1b2a 0%, #050a14 100%);
    overflow: hidden;
}
.splash-container {
    text-align: center;
    position: relative;
    z-index: 2;
}
.splash-bg-glow {
    position: absolute;
    width: 400px;
    height: 400px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(
        circle,
        rgba(79, 195, 247, 0.12) 0%,
        transparent 70%
    );
    pointer-events: none;
}

/* Atom Orbit Animation */
.splash-atom-orbit {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 30px;
}
.nucleus {
    position: absolute;
    width: 24px;
    height: 24px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, #ff6b6b, #c0392b);
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.6);
}
.orbit {
    position: absolute;
    border: 1px solid rgba(79, 195, 247, 0.25);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.orbit-1 {
    width: 80px;
    height: 80px;
    animation: orbit-rotate 2s linear infinite;
}
.orbit-2 {
    width: 130px;
    height: 130px;
    animation: orbit-rotate 3s linear infinite reverse;
    transform-origin: center;
}
.orbit-3 {
    width: 180px;
    height: 180px;
    animation: orbit-rotate 4.5s linear infinite;
}
.orbit-2 {
    transform: translate(-50%, -50%) rotateX(60deg);
}
.orbit-3 {
    transform: translate(-50%, -50%) rotateX(-45deg) rotateZ(30deg);
}

.electron {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #4fc3f7;
    border-radius: 50%;
    box-shadow:
        0 0 10px rgba(79, 195, 247, 0.8),
        0 0 20px rgba(79, 195, 247, 0.4);
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
}

@keyframes orbit-rotate {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.splash-title {
    font-family: var(--font-display);
    font-size: 2.5em;
    font-weight: 800;
    letter-spacing: 6px;
    color: #fff;
    line-height: 1.1;
    margin-bottom: 10px;
    text-shadow: 0 0 30px rgba(79, 195, 247, 0.3);
}
.splash-title span {
    font-size: 0.55em;
    letter-spacing: 12px;
    color: var(--accent);
    font-weight: 400;
}
.splash-subtitle {
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-bottom: 40px;
    letter-spacing: 2px;
}
.splash-loader {
    width: 200px;
    margin: 0 auto;
}
.loader-bar {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}
.loader-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #81d4fa);
    border-radius: 3px;
    transition: width 0.1s linear;
}
.loader-text {
    color: var(--text-muted);
    font-size: 0.75em;
    margin-top: 8px;
    letter-spacing: 1px;
}
.splash-version {
    position: absolute;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-muted);
    font-size: 0.7em;
}

/* ===== TABLE HEADER ===== */
.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 10px;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
}
.header-left h2 {
    font-family: var(--font-display);
    font-size: 1em;
    font-weight: 600;
    letter-spacing: 1px;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}
.search-box {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px 10px;
    gap: 6px;
    transition: border-color 0.2s;
}
.search-box:focus-within {
    border-color: var(--accent);
}
.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}
.search-box input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.85em;
    width: 140px;
}
.search-box input::placeholder {
    color: var(--text-muted);
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-icon:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--accent);
}

/* ===== CATEGORY LEGEND ===== */
.category-legend {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    overflow-x: auto;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.category-legend::-webkit-scrollbar {
    display: none;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.7em;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.legend-item:hover {
    background: rgba(255, 255, 255, 0.08);
}
.legend-item.active {
    background: rgba(79, 195, 247, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}
.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ===== SORT PANEL ===== */
.sort-panel {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.sort-panel.hidden {
    display: none;
}
.sort-panel h3 {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-right: 6px;
}
.sort-btn {
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.75em;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s;
}
.sort-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}
.sort-btn.active {
    background: rgba(79, 195, 247, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

/* ===== PERIODIC TABLE GRID ===== */
.table-container {
    flex: 1;
    overflow: auto;
    padding: 12px;
}
.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, 1fr);
    gap: 2px;
    min-width: 720px;
    max-width: 1200px;
    margin: 0 auto;
}
.element-cell {
    aspect-ratio: 1;
    min-width: 38px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    padding: 2px;
}
.element-cell::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    opacity: 0.8;
}
.element-cell:hover {
    transform: scale(1.15);
    z-index: 5;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border-color: var(--accent);
}
.element-cell .el-number {
    font-size: 0.5em;
    color: var(--text-muted);
    line-height: 1;
}
.element-cell .el-symbol {
    font-size: 0.95em;
    font-weight: 700;
    line-height: 1.2;
}
.element-cell .el-name {
    font-size: 0.35em;
    color: var(--text-secondary);
    line-height: 1;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.element-cell .el-weight {
    font-size: 0.35em;
    color: var(--text-muted);
    line-height: 1;
}
.element-cell.empty {
    background: transparent;
    border: none;
    cursor: default;
    pointer-events: none;
}
.element-cell.label-cell {
    background: transparent;
    border: none;
    cursor: default;
    font-size: 0.6em;
    color: var(--text-muted);
    font-weight: 500;
}
.element-cell.dimmed {
    opacity: 0.15;
}
.element-cell.highlighted {
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.3);
}

/* Phase indicators on temperature */
.element-cell.phase-solid .el-symbol {
    color: inherit;
}
.element-cell.phase-liquid .el-symbol {
    color: #4fc3f7;
}
.element-cell.phase-gas .el-symbol {
    color: #ff7043;
    font-weight: 400;
}

/* Lanthanide/Actinide separator */
.table-separator {
    grid-column: 1 / -1;
    height: 12px;
}

/* ===== ELEMENT LIST VIEW ===== */
.element-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px;
}
.element-list.hidden {
    display: none;
}
.element-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.element-list-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}
.list-symbol-box {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
    font-weight: 700;
    flex-shrink: 0;
}
.list-info {
    flex: 1;
}
.list-info .list-name {
    font-size: 0.95em;
    font-weight: 500;
}
.list-info .list-detail {
    font-size: 0.75em;
    color: var(--text-secondary);
}
.list-number {
    font-size: 0.8em;
    color: var(--text-muted);
}

/* ===== TEMPERATURE SLIDER ===== */
.temp-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    font-size: 0.8em;
}
.temp-slider-container label {
    color: var(--text-muted);
    white-space: nowrap;
}
#temp-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 4px;
    background: linear-gradient(90deg, #4fc3f7, #ff7043, #ff5252);
    border-radius: 4px;
    outline: none;
}
#temp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
}
#temp-value {
    color: var(--accent);
    font-weight: 500;
    min-width: 65px;
    text-align: right;
}

/* ===== DETAIL PAGE HEADER ===== */
.detail-header,
.settings-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-shrink: 0;
}
.btn-back {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-back:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--accent);
}
.detail-header h2,
.settings-header h2 {
    flex: 1;
    font-family: var(--font-display);
    font-size: 1em;
    font-weight: 600;
    letter-spacing: 1px;
}
.detail-nav-btns {
    display: flex;
    gap: 4px;
}

/* ===== DETAIL TABS ===== */
.detail-tabs {
    display: flex;
    gap: 2px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.tab-btn {
    flex: 1;
    padding: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.8em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.tab-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}
.tab-btn.active {
    background: rgba(79, 195, 247, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

/* ===== TAB CONTENT ===== */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}
.tab-content.active {
    display: block;
}

/* ===== HERO CARD ===== */
.element-hero {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
}
.hero-card {
    width: 140px;
    height: 160px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-light);
    position: relative;
    flex-shrink: 0;
    background: var(--bg-card);
}
.hero-number {
    font-size: 0.75em;
    color: var(--text-muted);
    position: absolute;
    top: 8px;
    left: 10px;
}
.hero-symbol {
    font-size: 3.5em;
    font-weight: 700;
    line-height: 1;
}
.hero-name {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-top: 4px;
}
.hero-weight {
    font-size: 0.7em;
    color: var(--text-muted);
}
.hero-nameplate {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hero-nameplate img {
    max-width: 100%;
    max-height: 120px;
    object-fit: contain;
    border-radius: 8px;
}

/* ===== INFO GRID ===== */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}
.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    transition: border-color 0.2s;
}
.info-card:hover {
    border-color: var(--border-light);
}
.info-card .info-label {
    font-size: 0.65em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.info-card .info-value {
    font-size: 1em;
    font-weight: 600;
    color: var(--text-primary);
}
.info-card .info-unit {
    font-size: 0.7em;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ===== ELEMENT DESCRIPTION ===== */
.element-description {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    font-size: 0.85em;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ===== DETAIL SECTIONS ===== */
.detail-section {
    margin-bottom: 24px;
}
.section-title {
    font-family: var(--font-display);
    font-size: 0.8em;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 1px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

/* Crystal Display */
.crystal-display {
    text-align: center;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
}
.crystal-display img {
    max-width: 200px;
    max-height: 200px;
    object-fit: contain;
    margin-bottom: 10px;
}
.crystal-display p {
    color: var(--text-secondary);
    font-size: 0.9em;
    font-weight: 500;
}

/* Electron Configuration */
.electron-config {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    font-family: monospace;
    font-size: 0.95em;
    color: var(--accent);
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    word-break: break-all;
}

/* Shell Diagram */
.shell-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    flex-wrap: wrap;
}
.shell-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.shell-bar .shell-label {
    font-size: 0.65em;
    color: var(--text-muted);
    text-transform: uppercase;
}
.shell-bar .shell-fill {
    width: 36px;
    background: linear-gradient(180deg, var(--accent), rgba(79, 195, 247, 0.3));
    border-radius: 4px;
    min-height: 4px;
    transition: height 0.4s ease;
}
.shell-bar .shell-count {
    font-size: 0.75em;
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== 3D ATOM VIEWER ===== */
.atom-viewer-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
}
#atom-canvas {
    flex: 1;
    width: 100%;
    background: radial-gradient(ellipse at center, #0d1b2a 0%, #050a14 100%);
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: grab;
}
#atom-canvas:active {
    cursor: grabbing;
}
.atom-controls {
    display: flex;
    gap: 6px;
    padding: 10px 0;
    justify-content: center;
}
.atom-ctrl-btn {
    padding: 6px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.75em;
    cursor: pointer;
    transition: all 0.2s;
}
.atom-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}
.atom-ctrl-btn.active {
    background: rgba(79, 195, 247, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}
.atom-info-panel {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 8px 0;
}
.atom-info-row {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
}
.atom-info-label {
    display: block;
    font-size: 0.6em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.atom-info-value {
    display: block;
    font-size: 1.1em;
    font-weight: 700;
    color: var(--accent);
    margin-top: 2px;
}

/* ===== EMISSION SPECTRUM ===== */
.emission-container h3 {
    font-family: var(--font-display);
    font-size: 0.9em;
    color: var(--accent);
    margin-bottom: 16px;
    letter-spacing: 1px;
}
.spectrum-display {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 12px;
}
.spectrum-display img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    display: block;
}
.spectrum-scale {
    display: flex;
    justify-content: space-between;
    padding: 6px 12px;
    font-size: 0.6em;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.6);
}
.spectrum-bg-bar {
    display: none;
}
.no-data {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9em;
}
.visible-spectrum-bar {
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}
.spectrum-gradient {
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        #8b00ff,
        #4b0082,
        #0000ff,
        #00ff00,
        #ffff00,
        #ff7f00,
        #ff0000
    );
}
.emission-info {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}

/* ===== SETTINGS PAGE ===== */
.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}
.settings-group {
    margin-bottom: 24px;
}
.settings-group h3 {
    font-family: var(--font-display);
    font-size: 0.8em;
    color: var(--accent);
    letter-spacing: 1px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 6px;
    font-size: 0.9em;
}
.setting-row span:first-child {
    color: var(--text-secondary);
}
.setting-value {
    color: var(--text-muted);
    font-size: 0.85em;
}
.setting-row select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 4px 8px;
    font-family: var(--font-main);
    font-size: 0.85em;
    outline: none;
}

/* Mix Lab Button in Header */
.btn-lab {
    color: #ff9800 !important;
    border-color: rgba(255, 152, 0, 0.3) !important;
    background: rgba(255, 152, 0, 0.1) !important;
}
.btn-lab:hover {
    background: rgba(255, 152, 0, 0.2) !important;
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.2);
}

/* ===== MIX LAB PAGE ===== */
.mixlab-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(180deg, #1a2040 0%, #111827 100%);
    border-bottom: 1px solid var(--border);
    gap: 8px;
    flex-shrink: 0;
}
.mixlab-header-center {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}
.mixlab-level-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
}
.mixlab-header h2 {
    font-family: var(--font-display);
    font-size: 1em;
    font-weight: 600;
    letter-spacing: 1px;
}
.mixlab-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}
.sim-speed-img {
    width: 16px;
    height: auto;
    object-fit: contain;
    filter: brightness(0.8);
}
.hint-img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}
.mixlab-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: radial-gradient(
        ellipse at 50% 30%,
        rgba(79, 195, 247, 0.03) 0%,
        transparent 70%
    );
}

/* Lab Workspace (Canvas) */
.lab-workspace {
    width: 100%;
    aspect-ratio: 4/3;
    max-height: 380px;
    background: #0a0e18;
    border: 1px solid rgba(79, 195, 247, 0.15);
    border-radius: 14px;
    overflow: hidden;
    position: relative;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.4),
        inset 0 0 30px rgba(79, 195, 247, 0.03);
}
.lab-workspace canvas {
    width: 100%;
    height: 100%;
    display: block;
}
/* Sim Speed Overlay */
.sim-speed-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 5;
}
.sim-speed-overlay.hidden {
    display: none;
}
.sim-speed-overlay input[type="range"] {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 20px;
    height: 80px;
    -webkit-appearance: none;
    background: rgba(79, 195, 247, 0.2);
    border-radius: 4px;
}
.sim-speed-label {
    font-size: 0.7em;
    color: var(--accent);
    font-weight: 600;
}

/* Chemical Selection */
.chem-selection {
    display: flex;
    align-items: stretch;
    gap: 8px;
}
.chem-slot {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: relative;
}
.chem-bottle-icon {
    width: 36px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.bottle-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.6;
    transition: opacity 0.3s;
}
.chem-slot:has(select:not([value=""])) .bottle-icon-img,
.chem-slot.has-value .bottle-icon-img {
    opacity: 1;
}
.chem-slot label {
    font-size: 0.6em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.chem-slot select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 8px 10px;
    font-family: var(--font-main);
    font-size: 0.8em;
    outline: none;
    cursor: pointer;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%238b92a8' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}
.chem-slot select:focus {
    border-color: var(--accent);
}
.chem-plus {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
    align-self: center;
}
.chem-preview {
    font-size: 0.75em;
    color: var(--accent);
    min-height: 16px;
    font-weight: 500;
}

/* Lab Control Buttons */
.lab-controls {
    display: flex;
    gap: 8px;
}
.lab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}
.lab-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}
.lab-btn:hover::before {
    opacity: 1;
}
.lab-btn:hover {
    background: var(--bg-card-hover);
}
.lab-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.lab-btn-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
}
.lab-btn-mix {
    background: rgba(79, 195, 247, 0.12);
    border-color: rgba(79, 195, 247, 0.25);
    color: var(--accent);
}
.lab-btn-mix::before {
    background: var(--accent);
}
.lab-btn-mix:hover:not(:disabled) {
    background: rgba(79, 195, 247, 0.22);
    box-shadow: 0 0 12px rgba(79, 195, 247, 0.15);
}
.lab-btn-heat {
    background: rgba(255, 152, 0, 0.12);
    border-color: rgba(255, 152, 0, 0.25);
    color: #ff9800;
}
.lab-btn-heat::before {
    background: #ff9800;
}
.lab-btn-heat:hover:not(:disabled) {
    background: rgba(255, 152, 0, 0.22);
    box-shadow: 0 0 12px rgba(255, 152, 0, 0.15);
}
.lab-btn-heat.heating-active {
    background: rgba(255, 100, 0, 0.45) !important;
    border-color: rgba(255, 100, 0, 0.6) !important;
    color: #fff !important;
    box-shadow: 0 0 15px rgba(255, 100, 0, 0.3);
    animation: pulseHeat 1s ease-in-out infinite;
}
@keyframes pulseHeat {
    0%,
    100% {
        box-shadow: 0 0 10px rgba(255, 100, 0, 0.3);
    }
    50% {
        box-shadow: 0 0 25px rgba(255, 100, 0, 0.5);
    }
}
.lab-btn-reset {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border);
    color: var(--text-secondary);
}
.lab-btn-reset:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Reaction Equation Bar */
.reaction-equation-bar {
    background: rgba(79, 195, 247, 0.08);
    border: 1px solid rgba(79, 195, 247, 0.2);
    border-radius: 10px;
    padding: 10px 16px;
    text-align: center;
    animation: fadeSlideUp 0.4s ease;
}
.reaction-equation-bar.hidden {
    display: none;
}
.equation-text {
    font-family: var(--font-display);
    font-size: 0.95em;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.5px;
    word-break: break-word;
}

/* ===== RESULT PANEL (Original APK Style) ===== */
.reaction-result-panel {
    animation: resultPanelIn 0.5s ease;
}
.reaction-result-panel.hidden {
    display: none;
}
.result-panel-bg {
    position: relative;
    width: 100%;
    border-radius: 14px;
    overflow: hidden;
}
.result-panel-img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 14px;
    opacity: 0.25;
}
.result-panel-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 20px;
    gap: 8px;
}
/* Level Status */
.result-status {
    margin-bottom: 4px;
}
.result-status img {
    height: 32px;
    object-fit: contain;
}
/* Stars Row */
.result-stars {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}
.result-star {
    width: 36px;
    height: 34px;
    object-fit: contain;
    transition:
        transform 0.3s ease,
        filter 0.3s;
}
.result-star.earned {
    filter: drop-shadow(0 0 6px rgba(255, 200, 0, 0.6));
    animation: starPop 0.4s ease;
}
@keyframes starPop {
    0% {
        transform: scale(0.3) rotate(-30deg);
    }
    60% {
        transform: scale(1.3) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}
/* Result Equation */
.result-equation {
    font-family: var(--font-display);
    font-size: 0.9em;
    font-weight: 600;
    color: var(--accent);
    text-align: center;
    padding: 6px 12px;
    background: rgba(79, 195, 247, 0.1);
    border-radius: 8px;
    letter-spacing: 0.5px;
    word-break: break-word;
    width: 100%;
    max-width: 320px;
}
.result-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    max-width: 320px;
}
.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.result-label {
    font-size: 0.68em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.result-value {
    font-size: 0.82em;
    font-weight: 500;
    color: var(--text-primary);
}
.result-description {
    font-size: 0.78em;
    color: var(--text-secondary);
    line-height: 1.4;
    text-align: center;
    max-width: 320px;
}
/* Result Action Buttons */
.result-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}
.result-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 20px;
    border-radius: 10px;
    font-family: var(--font-main);
    font-size: 0.8em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
}
.result-btn-retry {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}
.result-btn-retry:hover {
    background: rgba(255, 255, 255, 0.14);
    color: var(--text-primary);
}
.result-btn-next {
    background: rgba(79, 195, 247, 0.2);
    border-color: rgba(79, 195, 247, 0.3);
    color: var(--accent);
}
.result-btn-next:hover {
    background: rgba(79, 195, 247, 0.3);
    box-shadow: 0 0 10px rgba(79, 195, 247, 0.15);
}

@keyframes resultPanelIn {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(15px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Info Modal */
.lab-info-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    backdrop-filter: blur(4px);
}
.lab-info-modal.hidden {
    display: none;
}
.lab-info-content {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 24px;
    max-width: 360px;
    width: 100%;
}
.lab-info-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.lab-info-hint-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
}
.lab-info-content h3 {
    font-family: var(--font-display);
    font-size: 0.9em;
    color: var(--accent);
    letter-spacing: 1px;
}
.lab-info-content ol {
    padding-left: 20px;
    margin-bottom: 14px;
}
.lab-info-content li {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.4;
}
.lab-info-note {
    font-size: 0.75em;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.lab-info-content .lab-btn {
    width: 100%;
    justify-content: center;
    background: rgba(79, 195, 247, 0.15);
    border-color: rgba(79, 195, 247, 0.3);
    color: var(--accent);
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .search-box input {
        width: 100px;
    }
    .element-cell .el-name {
        display: none;
    }
    .element-cell .el-weight {
        display: none;
    }
    .periodic-table {
        gap: 1px;
    }
    .element-cell {
        min-width: 30px;
    }
    .element-hero {
        flex-direction: column;
        text-align: center;
    }
    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .atom-info-panel {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 480px) {
    .element-cell .el-symbol {
        font-size: 0.75em;
    }
    .element-cell .el-number {
        font-size: 0.4em;
    }
    .splash-title {
        font-size: 1.8em;
    }
    .header-left h2 {
        display: none;
    }
}

/* ==================== BURN PAGE STYLES ==================== */
.burn-selection {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    margin: 0 12px 8px;
}
.burn-element-pick {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}
.burn-bottle-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    opacity: 0.7;
}
.burn-element-pick select {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.95em;
    outline: none;
}
.burn-element-pick select:focus {
    border-color: #ff9800;
}
.burn-sample-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 100px;
}
#burn-sample-label {
    font-size: 0.85em;
    color: #bbb;
}
#burn-temp-display {
    font-size: 1.1em;
    font-weight: 600;
    color: #ff9800;
}
.burn-temp-control {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    margin: 0 12px 8px;
    background: rgba(255, 87, 34, 0.08);
    border-radius: 10px;
    border: 1px solid rgba(255, 87, 34, 0.15);
}
.burn-temp-label {
    font-size: 0.85em;
    color: #ff9800;
    white-space: nowrap;
}
#burn-temp-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #2196f3, #ff9800, #f44336);
    outline: none;
}
#burn-temp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #ff9800;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.5);
}
.burn-temp-val {
    font-size: 0.95em;
    font-weight: 600;
    color: #ff9800;
    min-width: 55px;
    text-align: right;
}

/* ==================== SOLUBILITY PAGE STYLES ==================== */
.sol-selection {
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    margin: 0 12px 8px;
}
.sol-pick {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    padding: 10px;
}
.sol-pick label {
    font-size: 0.8em;
    color: #81d4fa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.sol-bottle-icon {
    width: 26px;
    height: 26px;
    object-fit: contain;
    opacity: 0.7;
}
.sol-pick select {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 0.9em;
    outline: none;
}
.sol-pick select:focus {
    border-color: #4fc3f7;
}
.sol-controls {
    padding: 8px 16px;
    margin: 0 12px 8px;
    background: rgba(79, 195, 247, 0.06);
    border-radius: 10px;
    border: 1px solid rgba(79, 195, 247, 0.12);
}
.sol-control-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}
.sol-control-row span:first-child {
    font-size: 0.85em;
    color: #81d4fa;
    min-width: 90px;
}
.sol-control-row input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 5px;
    border-radius: 3px;
    background: rgba(79, 195, 247, 0.3);
    outline: none;
}
.sol-control-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4fc3f7;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(79, 195, 247, 0.5);
}
#sol-amount-val,
#sol-temp-val {
    font-size: 0.9em;
    font-weight: 600;
    color: #4fc3f7;
    min-width: 45px;
    text-align: right;
}
.sol-info-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    padding: 10px 16px;
    margin: 0 12px 8px;
    background: rgba(0, 150, 136, 0.08);
    border-radius: 10px;
    border: 1px solid rgba(0, 150, 136, 0.15);
}
.sol-info-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88em;
}
.sol-info-row span:first-child {
    color: #80cbc4;
}
.sol-info-row span:last-child {
    color: #e0e0e0;
    font-weight: 600;
}
.sol-crystal-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    vertical-align: middle;
}

/* ==================== MIXING GAME STYLES ==================== */
.mixgame-header {
    flex-wrap: wrap;
}
.mixgame-hud {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}
.mixgame-timer {
    display: flex;
    align-items: center;
    gap: 4px;
}
.mixgame-clock-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}
.mixgame-timer span {
    font-size: 1.3em;
    font-weight: 700;
    color: #ff9800;
    font-variant-numeric: tabular-nums;
}
.mixgame-timer.warning span {
    color: #f44336;
    animation: timerPulse 0.5s ease infinite;
}
@keyframes timerPulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}
.mixgame-score-wrap,
.mixgame-level-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.mixgame-score-label,
.mixgame-lvl-label {
    font-size: 0.65em;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
#mixgame-score {
    font-size: 1.2em;
    font-weight: 700;
    color: #4caf50;
}
#mixgame-level {
    font-size: 1.2em;
    font-weight: 700;
    color: #81d4fa;
}
.mixgame-target {
    margin: 0 12px 8px;
}
.mixgame-target-bg {
    background-size: cover;
    background-position: center;
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
    overflow: hidden;
}
.mixgame-target-bg::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 12px;
}
.mixgame-target-bg > * {
    position: relative;
    z-index: 1;
}
.mixgame-target-label {
    font-size: 0.8em;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.mixgame-target-compound {
    font-size: 1.5em;
    font-weight: 700;
    color: #fff;
}
.mixgame-target-formula {
    font-size: 0.95em;
    color: #81d4fa;
}
.mixgame-selection {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    margin: 0 12px 8px;
}
.mixgame-pick {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}
.mixgame-pick select {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.9em;
    outline: none;
}
.mixgame-pick select:focus {
    border-color: #4caf50;
}
.mixgame-plus {
    font-size: 1.5em;
    font-weight: 700;
    color: #666;
}
.mixgame-mix-btn {
    background: linear-gradient(135deg, #4caf50, #2e7d32) !important;
}
.mixgame-mix-btn:active {
    background: linear-gradient(135deg, #388e3c, #1b5e20) !important;
}
.mixgame-feedback {
    text-align: center;
    padding: 10px 16px;
    margin: 0 12px 8px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1em;
    animation: feedbackIn 0.3s ease;
}
.mixgame-feedback.correct {
    background: rgba(76, 175, 80, 0.15);
    color: #66bb6a;
    border: 1px solid rgba(76, 175, 80, 0.3);
}
.mixgame-feedback.wrong {
    background: rgba(244, 67, 54, 0.15);
    color: #ef5350;
    border: 1px solid rgba(244, 67, 54, 0.3);
}
@keyframes feedbackIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.mixgame-final-score {
    text-align: center;
    padding: 8px 0;
    font-size: 1.1em;
    color: #bbb;
}
.mixgame-final-score span:last-child {
    font-size: 1.4em;
    font-weight: 700;
    color: #ffd54f;
}
.mixgame-confetti-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}
