:root {
    /* Premium Palette */
    --bg-deep: #000000;
    --bg-surface: #0a0a0d;
    
    /* Apple/Vercel-like Glass */
    --glass-panel: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.12);
    
    /* Typography */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --text-primary: rgba(255, 255, 255, 0.96);
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-tertiary: rgba(255, 255, 255, 0.3);
    
    /* Accents (Subtle) */
    --accent-blue: #3b82f6; 
    --accent-purple: #8b5cf6;
    --accent-glow: rgba(59, 130, 246, 0.5);

    /* Category Colors (Muted/Pastel for elegance) */
    --cat-alkali: #eab308;
    --cat-alkaline: #f97316;
    --cat-transition: #94a3b8;
    --cat-lanthanide: #ec4899;
    --cat-actinide: #d946ef;
    --cat-metalloid: #22d3ee;
    --cat-nonmetal: #4ade80;
    --cat-halogen: #a855f7;
    --cat-noble: #6366f1;
    --cat-unknown: #334155;

    /* Sizing */
    --card-size: 64px;
    --gap: 4px; /* Tighter interaction */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-main);
    width: 100vw;
    height: 100vh;
    overflow: hidden; /* App-like feel */
    display: flex;
    flex-direction: column;
}

/* --- Atmospheric Background --- */
.cosmos-bg {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: 
        radial-gradient(circle at 15% 50%, rgba(56, 189, 248, 0.03), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.03), transparent 25%);
    z-index: -2;
}

.ambient-light {
    position: fixed;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0IiBoZWlnaHQ9IjQiPgo8cmVjdCB3aWR0aD0iNCIgaGVpZ2h0PSI0IiBmaWxsPSIjZmZmIiBmaWxsLW9wYWNpdHk9IjAuMDIiLz4KPC9zdmc+');
    opacity: 0.3;
    z-index: -1;
    pointer-events: none;
}

/* --- Header --- */
.main-header {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 50;
    transition: all 0.3s ease;
}

.header-content {
    width: 95%;
    max-width: 1400px;
    min-height: 100px; /* Give it space */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: transparent;
    z-index: 50;
    margin-bottom: 20px; /* Space between header and grid */
}

/* Laptop Optimization (1366px and below) */
@media (max-width: 1366px) {
    .main-header {
        height: 70px; /* Slightly smaller header */
    }
    .logo-text h1 {
        font-size: 1.2rem;
    }
    .logo-tile {
        width: 40px;
        height: 40px;
    }
    .logo-symbol {
        font-size: 1rem;
    }
    .controls-container {
        gap: 10px;
    }
    #tempSlider {
        width: 200px; /* Smaller slider */
    }
}

/* Super Stylish Logo */
.logo-container {
    display: flex;
    align-items: center;
    gap: 16px;
}
/* ... existing logo styles ... */

/* ... */

.element-card:hover {
    transform: scale(1.3) translateY(-3px); /* Reduced movement (was 1.6 and -5px) */
    z-index: 100;
    filter: brightness(1.2); /* Add brightness instead of huge movement */
    background: rgba(30, 30, 35, 0.95);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 
        0 8px 25px -5px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.2);
}

.logo-tile {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.1));
    border: 1px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    border-radius: 4px;
}

.logo-number {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.5rem;
    color: var(--accent-blue);
}

.logo-symbol {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(180deg, #fff, #aaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-name {
    font-size: 0.4rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: -2px;
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 200;
    letter-spacing: 0.3em;
    color: var(--text-primary);
    line-height: 1;
}

.logo-text p {
    font-size: 0.6rem;
    letter-spacing: 0.4em;
    color: var(--accent-purple);
    margin-top: 4px;
    text-shadow: 0 0 10px rgba(139, 92, 246, 0.4);
}


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

.control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.lab-btn {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.1));
    border-color: rgba(16, 185, 129, 0.4);
    color: #34d399;
}

.lab-btn:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.4), rgba(5, 150, 105, 0.3));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.search-box input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    outline: none;
    width: 200px;
    transition: all 0.3s ease;
}

.search-box input:focus {
    width: 260px;
    border-color: var(--accent-blue);
    background: rgba(0, 0, 0, 0.5);
}

