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

body {
    font-family: Georgia, 'Times New Roman', serif;
    background: #f4f1eb;
    min-height: 100vh;
    padding: 20px;
    transition: background 0.3s, color 0.3s;
    -webkit-tap-highlight-color: transparent;
}

body.dark {
    background: #1a1a2e;
    color: #eee;
}

header {
    text-align: center;
    margin-bottom: 15px;
}

h1 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-weight: normal;
    font-size: 28px;
    letter-spacing: 1px;
}

body.dark h1 {
    color: #ecf0f1;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.controls input, .controls select, .controls button {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-family: inherit;
    font-size: 13px;
}

.controls button {
    background: #3498db;
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.controls button:hover {
    background: #2980b9;
}

body.dark .controls input, body.dark .controls select {
    background: #2d2d44;
    color: #eee;
    border-color: #444;
}

.temp-slider-container {
    text-align: center;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

body.dark .temp-slider-container {
    background: rgba(255,255,255,0.05);
}

#temp-slider {
    width: 200px;
    margin: 0 10px;
}

.state-legend {
    display: inline-flex;
    gap: 15px;
    margin-left: 15px;
    font-size: 12px;
}

.solid-dot, .liquid-dot, .gas-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 4px;
}

.solid-dot { background: #555; }
.liquid-dot { background: #3498db; }
.gas-dot { background: #e74c3c; }

.legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.legend-item {
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 11px;
    color: #333;
}

#table-container {
    display: grid;
    grid-template-columns: repeat(18, 1fr);
    gap: 2px;
    max-width: 1100px;
    margin: 0 auto 30px;
    outline: none;
}

.element {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.3s, filter 0.3s;
    border: 1px solid rgba(0,0,0,0.1);
    position: relative;
    min-width: 0;
    padding: 2px;
}

.element:hover {
    transform: scale(1.3);
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
    z-index: 100;
}

@media (hover: none) {
    .element:hover {
        transform: none;
        box-shadow: none;
    }
    .element:active {
        transform: scale(1.1);
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }
}

.element.selected {
    outline: 3px solid #e74c3c;
}

.element.dimmed {
    opacity: 0.2;
}

.element.radioactive {
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px #2ecc71; }
    50% { box-shadow: 0 0 15px #2ecc71, 0 0 25px #27ae60; }
}

.element .number {
    font-size: 9px;
    color: #555;
    position: absolute;
    top: 2px;
    left: 3px;
}

.element .symbol {
    font-size: 16px;
    font-weight: bold;
    color: #222;
}

.element .name {
    font-size: 6px;
    color: #666;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

.element .state-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.element .state-indicator.solid { background: #555; }
.element .state-indicator.liquid { background: #3498db; }
.element .state-indicator.gas { background: #e74c3c; }

body.dark .element .number { color: #aaa; }
body.dark .element .symbol { color: #111; }
body.dark .element .name { color: #444; }

.placeholder {
    visibility: hidden;
}

.alkali { background: #ffb3ba; }
.alkaline { background: #ffdfba; }
.transition { background: #ffffba; }
.post-transition { background: #baffc9; }
.metalloid { background: #bae1ff; }
.nonmetal { background: #e2baff; }
.halogen { background: #ffbaf3; }
.noble { background: #d4baff; }
.lanthanide { background: #ffd9ba; }
.actinide { background: #c9ffba; }
.unknown { background: #ddd; }

#element-info {
    max-width: 600px;
    margin: 0 auto 20px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    min-height: 120px;
}

body.dark #element-info {
    background: #2d2d44;
}

#element-info h2 {
    margin-bottom: 10px;
    color: #2c3e50;
    font-weight: normal;
}

body.dark #element-info h2 {
    color: #ecf0f1;
}

#element-info p {
    color: #555;
    line-height: 1.6;
    font-size: 14px;
}

body.dark #element-info p {
    color: #bbb;
}

#element-info .detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

#element-info .detail-item {
    font-size: 13px;
}

#element-info .detail-item span {
    color: #888;
}

#element-info .electron-shells {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 15px;
    gap: 5px;
}

#element-info .shell {
    border: 2px solid #3498db;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #3498db;
}

#element-info .wiki-link {
    display: inline-block;
    margin-top: 10px;
    color: #3498db;
    text-decoration: none;
}

#element-info .wiki-link:hover {
    text-decoration: underline;
}

#element-info .fun-fact {
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-left: 3px solid #3498db;
    font-style: italic;
    font-size: 13px;
}

body.dark #element-info .fun-fact {
    background: #1a1a2e;
}

#compare-section, #calculator {
    max-width: 600px;
    margin: 20px auto;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

body.dark #compare-section, body.dark #calculator {
    background: #2d2d44;
}

#compare-section h3, #calculator h3 {
    margin-bottom: 15px;
    font-weight: normal;
    color: #2c3e50;
}

body.dark #compare-section h3, body.dark #calculator h3 {
    color: #ecf0f1;
}

.compare-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.compare-controls select {
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ccc;
    min-width: 150px;
}

body.dark .compare-controls select {
    background: #1a1a2e;
    color: #eee;
    border-color: #444;
}

#compare-result {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.compare-card {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

body.dark .compare-card {
    background: #1a1a2e;
}

.compare-card h4 {
    margin-bottom: 10px;
    color: #2c3e50;
}

body.dark .compare-card h4 {
    color: #ecf0f1;
}

.compare-card p {
    font-size: 13px;
    margin: 5px 0;
    color: #555;
}

body.dark .compare-card p {
    color: #bbb;
}

#calculator input {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    width: 200px;
    margin-right: 10px;
}

body.dark #calculator input {
    background: #1a1a2e;
    color: #eee;
    border-color: #444;
}

#calc-btn {
    padding: 10px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#calc-btn:hover {
    background: #2980b9;
}

#calc-result {
    margin-top: 15px;
    font-size: 18px;
    color: #2c3e50;
}

