/* ===================================================
   MolekülLab – Premium Molecule Builder CSS
   Mor-Koyu Tema
   =================================================== */

/* === Reset & Base === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Color System - Mor-Koyu Theme */
  --bg-primary: #0a0612;
  --bg-secondary: #12091f;
  --bg-tertiary: #1a0f2e;
  --bg-card: #201540;
  --bg-card-hover: #2a1d55;

  --surface-glass: rgba(139, 92, 246, 0.03);
  --surface-glass-hover: rgba(139, 92, 246, 0.08);
  --surface-border: rgba(139, 92, 246, 0.15);
  --surface-border-accent: rgba(139, 92, 246, 0.4);

  --text-primary: #ede9fe;
  --text-secondary: #c4b5fd;
  --text-muted: #a78bfa;

  --accent-primary: #8b5cf6;
  --accent-primary-light: #a78bfa;
  --accent-secondary: #c084fc;
  --accent-glow: rgba(139, 92, 246, 0.3);
  --accent-glow-strong: rgba(139, 92, 246, 0.6);

  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;

  /* Gradients */
  --gradient-accent: linear-gradient(135deg, #8b5cf6, #c084fc);
  --gradient-hero: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 50%, #c084fc 100%);
  --gradient-surface: linear-gradient(180deg, rgba(139,92,246,0.1) 0%, rgba(139,92,246,0.02) 100%);
  --gradient-mesh: radial-gradient(ellipse at center, rgba(139, 92, 246, 0.15), transparent);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-display: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --header-height: 56px;
  --tray-height: 160px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.6);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.7);
  --shadow-glow: 0 0 40px var(--accent-glow);
  --shadow-glow-intense: 0 0 60px var(--accent-glow-strong), 0 0 100px var(--accent-glow);

  /* Transitions */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 150ms var(--ease-smooth);
  --transition-medium: 250ms var(--ease-smooth);
  --transition-slow: 400ms var(--ease-smooth);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  background-image: var(--gradient-mesh);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Focus States (Accessibility) === */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 3px;
}

/* === Loading Screen === */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  transition: opacity 0.6s ease, visibility 0.6s ease;
  pointer-events: none;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-content {
  text-align: center;
}

/* Atom Loader Animation */
.atom-loader {
  width: 80px;
  height: 80px;
  position: relative;
  margin: 0 auto 24px;
}

.nucleus {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gradient-accent);
  box-shadow: 0 0 20px var(--accent-glow-strong);
}

.electron-orbit {
  position: absolute;
  inset: 0;
  border: 1.5px solid rgba(139, 92, 246, 0.3);
  border-radius: 50%;
}

.electron-orbit .electron {
  position: absolute;
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary-light);
  box-shadow: 0 0 8px var(--accent-glow-strong);
}

.orbit-1 {
  animation: orbit-spin 2s linear infinite;
}

.orbit-2 {
  transform: rotate(60deg);
  animation: orbit-spin 2.5s linear infinite reverse;
}

.orbit-3 {
  transform: rotate(120deg);
  animation: orbit-spin 3s linear infinite;
}

@keyframes orbit-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.loader-title {
  font-size: 28px;
  font-weight: 800;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.loader-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 24px;
}

.loader-bar {
  width: 200px;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 0 auto;
}

.loader-progress {
  height: 100%;
  width: 0%;
  background: var(--gradient-accent);
  border-radius: var(--radius-full);
  animation: loading-progress 2s ease-in-out forwards;
}

@keyframes loading-progress {
  0% { width: 0%; }
  30% { width: 40%; }
  60% { width: 70%; }
  90% { width: 90%; }
  100% { width: 100%; }
}

/* === App Layout === */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.app.visible,
.app[style*="opacity: 1"] {
  opacity: 1;
  pointer-events: auto;
}

/* === Header === */
.header {
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--surface-border);
  border-image: linear-gradient(90deg, transparent, var(--accent-primary), transparent) 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
  z-index: 100;
  backdrop-filter: blur(12px);
  flex-shrink: 0;
  overflow-x: auto;
}

/* Simplified header for single and quiz modes */
.header.simplified .header-center {
  margin-left: auto;
}

.header::-webkit-scrollbar {
  display: none;
}

.header-left {
  display: flex;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 24px;
  line-height: 1;
  max-width: 40px;
  max-height: 40px;
  object-fit: contain;
  animation: logo-pulse-subtle 3s ease-in-out infinite;
}

@keyframes logo-pulse-subtle {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(139, 92, 246, 0.3)); }
  50% { filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.6)); }
}

.logo-title {
  font-size: 18px;
  font-weight: 800;
  font-family: var(--font-display);
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.3px;
}

.logo-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: block;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

/* Header Center - Formula Display */
.header-center {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  justify-content: center;
}

.formula-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  min-width: 140px;
  backdrop-filter: blur(12px);
  transition: all 0.3s ease;
}

.formula-display:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}

.formula-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.formula-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-primary-light);
  text-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

.molecule-name-display {
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  backdrop-filter: blur(12px);
  transition: all 0.3s ease;
}

.molecule-name-display:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}

.molecule-name {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Header Right Actions */
.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  transition: var(--transition-fast);
}

.header-btn:hover {
  background: var(--surface-glass-hover);
  color: var(--text-primary);
}

.header-btn:active {
  transform: scale(0.95);
  background: rgba(139, 92, 246, 0.12);
}

.header-btn.accent-btn {
  background: var(--gradient-accent);
  color: white;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.header-btn.accent-btn:hover {
  background: var(--accent-primary-light);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.5);
  transform: translateY(-1px);
}

.header-btn.accent-btn:active {
  transform: scale(0.96);
  background: var(--accent-primary);
}

.header-divider {
  width: 1px;
  height: 24px;
  background: var(--surface-border);
  margin: 0 6px;
}

/* === Main Layout === */
.main-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-height: 0;
  height: calc(100vh - var(--header-height));
}

.tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* === 3D Viewport === */
.viewport {
  flex: 1;
  position: relative;
  background: 
    radial-gradient(circle at 20% 30%, rgba(139, 92, 246, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(192, 132, 252, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at center, #12091f 0%, #0a0612 70%);
  background-image: 
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(139, 92, 246, 0.03) 2px, rgba(139, 92, 246, 0.03) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(139, 92, 246, 0.03) 2px, rgba(139, 92, 246, 0.03) 4px),
    radial-gradient(ellipse at center, #12091f 0%, #0a0612 70%);
  overflow: hidden;
  cursor: default;
  min-height: 300px;
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewport canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.viewport canvas:active {
  cursor: grabbing;
}

@media (max-width: 768px) {
  .viewport {
    min-height: 250px;
  }
}

@media (max-width: 480px) {
  .viewport {
    min-height: 200px;
  }
}

/* Drop zone highlight */
.viewport.drag-over {
  background: radial-gradient(ellipse at center, #1a0f2e 0%, #0a0612 70%);
  box-shadow: inset 0 0 100px rgba(88, 166, 255, 0.2);
}

.viewport.drag-over::after {
  content: '';
  position: absolute;
  inset: 10px;
  border: 2px dashed var(--accent-primary);
  border-radius: var(--radius-lg);
  pointer-events: none;
  animation: pulse-border 1.5s ease infinite;
  box-shadow: 0 0 30px rgba(88, 166, 255, 0.3);
}

@keyframes pulse-border {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}

/* View Controls */
.view-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.view-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  backdrop-filter: blur(8px);
}

.view-btn:hover {
  background: rgba(30, 38, 66, 0.9);
  color: var(--text-primary);
  border-color: var(--surface-border-accent);
}

.view-btn.active {
  color: var(--accent-primary-light);
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.15);
}

/* Animation Controls */
.animation-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.anim-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 27, 34, 0.9);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: blur(12px);
}

.anim-btn:hover {
  background: rgba(45, 51, 59, 0.95);
  color: var(--accent-primary-light);
  border-color: var(--surface-border-accent);
  transform: scale(1.05);
}

.anim-btn.active {
  color: var(--accent-primary-light);
  border-color: var(--accent-primary);
  background: rgba(88, 166, 255, 0.15);
  box-shadow: 0 0 20px rgba(88, 166, 255, 0.3);
}

.anim-btn.active svg {
  animation: pulse-icon 2s ease-in-out infinite;
}

@keyframes pulse-icon {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

/* Viewport Info */
.viewport-info {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.info-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
}

.info-badge:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse-dot 2s ease infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--success); }
  50% { opacity: 0.4; box-shadow: 0 0 4px var(--success); }
}

/* Onboarding Hint */
.onboarding {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 5;
  pointer-events: none;
  animation: float-hint 3s ease-in-out infinite, fade-pulse 2s ease-in-out infinite;
}

@keyframes fade-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.onboarding.hidden {
  display: none;
}

.onboarding-icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: bounce-arrow 1.5s ease-in-out infinite;
}

@keyframes bounce-arrow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(10px); }
}

@keyframes float-hint {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.onboarding-text {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 500;
  max-width: 300px;
  line-height: 1.5;
}

/* === Atom Tray (Bottom Panel) === */
.atom-tray {
  height: var(--tray-height);
  min-height: var(--tray-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--surface-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 50;
  position: relative;
  overflow-x: auto;
}

.tray-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.tray-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.tray-title svg {
  color: var(--accent-primary-light);
}

.tray-nav {
  display: flex;
  gap: 4px;
}

.tray-nav-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-glass);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition-fast);
}

.tray-nav-btn:hover {
  background: var(--surface-glass-hover);
  color: var(--text-primary);
}

.tray-scroll-container {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 16px 12px;
  scroll-behavior: smooth;
}

.tray-scroll-container::-webkit-scrollbar {
  height: 4px;
}

.tray-scroll-container::-webkit-scrollbar-track {
  background: transparent;
}

.tray-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-full);
}

/* === Atom Bins (PhET Style) === */
.atom-bins {
  display: flex;
  gap: 16px;
  height: 100%;
}

.atom-bin {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
  position: relative;
}

.bin-container {
  width: 120px;
  height: 80px;
  position: relative;
  perspective: 600px;
}

/* The bin/bucket shape */
.bin-bucket {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 45px;
  border-radius: 0 0 16px 16px;
  overflow: hidden;
  pointer-events: none;
}

.bin-bucket-front {
  position: absolute;
  inset: 0;
  border-radius: 0 0 16px 16px;
  opacity: 0.9;
}

.bin-bucket-inner {
  position: absolute;
  top: 0;
  left: 8px;
  right: 4px;
  height: 12px;
  border-radius: 0 0 11px 8px;
  opacity: 0.5;
}

.bin-rim {
  position: absolute;
  bottom: 44px;
  left: -2px;
  right: -2px;
  height: 10px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 2;
}

/* Atom spheres inside bin */
.bin-atoms {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2px;
  z-index: 3;
  flex-wrap: wrap;
  padding: 0 8px;
}

.bin-atom {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: white;
  cursor: grab;
  position: relative;
  user-select: none;
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s ease;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  z-index: 5;
}

.bin-atom::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 6px;
  width: 12px;
  height: 6px;
  background: rgba(255,255,255,0.35);
  border-radius: 50%;
  transform: rotate(-20deg);
}

.bin-atom:hover {
  transform: scale(1.2) translateY(-4px);
  z-index: 10;
}

.bin-atom:active {
  cursor: grabbing;
  transform: scale(1.15);
}

.bin-atom.dragging {
  opacity: 0.5;
  transform: scale(0.8);
}

/* Bin label */
.bin-label {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}

/* Dragging atom clone */
.drag-atom-clone {
  position: fixed;
  pointer-events: none;
  z-index: 99999;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  transition: none;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

.drag-atom-clone::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 8px;
  width: 16px;
  height: 8px;
  background: rgba(255,255,255,0.35);
  border-radius: 50%;
  transform: rotate(-20deg);
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-medium);
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s var(--ease-spring);
}

.modal-overlay.visible .modal {
  transform: translateY(0) scale(1);
}

