:root {
    --bg-primary: #0a0e27;
    --bg-secondary: #1a1f3a;
    --bg-tertiary: #2a2f4a;
    --text-primary: #e0e6ed;
    --text-secondary: #a0a6b0;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --border: #3a3f5a;
    --shadow: rgba(0, 0, 0, 0.3);
    
    /* Element colors */
    --alkali-metal: #ff6b6b;
    --alkaline-earth: #ffd93d;
    --transition-metal: #ffa07a;
    --post-transition: #95e1d3;
    --metalloid: #a8e6cf;
    --nonmetal: #c7ceea;
    --halogen: #ff9ff3;
    --noble-gas: #dda0dd;
    --lanthanide: #ffccbc;
    --actinide: #f8bbd0;
    
    /* Russell colors */
    --russell-generative: #ff6b4a;
    --russell-radiative: #4a9eff;
    --russell-inert: #ffd700;
    --russell-balance: #ffffff;
}

[data-theme="light"] {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8ecf1;
    --text-primary: #1a1f3a;
    --text-secondary: #5a5f7a;
    --accent: #4f46e5;
    --accent-hover: #6366f1;
    --border: #d0d5dd;
    --shadow: rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

/* Navigation */
.main-nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px var(--shadow);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.nav-container h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.hamburger {
    width: 25px;
    height: 3px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s;
}

.nav-toggle.active .hamburger:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.nav-toggle.active .hamburger:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active .hamburger:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

.nav-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-btn {
    padding: 0.5rem 1.5rem;
    border: 2px solid var(--border);
    background: transparent;
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s;
}

.nav-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.nav-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.theme-toggle {
    padding: 0.5rem;
    border: 2px solid var(--border);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    border-color: var(--accent);
    transform: rotate(20deg);
}

[data-theme="light"] .moon {
    display: none;
}

[data-theme="dark"] .sun,
body:not([data-theme]) .sun {
    display: none;
}

/* Main Content */
main {
    max-width: 100%;
    margin: 2rem auto;
    padding: 0 1rem;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* Info Panel */
.info-panel {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow);
    margin-bottom: 2rem;
}

.info-panel h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

.info-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.info-section h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.info-section p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.info-section ul {
    list-style: none;
    padding-left: 0;
}

.info-section li {
    color: var(--text-secondary);
    line-height: 1.8;
    padding-left: 1rem;
    position: relative;
}

.info-section li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--accent);
}

/* Filter Panel */
.filter-panel {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow);
    margin-bottom: 2rem;
}

.filter-panel h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

.filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.range-group {
    min-width: 250px;
}

.range-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.range-input {
    padding: 0.5rem;
    border: 2px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 0.9rem;
    width: 80px;
    transition: all 0.3s;
}

.range-input:hover {
    border-color: var(--accent);
}

.range-input:focus {
    outline: none;
    border-color: var(--accent);
}

.range-separator {
    color: var(--text-secondary);
    font-weight: 600;
}

.filter-select {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    min-width: 180px;
    transition: all 0.3s;
}

.filter-select:hover {
    border-color: var(--accent);
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
}

.reset-btn {
    padding: 0.5rem 1.5rem;
    border: 2px solid var(--border);
    background: var(--accent);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s;
}

.reset-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.filter-stats {
    margin-top: 1rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Classic Periodic Table */
.table-container {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow);
    margin-bottom: 2rem;
    overflow-x: auto;
    overflow-y: visible;
}

.table-wrapper {
    position: relative;
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 0.5rem;
    max-width: 100%;
}

.group-labels-container {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.period-spacer {
    /* Empty spacer to align with period labels */
}

.group-labels {
    display: grid;
    grid-template-columns: repeat(18, minmax(0, 1fr));
    gap: 3px;
    width: 100%;
}

.group-label {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
}

.table-with-periods {
    grid-column: 1 / -1;
    display: contents;
}

.period-labels {
    display: grid;
    grid-template-rows: repeat(7, 1fr);
    gap: 3px;
}

.period-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
}

.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, minmax(0, 1fr));
    gap: 3px;
    margin-bottom: 1rem;
    width: 100%;
}

.element {
    aspect-ratio: 1;
    border: 2px solid var(--border);
    border-radius: 6px;
    padding: 0.3rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    background: var(--bg-tertiary);
    font-size: 0.9em;
    min-width: 0;
    min-height: 0;
}

.element:hover {
    transform: scale(1.15);
    z-index: 10;
    box-shadow: 0 8px 16px var(--shadow);
}

