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

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

.container {
    max-width: 1400px;
    margin: 0 auto;
}

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

h1 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    background: linear-gradient(90deg, #00d4ff, #7b2cbf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

#searchInput {
    padding: 12px 20px;
    border: 2px solid #3a3a5c;
    border-radius: 25px;
    background: rgba(255,255,255,0.05);
    color: #fff;
    font-size: 1rem;
    width: 250px;
    outline: none;
    transition: all 0.3s ease;
}

#searchInput:focus {
    border-color: #00d4ff;
    background: rgba(255,255,255,0.1);
}

#searchInput::placeholder {
    color: #888;
}

#filterSelect {
    padding: 12px 20px;
    border: 2px solid #3a3a5c;
    border-radius: 25px;
    background: rgba(255,255,255,0.05);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
}

#filterSelect:focus {
    border-color: #00d4ff;
}

#filterSelect option {
    background: #1a1a2e;
    color: #fff;
}

.legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #ccc;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, 1fr);
    gap: 4px;
    max-width: 1200px;
    margin: 0 auto;
}

.element {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255,255,255,0.1);
    position: relative;
    font-size: 0.75rem;
    padding: 4px;
}

.element:hover {
    transform: scale(1.15);
    z-index: 10;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.element.hidden {
    display: none;
}

.element.dimmed {
    opacity: 0.2;
}

.element-number {
    font-size: 0.6rem;
    opacity: 0.8;
}

.element-symbol {
    font-size: 1.1rem;
    font-weight: bold;
    margin: 2px 0;
}

.element-name {
    font-size: 0.5rem;
    opacity: 0.9;
    text-align: center;
    line-height: 1.1;
}

.element-mass {
    font-size: 0.5rem;
    opacity: 0.7;
}

/* Element Type Colors */
.alkali-metal {
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
}

.alkaline-earth {
    background: linear-gradient(135deg, #ffa94d, #ff922b);
}

.transition-metal {
    background: linear-gradient(135deg, #ffd43b, #fcc419);
    color: #333;
}

.post-transition {
    background: linear-gradient(135deg, #69db7c, #51cf66);
    color: #333;
}

.metalloid {
    background: linear-gradient(135deg, #38d9a9, #20c997);
    color: #333;
}

.nonmetal {
    background: linear-gradient(135deg, #4dabf7, #339af0);
}

.halogen {
    background: linear-gradient(135deg, #da77f2, #cc5de8);
}

.noble-gas {
    background: linear-gradient(135deg, #9775fa, #845ef7);
}

.lanthanide {
    background: linear-gradient(135deg, #f06595, #e64980);
}

.actinide {
    background: linear-gradient(135deg, #ff8787, #ff6b6b);
}

/* 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);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    margin: 10% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    position: relative;
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.close:hover {
    opacity: 1;
}

.modal-element {
    text-align: center;
}

.modal-symbol {
    font-size: 4rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.modal-name {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: #00d4ff;
}

.modal-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    text-align: left;
}

.detail-item {
    background: rgba(255,255,255,0.05);
    padding: 12px;
    border-radius: 8px;
}

.detail-label {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.detail-value {
    font-size: 1.1rem;
    color: #fff;
}

/* Responsive */
@media (max-width: 1000px) {
    .periodic-table {
        grid-template-columns: repeat(18, minmax(35px, 1fr));
        gap: 2px;
    }
    
    .element {
        font-size: 0.6rem;
    }
    
    .element-symbol {
        font-size: 0.8rem;
    }
    
    .element-name,
    .element-mass {
        display: none;
    }
}

@media (max-width: 600px) {
    h1 {
        font-size: 1.5rem;
    }
    
    .legend {
        gap: 8px;
    }
    
    .legend-item {
        font-size: 0.7rem;
    }
    
    .periodic-table {
        gap: 1px;
    }
    
    .element-number {
        font-size: 0.4rem;
    }
    
    .element-symbol {
        font-size: 0.6rem;
    }
}
