:root {
    --alkali-metal: #ff8a65;
    --alkaline-earth: #ffb74d;
    --transition-metal: #90caf9;
    --post-transition: #a5d6a7;
    --metalloid: #80deea;
    --nonmetal: #ef9a9a;
    --halogen: #ce93d8;
    --noble-gas: #9fa8da;
    --lanthanide: #b39ddb;
    --actinide: #f48fb1;
    --unknown: #e0e0e0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Roboto', Arial, sans-serif;
}

body {
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #333;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.view-toggle {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.view-toggle button {
    padding: 8px 16px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.view-toggle button.active {
    background-color: #2196F3;
    color: white;
}

.category-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 0.8rem;
    margin-bottom: 5px;
}

.legend-color {
    width: 16px;
    height: 16px;
    margin-right: 5px;
    border-radius: 2px;
}

#periodic-table {
    display: grid;
    grid-template-columns: repeat(18, 1fr);
    grid-gap: 3px;
    margin-bottom: 20px;
}

.placeholder {
    grid-column: span 1;
    visibility: hidden;
}

.lanthanide-actinide-row {
    margin-top: 20px;
}

#element-details {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 20px;
    margin-top: 30px;
    display: none;
}

#element-details.active {
    display: block;
}

.detail-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.detail-symbol {
    font-size: 3rem;
    font-weight: bold;
    margin-right: 20px;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: white;
}

.detail-title {
    flex-grow: 1;
}

.detail-title h2 {
    font-size: 2rem;
    margin-bottom: 5px;
}

.detail-title p {
    font-size: 1.2rem;
    color: #666;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    grid-gap: 20px;
    margin-bottom: 20px;
}

.detail-item {
    background-color: #f9f9f9;
    padding: 10px;
    border-radius: 4px;
}

.detail-item h3 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.detail-item p {
    font-size: 1.1rem;
    font-weight: bold;
}

.tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}

.tab.active {
    border-bottom-color: #2196F3;
    font-weight: bold;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.gradient-legend {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 10px 0 20px;
    padding: 10px;
    background-color: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    display: none;
}

.gradient-legend.active {
    display: flex;
}

.gradient-legend h3 {
    margin-bottom: 10px;
    font-size: 1rem;
}

.gradient-bar {
    width: 100%;
    height: 20px;
    background: linear-gradient(to right, #2196F3, #FFEB3B, #F44336);
    border-radius: 4px;
    margin: 0 10px;
}

.gradient-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 0.8rem;
    padding: 5px 10px 0;
}

@media (max-width: 768px) {
    #periodic-table {
        grid-gap: 2px;
    }
    
    .controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .category-legend {
        margin-top: 15px;
    }
    
    .detail-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 576px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-header {
        flex-direction: column;
        text-align: center;
    }
    
    .detail-symbol {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 5px;
    }
}

.element {
    background-color: white;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    aspect-ratio: 1/1;
}

.element:hover {
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.element.active {
    box-shadow: 0 0 0 3px #2196F3, 0 5px 15px rgba(0, 0, 0, 0.2);
}

.element-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px;
}

/* Prevent text overlap in different views */
.property-view .element .element-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    height: 100%;
}

.property-view .atomic-number {
    position: absolute;
    top: 3px;
    left: 3px;
    font-size: 0.6rem;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 1px 3px;
    border-radius: 2px;
}

.property-view .symbol {
    font-size: 1rem;
    margin-top: 5px;
    margin-bottom: 0;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 1px 5px;
    border-radius: 3px;
}

.property-view .name,
.property-view .mass {
    display: none;
}

.property-view .value {
    position: absolute;
    bottom: 5px;
    width: 100%;
    text-align: center;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 1px 0;
    border-radius: 2px;
}

/* When in standard view, show all details */
#periodic-table:not(.property-view) .element .name {
    display: block;
}

#periodic-table:not(.property-view) .element .mass {
    display: block;
}

.atomic-number {
    font-size: 0.7rem;
    position: absolute;
    top: 3px;
    left: 3px;
}

