:root {
  --bg: #020408;
  --bg2: #050d18;
  --panel: rgba(5,20,40,0.85);
  --border: rgba(0,200,255,0.18);
  --cyan: #00c8ff;
  --cyan2: #00ffcc;
  --gold: #ffd700;
  --red: #ff4466;
  --purple: #a855f7;
  --green: #22c55e;
  --text: #c8e8ff;
  --text2: #7aa8cc;
  --glow: 0 0 20px rgba(0,200,255,0.4);
  --glow2: 0 0 40px rgba(0,200,255,0.2);
}

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

body {
  font-family: 'Rajdhani', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}


/* Stars background — animated nebula */
@keyframes nebula1 {
  0%   { opacity: 0.12; }
  33%  { opacity: 0.24; }
  66%  { opacity: 0.12; }
  100% { opacity: 0.12; }
}
@keyframes nebula2 {
  0%   { opacity: 0.12; }
  40%  { opacity: 0.24; }
  80%  { opacity: 0.12; }
  100% { opacity: 0.12; }
}
@keyframes nebula3 {
  0%   { opacity: 0.12; }
  50%  { opacity: 0.24; }
  100% { opacity: 0.12; }
}
@keyframes aurora {
  0%   { opacity: 0.06; transform: scaleX(1) translateY(0); }
  50%  { opacity: 0.13; transform: scaleX(1.04) translateY(-1%); }
  100% { opacity: 0.06; transform: scaleX(1) translateY(0); }
}

body::before {
  content:'';
  position:fixed;
  inset:0;
  background:
    radial-gradient(ellipse at 15% 25%, rgba(180,80,255,1.2) 0%, transparent 50%),
    radial-gradient(ellipse at 20% 50%, rgba(0,100,200,1) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 20%, rgba(100,40,180,1) 0%, transparent 48%),
    radial-gradient(ellipse at 50% 85%, rgba(0,160,80,1) 0%, transparent 48%);
  animation: nebula1 18s ease-in-out infinite;
  pointer-events:none;
  z-index:0;
}
body::after {
  content:'';
  position:fixed;
  inset:0;
  background:
    radial-gradient(ellipse at 10% 20%, rgba(200,100,255,1.4) 0%, transparent 45%),
    radial-gradient(ellipse at 70% 60%, rgba(0,200,255,1) 0%, transparent 40%),
    radial-gradient(ellipse at 15% 15%, rgba(200,120,255,1) 0%, transparent 42%),
    radial-gradient(ellipse at 88% 80%, rgba(0,255,180,1) 0%, transparent 38%);
  opacity: 0.2;
  animation: nebula2 18s ease-in-out infinite;
  pointer-events:none;
  z-index:0;
}

/* Cursor glow spreading effect for neighboring cells */
.element-cell.cursor-glow-primary::after,
.element-cell.cursor-glow-secondary::after {
  opacity: 1;
}

.element-cell.cursor-glow-secondary::after {
  opacity: 0.4;
}

#stars-canvas {
  position:fixed;
  inset:0;
  z-index:0;
  pointer-events:none;
}

/* NAV */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 60px;
  background: rgba(2,4,8,0.95);
  border-bottom: 1px solid rgba(0,200,255,0.25);
  backdrop-filter: blur(18px);
  box-shadow: 0 4px 32px rgba(0,0,0,0.4);
}
.nav-mobile-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 1.2rem;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  border-radius: 4px;
  order: 3;
}
@media(max-width:768px){
  nav { display: flex; justify-content: space-between; }
  .nav-mobile-btn { display: block; }
  .nav-links {
    display: none;
    position: fixed;
    top: 60px; left: 0; right: 0;
    background: rgba(2,4,8,0.99);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.4rem;
    gap: 0;
    z-index: 10000;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.8);
  }
  .nav-links.mobile-open { display: flex; }
  .nav-links li { width: 100%; border-bottom: 1px solid rgba(0,200,255,0.08); }
  .nav-links li:last-child { border-bottom: none; }
  .nav-links a { display: block; width: 100%; text-align: center; padding: 0.75rem 1rem; font-size: 0.9rem; letter-spacing: 2px; }
}

.logo {
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  font-size: 1.4rem;
  color: var(--cyan);
  text-shadow: 0 0 20px rgba(0,200,255,0.8), 0 0 40px rgba(0,200,255,0.4);
  letter-spacing: 4px;
  cursor: pointer;
  transition: text-shadow 0.3s ease;
}
.logo:hover { text-shadow: 0 0 30px rgba(0,200,255,1), 0 0 60px rgba(0,200,255,0.6); }
.logo span { color: var(--gold); }

.nav-links {
  gap: 0.2rem;
  list-style: none;
  flex-wrap: nowrap;
}
@media(min-width:769px){
  .nav-links {
    display: flex;
    position: absolute;
    left: 50%;
    transform: translateX(-46%);
  }
}

.nav-links a {
  font-family: 'Exo 2', 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text2);
  text-decoration: none;
  padding: 0.4rem 0.9rem;
  border: 1px solid rgba(0,200,255,0.2);
  border-radius: 4px;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--cyan);
  border-color: var(--cyan);
  background: rgba(0,200,255,0.12);
  text-shadow: 0 0 12px rgba(0,200,255,0.7);
  box-shadow: inset 0 0 12px rgba(0,200,255,0.15), 0 0 8px rgba(0,200,255,0.3);
}

.lang-toggle {
  display: flex;
  gap: 4px;
}
.lang-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  padding: 0.3rem 0.6rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(0,200,255,0.15);
  color: var(--text2);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  letter-spacing: 1px;
}
.lang-btn.active, .lang-btn:hover {
  color: var(--cyan);
  border-color: var(--cyan);
  background: rgba(0,200,255,0.15);
  box-shadow: 0 0 12px rgba(0,200,255,0.2);
}

/* SECTIONS */
section {
  position: relative;
  z-index: 1;
  display: none;
  min-height: 100vh;
  padding: 80px 2rem 2rem;
}
section::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(2,4,8,0.2) 0%, rgba(5,20,40,0.15) 50%, rgba(2,4,8,0.2) 100%);
  pointer-events: none;
}
section.active { display: block; }
#home.active { display: flex !important; }

/* HERO */
#home {
  display: none;
  text-align: center;
  /* Completely override the section rule */
  min-height: 0 !important;
  height: 100vh !important;
  padding: 0 !important;
  /* Push content down by nav height using a pseudo-trick */
}
#home.active {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 60px !important;
  box-sizing: border-box !important;
}

.hero-title {
  font-family: 'Orbitron', monospace;
  font-size: clamp(3.2rem, 8vw, 7.5rem);
  font-weight: 900;
  letter-spacing: 10px;
  color: var(--cyan);
  text-shadow: 0 0 30px rgba(0,200,255,0.8), 0 0 60px rgba(0,200,255,0.5), 0 0 120px rgba(0,200,255,0.3);
  animation: pulse-title 3s ease-in-out infinite;
  line-height: 1;
  text-transform: uppercase;
}
.hero-title .hero-atom { color: var(--cyan); }
.hero-title .hero-ica { color: var(--gold); text-shadow: 0 0 30px rgba(255,215,0,0.8), 0 0 60px rgba(255,215,0,0.5); }

@keyframes pulse-title {
  0%,100%{ text-shadow: 0 0 30px rgba(0,200,255,0.8), 0 0 60px rgba(0,200,255,0.4); }
  50%{ text-shadow: 0 0 50px rgba(0,200,255,1), 0 0 100px rgba(0,200,255,0.6), 0 0 150px rgba(0,200,255,0.3); }
}

.hero-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(0.85rem, 2vw, 1.15rem);
  color: var(--text);
  letter-spacing: 2px;
  margin: 1.5rem 0 3rem;
  text-transform: uppercase;
  font-weight: 500;
}

.hero-sub span {
  color: var(--cyan2);
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-primary {
  font-family: 'Exo 2', 'Orbitron', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 0.9rem 2rem;
  background: linear-gradient(135deg, rgba(0,200,255,0.18), rgba(0,255,204,0.12));
  border: 1px solid var(--cyan);
  color: var(--cyan);
  cursor: pointer;
  border-radius: 5px;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(0,200,255,0.3), inset 0 0 12px rgba(0,200,255,0.1);
}
.btn-primary::before {
  content:'';
  position:absolute;
  inset:0;
  background: linear-gradient(135deg, rgba(0,200,255,0.25), rgba(0,255,204,0.25));
  opacity:0;
  transition: opacity 0.25s;
}
.btn-primary:hover { box-shadow: 0 0 30px rgba(0,200,255,0.5), inset 0 0 16px rgba(0,200,255,0.2), 0 8px 32px rgba(0,200,255,0.2); transform: translateY(-3px) scale(1.02); }
.btn-primary:hover::before { opacity:1; }

.btn-secondary {
  font-family: 'Exo 2', 'Orbitron', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 0.9rem 2rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s;
  text-transform: uppercase;
}
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }

.hero-stats {
  display: flex;
  gap: 3rem;
  margin-top: 4rem;
  flex-wrap: wrap;
  justify-content: center;
}
.stat {
  text-align: center;
}
.stat-num {
  font-family: 'Orbitron', monospace;
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 20px rgba(0,200,255,0.8), 0 0 40px rgba(0,200,255,0.4);
}
.stat-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--text);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 0.3rem;
  font-weight: 500;
}

/* PERIODIC TABLE */
#elements {
  max-width: 1600px;
  margin: 0 auto;
}

.section-title {
  font-family: 'Exo 2', 'Orbitron', monospace;
  font-size: 2rem;
  font-weight: 800;
  color: var(--cyan);
  text-shadow: 0 0 25px rgba(0,200,255,0.7), 0 0 50px rgba(0,200,255,0.3);
  margin-bottom: 0.5rem;
  letter-spacing: 4px;
  text-transform: uppercase;
}
.section-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text);
  letter-spacing: 2px;
  margin-bottom: 2rem;
  text-transform: uppercase;
  font-weight: 500;
}

.search-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.search-input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  padding: 0.6rem 1rem;
  background: rgba(5,20,40,0.5);
  border: 1px solid rgba(0,200,255,0.3);
  color: var(--text);
  border-radius: 5px;
  width: 260px;
  outline: none;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  backdrop-filter: blur(8px);
}
.search-input:focus { border-color: var(--cyan); box-shadow: 0 0 16px rgba(0,200,255,0.4), inset 0 0 8px rgba(0,200,255,0.1); background: rgba(5,20,40,0.7); }
.search-input::placeholder { color: var(--text2); }

.filter-btns {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.filter-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid rgba(0,200,255,0.15);
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: rgba(255,255,255,0.03);
  color: var(--text2);
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  backdrop-filter: blur(2px);
}
.filter-btn:hover { color: var(--text); border-color: rgba(0,200,255,0.3); background: rgba(0,200,255,0.08); }
.filter-btn.active { background: rgba(0,200,255,0.18); color: var(--cyan); border-color: rgba(0,200,255,0.5); box-shadow: 0 0 12px rgba(0,200,255,0.2); }

/* Category colors */
.c-nonmetal { --cat-color: #22c55e; }
.c-noble { --cat-color: #a855f7; }
.c-alkali { --cat-color: #f97316; }
.c-alkaline { --cat-color: #eab308; }
.c-metalloid { --cat-color: #06b6d4; }
.c-halogen { --cat-color: #ec4899; }
.c-post { --cat-color: #64748b; }
.c-transition { --cat-color: #3b82f6; }
.c-lanthanide { --cat-color: #8b5cf6; }
.c-actinide { --cat-color: #ef4444; }
.c-unknown { --cat-color: #475569; }

.periodic-table {
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  gap: 3px;
  margin-bottom: 1.5rem;
  contain: layout;
}

.element-cell {
  aspect-ratio: 1;
  background: rgba(5,20,40,0.5);
  border: 1px solid rgba(var(--cat-color-rgb, 0,200,255),0.25);
  border-color: color-mix(in srgb, var(--cat-color) 40%, transparent);
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px;
  transition: transform 0.15s cubic-bezier(0.4,0,0.2,1), box-shadow 0.12s ease, opacity 0.15s ease, border-color 0.12s ease, background 0.12s ease;
  position: relative;
  overflow: hidden;
  min-width: 0;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3), inset 0 0 8px rgba(var(--cat-color-rgb, 0,200,255),0.1);
  will-change: transform, box-shadow;
  contain: paint;
  transform: translateZ(0);
}

.element-cell::before {
  content:'';
  position:absolute;
  inset:0;
  background: linear-gradient(135deg, var(--cat-color), rgba(var(--cat-color-rgb, 0,200,255),0.5));
  opacity:0;
  transition: opacity 0.12s ease;
  will-change: opacity;
}

.element-cell:hover {
  transform: scale(1.15) translateY(-4px) translateZ(0);
  z-index: 10;
  box-shadow: 0 12px 32px color-mix(in srgb, var(--cat-color) 60%, rgba(0,0,0,0.5)), inset 0 0 12px rgba(var(--cat-color-rgb, 0,200,255),0.15), 0 0 20px color-mix(in srgb, var(--cat-color) 40%, transparent);
  border-color: var(--cat-color);
  background: rgba(5,20,40,0.8);
}
.element-cell:hover::before { opacity: 0.15; }

.element-cell .el-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(0.35rem, 0.8vw, 0.6rem);
  color: var(--cat-color);
  line-height: 1;
  position: relative;
}
.element-cell .el-sym {
  font-family: 'Orbitron', monospace;
  font-size: clamp(0.6rem, 1.5vw, 1.1rem);
  font-weight: 700;
  color: #fff;
  line-height: 1;
  position: relative;
}
.element-cell .el-name {
  font-family: 'Rajdhani', sans-serif;
  font-size: clamp(0.32rem, 0.75vw, 0.62rem);
  color: var(--text2);
  text-align: center;
  line-height: 1;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
}

.element-cell.empty { background: transparent; border: none; cursor: default; box-shadow: none; backdrop-filter: none; pointer-events: none; animation: none !important; }
.element-cell.spacer { background: transparent; border: none; cursor: default; box-shadow: none; backdrop-filter: none; pointer-events: none; animation: none !important; }

.element-cell.dimmed { opacity: 0.15; }

.lanthanide-label, .actinide-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.55rem;
  color: var(--text2);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  animation: none !important;
  pointer-events: none;
  cursor: default;
}

/* ELEMENT MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
  padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
  background: linear-gradient(135deg, rgba(5,15,35,0.95), rgba(2,8,20,0.95));
  border: 1px solid rgba(0,200,255,0.35);
  border-radius: 12px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 60px rgba(0,200,255,0.25), inset 0 0 40px rgba(0,200,255,0.08), 0 20px 60px rgba(0,0,0,0.6);
  position: relative;
  backdrop-filter: blur(8px);
}

/* Mobile: full-screen bottom sheet */
@media(max-width:600px){
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    border-left: none; border-right: none; border-bottom: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: slideUp 0.3s cubic-bezier(0.22,1,0.36,1);
  }
  @keyframes slideUp {
    from { transform: translateY(100%); opacity: 0.5; }
    to   { transform: translateY(0);    opacity: 1; }
  }
  .modal-header { padding: 1rem 1rem 0; }
  .modal-body { grid-template-columns: 1fr !important; gap: 1rem; padding: 0.8rem 1rem 1.5rem; }
  .el-big-sym { font-size: 2.8rem; }
  #atom-canvas { height: 200px !important; }
  /* Swipe indicator bar at top */
  .modal::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: rgba(0,180,255,0.35);
    border-radius: 2px;
    margin: 10px auto 0;
  }
  /* Larger close button for thumb */
  .modal-close {
    font-size: 1.4rem;
    padding: 0.5rem 0.9rem;
    min-width: 44px; min-height: 44px;
  }
}

/* Landscape mobile: side-by-side compact */
@media(max-width:900px) and (orientation:landscape) and (max-height:500px){
  .modal-overlay { padding: 0.3rem; align-items: center; }
  .modal { max-height: 98vh; }
  .modal-body { grid-template-columns: 1fr 1fr !important; gap: 0.6rem; padding: 0.5rem 0.8rem 0.8rem; }
  .modal-header { padding: 0.5rem 0.8rem 0; }
  .el-big-sym { font-size: 2rem; }
  #atom-canvas { height: 160px !important; }
  .info-grid { grid-template-columns: 1fr 1fr; gap: 0.3rem; }
  .info-value { font-size: 0.78rem; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.5rem 1.5rem 0;
}

.modal-close {
  background: transparent;
  border: 1px solid rgba(0,200,255,0.2);
  color: var(--text2);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.3rem 0.7rem;
  border-radius: 5px;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  font-family: 'JetBrains Mono', monospace;
}
.modal-close:hover { color: var(--red); border-color: var(--red); box-shadow: 0 0 12px rgba(255,68,102,0.3); }

.modal-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 1rem 1.5rem 1.5rem;
}

@media(max-width:700px){
  .modal-body { grid-template-columns: 1fr; }
}

.modal-left {}

.el-big-sym {
  font-family: 'Orbitron', monospace;
  font-size: 5rem;
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 30px rgba(0,200,255,0.8), 0 0 60px rgba(0,200,255,0.5);
  line-height: 1;
}
.el-big-name {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text);
  margin: 0.4rem 0;
  letter-spacing: 0.5px;
}
.el-big-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text2);
  margin-bottom: 1rem;
  letter-spacing: 2px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.info-item {
  background: rgba(0,200,255,0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.7rem;
}
.info-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: var(--text2);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}
.info-value {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 600;
}

.el-desc {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.8;
  margin-top: 1rem;
  border-top: 1px solid rgba(0,200,255,0.2);
  padding-top: 1rem;
  font-weight: 500;
}

#atom-canvas-container {
  position: relative;
  background: radial-gradient(ellipse at center, rgba(0,40,80,0.5) 0%, rgba(0,0,0,0) 70%);
  border: 1px solid rgba(0,200,255,0.3);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 32px rgba(0,200,255,0.15), 0 0 24px rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
}

#atom-canvas {
  width: 100%;
  height: 320px;
  display: block;
  cursor: grab;
}
#atom-canvas:active { cursor: grabbing; }

.canvas-top-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  background: linear-gradient(to bottom, rgba(2,4,8,0.7), transparent);
  pointer-events: none;
  z-index: 5;
}
.canvas-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.55rem;
  color: rgba(122,168,204,0.7);
  letter-spacing: 1px;
}
.fullscreen-btn {
  pointer-events: all;
  background: rgba(0,200,255,0.1);
  border: 1px solid rgba(0,200,255,0.3);
  color: var(--cyan);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
}
.fullscreen-btn:hover { background: rgba(0,200,255,0.2); box-shadow: 0 0 10px rgba(0,200,255,0.3); }