body.dark #calc-result {
    color: #ecf0f1;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

body.dark .modal-content {
    background: #2d2d44;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    cursor: pointer;
    color: #888;
}

.close-btn:hover {
    color: #333;
}

body.dark .close-btn:hover {
    color: #eee;
}

#modal-body h2 {
    margin-bottom: 15px;
    color: #2c3e50;
}

body.dark #modal-body h2 {
    color: #ecf0f1;
}

#modal-body p {
    margin: 8px 0;
    color: #555;
}

body.dark #modal-body p {
    color: #bbb;
}

.quiz-content {
    text-align: center;
}

.quiz-content h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

body.dark .quiz-content h2 {
    color: #ecf0f1;
}

#quiz-question {
    font-size: 18px;
    margin-bottom: 20px;
    color: #333;
}

body.dark #quiz-question {
    color: #eee;
}

#quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

#quiz-options button {
    padding: 15px;
    border: 2px solid #3498db;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

body.dark #quiz-options button {
    background: #1a1a2e;
    color: #eee;
}

#quiz-options button:hover {
    background: #3498db;
    color: white;
}

#quiz-options button.correct {
    background: #2ecc71;
    border-color: #2ecc71;
    color: white;
}

#quiz-options button.wrong {
    background: #e74c3c;
    border-color: #e74c3c;
    color: white;
}

#quiz-score {
    margin-top: 20px;
    font-size: 16px;
    color: #555;
}

body.dark #quiz-score {
    color: #bbb;
}

