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

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

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, rgba(120, 119, 198, 0.2) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

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

h1 {
    text-align: center;
    color: #fff;
    margin-bottom: 20px;
    font-size: 3rem;
    font-weight: 300;
    text-shadow: 0 0 20px rgba(120, 219, 255, 0.5);
    letter-spacing: 2px;
}

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

.search-input {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    padding: 12px 20px;
    color: #fff;
    font-size: 16px;
    width: 300px;
    transition: all 0.3s ease;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-input:focus {
    outline: none;
    border-color: rgba(120, 219, 255, 0.6);
    box-shadow: 0 0 20px rgba(120, 219, 255, 0.3);
}

.random-btn {
    background: linear-gradient(135deg, rgba(120, 219, 255, 0.3), rgba(255, 119, 198, 0.3));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    padding: 12px 24px;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.random-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(120, 219, 255, 0.3);
    background: linear-gradient(135deg, rgba(120, 219, 255, 0.4), rgba(255, 119, 198, 0.4));
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); box-shadow: 0 0 30px rgba(120, 219, 255, 0.8); }
}

.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 2px;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    max-width: 1400px;
    margin: 0 auto;
}

.element {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    font-size: 11px;
    color: #fff;
}

.element.empty {
    background: transparent;
    border: none;
    cursor: default;
}

.element.label {
    background: rgba(255, 255, 255, 0.05);
    cursor: default;
    font-style: italic;
    border: 1px dashed rgba(255, 255, 255, 0.3);
}

/* Element category colors with glow effects */
.element.alkali-metal { 
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.3), rgba(255, 107, 107, 0.1));
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.element.alkaline-earth-metal { 
    background: linear-gradient(135deg, rgba(254, 202, 87, 0.3), rgba(254, 202, 87, 0.1));
    box-shadow: 0 4px 15px rgba(254, 202, 87, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.element.transition-metal { 
    background: linear-gradient(135deg, rgba(72, 219, 251, 0.3), rgba(72, 219, 251, 0.1));
    box-shadow: 0 4px 15px rgba(72, 219, 251, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.element.post-transition-metal { 
    background: linear-gradient(135deg, rgba(255, 159, 243, 0.3), rgba(255, 159, 243, 0.1));
    box-shadow: 0 4px 15px rgba(255, 159, 243, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.element.metalloid { 
    background: linear-gradient(135deg, rgba(84, 160, 255, 0.3), rgba(84, 160, 255, 0.1));
    box-shadow: 0 4px 15px rgba(84, 160, 255, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.element.nonmetal { 
    background: linear-gradient(135deg, rgba(95, 39, 205, 0.4), rgba(95, 39, 205, 0.2));
    box-shadow: 0 4px 15px rgba(95, 39, 205, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.element.halogen { 
    background: linear-gradient(135deg, rgba(0, 210, 211, 0.3), rgba(0, 210, 211, 0.1));
    box-shadow: 0 4px 15px rgba(0, 210, 211, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.element.noble-gas { 
    background: linear-gradient(135deg, rgba(255, 99, 72, 0.3), rgba(255, 99, 72, 0.1));
    box-shadow: 0 4px 15px rgba(255, 99, 72, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.element.lanthanide { 
    background: linear-gradient(135deg, rgba(255, 234, 167, 0.3), rgba(255, 234, 167, 0.1));
    box-shadow: 0 4px 15px rgba(255, 234, 167, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    color: #fff;
}
.element.actinide { 
    background: linear-gradient(135deg, rgba(253, 121, 168, 0.3), rgba(253, 121, 168, 0.1));
    box-shadow: 0 4px 15px rgba(253, 121, 168, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.element:hover:not(.empty):not(.label) {
    transform: scale(1.05);
    border: 1px solid rgba(120, 219, 255, 0.6);
    z-index: 10;
}

@keyframes clickEffect {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.element .number {
    font-size: 8px;
    font-weight: bold;
    position: absolute;
    top: 1px;
    left: 2px;
}

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

.element .name {
    font-size: 8px;
    line-height: 1.1;
    margin-bottom: 2px;
    font-weight: 500;
}

.element .mass {
    font-size: 8px;
    font-weight: normal;
    position: absolute;
    bottom: 2px;
    right: 3px;
    opacity: 0.8;
}

.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(10px);
}

.modal-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    margin: 10% auto;
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: modalSlide 0.3s ease;
    color: #fff;
}

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

.close {
    color: rgba(255, 255, 255, 0.7);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 10px;
    transition: all 0.3s ease;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

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

.element-detail h2 {
    color: #fff;
    margin-bottom: 25px;
    font-size: 2.5rem;
    text-shadow: 0 0 20px rgba(120, 219, 255, 0.5);
    font-weight: 300;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.detail-item {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.detail-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.detail-item strong {
    color: rgba(120, 219, 255, 0.9);
    font-weight: 600;
}

@media (max-width: 1200px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 2rem;
        margin-bottom: 15px;
    }
    
    .controls {
        margin-bottom: 20px;
    }
    
    .search-input {
        width: 250px;
        font-size: 14px;
    }
    
    .periodic-table {
        padding: 15px;
        gap: 1px;
    }
    
    .element {
        min-height: 45px;
        padding: 2px;
    }
    
    .element .symbol {
        font-size: 12px;
    }
    
    .element .name {
        font-size: 6px;
    }
    
    .element .mass {
        font-size: 6px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    h1 {
        font-size: 1.5rem;
        margin-bottom: 10px;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        margin-bottom: 20px;
    }
    
    .search-input {
        width: 200px;
        font-size: 14px;
        padding: 10px 16px;
    }
    
    .random-btn {
        font-size: 14px;
        padding: 10px 20px;
    }
    
    .periodic-table {
        padding: 8px;
        gap: 0.5px;
        overflow-x: auto;
        min-width: 600px;
    }
    
    .element {
        min-height: 30px;
        padding: 1px;
        min-width: 30px;
    }
    
    .element .number {
        font-size: 6px;
    }
    
    .element .symbol {
        font-size: 8px;
        margin: 4px 0 1px 0;
    }
    
    .element .name {
        font-size: 4px;
        line-height: 0.9;
    }
    
    .element .mass {
        font-size: 4px;
    }
    
    .modal-content {
        margin: 5% auto;
        padding: 20px;
        width: 95%;
    }
}

/* Developer Credit Footer */
.developer-credit {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 10px;
}

.developer-credit p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    margin: 0;
}

.developer-credit a {
    color: rgba(120, 219, 255, 0.9);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.developer-credit a:hover {
    color: #fff;
    text-shadow: 0 0 10px rgba(120, 219, 255, 0.5);
}

@media (max-width: 768px) {
    .developer-credit {
        margin-top: 30px;
        padding: 15px;
    }
    
    .developer-credit p {
        font-size: 12px;
    }
}