body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* FIXED: Changed from 'overflow-x: hidden' to prevent the browser from clipping the scrollbar track */
    overflow-y: auto; 
    overflow-x: clip; 
    background-color: #ffffff;
    color: #121212;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- Dark Mode Default Variables --- */
body.dark-mode {
    background-color: #121214;
    color: #ffffff;
}

/* --- Navigation Bar --- */
.navigationtab {
     height: 50px;
     width: 100%;
     min-width: 500px;
     background-color: rgba(80, 168, 203, 0.579);
     display: flex;
     justify-content: flex-start;
     align-items: center;
}

/* Update your navigation tab to handle spacing for the button */
.navigationtab {
     height: 50px;
     width: 100%;
     min-width: 500px;
     background-color: rgba(80, 168, 203, 0.579);
     display: flex;
     justify-content: space-between; /* Pushes title to left and button to right */
     align-items: center;
}

/* Style the modern toggle button */
.toggle-btn {
    margin-right: 20px;
    padding: 8px 16px;
    font-family: "Comfortaa", sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    border: 2px solid #ffffff;
    border-radius: 20px;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Hover effect for the button */
.toggle-btn:hover {
    background-color: #ffffff;
    color: #50a8cb;
}

/* Adjust button look when dark mode is active */
body.dark-mode .toggle-btn {
    border-color: #ffffff;
    color: #ffffff;
}
body.dark-mode .toggle-btn:hover {
    background-color: #ffffff;
    color: #121214;
}

       
.thanimumtitle {
     margin-left: 20px;
     font-size: 25px;
     font-family: "Comfortaa", sans-serif;
     font-weight: 800;
}  

/* --- Periodic Table Grid --- */
/* --- Global Container Adjustment --- */
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* Prevents the whole page from breaking sideways */
}

/* --- Responsive Table Wrapper --- */
.table-container {
    width: 100%;
    overflow-x: auto; /* Crucial: Allows horizontal scrolling on small screens */
    padding: 10px;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS devices */
}

/* --- Optimized Grid Architecture (Compact Height) --- */
.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, minmax(55px, 1fr)); /* Tightened minimum card width */
    grid-auto-rows: minmax(48px, auto); /* Strict control over row heights */
    grid-gap: 4px; /* Reduced gap size to save space */
    width: max-content;
    margin: 0 auto;
    padding-bottom: 10px;
}

/* --- Compact Element Cell Styling --- */
.element {
    border: 1px solid #ccc;
    padding: 4px 2px;
    text-align: center;
    background-color: #f9f9f9;
    color: #121212;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Pushes content down slightly so everything fits */
    align-items: center;
    height: 56px; /* Increased slightly from 52px to guarantee the name fits */
    position: relative; /* Crucial: Allows absolute placement of the atomic number */
    box-sizing: border-box;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}


/* --- Absolute Placement for Atomic Number --- */
.atomic-number {
    font-size: 0.6rem;
    position: absolute;
    top: 2px;
    left: 4px;
    line-height: 1;
    color: #555;
}
body.dark-mode .atomic-number {
    color: #aaa;
}

/* --- Center Symbol --- */
.symbol {
    font-weight: bold;
    font-size: 1.1rem; /* Slightly smaller to leave room for the name below */
    display: block;
    margin-top: 8px; /* Creates space below the absolute atomic number */
    line-height: 1.1;
}

/* --- Visible Element Name --- */
.name {
    font-size: 0.55rem; /* Sized perfectly to remain legible */
    display: block;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Adds '...' if the name is too long for a tight box */
    color: #333;
    line-height: 1.2;
    margin-top: 1px;
}
body.dark-mode .name {
    color: #ccc;
}

/* --- Laptop / Desktop Screens Tweak --- */
@media screen and (min-width: 1200px) {
    .periodic-table {
        width: 100%;
        max-width: 1250px;
    }
    .element {
        height: 62px; /* Gives plenty of breathing room on large laptops */
        padding: 6px 3px;
    }
    .symbol {
        font-size: 1.2rem;
        margin-top: 6px;
    }
    .name {
        font-size: 0.62rem;
    }
}



