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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #fff;
    min-height: 100vh;
    padding: 20px;
}

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

header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.2em;
    margin-bottom: 10px;
    opacity: 0.9;
}

.subtitle {
    font-size: 1em;
    opacity: 0.7;
    font-style: italic;
}

/* Search container styles */
.search-container {
    max-width: 800px;
    margin: 30px auto;
    padding: 0 20px;
}

.search-box {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

#search-input {
    flex: 1;
    max-width: 500px;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    transition: all 0.3s ease;
}

#search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

#search-input::placeholder {
    color: #666;
    font-style: italic;
}

#reset-button {
    padding: 12px 20px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 80px;
}

#reset-button:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#reset-button:active {
    transform: translateY(0);
}

/* Filtered/greyed out element styles */
.element.filtered-out {
    opacity: 0.3;
    pointer-events: none;
    cursor: not-allowed !important;
    transform: none !important;
    background: rgba(100, 100, 100, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.element.filtered-out:hover {
    transform: none !important;
    box-shadow: none !important;
    background: rgba(100, 100, 100, 0.2) !important;
}

/* Search result highlight */
.element.search-result {
    animation: searchPulse 1.5s ease-in-out;
    border-color: #f39c12 !important;
    box-shadow: 0 0 15px rgba(243, 156, 18, 0.4);
}

@keyframes searchPulse {
    0% { box-shadow: 0 0 15px rgba(243, 156, 18, 0.4); }
    50% { box-shadow: 0 0 25px rgba(243, 156, 18, 0.6); }
    100% { box-shadow: 0 0 15px rgba(243, 156, 18, 0.4); }
}

@media (max-width: 768px) {
    .search-box {
        flex-direction: column;
        gap: 15px;
    }
    
    #search-input {
        max-width: none;
        width: 100%;
    }
    
    #reset-button {
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }
}

.periodic-table {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 15px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.group-label {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: bold;
    font-size: 0.9em;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.element {
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    margin: 0 auto;
}

.element:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
    background: rgba(255, 255, 255, 0.2);
}

.element .symbol {
    font-size: 2.5em;
    font-weight: bold;
    margin-bottom: 5px;
}

.element .name {
    font-size: 0.9em;
    opacity: 0.8;
    text-align: center;
    word-wrap: break-word;
}

/* Group-specific colors */
.basic-element {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    border-color: #ff9ff3;
}

.navigation-element {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    border-color: #78e08f;
}

.remote-element {
    background: linear-gradient(135deg, #45b7d1, #3742fa);
    border-color: #70a1ff;
}

.history-element {
    background: linear-gradient(135deg, #f9ca24, #f0932b);
    border-color: #ffbe76;
}

.debugging-element {
    background: linear-gradient(135deg, #eb4d4b, #c44569);
    border-color: #ff7675;
}

.advanced-element {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    border-color: #fd79a8;
}

.collaboration-element {
    background: linear-gradient(135deg, #00b894, #00cec9);
    border-color: #55efc4;
}

.maintenance-element {
    background: linear-gradient(135deg, #fdcb6e, #e17055);
    border-color: #fab1a0;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    animation: fadeIn 0.3s ease;
}

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

.modal-content {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
}

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

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 20px;
    top: 20px;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #fff;
}

#modal-body h2 {
    color: #3498db;
    margin-bottom: 15px;
    font-size: 2.2em;
    display: flex;
    align-items: center;
    gap: 10px;
}

#modal-body .command-name {
    font-size: 1.2em;
    color: #2ecc71;
    margin-bottom: 10px;
    font-family: 'Courier New', monospace;
    background: rgba(0,0,0,0.3);
    padding: 8px 12px;
    border-radius: 5px;
    display: inline-block;
}

#modal-body .group-info {
    background: rgba(52, 152, 219, 0.2);
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    border-left: 4px solid #3498db;
}

#modal-body .reactivity-info {
    background: rgba(231, 76, 60, 0.2);
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    border-left: 4px solid #e74c3c;
}

#modal-body .description {
    line-height: 1.6;
    margin: 15px 0;
}

#modal-body .examples {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    overflow-x: auto;
}

#modal-body .examples pre {
    color: #2ecc71;
    margin: 5px 0;
    white-space: pre;
    overflow-x: auto;
    display: block;
}

#modal-body .doc-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

#modal-body .doc-footer a {
    display: inline-block;
    color: #3498db;
    text-decoration: none;
    font-weight: bold;
    padding: 10px 20px;
    background: rgba(52, 152, 219, 0.2);
    border-radius: 5px;
    transition: all 0.3s ease;
}

#modal-body .doc-footer a:hover {
    color: #fff;
    background: rgba(52, 152, 219, 0.4);
    transform: translateY(-2px);
}

footer {
    text-align: center;
    margin-top: 50px;
    opacity: 0.7;
    font-size: 0.9em;
}

footer p {
    margin: 5px 0;
}

/* Responsive design */
@media (max-width: 1024px) {
    .periodic-table {
        grid-template-columns: repeat(8, 1fr);
        gap: 12px;
    }
    
    .element {
        width: 100px;
        height: 100px;
    }
    
    .element .symbol {
        font-size: 2em;
    }
}

@media (max-width: 768px) {
    .periodic-table {
        grid-template-columns: repeat(6, 1fr);
        gap: 10px;
    }
    
    .element {
        width: 80px;
        height: 80px;
    }
    
    .element .symbol {
        font-size: 1.5em;
    }
    
    .element .name {
        font-size: 0.7em;
    }
    
    header h1 {
        font-size: 2em;
    }
}

@media (max-width: 480px) {
    .periodic-table {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .element {
        width: 70px;
        height: 70px;
    }
    
    .element .symbol {
        font-size: 1.2em;
    }
    
    .element .name {
        font-size: 0.6em;
    }
}

/* Reactivity indicator */
.reactivity-inert { border-left-color: #2ecc71 !important; }
.reactivity-stable { border-left-color: #f39c12 !important; }
.reactivity-reactive { border-left-color: #e67e22 !important; }
.reactivity-highly-reactive { border-left-color: #e74c3c !important; }
.reactivity-radioactive { border-left-color: #8e44ad !important; }

/* Legend styles */
.legend {
    max-width: 1200px;
    margin: 40px auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.legend h3 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5em;
    color: #fff;
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.legend-color {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.legend-item span {
    font-size: 1.1em;
    font-weight: 500;
}

.legend-note {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.legend-note p {
    font-size: 1em;
    color: #fff;
    text-align: center;
    margin: 0;
}

.legend-note strong {
    color: #ffbe76;
    font-size: 1.1em;
}

@media (max-width: 768px) {
    .legend-items {
        grid-template-columns: 1fr;
    }
    
    .legend-item {
        gap: 10px;
    }
    
    .legend-color {
        width: 30px;
        height: 30px;
    }
    
    .legend-item span {
        font-size: 1em;
    }
}