/* Fullscreen atom overlay */
#atom-fullscreen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #020408;
  flex-direction: column;
}
#atom-fullscreen.open { display: flex; }

#atom-fullscreen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(2,4,8,0.95);
  flex-shrink: 0;
}
#atom-fullscreen-title {
  font-family: 'Exo 2', 'Orbitron', monospace;
  font-size: 1.2rem;
  color: var(--cyan);
  text-shadow: var(--glow);
  letter-spacing: 3px;
}
#atom-fullscreen-close {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  padding: 0.4rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  letter-spacing: 1px;
}
#atom-fullscreen-close:hover { color: var(--red); border-color: var(--red); }

#atom-fullscreen-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at center, rgba(0,40,80,0.5) 0%, #020408 70%);
}

#atom-fullscreen-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#atom-fullscreen-canvas:active { cursor: grabbing; }

#atom-fullscreen-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--border);
  background: rgba(2,4,8,0.95);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.zoom-btn {
  font-family: 'Orbitron', monospace;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.4rem 0.9rem;
  background: rgba(0,200,255,0.12);
  border: 1px solid rgba(0,200,255,0.3);
  color: var(--cyan);
  cursor: pointer;
  border-radius: 5px;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  line-height: 1;
  box-shadow: inset 0 0 8px rgba(0,200,255,0.1);
}
.zoom-btn:hover { background: rgba(0,200,255,0.2); box-shadow: var(--glow), inset 0 0 12px rgba(0,200,255,0.15); }

.zoom-level-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text2);
  min-width: 50px;
  text-align: center;
  letter-spacing: 1px;
}

.fs-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: rgba(122,168,204,0.5);
  letter-spacing: 1px;
  margin-left: 1rem;
}

.model-switch {
  display: flex;
  gap: 4px;
  padding: 0.5rem;
  border-top: 1px solid var(--border);
  justify-content: center;
}
.atom-legend {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding: 0.4rem 0.5rem;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  flex-wrap: wrap;
}
.atom-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: var(--text2);
  letter-spacing: 1px;
}
.atom-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.model-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  padding: 0.3rem 0.6rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
  letter-spacing: 1px;
}
.model-btn.active, .model-btn:hover {
  color: var(--cyan);
  border-color: var(--cyan);
  background: rgba(0,200,255,0.08);
}

/* QUIZ */
#quiz {
  max-width: 800px;
  margin: 0 auto;
}

.quiz-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.quiz-mode-card {
  background: linear-gradient(135deg, rgba(5,20,40,0.5), rgba(5,15,35,0.5));
  border: 1px solid rgba(0,200,255,0.25);
  border-radius: 10px;
  padding: 1.5rem;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4,0,0.2,1), box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease, opacity 0.2s ease;
  text-align: center;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3), inset 0 0 12px rgba(0,200,255,0.08);
  position: relative;
  will-change: transform, box-shadow;
  contain: layout style paint;
  transform: translateZ(0);
}
.quiz-mode-card:hover {
  border-color: var(--cyan);
  box-shadow: 0 16px 40px rgba(0,200,255,0.2), inset 0 0 20px rgba(0,200,255,0.15), 0 0 30px rgba(0,200,255,0.15);
  transform: translateY(-5px) scale(1.02) translateZ(0);
  background: linear-gradient(135deg, rgba(5,20,40,0.7), rgba(5,15,35,0.7));
}}
.quiz-mode-card .mode-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}
.quiz-mode-card .mode-title {
  font-family: 'Exo 2', 'Orbitron', monospace;
  font-size: 0.9rem;
  color: var(--cyan);
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 0.4rem;
}
.quiz-mode-card .mode-desc {
  font-size: 0.8rem;
  color: var(--text2);
}

.quiz-area {
  display: none;
}
.quiz-area.active { display: block; }

.quiz-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.4rem 1.2rem;
  background: linear-gradient(135deg, rgba(5,20,40,0.6), rgba(5,15,35,0.6));
  border: 1px solid rgba(0,200,255,0.3);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3), inset 0 0 12px rgba(0,200,255,0.1);
}
.quiz-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.quiz-score {
  font-family: 'Orbitron', monospace;
  font-size: 1rem;
  color: var(--gold);
}
.quiz-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  color: var(--cyan);
  text-shadow: var(--glow);
  font-variant-numeric: tabular-nums;
  min-width: 4ch;
  text-align: center;
  display: inline-block;
  font-weight: 700;
  letter-spacing: 2px;
}
.quiz-timer.danger { color: var(--red); text-shadow: 0 0 20px rgba(255,68,102,0.6); animation: blink 0.5s step-end infinite; }
@keyframes blink { 50%{opacity:0.4;} }

.quiz-question-box {
  background: linear-gradient(135deg, rgba(5,20,40,0.6), rgba(5,15,35,0.6));
  border: 1px solid rgba(0,200,255,0.3);
  border-radius: 10px;
  padding: 2.2rem;
  margin-bottom: 1.5rem;
  text-align: center;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3), inset 0 0 12px rgba(0,200,255,0.1);
}

.quiz-q-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text2);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.quiz-question-text {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.6;
  letter-spacing: 0.5px;
}

.quiz-question-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--cyan);
  margin-top: 0.5rem;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.quiz-option {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 1rem 1.2rem;
  background: rgba(5,20,40,0.5);
  border: 1px solid rgba(0,200,255,0.2);
  color: var(--text);
  cursor: pointer;
  border-radius: 7px;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  text-align: left;
  backdrop-filter: blur(4px);
}
.quiz-option:hover { border-color: var(--cyan); color: var(--cyan); background: rgba(0,200,255,0.12); box-shadow: 0 0 16px rgba(0,200,255,0.2), inset 0 0 8px rgba(0,200,255,0.1); }
.quiz-option.correct { border-color: var(--green); color: var(--green); background: rgba(34,197,94,0.15); box-shadow: 0 0 16px rgba(34,197,94,0.25); }
.quiz-option.wrong { border-color: var(--red); color: var(--red); background: rgba(255,68,102,0.15); box-shadow: 0 0 16px rgba(255,68,102,0.25); }
.quiz-option:disabled { cursor: not-allowed; }

.quiz-fill {
  width: 100%;
  font-family: 'Exo 2', 'Orbitron', monospace;
  font-size: 1.2rem;
  text-align: center;
  padding: 0.8rem;
  background: rgba(5,20,40,0.5);
  border: 1px solid rgba(0,200,255,0.2);
  color: var(--text);
  border-radius: 7px;
  outline: none;
  margin-bottom: 1rem;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  backdrop-filter: blur(4px);
}
.quiz-fill:focus { border-color: var(--cyan); box-shadow: 0 0 12px rgba(0,200,255,0.3), inset 0 0 8px rgba(0,200,255,0.1); }
.quiz-fill.correct { border-color: var(--green); color: var(--green); }
.quiz-fill.wrong { border-color: var(--red); color: var(--red); }

.quiz-feedback {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1rem;
  text-align: center;
  padding: 0.8rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  display: none;
}
.quiz-feedback.show { display: block; }
.quiz-feedback.ok { background: rgba(34,197,94,0.12); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.quiz-feedback.bad { background: rgba(255,68,102,0.12); color: var(--red); border: 1px solid rgba(255,68,102,0.3); }

.quiz-next-btn {
  width: 100%;
  font-family: 'Exo 2', 'Orbitron', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 0.9rem;
  background: linear-gradient(135deg, rgba(0,200,255,0.18), rgba(0,255,204,0.12));
  border: 1px solid var(--cyan);
  color: var(--cyan);
  cursor: pointer;
  border-radius: 7px;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  display: none;
  box-shadow: 0 0 20px rgba(0,200,255,0.3), inset 0 0 8px rgba(0,200,255,0.1);
}
.quiz-next-btn.show { display: block; }
.quiz-next-btn:hover { box-shadow: 0 0 30px rgba(0,200,255,0.5), inset 0 0 12px rgba(0,200,255,0.2), 0 8px 32px rgba(0,200,255,0.2); transform: translateY(-2px) scale(1.01); }

.quiz-results {
  display: none;
  text-align: center;
  padding: 3rem;
  background: linear-gradient(135deg, rgba(5,20,40,0.6), rgba(5,15,35,0.6));
  border: 1px solid rgba(0,200,255,0.3);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 48px rgba(0,0,0,0.4), inset 0 0 20px rgba(0,200,255,0.12);
}
.quiz-results.show { display: block; }

.results-score {
  font-family: 'Orbitron', monospace;
  font-size: 4rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(255,215,0,0.5);
  margin-bottom: 0.5rem;
}
.results-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text2);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 2rem;
}
.results-msg {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 2rem;
}

/* COMPOUNDS */
#compounds {
  max-width: 1000px;
  margin: 0 auto;
}

.compounds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.compound-card {
  background: linear-gradient(135deg, rgba(5,20,40,0.5), rgba(5,15,35,0.5));
  border: 1px solid rgba(0,200,255,0.25);
  border-radius: 10px;
  padding: 1.2rem;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4,0,0.2,1), box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3), inset 0 0 12px rgba(0,200,255,0.08);
  will-change: transform, box-shadow;
  contain: layout style paint;
  transform: translateZ(0);
}
.compound-card::before {
  content:'';
  position:absolute;
  top:0;left:0;right:0;
  height:2px;
  background: linear-gradient(90deg, var(--cyan), var(--cyan2));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 0 12px rgba(0,200,255,0.6);
  will-change: transform;
}
.compound-card:hover { border-color: var(--cyan); box-shadow: 0 16px 40px rgba(0,200,255,0.2), inset 0 0 20px rgba(0,200,255,0.15), 0 0 30px rgba(0,200,255,0.15); transform: translateY(-5px) scale(1.02) translateZ(0); background: linear-gradient(135deg, rgba(5,20,40,0.7), rgba(5,15,35,0.7)); }
.compound-card:hover::before { transform: scaleX(1); }

.compound-formula {
  font-family: 'Orbitron', monospace;
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 20px rgba(0,200,255,0.8), 0 0 40px rgba(0,200,255,0.4);
  margin-bottom: 0.3rem;
  letter-spacing: 1px;
}
.compound-name {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
  letter-spacing: 0.3px;
}
.compound-type {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 2px;
  border: 1px solid;
  display: inline-block;
  margin-bottom: 0.7rem;
}
.compound-type.organic { color: var(--green); border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.08); }
.compound-type.inorganic { color: var(--cyan); border-color: rgba(0,200,255,0.4); background: rgba(0,200,255,0.08); }
.compound-type.industrial { color: var(--gold); border-color: rgba(255,215,0,0.4); background: rgba(255,215,0,0.08); }

.compound-desc {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.82rem;
  color: var(--text2);
  line-height: 1.6;
}

/* Compound test */
.compound-test-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(0,200,255,0.3); border-radius: 3px; }

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  color: var(--text2);
  letter-spacing: 1px;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  transition: all 0.2s;
}
.legend-item:hover { background: rgba(255,255,255,0.05); }
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Progress bar for quiz timer */
.timer-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 99px;
  margin-top: 0.6rem;
  overflow: hidden;
  border: 1px solid rgba(0,200,255,0.12);
  position: relative;
}
.timer-bar {
  height: 100%;
  border-radius: 99px;
  transition: background 0.4s;
  background: linear-gradient(90deg, #00c8ff, #00ffcc);
  box-shadow: 0 0 12px rgba(0,200,255,0.7), 0 0 24px rgba(0,200,255,0.3);
  position: relative;
}
.timer-bar::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 20px;
  background: rgba(255,255,255,0.35);
  border-radius: 99px;
  filter: blur(3px);
}
.timer-bar.danger {
  background: linear-gradient(90deg, #ff2244, #ff8800);
  box-shadow: 0 0 14px rgba(255,50,50,0.8), 0 0 28px rgba(255,100,0,0.4);
}

/* Back button */
.back-btn {
  font-family: 'Exo 2', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 2px;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid rgba(0,200,255,0.2);
  color: var(--text2);
  cursor: pointer;
  border-radius: 5px;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  margin-bottom: 1.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.back-btn:hover { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 12px rgba(0,200,255,0.3); }

/* Category selector for quiz */
.quiz-category-select {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  padding: 0.4rem 1.75rem 0.4rem 0.65rem;
  border: 1px solid rgba(0,200,255,0.4);
  color: var(--cyan);
  border-radius: 5px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2300b4ff'/%3E%3C/svg%3E") no-repeat right 0.65rem center / 8px,
    linear-gradient(135deg, rgba(0,200,255,0.12), rgba(0,150,255,0.06));
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  letter-spacing: 0.5px;
  box-shadow: inset 0 0 8px rgba(0,200,255,0.1);
}
.quiz-category-select:hover {
  border-color: var(--cyan);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2300b4ff'/%3E%3C/svg%3E") no-repeat right 0.65rem center / 8px,
    linear-gradient(135deg, rgba(0,200,255,0.18), rgba(0,150,255,0.1));
  box-shadow: inset 0 0 12px rgba(0,200,255,0.15), 0 0 12px rgba(0,200,255,0.2);
}
.quiz-category-select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,180,255,0.2), inset 0 0 12px rgba(0,180,255,0.15);
}

.quiz-config {
  background: linear-gradient(135deg, rgba(5,20,40,0.5), rgba(5,15,35,0.5));
  border: 1px solid rgba(0,200,255,0.25);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: visible;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3), inset 0 0 12px rgba(0,200,255,0.08);
}
.quiz-config-title {
  font-family: 'Exo 2', 'Orbitron', monospace;
  font-size: 0.8rem;
  color: var(--cyan);
  letter-spacing: 2px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  line-height: 1;
}
.quiz-config-title::before {
  content: '';
  display: inline-block;
  margin-top: -0.15em;
}
.quiz-config-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}
.quiz-config-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text2);
  letter-spacing: 1px;
  min-width: 80px;
}

.start-quiz-btn {
  font-family: 'Exo 2', 'Orbitron', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 0.8rem 2rem;
  background: linear-gradient(135deg, rgba(0,200,255,0.18), rgba(0,255,204,0.12));
  border: 1px solid var(--cyan);
  color: var(--cyan);
  cursor: pointer;
  border-radius: 7px;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  width: 100%;
  margin-top: 0.5rem;
  box-shadow: 0 0 20px rgba(0,200,255,0.3), inset 0 0 8px rgba(0,200,255,0.1);
}
.start-quiz-btn:hover { box-shadow: 0 0 30px rgba(0,200,255,0.5), inset 0 0 12px rgba(0,200,255,0.2), 0 8px 32px rgba(0,200,255,0.2); transform: translateY(-2px) scale(1.01); }