.menu-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Laptop/Mobile Micro-Polish */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 15px;
        height: auto;
        padding-bottom: 15px;
    }
    
    .logo-container {
        margin-bottom: 5px;
    }

    .controls-container {
        width: 100%;
        justify-content: space-between;
    }
    
    .search-box input {
        width: 100%; /* Expand on mobile */
    }
    
    .scientific-controls {
        bottom: 80px; /* Avoid mobile nav area if any */
        width: 90%;
        padding: 10px 15px;
        flex-wrap: wrap;
        justify-content: center;
    }
}

.state-indicators {
    display: flex;
    gap: 15px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.state-indicators span {
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid transparent;
}

/* Active State Styles */
.is-solid { border-color: #a8a8a8; color: #fff; }
.is-liquid { border-color: var(--accent-blue); color: var(--accent-blue); text-shadow: 0 0 5px var(--accent-blue); }
.is-gas { border-color: #eab308; color: #eab308; text-shadow: 0 0 5px #eab308; }


/* --- Advanced Element Card (Glossy V3) --- */
/* --- Advanced Element Card (God-Tier Holographic) --- */
.element-card {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 6px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-radius: 6px;
    overflow: hidden;
}

/* Internal Glass Edge Highlight */
.element-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    padding: 1px;
    background: linear-gradient(145deg, rgba(255,255,255,0.4), rgba(255,255,255,0.05) 50%, rgba(255,255,255,0));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* Spotlight Glow Effect (Controlled by JS) */
.element-card::after {
    content: '';
    position: absolute;
    inset: -1px;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(255,255,255,0.15), transparent 80%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 1;
}

.periodic-grid:hover .element-card::after {
    opacity: 1;
}

/* Hover State - 3D Lift & Bloom */
.element-card:hover {
    transform: translateY(-5px) scale(1.15) !important;
    z-index: 100 !important;
    background: rgba(40, 40, 50, 0.9);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 
        0 15px 35px rgba(0,0,0,0.5),
        0 0 20px rgba(var(--accent-rgb, 100,100,255), 0.3); /* Colored Bloom */
}

/* Hide ::after on hover to focus on the active card */
.element-card:hover::after {
    opacity: 0;
}

/* Laser Line Grouping (refined) */
.highlight-dim {
    opacity: 0.2 !important;
    filter: blur(2px) grayscale(80%);
    transform: scale(0.95);
}

.highlight-group {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
    border-color: rgba(255,255,255,0.3);
    z-index: 50;
}

/* State Change Visuals */
.element-card.melted {
    box-shadow: inset 0 0 20px rgba(59, 130, 246, 0.2);
}
.element-card.boiled {
    box-shadow: inset 0 0 20px rgba(234, 179, 8, 0.2);
    /* Subtle float animation for Gas */
    animation: floatGas 3s infinite ease-in-out;
}

@keyframes floatGas {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}
/* --- Compound Builder Panel --- */
.compound-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    background: rgba(10, 10, 15, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    backdrop-filter: blur(20px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.compound-panel.hidden {
    transform: translateY(120%);
    display: flex !important; /* Override generic hidden for transform anim */
}

.panel-header {
    background: rgba(255,255,255,0.05);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.panel-header h3 {
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    color: var(--accent-blue);
}

.builder-area {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.drop-zone {
    height: 150px;
    border: 2px dashed rgba(255,255,255,0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: rgba(0,0,0,0.2);
    transition: all 0.2s;
}

.drop-zone.drag-over {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
}

.atom-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    z-index: 2;
}

.mini-atom {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #fff;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

.result-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.compound-name {
    flex: 1;
    font-size: 1.2rem;
    color: #fff;
    font-family: monospace;
    min-height: 24px;
}

.close-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1.2rem;
}

/* Add a toggle button for the builder in controls */
.builder-toggle {
    background: var(--glass-panel);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.builder-toggle:hover {
    background: var(--glass-highlight);
}

.table-container {
    flex: 1;
    width: 100%;
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Start from LEFT so Group 1 is visible */
    justify-content: flex-start;
    padding: 20px;
    padding-left: 10px;
}

/* --- Hamburger Button --- */
.hamburger-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2000;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.hamburger-btn:hover {
    background: var(--glass-highlight);
    transform: scale(1.1);
}

/* --- Menu Overlay --- */
.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 10, 0.95);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.menu-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: all;
}

.close-menu-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 2rem;
    cursor: pointer;
}

.menu-content {
    width: 90%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.menu-title {
    font-size: 2rem;
    font-weight: 200;
    text-align: center;
    margin-bottom: 20px;
    letter-spacing: 0.1em;
}

.menu-section h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 10px;
}

.menu-input {
    width: 100%;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 1rem;
}

.filter-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.full-width {
    width: 100%;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 15px;
}

/* Hide elements when hidden helper */
.hidden {
    display: none !important; /* Force hide for logic */
    opacity: 0;
}
.menu-overlay.hidden {
    display: flex !important; /* Keep flex for transition */
    opacity: 0;
    pointer-events: none;
}

/* Grid System */
.periodic-grid {
    display: grid;
    grid-template-columns: repeat(18, var(--card-size));
    grid-template-rows: repeat(7, var(--card-size));
    gap: var(--gap);
    margin-bottom: var(--gap);
}

/* Lanthanoids / Actinoids separation */
.lanthanoids-grid, .actinoids-grid {
    display: grid;
    grid-template-columns: repeat(15, var(--card-size)); /* 57-71 = 15 elements */
    gap: var(--gap);
    margin-top: var(--gap);
    margin-left: calc(2 * (var(--card-size) + var(--gap))); /* Align with Group 3 */
}


/* --- Element Card (Premium) --- */
.element-card {
    width: var(--card-size);
    height: var(--card-size);
    background: var(--glass-panel);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.element-card:hover {
    /* Fixed: Reduced scale/translate for stability on laptops */
    transform: scale(1.3) translateY(-3px); 
    z-index: 100;
    filter: brightness(1.2); 
    background: rgba(30, 30, 35, 0.95);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 
        0 8px 25px -5px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.2);
}

/* Card Typography */
.element-number {
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 0.6rem;
    color: var(--text-tertiary);
    font-weight: 400;
}

.element-symbol {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    background: linear-gradient(180deg, #fff 0%, #ccc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.element-name {
    position: absolute;
    bottom: -20px;
    background: rgba(0,0,0,0.8);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.element-card:hover .element-name {
    opacity: 1;
    bottom: -25px;
}

/* Category Indicators (Subtle Bottom Bar) */
.element-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: currentColor;
    opacity: 0.6;
    border-bottom-left-radius: 3px;
    border-bottom-right-radius: 3px;
}


/* --- Modal (Holographic & Glassmorphism) --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(15px);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 2000px; /* Deep perspective for 3D tilt */
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    /* Holographic Card Base */
    background: linear-gradient(
        135deg, 
        rgba(255, 255, 255, 0.05) 0%, 
        rgba(255, 255, 255, 0.01) 100%
    );
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    border-radius: 32px;
    box-shadow: 
        0 50px 100px -20px rgba(0, 0, 0, 0.8),
        inset 0 0 50px rgba(255, 255, 255, 0.02);
    overflow: hidden;
    position: relative;
    transform-style: preserve-3d; /* Key for tilt */
    transform: rotateX(0) rotateY(0); /* Default state */
    transition: transform 0.1s ease-out; /* Super smooth movement */
    display: flex;
}

/* Modal Layout */
.modal-layout {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 2; /* Above any glows */
}

/* Atom Visual Area (Left) */
.atom-visual-container {
    flex: 1.2;
    background: radial-gradient(circle at center, rgba(30, 30, 40, 0.3), transparent 80%);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

#atomCanvas {
    width: 100%;
    height: 100%;
    position: relative;
    transform: translateZ(50px); /* Pop out 3D */
}

/* Stats HUD */
.electron-stats {
    position: absolute;
    bottom: 40px;
    left: 40px;
    display: flex;
    gap: 15px;
    transform: translateZ(30px);
}

.stat {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
}

.stat span:first-child {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.stat span:last-child {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-blue);
    font-family: monospace;
}

/* Info Area (Right) */
.element-info {
    flex: 1;
    padding: 60px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3); /* Slightly darker for readability */
    position: relative;
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

/* Typography Enhancements */
.element-meta {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 10px;
    transform: translateZ(20px);
}

.element-number { /* Modal specific override */
    position: static;
    font-size: 1.2rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: 50px;
}

.element-title {
    font-size: 5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(180deg, #ffffff 0%, rgba(255,255,255,0.4) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 20px;
    line-height: 0.9;
    text-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transform: translateZ(40px); /* Pop out more */
    display: flex; /* alignment */
    align-items: center;
    gap: 20px;
}

.audio-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    color: #fff;
    cursor: pointer;
    -webkit-text-fill-color: initial; /* Reset text gradient */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.audio-btn:hover {
    background: var(--accent-blue);
    transform: scale(1.1);
}

.element-desc {
    font-size: 1.15rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 40px;
    font-weight: 300;
    border-left: 2px solid var(--accent-blue);
    padding-left: 20px;
    transform: translateZ(20px);
}

/* Info Grid HUD Cards */
.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 40px;
    transform: translateZ(20px);
}

.info-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 24px;
    border-radius: 16px;
    transition: background 0.3s;
}

.info-card:hover {
    background: rgba(255, 255, 255, 0.07);
}

.info-card h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-purple);
    margin-bottom: 16px;
}

.info-card h3::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    box-shadow: 0 0 10px currentColor;
}

.info-card li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

/* Quiz Section (Minimal) */
.quiz-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--glass-border);
}