.modal-3d {
  max-width: 90vw;
  max-height: 90vh;
  width: 90vw;
  height: 90vh;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--surface-border);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.modal-close:hover {
  background: var(--surface-glass-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-3d-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: calc(90vh - 60px);
}

/* 3D Viewer */
.viewer-3d {
  flex: 1;
  position: relative;
  background: radial-gradient(ellipse at center, #12091f 0%, #0a0612 70%);
  overflow: hidden;
}

.viewer-3d canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  position: relative;
  z-index: 1;
}

.viewer-3d-info {
  padding: 16px 20px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--surface-border);
  text-align: center;
}

.viewer-3d-info p {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0;
}

/* Examples Grid */
.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.example-card {
  background: var(--bg-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: var(--transition-medium);
  text-align: center;
}

.example-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--surface-border-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.example-card .example-emoji {
  font-size: 32px;
  margin-bottom: 8px;
}

.example-card .example-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.example-card .example-formula {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-primary-light);
}

.example-card .example-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* === Toast === */
.toast-container {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s var(--ease-spring);
  backdrop-filter: blur(12px);
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.warning {
  border-left: 3px solid var(--warning);
}

.toast.error {
  border-left: 3px solid var(--error);
}

.toast.info {
  border-left: 3px solid var(--accent-primary);
}

.toast.removing {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100px); }
}

/* === Achievement Toast === */
.toast.achievement-toast {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(234, 88, 12, 0.15));
  border: 2px solid #f59e0b;
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  box-shadow: 0 8px 32px rgba(245, 158, 11, 0.3);
}

.achievement-icon {
  font-size: 28px;
  animation: achievement-pop 0.5s var(--ease-spring);
}

@keyframes achievement-pop {
  0% { transform: scale(0) rotate(-180deg); }
  60% { transform: scale(1.3) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.achievement-content {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
}

.achievement-content strong {
  color: #f59e0b;
  font-size: 14px;
}

/* === Stars in Notification === */
.stars-container {
  margin-left: 8px;
  display: inline-flex;
  gap: 2px;
}

.stars-container .star {
  color: var(--text-muted);
  font-size: 14px;
}

.stars-container .star.filled {
  color: #f59e0b;
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

/* === Level Display === */
.score-level .score-value {
  color: #f59e0b;
}

.score-level .score-icon {
  color: #f59e0b;
}

/* === Level Progress === */
.level-progress {
  padding: 4px 12px;
  background: rgba(99, 102, 241, 0.15);
  border-radius: var(--radius-full);
}

.progress-text {
  font-size: 11px;
  color: var(--accent-primary-light);
  font-weight: 500;
}

/* === Single Buttons === */
.single-buttons {
  display: flex;
  gap: 8px;
  margin-left: 12px;
  align-items: center;
}

.single-new-round-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--bg-card-hover), var(--bg-tertiary));
  color: var(--text-secondary);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease-smooth);
}

.single-new-round-btn:hover {
  background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
  color: white;
  border-color: var(--accent-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* === Molecule Notification === */
.molecule-notification {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-150%);
  z-index: 99998;
  transition: transform 0.5s var(--ease-spring);
  opacity: 0;
  visibility: hidden;
}

.molecule-notification.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

.molecule-notification-content {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(99, 102, 241, 0.15));
  border: 2px solid var(--success);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.3);
  backdrop-filter: blur(12px);
  min-width: 450px;
  max-width: 90vw;
  flex-wrap: wrap;
}

.molecule-notification-icon {
  font-size: 32px;
  animation: bounce-icon 0.6s ease;
}

@keyframes bounce-icon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.molecule-notification-text {
  flex: 1;
}

.molecule-notification-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--success);
  margin-bottom: 4px;
}

.molecule-notification-formula {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
}

.molecule-notification-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--success);
  border: none;
  border-radius: var(--radius-full);
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  font-family: var(--font-sans);
}

.molecule-notification-btn:hover {
  background: #0ea574;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.molecule-notification-btn.continue-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
  animation: pulse-btn 1.5s ease-in-out infinite;
  display: none;
}

.molecule-notification-btn.continue-btn.show {
  display: flex !important;
}

@keyframes pulse-btn {
  0%, 100% { box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4); }
  50% { box-shadow: 0 4px 25px rgba(16, 185, 129, 0.6); }
}

.molecule-notification-btn.continue-btn:hover {
  background: linear-gradient(135deg, #059669, #047857);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.molecule-notification-btn.continue-btn svg {
  animation: pulse-play 1s ease-in-out infinite;
}

@keyframes pulse-play {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.molecule-notification-close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  font-family: var(--font-sans);
  margin-left: 4px;
}

.molecule-notification-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* === Atom Placed Flash === */
@keyframes atom-place-flash {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.3); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

/* === Molecule Detection Badge === */
.molecule-detected-flash {
  animation: detected-flash 0.6s ease;
}

@keyframes detected-flash {
  0%, 100% { background: var(--surface-glass); }
  50% { background: rgba(16, 185, 129, 0.2); border-color: var(--success); }
}

/* === Responsive === */
@media (max-width: 768px) {
  :root {
    --header-height: 48px;
    --tray-height: 140px;
  }

  .gamification-bar {
    gap: 12px;
    padding: 4px 12px;
  }

  .gamification-progress {
    max-width: 150px;
  }

  .header-center {
    display: none;
  }

  .logo-subtitle {
    display: none;
  }

  .header-btn span {
    display: none;
  }

  .atom-bin {
    min-width: 100px;
  }

  .bin-container {
    width: 100px;
    height: 70px;
  }

  .bin-atom {
    width: 26px;
    height: 26px;
    font-size: 11px;
  }

  .view-controls {
    top: 8px;
    right: 8px;
  }

  .view-btn {
    width: 32px;
    height: 32px;
  }
}

@media (max-width: 480px) {
  :root {
    --tray-height: 130px;
  }

  .atom-bin {
    min-width: 85px;
  }

  .bin-container {
    width: 85px;
    height: 60px;
  }

  .bin-atom {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }
}

/* === Scrollbar Global === */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

/* === Selection === */
::selection {
  background: var(--accent-primary);
  color: white;
}

/* ===================================================
   Task 8.1 – Landing Page Styles
   Requirements: 1.1, 1.5, 1.6
   =================================================== */

#landing-page,
.landing-page {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
}

.landing-page.hidden,
#landing-page[style*="display: none"] {
  display: none !important;
}