@media (max-width: 900px) {
    body { padding: 10px; }
    
    h1 { font-size: 22px; }
    
    #table-container { 
        gap: 1px;
        overflow-x: auto;
        max-width: 100%;
        min-width: 320px;
        padding-bottom: 10px;
    }
    
    #table-container::-webkit-scrollbar {
        height: 6px;
    }
    
    #table-container::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 3px;
    }
    
    .element .symbol { font-size: 10px; }
    .element .name { display: none; }
    .element .number { font-size: 6px; }
    .element .state-indicator { width: 4px; height: 4px; }
    
    .controls { 
        flex-direction: column; 
        align-items: stretch;
        padding: 0 10px;
    }
    
    .controls input, .controls select, .controls button {
        width: 100%;
        padding: 12px;
        font-size: 14px;
    }
    
    .legend { 
        gap: 5px; 
        padding: 0 10px;
    }
    
    .legend-item { 
        font-size: 9px; 
        padding: 3px 6px;
    }
    
    .temp-slider-container {
        padding: 15px 10px;
        margin: 10px;
    }
    
    .temp-slider-container label { 
        display: block; 
        margin-bottom: 10px; 
    }
    
    #temp-slider { 
        width: 100%; 
        margin: 10px 0;
    }
    
    .state-legend { 
        display: flex;
        justify-content: center;
        margin-left: 0; 
        margin-top: 10px;
    }
    
    #element-info { 
        margin: 10px; 
        padding: 15px;
    }
    
    #element-info .detail-grid { 
        grid-template-columns: 1fr; 
        gap: 5px;
    }
    
    #element-info .detail-item { font-size: 12px; }
    
    #element-info .fun-fact { 
        font-size: 12px; 
        padding: 8px;
    }
    
    #compare-section, #calculator, #equation-balancer { 
        margin: 10px; 
        padding: 15px;
    }
    
    #compare-result { grid-template-columns: 1fr; }
    
    .compare-controls { 
        flex-direction: column; 
        gap: 10px;
    }
    
    .compare-controls select { 
        width: 100%; 
        min-width: unset;
    }
    
    #calculator input { 
        width: 100%; 
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    #calc-btn { 
        width: 100%; 
    }
    
    .modal-content { 
        padding: 20px; 
        margin: 10px;
        max-height: 90vh;
    }
    
    #quiz-options { 
        grid-template-columns: 1fr; 
    }
    
    #quiz-options button { 
        padding: 12px; 
    }
    
    .balancer-input { 
        flex-direction: column; 
        gap: 10px;
    }
    
    .balancer-input input { 
        width: 100%; 
    }
    
    .balancer-input .arrow { 
        transform: rotate(90deg); 
    }
    
    #balance-result .balanced-equation { 
        font-size: 16px; 
        padding: 10px;
        word-break: break-all;
    }
    
    #balance-result .element-count { 
        gap: 10px; 
    }
    
    #balance-result .count-item { 
        padding: 5px 10px; 
        font-size: 12px;
    }
    
    .example-equations { 
        padding-top: 15px; 
    }
    
    .example-btn { 
        padding: 10px 8px; 
        font-size: 11px;
        margin: 3px;
    }
}

@media (max-width: 480px) {
    body { padding: 5px; }
    
    h1 { font-size: 16px; margin-bottom: 10px; }
    
    .element { 
        border-radius: 2px; 
    }
    
    .element .symbol { font-size: 7px; }
    .element .number { font-size: 4px; top: 1px; left: 1px; }
    .element .state-indicator { width: 3px; height: 3px; bottom: 1px; right: 1px; }
    
    .legend { display: none; }
    
    .temp-slider-container { 
        margin: 5px;
        padding: 10px;
        font-size: 12px;
    }
    
    .state-legend { font-size: 10px; gap: 8px; }
    .solid-dot, .liquid-dot, .gas-dot { width: 8px; height: 8px; }
    
    #element-info { 
        margin: 5px; 
        padding: 12px;
        min-height: 100px;
    }
    #element-info h2 { font-size: 16px; }
    #element-info .detail-item { font-size: 11px; }
    #element-info .fun-fact { font-size: 11px; padding: 6px; }
    #element-info .wiki-link { font-size: 12px; }
    
    #compare-section, #calculator, #equation-balancer { 
        margin: 5px; 
        padding: 12px;
    }
    
    #compare-section h3, #calculator h3, #equation-balancer h3 {
        font-size: 14px;
        margin-bottom: 10px;
    }
    
    .compare-card { padding: 8px; }
    .compare-card h4 { font-size: 13px; }
    .compare-card p { font-size: 11px; }
    
    #calculator input { font-size: 14px; padding: 10px; }
    #calc-btn { font-size: 14px; padding: 10px; }
    #calc-result { font-size: 14px; }
    
    .balancer-input input { 
        font-size: 14px; 
        padding: 10px;
    }
    
    #balance-btn { 
        font-size: 14px; 
        padding: 10px 20px;
    }
    
    #balance-result { padding: 10px; }
    #balance-result .balanced-equation { 
        font-size: 12px;
        padding: 8px;
    }
    #balance-result .count-item { 
        padding: 4px 8px; 
        font-size: 10px;
    }
    #balance-result .success { font-size: 12px; }
    
    .example-equations p { font-size: 11px; }
    .example-btn { 
        display: block;
        width: 100%;
        margin: 4px 0;
        padding: 8px;
        font-size: 11px;
    }
    
    .modal-content { 
        padding: 15px; 
        margin: 5px;
        border-radius: 8px;
    }
    
    #quiz-question { font-size: 14px; margin-bottom: 15px; }
    #quiz-options button { padding: 10px; font-size: 12px; }
    #quiz-score { font-size: 14px; }
    
    .close-btn { font-size: 24px; top: 5px; right: 10px; }
}

