/* ============================================
   INTERACTIVE PERIODIC TABLE - PREMIUM STYLES
   World-Class Design with 3D Effects
   ============================================ */

/* Main Container */
.pt-main {
    padding-top: 80px;
    min-height: 100vh;
}

/* Hero Section */
.pt-hero {
    padding: 2rem 1rem;
    text-align: center;
}

.pt-title {
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 800;
    background: linear-gradient(135deg, #667eea, #764ba2, #f093fb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.title-emoji {
    font-size: 1.2em;
    -webkit-text-fill-color: initial;
}

.title-sparkle {
    animation: twinkle 1.5s ease-in-out infinite;
    -webkit-text-fill-color: initial;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

.pt-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

/* Control Bar */
.pt-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 1200px;
    margin: 0 auto;
}

/* Language Toggle */
.lang-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem;
    border-radius: 10px;
}

.lang-label {
    padding: 0 0.5rem;
}

.lang-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.lang-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

/* Search */
.pt-search {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 0.5rem 1rem;
    gap: 0.5rem;
}

.pt-search input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    width: 150px;
    font-size: 0.95rem;
}

.pt-search input::placeholder {
    color: var(--text-tertiary);
}

/* Category Filter */
.pt-filter select {
    padding: 0.6rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
}

/* View Mode Buttons */
.pt-view-mode {
    display: flex;
    gap: 0.25rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem;
    border-radius: 10px;
}