.landing-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 28px;
  padding: 24px;
  max-width: 720px;
  width: 100%;
  position: relative;
  z-index: 2;
}

/* === Animated Background === */
.landing-bg-animation {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}

.bg-nucleus {
  position: absolute;
  top: 25%;
  left: 50%;
  width: 20px;
  height: 20px;
  background: var(--accent-primary);
  border-radius: 50%;
  box-shadow: 0 0 40px var(--accent-glow), 0 0 80px var(--accent-glow);
  opacity: 0.3;
  transform: translateX(-50%);
  z-index: 1;
}

.bg-orbit {
  position: absolute;
  top: 25%;
  left: 50%;
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 50%;
  transform-origin: center center;
  z-index: 1;
}

.bg-orbit.orbit-1 {
  width: 160px;
  height: 160px;
  margin-top: -80px;
  margin-left: -80px;
  animation: orbit-spin 8s linear infinite;
}

.bg-orbit.orbit-2 {
  width: 260px;
  height: 260px;
  margin-top: -130px;
  margin-left: -130px;
  animation: orbit-spin 12s linear infinite reverse;
}

.bg-orbit.orbit-3 {
  width: 360px;
  height: 360px;
  margin-top: -180px;
  margin-left: -180px;
  animation: orbit-spin 16s linear infinite;
}

.bg-orbit::after {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  background: var(--accent-secondary);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent-secondary), 0 0 4px var(--accent-secondary);
}

@keyframes orbit-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Floating Particles */
.bg-particle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 5px;
  height: 5px;
  background: var(--accent-primary-light);
  border-radius: 50%;
  opacity: 0.3;
  animation: particle-float var(--dur) ease-in-out infinite;
  animation-delay: var(--delay);
  box-shadow: 0 0 8px var(--accent-glow);
}

@keyframes particle-float {
  0%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.2;
  }
  50% {
    transform: translateY(-25px) scale(1.2);
    opacity: 0.5;
  }
}

/* Gradient Mesh */
.bg-mesh {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.18;
  animation: mesh-float 20s ease-in-out infinite;
}

@keyframes mesh-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.1); }
  66% { transform: translate(-30px, 30px) scale(0.9); }
}

.bg-mesh.mesh-1 {
  width: 450px;
  height: 450px;
  background: var(--accent-primary);
  top: 10%;
  left: -5%;
  animation-delay: 0s;
}

.bg-mesh.mesh-2 {
  width: 400px;
  height: 400px;
  background: var(--accent-secondary);
  bottom: 5%;
  right: -5%;
  animation-delay: 7s;
}

.bg-mesh.mesh-3 {
  width: 350px;
  height: 350px;
  background: #8b5cf6;
  top: 60%;
  left: 20%;
  animation-delay: 14s;
}

.landing-logo-icon {
  font-size: 48px;
  margin-bottom: 8px;
  animation: logo-pulse 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 12px rgba(139, 92, 246, 0.4));
}

@keyframes logo-pulse {
  0%, 100% { 
    transform: scale(1); 
    filter: drop-shadow(0 4px 12px rgba(139, 92, 246, 0.4)); 
  }
  50% { 
    transform: scale(1.08); 
    filter: drop-shadow(0 8px 24px rgba(139, 92, 246, 0.7)); 
  }
}

.landing-version-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--accent-primary-light);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  margin-bottom: 12px;
}

.landing-hero {
  text-align: center;
  margin-bottom: 8px;
}

.landing-title {
  font-size: 56px;
  font-weight: 800;
  font-family: var(--font-display);
  background: var(--gradient-hero);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1.5px;
  margin-bottom: 10px;
  line-height: 1.1;
  animation: gradient-shift 3s ease infinite;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% center; }
  50% { background-position: 100% center; }
}

.landing-subtitle {
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: -0.2px;
}

.landing-desc {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
  max-width: 500px;
  margin: 0 auto;
}

/* Landing Features Section */
.landing-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 600px;
}

.landing-feature-card {
  background: var(--bg-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 20px 12px;
  text-align: center;
  transition: var(--transition-medium);
}

.landing-feature-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.feature-icon {
  color: var(--accent-primary);
  margin-bottom: 10px;
}

.landing-feature-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.landing-feature-card p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.landing-molecules-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
}

.molecule-preview-card {
  background: var(--bg-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  cursor: pointer;
  transition: var(--transition-medium);
  text-align: center;
}

.molecule-preview-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--surface-border-accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.molecule-card-emoji {
  font-size: 32px;
  margin-bottom: 8px;
  display: block;
}

.molecule-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.molecule-card-formula {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-primary-light);
}

.landing-start-btn {
  background: var(--gradient-accent);
  border: none;
  border-radius: var(--radius-full);
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  margin-top: 32px;
  font-family: var(--font-sans);
  transition: var(--transition-medium);
  box-shadow: var(--shadow-glow);
}

.landing-start-btn:hover {
  opacity: 0.9;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

/* Landing mode selection cards */
.landing-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  width: 100%;
  max-width: 680px;
}

.landing-mode-card {
  background: var(--bg-card);
  border: 2px solid var(--surface-border);
  border-radius: var(--radius-xl);
  padding: 40px 24px 32px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.landing-mode-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-accent);
  opacity: 0;
  transition: opacity var(--transition-medium);
  border-radius: inherit;
}

.landing-mode-card::after {
  content: '';
  position: absolute;
  inset: -2px;
  background: var(--gradient-accent);
  border-radius: inherit;
  opacity: 0;
  z-index: -1;
  transition: opacity 0.4s ease;
}

.landing-mode-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 12px 40px rgba(139, 92, 246, 0.4), 0 0 60px rgba(139, 92, 246, 0.2);
}

.landing-mode-card:hover::after {
  opacity: 0.3;
}

.landing-mode-card:hover .mode-card-icon {
  color: var(--accent-secondary);
  transform: scale(1.15) rotate(5deg);
}

.landing-mode-card:hover .mode-card-arrow {
  opacity: 1;
  transform: translateX(4px);
}

.landing-mode-card:active {
  transform: translateY(-4px) scale(0.98);
}

.mode-card-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  background: var(--gradient-accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

.mode-card-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary-light);
  opacity: 0;
  transform: translateX(-8px);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin-top: 4px;
}

.mode-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  margin-bottom: 4px;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.3));
}

.mode-card-icon svg {
  width: 40px;
  height: 40px;
}

.mode-card-title {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.mode-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

@media (max-width: 768px) {
  .landing-mode-grid {
    grid-template-columns: 1fr;
    max-width: 360px;
  }
  .landing-molecules-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .landing-title {
    font-size: 42px;
  }
}

@media (max-width: 480px) {
  .landing-mode-grid {
    grid-template-columns: 1fr;
    max-width: 320px;
  }
  .landing-features {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  .landing-title {
    font-size: 36px;
  }
  .landing-feature-card h3 {
    font-size: 11px;
  }
  .landing-feature-card p {
    display: none;
  }
}

@media (max-width: 480px) {
  .landing-molecules-grid {
    grid-template-columns: 1fr;
  }
  .landing-title {
    font-size: 28px;
  }
}

/* === Site Footer === */
.site-footer {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(10, 6, 18, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  border: 1px solid var(--surface-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.site-footer a {
  color: var(--accent-primary-light);
  text-decoration: none;
  transition: color var(--transition-fast);
  font-weight: 500;
}

.site-footer a:hover {
  color: var(--text-primary);
}

.footer-dot {
  color: var(--surface-border-accent);
  font-size: 10px;
}

/* ===================================================
   Task 8.2 – Tab System Styles
   Requirements: 2.6, 2.7
   =================================================== */

.tab-bar {
  display: flex;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--surface-border);
  padding: 0 16px;
  flex-shrink: 0;
  position: relative;
}

.tab-btn {
  padding: 12px 20px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font-sans);
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn svg {
  width: 18px;
  height: 18px;
  transition: transform 0.3s ease;
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  right: 50%;
  height: 3px;
  background: var(--gradient-accent);
  transition: left 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), right 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: var(--radius-full) var(--radius-full) 0 0;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.6);
}

.tab-btn.active {
  color: var(--accent-primary-light);
  border-bottom-color: transparent;
}

.tab-btn.active svg {
  transform: scale(1.1);
}

.tab-btn.active::after {
  left: 0;
  right: 0;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--surface-glass);
}

.tab-btn:hover svg {
  transform: translateY(-2px);
}

.tab-btn:active {
  transform: scale(0.97);
}

.tab-btn {
  padding: 12px 20px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition-fast);
  font-family: var(--font-sans);
  position: relative;
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  right: 50%;
  height: 2px;
  background: var(--accent-primary);
  transition: left var(--transition-medium), right var(--transition-medium);
  border-radius: var(--radius-full) var(--radius-full) 0 0;
}

.tab-btn.active {
  color: var(--accent-primary-light);
  border-bottom-color: var(--accent-primary);
}

.tab-btn.active::after {
  left: 0;
  right: 0;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--surface-glass);
}

.tab-btn:active {
  transform: scale(0.97);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.single-tab-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  background: var(--bg-primary);
}

.single-target-display {
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  margin: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.single-target-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.single-target-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.single-target-formula {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-primary-light);
}

.single-target-name {
  font-size: 13px;
  color: var(--text-secondary);
}

/* === Score Bar (Game UI) === */
.single-score-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-glass);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
  padding: 6px 18px;
  margin-left: auto;
}

.score-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.score-icon {
  font-size: 16px;
}

.score-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.score-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-primary-light);
  min-width: 28px;
  text-align: center;
  transition: transform 0.2s, color 0.2s;
}

.score-value.score-animate {
  animation: score-pop 0.5s var(--ease-spring);
}

@keyframes score-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.5); color: #10b981; }
  100% { transform: scale(1); }
}

.score-value.score-negative-animate {
  animation: score-shake 0.5s ease;
}

@keyframes score-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); color: #ef4444; }
  40% { transform: translateX(5px); color: #ef4444; }
  60% { transform: translateX(-3px); color: #ef4444; }
  80% { transform: translateX(3px); color: #ef4444; }
}

/* === Combo Display === */
.combo-value {
  color: #f59e0b;
  animation: combo-glow 1.5s ease-in-out infinite;
}

@keyframes combo-glow {
  0%, 100% {
    text-shadow: 0 0 5px rgba(245, 158, 11, 0.3);
  }
  50% {
    text-shadow: 0 0 15px rgba(245, 158, 11, 0.6), 0 0 25px rgba(245, 158, 11, 0.3);
  }
}

.score-combo .score-value {
  color: #f59e0b;
  min-width: 20px;
}

/* Timer warning */
.score-value.timer-warning {
  color: var(--error);
  animation: timer-pulse 1s ease infinite;
}

@keyframes timer-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.1); }
}

.score-value.timer-critical {
  color: var(--error);
  animation: timer-critical 0.4s ease infinite;
}

@keyframes timer-critical {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(1.2); }
}

.score-divider {
  width: 1px;
  height: 24px;
  background: var(--surface-border);
}

/* Yeni Oyun button */
.single-new-round-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent-primary);
  border: none;
  border-radius: var(--radius-full);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: var(--transition-fast);
  white-space: nowrap;
}

.single-new-round-btn:hover {
  background: var(--accent-primary-light);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.single-new-round-btn:active {
  transform: scale(0.97);
}

/* Empty atom bucket styling */
.phet-bucket.atoms-empty .phet-bucket-front {
  opacity: 0.4;
  filter: grayscale(0.8);
}

.phet-bucket.atoms-empty .phet-atoms-in-bucket {
  opacity: 0.2;
}

/* === PhET Style Atom Tray === */
.phet-atom-tray {
  position: relative;
  background: var(--bg-secondary);
  border-top: 1px solid var(--surface-border);
  padding: 20px 60px 40px; /* Padding artırıldı */
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px; /* 180px'den 220px'e yükseltildi */
}

.phet-tray-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
  max-width: 1200px; /* Maksimum genişlik eklendi */
  width: 100%;
}

.phet-tray-slider {
  display: flex;
  transition: transform 0.3s ease;
}