.symbol {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 2px;
}

.name {
    font-size: 0.55rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    max-width: 100%;
}

.mass {
    font-size: 0.6rem;
    color: #666;
    position: absolute;
    bottom: 3px;
    width: 100%;
    text-align: center;
}

@media (max-width: 991px) {
    .symbol {
        font-size: 1rem;
    }
    
    .name {
        font-size: 0.5rem;
    }
    
    .mass, .atomic-number {
        font-size: 0.5rem;
    }
}

@media (max-width: 767px) {
    .symbol {
        font-size: 0.9rem;
    }
    
    .name {
        display: none;
    }
}

@media (max-width: 576px) {
    .mass {
        display: none;
    }
    
    .symbol {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .atomic-number {
        font-size: 0.4rem;
    }
    
    .symbol {
        font-size: 0.7rem;
    }
}


/* General mobile responsiveness improvements */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    header p {
        font-size: 0.9rem;
    }
    
    .controls {
        gap: 10px;
    }
    
    .view-toggle {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 5px;
        justify-content: flex-start;
    }
    
    .view-toggle button {
        white-space: nowrap;
        padding: 6px 12px;
        font-size: 0.9rem;
    }
    
    .category-legend {
        flex-wrap: wrap;
        justify-content: flex-start;
        width: 100%;
    }
    
    .legend-item {
        margin-right: 10px;
        font-size: 0.75rem;
    }
    
    .element {
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    }
    
    .element:hover {
        transform: scale(1.03);
    }
    
    #element-details {
        padding: 15px;
        margin-top: 20px;
    }
    
    .detail-header {
        margin-bottom: 15px;
    }
    
    .tabs {
        margin-bottom: 15px;
    }
    
    .tab {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }
    
    header p {
        font-size: 0.8rem;
    }
    
    #periodic-table {
        grid-gap: 2px;
    }
    
    .element-inner {
        padding: 2px;
    }
    
    .atomic-number {
        font-size: 0.5rem;
    }
    
    .symbol {
        font-size: 0.8rem;
        margin-bottom: 0;
    }
    
    .detail-symbol {
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }
    
    .detail-title h2 {
        font-size: 1.5rem;
    }
    
    .detail-title p {
        font-size: 1rem;
    }
    
    .detail-item {
        padding: 8px;
    }
    
    .detail-item h3 {
        font-size: 0.8rem;
    }
    
    .detail-item p {
        font-size: 1rem;
    }
    
    .tab {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* Improvement for gradient legend */
.gradient-legend {
    padding: 8px;
    margin: 8px 0 15px;
}

.gradient-legend h3 {
    font-size: 0.9rem;
}

.gradient-bar {
    height: 15px;
}

.gradient-labels {
    font-size: 0.7rem;
}

/* Touch-friendly styles for all interactive elements */
button, .element, .tab, .orbital, .property-bar {
    -webkit-tap-highlight-color: transparent;
}

/* Add smooth scrolling for the entire page */
html {
    scroll-behavior: smooth;
}

/* Enhanced Responsive Design */
@media (max-width: 1200px) {
    .container {
        padding: 0 15px;
    }
    
    h1 {
        font-size: 2.2rem;
    }
}

@media (max-width: 991px) {
    h1 {
        font-size: 2rem;
    }
    
    .detail-header {
        margin-bottom: 15px;
    }
    
    .detail-symbol {
        width: 70px;
        height: 70px;
        font-size: 2.5rem;
    }
    
    .detail-title h2 {
        font-size: 1.8rem;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    h1 {
        font-size: 1.8rem;
        margin-bottom: 5px;
    }
    
    header p {
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
    
    .controls {
        margin-bottom: 15px;
    }
    
    .view-toggle button {
        padding: 6px 12px;
        font-size: 0.9rem;
    }
    
    .element {
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    .element:hover {
        transform: scale(1.03);
    }
    
    #element-details {
        padding: 15px;
    }
    
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-wrap: nowrap;
        padding-bottom: 5px;
    }
    
    .tab {
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

@media (max-width: 576px) {
    h1 {
        font-size: 1.5rem;
    }
    
    header p {
        font-size: 0.8rem;
    }
    
    #periodic-table {
        grid-gap: 1px;
    }
    
    .view-toggle {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 5px;
        margin-bottom: 8px;
        width: 100%;
    }
    
    .view-toggle button {
        padding: 5px 10px;
        font-size: 0.8rem;
        flex: 0 0 auto;
    }
    
    .legend-item {
        font-size: 0.7rem;
        margin-right: 8px;
        margin-bottom: 5px;
    }
    
    .legend-color {
        width: 12px;
        height: 12px;
    }
    
    .detail-symbol {
        width: 55px;
        height: 55px;
        font-size: 2rem;
    }
    
    .detail-title h2 {
        font-size: 1.4rem;
    }
    
    .detail-item h3 {
        font-size: 0.75rem;
    }
    
    .detail-item p {
        font-size: 0.9rem;
    }
    
    .tab {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    #periodic-table {
        grid-gap: 1px;
    }
    
    .element-inner {
        padding: 1px;
    }
    
    .symbol {
        font-size: 0.7rem;
    }
    
    .atomic-number {
        font-size: 0.4rem;
        top: 1px;
        left: 1px;
    }
    
    .tabs {
        margin-bottom: 12px;
    }
    
    .tab {
        padding: 5px 8px;
        font-size: 0.75rem;
    }
}

/* Fix for iOS Safari zoom issues on input focus */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    select,
    input {
        font-size: 16px;
    }
}

/* Improve touch interactions */
@media (pointer: coarse) {
    .element:hover {
        transform: none;
    }
    
    .element:active {
        transform: scale(1.03);
    }
    
    /* Increase tap target sizes */
    .tab, .view-toggle button {
        min-height: 40px;
    }
}

/* Dark Mode Styles */
.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
}

.dark-mode .container {
    background-color: #121212;
}

.dark-mode header h1 {
    color: #f0f0f0;
}

.dark-mode header p {
    color: #ccc;
}

.dark-mode .view-toggle button {
    background-color: #2d2d2d;
    border-color: #444;
    color: #ddd;
}

.dark-mode .view-toggle button.active {
    background-color: #2196F3;
    color: #fff;
    border-color: #2196F3;
}

.dark-mode .element {
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.dark-mode .element-inner {
    color: #ddd;
}

.dark-mode .mass {
    color: #aaa;
}

.dark-mode .legend-item {
    color: #ddd;
}

.dark-mode #element-details {
    background-color: #222;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.dark-mode .detail-title h2 {
    color: #f0f0f0;
}

.dark-mode .detail-title p {
    color: #aaa;
}

.dark-mode .detail-item {
    background-color: #2d2d2d;
}

.dark-mode .detail-item h3 {
    color: #aaa;
}

.dark-mode .detail-item p {
    color: #f0f0f0;
}

.dark-mode .tab {
    color: #ddd;
}

.dark-mode .tab.active {
    color: #2196F3;
    border-bottom-color: #2196F3;
}

.dark-mode .visualization {
    background-color: #2d2d2d;
}

.dark-mode #applications {
    background-color: #2d2d2d;
}