select option { 
  background: #030a18;
  color: var(--cyan);
}

/* Animated entry */
@keyframes elReveal {
  from { opacity:0; transform: translateY(12px) scale(0.94); }
  to   { opacity:1; transform: translateY(0)   scale(1);    }
}
.element-cell {
  animation: elReveal 0.4s cubic-bezier(0.22,1,0.36,1) backwards;
  transition: opacity 0.2s cubic-bezier(0.4,0,0.2,1), transform 0.2s cubic-bezier(0.4,0,0.2,1), background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.element-cell.dimmed {
  opacity: 0.12 !important;
  transform: scale(0.97);
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.element-cell.tbl-visible {
  opacity: 1 !important;
  transform: scale(1);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

/* SANDBOX */
#sandbox {
  max-width: 100%;
  padding: 80px 0.8rem 0.6rem;
  height: 100vh;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  box-sizing: border-box;
}
#sandbox.active {
  display: flex !important;
}
.sb-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.35rem; flex-shrink: 0; flex-wrap: wrap; gap: 0.3rem;
  padding-bottom: 0.25rem; border-bottom: 1px solid rgba(0,180,255,0.08);
}
/* sb-title-wrap removed */
.sb-progress {
  font-family: 'JetBrains Mono', monospace; font-size: 0.65rem;
  color: var(--gold); letter-spacing: 1px;
}
.sb-grid {
  flex: 1; display: grid;
  grid-template-columns: 220px 1fr 220px;
  gap: 0.6rem; min-height: 0; overflow: hidden; height: 0;
}
@media(max-width:900px){
  .sb-grid { grid-template-columns: 1fr; height: auto; overflow: auto; }
  #sandbox { height: auto; overflow-y: auto; overflow-x: hidden; }
}

/* Shared panel */
.sb-panel {
  background: rgba(3,10,24,0.7);
  border: 1px solid rgba(0,180,255,0.2);
  border-radius: 8px; 
  display: flex; 
  flex-direction: column; 
  overflow: hidden;
  min-height: 0;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3), inset 0 0 12px rgba(0,180,255,0.08);
}
.sb-ph {
  font-family: 'JetBrains Mono', monospace; font-size: 0.52rem;
  letter-spacing: 3px; text-transform: uppercase; color: var(--cyan);
  padding: 0.4rem 0.65rem; border-bottom: 1px solid rgba(0,180,255,0.1);
  background: rgba(0,180,255,0.04); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
}
.sb-ph-badge {
  font-family: 'JetBrains Mono', monospace; font-size: 0.52rem;
  color: var(--gold); padding: 0.08rem 0.4rem;
  border: 1px solid rgba(255,215,0,0.3); border-radius: 10px;
}
.sb-scroll {
  flex: 1; overflow-y: auto; padding: 0.45rem; min-height: 0; overflow-x: hidden;
}
.sb-scroll::-webkit-scrollbar { width: 3px; }
.sb-scroll::-webkit-scrollbar-thumb { background: rgba(0,180,255,0.2); border-radius: 2px; }

/* Left sidebar */
.sb-left { display: flex; flex-direction: column; gap: 0.5rem; height: 100%; overflow: hidden; }
.sb-left .sb-panel:first-child { flex: 1 1 0; min-height: 0; }
.sb-left .sb-panel:last-child { flex: 0 0 38%; min-height: 160px; overflow: hidden; }
.sb-search {
  font-family: 'JetBrains Mono', monospace; font-size: 0.58rem;
  width: 100%; background: rgba(0,180,255,0.05);
  border: 1px solid rgba(0,180,255,0.12); color: var(--text);
  border-radius: 3px; padding: 0.22rem 0.45rem; outline: none;
  transition: border-color 0.15s;
}
.sb-search:focus { border-color: rgba(0,180,255,0.35); }
.sb-search::placeholder { color: var(--text2); }
.sb-search-wrap { padding: 0.35rem 0.45rem; border-bottom: 1px solid rgba(0,180,255,0.08); flex-shrink: 0; }

/* Element category + grid */
.sb-cat-lbl {
  font-family: 'JetBrains Mono', monospace; font-size: 0.44rem;
  letter-spacing: 2px; text-transform: uppercase; color: var(--text2);
  padding: 0.3rem 0.15rem 0.12rem; margin-top: 0.25rem;
  opacity: 0.7;
}
.sb-el-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; margin-bottom: 3px; }
.sb-el-btn {
  border-radius: 3px; border: 1px solid; padding: 3px 1px;
  cursor: pointer; text-align: center; transition: transform 0.1s, box-shadow 0.1s;
  background: rgba(3,10,24,0.9); position: relative;
}
.sb-el-btn:hover { transform: scale(1.14); z-index: 5; }
.sb-el-btn.in-slot { outline: 2px solid var(--gold); outline-offset: 1px; }
.sb-el-sym {
  font-family: 'Exo 2', 'Orbitron', monospace; font-size: 0.66rem;
  font-weight: 700; display: block; line-height: 1.15;
}
.sb-el-z {
  font-family: 'JetBrains Mono', monospace; font-size: 0.36rem;
  color: rgba(255,255,255,0.38); display: block;
}

/* Compound list */
.sb-comp-btn {
  width: 100%; text-align: left; padding: 0.3rem 0.45rem;
  margin-bottom: 3px; background: rgba(3,10,24,0.85);
  border: 1px solid rgba(0,180,255,0.15); border-radius: 4px;
  cursor: pointer; transition: all 0.13s; display: flex; align-items: center; gap: 0.4rem;
}
.sb-comp-btn:hover { border-color: rgba(0,180,255,0.5); background: rgba(0,180,255,0.08); }
.sb-comp-btn.in-slot { border-color: var(--gold); background: rgba(255,215,0,0.08); }
.sb-comp-f { font-family: 'JetBrains Mono', monospace; font-size: 0.64rem; color: var(--cyan); min-width: 62px; font-weight: 700; }
.sb-comp-n { font-family: 'Rajdhani', sans-serif; font-size: 0.72rem; color: var(--text); }

/* Center arena */
.sb-arena { display: flex; flex-direction: column; gap: 0.45rem; min-height: 0; height: 100%; }