.phet-page {
  min-width: 100%;
  display: flex;
  justify-content: center;
  gap: 8px; /* 20px'den 8px'e - kaplar arası mesafe azaltıldı çünkü kaplarda margin var */
  padding: 10px 20px; /* Yanlara daha fazla padding */
}

.phet-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background: var(--bg-tertiary);
  border: 1px solid var(--surface-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s;
  color: var(--text-primary);
}

.phet-nav-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
}

.phet-nav-prev {
  left: 10px;
}

.phet-nav-next {
  right: 10px;
}

/* Atom Bucket */
.phet-bucket {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: grab;
  user-select: none;
  margin: 0 12px; /* Kaplar arası mesafe */
}

.phet-bucket-container {
  position: relative;
  width: 120px;
  height: 60px;
}

.phet-bucket-back {
  position: absolute;
  bottom: 0;
  left: 5px;
  right: 5px;
  height: 65px; /* 50px'den 65px'e artırıldı */
  background: linear-gradient(180deg, #4a4a4a 0%, #333 100%);
  border-radius: 0 0 20px 20px;
  border: 2px solid #555;
}

.phet-bucket-front {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70px; /* 55px'den 70px'e artırıldı */
  background: linear-gradient(180deg, #555 0%, #3a3a3a 100%);
  border-radius: 5px 5px 25px 25px;
  border: 2px solid #666;
  z-index: 1;
}

.phet-bucket-inner {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  height: 40px;
  background: linear-gradient(180deg, #2a2a2a 0%, #222 100%);
  border-radius: 0 0 15px 15px;
}

.phet-bucket.atoms-empty .phet-bucket-front {
  opacity: 0.6;
}

.phet-atoms-in-bucket {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  gap: 5px;
  z-index: 2;
  align-items: center;
  max-height: 40px;
}

/* PhET Atom */
.phet-atom {
  width: 32px; /* 36px'den 32px'e küçültüldü */
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px; /* 16px'den 14px'e */
  cursor: grab;
  transition: transform 0.2s;
  position: relative;
  z-index: 5;
}

.phet-atom:hover {
  transform: scale(1.15); /* 1.1'den 1.15'e - hover efekti biraz daha belirgin */
}

.phet-atom.carbon {
  background: radial-gradient(circle at 35% 35%, #888, #444);
  color: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,0.5), inset 0 -3px 6px rgba(0,0,0,0.3);
  border: 2px solid #666;
}

.phet-atom.oxygen {
  background: radial-gradient(circle at 35% 35%, #ff6b6b, #e53935);
  color: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3), inset 0 -3px 6px rgba(0,0,0,0.2);
}

.phet-atom.nitrogen {
  background: radial-gradient(circle at 35% 35%, #5c6bc0, #3949ab);
  color: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3), inset 0 -3px 6px rgba(0,0,0,0.2);
}

.phet-atom.hydrogen {
  background: radial-gradient(circle at 35% 35%, #fff, #e0e0e0);
  color: #111;
  box-shadow: 0 3px 8px rgba(0,0,0,0.4), inset 0 -3px 6px rgba(0,0,0,0.1);
  border: 2px solid #999;
}

.phet-atom.chlorine {
  background: radial-gradient(circle at 35% 35%, #4ade80, #22c55e);
  color: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,0.4), inset 0 -3px 6px rgba(0,0,0,0.2);
  border: 2px solid #16a34a;
}

.phet-atom.fluorine {
  background: radial-gradient(circle at 35% 35%, #a7f3d0, #90ee90);
  color: #111;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3), inset 0 -3px 6px rgba(0,0,0,0.15);
  border: 2px solid #059669;
}

.phet-atom.sulfur {
  background: radial-gradient(circle at 35% 35%, #fde047, #ffd700);
  color: #111;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3), inset 0 -3px 6px rgba(0,0,0,0.2);
  border: 2px solid #ca8a04;
}

.phet-bucket-label {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
}

/* Page Dots */
.phet-page-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.phet-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

.phet-dot.active {
  background: var(--accent-primary);
}

/* Single tab viewport background */
#viewport-single {
  flex: 1;
  position: relative;
  background: radial-gradient(ellipse at center, #12091f 0%, #0a0612 70%);
  margin: 0 12px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--surface-border);
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#viewport-single canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

@media (max-width: 768px) {
  .tab-btn {
    padding: 10px 14px;
    font-size: 13px;
  }
}

/* ===================================================
   Task 8.3 – Viewer Mode Button Styles
   Requirements: 4.1
   =================================================== */

.viewer-mode-btns {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--surface-border);
}

.viewer-mode-btn {
  padding: 8px 16px;
  background: var(--surface-glass);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  font-family: var(--font-sans);
}

.viewer-mode-btn:hover {
  background: var(--surface-glass-hover);
  color: var(--text-primary);
}

.viewer-mode-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* === 3D View Button === */
.btn-3d-view {
  position: absolute;
  bottom: 220px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  z-index: 100;
  transition: transform 0.2s, box-shadow 0.2s;
  font-family: var(--font-sans);
}

.btn-3d-view:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
}

.btn-3d-view:active {
  transform: scale(0.98);
}

/* === Unknown Molecule Label === */
.unknown-molecule-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(245, 158, 11, 0.95);
  color: #000;
  padding: 16px 32px;
  border-radius: var(--radius-lg);
  font-size: 18px;
  font-weight: 700;
  pointer-events: none;
  z-index: 50;
  animation: pulse-warning 2s infinite;
}

@keyframes pulse-warning {
  0%, 100% { opacity: 0.9; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
}

.bond-legend-3d {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--surface-border);
}

.bond-legend-3d .bond-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.bond-legend-3d .bond-line {
  width: 24px;
  height: 3px;
}

.bond-legend-3d .bond-line.double {
  height: 8px;
  background: linear-gradient(to bottom, #888 0%, #888 30%, transparent 30%, transparent 70%, #888 70%);
}

.bond-legend-3d .bond-line.triple {
  height: 10px;
  background: linear-gradient(to bottom, #888 0%, #888 25%, transparent 25%, transparent 45%, #888 45%, #888 55%, transparent 55%, transparent 75%, #888 75%);
}


/* ============================================
   QUIZ MODE STYLES
   ============================================ */

.quiz-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--bg-primary);
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
}

.quiz-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--surface-border);
  padding: 20px;
}

.quiz-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  max-width: 600px;
  margin: 0 auto;
}