.view-btn {
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.view-btn.active {
    background: rgba(255, 255, 255, 0.15);
}

/* Quiz Button */
.quiz-btn {
    padding: 0.6rem 1.5rem;
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.quiz-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* Category Legend */
.category-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.legend-item:hover {
    color: var(--text-primary);
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
}

/* Category Colors */
.legend-item[data-category="alkali-metal"] .legend-color {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.legend-item[data-category="alkaline-earth"] .legend-color {
    background: linear-gradient(135deg, #f97316, #ea580c);
}

.legend-item[data-category="transition-metal"] .legend-color {
    background: linear-gradient(135deg, #eab308, #ca8a04);
}

.legend-item[data-category="post-transition"] .legend-color {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.legend-item[data-category="metalloid"] .legend-color {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
}

.legend-item[data-category="nonmetal"] .legend-color {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
}

.legend-item[data-category="halogen"] .legend-color {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.legend-item[data-category="noble-gas"] .legend-color {
    background: linear-gradient(135deg, #a855f7, #9333ea);
}

.legend-item[data-category="lanthanide"] .legend-color {
    background: linear-gradient(135deg, #ec4899, #db2777);
}

.legend-item[data-category="actinide"] .legend-color {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
}

.legend-item[data-category="radioactive"] .legend-color {
    background: linear-gradient(135deg, #fbbf24, #f59e0b, #d97706);
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

/* Group Filter Styles (All Metals / All Non-Metals) */
.legend-item.legend-group {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-weight: 600;
    padding: 0.5rem 1rem;
}

.legend-item.legend-group:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.legend-item[data-category="all-metals"] .legend-color {
    background: linear-gradient(135deg, #ffd700, #ff8c00, #ff4500);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.legend-item[data-category="all-nonmetals"] .legend-color {
    background: linear-gradient(135deg, #00bfff, #1e90ff, #9370db);
    box-shadow: 0 0 8px rgba(0, 191, 255, 0.5);
}

.legend-item.legend-group.legend-active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.2);
}

/* ============================================
   ADVANCED FILTER PANEL (Groups/Periods/Blocks)
   Compact, Premium, Space-Efficient Design
   ============================================ */

.advanced-filter-panel {
    max-width: 900px;
    margin: 0.5rem auto 1rem;
    background: rgba(30, 35, 50, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

/* Tabs Container */
.afp-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Individual Tab */
.afp-tab {
    flex: 1;
    padding: 0.6rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary, #8b95a5);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
}

.afp-tab:hover {
    color: var(--text-primary, #fff);
    background: rgba(255, 255, 255, 0.03);
}

.afp-tab.active {
    color: var(--text-primary, #fff);
    background: rgba(255, 255, 255, 0.08);
}

.afp-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    height: 2px;
    background: linear-gradient(90deg, #06b6d4, #8b5cf6);
    border-radius: 2px;
}

/* Content Container */
.afp-content {
    padding: 0.6rem;
}

/* Tab Panes */
.afp-pane {
    display: none;
}

.afp-pane.active {
    display: block;
    animation: afp-fade-in 0.2s ease;
}

@keyframes afp-fade-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Options Container */
.afp-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
}

/* Filter Buttons */
.afp-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text-secondary, #8b95a5);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.afp-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary, #fff);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.afp-btn.active {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.3), rgba(139, 92, 246, 0.3));
    border-color: rgba(6, 182, 212, 0.5);
    color: #fff;
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.3);
}

.afp-btn-wide {
    min-width: 40px;
    padding: 0 0.6rem;
}

/* Block-specific colors */
.afp-block-s {
    border-left: 3px solid #ef4444;
}

.afp-block-p {
    border-left: 3px solid #06b6d4;
}

.afp-block-d {
    border-left: 3px solid #eab308;
}

.afp-block-f {
    border-left: 3px solid #ec4899;
}

.afp-block-s.active {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.3), rgba(239, 68, 68, 0.1));
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

.afp-block-p.active {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.3), rgba(6, 182, 212, 0.1));
    border-color: rgba(6, 182, 212, 0.5);
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.3);
}

.afp-block-d.active {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.3), rgba(234, 179, 8, 0.1));
    border-color: rgba(234, 179, 8, 0.5);
    box-shadow: 0 0 12px rgba(234, 179, 8, 0.3);
}

.afp-block-f.active {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.3), rgba(236, 72, 153, 0.1));
    border-color: rgba(236, 72, 153, 0.5);
    box-shadow: 0 0 12px rgba(236, 72, 153, 0.3);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .advanced-filter-panel {
        margin: 0.5rem 1rem;
        border-radius: 10px;
    }

    .afp-btn {
        min-width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }

    .afp-options {
        gap: 0.3rem;
    }
}

/* ============================================
   PREMIUM INTERACTIVE LEGEND STYLES
   ============================================ */

/* Enhanced legend item base styles */
.legend-item {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.legend-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.legend-item:hover::before {
    opacity: 1;
}

.legend-item:hover {
    transform: translateY(-2px) scale(1.05);
    background: rgba(255, 255, 255, 0.08);
}

/* Active legend item state - PREMIUM GLOW */
.legend-item.legend-active {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    font-weight: 600;
    transform: scale(1.08);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

.legend-item.legend-active .legend-color {
    transform: scale(1.2);
    box-shadow: 0 0 15px currentColor;
}

/* Category-specific active glow colors */
.legend-item.legend-active[data-category="alkali-metal"] {
    box-shadow: 0 4px 25px rgba(239, 68, 68, 0.5);
}

.legend-item.legend-active[data-category="alkaline-earth"] {
    box-shadow: 0 4px 25px rgba(249, 115, 22, 0.5);
}

.legend-item.legend-active[data-category="transition-metal"] {
    box-shadow: 0 4px 25px rgba(234, 179, 8, 0.5);
}

.legend-item.legend-active[data-category="post-transition"] {
    box-shadow: 0 4px 25px rgba(34, 197, 94, 0.5);
}

.legend-item.legend-active[data-category="metalloid"] {
    box-shadow: 0 4px 25px rgba(20, 184, 166, 0.5);
}

.legend-item.legend-active[data-category="nonmetal"] {
    box-shadow: 0 4px 25px rgba(6, 182, 212, 0.5);
}

.legend-item.legend-active[data-category="halogen"] {
    box-shadow: 0 4px 25px rgba(139, 92, 246, 0.5);
}

.legend-item.legend-active[data-category="noble-gas"] {
    box-shadow: 0 4px 25px rgba(168, 85, 247, 0.5);
}

.legend-item.legend-active[data-category="lanthanide"] {
    box-shadow: 0 4px 25px rgba(236, 72, 153, 0.5);
}

.legend-item.legend-active[data-category="actinide"] {
    box-shadow: 0 4px 25px rgba(244, 63, 94, 0.5);
}

.legend-item.legend-active[data-category="radioactive"] {
    box-shadow: 0 4px 25px rgba(245, 158, 11, 0.5);
}

/* Inactive (dimmed) legend items when another is active */
.legend-item.legend-inactive {
    opacity: 0.4;
    transform: scale(0.95);
}

.legend-item.legend-inactive:hover {
    opacity: 0.7;
    transform: scale(1);
}

/* ============================================
   PREMIUM ELEMENT HIGHLIGHTING
   ============================================ */

/* Premium glow effect for filtered category */
.element.category-glow {
    box-shadow:
        0 0 20px rgba(255, 255, 255, 0.3),
        0 0 40px var(--glow-color, rgba(99, 102, 241, 0.4)),
        inset 0 0 15px rgba(255, 255, 255, 0.1);
    transform: scale(1.08);
    z-index: 10 !important;
}

/* Category-specific glow colors */
.element.alkali-metal.category-glow {
    --glow-color: rgba(239, 68, 68, 0.6);
}

.element.alkaline-earth.category-glow {
    --glow-color: rgba(249, 115, 22, 0.6);
}

.element.transition-metal.category-glow {
    --glow-color: rgba(234, 179, 8, 0.6);
}

.element.post-transition.category-glow {
    --glow-color: rgba(34, 197, 94, 0.6);
}

.element.metalloid.category-glow {
    --glow-color: rgba(20, 184, 166, 0.6);
}

.element.nonmetal.category-glow {
    --glow-color: rgba(6, 182, 212, 0.6);
}

.element.halogen.category-glow {
    --glow-color: rgba(139, 92, 246, 0.6);
}

.element.noble-gas.category-glow {
    --glow-color: rgba(168, 85, 247, 0.6);
}

.element.lanthanide.category-glow {
    --glow-color: rgba(236, 72, 153, 0.6);
}

.element.actinide.category-glow {
    --glow-color: rgba(244, 63, 94, 0.6);
}

.element.radioactive.category-glow {
    --glow-color: rgba(245, 158, 11, 0.6);
}

/* Premium pulse animation */
.element.category-pulse {
    animation: categoryPulse 2s ease-in-out infinite;
}

@keyframes categoryPulse {

    0%,
    100% {
        box-shadow:
            0 0 20px rgba(255, 255, 255, 0.3),
            0 0 40px var(--glow-color, rgba(99, 102, 241, 0.4)),
            inset 0 0 15px rgba(255, 255, 255, 0.1);
    }

    50% {
        box-shadow:
            0 0 30px rgba(255, 255, 255, 0.4),
            0 0 60px var(--glow-color, rgba(99, 102, 241, 0.6)),
            inset 0 0 20px rgba(255, 255, 255, 0.15);
    }
}

/* Enhanced dimmed state for non-matching elements */
.element.dimmed {
    opacity: 0.15;
    transform: scale(0.92);
    filter: grayscale(50%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.element.dimmed:hover {
    opacity: 0.35;
    transform: scale(0.96);
    filter: grayscale(30%);
}

/* ============================================
   PERIODIC TABLE GRID
   ============================================ */

.pt-grid-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    overflow-x: auto;
}

.pt-grid {
    display: grid;
    grid-template-columns: repeat(18, minmax(55px, 1fr));
    gap: 3px;
    min-width: 1000px;
}

/* Individual Element */
.element {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.element::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.element:hover {
    transform: scale(1.15) translateZ(20px);
    z-index: 10;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.element:hover::before {
    opacity: 1;
}

.element .el-number {
    font-size: 0.55rem;
    color: rgba(255, 255, 255, 0.6);
    position: absolute;
    top: 3px;
    left: 5px;
}

.element .el-radiation {
    font-size: 0.55rem;
    color: rgba(245, 158, 11, 0.7);
    position: absolute;
    top: 3px;
    right: 5px;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.element:hover .el-radiation {
    color: #fbbf24;
    transform: rotate(180deg) scale(1.2);
}

.element .el-symbol {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
}

.element .el-name {
    font-size: 0.5rem;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.element .el-mass {
    font-size: 0.45rem;
    color: rgba(255, 255, 255, 0.5);
}

/* Element Categories */
.element.alkali-metal {
    background: linear-gradient(145deg, rgba(239, 68, 68, 0.7), rgba(220, 38, 38, 0.5));
    border-color: #ef4444;
}

.element.alkaline-earth {
    background: linear-gradient(145deg, rgba(249, 115, 22, 0.7), rgba(234, 88, 12, 0.5));
    border-color: #f97316;
}

.element.transition-metal {
    background: linear-gradient(145deg, rgba(234, 179, 8, 0.7), rgba(202, 138, 4, 0.5));
    border-color: #eab308;
}

.element.post-transition {
    background: linear-gradient(145deg, rgba(34, 197, 94, 0.7), rgba(22, 163, 74, 0.5));
    border-color: #22c55e;
}

.element.metalloid {
    background: linear-gradient(145deg, rgba(20, 184, 166, 0.7), rgba(13, 148, 136, 0.5));
    border-color: #14b8a6;
}

.element.nonmetal {
    background: linear-gradient(145deg, rgba(6, 182, 212, 0.7), rgba(8, 145, 178, 0.5));
    border-color: #06b6d4;
}

.element.halogen {
    background: linear-gradient(145deg, rgba(139, 92, 246, 0.7), rgba(124, 58, 237, 0.5));
    border-color: #8b5cf6;
}

.element.noble-gas {
    background: linear-gradient(145deg, rgba(168, 85, 247, 0.7), rgba(147, 51, 234, 0.5));
    border-color: #a855f7;
}

.element.lanthanide {
    background: linear-gradient(145deg, rgba(236, 72, 153, 0.7), rgba(219, 39, 119, 0.5));
    border-color: #ec4899;
}

.element.actinide {
    background: linear-gradient(145deg, rgba(244, 63, 94, 0.7), rgba(225, 29, 72, 0.5));
    border-color: #f43f5e;
}

/* Placeholder for empty cells */
.element.placeholder {
    visibility: hidden;
}

/* State-based coloring */
.element.state-solid {
    border-color: #22c55e;
    box-shadow: inset 0 0 20px rgba(34, 197, 94, 0.3);
}

.element.state-liquid {
    border-color: #3b82f6;
    box-shadow: inset 0 0 20px rgba(59, 130, 246, 0.3);
}

.element.state-gas {
    border-color: #a855f7;
    box-shadow: inset 0 0 20px rgba(168, 85, 247, 0.3);
}

/* Block-based coloring */
.element.block-s-view {
    background: linear-gradient(145deg, rgba(239, 68, 68, 0.6), rgba(220, 38, 38, 0.4)) !important;
}

.element.block-p-view {
    background: linear-gradient(145deg, rgba(59, 130, 246, 0.6), rgba(37, 99, 235, 0.4)) !important;
}

.element.block-d-view {
    background: linear-gradient(145deg, rgba(234, 179, 8, 0.6), rgba(202, 138, 4, 0.4)) !important;
}

.element.block-f-view {
    background: linear-gradient(145deg, rgba(236, 72, 153, 0.6), rgba(219, 39, 119, 0.4)) !important;
}

/* Highlighted (search/filter) */
.element.dimmed {
    opacity: 0.2;
    transform: scale(0.95);
}

.element.highlighted {
    animation: pulse-highlight 1s ease-in-out infinite;
    z-index: 5;
}

@keyframes pulse-highlight {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.5);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(99, 102, 241, 0);
    }
}

/* F-Block (Lanthanides & Actinides) */
.pt-f-block {
    max-width: 1400px;
    margin: 1rem auto;
    padding: 0 1rem;
}

.f-block-label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin: 0.5rem 0;
    text-align: center;
}

.pt-lanthanides,
.pt-actinides {
    display: grid;
    grid-template-columns: repeat(15, minmax(55px, 1fr));
    gap: 3px;
    justify-content: center;
    min-width: 830px;
}

/* ============================================
   ELEMENT DETAIL MODAL
   ============================================ */

.element-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 1rem;
}

.element-modal.active {
    opacity: 1;
    visibility: visible;
}

.element-modal-content {
    background: linear-gradient(145deg, var(--bg-secondary), var(--bg-primary));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    padding: 2rem;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.element-modal.active .element-modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.8);
    transform: scale(1.1);
}

/* Modal Left - Element Card & 3D Atom */
.modal-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.element-card-large {
    width: 180px;
    height: 180px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.element-card-large .element-radiation-badge {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.25rem;
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
    animation: rotate-slow 10s linear infinite;
    pointer-events: none;
}

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

.element-card-large .element-number {
    position: absolute;
    top: 12px;
    left: 15px;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.7);
}

.element-card-large .element-symbol {
    font-size: 4rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.element-card-large .element-name {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

.element-card-large .element-mass {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
}

/* ============================================
   2D BOHR MODEL - Academically Accurate
   Premium Visualization with Scientific Precision
   Following Aufbau Principle & Bohr's Atomic Model
   ============================================ */

/* Bohr Model Wrapper */
.bohr-model-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.bohr-model-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(99, 102, 241, 0.85);
    text-transform: uppercase;
    letter-spacing: 2.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bohr-model-title::before,
.bohr-model-title::after {
    content: '';
    width: 20px;
    height: 1px;
}

.bohr-model-title::before {
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.4));
}

.bohr-model-title::after {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.4), transparent);
}

/* Atom Container - Flat 2D (No Perspective) */
.atom-3d-container {
    width: 220px;
    height: 220px;
    position: relative;
    /* No perspective - academically accurate flat 2D Bohr model */
}

/* Nucleus */
.atom-nucleus {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    background: radial-gradient(circle at 35% 30%, #ff8787, #e03131, #a61e1e);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 0 15px rgba(224, 49, 49, 0.5),
        0 0 35px rgba(224, 49, 49, 0.2),
        inset 0 -3px 8px rgba(0, 0, 0, 0.35),
        inset 0 2px 4px rgba(255, 255, 255, 0.15);
    z-index: 10;
    animation: nucleus-breathe 3s ease-in-out infinite;
}

@keyframes nucleus-breathe {
    0%, 100% {
        box-shadow:
            0 0 15px rgba(224, 49, 49, 0.5),
            0 0 35px rgba(224, 49, 49, 0.2),
            inset 0 -3px 8px rgba(0, 0, 0, 0.35),
            inset 0 2px 4px rgba(255, 255, 255, 0.15);
    }
    50% {
        box-shadow:
            0 0 22px rgba(224, 49, 49, 0.65),
            0 0 50px rgba(224, 49, 49, 0.3),
            inset 0 -3px 8px rgba(0, 0, 0, 0.35),
            inset 0 2px 4px rgba(255, 255, 255, 0.15);
    }
}

.proton-count {
    font-size: 0.9rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Electron Shells Container */
.electron-shells {
    position: absolute;
    inset: 0;
}

/* Individual Shell Orbit - Flat 2D Circle (No rotateX) */
.electron-shell {
    position: absolute;
    top: 50%;
    left: 50%;
    border: 1.5px solid rgba(99, 102, 241, 0.22);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    /* NO rotateX - pure 2D concentric circles per Bohr's model */
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.electron-shell:hover {
    border-color: rgba(99, 102, 241, 0.45);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.12);
}

/* Dashed shell style for inner shells */
.electron-shell:nth-child(1) { border-style: solid; }
.electron-shell:nth-child(2) { border-style: solid; }
.electron-shell:nth-child(3) { border-style: dashed; border-color: rgba(99, 102, 241, 0.18); }
.electron-shell:nth-child(n+4) { border-style: dashed; border-color: rgba(99, 102, 241, 0.14); }

/* Shell Label (K, L, M, N, O, P, Q) */
.shell-label {
    position: absolute;
    top: 0;
    right: 10%;
    transform: translate(50%, -50%);
    font-size: 0.52rem;
    font-weight: 700;
    color: rgba(99, 102, 241, 0.75);
    background: var(--bg-secondary, #1a1b2e);
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    z-index: 6;
    pointer-events: none;
    line-height: 1.4;
}

/* Electron Dots */
.electron {
    position: absolute;
    width: 10px;
    height: 10px;
    background: radial-gradient(circle at 35% 30%, #a5d8ff, #339af0, #1971c2);
    border-radius: 50%;
    box-shadow:
        0 0 5px rgba(51, 154, 240, 0.7),
        0 0 12px rgba(51, 154, 240, 0.35);
    animation: electron-glow 2.5s ease-in-out infinite;
    z-index: 5;
}

/* Stagger electron glow animations for organic look */
.electron:nth-child(2n) { animation-delay: -0.8s; }
.electron:nth-child(3n) { animation-delay: -1.6s; }
.electron:nth-child(4n+1) { animation-delay: -0.4s; }
.electron:nth-child(5n+2) { animation-delay: -1.2s; }
.electron:nth-child(7n+3) { animation-delay: -2s; }

@keyframes electron-glow {
    0%, 100% {
        box-shadow:
            0 0 5px rgba(51, 154, 240, 0.7),
            0 0 12px rgba(51, 154, 240, 0.35);
        transform: scale(1);
    }
    50% {
        box-shadow:
            0 0 8px rgba(51, 154, 240, 0.9),
            0 0 18px rgba(51, 154, 240, 0.5);
        transform: scale(1.15);
    }
}

/* Particle Info Legend (p⁺, n⁰, e⁻) */
.particle-info {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0;
}

.particle-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    color: var(--text-secondary, #8b95a5);
    font-weight: 500;
    letter-spacing: 0.3px;
}

.particle-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.particle-dot.proton-dot {
    background: radial-gradient(circle at 35% 30%, #ff8787, #e03131);
    box-shadow: 0 0 5px rgba(224, 49, 49, 0.4);
}

.particle-dot.neutron-dot {
    background: radial-gradient(circle at 35% 30%, #ced4da, #868e96);
    box-shadow: 0 0 5px rgba(134, 142, 150, 0.4);
}

.particle-dot.electron-dot {
    background: radial-gradient(circle at 35% 30%, #a5d8ff, #339af0);
    box-shadow: 0 0 5px rgba(51, 154, 240, 0.4);
}

/* Shell Configuration Badge */
.shell-config {
    font-size: 0.68rem;
    color: var(--text-secondary, #8b95a5);
    text-align: center;
    font-weight: 500;
    background: rgba(99, 102, 241, 0.06);
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    border: 1px solid rgba(99, 102, 241, 0.12);
    letter-spacing: 0.4px;
    line-height: 1.4;
}

.shell-config .shell-config-label {
    color: rgba(99, 102, 241, 0.7);
    font-weight: 700;
    margin-right: 0.25rem;
}

/* Pronounce Button */
.pronounce-btn {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.pronounce-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Modal Right - Info Sections */
.modal-right {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.info-section {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.info-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-item.full-width {
    grid-column: 1 / -1;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.info-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.info-value.radioactive-value {
    color: #fbbf24;
    text-shadow: 0 0 4px rgba(251, 191, 36, 0.2);
}

.info-value.stable-value {
    color: #22c55e;
}

.info-value.mono {
    font-family: 'Courier New', monospace;
}

.fun-fact-section {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    border-color: rgba(99, 102, 241, 0.2);
}

.fun-fact-text {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ============================================
   QUIZ MODAL
   ============================================ */

.quiz-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 1rem;
}

.quiz-modal.active {
    opacity: 1;
    visibility: visible;
}

.quiz-container {
    background: linear-gradient(145deg, var(--bg-secondary), var(--bg-primary));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    max-width: 600px;
    width: 100%;
    padding: 2rem;
    position: relative;
}

.quiz-header {
    margin-bottom: 1.5rem;
}

.quiz-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.quiz-mode {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.quiz-rewards .reward {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.2), rgba(245, 158, 11, 0.1));
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-weight: 600;
    color: #fbbf24;
}

.quiz-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.quiz-progress .progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.quiz-progress .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669);
    width: 0%;
    transition: width 0.3s ease;
}

.quiz-content {
    text-align: center;
}

.quiz-question {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.quiz-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.quiz-option {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quiz-option:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.quiz-option.correct {
    background: rgba(16, 185, 129, 0.3);
    border-color: #10b981;
}

.quiz-option.wrong {
    background: rgba(239, 68, 68, 0.3);
    border-color: #ef4444;
}

.quiz-option:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.quiz-feedback {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: 12px;
    display: none;
}

.quiz-feedback.correct {
    display: block;
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.quiz-feedback.wrong {
    display: block;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Quiz Results Modal */
.quiz-results-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    z-index: 100002;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 1rem;
}

.quiz-results-modal.active {
    opacity: 1;
    visibility: visible;
}

.quiz-results-container {
    background: linear-gradient(145deg, var(--bg-secondary), var(--bg-primary));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    max-width: 450px;
    width: 100%;
    padding: 2rem;
    text-align: center;
}

.results-header {
    margin-bottom: 1.5rem;
}

.trophy-animation {
    font-size: 4rem;
    animation: bounce 0.5s ease;
}

@keyframes bounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

.results-title {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-top: 0.5rem;
}

.results-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.result-stat {
    text-align: center;
}

.result-icon {
    font-size: 1.5rem;
    display: block;
}

.result-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.results-rewards {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.results-rewards h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.reward-earned {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fbbf24;
}

.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-replay,
.btn-home {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-replay {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-home {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* ============================================
   RESPONSIVE DESIGN - PREMIUM MOBILE EXPERIENCE
   ============================================ */

/* ========== TABLET (768px - 1024px) ========== */
@media (max-width: 1024px) {
    .pt-main {
        padding-top: 70px;
    }

    .pt-hero {
        padding: 1.5rem 1rem;
    }

    .pt-title {
        font-size: 1.8rem;
    }

    .pt-subtitle {
        font-size: 1rem;
    }

    .pt-controls {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .category-legend {
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .legend-item {
        font-size: 0.65rem;
    }

    .legend-color {
        width: 12px;
        height: 12px;
    }

    .pt-grid {
        grid-template-columns: repeat(18, minmax(48px, 1fr));
        gap: 2px;
        min-width: 870px;
    }

    .pt-lanthanides,
    .pt-actinides {
        grid-template-columns: repeat(15, minmax(48px, 1fr));
        gap: 2px;
        min-width: 725px;
    }

    .element .el-symbol {
        font-size: 1rem;
    }

    .element .el-number {
        font-size: 0.45rem;
    }

    .element .el-name {
        font-size: 0.4rem;
    }

    .element .el-mass {
        display: none;
    }
}

/* ========== MOBILE LANDSCAPE & SMALL TABLETS (600px - 768px) ========== */
@media (max-width: 768px) {
    .pt-main {
        padding-top: 60px;
    }

    .pt-hero {
        padding: 1rem 0.75rem;
    }

    .pt-title {
        font-size: 1.5rem;
        flex-wrap: wrap;
    }

    .title-emoji {
        font-size: 1em;
    }

    .pt-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }

    /* Control Bar - Horizontal Scroll on Mobile */
    .pt-controls {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding: 0.75rem;
        gap: 0.5rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin: 0 -0.5rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .pt-controls::-webkit-scrollbar {
        display: none;
    }

    .lang-toggle {
        flex-shrink: 0;
    }

    .lang-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .pt-search {
        flex-shrink: 0;
        min-width: 140px;
    }

    .pt-search input {
        width: 100px;
        font-size: 0.85rem;
    }

    .pt-filter {
        flex-shrink: 0;
    }

    .pt-filter select {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .pt-view-mode {
        flex-shrink: 0;
    }

    .view-btn {
        padding: 0.4rem 0.6rem;
        font-size: 1rem;
    }

    .quiz-btn {
        flex-shrink: 0;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    /* Category Legend - Horizontal Scroll */
    .category-legend {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding: 0.5rem 1rem;
        gap: 1rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .category-legend::-webkit-scrollbar {
        display: none;
    }

    .legend-item {
        flex-shrink: 0;
        font-size: 0.7rem;
    }

    /* Grid - Optimized for horizontal scroll */
    .pt-grid-container {
        padding: 0.5rem;
        margin: 0;
    }

    .pt-grid {
        grid-template-columns: repeat(18, 40px);
        gap: 2px;
        min-width: 740px;
    }

    .pt-lanthanides,
    .pt-actinides {
        grid-template-columns: repeat(15, 40px);
        gap: 2px;
        min-width: 610px;
    }

    .element {
        border-radius: 6px;
        min-height: 40px;
    }

    .element .el-number {
        font-size: 0.4rem;
        top: 2px;
        left: 3px;
    }

    .element .el-symbol {
        font-size: 0.9rem;
    }

    .element .el-name,
    .element .el-mass {
        display: none;
    }

    /* Disable hover scale on touch devices */
    .element:hover {
        transform: none;
        box-shadow: none;
    }

    .element:active {
        transform: scale(0.95);
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
    }

    .f-block-label {
        font-size: 0.7rem;
        margin: 0.3rem 0;
    }

    /* Element Modal - Full Screen on Mobile */
    .element-modal {
        padding: 0;
        align-items: flex-end;
    }

    .element-modal-content {
        grid-template-columns: 1fr;
        max-height: 85vh;
        border-radius: 24px 24px 0 0;
        padding: 1.5rem;
        gap: 1rem;
        width: 100%;
        max-width: 100%;
    }

    .modal-close {
        top: 0.75rem;
        right: 0.75rem;
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .modal-left {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }

    .element-card-large {
        width: 120px;
        height: 120px;
        border-radius: 16px;
    }

    .element-card-large .element-number {
        font-size: 0.8rem;
        top: 8px;
        left: 10px;
    }

    .element-card-large .element-symbol {
        font-size: 2.5rem;
    }

    .element-card-large .element-name {
        font-size: 0.9rem;
    }

    .element-card-large .element-mass {
        font-size: 0.75rem;
    }

    .bohr-model-wrapper {
        gap: 0.5rem;
    }

    .bohr-model-title {
        font-size: 0.6rem;
        letter-spacing: 1.5px;
    }

    .atom-nucleus {
        width: 32px;
        height: 32px;
    }

    .proton-count {
        font-size: 0.7rem;
    }

    .particle-info {
        gap: 0.5rem;
    }

    .particle-item {
        font-size: 0.62rem;
    }

    .shell-config {
        font-size: 0.6rem;
        padding: 0.3rem 0.6rem;
    }

    .pronounce-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        border-radius: 10px;
    }

    /* Info sections */
    .modal-right {
        gap: 0.75rem;
    }

    .info-section {
        padding: 0.75rem;
        border-radius: 10px;
    }

    .info-title {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .info-grid {
        gap: 0.5rem;
    }

    .info-label {
        font-size: 0.65rem;
    }

    .info-value {
        font-size: 0.85rem;
    }

    .fun-fact-text {
        font-size: 0.85rem;
    }

    /* Quiz Modal - Full Screen */
    .quiz-modal {
        padding: 0;
        align-items: flex-end;
    }

    .quiz-container {
        border-radius: 24px 24px 0 0;
        padding: 1.5rem;
        max-width: 100%;
        width: 100%;
        max-height: 85vh;
        overflow-y: auto;
    }

    .quiz-mode {
        font-size: 1rem;
    }

    .quiz-question {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }

    .quiz-options {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .quiz-option {
        padding: 0.9rem;
        font-size: 1rem;
    }

    /* Quiz Results - Full Screen */
    .quiz-results-modal {
        padding: 0;
        align-items: center;
    }

    .quiz-results-container {
        border-radius: 20px;
        padding: 1.5rem;
        margin: 1rem;
        max-width: 95%;
    }

    .trophy-animation {
        font-size: 3rem;
    }

    .results-title {
        font-size: 1.3rem;
    }

    .results-stats {
        gap: 1rem;
    }

    .result-value {
        font-size: 1.4rem;
    }

    .reward-earned {
        font-size: 1.2rem;
    }

    .results-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .btn-replay,
    .btn-home {
        width: 100%;
        padding: 0.9rem;
    }
}

/* ========== MOBILE PORTRAIT (up to 480px) ========== */
@media (max-width: 480px) {
    .pt-main {
        padding-top: 55px;
    }

    .pt-hero {
        padding: 0.75rem 0.5rem;
    }

    .pt-title {
        font-size: 1.3rem;
        gap: 0.3rem;
    }

    .title-emoji,
    .title-sparkle {
        font-size: 0.9em;
    }

    .pt-subtitle {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
        padding: 0 0.5rem;
    }

    /* Control Bar - More Compact */
    .pt-controls {
        padding: 0.5rem;
        gap: 0.4rem;
        border-radius: 12px;
    }

    .lang-label {
        display: none;
    }

    .lang-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }

    .pt-search {
        padding: 0.4rem 0.6rem;
    }

    .pt-search input {
        width: 80px;
        font-size: 0.8rem;
    }

    .search-icon {
        font-size: 0.9rem;
    }

    .pt-filter select {
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
    }

    .view-btn {
        padding: 0.35rem 0.5rem;
        font-size: 0.9rem;
    }

    .quiz-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    #quizBtnText {
        display: none;
    }

    /* Grid - Ultra Compact */
    .pt-grid-container {
        padding: 0.25rem;
    }

    .pt-grid {
        grid-template-columns: repeat(18, 32px);
        gap: 1px;
        min-width: 580px;
    }

    .pt-lanthanides,
    .pt-actinides {
        grid-template-columns: repeat(15, 32px);
        gap: 1px;
        min-width: 485px;
    }

    .element {
        border-radius: 4px;
        min-height: 32px;
        border-width: 1px;
    }

    .element .el-number {
        font-size: 0.35rem;
        top: 1px;
        left: 2px;
    }

    .element .el-symbol {
        font-size: 0.75rem;
        font-weight: 800;
    }

    .f-block-label {
        font-size: 0.6rem;
    }

    .pt-f-block {
        margin: 0.5rem auto;
        padding: 0 0.25rem;
    }

    /* Element Modal - Optimized */
    .element-modal-content {
        padding: 1rem;
        gap: 0.75rem;
        max-height: 90vh;
    }

    .modal-close {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        top: 0.5rem;
        right: 0.5rem;
    }

    .element-card-large {
        width: 100px;
        height: 100px;
        border-radius: 14px;
    }

    .element-card-large .element-symbol {
        font-size: 2rem;
    }

    .element-card-large .element-name {
        font-size: 0.8rem;
    }

    .bohr-model-wrapper {
        gap: 0.4rem;
    }

    .bohr-model-title {
        font-size: 0.55rem;
    }

    .atom-nucleus {
        width: 26px;
        height: 26px;
    }

    .proton-count {
        font-size: 0.6rem;
    }

    .particle-info {
        gap: 0.4rem;
    }

    .particle-item {
        font-size: 0.58rem;
    }

    .shell-config {
        font-size: 0.55rem;
        padding: 0.25rem 0.5rem;
    }

    .shell-label {
        font-size: 0.45rem;
        padding: 0px 3px;
    }

    .pronounce-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
    }

    .info-section {
        padding: 0.6rem;
    }

    .info-title {
        font-size: 0.7rem;
    }

    .info-label {
        font-size: 0.6rem;
    }

    .info-value {
        font-size: 0.8rem;
    }

    .fun-fact-text {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    /* Quiz Modal */
    .quiz-container {
        padding: 1rem;
    }

    .quiz-mode {
        font-size: 0.9rem;
    }

    .quiz-rewards .reward {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }

    .quiz-question {
        font-size: 1rem;
        line-height: 1.3;
    }

    .quiz-option {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .quiz-feedback {
        padding: 0.75rem;
    }
}

/* ========== VERY SMALL SCREENS (up to 360px) ========== */
@media (max-width: 360px) {
    .pt-title {
        font-size: 1.1rem;
    }

    .pt-subtitle {
        font-size: 0.75rem;
    }

    .pt-grid {
        grid-template-columns: repeat(18, 28px);
        min-width: 510px;
    }

    .pt-lanthanides,
    .pt-actinides {
        grid-template-columns: repeat(15, 28px);
        min-width: 425px;
    }

    .element {
        min-height: 28px;
        border-radius: 3px;
    }

    .element .el-number {
        display: none;
    }

    .element .el-symbol {
        font-size: 0.65rem;
    }

    .element-card-large {
        width: 90px;
        height: 90px;
    }

    .element-card-large .element-symbol {
        font-size: 1.8rem;
    }

    .bohr-model-title {
        font-size: 0.5rem;
    }

    .atom-nucleus {
        width: 22px;
        height: 22px;
    }

    .proton-count {
        font-size: 0.55rem;
    }
}

/* ========== TOUCH DEVICE OPTIMIZATIONS ========== */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .element {
        min-height: 44px;
    }

    .lang-btn,
    .view-btn,
    .quiz-btn {
        min-height: 44px;
    }

    .quiz-option {
        min-height: 50px;
    }

    .modal-close {
        min-width: 44px;
        min-height: 44px;
    }

    /* Disable hover effects */
    .element:hover {
        transform: none;
    }

    .quiz-btn:hover {
        transform: none;
    }

    .pronounce-btn:hover {
        transform: none;
    }

    /* Active states for touch */
    .element:active {
        transform: scale(0.9);
        opacity: 0.8;
    }

    .quiz-option:active {
        transform: scale(0.98);
    }

    /* Smooth scrolling */
    .pt-grid-container,
    .pt-controls,
    .category-legend {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
}

/* ========== LANDSCAPE MOBILE ========== */
@media (max-height: 500px) and (orientation: landscape) {
    .pt-main {
        padding-top: 50px;
    }

    .pt-hero {
        padding: 0.5rem;
    }

    .pt-title {
        font-size: 1.2rem;
        margin-bottom: 0.25rem;
    }

    .pt-subtitle {
        display: none;
    }

    .element-modal-content {
        max-height: 95vh;
        grid-template-columns: 200px 1fr;
    }

    .modal-left {
        flex-direction: column;
    }

    .element-card-large {
        width: 100px;
        height: 100px;
    }

    .atom-nucleus {
        width: 30px;
        height: 30px;
    }
}

/* ========== DARK/LIGHT THEME ========== */
[data-theme="light"] .element {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .element .el-number {
    color: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .element .el-symbol {
    color: rgba(0, 0, 0, 0.85);
}

[data-theme="light"] .element .el-name {
    color: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .pt-controls {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .pt-search {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .pt-search input {
    color: var(--text-primary);
}

[data-theme="light"] .lang-toggle {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .lang-btn {
    color: var(--text-secondary);
}

[data-theme="light"] .pt-filter select {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

/* ========== SCROLL INDICATORS ========== */
.pt-grid-container::after {
    content: '';
    position: sticky;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to left, var(--bg-primary), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
    .pt-grid-container {
        position: relative;
    }

    .pt-grid-container::before {
        content: '← Scroll →';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: rgba(99, 102, 241, 0.9);
        color: white;
        padding: 0.5rem 1rem;
        border-radius: 20px;
        font-size: 0.75rem;
        font-weight: 600;
        z-index: 100;
        animation: fadeOut 3s forwards;
        pointer-events: none;
    }
}

@keyframes fadeOut {

    0%,
    70% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        visibility: hidden;
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 100003;
}

.toast.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

@media (max-width: 480px) {
    .toast {
        bottom: 1rem;
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
        max-width: 90%;
        text-align: center;
    }
}

/* Particles Canvas */
#particleCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* ========== ACCESSIBILITY ========== */
@media (prefers-reduced-motion: reduce) {

    .element,
    .electron-shell,
    .title-sparkle {
        animation: none;
        transition: none;
    }
}

/* Focus states for keyboard navigation */
.element:focus,
.quiz-option:focus,
.lang-btn:focus,
.view-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* ============================================
   QUIZ MODE SELECTION SCREEN
   ============================================ */
.quiz-selection-screen {
    text-align: center;
    padding: 0.5rem;
}

.quiz-selection-title {
    font-size: 1.85rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fbbf24, #f59e0b, #e11d48);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.quiz-selection-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.quiz-modes-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quiz-mode-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    position: relative;
    overflow: hidden;
}

.quiz-mode-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.quiz-mode-card:hover {
    transform: translateY(-3px) scale(1.02);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.quiz-mode-card:hover::before {
    opacity: 1;
}

.quiz-mode-card .card-icon {
    font-size: 2.25rem;
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.quiz-mode-card:hover .card-icon {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

/* Card-specific hover glows */
.quiz-mode-card:nth-child(1):hover {
    border-color: #f59e0b;
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.2);
}
.quiz-mode-card:nth-child(1):hover .card-icon {
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}

.quiz-mode-card:nth-child(2):hover {
    border-color: #3b82f6;
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.2);
}
.quiz-mode-card:nth-child(2):hover .card-icon {
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
    color: #60a5fa;
}

.quiz-mode-card:nth-child(3):hover {
    border-color: #10b981;
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.2);
}
.quiz-mode-card:nth-child(3):hover .card-icon {
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
    color: #34d399;
}

.quiz-mode-card .card-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.quiz-mode-card .card-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.quiz-mode-card .card-desc {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    line-height: 1.4;
}

@media (max-width: 500px) {
    .quiz-mode-card {
        flex-direction: column;
        text-align: center;
        padding: 1.25rem 1rem;
    }
}