* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ---- Element Cell ---- */
.element-cell {
  position: absolute;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  will-change: transform, opacity;
  user-select: none;
  border: 1px solid rgba(255,255,255,0.04);
  backdrop-filter: blur(2px);
}
.element-cell:hover {
  z-index: 50;
  box-shadow: 0 0 16px rgba(255,255,255,0.12), 0 4px 24px rgba(0,0,0,0.5);
}
.element-cell .atomic-number {
  font-size: 8px;
  font-weight: 600;
  opacity: 0.4;
  line-height: 1;
}
.element-cell .symbol {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.element-cell .name {
  font-size: 7px;
  font-weight: 500;
  opacity: 0.6;
  line-height: 1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.element-cell .mass {
  font-size: 7px;
  opacity: 0.35;
  line-height: 1;
}

/* ---- Dimmed state when filtering ---- */
.element-cell.dimmed {
  opacity: 0.06 !important;
  pointer-events: none;
}
.element-cell.highlighted {
  opacity: 1 !important;
  z-index: 40;
}
.element-cell.cat-highlighted {
  opacity: 1 !important;
}
.element-cell.cat-dimmed {
  opacity: 0.08 !important;
}

/* ---- Grid cell background ---- */
.element-cell .cell-bg {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  opacity: 0.12;
  transition: opacity 0.3s ease;
}
.element-cell:hover .cell-bg {
  opacity: 0.24;
}

/* ---- Lanthanide / Actinide connector lines ---- */
.connector-line {
  position: absolute;
  border-left: 1px dashed rgba(255,255,255,0.06);
}

/* ---- Group Mode Labels ---- */
.group-label {
  position: absolute;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.25;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  white-space: nowrap;
}

/* ---- Period numbers (left side) ---- */
.period-label {
  position: absolute;
  font-size: 9px;
  font-weight: 600;
  opacity: 0.15;
  pointer-events: none;
}

/* ---- Glow ring on category highlight ---- */
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50% { box-shadow: 0 0 10px 2px var(--cat-glow); }
}
.element-cell.pulse-glow {
  animation: pulseGlow 1.5s ease-in-out infinite;
}

/* ---- Viz overlay dimmed base cells ---- */
.element-cell.viz-dimmed {
  opacity: 0.10 !important;
  pointer-events: none;
  transition: opacity 0.6s cubic-bezier(.4,0,.2,1);
}
.element-cell.viz-dimmed .cell-bg { opacity: 0.04 !important; }
.element-cell.viz-dimmed .symbol { opacity: 0.25; }
.element-cell.viz-dimmed .name,
.element-cell.viz-dimmed .mass,
.element-cell.viz-dimmed .atomic-number { opacity: 0.12; }
.element-cell.viz-dimmed:hover {
  opacity: 0.10 !important;
  box-shadow: none;
}

/* ---- Overlay layer ---- */
.viz-overlay { pointer-events: none; }
.viz-overlay circle { transition: r 0.4s ease; }
.viz-overlay text { pointer-events: none; }

/* ---- Lightning bolt flicker ---- */
@keyframes boltFlicker {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.06; }
}
.lightning-bolt {
  animation: boltFlicker 3s ease-in-out infinite alternate;
}

/* ---- Heat bar glow ---- */
.heat-bar {
  filter: drop-shadow(0 0 2px currentColor);
}

/* ---- Gun canvas ---- */
#gun-canvas {
  image-rendering: auto;
}
#gun-canvas.active {
  cursor: crosshair;
}

/* ---- Physics drag cursor ---- */
.element-cell.physics-active {
  cursor: grab;
}
.element-cell.physics-active:active {
  cursor: grabbing;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }
