* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: #1b130e;
  color: #f3ece6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: -20px;
  z-index: -2;
  background:
    radial-gradient(circle at 45% 45%, rgba(27, 19, 14, 0.65) 0%, rgba(12, 8, 5, 0.85) 100%),
    url('../assets/background.jpg') center / cover no-repeat;
  filter: blur(2px);
  transform: scale(1.03);
  pointer-events: none;
}

#canvas-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  padding: 24px;
  min-width: 0;
  background: transparent;
  perspective: 1100px;
  transition: all 0.3s ease;
}

.petri-dish {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  transform-style: preserve-3d;
  transform: rotateX(18deg) translateY(-32px);
  transition: transform 0.4s ease;
  border: 3px solid rgba(255, 244, 232, 0.36);
  box-shadow:
    0 0 0 1px rgba(255, 230, 205, 0.14),
    0 31px 15px -3px rgba(0, 0, 0, 0.95),
    0 45px 35px -5px rgba(0, 0, 0, 0.9),
    0 42px 50px rgba(0, 0, 0, 0.55),
    0 28px 22px -2px rgba(235, 165, 100, 0.2);
}

.petri-dish::before {
  content: "";
  position: absolute;
  top: 4px;
  left: -3px;
  right: -3px;
  bottom: -18px;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  background: linear-gradient(90deg,
      rgba(255, 242, 228, 0.28) 0%,
      rgba(255, 235, 215, 0.1) 14%,
      rgba(235, 185, 140, 0.05) 50%,
      rgba(255, 235, 215, 0.1) 86%,
      rgba(255, 242, 228, 0.28) 100%);
  border-bottom: 1.5px solid rgba(255, 244, 232, 0.35);
  border-left: 1px solid rgba(255, 244, 232, 0.22);
  border-right: 1px solid rgba(255, 244, 232, 0.22);
  box-shadow:
    inset 0 -2px 5px rgba(255, 240, 220, 0.2),
    inset 0 -8px 14px rgba(235, 175, 115, 0.1);
}

.petri-dish::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  box-shadow:
    inset 0 26px 38px rgba(0, 0, 0, 0.94),
    inset 0 -10px 20px rgba(0, 0, 0, 0.78),
    inset 0 2px 5px rgba(255, 245, 235, 0.45),
    inset 0 -3px 10px rgba(235, 165, 100, 0.24);
  background: radial-gradient(ellipse at 35% 20%,
      rgba(255, 248, 240, 0.1) 0%,
      rgba(255, 245, 235, 0.02) 40%,
      transparent 70%);
}

#petri {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(36, 27, 21, 0.55) 0%, rgba(22, 16, 12, 0.55) 65%, rgba(13, 9, 7, 0.55) 100%);
  cursor: crosshair;
  touch-action: none;
}

#pop-chart {
  width: 100%;
  height: 110px;
  background: #17110d;
  border-radius: 8px;
  border: 1px solid #3a2b22;
  display: block;
  margin-top: 8px;
}

#burger-btn {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 50;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(38, 28, 22, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid #4d392d;
  color: #f3ece6;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

#burger-btn:hover {
  background: #4a372b;
}

#ui {
  width: 320px;
  height: 100dvh;
  margin-right: 24px;
  background: rgba(33, 24, 19, 0.94);
  backdrop-filter: blur(10px);
  border-left: 1px solid #4d392d;
  border-right: 1px solid #4d392d;
  padding: 20px 10px 20px 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 15px;
  overflow-y: auto;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

#ui::-webkit-scrollbar {
  width: 6px;
}

#ui::-webkit-scrollbar-track {
  background: transparent;
  margin: 8px 0;
}

#ui::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 10px;
}

#ui:hover::-webkit-scrollbar-thumb {
  background: rgba(187, 169, 156, 0.25);
}

#ui::-webkit-scrollbar-thumb:hover {
  background: rgba(245, 158, 11, 0.65);
}

#ui {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

#ui:hover {
  scrollbar-color: rgba(187, 169, 156, 0.25) transparent;
}

#ui.closed {
  transform: translateX(100%);
  margin-right: -320px;
}

.ui-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#close-ui-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 16px;
  background: #2b1f18;
  border: 1px solid #453328;
  color: #bba99c;
}

h2 {
  margin: 0 0 5px 0;
  font-size: 16px;
  color: #f59e0b;
}

.control-group {
  background: #291e17;
  border: 1px solid #382920;
  padding: 12px;
  border-radius: 10px;
}

label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 5px;
  color: #e2d6cc;
}

input[type="range"] {
  width: 100%;
  accent-color: #f59e0b;
  height: 24px;
  margin-bottom: 6px;
  cursor: pointer;
}

.tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

button {
  padding: 10px 8px;
  background: #36271e;
  border: 1px solid #4d392d;
  color: #f3ece6;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  transition: 0.2s;
}

button.active {
  background: linear-gradient(135deg, #b45309, #d97706) !important;
  border-color: #fbbf24 !important;
  color: #fff !important;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.4);
}

button:hover {
  background: #473428;
}

.stats {
  font-size: 12px;
  line-height: 1.6;
  color: #bba99c;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}

#pause-btn {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 50;
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  background: rgba(38, 28, 22, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid #4d392d;
  color: #f3ece6;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

#pause-btn:hover {
  background: #4a372b;
}

#pause-btn.paused {
  background: rgba(217, 119, 6, 0.9);
  border-color: #fbbf24;
  color: #fff;
}

#cell-inspector {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 250px;
  background: rgba(33, 24, 19, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid #4d392d;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12px;
  color: #f3ece6;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65);
  z-index: 60;
  display: none;
}

#cell-inspector.visible {
  display: block;
}

.inspector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #3d2e24;
  padding-bottom: 6px;
  margin-bottom: 8px;
  font-weight: 600;
  color: #f59e0b;
}

#close-inspector {
  background: none;
  border: none;
  color: #bba99c;
  cursor: pointer;
  padding: 0 4px;
  font-size: 14px;
}

.gene-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  color: #bba99c;
}

.gene-row b {
  color: #f3ece6;
}

@media (max-width: 768px) {
  #canvas-container {
    padding: 8px;
  }

  #ui {
    position: fixed;
    top: 0;
    right: 0;
    height: 100dvh;
    width: 86vw;
    max-width: 340px;
    padding: 20px;
    margin-right: 0 !important;
    background: rgba(33, 24, 19, 0.96);
    border-right: 0;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.75);
  }

  #ui.closed {
    transform: translateX(100%);
  }

  button {
    padding: 12px 8px;
    font-size: 13px;
  }
}
