* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

.container {
    max-width: 95vw;
    margin: 0 auto;
    padding: 20px;
}

/* Новый хедер с навигацией */
.project-header {
    background: #E4C1F9;
    color: black;
    padding: 15px 0;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.project-title {
    font-size: 1.8rem;
    font-weight: bold;
}

.project-nav {
    display: flex;
    gap: 15px;
}

.nav-btn {
    background: #D9A6F6;
    color: black;
    border: none;
    padding: 10px 20px; /* Увеличил отступы внутри кнопок */
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.nav-btn:hover {
    background: #D9A6F6;
    color: black;
    transform: translateY(-2px);
}

/* Элементы управления */
.controls {
    text-align: center;
    margin-bottom: 20px;
}

#search {
    padding: 10px;
    width: 300px;
    border: 2px solid #bdc3c7;
    border-radius: 4px;
    font-size: 1rem;
    margin-right: 10px;
}

#reset {
    padding: 10px 20px;
    background: #E4C1F9;
    color: black;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

#reset:hover {
    background: #D9A6F6;
    color: black;
    transform: translateY(-2px);

}

/* Периодическая таблица */
.periodic-table {
    display: grid;
    grid-template-columns: 40px repeat(18, 1fr); /* 1 колонка для номеров периодов + 18 для элементов */
    grid-template-rows: 30px repeat(7, 1fr) 5px repeat(3, 1fr); /* Сократил высоту разделительной строки с 10px до 5px */
    gap: 2px;
    margin: 20px auto;
    max-width: 90vw;
    aspect-ratio: 19 / 11;
}

/* Номера групп (верхняя строка) */
.group-number {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    color: #2c3e50;
    background: transparent;
}

/* Номера периодов (левый столбец) */
.period-number {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    color: #2c3e50;
    background: transparent;
}

/* Пустые ячейки для периодов в f-блоке */
.empty-period {
    background: transparent;
}

/* Пустой угол */
.empty-corner {
    background: transparent;
}

/* Строка-разделитель между основной таблицей и f-блоком */
.separator-row {
    background: transparent;
    height: 5px; /* Сократил высоту разделительной строки */
}

.element {
    border: none;
    border-radius: 4px;
    padding: 4px 2px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    font-size: 0.8rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.element.empty {
    background: transparent;
    cursor: default;
    box-shadow: none;
}

.element:hover:not(.empty) {
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Цвета блоков - фиолетовая градиентная палитра */
.s-block { background-color: #ff99c8; }
.p-block { background-color: #d0f4de; }
.d-block { background-color: #a9def9; }
.f-block { background-color: #fcf6bd; }

.element-number {
    font-size: 0.6rem;
    position: absolute;
    top: 2px;
    left: 4px;
    font-weight: bold;
}

.element-symbol {
    font-size: 1rem;
    font-weight: bold;
    margin: 2px 0;
}

.element-name {
    font-size: 0.55rem;
    margin-bottom: 1px;
}

.element-mass {
    font-size: 0.5rem;
    opacity: 0.9;
}

/* Легенда */
.legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-box {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 3px;
}

.s-block-color { background-color: #ff99c8; }
.p-block-color { background-color: #d0f4de; }
.d-block-color { background-color: #a9def9; }
.f-block-color { background-color: #fcf6bd; }

/* Модальное окно информации об элементе */
.element-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: relative;
    animation: modalOpen 0.3s ease;
}

@keyframes modalOpen {
    from {opacity: 0; transform: translateY(-50px);}
    to {opacity: 1; transform: translateY(0);}
}

.close-modal {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 28px;
    font-weight: bold;
    color: #7f8c8d;
    cursor: pointer;
    z-index: 1001;
}

.close-modal:hover {
    color: #2c3e50;
}

.element-info {
    padding: 30px;
    min-height: 200px;
}

.info-placeholder {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 60px 20px;
}

.element-details h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 10px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.detail-item {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.detail-item strong {
    color: #2c3e50;
    display: block;
    margin-bottom: 5px;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.element-details {
    max-height: 70vh;
    overflow-y: auto;
}

/* Большие модальные окна */
.large-modal .modal-content {
    max-width: 1000px; /* Увеличил размер больших модальных окон */
    max-height: 85vh; /* Увеличил высоту */
}

.modal-body {
    max-height: 70vh; /* Увеличил высоту содержимого */
    overflow-y: auto;
    padding: 30px; /* Увеличил отступы внутри модальных окон */
    line-height: 1.6;
}

.modal-body h1, .modal-body h2, .modal-body h3 {
    color: #2c3e50;
    margin: 20px 0 10px 0;
}

.modal-body h1 {
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 10px;
}

.modal-body ul, .modal-body ol {
    margin: 10px 0 10px 20px;
}

.modal-body li {
    margin: 5px 0;
}

.modal-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.modal-body th, .modal-body td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.modal-body th {
    background-color: #f8f9fa;
}

/* Адаптивность */
@media (max-width: 1200px) {
    .periodic-table {
        gap: 1px;
        max-width: 95vw;
    }

    .element {
        padding: 3px 1px;
        font-size: 0.7rem;
    }

    .element-symbol {
        font-size: 0.9rem;
    }

    .element-number {
        font-size: 0.5rem;
    }

    .element-name {
        font-size: 0.5rem;
    }

    .element-mass {
        font-size: 0.45rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .project-title {
        font-size: 1.5rem;
    }
    
    .project-nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    #search {
        width: 200px;
    }

    .periodic-table {
        grid-template-columns: 30px repeat(9, 1fr);
        aspect-ratio: auto;
    }

    .legend {
        flex-direction: column;
        align-items: center;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
    }

    .group-number, .period-number {
        font-size: 0.8rem;
    }
}

footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #ecf0f1;
    color: #7f8c8d;
    font-size: 0.9rem;
}

footer p {
    margin: 5px 0;
}
