:root {
    --primary-color: #00d2ff;
    --accent-color: #7b2ff7;
    --bg-dark: #0a0a1a;
    --card-bg: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-dark);
    color: #fff;
    overflow-x: hidden;
    line-height: 1.6;
}

.home-link {
    position: absolute;
    top: 20px;
    left: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    z-index: 100;
    transition: all 0.2s;
}
.home-link:hover {
    background: rgba(255,255,255,0.14);
    color: #fff;
    border-color: rgba(255,255,255,0.25);
}

.header {
    text-align: center;
    padding: 40px 20px;
    background: radial-gradient(circle at center, #1a1a3a 0%, #0a0a1a 100%);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 10px;
    letter-spacing: 4px;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7, #ff1493);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p {
    font-size: 0.9rem;
    color: #888;
    margin-top: 10px;
}

/* 周期表布局与响应式 */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    padding: 20px 0;
    -webkit-overflow-scrolling: touch;
}

.table-wrapper::-webkit-scrollbar {
    height: 6px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, minmax(65px, 1fr));
    grid-template-rows: repeat(10, minmax(75px, auto));
    gap: 6px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    min-width: 1200px;
}

.element-cell {
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 65px;
    overflow: hidden;
}

.element-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
    pointer-events: none;
}

.element-cell:hover {
    transform: scale(1.15);
    z-index: 10;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
}

.element-cell:active {
    transform: scale(1.05);
}

.element-number {
    font-size: 0.65rem;
    opacity: 0.8;
    text-align: left;
}

.element-symbol {
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.2;
}

.element-name {
    font-size: 0.6rem;
    text-align: center;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 元素分类颜色 */
.alkali-metal { background: linear-gradient(135deg, #ff6b6b, #ee5a24); }
.alkaline-earth { background: linear-gradient(135deg, #ff9ff3, #f368e0); }
.transition-metal { background: linear-gradient(135deg, #ffa502, #ff6348); }
.post-transition { background: linear-gradient(135deg, #7bed9f, #2ed573); }
.metalloid { background: linear-gradient(135deg, #70a1ff, #1e90ff); }
.nonmetal { background: linear-gradient(135deg, #ff4757, #ff6b81); }
.halogen { background: linear-gradient(135deg, #4ecdc4, #45b7d1); }
.noble-gas { background: linear-gradient(135deg, #a29bfe, #6c5ce7); }
.lanthanide { background: linear-gradient(135deg, #fd79a8, #e84393); }
.actinide { background: linear-gradient(135deg, #636e72, #2d3436); }

.empty-cell { pointer-events: none; }

/* 弹窗样式 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    backdrop-filter: blur(15px);
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #111;
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    border-radius: 24px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    box-shadow: 0 50px 100px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-header {
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 20px;
}

.modal-element-symbol {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary-color);
    text-shadow: 0 0 20px rgba(0, 210, 255, 0.5);
    background: none !important; /* 强制取消背景色 */
    padding: 0;
    min-height: auto;
}

.modal-element-info h2 {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.modal-element-info p {
    font-size: 0.9rem;
    opacity: 0.6;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.modal-close:hover { opacity: 1; }

.modal-canvas-container {
    flex: 1;
    position: relative;
    background: radial-gradient(circle at center, #1a1a3a 0%, #000 100%);
}

#modal-canvas {
    width: 100%;
    height: 100%;
}

.modal-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

.modal-controls button {
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    cursor: pointer;
    border-radius: 25px;
    font-size: 0.9rem;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.modal-controls button:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.modal-nav.prev { left: 20px; border-radius: 0 15px 15px 0; }
.modal-nav.next { right: 20px; border-radius: 15px 0 0 15px; }

.modal-tip {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.4);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    gap: 20px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-tip-item { display: flex; align-items: center; gap: 6px; }

/* 图例与介绍区块 */
.legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    padding: 15px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; opacity: 0.8; }
.legend-color { width: 16px; height: 16px; border-radius: 4px; }

.intro-section {
    max-width: 1100px;
    margin: 40px auto;
    padding: 40px;
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.intro-section:hover {
    transform: translateY(-5px);
    border-color: rgba(0, 210, 255, 0.3);
}

.intro-section h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 20px;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.intro-section p {
    font-size: 1rem;
    opacity: 0.8;
    max-width: 900px;
    margin: 0 auto 20px;
    line-height: 1.8;
    color: #e0e0e0;
}

.features {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s;
}

.feature-item:hover {
    background: rgba(0, 210, 255, 0.1);
    border-color: rgba(0, 210, 255, 0.3);
    transform: scale(1.05);
}

.knowledge-btn {
    padding: 8px 20px;
    background: var(--accent-color);
    border: none;
    color: white;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.knowledge-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(123, 47, 247, 0.5);
}

/* 移动端媒体查询 */
@media (max-width: 1400px) {
    .periodic-table { min-width: 1100px; grid-template-columns: repeat(18, minmax(55px, 1fr)); gap: 4px; }
}

@media (max-width: 768px) {
    .header h1 { font-size: 1.8rem; }
    .intro-section { margin: 20px 15px; padding: 30px 20px; }
    .intro-section h2 { font-size: 1.5rem; }
    .features { gap: 10px; }
    .feature-item { padding: 8px 15px; font-size: 0.8rem; }
    
    .modal-content { width: 95%; height: 90vh; }
    .modal-header { padding: 15px 20px; }
    .modal-element-symbol { font-size: 1.8rem; }
    .modal-header h2 { font-size: 1.1rem; }
    .modal-tip { display: none; }
    .modal-nav { width: 30px; height: 60px; font-size: 1.2rem; }
}

@media (max-width: 480px) {
    .modal-controls button { padding: 8px 16px; font-size: 0.8rem; }
    .knowledge-btn { padding: 6px 14px; font-size: 0.8rem; }
}

/* 高级演示卡片样式 */
.extra-visualizations {
    max-width: 1400px !important;
    margin: 60px auto !important;
}

.viz-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary-color) !important;
    box-shadow: 0 15px 35px rgba(0, 210, 255, 0.2);
    background: rgba(255, 255, 255, 0.08) !important;
}

.viz-card h3 {
    transition: color 0.3s;
}

.viz-card:hover h3 {
    color: #fff !important;
    text-shadow: 0 0 10px var(--primary-color);
}

/* 移动端调整 */
@media (max-width: 768px) {
    .extra-visualizations {
        margin: 30px 15px !important;
        padding: 25px 15px !important;
    }
}

/* 动画定义 */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { 
    from { opacity: 0; transform: translateY(50px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 知识点弹窗（备份功能） */
.knowledge-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}
.knowledge-popup.active { display: flex; }
.knowledge-popup-content {
    background: #1a1a1a;
    width: 90%;
    max-width: 600px;
    padding: 30px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
}
.knowledge-popup-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.knowledge-popup-close { background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; }
.knowledge-list-popup { list-style: none; margin-bottom: 20px; }
.knowledge-list-popup li { padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 0.95rem; line-height: 1.6; }
.element-detail-link { display: inline-block; margin-top: 15px; color: var(--primary-color); text-decoration: none; font-weight: 600; }