@media (max-width: 360px) {
    h1 { font-size: 14px; }
    
    .element .symbol { font-size: 6px; }
    .element .number { display: none; }
    
    .controls input, .controls select, .controls button {
        padding: 10px;
        font-size: 12px;
    }
}

@media print {
    .controls, .temp-slider-container, #element-info, #compare-section, #calculator { display: none; }
    body { background: white; }
    .element:hover { transform: none; box-shadow: none; }
}


#equation-balancer {
    max-width: 700px;
    margin: 20px auto;
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

body.dark #equation-balancer {
    background: #2d2d44;
}

#equation-balancer h3 {
    margin-bottom: 20px;
    font-weight: normal;
    color: #2c3e50;
    text-align: center;
}

body.dark #equation-balancer h3 {
    color: #ecf0f1;
}

.balancer-input {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.balancer-input input {
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    width: 200px;
    transition: border-color 0.2s;
}

.balancer-input input:focus {
    outline: none;
    border-color: #3498db;
}

body.dark .balancer-input input {
    background: #1a1a2e;
    color: #eee;
    border-color: #444;
}

.balancer-input .arrow {
    font-size: 24px;
    color: #3498db;
}

#balance-btn {
    display: block;
    margin: 0 auto 20px;
    padding: 12px 30px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

#balance-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
}

#balance-result {
    text-align: center;
    padding: 20px;
    min-height: 60px;
}

#balance-result .balanced-equation {
    font-size: 24px;
    font-family: 'Courier New', monospace;
    color: #2c3e50;
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #2ecc71;
}

body.dark #balance-result .balanced-equation {
    background: #1a1a2e;
    color: #ecf0f1;
}

#balance-result .element-count {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 15px;
}

#balance-result .count-item {
    padding: 8px 15px;
    background: #ecf0f1;
    border-radius: 20px;
    font-size: 14px;
}

body.dark #balance-result .count-item {
    background: #1a1a2e;
    color: #bbb;
}

#balance-result .error {
    color: #e74c3c;
    font-size: 14px;
}

#balance-result .success {
    color: #2ecc71;
    font-weight: bold;
}

.example-equations {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

body.dark .example-equations {
    border-top-color: #444;
}

.example-equations p {
    color: #888;
    font-size: 13px;
    margin-bottom: 10px;
}

.example-btn {
    padding: 8px 12px;
    margin: 5px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.example-btn:hover {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

body.dark .example-btn {
    background: #1a1a2e;
    border-color: #444;
    color: #bbb;
}

body.dark .example-btn:hover {
    background: #3498db;
    color: white;
}


.tools-section {
    max-width: 900px;
    margin: 20px auto;
    padding: 20px;
}

.tools-section h3 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 20px;
    font-weight: normal;
}

body.dark .tools-section h3 {
    color: #ecf0f1;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.tool-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

body.dark .tool-card {
    background: #2d2d44;
}

.tool-card h4 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-weight: normal;
    font-size: 16px;
}

body.dark .tool-card h4 {
    color: #ecf0f1;
}

.tool-card input, .tool-card select {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

body.dark .tool-card input, body.dark .tool-card select {
    background: #1a1a2e;
    color: #eee;
    border-color: #444;
}

.tool-card button {
    width: 100%;
    padding: 10px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.tool-card button:hover {
    background: #2980b9;
}

.tool-formula {
    text-align: center;
    font-family: 'Courier New', monospace;
    color: #3498db;
    margin-bottom: 10px;
    font-size: 14px;
}

.dilution-inputs, .molarity-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.convert-arrow {
    display: block;
    text-align: center;
    color: #3498db;
    font-size: 20px;
    margin: 5px 0;
}

.ph-scale {
    margin-top: 15px;
    position: relative;
    height: 30px;
}

.ph-bar {
    height: 15px;
    border-radius: 8px;
    background: linear-gradient(to right, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #8b00ff);
}

.ph-marker {
    position: absolute;
    top: -5px;
    width: 4px;
    height: 25px;
    background: #333;
    border-radius: 2px;
    transition: left 0.3s;
    display: none;
}

.ph-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

body.dark .ph-labels {
    color: #aaa;
}

#ph-result, #dilution-result, #convert-result, #molarity-result {
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
    text-align: center;
    min-height: 20px;
    color: #2c3e50;
}

body.dark #ph-result, body.dark #dilution-result, body.dark #convert-result, body.dark #molarity-result {
    background: #1a1a2e;
    color: #ecf0f1;
}


#electron-viewer {
    max-width: 500px;
    margin: 20px auto;
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

body.dark #electron-viewer {
    background: #2d2d44;
}

#electron-viewer h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-weight: normal;
}

body.dark #electron-viewer h3 {
    color: #ecf0f1;
}

