/* Base styles */
body, html {
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
    background-color: #f0f8ff;
    color: #333;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 10px;
}

h1 {
    text-align: center;
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #0056b3;
}

@media (max-width: 768px) {
    h1 {
        font-size: 2em;
        margin-bottom: 15px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }
}

/* Periodic table grid */
.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, minmax(0, 1fr));
    gap: 3px;
    background-color: #fff;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    width: 100%;
    box-sizing: border-box;
}

/* Element styling */
.element {
    aspect-ratio: 1;
    display: grid;
    grid-template-rows: auto 1fr auto;
    align-items: center;
    justify-items: center;
    border-radius: 5px;
    transition: all 0.3s ease;
    cursor: pointer;
    padding: 3x;
    font-size: 10px;
    position: relative;
    box-sizing: border-box;
    width: 100%;
    overflow: hidden;
}

.element.empty {
    background-color: transparent !important;
    cursor: default;
    pointer-events: none;
}

.element:not(.empty):hover {
    transform: scale(1.1);
    z-index: 1;
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
}

.symbol {
    font-size: 1em;
    font-weight: bold;
    text-align: center;
    width: 100%;
    margin: 0;
    margin-top: 3px;
    grid-row: 2;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: -0.1em;
}

.number {
    font-size: 0.9em;
    position: absolute;
    top: 2px;
    left: 2px;
    margin: 0;
    grid-row: 1;
}

.name {
    font-size: 0.75em;
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 2px;
    box-sizing: border-box;
    grid-row: 3;
    line-height: 1;
    margin-top: -0.1em;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: 10px;
    position: relative;
}

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

.close:hover {
    color: #000;
}

#showAtomButton {
    display: none;
    margin-top: 10px;
    padding: 8px 15px;
    background-color: #4CAF50;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
}

#showAtomButton:hover {
    background-color: #45a049;
}

/* Legend styles */
.legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
    background-color: #fff;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.legend-item {
    display: flex;
    align-items: center;
    margin: 5px 10px;
}

.legend-color {
    width: 20px;
    height: 20px;
    margin-right: 5px;
    border-radius: 3px;
}

/* Improved f-block element rows */
.f-block-container {
    grid-column: 1 / -1;
    margin-top: 15px;
    display: grid;
    grid-template-rows: auto auto;
    gap: 5px;
}

.f-block-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px;
    align-items: start;
}

.f-block-label {
    background-color: #f0f0f0;
    border-radius: 5px;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    min-width: 35px;
    font-size: 0.8em;
    height: fit-content;
}

.f-block-elements {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    gap: 2px;
    width: calc((100% / 18) * 15);
}

.f-block-elements .element {
    width: 100%;
    aspect-ratio: 1;
}

/* Additional Information Styles */
.additional-info {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.additional-info h3 {
    color: #0056b3;
    margin-bottom: 15px;
}

.additional-info ul {
    list-style-type: none;
    padding-left: 0;
}

.additional-info li {
    margin-bottom: 5px;
    padding: 5px;
    background-color: #f8f9fa;
    border-radius: 3px;
}

/* Responsive scaling */
@media screen and (min-width: 1440px) {
    .element {
        font-size: 16px;
    }
}

@media screen and (max-width: 1024px) {
    .element {
        font-size: 12px;
    }
}

@media screen and (max-width: 768px) {
    .element {
        font-size: 10px;
    }
}

@media screen and (max-width: 576px) {
    .element {
        font-size: 9px;
    }
}

@media screen and (max-width: 375px) {
    .element {
        font-size: 8px;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .element:not(.empty):hover {
        transform: none;
    }
    
    .element:not(.empty):active {
        transform: scale(1.05);
        background-color: rgba(255, 255, 255, 0.1);
    }
}

/* Version display */
.version-info {
    text-align: center;
    margin: 20px auto;
    padding: 10px;
    font-size: 0.8em;
    color: #888;
}

.version-number {
    font-weight: bold;
    color: #0056b3;
    text-decoration: none;
    cursor: pointer;
}

.version-number:hover {
    text-decoration: underline;
}

/* Changelog styles */
.changelog-entry {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.changelog-entry:last-child {
    border-bottom: none;
}

.changelog-entry h3 {
    margin: 0 0 10px 0;
    color: #333;
}

.changelog-version {
    color: #0056b3;
    margin-right: 10px;
}

.changelog-date {
    color: #666;
    font-size: 0.9em;
    font-weight: normal;
}

.changelog-changes {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}

.changelog-changes li {
    padding: 5px 0 5px 20px;
    position: relative;
}

.changelog-changes li:before {
    content: "•";
    position: absolute;
    left: 5px;
    color: #0056b3;
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    width: 300px;
    font-size: 14px;
}

.settings-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-header h2 {
    margin: 0;
    font-size: 1.2em;
    color: #333;
}

.settings-toggle {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    padding: 0;
}

.settings-content {
    display: none;
    padding: 15px;
    max-height: 80vh;
    overflow-y: auto;
}

.settings-content.visible {
    display: block;
}

.settings-section {
    margin-bottom: 20px;
}

.settings-section h3 {
    margin: 0 0 10px 0;
    font-size: 1em;
    color: #666;
}

.setting-control {
    margin-bottom: 10px;
}

.setting-control label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
    color: #555;
}

.setting-control input[type="range"] {
    width: 100%;
    margin: 5px 0;
}

.setting-control .value {
    font-size: 0.8em;
    color: #666;
    margin-left: 5px;
}

.settings-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.settings-actions button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

.save-settings {
    background-color: #4CAF50;
    color: white;
}

.save-settings:hover {
    background-color: #45a049;
}

.reset-settings {
    background-color: #f44336;
    color: white;
}

.reset-settings:hover {
    background-color: #da190b;
}

/* Responsive settings panel */
@media screen and (max-width: 768px) {
    .settings-panel {
        width: 100%;
        top: auto;
        bottom: 0;
        right: 0;
        border-radius: 8px 8px 0 0;
        max-height: 80vh;
    }

    .settings-content {
        max-height: 60vh;
    }
}