/* --- Desktop Sizing Tweak (Overriding large limits) --- */
@media screen and (min-width: 1200px) {
    .periodic-table {
        width: 100%;
        max-width: 1250px;
        grid-auto-rows: minmax(54px, auto); /* Cleaner look for laptop layouts */
    }
    .element {
        padding: 5px 3px;
        height: 58px; /* Slightly taller on desktop, but still compact */
    }
}

/* --- Removing Lanthanide and Actinide Custom Spacing Offsets --- */
/* (We strip the old 15px margin-top to keep row 8 and row 9 perfectly snug) */
.la, .ce, .pr, .nd, .pm, .sm, .eu, .gd, .tb, .dy, .ho, .er, .tm, .yb, .lu {
    margin-top: 0 !important;
}



.element:hover {
    transform: scale(1.08);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    background-color: #ffffff !important; /* Forces clean hover state */
    border-color: #181818;
}



/* --- Light Mode Block Colors --- */
.s-block { background-color: rgba(238, 28, 28, 0.25); border-color: #ee1c1c; }
.p-block { background-color: rgba(107, 212, 112, 0.35); border-color: #4CAF50; }
.d-block { background-color: rgba(45, 55, 195, 0.2); border-color: #2d37c3; }
.f-block { background-color: rgba(255, 239, 161, 0.6); border-color: #d4b200; }

/* --- Dark Mode Block Colors (Fixes & Optimization) --- */
body.dark-mode .element {
    background-color: #222225;
    border-color: #444;
}
body.dark-mode .atomic-number { color: #aaa; }
body.dark-mode .name { color: #bbb; }

body.dark-mode .s-block { background-color: rgba(238, 28, 28, 0.4); }  
body.dark-mode .p-block { background-color: rgba(107, 212, 112, 0.4); }
body.dark-mode .d-block { background-color: rgba(45, 163, 195, 0.4); }  
body.dark-mode .f-block { background-color: rgba(255, 239, 161, 0.3); } 

body.dark-mode .element:hover {
    background-color: #ffffff !important;
    color: #000000 !important;
}
body.dark-mode .element:hover .atomic-number,
body.dark-mode .element:hover .name {
    color: #333333;
}

/* --- Precise Coordinate Placements --- */

/* Row 1 */
.h   { grid-column: 1;  grid-row: 1; }
.he  { grid-column: 18; grid-row: 1; }

/* Row 2 */
.li  { grid-column: 1;  grid-row: 2; }
.be  { grid-column: 2;  grid-row: 2; }
.b   { grid-column: 13; grid-row: 2; }
.c   { grid-column: 14; grid-row: 2; }
.n   { grid-column: 15; grid-row: 2; }
.o   { grid-column: 16; grid-row: 2; }
.f   { grid-column: 17; grid-row: 2; }
.ne  { grid-column: 18; grid-row: 2; }

/* Row 3 */
.na  { grid-column: 1;  grid-row: 3; }
.mg  { grid-column: 2;  grid-row: 3; }
.al  { grid-column: 13; grid-row: 3; }
.si  { grid-column: 14; grid-row: 3; }
.p   { grid-column: 15; grid-row: 3; }
.s   { grid-column: 16; grid-row: 3; }
.cl  { grid-column: 17; grid-row: 3; }
.ar  { grid-column: 18; grid-row: 3; }

/* Row 4 */
.k   { grid-column: 1;  grid-row: 4; }
.ca  { grid-column: 2;  grid-row: 4; }
.sc  { grid-column: 3;  grid-row: 4; }
.ti  { grid-column: 4;  grid-row: 4; }
.v   { grid-column: 5;  grid-row: 4; }
.cr  { grid-column: 6;  grid-row: 4; }
.mn  { grid-column: 7;  grid-row: 4; }
.fe  { grid-column: 8;  grid-row: 4; }
.co  { grid-column: 9;  grid-row: 4; }
.ni  { grid-column: 10; grid-row: 4; }
.cu  { grid-column: 11; grid-row: 4; }
.zn  { grid-column: 12; grid-row: 4; }
.ga  { grid-column: 13; grid-row: 4; }
.ge  { grid-column: 14; grid-row: 4; }
.as  { grid-column: 15; grid-row: 4; }
.se  { grid-column: 16; grid-row: 4; }
.br  { grid-column: 17; grid-row: 4; }
.kr  { grid-column: 18; grid-row: 4; }

/* Row 5 */
.rb  { grid-column: 1;  grid-row: 5; }
.sr  { grid-column: 2;  grid-row: 5; }
.y   { grid-column: 3;  grid-row: 5; }
.zr  { grid-column: 4;  grid-row: 5; }
.nb  { grid-column: 5;  grid-row: 5; }
.mo  { grid-column: 6;  grid-row: 5; }
.tc  { grid-column: 7;  grid-row: 5; }
.ru  { grid-column: 8;  grid-row: 5; }
.rh  { grid-column: 9;  grid-row: 5; }
.pd  { grid-column: 10; grid-row: 5; }
.ag  { grid-column: 11; grid-row: 5; }
.cd  { grid-column: 12; grid-row: 5; }
.in  { grid-column: 13; grid-row: 5; }
.sn  { grid-column: 14; grid-row: 5; }
.sb  { grid-column: 15; grid-row: 5; } /* Fixed duplicate row 2 assignment */
.te  { grid-column: 16; grid-row: 5; }
.i   { grid-column: 17; grid-row: 5; }
.xe  { grid-column: 18; grid-row: 5; }

/* Row 6 */
.cs  { grid-column: 1;  grid-row: 6; }
.ba  { grid-column: 2;  grid-row: 6; }
.lanthanides { grid-column: 3; grid-row: 6; }
.hf  { grid-column: 4;  grid-row: 6; }
.ta  { grid-column: 5;  grid-row: 6; }
.w   { grid-column: 6;  grid-row: 6; }
.re  { grid-column: 7;  grid-row: 6; }
.os  { grid-column: 8;  grid-row: 6; }
.ir  { grid-column: 9;  grid-row: 6; }
.pt  { grid-column: 10; grid-row: 6; }
.au  { grid-column: 11; grid-row: 6; }
.hg  { grid-column: 12; grid-row: 6; }
.tl  { grid-column: 13; grid-row: 6; }
.pb  { grid-column: 14; grid-row: 6; }
.bi  { grid-column: 15; grid-row: 6; }
.po  { grid-column: 16; grid-row: 6; }
.at  { grid-column: 17; grid-row: 6; }
.rd  { grid-column: 18; grid-row: 6; }

/* Row 7 */
.fr  { grid-column: 1;  grid-row: 7; }
.ra  { grid-column: 2;  grid-row: 7; }
.actinides { grid-column: 3; grid-row: 7; }
.rf  { grid-column: 4;  grid-row: 7; }
.db  { grid-column: 5;  grid-row: 7; }
.sg  { grid-column: 6;  grid-row: 7; }
.bh  { grid-column: 7;  grid-row: 7; }
.hs  { grid-column: 8;  grid-row: 7; }
.mt  { grid-column: 9;  grid-row: 7; }
.ds  { grid-column: 10; grid-row: 7; }
.rg  { grid-column: 11; grid-row: 7; }
.cn  { grid-column: 12; grid-row: 7; }
.nh  { grid-column: 13; grid-row: 7; }
.fl  { grid-column: 14; grid-row: 7; }
.mc  { grid-column: 15; grid-row: 7; }
.lv  { grid-column: 16; grid-row: 7; }
.ts  { grid-column: 17; grid-row: 7; }
.og  { grid-column: 18; grid-row: 7; }

/* --- Lanthanides Block (Row 8 Spacing) --- */
.la  { grid-column: 3;  grid-row: 8; margin-top: 15px; }
.ce  { grid-column: 4;  grid-row: 8; margin-top: 15px; }
.pr  { grid-column: 5;  grid-row: 8; margin-top: 15px; }
.nd  { grid-column: 6;  grid-row: 8; margin-top: 15px; }
.pm  { grid-column: 7;  grid-row: 8; margin-top: 15px; }
.sm  { grid-column: 8;  grid-row: 8; margin-top: 15px; }
.eu  { grid-column: 9;  grid-row: 8; margin-top: 15px; }
.gd  { grid-column: 10; grid-row: 8; margin-top: 15px; }
.tb  { grid-column: 11; grid-row: 8; margin-top: 15px; }
.dy  { grid-column: 12; grid-row: 8; margin-top: 15px; }
.ho  { grid-column: 13; grid-row: 8; margin-top: 15px; }
.er  { grid-column: 14; grid-row: 8; margin-top: 15px; }
.tm  { grid-column: 15; grid-row: 8; margin-top: 15px; }
.yb  { grid-column: 16; grid-row: 8; margin-top: 15px; }
.lu  { grid-column: 17; grid-row: 8; margin-top: 15px; }

/* --- Actinides Block (Row 9 Spacing) --- */
.ac  { grid-column: 3;  grid-row: 9; }
.th  { grid-column: 4;  grid-row: 9; }
.pa  { grid-column: 5;  grid-row: 9; }
.u   { grid-column: 6;  grid-row: 9; }
.np  { grid-column: 7;  grid-row: 9; }
.pu  { grid-column: 8;  grid-row: 9; }
.am  { grid-column: 9;  grid-row: 9; }
.cm  { grid-column: 10; grid-row: 9; }
.bk  { grid-column: 11; grid-row: 9; }
.cf  { grid-column: 12; grid-row: 9; }
.es  { grid-column: 13; grid-row: 9; }
.fm  { grid-column: 14; grid-row: 9; }
.md  { grid-column: 15; grid-row: 9; }
.no  { grid-column: 16; grid-row: 9; }
.lr  { grid-column: 17; grid-row: 9; }



/* ==========================================================================
   CLEAN & MODERN POP-UP MODAL DESIGN
   ========================================================================== */

/* The Dimmed Blurred Backdrop Wrapper */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(15, 17, 23, 0.4); /* Soft midnight tint */
    backdrop-filter: blur(8px); /* Elegant frosted glass blur */
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}


.modal-content {
    background-color: #ffffff;
    color: #1a1a1a;
    padding: 20px 20px; /* FIXED: Reduced to keep the popup short */
    border-radius: 16px; 
    width: 95%; 
    max-width: 420px; /* FIXED: Widened to fit side-by-side pairs perfectly */
    position: relative;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12); 
    border: 1px solid rgba(0, 0, 0, 0.05);
    animation: smoothModalUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Dark Mode Adaptation */
body.dark-mode .modal-content {
    background-color: #1e1e22;
    color: #f3f4f6;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Sleek Close Button */
.close-btn {
    position: absolute;
    top: 14px;
    right: 18px;
    font-size: 22px;
    font-weight: 300;
    color: #9ca3af;
    cursor: pointer;
    transition: color 0.15s ease;
    line-height: 1;
}
.close-btn:hover { 
    color: #ef4444; 
}

/* --- Clean Content Typography --- */
.modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Atomic Number Tag */
.modal-atomic-number {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #6b7280;
    text-transform: uppercase;
    margin-bottom: 8px;
}
body.dark-mode .modal-atomic-number {
    color: #9ca3af;
}

.modal-symbol { 
    font-size: 3.5rem; 
    margin: 0; 
    font-weight: 800; 
    letter-spacing: -0.02em;
    line-height: 1.1;
    
    /* FIXED: Explicitly sets a crisp standard font instead of inheriting Comfortaa */
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    
    background: linear-gradient(135deg, #111827, #4b5563);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.dark-mode .modal-symbol {
    background: linear-gradient(135deg, #ffffff, #9ca3af);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Clean Element Name */
.modal-name { 
    font-size: 1.4rem; /* FIXED: Scaled down slightly */
    margin: 2px 0 10px 0; /* FIXED: Compact margins to cut height */
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* Clean Minimal Divider Line */
.modal-body::after {
    content: "";
    width: 40px;
    height: 2px;
    background-color: rgba(0, 0, 0, 0.08);
    margin-bottom: 16px;
    border-radius: 2px;
}
body.dark-mode .modal-body::after {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Modern Pill Badge Group Text */
.modal-info { 
    font-size: 0.72rem; 
    font-weight: 700;
    color: #4b5563; 
    text-transform: uppercase; 
    letter-spacing: 0.08em;
    background-color: #f3f4f6; 
    padding: 6px 14px;
    border-radius: 20px;
    margin: 0;
    border: 1px solid rgba(0,0,0,0.03);
}
body.dark-mode .modal-info { 
    color: #d1d5db; 
    background-color: #2a2a30;
    border: 1px solid rgba(255,255,255,0.03);
}

/* Clean Easing Entry Animation */
@keyframes smoothModalUp {
    from { transform: scale(0.96) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

/* --- Info Data Grid Style --- */
.modal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    margin-top: 20px;
}

.grid-card {
    background-color: #f9fafb;
    border: 1px solid rgba(0, 0, 0, 0.05);
    padding: 6px 8px; /* FIXED: Tightened padding stops window card stretching */
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
body.dark-mode .grid-card {
    background-color: #27272a;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.grid-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #6b7280;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}
body.dark-mode .grid-label { color: #a1a1aa; }

.grid-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #111827;
}
body.dark-mode .grid-value { color: #f4f4f5; }

/* ADDED: Clean typography rules for the bottom Electron Configuration line */
#modal-configuration {
    font-family: monospace;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    word-break: break-all;
    text-align: center;
}


/* ==========================================================================
   SMOOTH CASCADING ENTRY ANIMATION LOGIC
   ========================================================================== */

/* Keeps items hidden downward by default */
.animate-item .grid-card {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
                transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Forces ALL grid cards to reveal smoothly when the modal opens */
.modal.active .animate-item .grid-card {
    opacity: 1;
    transform: translateY(0);
}

/* Extended sequential stagger delays up to 10 child entries */
.modal.active .animate-item .grid-card:nth-child(1) { transition-delay: 0.04s; }
.modal.active .animate-item .grid-card:nth-child(2) { transition-delay: 0.08s; }
.modal.active .animate-item .grid-card:nth-child(3) { transition-delay: 0.12s; }
.modal.active .animate-item .grid-card:nth-child(4) { transition-delay: 0.16s; }
.modal.active .animate-item .grid-card:nth-child(5) { transition-delay: 0.20s; }
.modal.active .animate-item .grid-card:nth-child(6) { transition-delay: 0.24s; }
.modal.active .animate-item .grid-card:nth-child(7) { transition-delay: 0.28s; }
.modal.active .animate-item .grid-card:nth-child(8) { transition-delay: 0.32s; }
.modal.active .animate-item .grid-card:nth-child(9) { transition-delay: 0.36s; }
.modal.active .animate-item .grid-card:nth-child(10) { transition-delay: 0.40s; }


/* Style adjustment for the complex scientific configuration text formatting */
#modal-configuration {
    font-family: monospace;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    word-break: break-all;
    text-align: center;
}
/* Interactive Color Preview Button Style */
.element-color-badge {
    margin-top: 4px;
    padding: 6px 12px;
    font-family: "Comfortaa", sans-serif;
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    background-color: #e5e7eb;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
}

.element-color-badge:hover {
    background-color: #d1d5db;
    transform: scale(1.03);
}

/* Enable hardware acceleration for fluid background transformations */
.modal-content {
    transition: background-color 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
                color 0.3s ease, 
                transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Styling for the new interactive Group Link Cards */
.group-link {
    background-color: rgba(255, 239, 161, 0.15) !important;
    border: 2px dashed #d4b200 !important;
    cursor: pointer;
    font-weight: bold;
}
body.dark-mode .group-link {
    background-color: rgba(255, 239, 161, 0.08) !important;
    border-color: #ffeb3b !important;
}

/* Dimming engine states triggered by JavaScript highlight filter toggles */
.periodic-table.dim-all .element {
    opacity: 0.25;
    transform: scale(0.96);
    filter: grayscale(80%);
    transition: all 0.3s ease;
}

/* rare metals in the periodic table*/
/* Force-keep highlighted rare metal rows fully active and glowing */
.periodic-table.highlight-lanthanides .la,
.periodic-table.highlight-lanthanides .ce,
.periodic-table.highlight-lanthanides .pr,
.periodic-table.highlight-lanthanides .nd,
.periodic-table.highlight-lanthanides .pm,
.periodic-table.highlight-lanthanides .sm,
.periodic-table.highlight-lanthanides .eu,
.periodic-table.highlight-lanthanides .gd,
.periodic-table.highlight-lanthanides .tb,
.periodic-table.highlight-lanthanides .dy,
.periodic-table.highlight-lanthanides .ho,
.periodic-table.highlight-lanthanides .er,
.periodic-table.highlight-lanthanides .tm,
.periodic-table.highlight-lanthanides .yb,
.periodic-table.highlight-lanthanides .lu,
.periodic-table.highlight-lanthanides .la-group-btn,
.periodic-table.highlight-actinides .ac,
.periodic-table.highlight-actinides .th,
.periodic-table.highlight-actinides .pa,
.periodic-table.highlight-actinides .u,
.periodic-table.highlight-actinides .np,
.periodic-table.highlight-actinides .pu,
.periodic-table.highlight-actinides .am,
.periodic-table.highlight-actinides .cm,
.periodic-table.highlight-actinides .bk,
.periodic-table.highlight-actinides .cf,
.periodic-table.highlight-actinides .es,
.periodic-table.highlight-actinides .fm,
.periodic-table.highlight-actinides .md,
.periodic-table.highlight-actinides .no,
.periodic-table.highlight-actinides .lr,
.periodic-table.highlight-actinides .ac-group-btn {
    opacity: 1 !important;
    transform: scale(1.06) !important;
    filter: grayscale(0%) !important;
    box-shadow: 0 0 12px rgba(212, 178, 0, 0.6);
    z-index: 5;
}

/* ==========================================================================
   MAIN PERIODIC TABLE HEADER TYPOGRAPHY
   ========================================================================== */
h1 {
    font-family: "Comfortaa", sans-serif;
    font-weight: 700; /* Crisp semi-bold layout weight */
    font-size: 2.2rem;
    letter-spacing: -0.02em; /* Sleek, tight modern spacing profile */
    text-transform: capitalize;
    margin-top: 24px;
    margin-bottom: 4px;
    
    /* Premium visual text gradient effect */
    background: linear-gradient(135deg, #111827, #4b5563);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Dark Mode Adaptation for Title Header */
body.dark-mode h1 {
    background: linear-gradient(135deg, #ffffff, #a1a1aa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Adaptive layout scaling rules for small smartphone screens */
@media screen and (max-width: 480px) {
    h1 {
        font-size: 1.55rem; /* Scales text down fluidly on phones to stop wrapping */
        margin-top: 16px;
        padding: 0 10px;
    }
}



/* ==========================================================================
   8. MODERN CENTRAL SEARCH BAR CONFIGURATION
   ========================================================================== */
/* Centers the search bar wrapper completely below your h1 title */
.search-bar-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 14px;
    margin-bottom: 16px;
    padding: 0 16px;
    box-sizing: border-box;
}

.search-container {
    position: relative;
    width: 100%;
    max-width: 380px; /* Expanded slightly for look balance beneath title */
}

#element-search {
    width: 100%;
    padding: 10px 16px; /* Increased padding slightly for a modern look */
    font-family: "Comfortaa", sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid #cccccc;
    border-radius: 24px;
    background-color: #f9fafb; /* Solid light tint profile for visibility */
    color: #121212;
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

#element-search::placeholder {
    color: #71717a;
}

#element-search:focus {
    background-color: #ffffff;
    border-color: #50a8cb;
    box-shadow: 0 4px 14px rgba(80, 168, 203, 0.2);
}

/* Dark Mode Search Override Attributes */
body.dark-mode #element-search {
    border-color: #444449;
    background-color: #1e1e22;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

body.dark-mode #element-search:focus {
    background-color: #27272a;
    border-color: #50a8cb;
    box-shadow: 0 4px 14px rgba(80, 168, 203, 0.15);
}

body.dark-mode #element-search::placeholder {
    color: #a1a1aa;
}

/* Dropdown Autocomplete Layout Panel */
.search-dropdown {
    position: absolute;
    top: 108%;
    left: 0;
    width: 100%;
    max-height: 240px;
    overflow-y: auto;
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 2000;
    display: none;
    box-sizing: border-box;
}

body.dark-mode .search-dropdown {
    background-color: #1e1e22;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Individual Search Match Items */
.search-item {
    padding: 11px 16px;
    font-family: "Comfortaa", sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    color: #1a1a1a;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    transition: background-color 0.15s ease;
}

body.dark-mode .search-item {
    color: #f3f4f6;
}

.search-item:hover {
    background-color: #f3f4f6;
}

body.dark-mode .search-item:hover {
    background-color: #2a2a30;
}

.search-item-symbol {
    color: #50a8cb;
    font-weight: 800;
}
/*mobile phones*/
/* ==========================================================================
   9. PERFECT FULL-SCREEN PHONE LAYOUT CONTROLS (< 480px)
   ========================================================================== */
@media screen and (max-width: 480px) {
    /* Tightens overall margins so elements can utilize every pixel of screen width */
    body {
        min-height: 100vh;
        overflow-x: hidden;
    }

    /* Sets up a clean layout that prevents awkward horizontal scrolling */
    .table-container {
        padding: 4px;
        overflow-x: hidden;
        width: 100%;
        box-sizing: border-box;
    }

    /* Structures cards into a tight 3-column system that fills the screen evenly */
    .periodic-table {
        display: grid;
        grid-template-columns: repeat(3, 1fr) !important;
        grid-auto-rows: auto !important;
        gap: 4px !important;
        width: 100% !important;
        max-width: 100% !important;
        padding-bottom: 8px; /* Zero large gaps at the bottom */
    }

    /* Redesigns each box into a space-efficient touch tile */
    .element {
        grid-column: auto !important;
        grid-row: auto !important;
        height: auto !important;
        min-height: 52px !important; 
        padding: 4px 6px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        border-radius: 6px !important;
        box-sizing: border-box !important;
    }

    /* Pins atomic numbers to the top corner to save text line space */
    .atomic-number {
        position: absolute !important;
        top: 2px !important;
        left: 4px !important;
        font-size: 0.55rem !important;
        font-weight: 700;
    }

    /* Centers chemical symbols perfectly inside each card */
    .symbol {
        font-size: 1.1rem !important;
        margin-top: 4px !important;
        line-height: 1 !important;
    }

    /* Auto-shrinks element names so long names never clip or distort the box shape */
    .name {
        font-size: 0.58rem !important;
        margin-top: 1px !important;
        width: 100%;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Safely drops layout items that break horizontal rules on screens of this size */
    .group-link, 
    .scroll-hint {
        display: none !important;
    }

    /* Adjusts the search box dynamically so it spans from edge to edge on devices */
    .search-bar-wrapper {
        padding: 0 8px;
        margin-bottom: 10px;
    }
    .search-container {
        max-width: 100%;
    }
    #element-search {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

  /* ==========================================================================
   11. MOBILE SCROLLABLE CONTENT WITH STICKY CLOSE BUTTON (< 480px)
   ========================================================================== */
@media screen and (max-width: 480px) {
    /* 1. Flex overlay keeps the modal box dead center on the phone screen */
    .modal {
        display: none;
        position: fixed; 
        z-index: 10000;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(15, 17, 23, 0.6);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

    /* 2. Restricts the popup box max height so it never leaks off screen edges */
    .modal-content {
        width: 90% !important;
        max-width: 340px !important;
        max-height: 82vh !important; /* FIXED: Caps height at 82% of screen height */
        padding: 0 !important; /* FIXED: Removed padding so items scroll cleanly edge-to-edge */
        border-radius: 16px !important;
        box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35) !important;
        display: flex !important;
        flex-direction: column !important;
        position: relative !important; /* Anchor for the sticky close button */
        overflow: hidden !important;
    }

    /* 3. 🌟 STICKY CLOSE BUTTON: Pinned to the top right corner of the box */
    .close-btn {
        position: absolute !important;
        top: 10px !important;
        right: 12px !important;
        font-size: 28px !important;
        font-weight: bold !important;
        color: #9ca3af;
        z-index: 10050 !important; /* Always sits on top of text */
        background-color: rgba(255, 255, 255, 0.9) !important; /* Subtle mask so it stands out */
        width: 36px;
        height: 36px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    body.dark-mode .close-btn {
        background-color: rgba(30, 30, 34, 0.9) !important;
        color: #f3f4f6;
    }

    /* 4. 🌟 SCROLLABLE CONTAINER: Allows scrolling inside the data elements card blocks */
    .modal-body {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        width: 100% !important;
        height: 100% !important;
        padding: 24px 14px 16px 14px !important; /* Restored padding natively inside scroll view box */
        overflow-y: auto !important; /* FIXED: Activates dynamic touch-drag scrolling tracking */
        -webkit-overflow-scrolling: touch; /* Smooth kinetic scrolling physics glide on iPhones */
        box-sizing: border-box !important;
    }

    /* Shrinks header elements so more data grid properties are visible on layout panels */
    .modal-symbol {
        font-size: 2.6rem !important;
    }

    .modal-name {
        font-size: 1.15rem !important;
        margin: 2px 0 6px 0 !important;
    }
}

/* ==========================================================================
   12. ULTRA-COMPACT CIRCULAR THEME TOGGLE FOR PHONES (< 480px)
   ========================================================================== */
@media screen and (max-width: 480px) {
    /* 1. Turns your wide button into a perfect circular touch widget */
    .toggle-btn {
        margin-right: 14px !important;
        padding: 0 !important;
        width: 38px !important; /* Pristine circular touch target boundaries */
        height: 38px !important;
        min-width: 38px !important;
        border-radius: 50% !important; /* Perfect circle edge loop curves */
        font-family: sans-serif !important; /* Standard cross-platform font structure */
        font-size: 1.25rem !important; /* Scales the emoji emblem perfectly */
        display: inline-flex !important;
        align-items: center !important;
        justify-content: flex-start !important; /* Keeps emoji anchored at the start */
        border: 2px solid rgba(255, 255, 255, 0.8) !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1) !important;
        cursor: pointer;
        box-sizing: border-box !important;
        
        /* 2. 🌟 THE FIX: Clips and hides the words "Dark Mode" / "Light Mode" 
              while keeping the first character (the emoji) beautifully visible! */
        overflow: hidden !important;
        white-space: nowrap !important;
        width: 38px !important;
        text-indent: 6px; /* Spaces the emoji neatly inside the circle button border */
    }

    /* Adjusts your navbar configurations so your new button sits cleanly aligned */
    .thanimumtitle {
        font-size: 20px !important;
        margin-left: 14px !important;
    }
    
    .navigationtab {
        min-width: 100% !important;
        height: 50px !important;
        box-sizing: border-box !important;
    }
}