#electron-element-select {
    padding: 10px 20px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 20px;
}

body.dark #electron-element-select {
    background: #1a1a2e;
    color: #eee;
    border-color: #444;
}

.electron-display {
    position: relative;
    width: 280px;
    height: 280px;
    margin: 0 auto 20px;
}

.nucleus {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: radial-gradient(circle, #e74c3c, #c0392b);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    z-index: 10;
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.5);
}

.shells-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
}

.electron-shell {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px dashed #3498db;
    border-radius: 50%;
    animation: rotate 10s linear infinite;
}

.electron-shell:nth-child(2) { animation-duration: 8s; animation-direction: reverse; }
.electron-shell:nth-child(3) { animation-duration: 12s; }
.electron-shell:nth-child(4) { animation-duration: 15s; animation-direction: reverse; }

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

.electron {
    position: absolute;
    width: 12px;
    height: 12px;
    background: radial-gradient(circle, #3498db, #2980b9);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.8);
}

#electron-config-display {
    font-family: 'Courier New', monospace;
    color: #555;
    font-size: 14px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
}

body.dark #electron-config-display {
    background: #1a1a2e;
    color: #bbb;
}

#trends-section {
    max-width: 700px;
    margin: 20px auto;
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

body.dark #trends-section {
    background: #2d2d44;
}

#trends-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-weight: normal;
}

body.dark #trends-section h3 {
    color: #ecf0f1;
}

.trends-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.trend-btn {
    padding: 10px 20px;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

body.dark .trend-btn {
    background: #1a1a2e;
}

.trend-btn:hover, .trend-btn.active {
    background: #3498db;
    color: white;
}

.trend-arrows {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin: 20px 0;
    min-height: 100px;
}

.trend-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.trend-arrow .arrow-visual {
    font-size: 40px;
    color: #3498db;
}

.trend-arrow .arrow-label {
    font-size: 12px;
    color: #666;
}

body.dark .trend-arrow .arrow-label {
    color: #aaa;
}

.trend-explanation {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    color: #555;
    font-size: 14px;
    line-height: 1.6;
    text-align: left;
}

body.dark .trend-explanation {
    background: #1a1a2e;
    color: #bbb;
}

@media (max-width: 600px) {
    .tools-grid { grid-template-columns: 1fr; }
    .dilution-inputs, .molarity-inputs { grid-template-columns: 1fr; }
    .electron-display { width: 220px; height: 220px; }
    .nucleus { width: 40px; height: 40px; font-size: 12px; }
    .electron { width: 10px; height: 10px; }
    .trend-arrows { flex-direction: column; gap: 20px; }
    .trends-buttons { gap: 5px; }
    .trend-btn { padding: 8px 15px; font-size: 12px; }
}


.nav-link {
    display: inline-block;
    padding: 8px 12px;
    background: #9b59b6;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-size: 13px;
    transition: background 0.2s;
}

.nav-link:hover {
    background: #8e44ad;
}


.builder-link {
    background: #27ae60;
}

.builder-link:hover {
    background: #219a52;
}


#oxidation-finder {
    max-width: 700px;
    margin: 20px auto;
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

body.dark #oxidation-finder {
    background: #2d2d44;
}

#oxidation-finder h3 {
    text-align: center;
    color: #2c3e50;
    font-weight: normal;
    margin-bottom: 8px;
}

body.dark #oxidation-finder h3 {
    color: #ecf0f1;
}

.tool-subtitle {
    text-align: center;
    color: #888;
    font-size: 14px;
    margin-bottom: 20px;
}

.oxidation-input-row {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.oxidation-input-row input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
}

.oxidation-input-row input:focus {
    outline: none;
    border-color: #3498db;
}

body.dark .oxidation-input-row input {
    background: #1a1a2e;
    color: #eee;
    border-color: #444;
}

.oxidation-input-row button {
    padding: 12px 25px;
    background: #9b59b6;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.oxidation-input-row button:hover {
    background: #8e44ad;
}

#oxidation-result {
    min-height: 60px;
    margin-bottom: 20px;
}

#oxidation-result .compound-display {
    text-align: center;
    font-size: 28px;
    font-family: 'Courier New', monospace;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

body.dark #oxidation-result .compound-display {
    background: #1a1a2e;
}