/* --- 3D Atom (CSS Refined) --- */
.atom-core {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 0 30px rgba(255,255,255,0.8);
    position: absolute;
    z-index: 10;
}

.electron-ring {
    border: 1px solid rgba(255, 255, 255, 0.15); /* Thinner lines */
    position: absolute;
    border-radius: 50%;
    transform-style: preserve-3d;
}

.electron {
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255,255,255,0.5); /* White glow */
    position: absolute; 
}

/* Cursor interaction */
.cursor-glow {
    display: none; /* Removed for cleaner look, or make very subtle */
}

/* Category mappings for colors via inline styles or JS classes */
.cat-alkali { color: var(--cat-alkali); }
.cat-alkaline-earth-metal { color: var(--cat-alkaline); }
.cat-transition-metal { color: var(--cat-transition); }
.cat-noble-gas { color: var(--cat-noble); }
.cat-reactive-nonmetal { color: var(--cat-nonmetal); }
.cat-metalloid { color: var(--cat-metalloid); }
.cat-post-transition-metal { color: var(--cat-metalloid); } /* Group similar */
.cat-lanthanide { color: var(--cat-lanthanide); }
.cat-actinide { color: var(--cat-actinide); }

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

/* --- Scientific Controls (Bottom Floating Bar) --- */
.scientific-controls {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 10, 12, 0.8);
    backdrop-filter: blur(20px);
    padding: 15px 30px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    z-index: 200;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    gap: 20px;
    align-items: center;
}