.dark-mode #applications h3 {
    color: #f0f0f0;
}

.dark-mode #applications-list li {
    background-color: #333;
}

.dark-mode .tab-content h3 {
    color: #f0f0f0;
    border-bottom-color: #444;
}

.dark-mode .tab-content p {
    color: #ccc;
}

.dark-mode #electron-config-detail, 
.dark-mode #hybridization-detail, 
.dark-mode #properties-detail {
    background-color: #2d2d2d;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.dark-mode .gradient-legend {
    background-color: #2d2d2d;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.dark-mode .modal {
    background-color: #222;
    color: #e0e0e0;
}

.dark-mode .modal h2 {
    color: #2196F3;
}

.dark-mode .modal h3 {
    color: #ccc;
}

.dark-mode .modal-close {
    color: #aaa;
}

.dark-mode .modal-close:hover {
    color: #fff;
}

.dark-mode .share-button {
    background-color: #333;
    color: #ddd;
}

.dark-mode .share-button:hover {
    background-color: #444;
}

.dark-mode #share-url {
    background-color: #333;
    color: #ddd;
    border-color: #444;
}

/* Search bar styles */
.search-bar {
    position: relative;
    max-width: 300px;
    margin: 0 auto 20px;
}

#element-search {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

#element-search:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.2);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.search-result-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: #f5f5f5;
}

