:root {
    --bg-color: #050505;
    --glass-bg: rgba(255, 255, 255, 0.06);
    --text-color: #fff;
    --neon-blue: #00f3ff;
    --neon-pink: #ff00de;
    --neon-green: #00ff41;
    --neon-yellow: #ffee00;
    --font-fa: 'Vazirmatn', sans-serif;
    --font-en: 'Orbitron', sans-serif;
    
    /* سایزهای بزرگتر شده برای خوانایی بهتر */
    /* 5.3vmin یعنی حدود 96% عرض صفحه پر میشود (18 ستون) */
    --cell-size: 5.3vmin; 
    --gap-size: 0.5vmin;
    --font-symbol: 1.6vmin;
    --font-name: 0.85vmin;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-fa);
}

/* تنظیمات انگلیسی */
body.lang-en {
    font-family: var(--font-en);
    direction: ltr;
    /* در انگلیسی هم سایز را بزرگ نگه میداریم اما فونت را تنظیم میکنیم */
    --cell-size: 5.1vmin; 
    --font-symbol: 1.4vmin;
    --font-name: 0.7vmin;
}

.main-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    padding: 10px;
}

header {
    flex: 0 0 auto;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    z-index: 10;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 98vw;
    margin: 0 auto;
}

.neon-title {
    font-size: 3.5vmin; /* تیتر بزرگتر */
    margin: 0;
    text-shadow: 0 0 10px var(--neon-blue);
    white-space: nowrap;
}

.controls { display: flex; gap: 10px; align-items: center; }

.neon-btn {
    background: transparent;
    color: var(--neon-blue);
    border: 1px solid var(--neon-blue);
    padding: 5px 15px;
    font-family: var(--font-en);
    cursor: pointer;
    border-radius: 5px;
    font-size: 1.5vmin;
    transition: 0.3s;
}
.neon-btn:hover { background: var(--neon-blue); color: #000; box-shadow: 0 0 15px var(--neon-blue); }

.search-box { position: relative; width: 20vw; max-width: 300px; }
#searchInput {
    width: 100%;
    padding: 5px 30px 5px 10px;
    border-radius: 20px;
    border: 1px solid var(--neon-pink);
    background: rgba(0,0,0,0.3);
    color: white;
    font-family: inherit;
    font-size: 1.5vmin;
    text-align: center;
}
.search-icon {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    font-size: 1.5vmin; color: var(--neon-pink);
}
body.lang-en .search-icon { right: 10px; left: auto; }

/* کانتینر جدول */
.table-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    overflow: hidden;
    position: relative;
}

.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, var(--cell-size));
    grid-auto-rows: var(--cell-size);
    gap: var(--gap-size);
    direction: ltr;
    margin: auto;
}

.element {
    background: var(--glass-bg);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    border-radius: 4px; /* گوشه‌های نرم‌تر */
    transition: 0.2s;
}

.element:hover {
    transform: scale(1.6); /* هاور بزرگتر برای نمایش بهتر */
    z-index: 100;
    background: #000;
    border-color: white;
    box-shadow: 0 0 20px currentColor;
}

.at-num {
    position: absolute; top: 2px; left: 3px;
    font-size: 0.9vmin; opacity: 0.7;
}

.symbol {
    font-size: var(--font-symbol);
    font-weight: bold;
    text-shadow: 0 0 5px currentColor;
    margin-bottom: 2px;
}

.name {
    font-size: var(--font-name);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    width: 98%;
    text-align: center;
}

/* رنگ‌ها */
.cat-alkali { color: var(--neon-pink); border-color: var(--neon-pink); }
.cat-alkaline { color: #ff6b6b; border-color: #ff6b6b; }
.cat-transition { color: var(--neon-yellow); border-color: var(--neon-yellow); }
.cat-basic { color: var(--neon-green); border-color: var(--neon-green); }
.cat-noble { color: var(--neon-blue); border-color: var(--neon-blue); }
.cat-other { color: #a29bfe; border-color: #a29bfe; }

/* فاصله لانتانیدها */
.element[style*="grid-row: 9"], .element[style*="grid-row: 10"] {
    margin-top: calc(var(--cell-size) * 0.4); /* فاصله بیشتر */
}

footer {
    flex: 0 0 auto; text-align: center;
    padding-top: 5px; font-size: 1.5vmin; color: #777;
}
.creator-link { color: var(--neon-green); text-decoration: none; }

/* مودال بزرگتر */
.modal {
    display: none; position: fixed; z-index: 1000;
    left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.92); backdrop-filter: blur(8px);
    justify-content: center; align-items: center;
}
.modal-content {
    background: #0d0d0d; border: 2px solid var(--neon-blue);
    box-shadow: 0 0 40px var(--neon-blue);
    width: 90%; max-width: 500px; /* مودال عریض‌تر برای متن طولانی */
    border-radius: 15px; padding: 30px;
    position: relative; color: white;
}
body.lang-fa .modal-content { direction: rtl; }
body.lang-en .modal-content { direction: ltr; }

.close-btn { position: absolute; top: 15px; inset-inline-end: 20px; font-size: 28px; cursor: pointer; color: #aaa; }
.modal-header { display: flex; align-items: center; gap: 20px; border-bottom: 1px solid #333; padding-bottom: 20px; margin-bottom: 20px; }
.element-symbol-large {
    font-size: 3.5rem; color: var(--neon-blue); border: 3px solid var(--neon-blue);
    width: 80px; height: 80px; display: flex; justify-content: center; align-items: center;
    border-radius: 12px; font-family: var(--font-en);
}
.info-row { display: flex; justify-content: space-between; margin-bottom: 10px; border-bottom: 1px dashed #333; padding-bottom: 5px; font-size: 1rem; }
.info-desc { margin-top: 20px; font-size: 0.95rem; line-height: 1.8; color: #ddd; text-align: justify; }

@media (max-width: 768px) {
    html, body { overflow-x: hidden; overflow-y: auto; }
    .main-wrapper { height: auto; min-height: 100vh; }
    .periodic-table {
        grid-template-columns: repeat(18, 45px);
        grid-auto-rows: 45px;
        overflow-x: auto;
    }
    .table-container { display: block; overflow-x: auto; }
    .neon-title { font-size: 2rem; }
}