.temp-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

#tempSlider {
    width: 300px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

.state-indicators {
    display: flex;
    gap: 15px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.state-indicators span {
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid transparent;
}

/* Active State Styles */
.is-solid { border-color: #a8a8a8; color: #fff; }
.is-liquid { border-color: var(--accent-blue); color: var(--accent-blue); text-shadow: 0 0 5px var(--accent-blue); }
.is-gas { border-color: #eab308; color: #eab308; text-shadow: 0 0 5px #eab308; }


/* --- Advanced Element Card (Glossy V3) --- */
.element-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.01) 100%);
    box-shadow: 
        inset 1px 1px 0 rgba(255,255,255,0.1),
        inset -1px -1px 0 rgba(0,0,0,0.2); 
        /* Physical edge feel */
}

/* Smart Grouping (Laser Lines) */
/* Smart Grouping (Laser Lines) */
.highlight-dim {
    opacity: 0.4 !important; /* Visual improvement: Don't disappear completely */
    filter: grayscale(80%); /* Just de-saturate instead of blur */
    transform: scale(0.98);
}

.highlight-group {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
    border-color: rgba(255,255,255,0.3);
    z-index: 50;
}

/* State Change Visuals */
.element-card.melted {
    box-shadow: inset 0 0 20px rgba(59, 130, 246, 0.2);
}
.element-card.boiled {
    box-shadow: inset 0 0 20px rgba(234, 179, 8, 0.2);
    /* Subtle float animation for Gas */
    animation: floatGas 3s infinite ease-in-out;
}