.search-result-item .result-symbol {
    font-weight: bold;
    color: #2196F3;
    margin-right: 8px;
}

.search-result-item .result-number {
    float: right;
    color: #999;
    font-size: 0.8rem;
}

.search-result-item .result-category {
    font-size: 0.8rem;
    color: #666;
    margin-top: 3px;
}

.no-results {
    padding: 15px;
    text-align: center;
    color: #666;
}

/* Dark mode styles for search */
.dark-mode #element-search {
    background-color: #333;
    border-color: #444;
    color: #eee;
}

.dark-mode .search-results {
    background-color: #333;
}

.dark-mode .search-result-item {
    border-bottom-color: #444;
}

.dark-mode .search-result-item:hover {
    background-color: #444;
}

.dark-mode .search-result-item .result-category {
    color: #aaa;
}

.dark-mode .no-results {
    color: #aaa;
}

/* Make search responsive */
@media (max-width: 768px) {
    .search-bar {
        margin-bottom: 15px;
    }
}

@media (max-width: 480px) {
    .search-bar {
        max-width: 100%;
    }
    
    #element-search {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

/* Highlight pulse animation */
@keyframes highlight-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.7); }
    50% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(33, 150, 243, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(33, 150, 243, 0); }
}
 
.highlight-pulse {
    animation: highlight-pulse 1s ease-in-out;
    z-index: 10;
}

/* Modern Header Styling */
header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1rem 1rem;
    position: relative;
    overflow: hidden;
    border-radius: 1rem;
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.1), rgba(33, 150, 243, 0.05));
}

header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle at 20% 30%, rgba(33, 150, 243, 0.15) 0%, transparent 50%),
                      radial-gradient(circle at 80% 70%, rgba(156, 39, 176, 0.1) 0%, transparent 50%);
    z-index: -1;
}

h1 {
    font-size: 2.00rem;
    margin-bottom: 1rem;
    color: #1565C0;
    font-weight: 800;
    letter-spacing: -0.5px;
    position: relative;
    display: inline-block;
}

h1::after {
    content: "";
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, #1565C0, #2196F3);
    border-radius: 2px;
}

header p {
    font-size: 1.25rem;
    color: #546E7A;
    max-width: 600px;
    margin: 1.25rem auto 0;
    font-weight: 400;
    line-height: 1.5;
}

/* Modern View Toggle Buttons */
.view-toggle {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.view-toggle button {
    padding: 0.7rem 1.2rem;
    background-color: #ffffff;
    color: #455A64;
    border: none;
    border-radius: 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.view-toggle button::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, #1976D2, #2196F3);
    transition: width 0.25s ease;
    border-radius: 3px;
}

.view-toggle button:hover {
    background-color: #f5f9ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.15);
}

.view-toggle button:hover::before {
    width: 100%;
}

.view-toggle button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.1);
}