#oxidation-result .oxidation-states {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
}

#oxidation-result .state-card {
    background: #f8f9fa;
    padding: 15px 25px;
    border-radius: 10px;
    text-align: center;
    min-width: 100px;
}

body.dark #oxidation-result .state-card {
    background: #1a1a2e;
}

#oxidation-result .state-card .element-sym {
    font-size: 24px;
    font-weight: bold;
    color: #2c3e50;
}

body.dark #oxidation-result .state-card .element-sym {
    color: #ecf0f1;
}

#oxidation-result .state-card .state-value {
    font-size: 20px;
    margin-top: 5px;
}

#oxidation-result .state-card .state-value.positive {
    color: #e74c3c;
}

#oxidation-result .state-card .state-value.negative {
    color: #3498db;
}

#oxidation-result .state-card .state-value.zero {
    color: #95a5a6;
}

#oxidation-result .verification {
    text-align: center;
    margin-top: 15px;
    padding: 10px;
    background: #d5f5e3;
    border-radius: 5px;
    color: #27ae60;
    font-size: 14px;
}

body.dark #oxidation-result .verification {
    background: #1e3a2f;
}

#oxidation-result .error {
    text-align: center;
    color: #e74c3c;
    padding: 15px;
}

.oxidation-examples {
    text-align: center;
    margin-bottom: 20px;
}

.oxidation-examples p {
    color: #888;
    font-size: 13px;
    margin-bottom: 10px;
}

.ox-example-btn {
    padding: 8px 15px;
    margin: 4px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    transition: all 0.2s;
}

.ox-example-btn:hover {
    background: #9b59b6;
    color: white;
    border-color: #9b59b6;
}

body.dark .ox-example-btn {
    background: #1a1a2e;
    border-color: #444;
    color: #bbb;
}

body.dark .ox-example-btn:hover {
    background: #9b59b6;
    color: white;
}

.oxidation-rules {
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 4px solid #9b59b6;
}

body.dark .oxidation-rules {
    background: #1a1a2e;
}

.oxidation-rules h4 {
    color: #2c3e50;
    font-weight: normal;
    margin-bottom: 10px;
    font-size: 14px;
}

body.dark .oxidation-rules h4 {
    color: #ecf0f1;
}

.oxidation-rules ul {
    margin-left: 20px;
    color: #666;
    font-size: 13px;
    line-height: 1.8;
}

body.dark .oxidation-rules ul {
    color: #aaa;
}

@media (max-width: 600px) {
    .oxidation-input-row {
        flex-direction: column;
    }
    
    .oxidation-input-row button {
        width: 100%;
    }
    
    #oxidation-result .compound-display {
        font-size: 20px;
    }
    
    #oxidation-result .state-card {
        min-width: 80px;
        padding: 10px 15px;
    }
    
    .ox-example-btn {
        padding: 10px 12px;
    }
}


.abundance-link {
    background: #e67e22;
}

.abundance-link:hover {
    background: #d35400;
}

.isotopes-link {
    background: #1abc9c;
}

.isotopes-link:hover {
    background: #16a085;
}

.safety-link {
    background: #e74c3c;
}

.safety-link:hover {
    background: #c0392b;
}

.solubility-link {
    background: #3498db;
}

.solubility-link:hover {
    background: #2980b9;
}


.games-link {
    background: #f39c12;
}

.games-link:hover {
    background: #d68910;
}


.gas-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.tool-hint {
    font-size: 11px;
    color: #888;
    text-align: center;
    margin-bottom: 10px;
}

.stoich-arrow {
    text-align: center;
    color: #3498db;
    font-size: 13px;
    margin: 8px 0;
}

.empirical-inputs {
    margin-bottom: 10px;
}

.empirical-row {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.empirical-row input {
    flex: 1;
}

#add-element-btn {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    background: #ecf0f1;
    border: 1px dashed #bdc3c7;
    border-radius: 5px;
    cursor: pointer;
    color: #7f8c8d;
    font-size: 13px;
}

body.dark #add-element-btn {
    background: #1a1a2e;
    border-color: #444;
    color: #888;
}

#add-element-btn:hover {
    background: #bdc3c7;
    color: #2c3e50;
}

body.dark #add-element-btn:hover {
    background: #444;
    color: #eee;
}

@media (max-width: 600px) {
    .gas-inputs {
        grid-template-columns: 1fr;
    }
    
    .empirical-row {
        flex-direction: column;
        gap: 5px;
    }
}