@keyframes floatGas {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Atom Animation */
@keyframes spinOrbit {
    0% { transform: rotateX(var(--rx, 60deg)) rotateY(var(--ry, 60deg)) rotateZ(0deg); }
    100% { transform: rotateX(var(--rx, 60deg)) rotateY(var(--ry, 60deg)) rotateZ(360deg); }
}

/* Since we apply inline rotation, we need a way to maintain that 3d plane while spinning.
   Actually, the simple spinOrbit above might override inline styles.
   Let's use a preserv-3d spin wrapper or simplify.
   
   Better Approach for JS generated: 
   Let the JS set the static plane, and we just animate the Z rotation?
   No, electrons need to orbit. 
   
   Let's just define a generic spin that simply rotates the ring on its own Z axis (which is tilted).
*/

.electron-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Center it first? No, we set width/height */
    /* We need to center the ring itself in the canvas container */
    margin-left: calc(var(--size) / -2); /* JS needs to help or we use flex/grid center */
    /* script.js sets width/height usually. */
    /* Let's rely on flexbox centering in #atomCanvas and removing absolute positioning if possible,
       but rings are concentric. Absolute is best. */
    
    position: absolute; 
    /* The JS sets width/height, so let's center using margins or translate */
    transform-origin: center center;
    border: 1px solid rgba(255,255,255,0.3);
}

/* === CLOSE MODAL BUTTON === */
.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.close-modal:hover {
    background: rgba(239, 68, 68, 0.8);
    transform: rotate(90deg) scale(1.1);
    border-color: rgba(239, 68, 68, 0.5);
}

.close-modal:active {
    transform: scale(0.95);
}

/* === PREMIUM FOOTER === */
.app-footer {
    margin-top: 60px;
    margin-bottom: 30px;
    padding: 20px 30px;
    text-align: center;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.app-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-50%); }
    100% { transform: translateX(50%); }
}