.quiz-stat-item {
  text-align: center;
}

.quiz-stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.quiz-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-primary);
}

.quiz-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px 20px 28px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.quiz-molecule-display {
  text-align: center;
  margin-bottom: 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.quiz-molecule-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.quiz-canvas {
  width: 100%;
  max-width: 540px;
  min-height: 240px;
  height: 38vh;
  max-height: 360px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 2px solid var(--surface-border);
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.quiz-canvas canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.quiz-formula {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-primary);
  font-family: 'Courier New', monospace;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: min(100%, 780px);
  margin: 0 auto 20px;
  align-items: stretch;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 2px solid var(--surface-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  min-height: 62px;
  width: 100%;
}

.quiz-option:hover {
  background: var(--surface-glass-hover);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.quiz-option.selected {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.quiz-option.correct {
  background: #10b981;
  border-color: #10b981;
  color: white;
  animation: correctPulse 0.5s ease;
}

.quiz-option.wrong {
  background: #ef4444;
  border-color: #ef4444;
  color: white;
  animation: wrongShake 0.5s ease;
}

.quiz-option.disabled {
  pointer-events: none;
  opacity: 0.6;
}

.quiz-option-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent-primary);
  color: white;
  border-radius: 50%;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.quiz-option.correct .quiz-option-letter,
.quiz-option.wrong .quiz-option-letter {
  background: rgba(255, 255, 255, 0.3);
}

.quiz-option-text {
  flex: 1;
  line-height: 1.35;
}

.quiz-feedback {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
}

.quiz-feedback.show {
  display: flex;
}

.quiz-feedback.correct {
  background: rgba(16, 185, 129, 0.1);
  border: 2px solid #10b981;
  color: #10b981;
}

.quiz-feedback.wrong {
  background: rgba(239, 68, 68, 0.1);
  border: 2px solid #ef4444;
  color: #ef4444;
}

.quiz-feedback-icon {
  font-size: 24px;
}

.quiz-next-btn {
  display: none;
  padding: 8px 24px;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.quiz-next-btn.show {
  display: block;
}

.quiz-next-btn:hover {
  background: var(--accent-primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}

/* Quiz Results */
.quiz-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.quiz-results.hidden {
  display: none;
}

.quiz-results-icon {
  font-size: 80px;
  margin-bottom: 20px;
  animation: bounceIn 0.6s ease, icon-glow 2s ease-in-out infinite;
}

@keyframes icon-glow {
  0%, 100% { 
    filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.4));
  }
  50% { 
    filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.8));
  }
}

.quiz-results-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 40px;
}

.quiz-results-stats {
  display: flex;
  gap: 40px;
  margin-bottom: 40px;
}

.quiz-result-stat {
  text-align: center;
}

.quiz-result-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.quiz-result-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent-primary);
}

.quiz-results-actions {
  display: flex;
  gap: 16px;
}