.element .atomic-number {
    font-size: 0.65rem;
    color: #000;
    position: absolute;
    top: 2px;
    left: 4px;
}

.element .symbol {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0.2rem 0;
    color: #000;
}

.element .name {
    font-size: 0.55rem;
    color: #000;
    margin-top: 0.1rem;
    font-weight: 700;
}

.element .mass {
    font-size: 0.5rem;
    color: #000;
}

/* Element category colors */
.element.alkali-metal { background: var(--alkali-metal); color: #000; }
.element.alkaline-earth { background: var(--alkaline-earth); color: #000; }
.element.transition-metal { background: var(--transition-metal); color: #000; }
.element.post-transition { background: var(--post-transition); color: #000; }
.element.metalloid { background: var(--metalloid); color: #000; }
.element.nonmetal { background: var(--nonmetal); color: #000; }
.element.halogen { background: var(--halogen); color: #000; }
.element.noble-gas { background: var(--noble-gas); color: #000; }
.element.lanthanide { background: var(--lanthanide); color: #000; }
.element.actinide { background: var(--actinide); color: #000; }

/* Lanthanides and Actinides */
.lanthanides-actinides {
    margin-top: 1.5rem;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
    align-items: center;
}

.series-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
    text-align: right;
    padding-right: 0.5rem;
}

.series-row {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    gap: 4px;
}

/* Filtered out elements */
.element.filtered-out {
    opacity: 0.15;
    pointer-events: none;
    filter: grayscale(100%);
}

/* Legend */
.legend {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow);
}

.legend h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.legend-item.clickable {
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.legend-item.clickable:hover {
    background: var(--bg-tertiary);
    transform: translateX(5px);
}

.legend-item.clickable.active {
    background: var(--accent);
    color: white;
    font-weight: 600;
}

.color-box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* Russell Spiral View */
.russell-info {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow);
    margin-bottom: 2rem;
    text-align: center;
}

.russell-info h2 {
    margin-bottom: 0.75rem;
    font-size: 1.5rem;
}

.russell-info p {
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 800px;
    margin: 0 auto;
}

.russell-section {
    margin-bottom: 3rem;
}

.russell-section h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

.helix-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-style: italic;
}

.russell-container {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow);
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.helix-container {
    background: #ffffff;
    padding: 3rem 2rem;
    min-height: 1400px;
    position: relative;
}

[data-theme="dark"] .helix-container {
    background: #f8f8f8;
}

.russell-section h3 {
    text-align: center;
}

#russellSpiral {
    max-width: 100%;
    height: auto;
}

#russellHelix {
    max-width: 100%;
    height: auto;
}

.russell-element {
    cursor: pointer;
    transition: all 0.2s;
}

.russell-element:hover {
    transform: scale(1.2);
    filter: brightness(1.2);
}

.russell-element circle {
    transition: all 0.2s;
}

.russell-element:hover circle {
    stroke-width: 3;
}

.russell-legend {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow);
}

.russell-legend h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.russell-legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.russell-generative { background: var(--russell-generative); }
.russell-radiative { background: var(--russell-radiative); }
.russell-inert { background: var(--russell-inert); }
.russell-balance { background: var(--russell-balance); border: 2px solid #000; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
}

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

.close {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    font-size: 2rem;
    font-weight: 300;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close:hover {
    color: var(--text-primary);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    border-bottom: 1px solid var(--border);
}

.modal-symbol {
    font-size: 4rem;
    font-weight: 700;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 3px solid var(--border);
}

.modal-title h2 {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.modal-title p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.modal-body {
    padding: 2rem;
}

.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section h3 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    color: var(--accent);
}

.modal-section p {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.modal-section strong {
    color: var(--text-primary);
}

.russell-section {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--accent);
}

.wiki-link {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: background 0.2s;
}

.wiki-link:hover {
    background: var(--accent-hover);
}

/* Responsive Design */
@media (min-width: 769px) and (max-width: 1024px) {
    .tablet-tip {
        display: block;
    }
    
    .desktop-tip,
    .mobile-tip {
        display: none;
    }
}

@media (max-width: 1024px) {
    .periodic-table {
        gap: 2px;
    }
    
    .element {
        padding: 0.3rem;
    }
    
    .element .symbol {
        font-size: 1rem;
    }
    
    .element .name,
    .element .mass {
        font-size: 0.45rem;
    }
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }
    
    .nav-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .nav-container h1 {
        font-size: 1.2rem;
    }
    
    .nav-toggle {
        display: flex;
    }
    
    .nav-buttons {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
        padding-top: 1rem;
    }
    
    .nav-buttons.active {
        display: flex;
    }
    
    .nav-btn,
    .theme-toggle,
    .screensaver-controls {
        width: 100%;
    }
    
    .screensaver-controls {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .screensaver-toggle,
    .screensaver-speed {
        flex: 1;
    }
    
    main {
        padding: 0 0.5rem;
    }
    
    .info-content {
        grid-template-columns: 1fr;
    }
    
    .filter-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-select {
        width: 100%;
    }
    
    .range-group {
        width: 100%;
        min-width: auto;
    }
    
    .range-inputs {
        flex-wrap: wrap;
    }
    
    .range-input {
        flex: 1;
        min-width: 70px;
    }
    
    .table-container {
        padding: 0.5rem;
        overflow-x: auto;
        overflow-y: visible;
    }
    
    .table-wrapper {
        grid-template-columns: 30px 1fr;
        min-width: 600px;
    }
    
    .group-labels-container {
        grid-template-columns: 30px 1fr;
    }
    
    .period-label {
        font-size: 0.75rem;
    }
    
    .group-label {
        font-size: 0.75rem;
    }
    
    .periodic-table {
        min-width: auto;
    }
    
    .element {
        font-size: 0.8em;
        padding: 0.2rem;
        justify-content: space-between;
    }
    
    .element .atomic-number {
        font-size: 0.55rem;
        position: absolute;
        top: 2px;
        left: 2px;
    }
    
    .element .symbol {
        font-size: 0.9rem;
        position: absolute;
        bottom: 2px;
        right: 2px;
        margin: 0;
    }
    
    .element .name,
    .element .mass {
        display: none;
    }
    
    .series-row .element .symbol {
        display: none;
    }
    
    .series-row .element .atomic-number {
        position: static;
        font-size: 0.7rem;
    }
    
    .mobile-tip {
        display: block;
    }
    
    .tablet-tip,
    .desktop-tip {
        display: none;
    }
    
    .legend-grid,
    .russell-legend-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
    }
    
    .modal-header {
        flex-direction: column;
        text-align: center;
    }
    
    .screensaver-controls {
        flex-direction: column;
        width: 100%;
    }
    
    .screensaver-toggle,
    .screensaver-speed {
        width: 100%;
    }
}

/* Screensaver Styles */
.screensaver-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.screensaver-toggle {
    padding: 0.5rem 1.5rem;
    border: 2px solid var(--border);
    background: transparent;
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s;
}

.screensaver-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.screensaver-toggle.active {
    background: #dc2626;
    border-color: #dc2626;
    color: white;
    animation: pulse 2s infinite;
}

.screensaver-speed {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s;
}

.screensaver-speed:hover {
    border-color: var(--accent);
}

.screensaver-speed:focus {
    outline: none;
    border-color: var(--accent);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.element.screensaver-highlight {
    animation: highlightPulse 1.5s ease-in-out infinite;
    border: 3px solid #dc2626 !important;
    box-shadow: 0 0 20px rgba(220, 38, 38, 0.6) !important;
    z-index: 50 !important;
}

@keyframes highlightPulse {
    0%, 100% {
        transform: scale(1.2);
        box-shadow: 0 0 20px rgba(220, 38, 38, 0.6);
    }
    50% {
        transform: scale(1.25);
        box-shadow: 0 0 30px rgba(220, 38, 38, 0.8);
    }
}

.screensaver-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 999;
    display: none;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease-in;
}

.screensaver-overlay.fade-out {
    animation: fadeOut 0.5s ease-out;
}

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

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

.screensaver-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    max-height: 100vh;
    overflow: visible;
    width: 100%;
    max-width: 1600px;
}

.screensaver-number {
    font-size: 8rem;
    font-weight: 700;
    color: #fbbf24;
    text-shadow: 0 0 30px rgba(251, 191, 36, 0.5);
}

.screensaver-symbol {
    font-size: 12rem;
    font-weight: 900;
    color: #000;
    padding: 2rem 3rem;
    border-radius: 20px;
    border: 5px solid #fff;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    min-width: 250px;
    text-align: center;
}

.screensaver-info {
    background: var(--bg-secondary);
    padding: 2rem 3rem;
    border-radius: 16px;
    width: 95%;
    max-width: 1400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.screensaver-info h2 {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--accent);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.75rem;
    font-size: 1rem;
}

.info-grid > div {
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.info-grid strong {
    color: var(--accent);
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.fade-in {
    animation: fadeInScale 0.6s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Large screens - better utilize space */
@media (min-width: 1400px) {
    .info-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
        font-size: 1.05rem;
    }
    
    .screensaver-info {
        max-width: 1600px;
    }
}

@media (min-width: 1800px) {
    .info-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 768px) {
    .screensaver-content {
        padding: 1rem;
        gap: 1rem;
        justify-content: center;
    }
    
    .screensaver-number {
        font-size: 4rem;
    }
    
    .screensaver-symbol {
        font-size: 6rem;
        min-width: 120px;
        padding: 1rem 1.5rem;
    }
    
    .screensaver-info {
        padding: 1rem;
        max-width: 95%;
        width: 95%;
    }
    
    .screensaver-info h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .info-grid {
        grid-template-columns: 1fr 1fr;
        font-size: 0.85rem;
        gap: 0.5rem;
    }
    
    .info-grid > div {
        padding: 0.5rem;
    }
}

/* Filter Info */
.filter-info {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--accent);
}

.filter-info p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.filter-info kbd {
    background: var(--bg-primary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
}

.mobile-tip,
.tablet-tip {
    display: none;
}

.desktop-tip {
    display: block;
}

/* Saved Elements Toggle Button */
.saved-toggle {
    position: relative;
}

/* Saved Elements Dropdown Panel */
.saved-panel-dropdown {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 500px;
    max-height: 400px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 1000;
    display: none;
    flex-direction: column;
    animation: slideDown 0.3s ease-out;
}

.saved-panel-dropdown.active {
    display: flex;
}

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

.saved-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    border-radius: 12px 12px 0 0;
}

.saved-header h3 {
    font-size: 1rem;
    margin: 0;
    color: var(--text-primary);
}

.saved-actions {
    display: flex;
    gap: 0.5rem;
}

.saved-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.saved-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.saved-btn.close-btn {
    font-size: 1.5rem;
    padding: 0.2rem 0.6rem;
    line-height: 1;
}

.saved-btn.close-btn:hover {
    background: #dc2626;
}

.saved-list {
    padding: 1rem 1.5rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-content: flex-start;
}

.saved-empty {
    color: var(--text-secondary);
    font-style: italic;
    margin: 0;
}

.saved-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 2px solid var(--border);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.saved-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

.saved-number {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.saved-symbol {
    font-weight: 700;
    font-size: 1.1rem;
    color: #000;
}

.saved-name {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.remove-saved {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    margin-left: 0.5rem;
    line-height: 1;
    transition: all 0.2s;
}

.remove-saved:hover {
    color: #dc2626;
    transform: scale(1.2);
}

/* Save Notification */
.save-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    z-index: 1001;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.save-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.save-notification.success {
    background: #10b981;
    color: white;
}

.save-notification.warning {
    background: #f59e0b;
    color: white;
}

@media (max-width: 768px) {
    .saved-panel-dropdown {
        right: 10px;
        left: 10px;
        width: auto;
        max-height: 300px;
        top: 60px;
    }
    
    .saved-header {
        padding: 0.75rem 1rem;
    }
    
    .saved-header h3 {
        font-size: 0.9rem;
    }
    
    .saved-list {
        padding: 0.75rem 1rem;
    }
    
    .saved-item {
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
    }
    
    .save-notification {
        top: 60px;
        right: 10px;
        left: 10px;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

/* Quiz Mode Styles */
.quiz-toggle.active {
    background: #f59e0b;
    border-color: #f59e0b;
    color: white;
    animation: pulse 2s infinite;
}

.quiz-info {
    background: #fef3c7;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid #f59e0b;
}

[data-theme="dark"] .quiz-info {
    background: #78350f;
    border-left-color: #fbbf24;
}

.quiz-info p {
    margin: 0;
    color: #78350f;
    line-height: 1.6;
}

[data-theme="dark"] .quiz-info p {
    color: #fef3c7;
}

/* Quiz Mode Element States */
.element.quiz-mode {
    position: relative;
    cursor: pointer;
}

.element.quiz-mode::before {
    content: '?';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-secondary);
    opacity: 0.3;
    z-index: 1;
}

.element.quiz-mode .atomic-number,
.element.quiz-mode .symbol,
.element.quiz-mode .name,
.element.quiz-mode .mass {
    opacity: 0;
    visibility: hidden;
}

/* Quiz Reveal State 1: Show atomic number */
.element.quiz-mode.quiz-reveal-1 .atomic-number {
    opacity: 1;
    visibility: visible;
    animation: revealPop 0.3s ease-out;
}

/* Quiz Reveal State 2: Show atomic number + symbol */
.element.quiz-mode.quiz-reveal-2 .atomic-number,
.element.quiz-mode.quiz-reveal-2 .symbol {
    opacity: 1;
    visibility: visible;
    animation: revealPop 0.3s ease-out;
}

/* Quiz Reveal State 3: Show all */
.element.quiz-mode.quiz-reveal-3 .atomic-number,
.element.quiz-mode.quiz-reveal-3 .symbol,
.element.quiz-mode.quiz-reveal-3 .name,
.element.quiz-mode.quiz-reveal-3 .mass {
    opacity: 1;
    visibility: visible;
    animation: revealPop 0.3s ease-out;
}

.element.quiz-mode.quiz-reveal-3::before {
    display: none;
}

@keyframes revealPop {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Quiz mode hover effect */
.element.quiz-mode:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* Trends Panel */
.trends-panel-dropdown {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 600px;
    max-height: 600px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 1000;
    display: none;
    flex-direction: column;
    animation: slideDown 0.3s ease-out;
}

.trends-panel-dropdown.active {
    display: flex;
}

.trends-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    border-radius: 12px 12px 0 0;
}

.trends-header h3 {
    font-size: 1rem;
    margin: 0;
    color: var(--text-primary);
}

.trends-content {
    padding: 1.5rem;
    overflow-y: auto;
}

.trend-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.trend-btn {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

.trend-btn:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.trend-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.trend-legend {
    margin-bottom: 1.5rem;
}

.legend-title {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.legend-gradient {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.legend-min, .legend-max {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.gradient-bar {
    flex: 1;
    height: 30px;
    border-radius: 6px;
    background: linear-gradient(to right, 
        rgb(0, 0, 255),
        rgb(0, 255, 255),
        rgb(0, 255, 0),
        rgb(255, 255, 0),
        rgb(255, 0, 0)
    );
    border: 1px solid var(--border);
}

.trend-graph {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
}

.graph-title {
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
    color: var(--text-primary);
}

.graph-bars {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 150px;
    gap: 0.5rem;
}

.graph-bar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.graph-bar {
    width: 100%;
    background: var(--accent);
    border-radius: 4px 4px 0 0;
    transition: height 0.3s ease;
    min-height: 2px;
}

.graph-label {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Comparison Panel */
.compare-panel-dropdown {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    width: 900px;
    max-width: 95vw;
    max-height: 80vh;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 1000;
    display: none;
    flex-direction: column;
    animation: slideDown 0.3s ease-out;
}

.compare-panel-dropdown.active {
    display: flex;
}

.compare-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    border-radius: 12px 12px 0 0;
}

.compare-header h3 {
    font-size: 1rem;
    margin: 0;
    color: var(--text-primary);
}

.compare-content {
    padding: 1.5rem;
    overflow-y: auto;
}

.compare-instructions {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-style: italic;
}

.compare-display {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1.5rem;
    align-items: start;
}

.compare-slot {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 1.5rem;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compare-empty {
    color: var(--text-secondary);
    font-style: italic;
}

.compare-divider {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    padding: 1rem;
    display: flex;
    align-items: center;
}

.compare-card {
    width: 100%;
}

.compare-symbol {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    border-radius: 12px;
    border: 3px solid var(--border);
    color: #000;
}

.compare-card h3 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.compare-props {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.compare-prop {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.prop-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.prop-value {
    color: var(--text-primary);
    font-weight: 500;
}

.compare-toggle.active {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

/* Comparison Tooltip */
.compare-tooltip {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: #10b981;
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 999;
    display: none;
    animation: slideDown 0.3s ease-out;
}

.compare-tooltip.active {
    display: block;
}

.trends-toggle.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

@media (max-width: 768px) {
    .trends-panel-dropdown {
        right: 10px;
        left: 10px;
        width: auto;
        max-height: 70vh;
    }
    
    .trend-options {
        grid-template-columns: 1fr;
    }
    
    .compare-panel-dropdown {
        width: 95vw;
    }
    
    .compare-display {
        grid-template-columns: 1fr;
    }
    
    .compare-divider {
        transform: rotate(90deg);
        font-size: 1.5rem;
    }
}
