:root {
    --bg-dark: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --accent-blue: #00d4ff;
    --accent-purple: #9d4edd;
    --accent-green: #10b981;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border-color: #333;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a0033 50%, var(--bg-dark) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: auto;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 2.5rem;
    background: linear-gradient(45deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    0% { filter: drop-shadow(0 0 10px var(--accent-blue)); }
    100% { filter: drop-shadow(0 0 20px var(--accent-purple)); }
}

.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 2px;
    margin-bottom: 30px;
    background: var(--bg-secondary);
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.element {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.element::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.element:hover::before {
    left: 100%;
}

.element:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 30px rgba(0, 212, 255, 0.3);
    border-color: var(--accent-blue);
}

.element.selected {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 20px 40px rgba(157, 78, 221, 0.4);
    animation: selectedPulse 2s ease-in-out infinite;
}

@keyframes selectedPulse {
    0%, 100% { box-shadow: 0 20px 40px rgba(157, 78, 221, 0.4); }
    50% { box-shadow: 0 25px 50px rgba(0, 212, 255, 0.6); }
}

.element-number {
    font-size: 0.7rem;
    position: absolute;
    top: 2px;
    left: 3px;
    opacity: 0.8;
}

.element-symbol {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 2px;
}

.element-name {
    font-size: 0.6rem;
    opacity: 0.9;
    text-align: center;
}

.element-mass {
    font-size: 0.5rem;
    opacity: 0.7;
    position: absolute;
    bottom: 2px;
    right: 3px;
}

/* Element category colors */
.alkali-metal { background-color: #ff6b6b; }
.alkaline-earth-metal { background-color: #ffa726; }
.transition-metal { background-color: #42a5f5; }
.post-transition-metal { background-color: #66bb6a; }
.metalloid { background-color: #ab47bc; }
.nonmetal { background-color: #26c6da; }
.halogen { background-color: #ffee58; }
.noble-gas { background-color: #ef5350; }
.lanthanide { background-color: #5c6bc0; }
.actinide { background-color: #8d6e63; }

.element-info {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    min-height: 400px;
}

.atom-visualization {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 0 auto;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nucleus {
    width: 30px;
    height: 30px;
    background: linear-gradient(45deg, var(--accent-purple), #ff6b6b);
    border-radius: 50%;
    position: absolute;
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.6);
    animation: nucleusGlow 2s ease-in-out infinite alternate;
}

@keyframes nucleusGlow {
    0% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 107, 107, 0.6); }
    100% { transform: scale(1.1); box-shadow: 0 0 30px rgba(157, 78, 221, 0.8); }
}

.electron-shell {
    position: absolute;
    border: 2px solid var(--accent-blue);
    border-radius: 50%;
    opacity: 0.6;
    animation: shellRotate 10s linear infinite;
}

.shell-1 {
    width: 80px;
    height: 80px;
    animation-duration: 8s;
}

.shell-2 {
    width: 140px;
    height: 140px;
    animation-duration: 12s;
    animation-direction: reverse;
}

.shell-3 {
    width: 200px;
    height: 200px;
    animation-duration: 16s;
}

@keyframes shellRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.electron {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-green);
    opacity: 0;
    transition: opacity 0.3s ease;
}

@keyframes electronOrbit1 {
    from { transform: translate(-50%, -50%) rotate(0deg) translateX(30px) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg) translateX(30px) rotate(-360deg); }
}

@keyframes electronOrbit2 {
    from { transform: translate(-50%, -50%) rotate(0deg) translateX(55px) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(-360deg) translateX(55px) rotate(360deg); }
}

@keyframes electronOrbit3 {
    from { transform: translate(-50%, -50%) rotate(0deg) translateX(80px) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg) translateX(80px) rotate(-360deg); }
}

.element-details {
    padding: 20px 0;
}

#elementName {
    font-size: 2.5rem;
    margin-bottom: 20px;
    background: linear-gradient(45deg, var(--accent-blue), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.details-grid {
    display: grid;
    gap: 15px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border-left: 3px solid var(--accent-blue);
    transition: all 0.3s ease;
}

.detail-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.label {
    font-weight: 600;
    color: var(--text-secondary);
}

.detail-item span:last-child {
    font-weight: bold;
    color: var(--accent-blue);
}

.how-to-make {
    background: linear-gradient(45deg, rgba(16, 185, 129, 0.1), rgba(0, 212, 255, 0.1));
    border-left: 3px solid var(--accent-green);
}

.how-to-make .label {
    color: var(--accent-green);
}

.how-to-make span:last-child {
    color: var(--accent-blue);
    font-style: italic;
    line-height: 1.4;
}

.fun-fact {
    background: linear-gradient(45deg, rgba(157, 78, 221, 0.1), rgba(0, 212, 255, 0.1));
    border-left: 3px solid var(--accent-purple);
}

.fun-fact .label {
    color: var(--accent-purple);
}

.fun-fact span:last-child {
    color: var(--accent-green);
    font-style: italic;
    line-height: 1.4;
}

.video-preview {
    display: flex;
    align-items: center;
    background: linear-gradient(45deg, rgba(0,212,255,0.05) 0%, rgba(157,78,221,0.05) 100%);
    border-left: 3px solid var(--accent-blue);
    padding: 10px 15px;
    border-radius: 8px;
    margin-top: 5px;
    gap: 15px;
    transition: background 0.3s;
}

.video-preview .label {
    min-width: 120px;
    color: var(--accent-blue);
    font-weight: 600;
    margin-right: 10px;
}

.video-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    gap: 10px;
}

.video-thumbnail {
    width: 80px;
    height: 45px;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    object-fit: cover;
    border: 2px solid #222;
    margin-right: 6px;
    transition: box-shadow 0.3s;
}

.video-link:hover .video-thumbnail {
    box-shadow: 0 4px 20px var(--accent-blue);
}

.video-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    line-height: 1.2;
    max-width: 180px;
}

@media (max-width: 768px) {
    .periodic-table {
        grid-template-columns: repeat(9, 1fr);
        gap: 1px;
    }
    
    .element-info {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .atom-visualization {
        width: 250px;
        height: 250px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .video-preview .label {
        min-width: 90px;
        font-size: 0.92rem;
    }
    .video-title {
        font-size: 0.85rem;
        max-width: 90px;
    }
    .video-thumbnail {
        width: 55px;
        height: 31px;
    }
}