body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 20px;
    background-color: #f8f8f8;
    color: #444;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.4;
    margin: 0;
}

h1 {
    color: #6a6a6a;
    margin-bottom: 20px;
    font-size: 2.5rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.05);
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    gap: 10px;
    width: 100%;
    max-width: 900px;
}

#searchInput {
    flex: 1;
    padding: 10px;
    border-radius: 0;
    border: 1px solid #ccc;
    min-width: 200px;
    font-size: 1rem;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

#searchInput:focus {
    outline: none;
    border-color: #999;
    box-shadow: 0 0 5px rgba(153, 153, 153, 0.2);
}

.controls button {
    padding: 10px 15px;
    border: none;
    border-radius: 0;
    background-color: #6a6a6a;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.controls button:hover {
    background-color: #444;
    transform: translateY(-2px);
}

#periodicTable {
    display: grid;
    grid-template-columns: repeat(18, 1fr);
    grid-auto-rows: 90px;
    gap: 6px;
    width: 100%;
    margin-top: 20px;
}

.element-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 5px;
    border-radius: 0;
    text-align: center;
    font-size: 11px;
    font-weight: bold;
    color: #444;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    position: relative;
}

.element-card:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.element-card strong {
    font-size: 1.5em;
    font-weight: 700;
}

.atomic-number {
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 0.8em;
    font-weight: normal;
}

.atomic-mass {
    font-size: 0.7em;
    margin-top: 5px;
    font-weight: normal;
}

#lanthanideActinideBlock {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    gap: 6px;
    width: calc(15 / 18 * 100%);
    margin-top: 30px;
    border-top: 2px solid #ddd;
    padding-top: 20px;
}

/* Colors based on user's request */
.alkali_metals { background-color: #f49306; }
.alkaline_earth_metals { background-color: #a5bb1a; }
.transition_metals { background-color: #dedde2; }
.post_transition_metals { background-color: #6db8be; }
.metalloids { background-color: #e0858e; }
.nonmetals { background-color: #9ec6aa; }
.halogens { background-color: #a7bd40; }
.noble_gases { background-color: #c7da91; }
.lanthanides { background-color: #b2c8e8; }
.actinides { background-color: #e8b2c8; }

.hidden {
    display: none;
}

.highlight {
    border: 2px solid #333;
    box-shadow: 0 0 10px #333;
}

/* Modal for element details */
.modal {
    position: fixed;
    z-index: 20;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
    display: none;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fefefe;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    animation-name: animatetop;
    animation-duration: 0.4s;
}

@keyframes animatetop {
    from { top: -300px; opacity: 0; }
    to { top: 0; opacity: 1; }
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-details h2 {
    font-size: 2rem;
    margin-bottom: 5px;
}

.modal-details p {
    margin: 5px 0;
}

@media (max-width: 768px) {
    #periodicTable {
        grid-auto-rows: 60px;
        gap: 4px;
    }
    .element-card {
        font-size: 9px;
    }
    .element-card strong {
        font-size: 1.2em;
    }
    .atomic-number {
        font-size: 0.7em;
    }
}