/* Slots row */
.sb-slots-row { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.sb-slot {
  flex: 1; min-height: 70px;
  background: rgba(3,10,24,0.95); border: 1.5px dashed rgba(0,180,255,0.2);
  border-radius: 7px; padding: 0.4rem 0.6rem; cursor: pointer;
  transition: all 0.18s; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.sb-slot:hover { border-color: rgba(0,180,255,0.4); }
.sb-slot.filled { border-style: solid; border-color: var(--cyan); }
.sb-slot-lbl {
  font-family: 'JetBrains Mono', monospace; font-size: 0.46rem;
  color: var(--text2); letter-spacing: 2px; margin-bottom: 0.22rem;
}
.sb-slot-empty { font-family: 'JetBrains Mono', monospace; font-size: 0.58rem; color: rgba(90,138,170,0.35); text-align: center; }
.sb-slot-sym { font-family: 'Orbitron', monospace; font-size: 1.65rem; font-weight: 900; line-height: 1; }
.sb-slot-sub { font-family: 'Rajdhani', sans-serif; font-size: 0.7rem; color: var(--text2); }
.sb-slot-clr { font-family: 'JetBrains Mono', monospace; font-size: 0.42rem; color: rgba(255,60,60,0.4); margin-top: 2px; }
.sb-plus { font-family: 'Orbitron', monospace; font-size: 1.4rem; color: var(--text2); flex-shrink: 0; }

/* Conditions */
.sb-conds {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem;
  background: rgba(3,8,18,0.92); border: 1px solid rgba(0,180,255,0.1);
  border-radius: 5px; padding: 0.28rem 0.5rem; flex-shrink: 0;
}
.sb-cond-lbl {
  font-family: 'JetBrains Mono', monospace; font-size: 0.46rem;
  color: var(--text2); letter-spacing: 2px; margin-right: 0.2rem;
}
.sb-cond-btn {
  font-family: 'Exo 2', sans-serif; font-weight: 600; font-size: 0.52rem;
  padding: 0.16rem 0.48rem; border: 1px solid rgba(255,255,255,0.09);
  border-radius: 3px; background: rgba(255,255,255,0.03);
  color: var(--text2); cursor: pointer; transition: all 0.13s; letter-spacing: 0.5px;
}
.sb-cond-btn:hover { border-color: rgba(255,255,255,0.22); color: var(--text); }
.sb-cond-btn.on { border-color: var(--gold); color: var(--gold); background: rgba(255,215,0,0.08); }

/* React btn */
.sb-react-btn {
  width: 100%; font-family: 'Exo 2', 'Orbitron', monospace; font-size: 0.78rem;
  font-weight: 700; letter-spacing: 3px; padding: 0.45rem;
  background: linear-gradient(135deg, rgba(0,180,255,0.18), rgba(0,255,204,0.12));
  border: 1.5px solid var(--cyan); color: var(--cyan);
  cursor: pointer; border-radius: 6px; transition: all 0.25s cubic-bezier(0.4,0,0.2,1); flex-shrink: 0;
  box-shadow: 0 0 20px rgba(0,180,255,0.3), inset 0 0 8px rgba(0,180,255,0.1);
}
.sb-react-btn:hover:not(:disabled) { box-shadow: 0 0 30px rgba(0,180,255,0.5), inset 0 0 12px rgba(0,180,255,0.2), 0 8px 32px rgba(0,180,255,0.2); transform: translateY(-2px) scale(1.01); }
.sb-react-btn:disabled { opacity: 0.35; cursor: not-allowed; border-color: rgba(0,180,255,0.2); color: var(--text2); }

/* Chamber */
.sb-chamber {
  flex: 1; position: relative; border-radius: 7px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 85%, rgba(0,25,55,0.5) 0%, rgba(1,3,8,0.99) 75%);
  border: 1px solid rgba(0,180,255,0.12); min-height: 200px;
}
#rxCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sb-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(1,4,10,0.97) 28%);
  padding: 0.8rem 1rem 0.65rem; display: none; pointer-events: none;
}
.sb-overlay.show { display: block; }
.sb-ov-badges { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 0.3rem; justify-content: center; }
.sb-badge {
  font-family: 'JetBrains Mono', monospace; font-size: 0.46rem;
  letter-spacing: 2px; padding: 0.1rem 0.42rem; border-radius: 2px; border: 1px solid;
}
.sb-badge.exo     { color: #ff7744; border-color: rgba(255,100,60,0.4);  background: rgba(255,80,40,0.07); }
.sb-badge.endo    { color: #6699ff; border-color: rgba(100,150,255,0.4); background: rgba(100,150,255,0.07); }
.sb-badge.neutral { color: var(--green); border-color: rgba(34,220,100,0.4); background: rgba(34,220,100,0.07); }
.sb-badge.danger  { color: var(--red);  border-color: rgba(255,50,80,0.4);  background: rgba(255,50,80,0.07); }
.sb-badge.toxic   { color: #aaff22; border-color: rgba(160,255,30,0.4);  background: rgba(160,255,30,0.05); }
.sb-badge.explosive { color: var(--gold); border-color: rgba(255,215,0,0.4); background: rgba(255,215,0,0.07); }
.sb-ov-formula { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; color: var(--cyan); text-align: center; text-shadow: 0 0 12px rgba(0,180,255,0.5); }
.sb-ov-name { font-family: 'Exo 2', 'Orbitron', monospace; font-size: 0.72rem; font-weight: 700; color: var(--gold); text-align: center; letter-spacing: 2px; margin: 0.2rem 0; }
.sb-ov-desc { font-family: 'Rajdhani', sans-serif; font-size: 0.82rem; color: var(--text2); text-align: center; line-height: 1.45; }
.sb-no-rx {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  text-align: center; font-family: 'JetBrains Mono', monospace; font-size: 0.62rem;
  color: var(--text2); padding: 1rem; display: none; pointer-events: none;
}
.sb-no-rx.show { display: block; }
.sb-idle {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}
.sb-idle-icon { font-size: 2.2rem; opacity: 0.2; margin-bottom: 0.4rem; }
.sb-idle-txt { font-family: 'JetBrains Mono', monospace; font-size: 0.55rem; color: var(--text2); letter-spacing: 1px; opacity: 0.5; }

/* Right sidebar */
.sb-right { display: flex; flex-direction: column; gap: 0.5rem; height: 100%; overflow: hidden; }
.sb-right .sb-panel:first-child { flex: 1 1 0; min-height: 0; }
.sb-right .sb-panel:last-child  { flex: 1 1 0; min-height: 0; }
.sb-log-entry {
  border-radius: 4px; border: 1px solid rgba(0,180,255,0.1);
  margin-bottom: 4px; background: rgba(3,10,24,0.8);
  cursor: pointer; transition: all 0.13s; overflow: hidden;
}
.sb-log-entry:hover { border-color: rgba(0,180,255,0.35); background: rgba(0,180,255,0.05); }
.sb-log-hdr { padding: 0.35rem 0.5rem 0.3rem; display: flex; align-items: flex-start; gap: 0.4rem; }
.sb-log-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin-top: 3px; }
.sb-log-f { font-family: 'JetBrains Mono', monospace; font-size: 0.6rem; color: var(--cyan); }
.sb-log-n { font-family: 'Exo 2', 'Orbitron', monospace; font-size: 0.62rem; color: var(--gold); letter-spacing: 1px; margin-top: 3px; }
.sb-log-product { font-family: 'JetBrains Mono', monospace; font-size: 0.6rem; color: var(--cyan); margin-top: 4px; background: rgba(0,180,255,0.1); padding: 2px 6px; border-radius: 3px; display: inline-block; }
.sb-log-desc { font-family: 'Rajdhani', sans-serif; font-size: 0.78rem; color: var(--text); line-height: 1.5; padding: 0.3rem 0.55rem 0.5rem 1.1rem; border-top: 1px solid rgba(0,180,255,0.1); }
.sb-log-empty { font-family: 'JetBrains Mono', monospace; font-size: 0.55rem; color: var(--text2); text-align: center; padding: 1rem 0; opacity: 0.5; }
.sb-ux-entry {
  border-radius: 4px; border: 1px solid rgba(0,180,255,0.12);
  margin-bottom: 3px; padding: 0.28rem 0.45rem;
  background: rgba(3,10,24,0.7);
}
.sb-ux-entry.hint { cursor: pointer; transition: border-color 0.12s, background 0.12s; }
.sb-ux-entry.hint:hover { border-color: rgba(0,180,255,0.45); background: rgba(0,180,255,0.06); }
.sb-ux-f { font-family: 'JetBrains Mono', monospace; font-size: 0.62rem; font-weight: 700; }
.sb-ux-product { display: none; }
.sb-ux-name { display: none; }
.sb-ux-desc { display: none; }
.sb-ux-h { font-family: 'JetBrains Mono', monospace; font-size: 0.44rem; color: var(--text2); margin-top: 1px; opacity: 0.55; letter-spacing: 0.5px; }
.sb-ux-locked { font-family: 'JetBrains Mono', monospace; font-size: 0.52rem; color: var(--text2); letter-spacing: 2px; opacity: 0.4; }
.sb-ux-all { text-align: center; padding: 1rem; font-family: 'Exo 2', 'Orbitron', monospace; font-size: 0.62rem; color: var(--gold); }


/* ══ TIMELINE ══════════════════════════════════════════════════ */
#timeline {
  padding: 80px 0 0 !important;
  height: 100vh;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}
#timeline.active { display: flex !important; }
.tl-layout {
  flex: 1; display: grid;
  grid-template-columns: 340px 1fr;
  gap: 12px; overflow: hidden; min-height: 0;
  padding: 0 0 12px 0;
}
@media(max-width:768px){
  .tl-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: 100%; }
  .tl-rail-wrap { max-height: 48vh; }
  .tl-blog-wrap { position: relative; }
}