.view-toggle button.active {
    background-color: #1976D2;
    color: white;
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

.view-toggle button.active::before {
    width: 100%;
    background: linear-gradient(90deg, #135799, #1976D2);
}

/* Dark Mode Styling */
.dark-mode header {
    background: linear-gradient(135deg, rgba(25, 118, 210, 0.15), rgba(25, 118, 210, 0.05));
}

.dark-mode header::before {
    background-image: radial-gradient(circle at 20% 30%, rgba(33, 150, 243, 0.2) 0%, transparent 50%),
                      radial-gradient(circle at 80% 70%, rgba(156, 39, 176, 0.15) 0%, transparent 50%);
}

.dark-mode h1 {
    color: #64B5F6;
}

.dark-mode h1::after {
    background: linear-gradient(90deg, #42A5F5, #90CAF9);
}

.dark-mode header p {
    color: #B0BEC5;
}

.dark-mode .view-toggle button {
    background-color: #2c2c2c;
    color: #B0BEC5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.dark-mode .view-toggle button:hover {
    background-color: #383838;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dark-mode .view-toggle button::before {
    background: linear-gradient(90deg, #42A5F5, #64B5F6);
}

.dark-mode .view-toggle button.active {
    background-color: #1976D2;
    color: white;
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.2);
}

.dark-mode .view-toggle button.active::before {
    background: linear-gradient(90deg, #1565C0, #1976D2);
}

/* Responsive Styles */
@media (max-width: 768px) {
    h1 {
        font-size: 2.2rem;
    }
    
    header p {
        font-size: 1.1rem;
        padding: 0 1rem;
    }
    
    .view-toggle {
        justify-content: center;
        padding: 0 0.5rem;
    }
    
    .view-toggle button {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
        flex: 1 0 auto;
        min-width: 120px;
        max-width: 45%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.8rem;
    }
    
    h1::after {
        width: 40px;
        height: 3px;
    }
    
    header p {
        font-size: 0.95rem;
    }
    
    .view-toggle button {
        padding: 0.55rem 0.8rem;
        font-size: 0.85rem;
        min-width: 0;
        max-width: none;
        flex: 1 0 calc(50% - 0.5rem);
    }
}

/* Animation for Header (Optional) */
@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

h1 span {
    background: linear-gradient(90deg, #1976D2, #2196F3, #0D47A1, #1976D2);
    background-size: 300% 100%;
    animation: gradientFlow 8s ease infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    padding: 0 0.1em;
}

.dark-mode h1 span {
    background: linear-gradient(90deg, #42A5F5, #90CAF9, #2196F3, #42A5F5);
    background-size: 300% 100%;
    animation: gradientFlow 8s ease infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Standard view in dark mode */
.dark-mode #periodic-table:not(.property-view) .element {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dark-mode #periodic-table:not(.property-view) .element:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

.dark-mode #periodic-table:not(.property-view) .element .name,
.dark-mode #periodic-table:not(.property-view) .element .atomic-number {
    color: rgba(255, 255, 255, 0.9);
}

.dark-mode #periodic-table:not(.property-view) .element .mass {
    color: rgba(255, 255, 255, 0.7);
}

/* Property views in dark mode */
.dark-mode #periodic-table.property-view .element {
    background-color: #333;
}

.dark-mode #periodic-table.property-view .atomic-number {
    background-color: rgba(0, 0, 0, 0.2);
    color: rgba(255, 255, 255, 0.8);
}

.dark-mode #periodic-table.property-view .symbol {
    background-color: rgba(0, 0, 0, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

.dark-mode #periodic-table.property-view .value {
    background-color: rgba(0, 0, 0, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

/* Gradient legend for property views in dark mode */
.dark-mode .gradient-legend {
    background-color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.dark-mode .gradient-legend h3 {
    color: rgba(255, 255, 255, 0.9);
}

.dark-mode .gradient-bar {
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dark-mode .gradient-labels {
    color: rgba(255, 255, 255, 0.7);
}

/* Element cards in dark mode */
.dark-mode .element-inner {
    color: rgba(255, 255, 255, 0.9);
}

/* Theme Toggle Styling */
.theme-toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 30px;
    height: 30px;
}

.theme-icon {
    position: absolute;
    top: 0;
    left: 0;
    color: white;
    transition: transform 0.5s ease, opacity 0.5s ease;
}

.light-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.dark-icon {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.dark-mode .light-icon {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.dark-mode .dark-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

#theme-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
}

#theme-toggle:hover .theme-icon {
    color: rgba(255, 255, 255, 0.8);
}

.dark-mode #theme-toggle:hover .theme-icon {
    color: rgba(255, 255, 255, 0.8);
}