.footer-brand {
    font-size: 0.9rem;
    font-weight: 600;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899, #3b82f6);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientFlow 4s ease infinite;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

@keyframes gradientFlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.footer-tagline {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 8px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    opacity: 0.7;
}

.footer-atoms {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 12px;
}

.footer-atom {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.footer-atom:nth-child(1) { background: #3b82f6; animation-delay: 0s; }
.footer-atom:nth-child(2) { background: #8b5cf6; animation-delay: 0.3s; }
.footer-atom:nth-child(3) { background: #ec4899; animation-delay: 0.6s; }

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.5); opacity: 1; }
}


/* ============================================= */
/* ===== RESPONSIVE DESIGN - MOBILE FIRST ===== */
/* ============================================= */

/* === TABLET (768px - 1024px) === */
@media (max-width: 1024px) {
    :root {
        --card-size: 56px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 12px;
        padding: 15px;
    }
    
    .controls-container {
        width: 100%;
        justify-content: center;
    }
}

/* === MOBILE (< 768px) === */
@media (max-width: 768px) {
    :root {
        --card-size: 44px;
        --gap: 2px;
    }
    
    body {
        overflow: auto; /* Allow scrolling on mobile */
    }
    
    /* Header - Stack vertically */
    .main-header {
        height: auto;
        padding: 10px 0;
    }
    
    .header-content {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
        min-height: auto;
        margin-bottom: 10px;
    }
    
    .logo-container {
        flex-direction: column;
        text-align: center;
    }
    
    .logo-tile {
        width: 50px;
        height: 50px;
    }
    
    .logo-text h1 {
        font-size: 1.2rem;
    }
    
    .controls-container {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .search-box input {
        width: 150px;
        font-size: 14px;
    }
    
    .lab-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    /* Grid - Enable horizontal scroll */
    .table-container {
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 10px;
    }
    
    .periodic-grid {
        min-width: calc(18 * (var(--card-size) + var(--gap)));
    }
    
    .lanthanoids-grid,
    .actinoids-grid {
        min-width: calc(15 * (var(--card-size) + var(--gap)));
        margin-left: calc(2 * (var(--card-size) + var(--gap)));
    }
    
    /* Element Cards - Smaller */
    .element-card {
        width: var(--card-size);
        height: var(--card-size);
    }
    
    .element-card:hover {
        transform: scale(1.15); /* Less aggressive on mobile */
    }
    
    .element-symbol {
        font-size: 0.9rem;
    }
    
    .element-number {
        font-size: 0.5rem;
        top: 2px;
        left: 3px;
    }
    
    /* Modal - Complete Mobile Overhaul */
    .modal-overlay {
        padding: 0;
        align-items: flex-start;
    }
    
    .modal-content {
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }
    
    .modal-layout {
        flex-direction: column;
        gap: 0;
        height: auto;
    }
    
    /* Atom section - compact on mobile */
    .atom-visual-container {
        width: 100%;
        height: 250px;
        min-height: 250px;
        flex-shrink: 0;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .electron-stats {
        bottom: 15px;
        left: 15px;
        gap: 10px;
    }
    
    .stat {
        padding: 6px 12px;
        font-size: 0.7rem;
    }
    
    .stat span:last-child {
        font-size: 0.85rem;
    }
    
    /* Info section - scrollable */
    .element-info {
        flex: 1;
        padding: 20px;
        overflow-y: auto;
        background: rgba(0, 0, 0, 0.5);
    }
    
    .element-title {
        font-size: 2.5rem;
        margin-bottom: 15px;
        gap: 15px;
        flex-wrap: wrap;
    }
    
    .audio-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .element-meta {
        flex-wrap: wrap;
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .element-desc {
        font-size: 1rem;
        line-height: 1.6;
        margin-bottom: 25px;
        padding-left: 15px;
    }
    
    .info-grid {
        gap: 15px;
        margin-bottom: 25px;
    }
    
    .info-card {
        padding: 15px;
    }
    
    .info-card h3 {
        font-size: 0.75rem;
        margin-bottom: 12px;
    }
    
    .info-card li {
        font-size: 0.9rem;
        padding: 6px 0;
    }
    
    /* Close button - more prominent */
    .close-modal {
        position: fixed;
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        background: rgba(0, 0, 0, 0.7);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 50%;
        font-size: 1.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1001;
        backdrop-filter: blur(10px);
    }
    
    /* Quiz section */
    .quiz-section {
        margin-top: 20px;
        padding-top: 20px;
    }
    
    /* Lab Panel - Mobile Optimized */
    .builder-panel,
    .compound-panel {
        height: 40vh;
        max-height: 350px;
    }
    
    .drop-zone {
        height: 80px;
    }
    
    .mini-atom {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
    }
    
    /* Floating Scientific Controls - Adjust */
    .scientific-controls {
        bottom: 15px;
        width: 95%;
        padding: 10px;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    #tempSlider {
        width: 120px;
    }
    
    /* Footer */
    .app-footer {
        margin-top: 20px;
        font-size: 0.65rem;
        padding: 10px;
    }
}

/* === SMALL MOBILE (< 480px) === */
@media (max-width: 480px) {
    :root {
        --card-size: 38px;
    }
    
    .logo-tile {
        width: 40px;
        height: 40px;
    }
    
    .logo-symbol {
        font-size: 1rem;
    }
    
    .logo-number, .logo-name {
        font-size: 0.4rem;
    }
    
    .logo-text h1 {
        font-size: 1rem;
    }
    
    .logo-text p {
        font-size: 0.5rem;
    }
    
    .search-box input {
        width: 120px;
    }
    
    .element-symbol {
        font-size: 0.8rem;
    }
    
    .properties-grid {
        grid-template-columns: 1fr;
    }
}

/* Touch feedback for mobile */
@media (hover: none) and (pointer: coarse) {
    .element-card:active {
        transform: scale(0.95);
        background: rgba(59, 130, 246, 0.2);
    }
    
    .element-card:hover {
        transform: none; /* Disable hover effects on touch */
        filter: none;
    }
    
    /* Lab mode indicator */
    .element-card.lab-active {
        animation: pulse 1s infinite;
    }
    
    @keyframes pulse {
        0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
        50% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    }
}