/* Rail (left) */
.tl-rail-wrap {
  border: 1px solid rgba(0,180,255,0.2);
  border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
  background: rgba(2,10,25,0.55);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.tl-header { padding: 1rem 1rem 0.5rem; flex-shrink: 0; border-bottom: 1px solid rgba(0,180,255,0.1); }
.tl-search {
  width: 100%;
  font-family: 'JetBrains Mono', monospace; font-size: 0.72rem;
  background: rgba(0,180,255,0.06); border: 1px solid rgba(0,180,255,0.18);
  color: var(--text); border-radius: 4px; padding: 0.35rem 0.65rem; outline: none;
  transition: border-color 0.2s; letter-spacing: 0.5px;
}
.tl-search:focus { border-color: rgba(0,180,255,0.45); }
.tl-search::placeholder { color: var(--text2); opacity: 0.6; }
.tl-rail {
  flex: 1; overflow-y: auto; padding: 0.6rem 0;
}
.tl-rail::-webkit-scrollbar { width: 4px; }
.tl-rail::-webkit-scrollbar-thumb { background: rgba(0,180,255,0.22); border-radius: 2px; }

/* Era group */
.tl-era-label {
  font-family: 'JetBrains Mono', monospace; font-size: 0.6rem;
  letter-spacing: 3px; text-transform: uppercase;
  color: var(--text2); opacity: 0.7;
  padding: 0.7rem 1rem 0.3rem;
  margin-top: 0.3rem;
}

/* Timeline event card */
.tl-event {
  display: flex; align-items: flex-start; gap: 0.65rem;
  padding: 0.85rem 1.1rem; cursor: pointer; transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  border-left: 2px solid rgba(0,180,255,0.2); margin: 2px 0;
  position: relative;
  border-radius: 4px;
  background: rgba(0,180,255,0.04);
}
.tl-event:hover { background: rgba(0,180,255,0.12); border-left-color: var(--cyan); box-shadow: inset 0 0 12px rgba(0,180,255,0.1); }
.tl-event.active-ev { background: rgba(0,180,255,0.18); border-left-color: var(--cyan); box-shadow: inset 0 0 16px rgba(0,180,255,0.15), 0 0 12px rgba(0,180,255,0.2); }
.tl-event-dot {
  width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0;
  margin-top: 5px; border: 1.5px solid rgba(255,255,255,0.25);
  box-shadow: 0 0 8px currentColor;
}
.tl-event-content { flex: 1; min-width: 0; }
.tl-event-year {
  font-family: 'Orbitron', monospace; font-size: 0.82rem;
  font-weight: 700; letter-spacing: 1px; margin-bottom: 2px;
}
.tl-event-name {
  font-family: 'Rajdhani', sans-serif; font-size: 1.05rem;
  font-weight: 600; color: var(--text); line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tl-event-who {
  font-family: 'JetBrains Mono', monospace; font-size: 0.62rem;
  color: var(--text2); margin-top: 3px; opacity: 0.8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tl-event-cat {
  font-family: 'JetBrains Mono', monospace; font-size: 0.52rem;
  letter-spacing: 1.5px; text-transform: uppercase;
  padding: 0.12rem 0.45rem; border-radius: 2px; border: 1px solid;
  margin-top: 4px; display: inline-block;
}

/* Blog article (right) */
.tl-blog-wrap {
  overflow-y: auto; padding: 0;
  background: rgba(2,10,25,0.45);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0,200,255,0.15);
  border-radius: 14px;
  display: flex; flex-direction: column;
}
.tl-blog-wrap::-webkit-scrollbar { width: 5px; }
.tl-blog-wrap::-webkit-scrollbar-thumb { background: rgba(0,180,255,0.2); border-radius: 3px; }
.tl-blog-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: rgba(90,138,170,0.3);
  font-family: 'JetBrains Mono', monospace; font-size: 0.72rem;
  letter-spacing: 2px; text-transform: uppercase; gap: 0.8rem;
}
.tl-blog-empty-icon { font-size: 3rem; opacity: 0.2; }

.tl-article { padding: 2.5rem 3rem 3rem; max-width: 100%; animation: tlFadeIn 0.35s ease; }
@keyframes tlFadeIn { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }

.tl-art-meta { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.8rem; }
.tl-art-year {
  font-family: 'Orbitron', monospace; font-size: 1.4rem;
  font-weight: 900; color: var(--cyan); text-shadow: var(--glow); letter-spacing: 2px;
}
.tl-art-cat {
  font-family: 'JetBrains Mono', monospace; font-size: 0.6rem;
  letter-spacing: 2px; text-transform: uppercase;
  padding: 0.2rem 0.6rem; border-radius: 3px; border: 1px solid;
}
.tl-art-title {
  font-family: 'Exo 2', 'Orbitron', monospace;
  font-size: clamp(1.4rem, 3vw, 2.2rem); font-weight: 700;
  color: var(--text); line-height: 1.2; margin-bottom: 0.5rem;
}
.tl-art-subtitle {
  font-family: 'Rajdhani', sans-serif; font-size: 1.05rem;
  color: var(--text2); margin-bottom: 1.2rem; line-height: 1.5; font-style: italic;
}
.tl-art-persons {
  display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem;
}
.tl-person-chip {
  font-family: 'JetBrains Mono', monospace; font-size: 0.65rem;
  padding: 0.25rem 0.7rem; border-radius: 4px; letter-spacing: 0.5px;
  background: rgba(0,180,255,0.08); border: 1px solid rgba(0,180,255,0.25); color: var(--cyan);
}
.tl-art-body {
  font-family: 'Rajdhani', sans-serif; font-size: 1rem;
  color: var(--text); line-height: 1.8; margin-bottom: 2rem;
}
.tl-art-body p { margin-bottom: 1rem; }
.tl-art-body strong { color: var(--cyan); font-weight: 700; }
.tl-art-body em { color: var(--gold); font-style: normal; font-weight: 600; }
.tl-art-body .tl-quote {
  border-left: 3px solid var(--cyan); padding: 0.5rem 1rem;
  margin: 1rem 0; color: var(--text2); font-style: italic;
  background: rgba(0,180,255,0.04); border-radius: 0 4px 4px 0;
}
.tl-art-impact {
  background: rgba(0,180,255,0.12); border: 1px solid rgba(0,180,255,0.3);
  border-radius: 8px; padding: 1.2rem; margin-bottom: 1.5rem;
  backdrop-filter: blur(4px);
  box-shadow: inset 0 0 16px rgba(0,180,255,0.1), 0 0 16px rgba(0,180,255,0.08);
}
.tl-impact-label {
  font-family: 'JetBrains Mono', monospace; font-size: 0.58rem;
  letter-spacing: 3px; text-transform: uppercase; color: var(--cyan);
  margin-bottom: 0.5rem;
}
.tl-impact-text {
  font-family: 'Rajdhani', sans-serif; font-size: 0.92rem;
  color: var(--text2); line-height: 1.6;
}
.tl-art-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tl-tag {
  font-family: 'JetBrains Mono', monospace; font-size: 0.58rem;
  padding: 0.18rem 0.55rem; border-radius: 3px; letter-spacing: 1px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1); color: var(--text2);
}

/* Category colours */
.cat-discovery  { color:#22c55e; border-color:rgba(34,197,94,0.4);  background:rgba(34,197,94,0.08);  }
.cat-theory     { color:#60a5fa; border-color:rgba(96,165,250,0.4); background:rgba(96,165,250,0.08); }
.cat-invention  { color:#f97316; border-color:rgba(249,115,22,0.4); background:rgba(249,115,22,0.08); }
.cat-industry   { color:#eab308; border-color:rgba(234,179,8,0.4);  background:rgba(234,179,8,0.08);  }
.cat-synthesis  { color:#a855f7; border-color:rgba(168,85,247,0.4); background:rgba(168,85,247,0.08); }
.cat-danger     { color:#ef4444; border-color:rgba(239,68,68,0.4);  background:rgba(239,68,68,0.08);  }
.cat-instrument { color:#06b6d4; border-color:rgba(6,182,212,0.4);  background:rgba(6,182,212,0.08);  }


/* ══ MOBILE OPTIMISATION (@media max-width:600px) ═══════════════ */
@media(max-width:600px){
  /* Nav */
  .logo { font-size:1.1rem; letter-spacing:3px; }
  nav { padding: 0 0.8rem; }
  .lang-toggle { gap:3px; }
  .lang-btn { font-size:0.58rem; padding:0.18rem 0.45rem; }

  /* Sections */
  section { padding: 70px 0.9rem 1rem; }
  #sandbox { padding: 70px 0 0 !important; }
  #timeline { padding: 70px 0 0 !important; }

  /* Hero */
  #home.active { padding-top: 60px; }
  .hero-title { font-size: clamp(2.6rem, 12vw, 4rem); letter-spacing:4px; }
  .hero-sub { font-size: 0.68rem; letter-spacing:2px; margin: 1rem 0 2rem; }
  .hero-buttons { gap: 0.6rem; }
  .btn-primary, .btn-secondary { font-size:0.72rem; padding:0.65rem 1.1rem; letter-spacing:1.5px; }
  .hero-stats { gap:1.5rem; margin-top:2.5rem; }
  .stat-num { font-size:1.5rem; }

  /* Periodic table */
  .periodic-table { gap:2px; }
  .element-cell .el-sym { font-size: clamp(0.45rem, 2.5vw, 0.85rem); }
  .element-cell .el-name { display:none; }

  /* Modal */
  .modal-body { grid-template-columns: 1fr; gap:0.8rem; }
  .modal { max-height: 85vh; }
  .el-big-sym { font-size:3.5rem; }

  /* Quiz */
  .quiz-modes { grid-template-columns:1fr; }
  .quiz-options { grid-template-columns:1fr; }
  .quiz-config-row { flex-direction:column; gap:0.5rem; }
  .quiz-category-select { width:100%; }
  .quiz-header { flex-wrap:wrap; gap:0.4rem; }
  /* Hide legend on mobile to save space */
  .periodic-legend { display: none; }
  /* Compact filter buttons on mobile */
  .filters-wrap { gap: 0.3rem; }
  .filter-btn { font-size: 0.55rem; padding: 0.22rem 0.5rem; letter-spacing: 1px; }
  .search-input { font-size: 0.78rem; padding: 0.4rem 0.7rem; }

  /* Sandbox */
  .sb-grid { grid-template-columns: 1fr !important; height:auto; overflow:auto; }
  .sb-left, .sb-right { max-height:none; }
  .sb-chamber { min-height:240px; }
  .sb-slots-row { gap:0.3rem; }
  .sb-slot { min-height:65px; padding:0.35rem 0.4rem; }
  .sb-slot-sym { font-size:1.35rem; }
  .sb-conds { padding:0.3rem 0.4rem; gap:0.2rem; flex-wrap:wrap; }
  .sb-cond-btn { font-size:0.5rem; padding:0.15rem 0.38rem; }
  .sb-react-btn { font-size:0.72rem; padding:0.45rem; letter-spacing:2px; }
  .sb-ph { font-size:0.5rem; letter-spacing:2px; }
  .sb-el-btn .esym { font-size:0.6rem; }
  .sb-el-btn .enum { font-size:0.36rem; }
  .sb-comp-f { font-size:0.58rem; min-width:50px; }
  .sb-comp-n { font-size:0.64rem; }
  .sb-ov-formula { font-size:0.78rem; }
  .sb-ov-name { font-size:0.65rem; }
  .sb-ov-desc { font-size:0.75rem; }

  /* Timeline */
  .tl-layout { grid-template-columns:1fr !important; grid-template-rows: auto 1fr; }
  .tl-rail-wrap { max-height: 40vh; min-height: 200px; }
  .tl-blog-wrap { border-top: 1px solid rgba(0,180,255,0.15); overflow-y: auto; }
  .tl-article { padding:1.2rem 1.1rem 1.5rem; }
  .tl-art-year { font-size:1.1rem; }
  .tl-art-title { font-size:clamp(1.1rem,5vw,1.6rem); }
  .tl-art-subtitle { font-size:0.9rem; }
  .tl-art-body { font-size:0.9rem; }
  .tl-impact-text { font-size:0.82rem; }
  .tl-header { padding:0.7rem 0.8rem 0.4rem; }
  .section-title { font-size:1.2rem !important; }

  /* Compounds */
  .compounds-grid { grid-template-columns: 1fr; }

  /* Atom modal fullscreen on mobile */
  .modal-overlay { padding:0; }
  .modal { border-radius:0; max-height:100vh; }
  #atom-canvas { height:220px; }
}

/* ── Custom Dropdown ─────────────────────────────────────────── */
.cdd {
  position: relative;
  display: inline-block;
  min-width: 160px;
  user-select: none;
  z-index: 500;
}
@media(max-width:600px){
  .cdd { display: block; width: 100%; }
  .quiz-config-row { flex-direction: column; gap: 0.6rem; }
  .cdd-selected { width: 100%; box-sizing: border-box; }
  /* On mobile open list goes UP to avoid clipping at bottom of screen */
  .cdd.open .cdd-list {
    bottom: calc(100% + 1px);
    top: auto;
    border-top: 1px solid var(--cyan);
    border-bottom: none;
    border-radius: 4px 4px 0 0;
  }
  .cdd.open .cdd-selected { border-radius: 0 0 4px 4px; border-top-color: rgba(0,180,255,0.3); }
  .cdd.open .cdd-arrow { transform: rotate(0deg); }
}
.cdd-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.65rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  color: var(--cyan);
  background: linear-gradient(135deg, rgba(0,200,255,0.12), rgba(0,150,255,0.06));
  border: 1px solid rgba(0,200,255,0.35);
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  box-shadow: inset 0 0 8px rgba(0,200,255,0.1);
}
.cdd-selected:hover { background: linear-gradient(135deg, rgba(0,200,255,0.18), rgba(0,150,255,0.1)); box-shadow: inset 0 0 12px rgba(0,200,255,0.15), 0 0 12px rgba(0,200,255,0.2); }
.cdd.open .cdd-selected {
  border-radius: 4px 4px 0 0;
  border-bottom-color: rgba(0,180,255,0.3);
  box-shadow: 0 0 0 2px rgba(0,180,255,0.15);
}
.cdd-arrow {
  font-size: 0.7rem;
  opacity: 0.75;
  transition: transform 0.18s;
  flex-shrink: 0;
}
.cdd.open .cdd-arrow { transform: rotate(180deg); }
.cdd-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: linear-gradient(135deg, rgba(0,200,255,0.12), rgba(0,150,255,0.06));
  border: 1px solid rgba(0,200,255,0.35);
  border-top: none;
  border-radius: 0 0 5px 5px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5), inset 0 0 16px rgba(0,200,255,0.1);
  backdrop-filter: blur(16px);
}
.cdd.open .cdd-list { display: block; }
.cdd-item {
  padding: 0.38rem 0.65rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  color: var(--cyan);
  cursor: pointer;
  transition: background 0.12s;
  letter-spacing: 0.4px;
  border-bottom: 1px solid rgba(0,180,255,0.12);
}
.cdd-item:last-child { border-bottom: none; }
.cdd-item:hover { background: rgba(0,180,255,0.18); }
.cdd-item.cdd-item-active { background: rgba(0,180,255,0.14); font-weight: 700; }

/* ╔══ CURSOR REACTIVE EFFECTS ══════════════════════════╗ */

/* Floating animations with varying speeds and delays */
@keyframes float-sync {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-5px); }
}

/* Cursor glow overlay for cards */
.element-cell::after,
.quiz-mode-card::after,
.compound-card::after,
.tl-event::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    circle at var(--cursor-x, 50%) var(--cursor-y, 50%),
    rgba(0, 200, 255, 0.25) 0%,
    rgba(0, 200, 255, 0.08) 35%,
    transparent 70%
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.element-cell:hover::after,
.quiz-mode-card:hover::after,
.compound-card:hover::after,
.tl-event:hover::after {
  opacity: 1;
}

/* Synced float — all cells move together */
.element-cell {
  animation: elReveal 0.4s cubic-bezier(0.22,1,0.36,1) backwards, float-sync 3.5s ease-in-out infinite;
}









.quiz-mode-card {
  animation: float-subtle-2 3.8s ease-in-out infinite;
}

.quiz-mode-card:nth-child(2) {
  animation-delay: 0.3s;
}

.compound-card {
  animation: float-subtle-3 4.4s ease-in-out infinite;
}

.compound-card:nth-child(odd) {
  animation-delay: 0.2s;
}

.compound-card:nth-child(even) {
  animation-delay: 0.4s;
}

.tl-event {
  animation: float-subtle-2 3.5s ease-in-out infinite;
}

.tl-event:nth-child(odd) {
  animation-delay: 0.15s;
}

/* Tag reveal animation with stagger */
@keyframes tag-slide-in {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.compound-type {
  animation: tag-slide-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation-fill-mode: both;
  animation-delay: 0.15s;
}

.tl-tag {
  animation: tag-slide-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation-fill-mode: both;
  animation-delay: var(--tag-delay, 0s);
}

/* ╚════════════════════════════════════════════════════╝ */