.quiz-restart-btn,
.quiz-menu-btn {
  padding: 16px 32px;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.quiz-restart-btn {
  background: var(--gradient-accent);
  color: white;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.quiz-restart-btn:hover {
  background: var(--accent-primary-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.quiz-menu-btn {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 2px solid var(--surface-border);
}

.quiz-menu-btn:hover {
  background: var(--surface-glass-hover);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

/* ============================================
   LEARNING MODE STYLES
   ============================================ */

.learn-quiz-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 6, 18, 0.95);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Learn Quiz Section (inside 3D modal) */
.learn-quiz-section {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: 340px;
  margin: 0;
  padding: 14px;
  background: linear-gradient(135deg, rgba(26, 11, 46, 0.97) 0%, rgba(45, 27, 78, 0.97) 100%);
  border-radius: 14px;
  border: 1px solid rgba(102, 126, 234, 0.7);
  backdrop-filter: blur(10px);
  z-index: 100;
  overflow-y: auto;
  pointer-events: auto;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.learn-quiz-header {
  margin-bottom: 10px;
}

.learn-quiz-stats {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.learn-stat-item {
  text-align: center;
  padding: 6px 8px;
  flex: 1;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 6px;
  border: 1px solid rgba(102, 126, 234, 0.3);
}

.learn-stat-label {
  font-size: 10px;
  color: #8b92a8;
  margin-bottom: 3px;
}

.learn-stat-value {
  font-size: 15px;
  font-weight: 700;
  color: #667eea;
}

.learn-quiz-content {
  display: block;
  min-height: 180px;
}

.learn-quiz-results {
  text-align: center;
  padding: 15px;
}

.learn-results-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.learn-results-title {
  font-size: 18px;
  font-weight: 700;
  color: #667eea;
  margin-bottom: 15px;
}

.learn-results-stats {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  margin-bottom: 15px;
}

.learn-result-stat {
  padding: 8px 15px;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(102, 126, 234, 0.3);
}

.learn-result-label {
  font-size: 10px;
  color: #8b92a8;
  margin-bottom: 4px;
}

.learn-result-value {
  font-size: 18px;
  font-weight: 700;
  color: #667eea;
}

.learn-results-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.learn-restart-btn, .learn-menu-btn {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.learn-restart-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.learn-restart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.learn-menu-btn {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.learn-menu-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.learn-instructions {
  text-align: center;
  padding: 40px 20px;
  max-width: 600px;
  margin: 0 auto;
}

.learn-instruction-icon {
  font-size: 64px;
  margin-bottom: 20px;
  animation: bounceIn 0.6s ease;
}

.learn-instructions h3 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
}

.learn-instructions p {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.6;
}

.learn-note {
  font-size: 14px;
  color: var(--accent-primary);
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 30px;
}

.learn-start-btn {
  padding: 16px 48px;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 20px;
}

.learn-start-btn:hover {
  background: var(--accent-primary-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}

.learn-question {
  text-align: center;
  margin-bottom: 12px;
}

.learn-question h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.learn-molecule-display {
  font-size: 30px;
  font-weight: 700;
  color: var(--accent-primary);
  font-family: 'Courier New', monospace;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 2px solid var(--surface-border);
  display: inline-block;
}

.learn-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: 100%;
  margin-bottom: 10px;
}

.learn-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 2px solid var(--surface-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
}

.learn-option:hover {
  background: var(--surface-glass-hover);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.learn-feedback {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

.learn-feedback.show {
  display: flex;
}

.learn-feedback.correct {
  background: rgba(16, 185, 129, 0.1);
  border: 2px solid #10b981;
  color: #10b981;
}

.learn-feedback.wrong {
  background: rgba(239, 68, 68, 0.1);
  border: 2px solid #ef4444;
  color: #ef4444;
}

.learn-feedback-icon {
  font-size: 18px;
}

@media (max-width: 980px) {
  .learn-quiz-section {
    width: 300px;
  }
}

@media (max-width: 768px) {
  .learn-quiz-section {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: 48vh;
  }

}

.learn-feedback-text {
  flex: 1;
}

/* Animations */
@keyframes correctPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

@keyframes bounceIn {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
  .quiz-canvas {
    width: 100%;
    max-width: 100%;
    height: 40vh;
    min-height: 200px;
  }

  .quiz-options {
    grid-template-columns: 1fr;
    width: min(100%, 560px);
  }

  .quiz-stats {
    gap: 20px;
  }

  .quiz-results-stats {
    flex-direction: column;
    gap: 20px;
  }

  .quiz-results-actions {
    flex-direction: column;
    width: 100%;
  }

  .quiz-restart-btn,
  .quiz-menu-btn {
    width: 100%;
  }

  .quiz-content {
    padding: 20px 16px;
  }

  .quiz-molecule-display {
    margin-bottom: 20px;
  }
}

@media (max-width: 480px) {
  .quiz-canvas {
    height: 35vh;
    min-height: 180px;
    border-radius: var(--radius-md);
  }

  .quiz-option {
    padding: 14px 16px;
    font-size: 14px;
    min-height: 56px;
  }

  .quiz-stat-value {
    font-size: 20px;
  }
}


/* ============================================
   SETTINGS PANEL
   ============================================ */

.settings-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
  transition: all 0.3s ease;
  z-index: 1000;
}

.settings-btn:hover {
  transform: scale(1.1) rotate(90deg);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

.settings-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100vh;
  background: linear-gradient(135deg, rgba(18, 9, 31, 0.98) 0%, rgba(26, 15, 46, 0.98) 100%);
  border-left: 1px solid var(--surface-border);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
  transition: right 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 2000;
  overflow-y: auto;
  backdrop-filter: blur(20px);
}

.settings-panel.open {
  right: 0;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--surface-border);
  background: var(--bg-tertiary);
}

.settings-header h3 {
  margin: 0;
  font-size: 20px;
  color: var(--text-primary);
}

.settings-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 20px;
  transition: all 0.2s ease;
}

.settings-close:hover {
  background: var(--surface-glass-hover);
  color: var(--text-primary);
}

.settings-body {
  padding: 20px;
}

.settings-section {
  margin-bottom: 30px;
}

.settings-section h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  color: var(--text-primary);
  font-weight: 600;
}

.settings-item {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-label {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.settings-label input[type="checkbox"],
.settings-label input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--accent-primary);
}

.settings-slider {
  flex: 1;
  margin: 0 12px;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-glass);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.6);
}

.settings-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: none;
}

#volume-value {
  min-width: 40px;
  text-align: right;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Light Theme */
body.light-theme {
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e9ecef;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --surface-border: #dee2e6;
  --surface-glass: rgba(0, 0, 0, 0.05);
  --surface-glass-hover: rgba(0, 0, 0, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
  .settings-panel {
    width: 100%;
    right: -100%;
  }

  .settings-btn {
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
  }
}

/* === Gamification Bar === */
.gamification-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 6px 20px;
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
  border-bottom: 1px solid rgba(139, 92, 246, 0.2);
  flex-shrink: 0;
  overflow-x: auto;
}

.gamification-bar::-webkit-scrollbar {
  display: none;
}

.gamification-bar .header-btn {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.gamification-bar .header-btn:hover {
  background: var(--bg-card);
  border-color: var(--accent-primary);
}

.gamification-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gamification-icon {
  font-size: 18px;
}

.gamification-label {
  color: var(--text-muted);
  font-size: 12px;
}

.gamification-value {
  color: var(--accent-primary);
  font-weight: bold;
  font-size: 14px;
}

.gamification-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 300px;
}

.gamification-progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(139, 92, 246, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.gamification-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #8b5cf6, #6366f1);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.gamification-xp {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

/* Learn Mode Styles */
.learn-content {
  flex: 1;
  padding: 20px;
  text-align: center;
}

.learn-instructions {
  padding: 40px;
}

.learn-instructions p {
  color: var(--text-secondary);
  font-size: 18px;
  margin-bottom: 16px;
}

.learn-question {
  margin-bottom: 30px;
}

.learn-question h3 {
  color: var(--text-primary);
  font-size: 24px;
  margin-bottom: 20px;
}

.learn-molecule-display {
  font-size: 48px;
  font-weight: bold;
  color: var(--accent-primary);
  font-family: 'Courier New', monospace;
  padding: 20px;
  background: rgba(139, 92, 246, 0.1);
  border-radius: var(--radius-lg);
  border: 2px solid var(--accent-primary);
}

.learn-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  max-width: 600px;
  margin: 0 auto 30px;
}

.learn-option {
  padding: 20px;
  background: var(--bg-card);
  border: 2px solid var(--surface-border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.learn-option:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.learn-option.correct {
  background: rgba(34, 197, 94, 0.2);
  border-color: #22c55e;
}

.learn-option.wrong {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
}

.learn-feedback {
  display: none;
  padding: 20px;
  border-radius: var(--radius-lg);
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 20px;
}

.learn-feedback.show {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.learn-feedback.correct {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
  border: 2px solid #22c55e;
}

.learn-feedback.wrong {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 2px solid #ef4444;
}

.learn-results {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.learn-results h2 {
  color: var(--text-primary);
  font-size: 32px;
  margin-bottom: 30px;
}
