:root {
  --bg-primary: #070d18;
  --bg-card: rgba(15, 23, 42, 0.88);
  --bg-panel: rgba(15, 23, 42, 0.78);
  --border-color: rgba(51, 65, 85, 0.65);
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --code-bg: #020617;
}

/* Projector-Friendly Light Mode */
body.light-mode {
  --bg-primary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-panel: rgba(255, 255, 255, 0.92);
  --border-color: rgba(148, 163, 184, 0.55);
  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;
  --code-bg: #0f172a;
  background-image:
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(168, 85, 247, 0.10) 0px, transparent 50%);
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.10) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(168, 85, 247, 0.10) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Glassmorphism backdrop */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-color);
}

/* Light mode text & panel overrides */
body.light-mode .text-white { color: #0f172a !important; }
body.light-mode .text-slate-100 { color: #0f172a !important; }
body.light-mode .text-slate-200 { color: #1e293b !important; }
body.light-mode .text-slate-300 { color: #334155 !important; }
body.light-mode .text-slate-400 { color: #475569 !important; }
body.light-mode .bg-slate-900\/90,
body.light-mode .bg-slate-900\/80,
body.light-mode .bg-slate-900\/60,
body.light-mode .bg-slate-900\/50,
body.light-mode .bg-slate-900 {
  background-color: rgba(255, 255, 255, 0.92) !important;
  border-color: #cbd5e1 !important;
}
body.light-mode .bg-slate-800,
body.light-mode .bg-slate-800\/60 {
  background-color: #e2e8f0 !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}
body.light-mode .bg-emerald-600,
body.light-mode .bg-sky-600 {
  color: #ffffff !important;
}
body.light-mode .bg-emerald-600 span,
body.light-mode .bg-sky-600 span {
  color: #ffffff !important;
}
body.light-mode pre {
  background-color: #0f172a !important;
  color: #34d399 !important;
}
body.light-mode .tile-name {
  color: #1e293b;
}

/* Group Numbers Header */
.group-headers-grid {
  display: grid;
  grid-template-columns: repeat(18, minmax(62px, 1fr));
  gap: 8px;
  min-width: 1200px;
}

/* Periodic Table Grid Layout */
.periodic-table-grid {
  display: grid;
  grid-template-columns: repeat(18, minmax(62px, 1fr));
  gap: 8px;
  min-width: 1200px;
}

/* Element Tile */
.element-tile {
  position: relative;
  aspect-ratio: 1 / 1.08;
  border-radius: 9px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 6px 5px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.element-tile:hover {
  transform: translateY(-4px) scale(1.06);
  z-index: 25;
  box-shadow: 0 12px 28px -5px rgba(0, 0, 0, 0.45), 0 0 18px -2px var(--glow-color, rgba(56, 189, 248, 0.55));
  border-color: var(--active-color, #38bdf8);
}

.element-tile.dimmed {
  opacity: 0.14;
  filter: grayscale(85%);
  transform: scale(0.95);
}

.element-tile.dimmed:hover {
  opacity: 0.65;
  filter: grayscale(20%);
  transform: translateY(-2px) scale(1.02);
}

.element-tile.highlighted {
  border-width: 2px;
  border-color: var(--active-color, #38bdf8);
  box-shadow: 0 0 18px var(--glow-color, rgba(56, 189, 248, 0.6));
}

/* Molecule / Roadmap Pulse Animation */
@keyframes moleculePulse {
  0%, 100% {
    box-shadow: 0 0 10px var(--glow-color, rgba(16, 185, 129, 0.45));
  }
  50% {
    box-shadow: 0 0 22px var(--active-color, #10b981), inset 0 0 8px var(--glow-color, rgba(16, 185, 129, 0.25));
  }
}

.element-tile.molecule-active {
  border-width: 2px;
  border-color: var(--active-color, #10b981);
  animation: moleculePulse 2.2s infinite ease-in-out;
  z-index: 10;
}

/* Custom Stack Selected Badge */
.element-tile.stack-selected {
  border-width: 2px;
  border-color: #10b981 !important;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.45);
}

.stack-badge, .roadmap-step-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  z-index: 30;
}

.stack-badge {
  background: #10b981;
  color: #022c22;
}

.roadmap-step-badge {
  background: #f59e0b;
  color: #0f172a;
}

/* Mastered Dot */
.mastered-dot {
  position: absolute;
  bottom: 3px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

/* Tile Internal Typography */
.tile-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1;
}

.tile-symbol {
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  letter-spacing: -0.5px;
  margin: 1px 0;
  line-height: 1.1;
}

.tile-name {
  font-size: 9.5px;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
}

/* Category, Molecule & Roadmap Filter Chips */
.category-chip, .molecule-chip, .roadmap-chip {
  transition: all 0.18s ease;
  border: 1px solid rgba(51, 65, 85, 0.7);
}
.category-chip:hover, .molecule-chip:hover, .roadmap-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.6);
}
.category-chip.active, .molecule-chip.active, .roadmap-chip.active {
  border-color: currentColor;
  box-shadow: 0 0 14px -2px currentColor;
}

/* Modal Drawer Overlay */
.modal-overlay {
  background: rgba(3, 7, 18, 0.76);
  backdrop-filter: blur(8px);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 4px;
}
